From cc10758d0bcac069f122c68b8a78a27704bd0b58 Mon Sep 17 00:00:00 2001 From: Andy Fragen Date: Wed, 1 Jun 2022 22:22:42 -0700 Subject: [PATCH 1/6] update for initial commit --- readme.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index b721682..41a9d35 100644 --- a/readme.txt +++ b/readme.txt @@ -1,4 +1,4 @@ -# WP Plugin Dependencies +# Plugin Dependencies Contributors: afragen, costdev Plugin URI: https://github.com/WordPress/wp-plugin-dependencies From 1f087701d6fe3b3e6b34b4909a8a3900e2ed528e Mon Sep 17 00:00:00 2001 From: Andy Fragen Date: Fri, 2 Sep 2022 16:42:24 -0700 Subject: [PATCH 2/6] update composer --- vendor/composer/installed.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index ec4431d..1f4dc37 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -1,9 +1,9 @@ array( 'name' => 'wordpress/wp-plugin-dependencies', - 'pretty_version' => 'dev-develop', - 'version' => 'dev-develop', - 'reference' => 'cf1518332d9715ab6ee575f53116794f6a14b193', + 'pretty_version' => 'dev-trunk', + 'version' => 'dev-trunk', + 'reference' => '64ddbde8c1af81b9c71a51ff0d7d41177f761936', 'type' => 'wordpress-plugin', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -20,9 +20,9 @@ 'dev_requirement' => false, ), 'wordpress/wp-plugin-dependencies' => array( - 'pretty_version' => 'dev-develop', - 'version' => 'dev-develop', - 'reference' => 'cf1518332d9715ab6ee575f53116794f6a14b193', + 'pretty_version' => 'dev-trunk', + 'version' => 'dev-trunk', + 'reference' => '64ddbde8c1af81b9c71a51ff0d7d41177f761936', 'type' => 'wordpress-plugin', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), From 7ce89063ccca463674cb3f15f0f70273ac59ecae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Wrede?= Date: Thu, 20 Oct 2022 17:34:45 +0200 Subject: [PATCH 3/6] Remove unnecessary Qualifier and fix typo (#28) --- plugin.php | 2 +- wp-admin/includes/class-wp-plugin-dependencies.php | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/plugin.php b/plugin.php index d396d25..0699a19 100644 --- a/plugin.php +++ b/plugin.php @@ -41,7 +41,7 @@ if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) { require __DIR__ . '/vendor/autoload.php'; } else { - \deactivate_plugins( __FILE__ ); + deactivate_plugins( __FILE__ ); wp_die( wp_kses_post( diff --git a/wp-admin/includes/class-wp-plugin-dependencies.php b/wp-admin/includes/class-wp-plugin-dependencies.php index a05ca9e..65a433a 100644 --- a/wp-admin/includes/class-wp-plugin-dependencies.php +++ b/wp-admin/includes/class-wp-plugin-dependencies.php @@ -101,7 +101,7 @@ private function get_plugins() { * * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass. * - * @return \stdClass + * @return stdClass */ private function parse_plugin_headers() { global $wp_filesystem; @@ -195,11 +195,11 @@ private function deactivate_unmet_dependencies() { /** * Modify plugins_api() response. * - * @param \stdClas $res Object of results. + * @param stdClass $res Object of results. * @param string $action Variable for plugins_api(). - * @param \stdClass $args Object of plugins_api() args. + * @param stdClass $args Object of plugins_api() args. * - * @return \stdClass + * @return stdClass */ public function plugins_api_result( $res, $action, $args ) { if ( property_exists( $args, 'browse' ) && 'dependencies' === $args->browse ) { @@ -627,10 +627,10 @@ private function get_requires_paths( $plugin_data ) { /** * Return empty plugins_api() response. * - * @param \stdClass|WP_Error $response Response from plugins_api(). + * @param stdClass|WP_Error $response Response from plugins_api(). * @param array $args Array of arguments passed to plugins_api(). * - * @return \stdClass + * @return stdClass */ private function get_empty_plugins_api_response( $response, $args ) { if ( is_wp_error( $response ) || property_exists( $response, 'error' ) @@ -664,7 +664,7 @@ private function get_empty_plugins_api_response( $response, $args ) { /** * Hide plugin card action links for plugins with no API data. * - * @global $pagenow Current page. + * @global string $pagenow Current page. * @return void */ public function hide_action_links() { From fc05ebf7ef6269e7ef65b1f5cc47efc70b85a0f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Wrede?= Date: Thu, 20 Oct 2022 17:36:09 +0200 Subject: [PATCH 4/6] Unused local variable 'required'. The value of the variable is overwritten immediately. (#29) --- wp-admin/includes/class-wp-plugin-dependencies.php | 1 - 1 file changed, 1 deletion(-) diff --git a/wp-admin/includes/class-wp-plugin-dependencies.php b/wp-admin/includes/class-wp-plugin-dependencies.php index 65a433a..0b1d69a 100644 --- a/wp-admin/includes/class-wp-plugin-dependencies.php +++ b/wp-admin/includes/class-wp-plugin-dependencies.php @@ -484,7 +484,6 @@ public function hide_column_checkbox( $plugin_file ) { * @return string */ public function plugin_install_description( $description, $plugin ) { - $required = null; if ( in_array( $plugin['slug'], array_keys( $this->plugin_data ), true ) ) { $dependents = $this->get_dependency_sources( $plugin ); $required = '' . __( 'Required by:' ) . ' ' . $dependents; From 4586cba36960da4c6a68d46ba0d7dd3e83cdd0cd Mon Sep 17 00:00:00 2001 From: Andy Fragen Date: Fri, 7 Apr 2023 15:23:06 -0700 Subject: [PATCH 5/6] Revert "tabs v spaces" This reverts commit e7e13bd7db281cb31e0b86394046b7a3fcc6ca4c. From 15e3d6a824f5343188bae0c37f81fd1dde4c6276 Mon Sep 17 00:00:00 2001 From: Erik <11491369+kebbet@users.noreply.github.com> Date: Sat, 6 May 2023 12:40:36 +0200 Subject: [PATCH 6/6] Adds a textdomain to I18N-strings --- plugin.php | 4 +- .../includes/class-wp-plugin-dependencies.php | 49 ++++++++++--------- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/plugin.php b/plugin.php index e51aeb2..9e821f4 100644 --- a/plugin.php +++ b/plugin.php @@ -78,7 +78,7 @@ function() { // phpcs:ignore WordPress.Security.NonceVerification.Recommended $tab = isset( $_GET['tab'] ) ? sanitize_title_with_dashes( wp_unslash( $_GET['tab'] ) ) : ''; if ( 'dependencies' === $tab ) { - echo '

' . esc_html__( 'These suggestions are based on dependencies required by installed plugins.' ) . '

'; + echo '

' . esc_html__( 'These suggestions are based on dependencies required by installed plugins.', 'wp-plugin-dependencies' ) . '

'; } } ); @@ -93,7 +93,7 @@ function() { * @return array */ public function add_install_tab( $tabs ) { - $tabs['dependencies'] = _x( 'Dependencies', 'Plugin Installer' ); + $tabs['dependencies'] = _x( 'Dependencies', 'Plugin Installer tab name', 'wp-plugin-dependencies' ); return $tabs; } diff --git a/wp-admin/includes/class-wp-plugin-dependencies.php b/wp-admin/includes/class-wp-plugin-dependencies.php index 689661d..8be75c3 100644 --- a/wp-admin/includes/class-wp-plugin-dependencies.php +++ b/wp-admin/includes/class-wp-plugin-dependencies.php @@ -368,7 +368,7 @@ public function modify_plugin_row_elements( $plugin_file, $plugin_data ) { $sources = $this->get_dependency_sources( $plugin_data ); $requires_filepaths = $this->get_requires_paths( $plugin_data ); print ''; } @@ -424,9 +424,9 @@ public function modify_plugin_install_action_links( $action_links, $plugin ) { foreach ( $requires_arr as $req ) { if ( ! $dependencies[ $req ] || is_plugin_inactive( $dependencies[ $req ] ) ) { if ( str_contains( $action_links[0], 'activate-now' ) ) { - $action_links[0] = str_replace( __( 'Network Activate' ), __( 'Activate' ), $action_links[0] ); - $action_links[0] = str_replace( __( 'Activate' ), _x( 'Cannot Activate', 'plugin' ), $action_links[0] ); - $action_links[0] .= '' . __( 'Cannot activate due to unmet dependency' ) . ''; + $action_links[0] = str_replace( __( 'Network Activate', 'wp-plugin-dependencies' ), __( 'Activate', 'wp-plugin-dependencies' ), $action_links[0] ); + $action_links[0] = str_replace( __( 'Activate', 'wp-plugin-dependencies' ), _x( 'Cannot Activate', 'plugin', 'wp-plugin-dependencies' ), $action_links[0] ); + $action_links[0] .= '' . __( 'Cannot activate due to unmet dependency', 'wp-plugin-dependencies' ) . ''; $action_links[0] = str_replace( 'activate-now', 'button-disabled', $action_links[0] ); if ( 'plugin-install.php' !== $pagenow ) { $action_links[] = $this->get_dependency_link(); @@ -457,9 +457,9 @@ public function empty_package_remove_install_button( $action_links, $plugin ) { ) { return $action_links; } - $action_links[0] = str_replace( __( 'Network Install' ), __( 'Install' ), $action_links[0] ); - $action_links[0] = str_replace( __( 'Install Now' ), _x( 'Cannot Install', 'plugin' ), $action_links[0] ); - $action_links[0] .= '' . __( 'Cannot install due to empty package' ) . ''; + $action_links[0] = str_replace( __( 'Network Install', 'wp-plugin-dependencies' ), __( 'Install', 'wp-plugin-dependencies' ), $action_links[0] ); + $action_links[0] = str_replace( __( 'Install Now', 'wp-plugin-dependencies' ), _x( 'Cannot Install', 'plugin', 'wp-plugin-dependencies' ), $action_links[0] ); + $action_links[0] .= '' . __( 'Cannot install due to empty package', 'wp-plugin-dependencies' ) . ''; $action_links[0] = str_replace( 'install-now', 'button-disabled', $action_links[0] ); return $action_links; @@ -476,7 +476,7 @@ public function plugin_install_description( $description, $plugin ) { $required = null; if ( in_array( $plugin['slug'], array_keys( $this->plugin_data ), true ) ) { $dependents = $this->get_dependency_sources( $plugin ); - $required = '' . __( 'Required by:' ) . ' ' . $dependents; + $required = '' . __( 'Required by:', 'wp-plugin-dependencies' ) . ' ' . $dependents; $description = $description . '

