diff --git a/README.md b/README.md
index af59f48..72556b6 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,22 @@
-# Avada-Custom-Visual-Builder-Button
\ No newline at end of file
+# Avada Custom Visual Builder Button
+
+
Adds a custom Avada button shortcode to the classic editor with simple parameters.
+
+
+
+
+ | Parameters | Description |
+ | link | url (required) |
+ | text | label (required) |
+ | target | leave blank / newtab / lightbox |
+ | icon | true / false |
+ | icon_class | font awesome class (optional) |
+ | icon_position | left / right |
+
+
+
+Basics:
+
+- [button link="https://google.com/" text="Google"]
+- [button link="https://youtube.com/" text="Youtube" target="newtab"]
+
diff --git a/custom-visual-builder-button.php b/custom-visual-builder-button.php
index 70f26af..3ab14c8 100644
--- a/custom-visual-builder-button.php
+++ b/custom-visual-builder-button.php
@@ -1,19 +1,18 @@
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' ) ){
@@ -23,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' => '',
@@ -53,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(
@@ -62,10 +61,11 @@ function add_shortcodes_media_button() {
'product',
'tribe_events'
);
- if (in_array($current_page, $allowed, false) || $the_page->base == 'toplevel_page_access-manager' || $the_page->base == 'post'){
+ if (in_array($current_page, $allowed, false) || $the_page->base == 'toplevel_page_access-manager' || $the_page->base == 'post' || $the_page->base == 'toplevel_page_acc-default-settings'){
printf( '' . ' %s' . '', '#', __( 'Generate Button', 'textdomain' ) );
}
- if(get_current_screen()->base == 'toplevel_page_access-manager'){
+ $current_screen = get_current_screen()->base;
+ if ($current_screen == 'toplevel_page_access-manager' || $current_screen == 'toplevel_page_acc-default-settings'){
echo '';
}
}
-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');
+ if ('post.php' == $hook || 'post-new.php' == $hook || 'toplevel_page_access-manager' == $hook || 'toplevel_page_acc-default-settings' == $hook) {
+ wp_enqueue_script('admin_custom_script', VBB_PLUGIN_PATH.'js/custom-admin-scripts.js', array('jquery-ui-dialog'));
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 );
+add_action( 'toplevel_page_acc-default-settings', 'vbb_render_button_shortcode_dialog', 20 );
+function vbb_render_button_shortcode_dialog( $post ){
echo '
';
}
\ No newline at end of file
diff --git a/js/custom-admin-scripts.js b/js/custom-admin-scripts.js
index 75c6c3c..8a7a05b 100644
--- a/js/custom-admin-scripts.js
+++ b/js/custom-admin-scripts.js
@@ -14,13 +14,22 @@ jQuery(document).ready(function($){
},
minWidth: 480
});
- acf.addAction('load', function(){
+ if(typeof acf != 'undefined'){
+ acf.addAction('load', function(){
+ $(document).on("click", ".generate-button-shortcode", function(e){
+ e.preventDefault();
+ $("#button-shortcode-dialog").dialog("open");
+ $("#page-mask").css({"opacity":1, "pointer-events": "auto"});
+ });
+ });
+ }else{
$(document).on("click", ".generate-button-shortcode", function(e){
e.preventDefault();
$("#button-shortcode-dialog").dialog("open");
$("#page-mask").css({"opacity":1, "pointer-events": "auto"});
});
- });
+ }
+
$('.generate-button-shortcode').click(function(e){
e.preventDefault();
$("#button-shortcode-dialog").dialog("open");
diff --git a/updater.php b/updater.php
index 2bc76fc..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,9 +60,13 @@ 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?
+ 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( 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 ) {
$new_files = $this->github_response['zipball_url']; // Get the ZIP
$slug = current( explode('/', $this->basename ) ); // Create valid slug