Esempio n. 1
0
 public static function prepare()
 {
     self::$is_html5 = Genesis_Club_Utils::is_html5();
     self::$post_id = Genesis_Club_Utils::get_post_id();
     //get post/page id
     self::$is_landing = Genesis_Club_Utils::is_landing_page();
     if (self::get_option('remove_blog_title')) {
         remove_all_actions('genesis_site_description');
         add_filter('genesis_seo_title', array(__CLASS__, 'blog_title_notext'), 11, 3);
     }
     if (self::get_option('read_more_text')) {
         add_filter('excerpt_more', array(__CLASS__, 'read_more_link'));
         add_filter('get_the_content_more_link', array(__CLASS__, 'read_more_link'));
         add_filter('the_content_more_link', array(__CLASS__, 'read_more_link'));
         add_filter('genesis_grid_loop_args', array(__CLASS__, 'set_read_more_text'));
         //Add a Read More for hand crafted excerpts
         if (is_archive()) {
             add_filter('the_excerpt', array(__CLASS__, 'add_read_more_link'), 30);
         }
     }
     if (self::get_option('comment_invitation')) {
         add_filter(self::$is_html5 ? 'comment_form_defaults' : 'genesis_comment_form_args', array(__CLASS__, 'comment_form_args'), 20);
     }
     if (self::get_option('comment_notes_hide')) {
         add_filter(self::$is_html5 ? 'comment_form_defaults' : 'genesis_comment_form_args', array(__CLASS__, 'comment_notes_hide'), 20);
     }
     if (is_archive() || is_singular() || is_front_page() || is_home()) {
         add_filter('genesis_breadcrumb_args', array(__CLASS__, 'filter_breadcrumb_args'));
     }
     if (self::get_option(self::BGCOLOR_KEY) || self::get_option(self::BORDER_KEY)) {
         add_action('wp_print_footer_scripts', array(__CLASS__, 'change_likebox_bgcolor'), 100);
     }
     if (is_singular()) {
         //remove or hide stuff
         if (get_post_meta(self::$post_id, self::HIDE_TITLE_METAKEY, true)) {
             add_filter('genesis_post_title_text', '__return_empty_string', 100);
         }
         if (get_post_meta(self::$post_id, self::DISABLE_AUTOP_METAKEY, true)) {
             remove_filter('the_content', 'wpautop');
         }
         if (get_post_meta(self::$post_id, self::DISABLE_BREADCRUMBS, true)) {
             add_filter('genesis_pre_get_option_breadcrumb_' . (is_page() ? 'page' : 'single'), '__return_false', 10, 2);
         }
     }
     if (self::get_option('before_content')) {
         add_action('genesis_before_content_sidebar_wrap', array(__CLASS__, 'show_before_content_sidebar'));
     }
     if (self::get_option('after_content')) {
         add_action('genesis_after_content_sidebar_wrap', array(__CLASS__, 'show_after_content_sidebar'));
     }
     if (is_single()) {
         //insert widgets before and after entries or entry content
         if (self::should_show_sidebar('before_entry')) {
             add_action(self::$is_html5 ? 'genesis_before_entry' : 'genesis_before_post', array(__CLASS__, 'show_before_entry_sidebar'));
         }
         if (self::should_show_sidebar('after_entry')) {
             add_action(self::$is_html5 ? 'genesis_after_entry' : 'genesis_after_post', array(__CLASS__, 'show_after_entry_sidebar'));
         }
         if (self::should_show_sidebar('before_entry_content')) {
             add_action(self::$is_html5 ? 'genesis_before_entry_content' : 'genesis_after_post_title', array(__CLASS__, 'show_before_entry_content_sidebar'));
         }
         if (self::should_show_sidebar('after_entry_content')) {
             add_action(self::$is_html5 ? 'genesis_after_entry_content' : 'genesis_after_post_content', array(__CLASS__, 'show_after_entry_content_sidebar'));
         }
     }
     if (is_archive()) {
         //insert widgets before and after entry archives
         add_filter('genesis_term_intro_text_output', 'do_shortcode', 11);
         //convert shortcode in toppers
         if (self::get_option('before_archive')) {
             add_action('genesis_before_loop', array(__CLASS__, 'show_before_archive_sidebar'));
         }
         if (self::get_option('after_archive')) {
             add_action('genesis_after_loop', array(__CLASS__, 'show_after_archive_sidebar'));
         }
     }
     if (is_front_page()) {
         add_action(self::$is_html5 ? 'genesis_before_entry' : 'genesis_before_post', array(__CLASS__, 'maybe_replace_category_images'));
     }
     if (self::get_option('no_page_postmeta') && (is_page() || is_front_page())) {
         //remove postinfo and postmeta on pages
         self::replace_postinfo(false);
         self::replace_postmeta(false);
     } elseif (($postinfo = self::get_option('postinfo_shortcodes')) && (is_single() || is_page() && !self::$is_landing)) {
         //replace postinfo
         self::replace_postinfo($postinfo);
     }
     if (($postmeta = self::get_option('postmeta_shortcodes')) && is_single()) {
         //replace postmeta on posts
         self::replace_postmeta($postmeta);
     }
     if (is_single() && is_active_widget(false, false, 'genesis-club-post-image-gallery', false)) {
         add_thickbox();
     }
     if (is_active_widget(false, false, 'genesis-club-likebox', false)) {
         add_action('genesis_before', array(__CLASS__, 'add_fb_root'));
     }
     if (self::$is_landing) {
         //disable breadcrumbs on landing pages
         add_filter('genesis_pre_get_option_breadcrumb_page', '__return_false');
     }
     if (self::get_option('alt_404_page')) {
         add_filter('template_redirect', array(__CLASS__, 'maybe_redirect_404'), 20);
     }
     if (self::get_option('disable_emojis')) {
         self::disable_emojis();
     }
     add_action('wp_enqueue_scripts', array(__CLASS__, 'enqueue_styles'));
 }