' . $required . '

'; } @@ -486,7 +486,7 @@ public function plugin_install_description( $description, $plugin ) { $file = $this->plugin_dirnames[ $plugin['slug'] ]; if ( in_array( $file, array_keys( $this->requires_plugins ), true ) ) { $require_names = $this->get_requires_plugins_names( $file ); - $requires = '' . __( 'Requires:' ) . ' ' . $require_names; + $requires = '' . __( 'Requires:', 'wp-plugin-dependencies' ) . ' ' . $require_names; $description = $description . '

' . $requires . '

'; } @@ -523,7 +523,7 @@ private function get_view_details_links( $plugin_file, $names ) { "%s", esc_url( network_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin_data['slug'] . '&TB_iframe=true&width=600&height=550' ) ), /* translators: %s: Plugin name. */ - sprintf( __( 'More information about %s' ), $name_attr ), + sprintf( __( 'More information about %s', 'wp-plugin-dependencies' ), $name_attr ), $name_attr, $name ); @@ -572,8 +572,8 @@ public function cannot_activate_unmet_dependencies( $actions, $plugin_file ) { foreach ( $plugin_dependencies as $plugin_dependency ) { if ( ! $dependencies[ $plugin_dependency ] || is_plugin_inactive( $dependencies[ $plugin_dependency ] ) ) { - $activate = _x( 'Cannot Activate', 'plugin' ); - $activate .= '' . __( 'Cannot activate due to unmet dependency' ) . ''; + $activate = _x( 'Cannot Activate', 'plugin', 'wp-plugin-dependencies' ); + $activate .= '' . __( 'Cannot activate due to unmet dependency', 'wp-plugin-dependencies' ) . ''; $dependencies = $this->get_dependency_link(); unset( $actions['activate'] ); $actions = array_merge( @@ -633,7 +633,7 @@ public function admin_notices() { printf( '

