| 1 |
<?php |
| 2 |
/** |
| 3 |
* WPSEO plugin file. |
| 4 |
* |
| 5 |
* @package WPSEO\Admin\Views |
| 6 |
* |
| 7 |
* @uses Yoast_Form $yform Form object. |
| 8 |
*/ |
| 9 |
|
| 10 |
use Yoast\WP\SEO\Presenters\Admin\Premium_Badge_Presenter; |
| 11 |
|
| 12 |
if ( ! defined( 'WPSEO_VERSION' ) ) { |
| 13 |
header( 'Status: 403 Forbidden' ); |
| 14 |
header( 'HTTP/1.1 403 Forbidden' ); |
| 15 |
exit(); |
| 16 |
} |
| 17 |
|
| 18 |
$feature_toggles = Yoast_Feature_Toggles::instance()->get_all(); |
| 19 |
|
| 20 |
?> |
| 21 |
<h2><?php esc_html_e( 'Features', 'wordpress-seo' ); ?></h2> |
| 22 |
<div class="yoast-measure"> |
| 23 |
<?php |
| 24 |
echo sprintf( |
| 25 |
/* translators: %1$s expands to Yoast SEO */ |
| 26 |
esc_html__( '%1$s comes with a lot of features. You can enable / disable some of them below. Clicking the question mark gives more information about the feature.', 'wordpress-seo' ), |
| 27 |
'Yoast SEO' |
| 28 |
); |
| 29 |
|
| 30 |
foreach ( $feature_toggles as $feature ) { |
| 31 |
$help_text = esc_html( $feature->label ); |
| 32 |
if ( ! empty( $feature->extra ) ) { |
| 33 |
$help_text .= ' ' . $feature->extra; |
| 34 |
} |
| 35 |
if ( ! empty( $feature->read_more_label ) ) { |
| 36 |
$url = $feature->read_more_url; |
| 37 |
if ( ! empty( $feature->premium ) && $feature->premium === true ) { |
| 38 |
$url = $feature->premium_url; |
| 39 |
} |
| 40 |
$help_text .= ' '; |
| 41 |
$help_text .= sprintf( |
| 42 |
'<a href="%1$s" target="_blank" rel="noopener noreferrer">%2$s</a>', |
| 43 |
esc_url( WPSEO_Shortlinker::get( $url ) ), |
| 44 |
esc_html( $feature->read_more_label ) |
| 45 |
); |
| 46 |
} |
| 47 |
|
| 48 |
$feature_help = new WPSEO_Admin_Help_Panel( |
| 49 |
$feature->setting, |
| 50 |
/* translators: %s expands to a feature's name */ |
| 51 |
sprintf( esc_html__( 'Help on: %s', 'wordpress-seo' ), esc_html( $feature->name ) ), |
| 52 |
$help_text |
| 53 |
); |
| 54 |
|
| 55 |
$name = $feature->name; |
| 56 |
if ( ! empty( $feature->premium ) && $feature->premium === true ) { |
| 57 |
$name .= ' ' . new Premium_Badge_Presenter( $feature->name ); |
| 58 |
} |
| 59 |
|
| 60 |
$disabled = false; |
| 61 |
if ( $feature->premium === true && YoastSEO()->helpers->product->is_premium() === false ) { |
| 62 |
$disabled = true; |
| 63 |
} |
| 64 |
|
| 65 |
$yform->toggle_switch( |
| 66 |
$feature->setting, |
| 67 |
[ |
| 68 |
'on' => __( 'On', 'wordpress-seo' ), |
| 69 |
'off' => __( 'Off', 'wordpress-seo' ), |
| 70 |
], |
| 71 |
$name, |
| 72 |
$feature_help->get_button_html() . $feature_help->get_panel_html(), |
| 73 |
[ 'disabled' => $disabled ] |
| 74 |
); |
| 75 |
|
| 76 |
if ( ! empty( $feature->after ) ) { |
| 77 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaping handled in integrations. |
| 78 |
echo $feature->after; |
| 79 |
} |
| 80 |
} |
| 81 |
?> |
| 82 |
</div> |
| 83 |
<?php |
| 84 |
/* |
| 85 |
* Required to prevent our settings framework from saving the default because the field isn't |
| 86 |
* explicitly set when saving the Dashboard page. |
| 87 |
*/ |
| 88 |
$yform->hidden( 'show_onboarding_notice', 'wpseo_show_onboarding_notice' ); |
| 89 |
|