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 1/8] 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 5/8] 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 6/8] 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 7/8] 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 8/8] 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