From 1d5a893231686aa1eb57258f14749be2fd02ac1b Mon Sep 17 00:00:00 2001 From: Jeremy Herve Date: Fri, 21 Apr 2017 11:51:58 -0600 Subject: [PATCH 1/3] Avoid errors when the plugin is installed manually. Fixes #20 When installing the plugin via the zip file generated from GitHub, the directory name is jetpack-beta-master. We should use that naming convention in the plugin as well. --- autoupdate-self.php | 8 ++++---- jetpack-beta-admin.php | 2 +- jetpack-beta.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/autoupdate-self.php b/autoupdate-self.php index 4d4b7ed23678d..34ddf89dfc764 100644 --- a/autoupdate-self.php +++ b/autoupdate-self.php @@ -26,9 +26,9 @@ public function __construct() { } $this->config = array( - 'plugin_file' => 'jetpack-beta/jetpack-beta.php', - 'slug' => 'jetpack-beta', - 'proper_folder_name' => 'jetpack-beta', + 'plugin_file' => 'jetpack-beta-master/jetpack-beta.php', + 'slug' => 'jetpack-beta-master', + 'proper_folder_name' => 'jetpack-beta-master', 'api_url' => 'https://api.github.com/repos/Automattic/jetpack-beta', 'github_url' => 'https://github.com/Automattic/jetpack-beta', 'requires' => '4.7', @@ -180,7 +180,7 @@ public function upgrader_source_selection( $source, $remote_source, $upgrader ) } return $source; } - + public function auto_update_jetpack_beta( $update, $item ) { if ( 'sure' !== get_option( 'jp_beta_autoupdate') ) { return $update; diff --git a/jetpack-beta-admin.php b/jetpack-beta-admin.php index 79045bca091fb..d593b3b40abb1 100644 --- a/jetpack-beta-admin.php +++ b/jetpack-beta-admin.php @@ -17,7 +17,7 @@ static function add_actions() { add_action( "load-$hook", array( __CLASS__, 'admin_page_load' ) ); add_action( "admin_print_styles-$hook", array( __CLASS__, 'admin_styles' ) ); add_action( "admin_print_scripts-$hook", array( __CLASS__, 'admin_scripts' ) ); - add_filter( 'plugin_action_links_' . plugin_basename( 'jetpack-beta/jetpack-beta.php' ), array( __CLASS__, 'admin_plugin_settings_link' ) ); + add_filter( 'plugin_action_links_' . plugin_basename( 'jetpack-beta-master/jetpack-beta.php' ), array( __CLASS__, 'admin_plugin_settings_link' ) ); } static function get_page_hook() { diff --git a/jetpack-beta.php b/jetpack-beta.php index 7297659334a5d..a59761fe3b3b3 100644 --- a/jetpack-beta.php +++ b/jetpack-beta.php @@ -35,7 +35,7 @@ * Jetpack beta manages files inside jetpack-dev folder this folder should contain * */ -define( 'JPBETA__PLUGIN_FOLDER', plugins_url() . '/jetpack-beta/' ); +define( 'JPBETA__PLUGIN_FOLDER', plugins_url() . '/jetpack-beta-master/' ); define( 'JPBETA__PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); define( 'JPBETA__PLUGIN_FILE', __FILE__ ); define( 'JPBETA_VERSION', 2 ); From 70b80d9313bf8eea61495f48e87863bb43326703 Mon Sep 17 00:00:00 2001 From: Jeremy Herve Date: Fri, 21 Apr 2017 12:37:42 -0600 Subject: [PATCH 2/3] Make plugin folder and diretories more dynamic. @see https://github.com/Automattic/jetpack-beta/pull/21#issuecomment-296261198 --- autoupdate-self.php | 6 +++--- jetpack-beta-admin.php | 2 +- jetpack-beta.php | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/autoupdate-self.php b/autoupdate-self.php index 34ddf89dfc764..f5d949e262731 100644 --- a/autoupdate-self.php +++ b/autoupdate-self.php @@ -26,9 +26,9 @@ public function __construct() { } $this->config = array( - 'plugin_file' => 'jetpack-beta-master/jetpack-beta.php', - 'slug' => 'jetpack-beta-master', - 'proper_folder_name' => 'jetpack-beta-master', + 'plugin_file' => JPBETA__PLUGIN_BASENAME . '/jetpack-beta.php', + 'slug' => JPBETA__PLUGIN_BASENAME, + 'proper_folder_name' => JPBETA__PLUGIN_BASENAME, 'api_url' => 'https://api.github.com/repos/Automattic/jetpack-beta', 'github_url' => 'https://github.com/Automattic/jetpack-beta', 'requires' => '4.7', diff --git a/jetpack-beta-admin.php b/jetpack-beta-admin.php index d593b3b40abb1..9d27c05457a03 100644 --- a/jetpack-beta-admin.php +++ b/jetpack-beta-admin.php @@ -17,7 +17,7 @@ static function add_actions() { add_action( "load-$hook", array( __CLASS__, 'admin_page_load' ) ); add_action( "admin_print_styles-$hook", array( __CLASS__, 'admin_styles' ) ); add_action( "admin_print_scripts-$hook", array( __CLASS__, 'admin_scripts' ) ); - add_filter( 'plugin_action_links_' . plugin_basename( 'jetpack-beta-master/jetpack-beta.php' ), array( __CLASS__, 'admin_plugin_settings_link' ) ); + add_filter( 'plugin_action_links_' . JPBETA__PLUGIN_BASENAME . '/jetpack-beta.php', array( __CLASS__, 'admin_plugin_settings_link' ) ); } static function get_page_hook() { diff --git a/jetpack-beta.php b/jetpack-beta.php index a59761fe3b3b3..39bef5596b2bb 100644 --- a/jetpack-beta.php +++ b/jetpack-beta.php @@ -35,9 +35,10 @@ * Jetpack beta manages files inside jetpack-dev folder this folder should contain * */ -define( 'JPBETA__PLUGIN_FOLDER', plugins_url() . '/jetpack-beta-master/' ); +define( 'JPBETA__PLUGIN_FOLDER', plugin_dir_url( __FILE__ ) ); define( 'JPBETA__PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); define( 'JPBETA__PLUGIN_FILE', __FILE__ ); +define( 'JPBETA__PLUGIN_BASENAME', dirname( plugin_basename( __FILE__ ) ) ); define( 'JPBETA_VERSION', 2 ); define( 'JPBETA_DEFAULT_BRANCH', 'rc_only' ); From de3c5d1e7e91a5b287fcb72f654821fb64f62f0b Mon Sep 17 00:00:00 2001 From: Enej Bajgoric Date: Fri, 21 Apr 2017 12:02:20 -0700 Subject: [PATCH 3/3] Update JETPACK__PLUGIN_FOLDER remove JPBETA__PLUGIN_BASENAME --- autoupdate-self.php | 6 +++--- jetpack-beta-admin.php | 2 +- jetpack-beta.php | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/autoupdate-self.php b/autoupdate-self.php index f5d949e262731..f1823f0140c34 100644 --- a/autoupdate-self.php +++ b/autoupdate-self.php @@ -26,9 +26,9 @@ public function __construct() { } $this->config = array( - 'plugin_file' => JPBETA__PLUGIN_BASENAME . '/jetpack-beta.php', - 'slug' => JPBETA__PLUGIN_BASENAME, - 'proper_folder_name' => JPBETA__PLUGIN_BASENAME, + 'plugin_file' => JPBETA__PLUGIN_FOLDER . '/jetpack-beta.php', + 'slug' => JPBETA__PLUGIN_FOLDER, + 'proper_folder_name' => JPBETA__PLUGIN_FOLDER, 'api_url' => 'https://api.github.com/repos/Automattic/jetpack-beta', 'github_url' => 'https://github.com/Automattic/jetpack-beta', 'requires' => '4.7', diff --git a/jetpack-beta-admin.php b/jetpack-beta-admin.php index 9d27c05457a03..e4cd62b4eecf6 100644 --- a/jetpack-beta-admin.php +++ b/jetpack-beta-admin.php @@ -17,7 +17,7 @@ static function add_actions() { add_action( "load-$hook", array( __CLASS__, 'admin_page_load' ) ); add_action( "admin_print_styles-$hook", array( __CLASS__, 'admin_styles' ) ); add_action( "admin_print_scripts-$hook", array( __CLASS__, 'admin_scripts' ) ); - add_filter( 'plugin_action_links_' . JPBETA__PLUGIN_BASENAME . '/jetpack-beta.php', array( __CLASS__, 'admin_plugin_settings_link' ) ); + add_filter( 'plugin_action_links_' . JPBETA__PLUGIN_FOLDER . '/jetpack-beta.php', array( __CLASS__, 'admin_plugin_settings_link' ) ); } static function get_page_hook() { diff --git a/jetpack-beta.php b/jetpack-beta.php index 39bef5596b2bb..9ca0e87ae6f6c 100644 --- a/jetpack-beta.php +++ b/jetpack-beta.php @@ -35,10 +35,9 @@ * Jetpack beta manages files inside jetpack-dev folder this folder should contain * */ -define( 'JPBETA__PLUGIN_FOLDER', plugin_dir_url( __FILE__ ) ); +define( 'JPBETA__PLUGIN_FOLDER', basename( __DIR__ ) ); define( 'JPBETA__PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); define( 'JPBETA__PLUGIN_FILE', __FILE__ ); -define( 'JPBETA__PLUGIN_BASENAME', dirname( plugin_basename( __FILE__ ) ) ); define( 'JPBETA_VERSION', 2 ); define( 'JPBETA_DEFAULT_BRANCH', 'rc_only' );