Merged in feature/314-dev-dev01 (pull request #24)

auto-patch  314-dev-dev01-2024-01-25T04_09_02

* auto-patch  314-dev-dev01-2024-01-25T04_09_02
This commit is contained in:
Tony Volpe
2024-01-25 04:11:47 +00:00
parent 6b67473553
commit 68dbe860e9
540 changed files with 3445 additions and 2131 deletions

View File

@@ -54,7 +54,7 @@ class Yoast_Plugin_Conflict {
if ( is_null( self::$instance ) ) {
if ( ! is_string( $class_name ) || $class_name === '' ) {
$class_name = __CLASS__;
$class_name = self::class;
}
self::$instance = new $class_name();
@@ -75,7 +75,7 @@ class Yoast_Plugin_Conflict {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
if ( isset( $_GET['action'] ) && is_string( $_GET['action'] ) ) {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are not processing form information and only comparing the variable in a condition.
// phpcs:ignore WordPress.Security.NonceVerification.Recommended,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are not processing form information and only comparing the variable in a condition.
$action = wp_unslash( $_GET['action'] );
if ( $action === 'deactivate' ) {
$this->remove_deactivated_plugin();
@@ -106,7 +106,7 @@ class Yoast_Plugin_Conflict {
$sections_checked = [];
}
if ( ! \in_array( $plugin_section, $sections_checked, true ) ) {
if ( ! in_array( $plugin_section, $sections_checked, true ) ) {
$sections_checked[] = $plugin_section;
return ( ! empty( $this->active_conflicting_plugins[ $plugin_section ] ) );
}
@@ -118,6 +118,8 @@ class Yoast_Plugin_Conflict {
* Checks for given $plugin_sections for conflicts.
*
* @param array $plugin_sections Set of sections.
*
* @return void
*/
public function check_plugin_conflicts( $plugin_sections ) {
foreach ( $plugin_sections as $plugin_section => $readable_plugin_section ) {
@@ -128,9 +130,9 @@ class Yoast_Plugin_Conflict {
}
// List of all active sections.
$sections = \array_keys( $plugin_sections );
$sections = array_keys( $plugin_sections );
// List of all sections.
$all_plugin_sections = \array_keys( $this->plugins );
$all_plugin_sections = array_keys( $this->plugins );
/*
* Get all sections that are inactive.
@@ -138,10 +140,10 @@ class Yoast_Plugin_Conflict {
*
* This happens when Sitemaps or OpenGraph implementations toggle active/disabled.
*/
$inactive_sections = \array_diff( $all_plugin_sections, $sections );
$inactive_sections = array_diff( $all_plugin_sections, $sections );
if ( ! empty( $inactive_sections ) ) {
foreach ( $inactive_sections as $section ) {
\array_walk( $this->plugins[ $section ], [ $this, 'clear_error' ] );
array_walk( $this->plugins[ $section ], [ $this, 'clear_error' ] );
}
}
@@ -152,10 +154,10 @@ class Yoast_Plugin_Conflict {
// If there are active plugins, filter them from being cleared.
if ( isset( $this->active_conflicting_plugins[ $section ] ) ) {
$inactive_plugins = \array_diff( $this->plugins[ $section ], $this->active_conflicting_plugins[ $section ] );
$inactive_plugins = array_diff( $this->plugins[ $section ], $this->active_conflicting_plugins[ $section ] );
}
\array_walk( $inactive_plugins, [ $this, 'clear_error' ] );
array_walk( $inactive_plugins, [ $this, 'clear_error' ] );
}
}
@@ -164,6 +166,8 @@ class Yoast_Plugin_Conflict {
*
* @param string $plugin_section Type of conflict group (such as Open Graph or sitemap).
* @param string $readable_plugin_section This is the value for the translation.
*
* @return void
*/
protected function set_error( $plugin_section, $readable_plugin_section ) {
@@ -200,6 +204,8 @@ class Yoast_Plugin_Conflict {
* Clear the notification for a plugin.
*
* @param string $plugin_file Clear the optional notification for this plugin.
*
* @return void
*/
public function clear_error( $plugin_file ) {
$identifier = $this->get_notification_identifier( $plugin_file );
@@ -212,6 +218,8 @@ class Yoast_Plugin_Conflict {
* Loop through the $this->plugins to check if one of the plugins is active.
*
* This method will store the active plugins in $this->active_plugins.
*
* @return void
*/
protected function search_active_plugins() {
foreach ( $this->plugins as $plugin_section => $plugins ) {
@@ -224,6 +232,8 @@ class Yoast_Plugin_Conflict {
*
* @param array $plugins Set of plugins.
* @param string $plugin_section Type of conflict group (such as Open Graph or sitemap).
*
* @return void
*/
protected function check_plugins_active( $plugins, $plugin_section ) {
foreach ( $plugins as $plugin ) {
@@ -241,7 +251,7 @@ class Yoast_Plugin_Conflict {
* @return bool
*/
protected function check_plugin_is_active( $plugin ) {
return \in_array( $plugin, $this->all_active_plugins, true );
return in_array( $plugin, $this->all_active_plugins, true );
}
/**
@@ -252,13 +262,15 @@ class Yoast_Plugin_Conflict {
*
* @param string $plugin_section Type of conflict group (such as Open Graph or sitemap).
* @param string $plugin Plugin basename string.
*
* @return void
*/
protected function add_active_plugin( $plugin_section, $plugin ) {
if ( ! \array_key_exists( $plugin_section, $this->active_conflicting_plugins ) ) {
if ( ! array_key_exists( $plugin_section, $this->active_conflicting_plugins ) ) {
$this->active_conflicting_plugins[ $plugin_section ] = [];
}
if ( ! \in_array( $plugin, $this->active_conflicting_plugins[ $plugin_section ], true ) ) {
if ( ! in_array( $plugin, $this->active_conflicting_plugins[ $plugin_section ], true ) ) {
$this->active_conflicting_plugins[ $plugin_section ][] = $plugin;
}
}
@@ -274,7 +286,7 @@ class Yoast_Plugin_Conflict {
*/
protected function find_plugin_category( $plugin ) {
foreach ( $this->plugins as $plugin_section => $plugins ) {
if ( \in_array( $plugin, $plugins, true ) ) {
if ( in_array( $plugin, $plugins, true ) ) {
return $plugin_section;
}
}
@@ -288,7 +300,7 @@ class Yoast_Plugin_Conflict {
* @return string|bool Plugin name or false when no name is set.
*/
protected function get_plugin_name( $plugin ) {
$plugin_details = \get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
$plugin_details = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
if ( $plugin_details['Name'] !== '' ) {
return $plugin_details['Name'];
@@ -299,6 +311,8 @@ class Yoast_Plugin_Conflict {
/**
* When being in the deactivation process the currently deactivated plugin has to be removed.
*
* @return void
*/
private function remove_deactivated_plugin() {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: On the deactivation screen the nonce is already checked by WordPress itself.
@@ -308,7 +322,7 @@ class Yoast_Plugin_Conflict {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: On the deactivation screen the nonce is already checked by WordPress itself.
$deactivated_plugin = sanitize_text_field( wp_unslash( $_GET['plugin'] ) );
$key_to_remove = \array_search( $deactivated_plugin, $this->all_active_plugins, true );
$key_to_remove = array_search( $deactivated_plugin, $this->all_active_plugins, true );
if ( $key_to_remove !== false ) {
unset( $this->all_active_plugins[ $key_to_remove ] );
@@ -323,6 +337,6 @@ class Yoast_Plugin_Conflict {
* @return string
*/
private function get_notification_identifier( $plugin_file ) {
return \md5( $plugin_file );
return md5( $plugin_file );
}
}