/** * Constructor. */ public function __construct() { add_action('admin_footer', array($this, 'wp_footer'), 10); add_action('admin_enqueue_scripts', array($this, 'enqueue_assets')); add_action('save_post', array($this, 'save_primary_terms')); $primary_term = new WPSEO_Frontend_Primary_Category(); $primary_term->register_hooks(); }
/** * Class constructor * * Adds and removes a lot of filters. */ protected function __construct() { $this->options = WPSEO_Options::get_options($this->required_options); add_action('wp_head', array($this, 'front_page_specific_init'), 0); add_action('wp_head', array($this, 'head'), 1); // The head function here calls action wpseo_head, to which we hook all our functionality. add_action('wpseo_head', array($this, 'debug_marker'), 2); add_action('wpseo_head', array($this, 'metadesc'), 6); add_action('wpseo_head', array($this, 'robots'), 10); add_action('wpseo_head', array($this, 'metakeywords'), 11); add_action('wpseo_head', array($this, 'canonical'), 20); add_action('wpseo_head', array($this, 'adjacent_rel_links'), 21); add_action('wpseo_head', array($this, 'publisher'), 22); // Remove actions that we will handle through our wpseo_head call, and probably change the output of. remove_action('wp_head', 'rel_canonical'); remove_action('wp_head', 'index_rel_link'); remove_action('wp_head', 'start_post_rel_link'); remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); remove_action('wp_head', 'noindex', 1); // When using WP 4.4, just use the new hook. add_filter('pre_get_document_title', array($this, 'title'), 15); add_filter('wp_title', array($this, 'title'), 15, 3); add_filter('thematic_doctitle', array($this, 'title'), 15); add_action('wp', array($this, 'page_redirect'), 99); add_action('template_redirect', array($this, 'noindex_feed')); add_filter('loginout', array($this, 'nofollow_link')); add_filter('register', array($this, 'nofollow_link')); // Fix the WooThemes woo_title() output. add_filter('woo_title', array($this, 'fix_woo_title'), 99); if ($this->options['disable-date'] === true || $this->options['disable-author'] === true || $this->options['disable-post_format'] === true) { add_action('wp', array($this, 'archive_redirect')); } if ($this->options['redirectattachment'] === true) { add_action('template_redirect', array($this, 'attachment_redirect'), 1); } /* * The setting to get here has been deprecated, but don't remove the code as that would break * the functionality for those that still have it! */ if ($this->options['trailingslash'] === true) { add_filter('user_trailingslashit', array($this, 'add_trailingslash'), 10, 2); } if ($this->options['cleanpermalinks'] === true) { add_action('template_redirect', array($this, 'clean_permalink'), 1); } if ($this->options['cleanreplytocom'] === true) { add_filter('comment_reply_link', array($this, 'remove_reply_to_com')); add_action('template_redirect', array($this, 'replytocom_redirect'), 1); } add_filter('the_content_feed', array($this, 'embed_rssfooter')); add_filter('the_excerpt_rss', array($this, 'embed_rssfooter_excerpt')); // For WordPress functions below 4.4. if (!current_theme_supports('title-tag') && $this->options['forcerewritetitle'] === true) { add_action('template_redirect', array($this, 'force_rewrite_output_buffer'), 99999); add_action('wp_footer', array($this, 'flush_cache'), -1); } if ($this->options['title_test'] > 0) { add_filter('wpseo_title', array($this, 'title_test_helper')); } $primary_category = new WPSEO_Frontend_Primary_Category(); $primary_category->register_hooks(); $this->hooks = array($primary_category); }