term = $term; $this->taxonomy = $taxonomy; $this->taxonomy_tab_content = new WPSEO_Taxonomy_Fields_Presenter( $this->term ); add_action( 'admin_footer', array( $this, 'template_generic_tab' ) ); add_action( 'admin_footer', array( $this, 'template_keyword_tab' ) ); } /** * Shows the Yoast SEO metabox for the term. */ public function display() { $content_sections = $this->get_content_sections(); $product_title = 'Yoast SEO'; if ( file_exists( WPSEO_PATH . 'premium/' ) ) { $product_title .= ' Premium'; } printf( '
'; } /** * Returns the relevant metabox sections for the current view. * * @return WPSEO_Metabox_Section[] */ private function get_content_sections() { $content_sections = array( $this->get_content_meta_section(), $this->get_social_meta_section(), $this->get_settings_meta_section(), ); if ( ! defined( 'WPSEO_PREMIUM_FILE' ) ) { $content_sections[] = $this->get_buy_premium_section(); } return $content_sections; } /** * Returns the metabox section for the content analysis. * * @return WPSEO_Metabox_Section */ private function get_content_meta_section() { $taxonomy_content_fields = new WPSEO_Taxonomy_Content_Fields( $this->term ); $content = $this->taxonomy_tab_content->html( $taxonomy_content_fields->get() ); $tab = new WPSEO_Metabox_Form_Tab( 'content', $content, __( '', 'wordpress-seo' ), array( 'tab_class' => 'yoast-seo__remove-tab', ) ); return new WPSEO_Metabox_Tab_Section( 'content', '' . __( 'Content optimization', 'wordpress-seo' ) . '' . $this->traffic_light_svg() . '', array( $tab ), array( 'link_aria_label' => __( 'Content optimization', 'wordpress-seo' ), 'link_class' => 'yoast-tooltip yoast-tooltip-e', ) ); } /** * Returns the metabox section for the settings. * * @return WPSEO_Metabox_Section */ private function get_settings_meta_section() { $taxonomy_settings_fields = new WPSEO_Taxonomy_Settings_Fields( $this->term ); $content = $this->taxonomy_tab_content->html( $taxonomy_settings_fields->get() ); $tab = new WPSEO_Metabox_Form_Tab( 'settings', $content, __( 'Settings', 'wordpress-seo' ), array( 'single' => true, ) ); return new WPSEO_Metabox_Tab_Section( 'settings', '' . __( 'Settings', 'wordpress-seo' ) . '', array( $tab ), array( 'link_aria_label' => __( 'Settings', 'wordpress-seo' ), 'link_class' => 'yoast-tooltip yoast-tooltip-e', ) ); } /** * Returns the metabox section for the social settings. * * @return WPSEO_Metabox_Section */ private function get_social_meta_section() { $options = WPSEO_Options::get_option( 'wpseo_social' ); $taxonomy_social_fields = new WPSEO_Taxonomy_Social_Fields( $this->term ); $tabs = array(); $single = true; if ( $options['opengraph'] === true && $options['twitter'] === true ) { $single = null; } if ( $options['opengraph'] === true ) { $facebook_meta_fields = $taxonomy_social_fields->get_by_network( 'opengraph' ); $tabs[] = new WPSEO_Metabox_Form_Tab( 'facebook', $this->taxonomy_tab_content->html( $facebook_meta_fields ), '' . __( 'Facebook / Open Graph metadata', 'wordpress-seo' ) . '', array( 'link_aria_label' => __( 'Facebook / Open Graph metadata', 'wordpress-seo' ), 'link_class' => 'yoast-tooltip yoast-tooltip-se', 'single' => $single, ) ); } if ( $options['twitter'] === true ) { $twitter_meta_fields = $taxonomy_social_fields->get_by_network( 'twitter' ); $tabs[] = new WPSEO_Metabox_Form_Tab( 'twitter', $this->taxonomy_tab_content->html( $twitter_meta_fields ), '' . __( 'Twitter metadata', 'wordpress-seo' ) . '', array( 'link_aria_label' => __( 'Twitter metadata', 'wordpress-seo' ), 'link_class' => 'yoast-tooltip yoast-tooltip-se', 'single' => $single, ) ); } return new WPSEO_Metabox_Tab_Section( 'social', '' . __( 'Social', 'wordpress-seo' ) . '', $tabs, array( 'link_aria_label' => __( 'Social', 'wordpress-seo' ), 'link_class' => 'yoast-tooltip yoast-tooltip-e', ) ); } /** * Returns a link to activate the Buy Premium tab. * * @return string */ private function get_buy_premium_link() { return sprintf( "", 'wpseo-metabox-buy-premium', __( 'Go Premium', 'wordpress-seo' ) ); } /** * Returns the metabox section for the Premium section.. * * @return WPSEO_Metabox_Section */ private function get_buy_premium_section() { $content = sprintf( " ", __( 'You\'re not getting the benefits of Yoast SEO Premium yet. If you had Yoast SEO Premium, you could use its awesome features:', 'wordpress-seo' ), __( 'Redirect manager', 'wordpress-seo' ), __( 'Create and manage redirects within your WordPress install.', 'wordpress-seo' ), __( 'Multiple focus keywords', 'wordpress-seo' ), __( 'Optimize a single post for up to 5 keywords.', 'wordpress-seo' ), __( 'Social Previews', 'wordpress-seo' ), __( 'Check what your Facebook or Twitter post will look like.', 'wordpress-seo' ), __( 'Premium support', 'wordpress-seo' ), __( 'Gain access to our 24/7 support team.', 'wordpress-seo' ), 'https://yoa.st/pe-buy-premium', __( 'Get Yoast SEO Premium now!', 'wordpress-seo' ), 'https://yoa.st/pe-premium-page', __( 'More info', 'wordpress-seo' ) ); $tab = new WPSEO_Metabox_Form_Tab( 'premium', $content, 'Yoast SEO Premium', array( 'single' => true, ) ); return new WPSEO_Metabox_Tab_Section( 'premium', '', array( $tab ), array( 'link_aria_label' => 'Yoast SEO Premium', 'link_class' => 'yoast-tooltip yoast-tooltip-e', ) ); } /** * Test whether we are on a public taxonomy - no metabox actions needed if we are not * Unfortunately we have to hook most everything in before the point where all taxonomies are registered and * we know which taxonomy is being requested, so we need to use this check in nearly every hooked in function. * * @since 1.5.0 */ private function tax_is_public() { // Don't make static as taxonomies may still be added during the run. $taxonomy = get_taxonomy( $this->taxonomy ); return $taxonomy->public; } /** * Return the SVG for the traffic light in the metabox. */ public function traffic_light_svg() { return << SVG; } /** * Generic tab. */ public function template_generic_tab() { // This template belongs to the post scraper so don't echo it if it isn't enqueued. if ( ! wp_script_is( WPSEO_Admin_Asset_Manager::PREFIX . 'term-scraper' ) ) { return; } echo ''; } /** * Keyword tab for enabling analysis of multiple keywords. */ public function template_keyword_tab() { // This template belongs to the term scraper so don't echo it if it isn't enqueued. if ( ! wp_script_is( WPSEO_Admin_Asset_Manager::PREFIX . 'term-scraper' ) ) { return; } echo ''; } }