From 4292164a308693b176899e436a6c3b64fc19fa81 Mon Sep 17 00:00:00 2001 From: PriyoMukul Date: Mon, 18 Feb 2019 17:52:03 +0600 Subject: [PATCH] Core Installer ( Possible issue, fix ) --- includes/class-wpdev-core-install.php | 20 +++++++++++--------- includes/class-wpdev-notices.php | 10 ++++++---- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/includes/class-wpdev-core-install.php b/includes/class-wpdev-core-install.php index c14867abb..692974fae 100755 --- a/includes/class-wpdev-core-install.php +++ b/includes/class-wpdev-core-install.php @@ -4,12 +4,19 @@ * WPDeveloper Core Install */ class WPDeveloper_Core_Installer { + /** + * Plugin Base Name + * + * @var string + */ + private $plugin_basename; /** * Instantiate the class * * @param string $affiliate */ - function __construct() { + function __construct( $plugin_basename = '' ) { + $this->plugin_basename = $plugin_basename; add_action( 'init', array( $this, 'init_hooks' ) ); } /** @@ -21,7 +28,7 @@ public function init_hooks() { if ( ! current_user_can( 'manage_options' ) ) { return; } - add_action( 'wp_ajax_wpdeveloper_upsale_core_install', array( $this, 'core_install' ) ); + add_action( 'wp_ajax_wpdeveloper_upsale_core_install_' . $this->plugin_basename, array( $this, 'core_install' ) ); } /** * Fail if plugin installtion/activation fails @@ -42,7 +49,7 @@ public function fail_on_error( $thing ) { * @return void */ public function core_install() { - check_ajax_referer( 'wpdeveloper_upsale_core_install' ); + check_ajax_referer( 'wpdeveloper_upsale_core_install_' . $this->plugin_basename ); if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( __( 'You don\'t have permission to install the plugins' ) ); @@ -92,9 +99,4 @@ public function install_plugin( $slug, $file ) { return activate_plugin( $plugin_basename ); } } - /** - * Initiate The Core Installer - */ - new WPDeveloper_Core_Installer(); -endif; - +endif; \ No newline at end of file diff --git a/includes/class-wpdev-notices.php b/includes/class-wpdev-notices.php index 0a0701050..540f16189 100755 --- a/includes/class-wpdev-notices.php +++ b/includes/class-wpdev-notices.php @@ -100,6 +100,8 @@ public function __construct( $plugin_file = '', $version = '' ) { if( ! class_exists( 'WPDeveloper_Core_Installer' ) ) { require_once dirname( __FILE__ ) . '/class-wpdev-core-install.php'; + + new WPDeveloper_Core_Installer( $this->plugin_name ); } } /** @@ -363,7 +365,7 @@ private function upsale_button(){ if( empty( $plugin_slug ) ) { return; } - echo ''; + echo ''; } /** * This methods is responsible for get notice image. @@ -723,7 +725,7 @@ public function upsale_button_script(){