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.../public_h.../wp-conte.../plugins/wordpres.../admin
File: class-yoast-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
* Class to change or add WordPress dashboard widgets.
[8] Fix | Delete
*/
[9] Fix | Delete
class Yoast_Dashboard_Widget implements WPSEO_WordPress_Integration {
[10] Fix | Delete
[11] Fix | Delete
/**
[12] Fix | Delete
* Holds the cache transient key.
[13] Fix | Delete
*
[14] Fix | Delete
* @var string
[15] Fix | Delete
*/
[16] Fix | Delete
public const CACHE_TRANSIENT_KEY = 'wpseo-dashboard-totals';
[17] Fix | Delete
[18] Fix | Delete
/**
[19] Fix | Delete
* Holds an instance of the admin asset manager.
[20] Fix | Delete
*
[21] Fix | Delete
* @var WPSEO_Admin_Asset_Manager
[22] Fix | Delete
*/
[23] Fix | Delete
protected $asset_manager;
[24] Fix | Delete
[25] Fix | Delete
/**
[26] Fix | Delete
* Holds the dashboard statistics.
[27] Fix | Delete
*
[28] Fix | Delete
* @var WPSEO_Statistics
[29] Fix | Delete
*/
[30] Fix | Delete
protected $statistics;
[31] Fix | Delete
[32] Fix | Delete
/**
[33] Fix | Delete
* Yoast_Dashboard_Widget constructor.
[34] Fix | Delete
*
[35] Fix | Delete
* @param WPSEO_Statistics|null $statistics WPSEO_Statistics instance.
[36] Fix | Delete
*/
[37] Fix | Delete
public function __construct( ?WPSEO_Statistics $statistics = null ) {
[38] Fix | Delete
if ( $statistics === null ) {
[39] Fix | Delete
$statistics = new WPSEO_Statistics();
[40] Fix | Delete
}
[41] Fix | Delete
[42] Fix | Delete
$this->statistics = $statistics;
[43] Fix | Delete
$this->asset_manager = new WPSEO_Admin_Asset_Manager();
[44] Fix | Delete
}
[45] Fix | Delete
[46] Fix | Delete
/**
[47] Fix | Delete
* Register WordPress hooks.
[48] Fix | Delete
*
[49] Fix | Delete
* @return void
[50] Fix | Delete
*/
[51] Fix | Delete
public function register_hooks() {
[52] Fix | Delete
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_dashboard_assets' ] );
[53] Fix | Delete
add_action( 'admin_init', [ $this, 'queue_dashboard_widget' ] );
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
/**
[57] Fix | Delete
* Adds the dashboard widget if it should be shown.
[58] Fix | Delete
*
[59] Fix | Delete
* @return void
[60] Fix | Delete
*/
[61] Fix | Delete
public function queue_dashboard_widget() {
[62] Fix | Delete
if ( $this->show_widget() ) {
[63] Fix | Delete
add_action( 'wp_dashboard_setup', [ $this, 'add_dashboard_widget' ] );
[64] Fix | Delete
}
[65] Fix | Delete
}
[66] Fix | Delete
[67] Fix | Delete
/**
[68] Fix | Delete
* Adds dashboard widget to WordPress.
[69] Fix | Delete
*
[70] Fix | Delete
* @return void
[71] Fix | Delete
*/
[72] Fix | Delete
public function add_dashboard_widget() {
[73] Fix | Delete
add_filter( 'postbox_classes_dashboard_wpseo-dashboard-overview', [ $this, 'wpseo_dashboard_overview_class' ] );
[74] Fix | Delete
wp_add_dashboard_widget(
[75] Fix | Delete
'wpseo-dashboard-overview',
[76] Fix | Delete
/* translators: %s is the plugin name */
[77] Fix | Delete
sprintf( __( '%s Posts Overview', 'wordpress-seo' ), 'Yoast SEO' ),
[78] Fix | Delete
[ $this, 'display_dashboard_widget' ]
[79] Fix | Delete
);
[80] Fix | Delete
}
[81] Fix | Delete
[82] Fix | Delete
/**
[83] Fix | Delete
* Adds CSS classes to the dashboard widget.
[84] Fix | Delete
*
[85] Fix | Delete
* @param array $classes An array of postbox CSS classes.
[86] Fix | Delete
*
[87] Fix | Delete
* @return array
[88] Fix | Delete
*/
[89] Fix | Delete
public function wpseo_dashboard_overview_class( $classes ) {
[90] Fix | Delete
$classes[] = 'yoast wpseo-dashboard-overview';
[91] Fix | Delete
return $classes;
[92] Fix | Delete
}
[93] Fix | Delete
[94] Fix | Delete
/**
[95] Fix | Delete
* Displays the dashboard widget.
[96] Fix | Delete
*
[97] Fix | Delete
* @return void
[98] Fix | Delete
*/
[99] Fix | Delete
public function display_dashboard_widget() {
[100] Fix | Delete
echo '<div id="yoast-seo-dashboard-widget"></div>';
[101] Fix | Delete
}
[102] Fix | Delete
[103] Fix | Delete
/**
[104] Fix | Delete
* Enqueues assets for the dashboard if the current page is the dashboard.
[105] Fix | Delete
*
[106] Fix | Delete
* @return void
[107] Fix | Delete
*/
[108] Fix | Delete
public function enqueue_dashboard_assets() {
[109] Fix | Delete
if ( ! $this->is_dashboard_screen() ) {
[110] Fix | Delete
return;
[111] Fix | Delete
}
[112] Fix | Delete
[113] Fix | Delete
$this->asset_manager->localize_script( 'dashboard-widget', 'wpseoDashboardWidgetL10n', $this->localize_dashboard_script() );
[114] Fix | Delete
$this->asset_manager->enqueue_script( 'dashboard-widget' );
[115] Fix | Delete
$this->asset_manager->enqueue_style( 'wp-dashboard' );
[116] Fix | Delete
$this->asset_manager->enqueue_style( 'monorepo' );
[117] Fix | Delete
}
[118] Fix | Delete
[119] Fix | Delete
/**
[120] Fix | Delete
* Translates strings used in the dashboard widget.
[121] Fix | Delete
*
[122] Fix | Delete
* @return array The translated strings.
[123] Fix | Delete
*/
[124] Fix | Delete
public function localize_dashboard_script() {
[125] Fix | Delete
return [
[126] Fix | Delete
'feed_header' => sprintf(
[127] Fix | Delete
/* translators: %1$s resolves to Yoast.com */
[128] Fix | Delete
__( 'Latest blog posts on %1$s', 'wordpress-seo' ),
[129] Fix | Delete
'Yoast.com'
[130] Fix | Delete
),
[131] Fix | Delete
'feed_footer' => __( 'Read more like this on our SEO blog', 'wordpress-seo' ),
[132] Fix | Delete
'wp_version' => substr( $GLOBALS['wp_version'], 0, 3 ) . '-' . ( is_plugin_active( 'classic-editor/classic-editor.php' ) ? '1' : '0' ),
[133] Fix | Delete
'php_version' => PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION,
[134] Fix | Delete
];
[135] Fix | Delete
}
[136] Fix | Delete
[137] Fix | Delete
/**
[138] Fix | Delete
* Checks if the current screen is the dashboard screen.
[139] Fix | Delete
*
[140] Fix | Delete
* @return bool Whether or not this is the dashboard screen.
[141] Fix | Delete
*/
[142] Fix | Delete
private function is_dashboard_screen() {
[143] Fix | Delete
$current_screen = get_current_screen();
[144] Fix | Delete
[145] Fix | Delete
return ( $current_screen instanceof WP_Screen && $current_screen->id === 'dashboard' );
[146] Fix | Delete
}
[147] Fix | Delete
[148] Fix | Delete
/**
[149] Fix | Delete
* Returns true when the dashboard widget should be shown.
[150] Fix | Delete
*
[151] Fix | Delete
* @return bool
[152] Fix | Delete
*/
[153] Fix | Delete
private function show_widget() {
[154] Fix | Delete
$analysis_seo = new WPSEO_Metabox_Analysis_SEO();
[155] Fix | Delete
[156] Fix | Delete
return $analysis_seo->is_enabled() && current_user_can( 'edit_posts' );
[157] Fix | Delete
}
[158] Fix | Delete
}
[159] Fix | Delete
[160] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function