Skip to content
Snippets Groups Projects
Commit 5ce17c5c authored by vasili.guruli's avatar vasili.guruli
Browse files

Fixed stupid mistake getting plagin data without transient (fubar)

parent 168ef453
No related branches found
No related tags found
No related merge requests found
Pipeline #9377 failed
...@@ -51,8 +51,6 @@ if ( ! class_exists( 'WPDesk_Basic_Requirement_Checker' ) ) { ...@@ -51,8 +51,6 @@ if ( ! class_exists( 'WPDesk_Basic_Requirement_Checker' ) ) {
* @param string $text_domain * @param string $text_domain
* @param string $php_version * @param string $php_version
* @param string $wp_version * @param string $wp_version
* @param string $minimum_required_plugin_version
* @param bool $force_plugin_update
*/ */
public function __construct( $plugin_file, $plugin_name, $text_domain, $php_version, $wp_version ) { public function __construct( $plugin_file, $plugin_name, $text_domain, $php_version, $wp_version ) {
$this->plugin_file = $plugin_file; $this->plugin_file = $plugin_file;
...@@ -221,7 +219,7 @@ if ( ! class_exists( 'WPDesk_Basic_Requirement_Checker' ) ) { ...@@ -221,7 +219,7 @@ if ( ! class_exists( 'WPDesk_Basic_Requirement_Checker' ) ) {
} }
if ( true == $this->is_required_minimum_version && false !== $this->check_minimum_required_plugin_version( $this->slug ) ) { if ( true == $this->is_required_minimum_version && false !== $this->check_minimum_required_plugin_version( $this->slug ) ) {
$notices[] = $this->prepare_notice_message( sprintf( __( 'The “%s” plugin requires at least %s version to work correctly with WooCommerce. Please update it', $this->get_text_domain() ), esc_html( $this->plugin_name ), $this->get_plugin_version_request( $this->slug ) ) ); $notices[] = $this->prepare_notice_message( sprintf( __( 'The “%s” plugin requires at least %s version to work correctly with WooCommerce. Please update it', $this->get_text_domain() ), esc_html( $this->plugin_name ), $this->get_plugin_version( $this->slug ) ) );
} }
$notices = $this->append_plugin_require_notices( $notices ); $notices = $this->append_plugin_require_notices( $notices );
...@@ -342,35 +340,32 @@ if ( ! class_exists( 'WPDesk_Basic_Requirement_Checker' ) ) { ...@@ -342,35 +340,32 @@ if ( ! class_exists( 'WPDesk_Basic_Requirement_Checker' ) ) {
/** /**
* Plugin slug * Plugin slug
* *
* @param string $slug * @param string $slug .
* *
* @return mixed * @return mixed
*/ */
public function create_request( $slug ) { public function get_plugin_info_from_plugins_api( $slug ) {
$args = (object) array( 'slug' => $slug );
$request = array(
'action' => 'plugin_information',
'timeout' => self::REQUEST_TIMEOUT,
'request' => serialize( $args )
);
$url = 'http://api.wordpress.org/plugins/info/1.0/'; $transient_version = get_transient( $slug );
$response = wp_remote_post( $url, array( 'body' => $request ) ); $plugin_info = null;
if (false === $transient_version) {
require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
$plugin_info = plugins_api( 'plugin_information', array( 'slug' => $slug ) );
return $response; set_transient( $slug, $plugin_info, WEEK_IN_SECONDS );
}
return $transient_version;
} }
/** /**
* @param string $slug * @param $slug
* *
* @return bool * @return bool
*/ */
public function get_plugin_version_request( $slug ) { public function get_plugin_version( $slug ) {
$response = $this->create_request( $slug );
$plugin_info = unserialize( $response['body'] );
$plugin_info = $this->get_plugin_info_from_plugins_api( $slug );
if ( ! empty( $plugin_info ) ) { if ( ! empty( $plugin_info ) ) {
return $plugin_info->version; return $plugin_info->version;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment