| @@ -7,61 +7,61 @@ | ||
| 7 | 7 | class maxButtonsPlugin |
| 8 | 8 | { |
| 9 | 9 | |
| 10 | 10 | protected $installed_version = 0; |
| 11 | - protected $plugin_name; | |
| 11 | + protected $plugin_name; | |
| 12 | 12 | protected $plugin_url; |
| 13 | 13 | protected $plugin_path; |
| 14 | 14 | protected $debug_mode = false; |
| 15 | 15 | protected $footer = array(); |
| 16 | 16 | |
| 17 | - protected static $notices = array(); | |
| 18 | - | |
| 19 | - protected $mainClasses = array(); | |
| 20 | - | |
| 17 | + protected static $notices = array(); | |
| 18 | + | |
| 19 | + protected $mainClasses = array(); | |
| 20 | + | |
| 21 | 21 | protected static $instance; |
| 22 | - | |
| 23 | - /* Class constructor | |
| 22 | + | |
| 23 | + /* Class constructor | |
| 24 | 24 | Add hooks and actions used by this plugin. Sets plugin environment information |
| 25 | 25 | */ |
| 26 | 26 | function __construct() |
| 27 | 27 | { |
| 28 | - maxUtils::timeInit(); // benchmark timer init. | |
| 28 | + maxUtils::timeInit(); // benchmark timer init. | |
| 29 | 29 | |
| 30 | 30 | $this->plugin_url = self::get_plugin_url(); //plugins_url() . '/' . $this->plugin_name; |
| 31 | - $this->plugin_path = self::get_plugin_path(); //plugin_dir_path($rootfile); | |
| 31 | + $this->plugin_path = self::get_plugin_path(); //plugin_dir_path($rootfile); | |
| 32 | 32 | $this->plugin_name = trim(basename($this->plugin_path), '/'); |
| 33 | - | |
| 34 | - $this->installed_version = get_option(MAXBUTTONS_VERSION_KEY); | |
| 35 | - | |
| 33 | + | |
| 34 | + $this->installed_version = get_option(MAXBUTTONS_VERSION_KEY); | |
| 35 | + | |
| 36 | 36 | if ( defined('MAXBUTTONS_DEBUG') && MAXBUTTONS_DEBUG) |
| 37 | 37 | $this->debug_mode = true; |
| 38 | - | |
| 38 | + | |
| 39 | 39 | add_action('plugins_loaded', array($this, 'load_textdomain')); |
| 40 | 40 | |
| 41 | 41 | add_filter('widget_text', 'do_shortcode'); |
| 42 | - add_shortcode('maxbutton', array($this, 'shortcode')); | |
| 42 | + add_shortcode('maxbutton', array($this, 'shortcode')); | |
| 43 | 43 | |
| 44 | - add_action("mb-footer", array($this, 'do_footer'),10,3); | |
| 45 | - add_action("wp_footer", array($this, "footer")); | |
| 46 | - | |
| 44 | + add_action("mb-footer", array($this, 'do_footer'),10,3); | |
| 45 | + add_action("wp_footer", array($this, "footer")); | |
| 46 | + | |
| 47 | 47 | // Media buttons |
| 48 | 48 | add_action('media_buttons', array($this,'media_button')); |
| 49 | 49 | |
| 50 | 50 | add_filter('plugin_action_links', array($this, "plugin_action_links"), 10, 2); |
| 51 | 51 | add_filter('plugin_row_meta', array($this, 'plugin_row_meta'), 10, 2); |
| 52 | - | |
| 52 | + | |
| 53 | 53 | if( is_admin()) |
| 54 | - { | |
| 54 | + { | |
| 55 | 55 | add_action('admin_enqueue_scripts', array($this,'add_admin_styles')); |
| 56 | - add_action('admin_enqueue_scripts', array($this,'add_admin_scripts')); | |
| 56 | + add_action('admin_enqueue_scripts', array($this,'add_admin_scripts')); | |
| 57 | 57 | add_action('admin_enqueue_scripts', array(maxUtils::namespaceit('maxUtils'), 'fixFAConflict'),999); |
| 58 | - | |
| 58 | + | |
| 59 | 59 | add_action('admin_init', array($this,'register_settings' )); |
| 60 | - | |
| 60 | + | |
| 61 | 61 | add_action('admin_init', array($this, 'do_review_notice')); // Ask for review |
| 62 | - add_action('admin_init', array(maxUtils::namespaceit('maxInstall'),'check_database')); | |
| 63 | - | |
| 62 | + add_action('admin_init', array(maxUtils::namespaceit('maxInstall'),'check_database')); | |
| 63 | + | |
| 64 | 64 | add_action('admin_menu', array($this, 'admin_menu')); |
| 65 | 65 | add_action('admin_footer', array($this, "footer")); |
| 66 | 66 | add_filter("admin_footer_text",array($this, "admin_footer_text")); |
| 67 | 67 | |
| @@ -68,159 +68,160 @@ | ||
| 68 | 68 | // errors in user space. No internal error but user output friendly issues |
| 69 | 69 | add_action("mb/editor/display_notices", array($this,"display_notices"), 99); |
| 70 | 70 | add_action("mb/collection/display_notices", array($this,"display_notices"), 99); |
| 71 | 71 | add_action('mb/header/display_notices', array($this, 'display_notices'), 99); |
| 72 | - | |
| 72 | + | |
| 73 | 73 | add_action("wp_ajax_getAjaxButtons", array(maxUtils::namespaceit('maxButtonsAdmin'), 'getAjaxButtons')); |
| 74 | - add_action("wp_ajax_set_review_notice_status", array($this, "setReviewNoticeStatus")); | |
| 74 | + add_action("wp_ajax_set_review_notice_status", array($this, "setReviewNoticeStatus")); | |
| 75 | 75 | |
| 76 | 76 | // Collection AJAX |
| 77 | - add_action("wp_ajax_collection-edit", array(maxUtils::namespaceit("maxCollections"), "ajax_save")); | |
| 78 | - add_action('wp_ajax_mbpro_collection_block', array(maxUtils::namespaceit("maxCollections"), "ajax_action")); // all block level ajax stuff - for logged in users - backend | |
| 79 | - add_action('wp_ajax_mb_button_action', array(maxUtils::namespaceit('maxButtons'), "ajax_action")); | |
| 80 | - | |
| 81 | - add_action('wp_ajax_maxajax', array(maxUtils::namespaceit('maxUtils'), 'ajax_action')); | |
| 77 | + add_action("wp_ajax_collection-edit", array(maxUtils::namespaceit("maxCollections"), "ajax_save")); | |
| 78 | + add_action('wp_ajax_mbpro_collection_block', array(maxUtils::namespaceit("maxCollections"), "ajax_action")); // all block level ajax stuff - for logged in users - backend | |
| 79 | + add_action('wp_ajax_mb_button_action', array(maxUtils::namespaceit('maxButtons'), "ajax_action")); | |
| 80 | + | |
| 81 | + add_action('wp_ajax_maxajax', array(maxUtils::namespaceit('maxUtils'), 'ajax_action')); | |
| 82 | 82 | } |
| 83 | 83 | // FRONT AJAX |
| 84 | 84 | add_action('wp_ajax_mbpro_collection_block_front', array(maxUtils::namespaceit("maxCollections"), "ajax_action_front")); // front end for all users |
| 85 | - add_action('wp_ajax_nopriv_mbpro_collection_block_front', array(maxUtils::namespaceit("maxCollections"), "ajax_action_front")); | |
| 86 | - | |
| 85 | + add_action('wp_ajax_nopriv_mbpro_collection_block_front', array(maxUtils::namespaceit("maxCollections"), "ajax_action_front")); | |
| 86 | + | |
| 87 | 87 | // front scripts |
| 88 | 88 | add_action('wp_enqueue_scripts', array($this, 'front_scripts')); |
| 89 | 89 | add_action('wp_enqueue_scripts', array(maxUtils::namespaceit('maxUtils'), 'fixFAConflict'),999); |
| 90 | - | |
| 90 | + | |
| 91 | 91 | $this->setMainClasses(); // struct for override functionality |
| 92 | - | |
| 93 | - // The second the blocks are being loaded, check dbase integrity | |
| 94 | - add_action("mb_blockclassesloaded", array($this, "check_database")); | |
| 95 | - | |
| 92 | + | |
| 93 | + // The second the blocks are being loaded, check dbase integrity | |
| 94 | + add_action("mb_blockclassesloaded", array($this, "check_database")); | |
| 95 | + | |
| 96 | 96 | // setup page hooks and shortcode |
| 97 | 97 | add_shortcode('maxcollection', array($this, 'collection_shortcode')); |
| 98 | - if (! is_admin()) | |
| 98 | + if (! is_admin()) | |
| 99 | 99 | $hook_bool = maxCollections::setupHooks(); // setup the hooks to insert collections |
| 100 | 100 | |
| 101 | 101 | self::$instance = $this; |
| 102 | - maxIntegrations::init(); // fire the integrations. | |
| 102 | + maxIntegrations::init(); // fire the integrations. | |
| 103 | 103 | } |
| 104 | - | |
| 104 | + | |
| 105 | 105 | public static function getInstance() |
| 106 | 106 | { |
| 107 | 107 | return self::$instance; |
| 108 | 108 | } |
| 109 | - | |
| 109 | + | |
| 110 | 110 | public function setMainClasses() |
| 111 | 111 | { |
| 112 | 112 | $classes = array( |
| 113 | 113 | "button" => "maxButton", |
| 114 | 114 | "buttons" => "maxButtons", |
| 115 | - "block" => "maxBlock", | |
| 116 | - "admin" => "maxButtonsAdmin", | |
| 117 | - "install" => "maxInstall", | |
| 115 | + "block" => "maxBlock", | |
| 116 | + "admin" => "maxButtonsAdmin", | |
| 117 | + "install" => "maxInstall", | |
| 118 | 118 | "groups" => "maxGroups", |
| 119 | - "collections" => "maxCollections", | |
| 119 | + "collections" => "maxCollections", | |
| 120 | 120 | "collection" => "maxCollection", |
| 121 | 121 | "pack" => "maxPack", |
| 122 | 122 | |
| 123 | - ); | |
| 124 | - | |
| 125 | - $this->mainClasses = $classes; | |
| 123 | + ); | |
| 124 | + | |
| 125 | + $this->mainClasses = $classes; | |
| 126 | 126 | } |
| 127 | - | |
| 127 | + | |
| 128 | 128 | // from block loader action. Checks if all parts of the table are there, or panic if not. |
| 129 | 129 | public function check_database($blocks) |
| 130 | 130 | { |
| 131 | 131 | maxUtils::addTime("Check database"); |
| 132 | - | |
| 133 | - $sql = "SELECT id,name,status,cache, created "; | |
| 134 | - foreach ($blocks as $block => $class) | |
| 132 | + | |
| 133 | + $sql = "SELECT id,name,status,cache, created "; | |
| 134 | + foreach ($blocks as $block => $class) | |
| 135 | 135 | { |
| 136 | - $sql .= ", $block"; | |
| 137 | - } | |
| 138 | - $sql .= " from " . maxUtils::get_table_name() . " limit 1"; | |
| 139 | - | |
| 140 | - global $wpdb; | |
| 136 | + $sql .= ", $block"; | |
| 137 | + } | |
| 138 | + $sql .= " from " . maxUtils::get_table_name() . " limit 1"; | |
| 139 | + | |
| 140 | + global $wpdb; | |
| 141 | 141 | $wpdb->hide_errors(); |
| 142 | - $result = $wpdb->get_results($sql); | |
| 143 | - | |
| 144 | - | |
| 145 | - // check this query for errors. If there is an error, one or more database fields are missing. Fix that. | |
| 146 | - if (isset($wpdb->last_error) && $wpdb->last_error != '') | |
| 142 | + $result = $wpdb->get_results($sql); | |
| 143 | + | |
| 144 | + | |
| 145 | + // check this query for errors. If there is an error, one or more database fields are missing. Fix that. | |
| 146 | + if (isset($wpdb->last_error) && $wpdb->last_error != '') | |
| 147 | 147 | { |
| 148 | - | |
| 149 | - $install = $this->getClass("install"); | |
| 148 | + | |
| 149 | + $install = $this->getClass("install"); | |
| 150 | 150 | $install::create_database_table(); |
| 151 | 151 | $install::migrate(); |
| 152 | 152 | } |
| 153 | - | |
| 154 | - | |
| 153 | + | |
| 154 | + | |
| 155 | 155 | maxUtils::addTime("End check database"); |
| 156 | 156 | } |
| 157 | - | |
| 157 | + | |
| 158 | 158 | public function getClass($class) |
| 159 | 159 | { |
| 160 | 160 | |
| 161 | - if (isset($this->mainClasses[$class])) | |
| 161 | + if (isset($this->mainClasses[$class])) | |
| 162 | 162 | { |
| 163 | - $load_class = maxUtils::namespaceit($this->mainClasses[$class]); | |
| 163 | + $load_class = maxUtils::namespaceit($this->mainClasses[$class]); | |
| 164 | 164 | if (method_exists($load_class,'getInstance')) |
| 165 | 165 | { |
| 166 | - return $load_class::getInstance(); | |
| 166 | + return $load_class::getInstance(); | |
| 167 | 167 | } |
| 168 | 168 | return new $load_class; |
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | - | |
| 171 | + | |
| 172 | 172 | /* Load the plugin textdomain */ |
| 173 | 173 | public function load_textdomain() |
| 174 | 174 | { |
| 175 | - // see: http://geertdedeckere.be/article/loading-wordpress-language-files-the-right-way | |
| 175 | + // see: http://geertdedeckere.be/article/loading-wordpress-language-files-the-right-way | |
| 176 | 176 | $domain = 'maxbuttons'; |
| 177 | 177 | // The "plugin_locale" filter is also used in load_plugin_textdomain() |
| 178 | 178 | $locale = apply_filters('plugin_locale', get_locale(), $domain); |
| 179 | 179 | |
| 180 | - load_textdomain($domain, WP_LANG_DIR.'/maxbuttons/'.$domain.'-'.$locale.'.mo'); | |
| 180 | + load_textdomain($domain, WP_LANG_DIR.'/maxbuttons/'.$domain.'-'.$locale.'.mo'); | |
| 181 | 181 | $res = load_plugin_textdomain('maxbuttons', false, $this->plugin_name . '/languages/'); |
| 182 | - | |
| 182 | + | |
| 183 | 183 | } |
| 184 | - | |
| 185 | - | |
| 184 | + | |
| 185 | + | |
| 186 | 186 | /** WP Settings framework. Registers settings used on maxbuttons-settings.php page */ |
| 187 | 187 | public function register_settings() |
| 188 | 188 | { |
| 189 | 189 | register_setting( 'maxbuttons_settings', 'maxbuttons_user_level' ); |
| 190 | 190 | register_setting( 'maxbuttons_settings', 'maxbuttons_noshowtinymce' ); |
| 191 | - register_setting( 'maxbuttons_settings', 'maxbuttons_minify' ); | |
| 192 | - register_setting( 'maxbuttons_settings', 'maxbuttons_hidedescription' ); | |
| 191 | + register_setting( 'maxbuttons_settings', 'maxbuttons_minify' ); | |
| 192 | + register_setting( 'maxbuttons_settings', 'maxbuttons_hidedescription' ); | |
| 193 | 193 | register_setting( 'maxbuttons_settings', 'maxbuttons_forcefa') ; |
| 194 | - register_setting( 'maxbuttons_settings', 'maxbuttons_borderbox'); | |
| 194 | + register_setting( 'maxbuttons_settings', 'maxbuttons_borderbox'); | |
| 195 | + register_setting( 'maxbuttons_settings', 'maxbuttons_protocol'); | |
| 195 | 196 | } |
| 196 | - | |
| 197 | - protected function checkbox_option($options) | |
| 197 | + | |
| 198 | + protected function checkbox_option($options) | |
| 198 | 199 | { |
| 199 | - if (! isset($options["maxbuttons_minify"])) | |
| 200 | - $options["maxbuttons_minify"] = 0; | |
| 201 | - | |
| 200 | + if (! isset($options["maxbuttons_minify"])) | |
| 201 | + $options["maxbuttons_minify"] = 0; | |
| 202 | + | |
| 202 | 203 | return $options; |
| 203 | - | |
| 204 | + | |
| 204 | 205 | } |
| 205 | 206 | |
| 206 | 207 | /** Returns the full path of the plugin installation directory */ |
| 207 | 208 | public static function get_plugin_path() |
| 208 | 209 | { |
| 209 | - return plugin_dir_path(MAXBUTTONS_ROOT_FILE); | |
| 210 | + return plugin_dir_path(MAXBUTTONS_ROOT_FILE); | |
| 210 | 211 | } |
| 211 | - | |
| 212 | - /** Returns the full URL of the plugin installation path */ | |
| 212 | + | |
| 213 | + /** Returns the full URL of the plugin installation path */ | |
| 213 | 214 | public static function get_plugin_url() |
| 214 | 215 | { |
| 215 | 216 | $url = plugin_dir_url(MAXBUTTONS_ROOT_FILE); |
| 216 | 217 | return $url; |
| 217 | 218 | } |
| 218 | - | |
| 219 | + | |
| 219 | 220 | /** Returns the current installed version */ |
| 220 | 221 | public function get_installed_version() |
| 221 | 222 | { |
| 222 | - return $this->installed_version; | |
| 223 | + return $this->installed_version; | |
| 223 | 224 | } |
| 224 | 225 | |
| 225 | 226 | /** Installs and adds the main menu and the submenu items */ |
| 226 | 227 | function admin_menu() { |
| @@ -236,18 +237,18 @@ | ||
| 236 | 237 | $menu_title = __('MaxButtons', 'maxbuttons'); |
| 237 | 238 | $capability = $maxbuttons_capabilities; |
| 238 | 239 | $admin_capability = 'manage_options'; |
| 239 | 240 | $menu_slug = 'maxbuttons-controller'; |
| 240 | - $function = array($this, 'load_admin_page'); | |
| 241 | + $function = array($this, 'load_admin_page'); | |
| 241 | 242 | $icon_url = $this->plugin_url . 'images/mb-peach-icon.png'; |
| 242 | - $submenu_function = array($this, 'load_admin_page'); | |
| 243 | - | |
| 243 | + $submenu_function = array($this, 'load_admin_page'); | |
| 244 | + | |
| 244 | 245 | add_menu_page($page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, 81); |
| 245 | - | |
| 246 | + | |
| 246 | 247 | // We add this submenu page with the same slug as the parent to ensure we don't get duplicates |
| 247 | 248 | $sub_menu_title = __('Buttons', 'maxbuttons'); |
| 248 | 249 | $admin_pages[] = add_submenu_page($menu_slug, $page_title, $sub_menu_title, $capability, $menu_slug, $function); |
| 249 | - | |
| 250 | + | |
| 250 | 251 | // Now add the submenu page for the Add New page |
| 251 | 252 | $submenu_page_title = __('MaxButtons: Add/Edit Button', 'maxbuttons'); |
| 252 | 253 | $submenu_title = __('Add New', 'maxbuttons'); |
| 253 | 254 | $submenu_slug = 'maxbuttons-controller&action=edit'; |
| @@ -253,14 +254,9 @@ | ||
| 253 | 254 | $submenu_slug = 'maxbuttons-controller&action=edit'; |
| 254 | 255 | //$submenu_function = 'maxbuttons_button'; |
| 255 | 256 | $admin_pages[] = add_submenu_page($menu_slug, $submenu_page_title, $submenu_title, $capability, $submenu_slug, $submenu_function); |
| 256 | 257 | |
| 257 | - // Now add the submenu page for the Export page | |
| 258 | - $submenu_page_title = __('MaxButtons: Social Share', 'maxbuttons'); | |
| 259 | - $submenu_title = __('Social Share', 'maxbuttons'); | |
| 260 | - $submenu_slug = 'maxbuttons-collections'; | |
| 261 | - $admin_pages[] = add_submenu_page($menu_slug, $submenu_page_title, $submenu_title, $capability, $submenu_slug, $submenu_function); | |
| 262 | - | |
| 258 | + | |
| 263 | 259 | // Now add the submenu page for the Go Pro page |
| 264 | 260 | $submenu_page_title = __('MaxButtons: Upgrade to Pro', 'maxbuttons'); |
| 265 | 261 | $submenu_title = __('Upgrade to Pro', 'maxbuttons'); |
| 266 | 262 | $submenu_slug = 'maxbuttons-pro'; |
| @@ -279,181 +275,186 @@ | ||
| 279 | 275 | $submenu_title = __('Support', 'maxbuttons'); |
| 280 | 276 | $submenu_slug = 'maxbuttons-support'; |
| 281 | 277 | //$submenu_function = 'maxbuttons_support'; |
| 282 | 278 | $admin_pages[] = add_submenu_page($menu_slug, $submenu_page_title, $submenu_title, $admin_capability, $submenu_slug, $submenu_function); |
| 283 | - | |
| 284 | - } | |
| 285 | - | |
| 279 | + | |
| 280 | + // Now add the submenu page for the Export page | |
| 281 | + $submenu_page_title = __('MaxButtons: Share Buttons', 'maxbuttons'); | |
| 282 | + $submenu_title = __('Share Buttons', 'maxbuttons'); | |
| 283 | + $submenu_slug = 'maxbuttons-collections'; | |
| 284 | + $admin_pages[] = add_submenu_page($menu_slug, $submenu_page_title, $submenu_title, $capability, $submenu_slug, $submenu_function); | |
| 285 | + | |
| 286 | + } | |
| 287 | + | |
| 286 | 288 | function load_admin_page($page) |
| 287 | 289 | { |
| 288 | 290 | $page = sanitize_text_field($_GET["page"]); |
| 289 | - | |
| 290 | - switch($page) | |
| 291 | + | |
| 292 | + switch($page) | |
| 291 | 293 | { |
| 292 | - case "maxbuttons-button": | |
| 293 | - $pagepath = "includes/maxbuttons-button.php"; | |
| 294 | + case "maxbuttons-button": | |
| 295 | + $pagepath = "includes/maxbuttons-button.php"; | |
| 294 | 296 | break; |
| 295 | - case "maxbuttons-support": | |
| 297 | + case "maxbuttons-support": | |
| 296 | 298 | $pagepath = "includes/maxbuttons-support.php"; |
| 297 | 299 | break; |
| 298 | - case "maxbuttons-settings": | |
| 299 | - $pagepath = "includes/maxbuttons-settings.php"; | |
| 300 | + case "maxbuttons-settings": | |
| 301 | + $pagepath = "includes/maxbuttons-settings.php"; | |
| 300 | 302 | break; |
| 301 | - case "maxbuttons-pro": | |
| 302 | - $pagepath = "includes/maxbuttons-pro.php"; | |
| 303 | + case "maxbuttons-pro": | |
| 304 | + $pagepath = "includes/maxbuttons-pro.php"; | |
| 303 | 305 | break; |
| 304 | - case "maxbuttons-collections": | |
| 305 | - $pagepath = "includes/maxbuttons-collections.php"; | |
| 306 | - break; | |
| 306 | + case "maxbuttons-collections": | |
| 307 | + $pagepath = "includes/maxbuttons-collections.php"; | |
| 308 | + break; | |
| 307 | 309 | default: |
| 308 | - $pagepath = "includes/maxbuttons-controller.php"; | |
| 310 | + $pagepath = "includes/maxbuttons-controller.php"; | |
| 309 | 311 | break; |
| 310 | 312 | } |
| 311 | - $pagepath = $this->plugin_path . $pagepath; | |
| 312 | - | |
| 313 | - include(apply_filters("mb-load-admin-page-$page", $pagepath)); | |
| 313 | + $pagepath = $this->plugin_path . $pagepath; | |
| 314 | + | |
| 315 | + include(apply_filters("mb-load-admin-page-$page", $pagepath)); | |
| 314 | 316 | } |
| 315 | 317 | |
| 316 | 318 | |
| 317 | - function add_admin_styles($hook) { | |
| 318 | - // only hook in maxbuttons realm. | |
| 319 | + function add_admin_styles($hook) { | |
| 320 | + // only hook in maxbuttons realm. | |
| 319 | 321 | if ( strpos($hook,'maxbuttons') === false && $hook != 'post.php' && $hook != 'post-new.php' ) |
| 320 | 322 | { |
| 321 | 323 | if (! isset($_GET['fl_builder'])) // exception for beaver builder |
| 322 | 324 | return; |
| 323 | 325 | } |
| 324 | - | |
| 325 | - | |
| 326 | - $fa_url = apply_filters("mb_fa_url", $this->plugin_url . 'assets/libraries/font-awesome/css/font-awesome.min.css'); | |
| 326 | + | |
| 327 | + $version = MAXBUTTONS_VERSION_NUM; | |
| 328 | + | |
| 329 | + $fa_url = apply_filters("mb_fa_url", $this->plugin_url . 'assets/libraries/font-awesome/css/font-awesome.min.css', array(), $version); | |
| 327 | 330 | if ($fa_url != false && $fa_url != '') |
| 328 | - { | |
| 329 | - wp_register_style('mbpro-font-awesome', $fa_url ); | |
| 330 | - wp_enqueue_style('mbpro-font-awesome'); | |
| 331 | + { | |
| 332 | + wp_register_style('mbpro-font-awesome', $fa_url, array(), $version); | |
| 333 | + wp_enqueue_style('mbpro-font-awesome'); | |
| 331 | 334 | } |
| 332 | - | |
| 333 | - wp_enqueue_style('wp-color-picker'); | |
| 334 | - wp_enqueue_style('maxbuttons-css', $this->plugin_url . 'assets/css/style.css'); | |
| 335 | - | |
| 335 | + | |
| 336 | + wp_enqueue_style('wp-color-picker'); | |
| 337 | + wp_enqueue_style('maxbuttons-css', $this->plugin_url . 'assets/css/style.css', array(), $version); | |
| 338 | + | |
| 336 | 339 | } |
| 337 | 340 | |
| 338 | - /** Add Admin scripts | |
| 341 | + /** Add Admin scripts | |
| 339 | 342 | * |
| 340 | 343 | * Uses WP hook for Admin scripts to add needed js. |
| 341 | 344 | */ |
| 342 | - function add_admin_scripts($hook) { | |
| 345 | + function add_admin_scripts($hook) { | |
| 343 | 346 | // only hook in maxbuttons realm. |
| 344 | - if ( strpos($hook,'maxbuttons') === false ) //&& $hook != 'post.php' && $hook != 'post-new.php' | |
| 347 | + if ( strpos($hook,'maxbuttons') === false ) //&& $hook != 'post.php' && $hook != 'post-new.php' | |
| 345 | 348 | return; |
| 346 | - | |
| 349 | + | |
| 347 | 350 | $version = MAXBUTTONS_VERSION_NUM; |
| 348 | - | |
| 349 | - $js_url = trailingslashit($this->plugin_url . 'js'); | |
| 350 | - if (! $this->debug_mode) | |
| 351 | - $js_url .= 'min/'; | |
| 352 | - | |
| 353 | - | |
| 351 | + | |
| 352 | + $js_url = trailingslashit($this->plugin_url . 'js'); | |
| 353 | + if (! $this->debug_mode) | |
| 354 | + $js_url .= 'min/'; | |
| 355 | + | |
| 356 | + | |
| 354 | 357 | wp_enqueue_script('jquery-ui-draggable'); |
| 355 | - | |
| 356 | - //wp_enqueue_script('maxbuttons-colorpicker-js', $js_url .'colpick.js', array('jquery'), $version, true); | |
| 357 | 358 | |
| 358 | - wp_enqueue_script('maxbutton-admin', $js_url . 'maxbuttons-admin.js', array('jquery', 'jquery-ui-draggable', 'maxbuttons-tabs','maxbuttons-modal', 'wp-color-picker', 'underscore'),$version, true); | |
| 359 | + wp_enqueue_script('maxbutton-admin', $js_url . 'maxbuttons-admin.js', array('jquery', 'jquery-ui-draggable', 'maxbuttons-tabs','maxbuttons-modal', 'wp-color-picker', 'underscore'),$version, true); | |
| 359 | 360 | wp_enqueue_script('maxbutton-js-init', $js_url . 'init.js', array('maxbutton-admin','maxcollections','maxbuttons-modal'),$version, true); |
| 360 | - wp_enqueue_script('maxbuttons-tabs', $js_url . 'maxtabs.js', array('jquery'),$version, true); | |
| 361 | - wp_enqueue_script('maxbuttons-responsive', $js_url . 'responsive.js', array('maxbutton-admin'), $version, true ); | |
| 362 | - | |
| 361 | + wp_enqueue_script('maxbuttons-tabs', $js_url . 'maxtabs.js', array('jquery'),$version, true); | |
| 362 | + wp_enqueue_script('maxbuttons-responsive', $js_url . 'responsive.js', array('maxbutton-admin'), $version, true ); | |
| 363 | + | |
| 363 | 364 | wp_register_script('maxbuttons-ajax', $js_url . 'maxajax.js', array('maxbutton-admin'), $version, true); |
| 364 | - wp_localize_script('maxbuttons-ajax', 'maxajax', | |
| 365 | + wp_localize_script('maxbuttons-ajax', 'maxajax', | |
| 365 | 366 | array( |
| 366 | 367 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 367 | 368 | 'ajax_action' => 'maxajax', |
| 368 | 369 | 'nonce' => wp_create_nonce('maxajax'), |
| 369 | - )); | |
| 370 | - | |
| 370 | + )); | |
| 371 | + | |
| 371 | 372 | wp_enqueue_script('maxbuttons-ajax'); |
| 372 | - | |
| 373 | - wp_register_script('maxcollections', $js_url . 'maxcollections.js', | |
| 374 | - array('jquery', 'maxbutton-admin', 'jquery-ui-sortable'),$version, true ); | |
| 375 | - | |
| 373 | + | |
| 374 | + wp_register_script('maxcollections', $js_url . 'maxcollections.js', | |
| 375 | + array('jquery', 'maxbutton-admin', 'jquery-ui-sortable'),$version, true ); | |
| 376 | + | |
| 376 | 377 | $local = array(); |
| 377 | 378 | $local["ajaxurl"] = admin_url( 'admin-ajax.php' ); |
| 378 | - $local["maxurl"] = $this->plugin_url; | |
| 379 | - wp_localize_script('maxbutton-admin', 'mb_ajax', $local); | |
| 380 | - | |
| 379 | + $local["maxurl"] = $this->plugin_url; | |
| 380 | + wp_localize_script('maxbutton-admin', 'mb_ajax', $local); | |
| 381 | + | |
| 381 | 382 | $local = array( |
| 382 | 383 | "leave_page" => __("You have unsaved data, are you sure you want to leave the page?","maxbuttons"), |
| 383 | - 'picker_title' => __('Select your buttons','maxbuttons'), | |
| 384 | - | |
| 385 | - ); | |
| 386 | - wp_localize_script('maxcollections', 'maxcol_wp', $local); | |
| 387 | - | |
| 388 | - $this->load_modal_script(); | |
| 389 | - | |
| 390 | - wp_enqueue_script('maxcollections'); | |
| 391 | - } | |
| 392 | - | |
| 384 | + 'picker_title' => __('Select your buttons','maxbuttons'), | |
| 385 | + | |
| 386 | + ); | |
| 387 | + wp_localize_script('maxcollections', 'maxcol_wp', $local); | |
| 388 | + | |
| 389 | + $this->load_modal_script(); | |
| 390 | + | |
| 391 | + wp_enqueue_script('maxcollections'); | |
| 392 | + } | |
| 393 | + | |
| 393 | 394 | /** Load the Modal Script |
| 394 | 395 | * The modal script is the generic solution for all popups within the plugin. |
| 395 | 396 | */ |
| 396 | - public function load_modal_script() | |
| 397 | + public function load_modal_script() | |
| 397 | 398 | { |
| 398 | 399 | $version = MAXBUTTONS_VERSION_NUM; |
| 399 | - $js_url = trailingslashit($this->plugin_url . 'js'); | |
| 400 | - if (! $this->debug_mode) | |
| 401 | - $js_url .= 'min/'; | |
| 402 | - | |
| 403 | - wp_register_script('maxbuttons-modal', $js_url . 'maxmodal.js', array('jquery','jquery-ui-draggable'), $version, true); | |
| 404 | - // translations of controls and other elements that can be used in maxmodal | |
| 400 | + $js_url = trailingslashit($this->plugin_url . 'js'); | |
| 401 | + if (! $this->debug_mode) | |
| 402 | + $js_url .= 'min/'; | |
| 403 | + | |
| 404 | + wp_register_script('maxbuttons-modal', $js_url . 'maxmodal.js', array('jquery','jquery-ui-draggable'), $version, true); | |
| 405 | + // translations of controls and other elements that can be used in maxmodal | |
| 405 | 406 | $translations = array( |
| 406 | - 'yes' => __("Yes","maxbuttons"), | |
| 407 | - 'no' => __("No","maxbuttons"), | |
| 408 | - 'ok' => __("OK","maxbuttons"), | |
| 409 | - 'cancel' => __("Cancel","maxbuttons"), | |
| 410 | - ); | |
| 411 | - wp_localize_script('maxbuttons-modal', 'modaltext', $translations); | |
| 412 | - wp_enqueue_script('maxbuttons-modal'); | |
| 407 | + 'yes' => __("Yes","maxbuttons"), | |
| 408 | + 'no' => __("No","maxbuttons"), | |
| 409 | + 'ok' => __("OK","maxbuttons"), | |
| 410 | + 'cancel' => __("Cancel","maxbuttons"), | |
| 411 | + ); | |
| 412 | + wp_localize_script('maxbuttons-modal', 'modaltext', $translations); | |
| 413 | + wp_enqueue_script('maxbuttons-modal'); | |
| 413 | 414 | |
| 414 | 415 | } |
| 415 | - | |
| 416 | - /** Load Media Buttons Script | |
| 417 | - | |
| 418 | - Useful for integrations that don't implement the media button but uses the media button JS for loading the button picker | |
| 419 | - | |
| 416 | + | |
| 417 | + /** Load Media Buttons Script | |
| 418 | + * | |
| 419 | + * Useful for integrations that don't implement the media button but uses the media button JS for loading the button picker | |
| 420 | + * | |
| 420 | 421 | */ |
| 421 | - public function load_media_script() | |
| 422 | + public function load_media_script() | |
| 422 | 423 | { |
| 423 | 424 | $version = MAXBUTTONS_VERSION_NUM; |
| 424 | 425 | |
| 425 | - $js_url = trailingslashit($this->plugin_url . 'js'); | |
| 426 | - if (! $this->debug_mode) | |
| 427 | - $js_url .= 'min/'; | |
| 428 | - | |
| 429 | - $fa_url = apply_filters("mb_fa_url", $this->plugin_url . 'assets/libraries/font-awesome/css/font-awesome.min.css'); | |
| 426 | + $js_url = trailingslashit($this->plugin_url . 'js'); | |
| 427 | + if (! $this->debug_mode) | |
| 428 | + $js_url .= 'min/'; | |
| 429 | + | |
| 430 | + $fa_url = apply_filters("mb_fa_url", $this->plugin_url . 'assets/libraries/font-awesome/css/font-awesome.min.css'); | |
| 430 | 431 | if ($fa_url != false && $fa_url != '') |
| 431 | 432 | { |
| 432 | - wp_register_style('mbpro-font-awesome', $fa_url); | |
| 433 | - wp_enqueue_style('mbpro-font-awesome'); | |
| 433 | + wp_register_style('mbpro-font-awesome', $fa_url, array(), $version); | |
| 434 | + wp_enqueue_style('mbpro-font-awesome'); | |
| 434 | 435 | } |
| 435 | - | |
| 436 | - wp_enqueue_script('mb-media-button', $js_url . 'maxbuttons_media_button.js', array('jquery', 'maxbuttons-modal'), $version, true); | |
| 436 | + | |
| 437 | + wp_enqueue_script('mb-media-button', $js_url . 'maxbuttons_media_button.js', array('jquery', 'maxbuttons-modal'), $version, true); | |
| 437 | 438 | $this->load_modal_script(); |
| 438 | - | |
| 439 | + | |
| 439 | 440 | $translations = array( |
| 440 | - 'insert' => __('Insert Button into Editor', 'maxbuttons'), | |
| 441 | - 'loading' => __("Loading your buttons","maxbuttons"), | |
| 442 | - 'select' => __('Click on a button from the list below to place the button shortcode in the editor.', 'maxbuttons'), | |
| 443 | - 'cancel' => __('Cancel', 'maxbuttons'), | |
| 444 | - 'windowtitle' => __("Select a MaxButton","maxbuttons"), | |
| 445 | - 'icon' => $this->plugin_url . 'images/mb-peach-32.png', | |
| 446 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), | |
| 447 | - 'short_url_label' => __('Button URL', 'maxbuttons'), | |
| 441 | + 'insert' => __('Insert Button into Editor', 'maxbuttons'), | |
| 442 | + 'loading' => __("Loading your buttons","maxbuttons"), | |
| 443 | + 'select' => __('Click on a button from the list below to place the button shortcode in the editor.', 'maxbuttons'), | |
| 444 | + 'cancel' => __('Cancel', 'maxbuttons'), | |
| 445 | + 'windowtitle' => __("Select a MaxButton","maxbuttons"), | |
| 446 | + 'icon' => $this->plugin_url . 'images/mb-peach-32.png', | |
| 447 | + 'ajax_url' => admin_url( 'admin-ajax.php' ), | |
| 448 | + 'short_url_label' => __('Button URL', 'maxbuttons'), | |
| 448 | 449 | 'short_text_label' => __('Button Text', 'maxbuttons'), |
| 449 | 450 | 'short_options_explain' => __('If you want to change the URL or Text of the Button, enter the appropiate field. If you want to use the button values, just click Add to editor', 'maxbuttons'), |
| 450 | - 'short_add_button' => __('Add to Editor', 'maxbuttons'), | |
| 451 | - ); | |
| 452 | - | |
| 453 | - wp_localize_script('mb-media-button','mbtrans', $translations); | |
| 451 | + 'short_add_button' => __('Add to Editor', 'maxbuttons'), | |
| 452 | + ); | |
| 453 | + | |
| 454 | + wp_localize_script('mb-media-button','mbtrans', $translations); | |
| 454 | 455 | } |
| 455 | - | |
| 456 | + | |
| 456 | 457 | /** Load Media Button in WP editor |
| 457 | 458 | * |
| 458 | 459 | * The 'add button' interface in WP post and page editor to simplify adding buttons. Loads button plus required Javascript. |
| 459 | 460 | */ |
| @@ -459,9 +460,9 @@ | ||
| 459 | 460 | */ |
| 460 | 461 | function media_button($editor_id) { |
| 461 | 462 | $output = ''; |
| 462 | 463 | |
| 463 | - // options | |
| 464 | + // options | |
| 464 | 465 | if (get_option('maxbuttons_noshowtinymce') == 1) return; |
| 465 | 466 | |
| 466 | 467 | $this->load_media_script(); |
| 467 | 468 | |
| @@ -469,92 +470,93 @@ | ||
| 469 | 470 | |
| 470 | 471 | $title = __('Add Button', 'maxbuttons'); |
| 471 | 472 | $icon = $this->plugin_url . 'images/mb-peach-icon.png'; |
| 472 | 473 | $img = '<span class="wp-media-buttons-icon" style="background-image: url(' . $icon . '); width: 16px; height: 16px; margin-top: 1px;"></span>'; |
| 473 | - $output = '<a href="javascript:void(0);" class="button maxbutton_media_button" data-callback="window.maxMedia.showShortcodeOptions" title="' . $title . '" style="padding-left: .4em;">' . $img . ' ' . $title . '</a>'; | |
| 474 | + $output = '<a href="javascript:void(0);" class="button maxbutton_media_button" data-callback="window.maxMedia.showShortcodeOptions" title="' . $title . '" style="padding-left: .4em;">' . $img . ' ' . $title . '</a>'; | |
| 474 | 475 | |
| 475 | 476 | echo $output; |
| 476 | 477 | } |
| 477 | - | |
| 478 | - /** Scripts run on front-end | |
| 479 | - Load font-awesome, and limited javascript for the front-end. This is being kept extremely limited for performance reasons. | |
| 478 | + | |
| 479 | + /** Scripts run on front-end | |
| 480 | + * Load font-awesome, and limited javascript for the front-end. This is being kept extremely limited for performance reasons. | |
| 480 | 481 | */ |
| 481 | - public function front_scripts() | |
| 482 | + public function front_scripts() | |
| 482 | 483 | { |
| 483 | - | |
| 484 | - $fa_url = apply_filters("mb_fa_url", $this->plugin_url . 'assets/libraries/font-awesome/css/font-awesome.min.css'); | |
| 484 | + $version = MAXBUTTONS_VERSION_NUM; | |
| 485 | + | |
| 486 | + $fa_url = apply_filters("mb_fa_url", $this->plugin_url . 'assets/libraries/font-awesome/css/font-awesome.min.css'); | |
| 485 | 487 | if ($fa_url != false && $fa_url != '') |
| 486 | 488 | { |
| 487 | - wp_register_style('mbpro-font-awesome', $fa_url); | |
| 488 | - wp_enqueue_style('mbpro-font-awesome'); | |
| 489 | - } | |
| 490 | - | |
| 489 | + wp_register_style('mbpro-font-awesome', $fa_url, array(), $version); | |
| 490 | + wp_enqueue_style('mbpro-font-awesome'); | |
| 491 | + } | |
| 492 | + | |
| 491 | 493 | // load backend script on front in Beaver Builder |
| 492 | 494 | if (isset($_GET['fl_builder'])) |
| 493 | 495 | { |
| 494 | - $this->add_admin_styles('maxbuttons'); | |
| 496 | + $this->add_admin_styles('maxbuttons'); | |
| 495 | 497 | } |
| 496 | - | |
| 497 | - wp_enqueue_script('maxbuttons-front', $this->plugin_url . 'js/min/front.js', array('jquery'), true); | |
| 498 | - $local = array(); | |
| 498 | + | |
| 499 | + wp_enqueue_script('maxbuttons-front', $this->plugin_url . 'js/min/front.js', array('jquery'), $version); | |
| 500 | + $local = array(); | |
| 499 | 501 | $local["ajaxurl"] = admin_url( 'admin-ajax.php' ); |
| 500 | 502 | |
| 501 | - wp_localize_script('maxbuttons-front', 'mb_ajax', $local); | |
| 503 | + wp_localize_script('maxbuttons-front', 'mb_ajax', $local); | |
| 502 | 504 | } |
| 503 | - | |
| 504 | - /** Extra text to display in admin footer */ | |
| 505 | + | |
| 506 | + /** Extra text to display in admin footer */ | |
| 505 | 507 | function admin_footer_text($text) |
| 506 | 508 | { |
| 507 | 509 | if (! isset($_GET["page"])) |
| 508 | 510 | return $text; |
| 509 | - | |
| 511 | + | |
| 510 | 512 | if ( strpos($_GET["page"],'maxbuttons') === false) |
| 511 | - return $text; | |
| 513 | + return $text; | |
| 512 | 514 | $text = ''; |
| 513 | 515 | |
| 514 | - $text .= sprintf("If you like MaxButtons please give us a %s★★★★★%s rating!", | |
| 515 | - "<a href='https://wordpress.org/support/view/plugin-reviews/maxbuttons#postform' target='_blank'>", | |
| 516 | - "</a>") ; | |
| 517 | - return $text; | |
| 518 | - | |
| 516 | + $text .= sprintf("If you like MaxButtons please give us a %s★★★★★%s rating!", | |
| 517 | + "<a href='https://wordpress.org/support/view/plugin-reviews/maxbuttons#postform' target='_blank'>", | |
| 518 | + "</a>") ; | |
| 519 | + return $text; | |
| 520 | + | |
| 519 | 521 | } |
| 520 | - | |
| 521 | - | |
| 522 | - function shortcode($atts) | |
| 522 | + | |
| 523 | + | |
| 524 | + function shortcode($atts) | |
| 523 | 525 | { |
| 524 | 526 | $button = $this->getClass("button"); |
| 525 | - return $button->shortcode($atts); | |
| 527 | + return $button->shortcode($atts); | |
| 526 | 528 | } |
| 527 | 529 | |
| 528 | 530 | public function collection_shortcode($atts, $content = null) |
| 529 | 531 | { |
| 530 | 532 | $atts = shortcode_atts(array( |
| 531 | - "id" => 0, | |
| 532 | - "name" => '', | |
| 533 | - "nocache" => false, // these are button options. | |
| 534 | - "mode" => "normal", | |
| 535 | - "style" => "footer", | |
| 533 | + "id" => 0, | |
| 534 | + "name" => '', | |
| 535 | + "nocache" => false, // these are button options. | |
| 536 | + "mode" => "normal", | |
| 537 | + "style" => "footer", | |
| 536 | 538 | ), |
| 537 | - | |
| 539 | + | |
| 538 | 540 | $atts); |
| 539 | - | |
| 540 | - $id = intval($atts["id"]); | |
| 541 | - $name = sanitize_text_field($atts["name"]); | |
| 542 | - | |
| 543 | - if ($id > 0) | |
| 541 | + | |
| 542 | + $id = intval($atts["id"]); | |
| 543 | + $name = sanitize_text_field($atts["name"]); | |
| 544 | + | |
| 545 | + if ($id > 0) | |
| 544 | 546 | $collection = maxCollections::getCollectionByID($id); |
| 545 | - elseif ($atts["name"] != '') | |
| 547 | + elseif ($atts["name"] != '') | |
| 546 | 548 | $collection = maxCollections::getCollectionByName($name); |
| 547 | - | |
| 548 | - | |
| 549 | + | |
| 550 | + | |
| 549 | 551 | if ($collection) |
| 550 | 552 | return $collection->shortcode($atts,$content); |
| 551 | - | |
| 553 | + | |
| 552 | 554 | } |
| 553 | - | |
| 554 | 555 | |
| 556 | + | |
| 555 | 557 | function plugin_action_links($links, $file) { |
| 556 | - | |
| 558 | + | |
| 557 | 559 | if ($file == plugin_basename(dirname(MAXBUTTONS_ROOT_FILE) . '/maxbuttons.php')) { |
| 558 | 560 | $label = __('Buttons', 'maxbuttons'); |
| 559 | 561 | $dashboard_link = '<a href="' . admin_url() . 'admin.php?page=maxbuttons-controller&action=list">' . $label . '</a>'; |
| 560 | 562 | array_unshift($links, $dashboard_link); |
| @@ -567,9 +569,9 @@ | ||
| 567 | 569 | function plugin_row_meta($links, $file) { |
| 568 | 570 | if ($file == plugin_basename(dirname(__FILE__) . '/maxbuttons.php')) { |
| 569 | 571 | $links[] = sprintf(__('%sUpgrade to Pro Version%s', 'maxbuttons'), '<a href="http://maxbuttons.com/?ref=mbfree" target="_blank">', '</a>'); |
| 570 | 572 | } |
| 571 | - | |
| 573 | + | |
| 572 | 574 | return $links; |
| 573 | 575 | } |
| 574 | 576 | |
| 575 | 577 | |
| @@ -574,134 +576,136 @@ | ||
| 574 | 576 | |
| 575 | 577 | |
| 576 | 578 | function do_footer($id, $code, $type = "css") |
| 577 | 579 | { |
| 578 | - | |
| 579 | - $this->footer[$type][$id] = $code; | |
| 580 | - | |
| 580 | + | |
| 581 | + $this->footer[$type][$id] = $code; | |
| 582 | + | |
| 581 | 583 | } |
| 582 | 584 | function footer() |
| 583 | 585 | { |
| 584 | 586 | if(count($this->footer) == 0) return; // nothing |
| 585 | - | |
| 586 | - foreach ($this->footer as $type => $part) | |
| 587 | + | |
| 588 | + foreach ($this->footer as $type => $part) | |
| 587 | 589 | { |
| 588 | 590 | // add tag |
| 589 | - if ($type == 'css') | |
| 591 | + if ($type == 'css') | |
| 590 | 592 | { |
| 591 | 593 | echo "<!--email_off--><style type='text/css'>"; |
| 592 | - } | |
| 594 | + } | |
| 593 | 595 | foreach ($part as $id => $statements) |
| 594 | 596 | { |
| 595 | - if (strlen($statements) > 0) // prevent whitespace | |
| 596 | - echo $statements . "\n"; | |
| 597 | + if (strlen($statements) > 0) // prevent whitespace | |
| 598 | + echo $statements . "\n"; | |
| 597 | 599 | } |
| 598 | - if ($type == 'css') | |
| 600 | + if ($type == 'css') | |
| 599 | 601 | { |
| 600 | - echo "</style><!--/email_off-->\n"; | |
| 601 | - } | |
| 602 | + echo "</style><!--/email_off-->\n"; | |
| 603 | + } | |
| 602 | 604 | } |
| 603 | - | |
| 605 | + | |
| 604 | 606 | } |
| 605 | - | |
| 607 | + | |
| 606 | 608 | public function do_review_notice () { |
| 607 | - | |
| 608 | - $current_user_id = get_current_user_id(); | |
| 609 | + | |
| 610 | + $current_user_id = get_current_user_id(); | |
| 611 | + $version = MAXBUTTONS_VERSION_NUM; | |
| 612 | + | |
| 609 | 613 | $review = get_user_meta( $current_user_id, 'maxbuttons_review_notice' , true ); |
| 610 | - | |
| 614 | + | |
| 611 | 615 | if ($review == '') |
| 612 | 616 | { |
| 613 | 617 | //$created = get_option("MBFREE_CREATED"); |
| 614 | - $show = time() + (7* DAY_IN_SECONDS); | |
| 618 | + $show = time() + (7* DAY_IN_SECONDS); | |
| 615 | 619 | update_user_meta($current_user_id, 'maxbuttons_review_notice', $show); |
| 616 | - return; | |
| 620 | + return; | |
| 617 | 621 | } |
| 618 | 622 | |
| 619 | - | |
| 623 | + | |
| 620 | 624 | $display_review = false; |
| 621 | - | |
| 622 | - if ($review == 'off') | |
| 623 | - { return; // no show | |
| 624 | - | |
| 625 | + | |
| 626 | + if ($review == 'off') | |
| 627 | + { return; // no show | |
| 628 | + | |
| 625 | 629 | } |
| 626 | 630 | elseif (is_numeric($review)) |
| 627 | - { | |
| 628 | - $now = time(); | |
| 631 | + { | |
| 632 | + $now = time(); | |
| 629 | 633 | |
| 630 | 634 | if ($now > $review) |
| 631 | - { | |
| 635 | + { | |
| 632 | 636 | $display_review = true; |
| 633 | 637 | |
| 634 | 638 | } |
| 635 | 639 | } |
| 636 | - | |
| 637 | - // load style / script. It's seperated since it should show everywhere in admin. | |
| 640 | + | |
| 641 | + // load style / script. It's seperated since it should show everywhere in admin. | |
| 638 | 642 | if ($display_review) |
| 639 | 643 | { |
| 640 | 644 | add_action( 'admin_notices', array( maxUtils::namespaceit('maxAdmin'), 'mb_review_notice')); |
| 641 | - wp_enqueue_style('maxbuttons-review-notice', $this->plugin_url . 'assets/css/review_notice.css'); | |
| 642 | - wp_enqueue_script('maxbuttons-review-notice', $this->plugin_url . 'js/min/review-notice.js', array('jquery'), true); | |
| 645 | + wp_enqueue_style('maxbuttons-review-notice', $this->plugin_url . 'assets/css/review_notice.css', array(), $version); | |
| 646 | + wp_enqueue_script('maxbuttons-review-notice', $this->plugin_url . 'js/min/review-notice.js', array('jquery'), $version); | |
| 643 | 647 | |
| 644 | - $local = array(); | |
| 648 | + $local = array(); | |
| 645 | 649 | $local["ajaxurl"] = admin_url( 'admin-ajax.php' ); |
| 646 | 650 | wp_localize_script('maxbuttons-review-notice', 'mb_ajax_review', $local); |
| 647 | 651 | } |
| 648 | - | |
| 652 | + | |
| 649 | 653 | } |
| 650 | - | |
| 651 | - public function setReviewNoticeStatus() | |
| 654 | + | |
| 655 | + public function setReviewNoticeStatus() | |
| 652 | 656 | { |
| 653 | - $status = isset($_POST["status"]) ? sanitize_text_field($_POST["status"]) : ''; | |
| 654 | - $current_user_id = get_current_user_id(); | |
| 655 | - | |
| 656 | - $updated = false; | |
| 657 | - | |
| 658 | - if ($status == 'off') | |
| 657 | + $status = isset($_POST["status"]) ? sanitize_text_field($_POST["status"]) : ''; | |
| 658 | + $current_user_id = get_current_user_id(); | |
| 659 | + | |
| 660 | + $updated = false; | |
| 661 | + | |
| 662 | + if ($status == 'off') | |
| 659 | 663 | { |
| 660 | - $updated = true; | |
| 661 | - update_user_meta($current_user_id, 'maxbuttons_review_notice', 'off'); | |
| 662 | - | |
| 664 | + $updated = true; | |
| 665 | + update_user_meta($current_user_id, 'maxbuttons_review_notice', 'off'); | |
| 666 | + | |
| 663 | 667 | } |
| 664 | - if ($status == 'later') | |
| 668 | + if ($status == 'later') | |
| 665 | 669 | { |
| 666 | 670 | $updated = true; |
| 667 | - $later = time() + (14 * DAY_IN_SECONDS ); | |
| 668 | - | |
| 669 | - update_user_meta($current_user_id, 'maxbuttons_review_notice', $later); | |
| 671 | + $later = time() + (14 * DAY_IN_SECONDS ); | |
| 672 | + | |
| 673 | + update_user_meta($current_user_id, 'maxbuttons_review_notice', $later); | |
| 670 | 674 | } |
| 671 | 675 | if ($status == 'reviewoffer-dismiss') // different ad! |
| 672 | 676 | { |
| 673 | - $updated = true; | |
| 674 | - update_user_meta($current_user_id, 'maxbuttons_review_offer', 'off'); | |
| 675 | - | |
| 677 | + $updated = true; | |
| 678 | + update_user_meta($current_user_id, 'maxbuttons_review_offer', 'off'); | |
| 679 | + | |
| 676 | 680 | } |
| 677 | - | |
| 678 | - echo json_encode(array("updated" => $updated)) ; | |
| 679 | - | |
| 680 | - exit(); | |
| 681 | + | |
| 682 | + echo json_encode(array("updated" => $updated)) ; | |
| 683 | + | |
| 684 | + exit(); | |
| 681 | 685 | } |
| 682 | - | |
| 683 | - /* Add a notice | |
| 684 | - | |
| 685 | - The added notice will be displayed to the user in WordPress format. | |
| 686 | + | |
| 687 | + /* Add a notice | |
| 688 | + | |
| 689 | + The added notice will be displayed to the user in WordPress format. | |
| 686 | 690 | @see display_notices |
| 687 | - | |
| 691 | + | |
| 688 | 692 | @param $type string message | notice | error | fatal |
| 689 | 693 | @param $message string User understandable message |
| 690 | - | |
| 694 | + | |
| 691 | 695 | */ |
| 692 | 696 | public static function add_notice($type, $message) |
| 693 | 697 | { |
| 694 | - self::$notices[] = array("type" => $type, | |
| 698 | + self::$notices[] = array("type" => $type, | |
| 695 | 699 | "message" => $message |
| 696 | - ); | |
| 697 | - | |
| 700 | + ); | |
| 701 | + | |
| 698 | 702 | } |
| 699 | - | |
| 703 | + | |
| 700 | 704 | /* Display all notices |
| 701 | - | |
| 705 | + | |
| 702 | 706 | Then notices added by @see add_notice will be displayed. This function is called by an action hook |
| 703 | - | |
| 707 | + | |
| 704 | 708 | @param $echo echo the results or silently return. |
| 705 | 709 | @return string|null If not written to screen via echo, the HTML output will be returned |
| 706 | 710 | */ |
| 707 | 711 | public function display_notices($echo = true) |
| @@ -707,27 +711,25 @@ | ||
| 707 | 711 | public function display_notices($echo = true) |
| 708 | 712 | { |
| 709 | 713 | |
| 710 | 714 | if ($echo === '') $echo = true; |
| 711 | - $notices = self::$notices; | |
| 712 | - $output = ''; | |
| 715 | + $notices = self::$notices; | |
| 716 | + $output = ''; | |
| 713 | 717 | if (count($notices) == 0) |
| 714 | 718 | return; |
| 715 | - | |
| 719 | + | |
| 716 | 720 | foreach($notices as $index => $notice) |
| 717 | 721 | { |
| 718 | - $type = $notice["type"]; | |
| 719 | - $message = $notice["message"]; | |
| 720 | - $output .= "<div class='mb-message $type'> "; | |
| 721 | - $output .= $message ; | |
| 722 | - $output .= "</div>"; | |
| 723 | - } | |
| 722 | + $type = $notice["type"]; | |
| 723 | + $message = $notice["message"]; | |
| 724 | + $output .= "<div class='mb-message $type'> "; | |
| 725 | + $output .= $message ; | |
| 726 | + $output .= "</div>"; | |
| 727 | + } | |
| 724 | 728 | |
| 725 | - self::$notices = array(); // empty notices to prevent double display | |
| 726 | - | |
| 727 | - if ($echo) echo $output; | |
| 729 | + self::$notices = array(); // empty notices to prevent double display | |
| 730 | + | |
| 731 | + if ($echo) echo $output; | |
| 728 | 732 | else return $output; |
| 729 | 733 | } |
| 730 | - | |
| 734 | + | |
| 731 | 735 | } // class |
| 732 | - | |
| 733 | - | |