Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/wordpres.../admin
File: class-wincher-dashboard-widget.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* WPSEO plugin file.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WPSEO\Admin
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Wincher dashboard widget.
[8] Fix | Delete
*/
[9] Fix | Delete
class Wincher_Dashboard_Widget implements WPSEO_WordPress_Integration {
[10] Fix | Delete
[11] Fix | Delete
/**
[12] Fix | Delete
* Holds an instance of the admin asset manager.
[13] Fix | Delete
*
[14] Fix | Delete
* @var WPSEO_Admin_Asset_Manager
[15] Fix | Delete
*/
[16] Fix | Delete
protected $asset_manager;
[17] Fix | Delete
[18] Fix | Delete
/**
[19] Fix | Delete
* Wincher_Dashboard_Widget constructor.
[20] Fix | Delete
*/
[21] Fix | Delete
public function __construct() {
[22] Fix | Delete
$this->asset_manager = new WPSEO_Admin_Asset_Manager();
[23] Fix | Delete
}
[24] Fix | Delete
[25] Fix | Delete
/**
[26] Fix | Delete
* Register WordPress hooks.
[27] Fix | Delete
*
[28] Fix | Delete
* @return void
[29] Fix | Delete
*/
[30] Fix | Delete
public function register_hooks() {
[31] Fix | Delete
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_wincher_dashboard_assets' ] );
[32] Fix | Delete
add_action( 'admin_init', [ $this, 'queue_wincher_dashboard_widget' ] );
[33] Fix | Delete
}
[34] Fix | Delete
[35] Fix | Delete
/**
[36] Fix | Delete
* Adds the Wincher dashboard widget if it should be shown.
[37] Fix | Delete
*
[38] Fix | Delete
* @return void
[39] Fix | Delete
*/
[40] Fix | Delete
public function queue_wincher_dashboard_widget() {
[41] Fix | Delete
if ( $this->show_widget() ) {
[42] Fix | Delete
add_action( 'wp_dashboard_setup', [ $this, 'add_wincher_dashboard_widget' ] );
[43] Fix | Delete
}
[44] Fix | Delete
}
[45] Fix | Delete
[46] Fix | Delete
/**
[47] Fix | Delete
* Adds the Wincher dashboard widget to WordPress.
[48] Fix | Delete
*
[49] Fix | Delete
* @return void
[50] Fix | Delete
*/
[51] Fix | Delete
public function add_wincher_dashboard_widget() {
[52] Fix | Delete
add_filter( 'postbox_classes_dashboard_wpseo-wincher-dashboard-overview', [ $this, 'wpseo_wincher_dashboard_overview_class' ] );
[53] Fix | Delete
wp_add_dashboard_widget(
[54] Fix | Delete
'wpseo-wincher-dashboard-overview',
[55] Fix | Delete
/* translators: %1$s expands to Yoast SEO, %2$s to Wincher */
[56] Fix | Delete
sprintf( __( '%1$s / %2$s: Top Keyphrases', 'wordpress-seo' ), 'Yoast SEO', 'Wincher' ),
[57] Fix | Delete
[ $this, 'display_wincher_dashboard_widget' ]
[58] Fix | Delete
);
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
/**
[62] Fix | Delete
* Adds CSS classes to the dashboard widget.
[63] Fix | Delete
*
[64] Fix | Delete
* @param array $classes An array of postbox CSS classes.
[65] Fix | Delete
*
[66] Fix | Delete
* @return array
[67] Fix | Delete
*/
[68] Fix | Delete
public function wpseo_wincher_dashboard_overview_class( $classes ) {
[69] Fix | Delete
$classes[] = 'yoast wpseo-wincherdashboard-overview';
[70] Fix | Delete
return $classes;
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
/**
[74] Fix | Delete
* Displays the Wincher dashboard widget.
[75] Fix | Delete
*
[76] Fix | Delete
* @return void
[77] Fix | Delete
*/
[78] Fix | Delete
public function display_wincher_dashboard_widget() {
[79] Fix | Delete
echo '<div id="yoast-seo-wincher-dashboard-widget"></div>';
[80] Fix | Delete
}
[81] Fix | Delete
[82] Fix | Delete
/**
[83] Fix | Delete
* Enqueues assets for the dashboard if the current page is the dashboard.
[84] Fix | Delete
*
[85] Fix | Delete
* @return void
[86] Fix | Delete
*/
[87] Fix | Delete
public function enqueue_wincher_dashboard_assets() {
[88] Fix | Delete
if ( ! $this->is_dashboard_screen() ) {
[89] Fix | Delete
return;
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
$this->asset_manager->localize_script( 'wincher-dashboard-widget', 'wpseoWincherDashboardWidgetL10n', $this->localize_wincher_dashboard_script() );
[93] Fix | Delete
$this->asset_manager->enqueue_script( 'wincher-dashboard-widget' );
[94] Fix | Delete
$this->asset_manager->enqueue_style( 'wp-dashboard' );
[95] Fix | Delete
$this->asset_manager->enqueue_style( 'monorepo' );
[96] Fix | Delete
}
[97] Fix | Delete
[98] Fix | Delete
/**
[99] Fix | Delete
* Translates strings used in the Wincher dashboard widget.
[100] Fix | Delete
*
[101] Fix | Delete
* @return array The translated strings.
[102] Fix | Delete
*/
[103] Fix | Delete
public function localize_wincher_dashboard_script() {
[104] Fix | Delete
[105] Fix | Delete
return [
[106] Fix | Delete
'wincher_is_logged_in' => YoastSEO()->helpers->wincher->login_status(),
[107] Fix | Delete
'wincher_website_id' => WPSEO_Options::get( 'wincher_website_id', '' ),
[108] Fix | Delete
];
[109] Fix | Delete
}
[110] Fix | Delete
[111] Fix | Delete
/**
[112] Fix | Delete
* Checks if the current screen is the dashboard screen.
[113] Fix | Delete
*
[114] Fix | Delete
* @return bool Whether or not this is the dashboard screen.
[115] Fix | Delete
*/
[116] Fix | Delete
private function is_dashboard_screen() {
[117] Fix | Delete
$current_screen = get_current_screen();
[118] Fix | Delete
[119] Fix | Delete
return ( $current_screen instanceof WP_Screen && $current_screen->id === 'dashboard' );
[120] Fix | Delete
}
[121] Fix | Delete
[122] Fix | Delete
/**
[123] Fix | Delete
* Returns true when the Wincher dashboard widget should be shown.
[124] Fix | Delete
*
[125] Fix | Delete
* @return bool
[126] Fix | Delete
*/
[127] Fix | Delete
private function show_widget() {
[128] Fix | Delete
$analysis_seo = new WPSEO_Metabox_Analysis_SEO();
[129] Fix | Delete
$user_can_edit = $analysis_seo->is_enabled() && current_user_can( 'edit_posts' );
[130] Fix | Delete
$is_wincher_active = YoastSEO()->helpers->wincher->is_active();
[131] Fix | Delete
[132] Fix | Delete
return $user_can_edit && $is_wincher_active;
[133] Fix | Delete
}
[134] Fix | Delete
}
[135] Fix | Delete
[136] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function