From 575a9f2d9d49834f39333af4f6e658af997dcf1c Mon Sep 17 00:00:00 2001 From: Juan Carlo Jose Valerio Date: Mon, 3 Oct 2022 10:54:12 +0800 Subject: [PATCH 01/20] reset version number --- custom-visual-builder-button.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom-visual-builder-button.php b/custom-visual-builder-button.php index a662908..bb0adfa 100644 --- a/custom-visual-builder-button.php +++ b/custom-visual-builder-button.php @@ -3,7 +3,7 @@ * Plugin Name: Avada Button Shortcode * Plugin URI: https://4sure.com.au * Description: Adds Avada button shortcodes to the classic editor - * Version: 2.0.0 + * Version: 1.0.0 * Author: 4sure * Requires PHP: 7.2 * Requires at least: 5.8 From e606317c825f072cfec7d9723c9bd67e0e10b68c Mon Sep 17 00:00:00 2001 From: Juan Carlo Jose Valerio Date: Mon, 3 Oct 2022 11:23:40 +0800 Subject: [PATCH 02/20] added updater function --- custom-visual-builder-button.php | 9 +++ updater.php | 123 ++++++++++++++++++++++++++++++- 2 files changed, 131 insertions(+), 1 deletion(-) diff --git a/custom-visual-builder-button.php b/custom-visual-builder-button.php index bb0adfa..70f26af 100644 --- a/custom-visual-builder-button.php +++ b/custom-visual-builder-button.php @@ -10,6 +10,15 @@ * Author URI: https://4sure.com.au */ define('VBB_PLUGIN_PATH', home_url().'/wp-content/plugins/custom-visual-builder-button/'); +// Include our updater file +include_once( plugin_dir_path( __FILE__ ) . 'updater.php'); +$updater = new Custom_visual_builder_button_updater( __FILE__ ); // instantiate our class +$updater->set_username( '4surecarlo' ); // set username +$updater->set_repository( 'Avada-Custom-Visual-Builder-Button' ); // set repo +$updater->initialize(); // initialize the updater +if( ! class_exists( 'Custom_visual_builder_button_updater' ) ){ + include_once( plugin_dir_path( __FILE__ ) . 'updater.php' ); +} add_action( 'wp_enqueue_scripts', 'vbb_enqueue_styles' ); function vbb_enqueue_styles(){ wp_enqueue_style( 'vbb-widget-styles', VBB_PLUGIN_PATH.'css/frontend-button-widget-styles.css' ); diff --git a/updater.php b/updater.php index 7545277..685be6e 100644 --- a/updater.php +++ b/updater.php @@ -4,7 +4,11 @@ class Custom_visual_builder_button_updater { protected $plugin; protected $basename; protected $active; - + private $username; + private $repository; + private $authorize_token; + private $github_response; + public function __construct( $file ) { $this->file = $file; add_action( 'admin_init', array( $this, 'set_plugin_properties' ) ); @@ -16,4 +20,121 @@ class Custom_visual_builder_button_updater { $this->basename = plugin_basename( $this->file ); $this->active = is_plugin_active( $this->basename ); } + public function set_username( $username ) { + $this->username = $username; + } + public function set_repository( $repository ) { + $this->repository = $repository; + } + public function authorize( $token ) { + $this->authorize_token = $token; + } + private function get_repository_info() { + if ( is_null( $this->github_response ) ) { // Do we have a response? + $request_uri = sprintf( 'https://api.github.com/repos/%s/%s/releases', $this->username, $this->repository ); // Build URI + if( $this->authorize_token ) { // Is there an access token? + $request_uri = add_query_arg( 'access_token', $this->authorize_to , $request_uri ); // Append it + } + $response = json_decode( wp_remote_retrieve_body( wp_remote_get( $request_uri ) ), true ); // Get JSON and parse it + if( is_array( $response ) ) { // If it is an array + $response = current( $response ); // Get the first item + } + if( $this->authorize_token ) { // Is there an access token? + $response['zipball_url'] = add_query_arg( 'access_token', $this->authorize_token, $response['zipball_url'] ); // Update our zip url with token + } + $this->github_response = $response; // Set it to our property + } + } + public function initialize() { + add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'modify_transient' ), 10, 1 ); + add_filter( 'plugins_api', array( $this, 'plugin_popup' ), 10, 3); + add_filter( 'upgrader_post_install', array( $this, 'after_install' ), 10, 3 ); + + // Add Authorization Token to download_package + add_filter( 'upgrader_pre_download', + function() { + add_filter( 'http_request_args', [ $this, 'download_package' ], 15, 2 ); + return false; // upgrader_pre_download filter default return value. + } + ); + } + public function modify_transient( $transient ) { + + if( property_exists( $transient, 'checked') ) { // Check if transient has a checked property + if( $checked = $transient->checked ) { // Did WordPress check for updates? + $this->get_repository_info(); // Get the repo info + $out_of_date = version_compare( $this->github_response['tag_name'], $checked[$this->basename], 'gt' ); // Check if we're out of date + if( $out_of_date ) { + $new_files = $this->github_response['zipball_url']; // Get the ZIP + $slug = current( explode('/', $this->basename ) ); // Create valid slug + $plugin = array( // setup our plugin info + 'url' => $this->plugin["PluginURI"], + 'slug' => $slug, + 'package' => $new_files, + 'new_version' => $this->github_response['tag_name'] + ); + $transient->response[ $this->basename ] = (object) $plugin; // Return it in response + } + } + } + return $transient; // Return filtered transient + } + public function plugin_popup( $result, $action, $args ) { + + if( ! empty( $args->slug ) ) { // If there is a slug + + if( $args->slug == current( explode( '/' , $this->basename ) ) ) { // And it's our slug + + $this->get_repository_info(); // Get our repo info + + // Set it to an array + $plugin = array( + 'name' => $this->plugin["Name"], + 'slug' => $this->basename, + 'version' => $this->github_response['tag_name'], + 'author' => $this->plugin["AuthorName"], + 'author_profile' => $this->plugin["AuthorURI"], + 'last_updated' => $this->github_response['published_at'], + 'homepage' => $this->plugin["PluginURI"], + 'short_description' => $this->plugin["Description"], + 'sections' => array( + 'Description' => $this->plugin["Description"], + 'Updates' => $this->github_response['body'], + ), + 'download_link' => $this->github_response['zipball_url'] + ); + + return (object) $plugin; // Return the data + } + + } + return $result; // Otherwise return default + } + + public function download_package( $args, $url ) { + + if ( null !== $args['filename'] ) { + if( $this->authorize_token ) { + $args = array_merge( $args, array( "headers" => array( "Authorization" => "token {$this->authorize_token}" ) ) ); + } + } + + remove_filter( 'http_request_args', [ $this, 'download_package' ] ); + + return $args; + } + + public function after_install( $response, $hook_extra, $result ) { + global $wp_filesystem; // Get global FS object + + $install_directory = plugin_dir_path( $this->file ); // Our plugin directory + $wp_filesystem->move( $result['destination'], $install_directory ); // Move files to the plugin dir + $result['destination'] = $install_directory; // Set the destination for the rest of the stack + + if ( $this->active ) { // If it was active + activate_plugin( $this->basename ); // Reactivate + } + + return $result; + } } From 79a33bf95339f8cd7fef619161282cc8feb68356 Mon Sep 17 00:00:00 2001 From: Juan Carlo Jose Valerio Date: Mon, 3 Oct 2022 11:25:07 +0800 Subject: [PATCH 03/20] test update --- custom-visual-builder-button.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom-visual-builder-button.php b/custom-visual-builder-button.php index 70f26af..20002d9 100644 --- a/custom-visual-builder-button.php +++ b/custom-visual-builder-button.php @@ -3,7 +3,7 @@ * Plugin Name: Avada Button Shortcode * Plugin URI: https://4sure.com.au * Description: Adds Avada button shortcodes to the classic editor - * Version: 1.0.0 + * Version: 1.0.1 * Author: 4sure * Requires PHP: 7.2 * Requires at least: 5.8 From e15b64d3e43547560947c2a486a8a7fb212ef550 Mon Sep 17 00:00:00 2001 From: Juan Carlo Jose Valerio Date: Mon, 3 Oct 2022 13:31:55 +0800 Subject: [PATCH 04/20] pre-update test --- custom-visual-builder-button.php | 2 +- updater.php | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/custom-visual-builder-button.php b/custom-visual-builder-button.php index 20002d9..42967f7 100644 --- a/custom-visual-builder-button.php +++ b/custom-visual-builder-button.php @@ -3,7 +3,7 @@ * Plugin Name: Avada Button Shortcode * Plugin URI: https://4sure.com.au * Description: Adds Avada button shortcodes to the classic editor - * Version: 1.0.1 + * Version: 0.9.0 * Author: 4sure * Requires PHP: 7.2 * Requires at least: 5.8 diff --git a/updater.php b/updater.php index 685be6e..2bc76fc 100644 --- a/updater.php +++ b/updater.php @@ -46,10 +46,10 @@ class Custom_visual_builder_button_updater { } } public function initialize() { - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'modify_transient' ), 10, 1 ); + /* Adding a filter to the transient. */ + add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'modify_transient' ), 10, 1 ); add_filter( 'plugins_api', array( $this, 'plugin_popup' ), 10, 3); add_filter( 'upgrader_post_install', array( $this, 'after_install' ), 10, 3 ); - // Add Authorization Token to download_package add_filter( 'upgrader_pre_download', function() { @@ -59,7 +59,6 @@ class Custom_visual_builder_button_updater { ); } public function modify_transient( $transient ) { - if( property_exists( $transient, 'checked') ) { // Check if transient has a checked property if( $checked = $transient->checked ) { // Did WordPress check for updates? $this->get_repository_info(); // Get the repo info @@ -80,7 +79,6 @@ class Custom_visual_builder_button_updater { return $transient; // Return filtered transient } public function plugin_popup( $result, $action, $args ) { - if( ! empty( $args->slug ) ) { // If there is a slug if( $args->slug == current( explode( '/' , $this->basename ) ) ) { // And it's our slug From 7ba72153b309a6df9f856222982d2cc00e69cce0 Mon Sep 17 00:00:00 2001 From: Juan Carlo Jose Valerio Date: Mon, 3 Oct 2022 13:33:08 +0800 Subject: [PATCH 05/20] update version number to 1 --- custom-visual-builder-button.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom-visual-builder-button.php b/custom-visual-builder-button.php index 42967f7..70f26af 100644 --- a/custom-visual-builder-button.php +++ b/custom-visual-builder-button.php @@ -3,7 +3,7 @@ * Plugin Name: Avada Button Shortcode * Plugin URI: https://4sure.com.au * Description: Adds Avada button shortcodes to the classic editor - * Version: 0.9.0 + * Version: 1.0.0 * Author: 4sure * Requires PHP: 7.2 * Requires at least: 5.8 From 494f3e72610c1993f377c1d7fb7ead46993953d4 Mon Sep 17 00:00:00 2001 From: 4surecarlo <114891181+4surecarlo@users.noreply.github.com> Date: Mon, 3 Oct 2022 14:53:07 +0800 Subject: [PATCH 06/20] Updated readme --- README.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index af59f48..aebbaec 100644 --- a/README.md +++ b/README.md @@ -1 +1,21 @@ -# Avada-Custom-Visual-Builder-Button \ No newline at end of file +# Avada-Custom-Visual-Builder-Button + +

