| @@ -6,8 +6,11 @@ | ||
| 6 | 6 | * |
| 7 | 7 | * @uses Yoast_Form $yform Form object. |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | +use Yoast\WP\SEO\Presenters\Admin\Beta_Badge_Presenter; | |
| 11 | +use Yoast\WP\SEO\Presenters\Admin\Premium_Badge_Presenter; | |
| 12 | + | |
| 10 | 13 | if ( ! defined( 'WPSEO_VERSION' ) ) { |
| 11 | 14 | header( 'Status: 403 Forbidden' ); |
| 12 | 15 | header( 'HTTP/1.1 403 Forbidden' ); |
| 13 | 16 | exit(); |
| @@ -18,35 +21,74 @@ | ||
| 18 | 21 | ?> |
| 19 | 22 | <h2><?php esc_html_e( 'Features', 'wordpress-seo' ); ?></h2> |
| 20 | 23 | <div class="yoast-measure"> |
| 21 | 24 | <?php |
| 22 | - echo sprintf( | |
| 25 | + printf( | |
| 23 | 26 | /* translators: %s expands to Yoast SEO */ |
| 24 | 27 | esc_html__( 'This tab allows you to selectively disable %s features for all sites in the network. By default all features are enabled, which allows site admins to choose for themselves if they want to toggle a feature on or off for their site. When you disable a feature here, site admins will not be able to use that feature at all.', 'wordpress-seo' ), |
| 25 | - 'Yoast SEO' | |
| 28 | + 'Yoast SEO', | |
| 26 | 29 | ); |
| 27 | 30 | |
| 28 | 31 | foreach ( $feature_toggles as $feature ) { |
| 32 | + $is_premium = YoastSEO()->helpers->product->is_premium(); | |
| 33 | + $premium_version = YoastSEO()->helpers->product->get_premium_version(); | |
| 34 | + | |
| 35 | + if ( $feature->premium && $feature->premium_version ) { | |
| 36 | + $not_supported_in_current_premium_version = $is_premium && version_compare( $premium_version, $feature->premium_version, '<' ); | |
| 37 | + | |
| 38 | + if ( $not_supported_in_current_premium_version ) { | |
| 39 | + continue; | |
| 40 | + } | |
| 41 | + } | |
| 42 | + | |
| 29 | 43 | $help_text = esc_html( $feature->label ); |
| 30 | 44 | if ( ! empty( $feature->extra ) ) { |
| 31 | 45 | $help_text .= ' ' . $feature->extra; |
| 32 | 46 | } |
| 33 | 47 | if ( ! empty( $feature->read_more_label ) ) { |
| 34 | - $help_text .= ' '; | |
| 48 | + $url = $feature->read_more_url; | |
| 49 | + if ( ! empty( $feature->premium ) && $feature->premium === true ) { | |
| 50 | + $url = $feature->premium_url; | |
| 51 | + } | |
| 35 | 52 | $help_text .= sprintf( |
| 36 | 53 | '<a href="%1$s" target="_blank" rel="noopener noreferrer">%2$s</a>', |
| 37 | - esc_url( WPSEO_Shortlinker::get( $feature->read_more_url ) ), | |
| 38 | - esc_html( $feature->read_more_label ) | |
| 54 | + esc_url( WPSEO_Shortlinker::get( $url ) ), | |
| 55 | + esc_html( $feature->read_more_label ), | |
| 39 | 56 | ); |
| 40 | 57 | } |
| 41 | 58 | |
| 42 | 59 | $feature_help = new WPSEO_Admin_Help_Panel( |
| 43 | 60 | WPSEO_Option::ALLOW_KEY_PREFIX . $feature->setting, |
| 44 | - /* translators: %s expands to a feature's name */ | |
| 61 | + /* translators: Hidden accessibility text; %s expands to a feature's name. */ | |
| 45 | 62 | sprintf( esc_html__( 'Help on: %s', 'wordpress-seo' ), esc_html( $feature->name ) ), |
| 46 | - $help_text | |
| 63 | + $help_text, | |
| 47 | 64 | ); |
| 48 | 65 | |
| 66 | + $name = $feature->name; | |
| 67 | + if ( ! empty( $feature->premium ) && $feature->premium === true ) { | |
| 68 | + $name .= ' ' . new Premium_Badge_Presenter( $feature->name ); | |
| 69 | + } | |
| 70 | + | |
| 71 | + if ( ! empty( $feature->in_beta ) && $feature->in_beta === true ) { | |
| 72 | + $name .= ' ' . new Beta_Badge_Presenter( $feature->name ); | |
| 73 | + } | |
| 74 | + | |
| 75 | + $disabled = false; | |
| 76 | + $show_premium_upsell = false; | |
| 77 | + $premium_upsell_url = ''; | |
| 78 | + $note_when_disabled = ''; | |
| 79 | + | |
| 80 | + if ( $feature->premium === true && YoastSEO()->helpers->product->is_premium() === false ) { | |
| 81 | + $disabled = true; | |
| 82 | + $show_premium_upsell = true; | |
| 83 | + $premium_upsell_url = WPSEO_Shortlinker::get( $feature->premium_upsell_url ); | |
| 84 | + } | |
| 85 | + | |
| 86 | + $preserve_disabled_value = false; | |
| 87 | + if ( $disabled ) { | |
| 88 | + $preserve_disabled_value = true; | |
| 89 | + } | |
| 90 | + | |
| 49 | 91 | $yform->toggle_switch( |
| 50 | 92 | WPSEO_Option::ALLOW_KEY_PREFIX . $feature->setting, |
| 51 | 93 | [ |
| 52 | 94 | 'on' => __( 'Allow Control', 'wordpress-seo' ), |
| @@ -51,10 +93,17 @@ | ||
| 51 | 93 | [ |
| 52 | 94 | 'on' => __( 'Allow Control', 'wordpress-seo' ), |
| 53 | 95 | 'off' => __( 'Disable', 'wordpress-seo' ), |
| 54 | 96 | ], |
| 55 | - $feature->name, | |
| 56 | - $feature_help->get_button_html() . $feature_help->get_panel_html() | |
| 97 | + $name, | |
| 98 | + $feature_help->get_button_html() . $feature_help->get_panel_html(), | |
| 99 | + [ | |
| 100 | + 'disabled' => $disabled, | |
| 101 | + 'preserve_disabled_value' => $preserve_disabled_value, | |
| 102 | + 'show_premium_upsell' => $show_premium_upsell, | |
| 103 | + 'premium_upsell_url' => $premium_upsell_url, | |
| 104 | + 'note_when_disabled' => $note_when_disabled, | |
| 105 | + ], | |
| 57 | 106 | ); |
| 58 | 107 | } |
| 59 | 108 | ?> |
| 60 | 109 | </div> |