function enqueue_styles()
 {
     if (is_admin()) {
         return;
     }
     // The user chooses a grid.
     $versions = array('grid960' => '20110221', 'grid720' => '20110221');
     $grid = wcb_get_option('grid');
     // Check whethec Custom CSS mode is set to Add or Replace.
     if (class_exists('Jetpack_Custom_CSS') && method_exists('Jetpack_Custom_CSS', 'get_current_revision')) {
         $safecss_post = Jetpack_Custom_CSS::get_current_revision();
         if (get_post_meta($safecss_post['ID'], 'custom_css_add', true) == 'no') {
             return;
         }
     }
     $start_fresh = apply_filters('wcb_start_fresh', false);
     $child_recs = array();
     if (!$start_fresh) {
         wp_enqueue_style('wcb-foundation', WCB_URL . '/style.css', array(), '20110212');
         $version = isset($versions[$grid]) ? $versions[$grid] : false;
         wp_enqueue_style("wcb-{$grid}", wcb_dev_url(WCB_URL . "/css/{$grid}.css"), array('wcb-foundation'), $version);
         wp_enqueue_style("wcb-style", wcb_dev_url(WCB_URL . '/css/default.css'), array('wcb-foundation', "wcb-{$grid}"), '20110421');
         $child_recs = array('wcb-foundation', "wcb-{$grid}", 'wcb-style');
     }
     if (is_child_theme()) {
         $child_version = apply_filters('wcb_child_css_version', false);
         wp_enqueue_style("wcb-child", get_stylesheet_uri(), $child_recs, $child_version);
     }
 }
Exemple #2
0
 /**
  * Override the content_width with a custom value if one is set.
  */
 static function jetpack_content_width($content_width)
 {
     $custom_content_width = 0;
     if (Jetpack_Custom_CSS::is_preview()) {
         $safecss_post = Jetpack_Custom_CSS::get_current_revision();
         $custom_content_width = intval(get_post_meta($safecss_post['ID'], 'content_width', true));
     } else {
         if (!Jetpack_Custom_CSS::is_freetrial()) {
             $custom_css_post_id = Jetpack_Custom_CSS::post_id();
             if ($custom_css_post_id) {
                 $custom_content_width = intval(get_post_meta($custom_css_post_id, 'content_width', true));
             }
         }
     }
     if ($custom_content_width > 0) {
         $content_width = $custom_content_width;
     }
     return $content_width;
 }
Exemple #3
0
 /**
  * Migration routine for moving safecss from wp_options to wp_posts to support revisions
  *
  * @return void
  */
 static function upgrade()
 {
     $css = get_option('safecss');
     // Check if CSS is stored in wp_options
     if ($css) {
         // Remove the async actions from publish_post
         remove_action('publish_post', 'queue_publish_post');
         $post = array();
         $post['post_content'] = $css;
         $post['post_title'] = 'safecss';
         $post['post_status'] = 'publish';
         $post['post_type'] = 'safecss';
         // Insert the CSS into wp_posts
         $post_id = wp_insert_post($post);
         // Check for errors
         if (!$post_id or is_wp_error($post_id)) {
             die($post_id->get_error_message());
         }
         // Delete safecss option
         delete_option('safecss');
     }
     unset($css);
     // Check if we have already done this
     if (!get_option('safecss_revision_migrated')) {
         define('DOING_MIGRATE', true);
         // Get hashes of safecss post and current revision
         $safecss_post = Jetpack_Custom_CSS::get_post();
         if (empty($safecss_post)) {
             return;
         }
         $safecss_post_hash = md5($safecss_post['post_content']);
         $current_revision = Jetpack_Custom_CSS::get_current_revision();
         if (null == $current_revision) {
             return;
         }
         $current_revision_hash = md5($current_revision['post_content']);
         // If hashes are not equal, set safecss post with content from current revision
         if ($safecss_post_hash !== $current_revision_hash) {
             Jetpack_Custom_CSS::save_revision($current_revision['post_content']);
             // Reset post_content to display the migrated revsion
             $safecss_post['post_content'] = $current_revision['post_content'];
         }
         // Set option so that we dont keep doing this
         update_option('safecss_revision_migrated', time());
     }
     $newest_safecss_post = Jetpack_Custom_CSS::get_current_revision();
     if ($newest_safecss_post) {
         if (get_option('safecss_content_width')) {
             // Add the meta to the post and the latest revision.
             update_post_meta($newest_safecss_post['ID'], 'content_width', get_option('safecss_content_width'));
             update_metadata('post', $newest_safecss_post['ID'], 'content_width', get_option('safecss_content_width'));
             delete_option('safecss_content_width');
         }
         if (get_option('safecss_add')) {
             update_post_meta($newest_safecss_post['ID'], 'custom_css_add', get_option('safecss_add'));
             update_metadata('post', $newest_safecss_post['ID'], 'custom_css_add', get_option('safecss_add'));
             delete_option('safecss_add');
         }
     }
 }