Adds Avada button shortcodes to the classic editor.

+ + + + + + + + + + + +
ParametersDescription
linkurl (required)
textlabel (required)
targetleave blank / newtab / lightbox
icontrue / false
icon_classfont awesome class (optional)
icon_positionleft / right
+ +

Basics:

+
    +
  • [button link="https://google.com/" text="Google"]
  • +
  • [button link="https://youtube.com/" text="Youtube" target="newtab"]
  • +
From 24307c5ee512ceb29849cd2ed66b6ef8d31f42ae Mon Sep 17 00:00:00 2001 From: 4surecarlo <114891181+4surecarlo@users.noreply.github.com> Date: Mon, 3 Oct 2022 14:57:08 +0800 Subject: [PATCH 07/20] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index aebbaec..418c6a9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Avada-Custom-Visual-Builder-Button - -

Adds Avada button shortcodes to the classic editor.

+ +

Adds a custom Avada button shortcode to the classic editor with simple parameters.

From e9aec43e03ce460ab25054cc1575a8e55020c25e Mon Sep 17 00:00:00 2001 From: 4surecarlo <114891181+4surecarlo@users.noreply.github.com> Date: Mon, 3 Oct 2022 14:57:35 +0800 Subject: [PATCH 08/20] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 418c6a9..72556b6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ -# Avada-Custom-Visual-Builder-Button - +# Avada Custom Visual Builder Button +