' /* translators: 1: plugin names, 2: link to Dependencies install page */ - . esc_html__( '%1$s plugin(s) have been deactivated. There are uninstalled or inactive dependencies. Go to the %2$s install page.' ) + . esc_html__( '%1$s plugin(s) have been deactivated. There are uninstalled or inactive dependencies. Go to the %2$s install page.', 'wp-plugin-dependencies' ) . '

', '' . esc_html( $deactivated_plugins ) . '', wp_kses_post( $this->get_dependency_link( true ) ) @@ -644,14 +644,14 @@ public function admin_notices() { $intersect = array_intersect( $this->slugs, $installed_slugs ); asort( $intersect ); if ( $intersect !== $this->slugs ) { - $message_html = __( 'There are additional plugins that must be installed.' ); + $message_html = __( 'There are additional plugins that must be installed.', 'wp-plugin-dependencies' ); // Display link (if not already on Dependencies install page). // phpcs:ignore WordPress.Security.NonceVerification.Recommended $tab = isset( $_GET['tab'] ) ? sanitize_title_with_dashes( wp_unslash( $_GET['tab'] ) ) : ''; if ( 'plugin-install.php' !== $pagenow || 'dependencies' !== $tab ) { $message_html .= ' ' . sprintf( - /* translators: 1: link to Dependencies install page */ + /* translators: link to Dependencies install page */ __( 'Go to the %s install page.' ), wp_kses_post( $this->get_dependency_link( true ) ), '' @@ -667,9 +667,12 @@ public function admin_notices() { $circular_dependencies = $this->get_circular_dependencies(); if ( ! empty( $circular_dependencies ) && count( $circular_dependencies ) > 1 ) { - /* translators: circular dependencies names */ - $messages = sprintf( __( 'You have circular dependencies with the following plugins: %s' ), implode( ', ', $circular_dependencies['names'] ) ); - $messages .= '
' . __( 'Please contact the plugin developers and make them aware.' ); + $messages = sprintf( + /* translators: circular dependencies names */ + __('You have circular dependencies with the following plugins: %s', 'wp-plugin-dependencies' ), + implode( ', ', $circular_dependencies['names'] ) + ); + $messages .= '
' . __( 'Please contact the plugin developers and make them aware.', 'wp-plugin-dependencies' ); printf( '

%s

', wp_kses_post( $messages ) @@ -773,9 +776,9 @@ private function get_dependency_sources( $plugin_data ) { * @return string */ private function get_dependency_link( $notice = false ) { - $link_text = $notice ? __( 'Dependencies' ) : __( 'Manage Dependencies' ); + $link_text = $notice ? __( 'Dependencies', 'wp-plugin-dependencies' ) : __( 'Manage Dependencies', 'wp-plugin-dependencies' ); $link = sprintf( - '%s', + '%s', $link_text ); @@ -830,7 +833,7 @@ private function get_empty_plugins_api_response( $response, $args ) { $dependencies = $this->get_dependency_filepaths(); $file = $dependencies[ $slug ]; $args = $file ? $this->plugins[ $file ] : $args; - $short_description = __( 'You will need to manually install this dependency. Please contact the plugin\'s developer and ask them to add plugin dependencies support and for information on how to install the this dependency.' ); + $short_description = __( 'You will need to manually install this dependency. Please contact the plugin\'s developer and ask them to add plugin dependencies support and for information on how to install the this dependency.', 'wp-plugin-dependencies' ); $response = array( 'name' => $args['Name'], 'slug' => $slug, @@ -842,7 +845,7 @@ private function get_empty_plugins_api_response( $response, $args ) { 'requires_php' => $args['RequiresPHP'], 'sections' => array( 'description' => '

' . $args['Description'] . '

' . $short_description, - 'installation' => __( 'Ask the plugin developer where to download and install this plugin dependency.' ), + 'installation' => __( 'Ask the plugin developer where to download and install this plugin dependency.', 'wp-plugin-dependencies' ), ), 'short_description' => '

' . $args['Description'] . '

' . $short_description, 'download_link' => '',