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.../src/integrat.../watchers
File: woocommerce-beta-editor-watcher.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Integrations\Watchers;
[2] Fix | Delete
[3] Fix | Delete
use Yoast\WP\SEO\Conditionals\Admin_Conditional;
[4] Fix | Delete
use Yoast\WP\SEO\Conditionals\Not_Admin_Ajax_Conditional;
[5] Fix | Delete
use Yoast\WP\SEO\Conditionals\WooCommerce_Conditional;
[6] Fix | Delete
use Yoast\WP\SEO\Helpers\Notification_Helper;
[7] Fix | Delete
use Yoast\WP\SEO\Helpers\Short_Link_Helper;
[8] Fix | Delete
use Yoast\WP\SEO\Integrations\Integration_Interface;
[9] Fix | Delete
use Yoast\WP\SEO\Presenters\Admin\Woocommerce_Beta_Editor_Presenter;
[10] Fix | Delete
use Yoast_Notification;
[11] Fix | Delete
use Yoast_Notification_Center;
[12] Fix | Delete
[13] Fix | Delete
/**
[14] Fix | Delete
* Shows a notification for users who have Woocommerce product beta editor enabled.
[15] Fix | Delete
*/
[16] Fix | Delete
class Woocommerce_Beta_Editor_Watcher implements Integration_Interface {
[17] Fix | Delete
[18] Fix | Delete
/**
[19] Fix | Delete
* The notification ID.
[20] Fix | Delete
*/
[21] Fix | Delete
public const NOTIFICATION_ID = 'wpseo-woocommerce-beta-editor-warning';
[22] Fix | Delete
[23] Fix | Delete
/**
[24] Fix | Delete
* The short link helper.
[25] Fix | Delete
*
[26] Fix | Delete
* @var Short_Link_Helper
[27] Fix | Delete
*/
[28] Fix | Delete
protected $short_link_helper;
[29] Fix | Delete
[30] Fix | Delete
/**
[31] Fix | Delete
* The Yoast notification center.
[32] Fix | Delete
*
[33] Fix | Delete
* @var Yoast_Notification_Center
[34] Fix | Delete
*/
[35] Fix | Delete
protected $notification_center;
[36] Fix | Delete
[37] Fix | Delete
/**
[38] Fix | Delete
* The notification helper.
[39] Fix | Delete
*
[40] Fix | Delete
* @var Notification_Helper
[41] Fix | Delete
*/
[42] Fix | Delete
protected $notification_helper;
[43] Fix | Delete
[44] Fix | Delete
/**
[45] Fix | Delete
* The WooCommerce conditional.
[46] Fix | Delete
*
[47] Fix | Delete
* @var WooCommerce_Conditional
[48] Fix | Delete
*/
[49] Fix | Delete
protected $woocommerce_conditional;
[50] Fix | Delete
[51] Fix | Delete
/**
[52] Fix | Delete
* The Woocommerce beta editor presenter.
[53] Fix | Delete
*
[54] Fix | Delete
* @var Woocommerce_Beta_Editor_Presenter
[55] Fix | Delete
*/
[56] Fix | Delete
protected $presenter;
[57] Fix | Delete
[58] Fix | Delete
/**
[59] Fix | Delete
* Woocommerce_Beta_Editor_Watcher constructor.
[60] Fix | Delete
*
[61] Fix | Delete
* @param Yoast_Notification_Center $notification_center The notification center.
[62] Fix | Delete
* @param Notification_Helper $notification_helper The notification helper.
[63] Fix | Delete
* @param Short_Link_Helper $short_link_helper The short link helper.
[64] Fix | Delete
* @param WooCommerce_Conditional $woocommerce_conditional The WooCommerce conditional.
[65] Fix | Delete
*/
[66] Fix | Delete
public function __construct(
[67] Fix | Delete
Yoast_Notification_Center $notification_center,
[68] Fix | Delete
Notification_Helper $notification_helper,
[69] Fix | Delete
Short_Link_Helper $short_link_helper,
[70] Fix | Delete
WooCommerce_Conditional $woocommerce_conditional
[71] Fix | Delete
) {
[72] Fix | Delete
$this->notification_center = $notification_center;
[73] Fix | Delete
$this->notification_helper = $notification_helper;
[74] Fix | Delete
$this->short_link_helper = $short_link_helper;
[75] Fix | Delete
$this->woocommerce_conditional = $woocommerce_conditional;
[76] Fix | Delete
$this->presenter = new Woocommerce_Beta_Editor_Presenter( $this->short_link_helper );
[77] Fix | Delete
}
[78] Fix | Delete
[79] Fix | Delete
/**
[80] Fix | Delete
* Returns the conditionals based on which this loadable should be active.
[81] Fix | Delete
*
[82] Fix | Delete
* @return string[] The conditionals.
[83] Fix | Delete
*/
[84] Fix | Delete
public static function get_conditionals() {
[85] Fix | Delete
return [ Admin_Conditional::class, Not_Admin_Ajax_Conditional::class ];
[86] Fix | Delete
}
[87] Fix | Delete
[88] Fix | Delete
/**
[89] Fix | Delete
* Initializes the integration.
[90] Fix | Delete
*
[91] Fix | Delete
* On admin_init, it is checked whether the notification about Woocommerce product beta editor enabled should be shown.
[92] Fix | Delete
*
[93] Fix | Delete
* @return void
[94] Fix | Delete
*/
[95] Fix | Delete
public function register_hooks() {
[96] Fix | Delete
\add_action( 'admin_init', [ $this, 'manage_woocommerce_beta_editor_notification' ] );
[97] Fix | Delete
}
[98] Fix | Delete
[99] Fix | Delete
/**
[100] Fix | Delete
* Manage the Woocommerce product beta editor notification.
[101] Fix | Delete
*
[102] Fix | Delete
* Shows the notification if needed and deletes it if needed.
[103] Fix | Delete
*
[104] Fix | Delete
* @return void
[105] Fix | Delete
*/
[106] Fix | Delete
public function manage_woocommerce_beta_editor_notification() {
[107] Fix | Delete
if ( \get_option( 'woocommerce_feature_product_block_editor_enabled' ) === 'yes' && $this->woocommerce_conditional->is_met() ) {
[108] Fix | Delete
$this->maybe_add_woocommerce_beta_editor_notification();
[109] Fix | Delete
}
[110] Fix | Delete
else {
[111] Fix | Delete
$this->notification_center->remove_notification_by_id( self::NOTIFICATION_ID );
[112] Fix | Delete
}
[113] Fix | Delete
}
[114] Fix | Delete
[115] Fix | Delete
/**
[116] Fix | Delete
* Add the Woocommerce product beta editor enabled notification if it does not exist yet.
[117] Fix | Delete
*
[118] Fix | Delete
* @return void
[119] Fix | Delete
*/
[120] Fix | Delete
public function maybe_add_woocommerce_beta_editor_notification() {
[121] Fix | Delete
if ( ! $this->notification_center->get_notification_by_id( self::NOTIFICATION_ID ) ) {
[122] Fix | Delete
$notification = $this->notification();
[123] Fix | Delete
$this->notification_helper->restore_notification( $notification );
[124] Fix | Delete
$this->notification_center->add_notification( $notification );
[125] Fix | Delete
}
[126] Fix | Delete
}
[127] Fix | Delete
[128] Fix | Delete
/**
[129] Fix | Delete
* Returns an instance of the notification.
[130] Fix | Delete
*
[131] Fix | Delete
* @return Yoast_Notification The notification to show.
[132] Fix | Delete
*/
[133] Fix | Delete
protected function notification() {
[134] Fix | Delete
return new Yoast_Notification(
[135] Fix | Delete
$this->presenter->present(),
[136] Fix | Delete
[
[137] Fix | Delete
'type' => Yoast_Notification::ERROR,
[138] Fix | Delete
'id' => self::NOTIFICATION_ID,
[139] Fix | Delete
'capabilities' => 'wpseo_manage_options',
[140] Fix | Delete
'priority' => 1,
[141] Fix | Delete
]
[142] Fix | Delete
);
[143] Fix | Delete
}
[144] Fix | Delete
}
[145] Fix | Delete
[146] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function