product_helper = $product_helper; } /** * Returns the conditionals based in which this loadable should be active. * * In this case: when on an admin page. */ public static function get_conditionals() { return [ Admin_Conditional::class ]; } /** * Registers an action to add a new tab to the General page. */ public function register_hooks() { \add_action( 'wpseo_settings_tabs_dashboard', [ $this, 'add_crawl_settings_tab' ] ); if ( ! $this->product_helper->is_premium() || ! $this->is_premium_upgraded() ) { \add_action( 'wpseo_settings_tab_crawl_cleanup', [ $this, 'add_crawl_settings_tab_content' ] ); \add_action( 'wpseo_settings_tab_crawl_cleanup_network', [ $this, 'add_crawl_settings_tab_content_network' ] ); } } /** * Checks if Premium is installed and upgraded to the right version. * * @return bool Whether Premium is installed and upgraded to the right version. */ public function is_premium_upgraded() { $premium_version = $this->product_helper->get_premium_version(); return $premium_version !== null && \version_compare( $premium_version, '18.6-RC1', '>=' ); } /** * Adds a dedicated tab in the General sub-page. * * @param WPSEO_Option_Tabs $dashboard_tabs Object representing the tabs of the General sub-page. */ public function add_crawl_settings_tab( $dashboard_tabs ) { $premium = $this->product_helper->is_premium() && $this->is_premium_upgraded(); $dashboard_tabs->add_tab( new WPSEO_Option_Tab( 'crawl-settings', \__( 'Crawl settings', 'wordpress-seo' ), [ 'save_button' => $premium, 'beta' => $premium, 'premium' => ! $premium, ] ) ); } /** * Adds content to the Crawl Cleanup tab. * * @param Yoast_Form $yform The yoast form object. */ public function add_crawl_settings_tab_content( $yform ) { $this->display_premium_upsell_btn(); $yform->toggle_switch( 'remove_feed_post_comments_free', [ 'off' => __( 'Keep', 'wordpress-seo' ), 'on' => __( 'Remove', 'wordpress-seo' ), ], __( 'Post comment feeds', 'wordpress-seo' ), '', [ 'disabled' => true, ] ); } /** * Adds content to the Crawl Cleanup network tab. * * @param Yoast_Form $yform The yoast form object. */ public function add_crawl_settings_tab_content_network( $yform ) { $this->display_premium_upsell_btn(); $yform->toggle_switch( WPSEO_Option::ALLOW_KEY_PREFIX . 'remove_feed_post_comments_free', [ 'on' => __( 'Allow Control', 'wordpress-seo' ), 'off' => __( 'Disable', 'wordpress-seo' ), ], __( 'Post comment feeds', 'wordpress-seo' ), '', [ 'disabled' => true, ] ); } /** * Displays the Premium upsell button. */ public function display_premium_upsell_btn() { echo ''; $button_msg = ( $this->product_helper->is_premium() && ! $this->is_premium_upgraded() ) ? \esc_html__( 'Upgrade Premium', 'wordpress-seo' ) : \esc_html__( 'Unlock with Premium', 'wordpress-seo' ); // phpcs:ignore WordPress.Security.EscapeOutput -- Already escaped. echo $button_msg // phpcs:ignore WordPress.Security.EscapeOutput -- Already escapes correctly. . WPSEO_Admin_Utils::get_new_tab_message(); echo ''; } }