Adds a custom Avada button shortcode to the classic editor with simple parameters.

+
From 968446895cd3db19b2d46a40cc7cb9d42f076195 Mon Sep 17 00:00:00 2001 From: 4suredev Date: Mon, 10 Oct 2022 11:10:22 +0800 Subject: [PATCH 09/20] updated repository username --- custom-visual-builder-button.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom-visual-builder-button.php b/custom-visual-builder-button.php index 70f26af..5b45b96 100644 --- a/custom-visual-builder-button.php +++ b/custom-visual-builder-button.php @@ -13,7 +13,7 @@ define('VBB_PLUGIN_PATH', home_url().'/wp-content/plugins/custom-visual-builder- // Include our updater file include_once( plugin_dir_path( __FILE__ ) . 'updater.php'); $updater = new Custom_visual_builder_button_updater( __FILE__ ); // instantiate our class -$updater->set_username( '4surecarlo' ); // set username +$updater->set_username( '4suredev' ); // set username $updater->set_repository( 'Avada-Custom-Visual-Builder-Button' ); // set repo $updater->initialize(); // initialize the updater if( ! class_exists( 'Custom_visual_builder_button_updater' ) ){ From 104a7995c6219524acf495a46b42975c2599c6bd Mon Sep 17 00:00:00 2001 From: 4suredev Date: Mon, 10 Oct 2022 11:12:34 +0800 Subject: [PATCH 10/20] updated repository user --- custom-visual-builder-button.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom-visual-builder-button.php b/custom-visual-builder-button.php index 5b45b96..9c60391 100644 --- a/custom-visual-builder-button.php +++ b/custom-visual-builder-button.php @@ -3,7 +3,7 @@ * Plugin Name: Avada Button Shortcode * Plugin URI: https://4sure.com.au * Description: Adds Avada button shortcodes to the classic editor - * Version: 1.0.0 + * Version: 1.0.1 * Author: 4sure * Requires PHP: 7.2 * Requires at least: 5.8 From e459773d9fef1589ac85e764221f7ad3de541a85 Mon Sep 17 00:00:00 2001 From: 4suredev Date: Mon, 10 Oct 2022 11:16:40 +0800 Subject: [PATCH 11/20] updated repository details --- custom-visual-builder-button.php | 1 - 1 file changed, 1 deletion(-) diff --git a/custom-visual-builder-button.php b/custom-visual-builder-button.php index 9c60391..cea9047 100644 --- a/custom-visual-builder-button.php +++ b/custom-visual-builder-button.php @@ -10,7 +10,6 @@ * Author URI: https://4sure.com.au */ define('VBB_PLUGIN_PATH', home_url().'/wp-content/plugins/custom-visual-builder-button/'); -// Include our updater file include_once( plugin_dir_path( __FILE__ ) . 'updater.php'); $updater = new Custom_visual_builder_button_updater( __FILE__ ); // instantiate our class $updater->set_username( '4suredev' ); // set username From 2b9838df1f00dc73af8c976574e9539496f98c8b Mon Sep 17 00:00:00 2001 From: 4suredev <64234115+4suredev@users.noreply.github.com> Date: Fri, 14 Oct 2022 14:35:10 +0800 Subject: [PATCH 12/20] Bug Fixes Fixed issue where css wont load after plugin update --- custom-visual-builder-button.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/custom-visual-builder-button.php b/custom-visual-builder-button.php index cea9047..8fc56e3 100644 --- a/custom-visual-builder-button.php +++ b/custom-visual-builder-button.php @@ -3,13 +3,13 @@ * Plugin Name: Avada Button Shortcode * Plugin URI: https://4sure.com.au * Description: Adds Avada button shortcodes to the classic editor - * Version: 1.0.1 + * Version: 1.0.2 * Author: 4sure * Requires PHP: 7.2 * Requires at least: 5.8 * Author URI: https://4sure.com.au */ -define('VBB_PLUGIN_PATH', home_url().'/wp-content/plugins/custom-visual-builder-button/'); +define('VBB_PLUGIN_PATH', plugin_dir_url( __FILE__ )); include_once( plugin_dir_path( __FILE__ ) . 'updater.php'); $updater = new Custom_visual_builder_button_updater( __FILE__ ); // instantiate our class $updater->set_username( '4suredev' ); // set username From e98e6c064ca51b8572fa5957de36073b1519d2ff Mon Sep 17 00:00:00 2001 From: 4suredev <64234115+4suredev@users.noreply.github.com> Date: Wed, 19 Oct 2022 14:42:13 +0800 Subject: [PATCH 13/20] updated function names to avoid potential conflicts with other plugins --- custom-visual-builder-button.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/custom-visual-builder-button.php b/custom-visual-builder-button.php index 8fc56e3..84d6566 100644 --- a/custom-visual-builder-button.php +++ b/custom-visual-builder-button.php @@ -3,7 +3,7 @@ * Plugin Name: Avada Button Shortcode * Plugin URI: https://4sure.com.au * Description: Adds Avada button shortcodes to the classic editor - * Version: 1.0.2 + * Version: 1.0.3 * Author: 4sure * Requires PHP: 7.2 * Requires at least: 5.8 @@ -22,8 +22,8 @@ add_action( 'wp_enqueue_scripts', 'vbb_enqueue_styles' ); function vbb_enqueue_styles(){ wp_enqueue_style( 'vbb-widget-styles', VBB_PLUGIN_PATH.'css/frontend-button-widget-styles.css' ); } -add_shortcode('button', 'custom_visual_builder_button'); -function custom_visual_builder_button($atts = array()){ +add_shortcode('button', 'vbb_custom_visual_builder_button'); +function vbb_custom_visual_builder_button($atts = array()){ $args = shortcode_atts( array( 'target' => '', @@ -52,7 +52,7 @@ function custom_visual_builder_button($atts = array()){ return $html; } //add media button to visual builder -function add_shortcodes_media_button() { +function vbb_add_shortcodes_media_button() { $the_page = get_current_screen(); $current_page = $the_page->post_type; $allowed = array( @@ -76,19 +76,19 @@ function add_shortcodes_media_button() { '; } } -add_action( 'media_buttons', 'add_shortcodes_media_button'); +add_action( 'media_buttons', 'vbb_add_shortcodes_media_button'); //Button shortcode admin bar widget -add_action('admin_enqueue_scripts', 'my_enqueue'); -function my_enqueue($hook) { +add_action('admin_enqueue_scripts', 'vbb_admin_scripts_enqueue'); +function vbb_admin_scripts_enqueue($hook) { // Only add to the edit post/page admin page. if ('post.php' == $hook || 'post-new.php' == $hook || 'toplevel_page_access-manager' == $hook) { wp_enqueue_script('admin_custom_script', VBB_PLUGIN_PATH.'js/custom-admin-scripts.js'); wp_enqueue_script('jquery-ui', 'https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.13.2/jquery-ui.min.js'); }else{return;} } -add_action( 'edit_form_after_editor', 'render_button_shortcode_dialog' ); -add_action( 'toplevel_page_access-manager', 'render_button_shortcode_dialog', 20 ); -function render_button_shortcode_dialog( $post ){ +add_action( 'edit_form_after_editor', 'vbb_render_button_shortcode_dialog' ); +add_action( 'toplevel_page_access-manager', 'vbb_render_button_shortcode_dialog', 20 ); +function vbb_render_button_shortcode_dialog( $post ){ echo ' '; } \ No newline at end of file From 572966dfae4a64c1e7f1c22e5447eb36bf2afd75 Mon Sep 17 00:00:00 2001 From: 4suredev <64234115+4suredev@users.noreply.github.com> Date: Fri, 21 Oct 2022 15:03:06 +0800 Subject: [PATCH 17/20] updated to v1.0.5 --- custom-visual-builder-button.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom-visual-builder-button.php b/custom-visual-builder-button.php index d7f1693..1f2ccf0 100644 --- a/custom-visual-builder-button.php +++ b/custom-visual-builder-button.php @@ -3,7 +3,7 @@ * Plugin Name: Avada Button Shortcode * Plugin URI: https://4sure.com.au * Description: Adds Avada button shortcodes to the classic editor - * Version: 1.0.4 + * Version: 1.0.5 * Author: 4sure * Requires PHP: 7.2 * Requires at least: 5.8 From a84cfc60e36eb0a504129e364fe2b391a6eb0b9e Mon Sep 17 00:00:00 2001 From: 4suredev <64234115+4suredev@users.noreply.github.com> Date: Thu, 8 May 2025 10:46:28 +0800 Subject: [PATCH 18/20] Bug fixes Fix issue in updater causing critical error, update plugin name --- custom-visual-builder-button.php | 4 ++-- updater.php | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/custom-visual-builder-button.php b/custom-visual-builder-button.php index 1f2ccf0..f2c0ccd 100644 --- a/custom-visual-builder-button.php +++ b/custom-visual-builder-button.php @@ -1,9 +1,9 @@ checked ) { // Did WordPress check for updates? + if( $transient->checked ) { // Did WordPress check for updates? + $checked = $transient->checked; $this->get_repository_info(); // Get the repo info - $out_of_date = version_compare( $this->github_response['tag_name'], $checked[$this->basename], 'gt' ); // Check if we're out of date - if( $out_of_date ) { + if (isset($checked[$this->basename]) != null) { + $out_of_date = version_compare( $this->github_response['tag_name'], $checked[$this->basename], 'gt' ); // Check if we're out of date + } else { + $out_of_date = false; + } + if( $out_of_date != false ) { $new_files = $this->github_response['zipball_url']; // Get the ZIP $slug = current( explode('/', $this->basename ) ); // Create valid slug $plugin = array( // setup our plugin info From fc580619ea18c6b4bd7dce291d31a75b6c410bdb Mon Sep 17 00:00:00 2001 From: 4suredev <64234115+4suredev@users.noreply.github.com> Date: Mon, 26 May 2025 08:56:44 +0800 Subject: [PATCH 19/20] Update to fix bugs --- custom-visual-builder-button.php | 2 +- updater.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/custom-visual-builder-button.php b/custom-visual-builder-button.php index f2c0ccd..161b2bc 100644 --- a/custom-visual-builder-button.php +++ b/custom-visual-builder-button.php @@ -3,7 +3,7 @@ * Plugin Name: 4sure - Avada Button Shortcode * Plugin URI: https://4sure.com.au * Description: Adds Avada button shortcodes to the classic editor - * Version: 1.0.6 + * Version: 1.0.7 * Author: 4sure * Requires PHP: 7.2 * Requires at least: 5.8 diff --git a/updater.php b/updater.php index 1771058..3b10c47 100644 --- a/updater.php +++ b/updater.php @@ -63,7 +63,7 @@ class Custom_visual_builder_button_updater { if( $transient->checked ) { // Did WordPress check for updates? $checked = $transient->checked; $this->get_repository_info(); // Get the repo info - if (isset($checked[$this->basename]) != null) { + if (!empty($checked[$this->basename])) { $out_of_date = version_compare( $this->github_response['tag_name'], $checked[$this->basename], 'gt' ); // Check if we're out of date } else { $out_of_date = false; From e6dcbe86b64954558321fe8f12abc19fac776cd9 Mon Sep 17 00:00:00 2001 From: 4suredev <64234115+4suredev@users.noreply.github.com> Date: Thu, 19 Jun 2025 08:36:26 +0800 Subject: [PATCH 20/20] Check response before comparing versions --- custom-visual-builder-button.php | 2 +- updater.php | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/custom-visual-builder-button.php b/custom-visual-builder-button.php index 161b2bc..3ab14c8 100644 --- a/custom-visual-builder-button.php +++ b/custom-visual-builder-button.php @@ -3,7 +3,7 @@ * Plugin Name: 4sure - Avada Button Shortcode * Plugin URI: https://4sure.com.au * Description: Adds Avada button shortcodes to the classic editor - * Version: 1.0.7 + * Version: 1.0.8 * Author: 4sure * Requires PHP: 7.2 * Requires at least: 5.8 diff --git a/updater.php b/updater.php index 3b10c47..29622b8 100644 --- a/updater.php +++ b/updater.php @@ -47,7 +47,7 @@ class Custom_visual_builder_button_updater { } public function initialize() { /* Adding a filter to the transient. */ - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'modify_transient' ), 10, 1 ); + add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'modify_transient' ), 10, 1 ); add_filter( 'plugins_api', array( $this, 'plugin_popup' ), 10, 3); add_filter( 'upgrader_post_install', array( $this, 'after_install' ), 10, 3 ); // Add Authorization Token to download_package @@ -60,15 +60,14 @@ class Custom_visual_builder_button_updater { } public function modify_transient( $transient ) { if( property_exists( $transient, 'checked') ) { // Check if transient has a checked property - if( $transient->checked ) { // Did WordPress check for updates? - $checked = $transient->checked; + if( $checked = $transient->checked ) { // Did WordPress check for updates? $this->get_repository_info(); // Get the repo info - if (!empty($checked[$this->basename])) { - $out_of_date = version_compare( $this->github_response['tag_name'], $checked[$this->basename], 'gt' ); // Check if we're out of date + if( is_array($this->github_response) && !empty($this->github_response['tag_name']) && !empty($checked[$this->basename]) ) { // Check response + $out_of_date = version_compare( $this->github_response['tag_name'], $checked[$this->basename], 'gt' ); // Check if we're out of date } else { $out_of_date = false; } - if( $out_of_date != false ) { + if( $out_of_date ) { $new_files = $this->github_response['zipball_url']; // Get the ZIP $slug = current( explode('/', $this->basename ) ); // Create valid slug $plugin = array( // setup our plugin info