| @@ -32,12 +32,11 @@ | ||
| 32 | 32 | $plugin_action = isset($_POST['plugin_action']) ? sanitize_text_field($_POST['plugin_action']) : ''; |
| 33 | 33 | $nonce = isset($_POST['nonce']) ? $_POST['nonce'] : false; |
| 34 | 34 | $message = __( sprintf("No Handler found for action %s ", $plugin_action), 'maxbuttons'); |
| 35 | 35 | |
| 36 | - | |
| 37 | 36 | if (! wp_verify_nonce($nonce, 'maxajax') ) |
| 38 | 37 | { |
| 39 | - $message = __('Nonce not verified (' . $nonce . ')', 'maxbuttons'); | |
| 38 | + $message = __('Nonce not verified', 'maxbuttons'); | |
| 40 | 39 | } |
| 41 | 40 | else |
| 42 | 41 | { |
| 43 | 42 | do_action('maxbuttons/ajax/' . $plugin_action, $_POST); |
| @@ -42,15 +41,13 @@ | ||
| 42 | 41 | { |
| 43 | 42 | do_action('maxbuttons/ajax/' . $plugin_action, $_POST); |
| 44 | 43 | } |
| 45 | 44 | |
| 46 | - /*echo json_encode( array( 'status' => $status, | |
| 45 | + echo json_encode( array( 'status' => $status, | |
| 47 | 46 | 'message' => $message, |
| 48 | 47 | ) |
| 49 | - ); */ | |
| 50 | - | |
| 51 | - wp_send_json_error( array('message' => $message) ); | |
| 52 | - | |
| 48 | + ); | |
| 49 | + wp_die(); | |
| 53 | 50 | } |
| 54 | 51 | |
| 55 | 52 | public static function translit($string) |
| 56 | 53 | { |
| @@ -56,9 +53,8 @@ | ||
| 56 | 53 | { |
| 57 | 54 | require_once(MB()->get_plugin_path() . "assets/libraries/url_slug.php"); |
| 58 | 55 | |
| 59 | 56 | $string = mb_url_slug($string, array("transliterate" => true)); |
| 60 | - | |
| 61 | 57 | return $string; |
| 62 | 58 | } |
| 63 | 59 | |
| 64 | 60 | public static function selectify($name, $array, $selected, $target = '', $class = '') |
| @@ -82,13 +78,8 @@ | ||
| 82 | 78 | |
| 83 | 79 | |
| 84 | 80 | static function hex2rgba($color, $opacity) { |
| 85 | 81 | // Grab the hex color and remove # |
| 86 | - | |
| 87 | - /* Check if color is already rgba. This can happen with transparency. */ | |
| 88 | - if (strpos($color, 'rgba') !== false) | |
| 89 | - return $color; | |
| 90 | - | |
| 91 | 82 | $hex = str_replace("#", "", $color); |
| 92 | 83 | |
| 93 | 84 | // Convert hex to rgb |
| 94 | 85 | if(strlen($color) == 3) { |
| @@ -120,22 +111,10 @@ | ||
| 120 | 111 | // Spits out rgba(0, 0, 0, 0.5) format |
| 121 | 112 | return 'rgba(' . $rgb . ', ' . $alpha . ')'; |
| 122 | 113 | } |
| 123 | 114 | |
| 124 | - // test if color value is in RGBA or not. | |
| 125 | - static function isrgba($value) | |
| 126 | - { | |
| 127 | - if (strpos($value, 'rgb') >= 0 ) | |
| 128 | - return true; | |
| 129 | - else { | |
| 130 | - return false; | |
| 131 | - } | |
| 132 | - } | |
| 133 | - | |
| 134 | 115 | static function strip_px($value) { |
| 135 | - $value = rtrim( intval($value), 'px'); | |
| 136 | - $value = rtrim( intval($value), '%'); | |
| 137 | - return $value; | |
| 116 | + return rtrim( intval($value), 'px'); | |
| 138 | 117 | } |
| 139 | 118 | |
| 140 | 119 | static function generate_font_sizes($start, $end, $step = 1) |
| 141 | 120 | { |
| @@ -165,16 +144,16 @@ | ||
| 165 | 144 | "large_desktop" => "only screen and (min-width : 1824px)", |
| 166 | 145 | ); |
| 167 | 146 | |
| 168 | 147 | $query_names = array( |
| 169 | - "phone" => __("Small phones, < 480px","maxbuttons"), | |
| 170 | - "phone_land" => __("Small phones (landscape) ","maxbuttons"), | |
| 171 | - "phone_portrait" => __("Small phones (portrait), < 320px ","maxbuttons"), | |
| 172 | - "medium_phone" => __("Medium-size (smart)phone (480px-768px)","maxbuttons"), | |
| 173 | - "ipad" => __("Ipad (all) / Large phones (768px-1024px)","maxbuttons"), | |
| 148 | + "phone" => __("Small phones","maxbuttons"), | |
| 149 | + "phone_land" => __("Small phones (landscape)","maxbuttons"), | |
| 150 | + "phone_portrait" => __("Small phones (portrait)","maxbuttons"), | |
| 151 | + "medium_phone" => __("Medium-size (smart)phone","maxbuttons"), | |
| 152 | + "ipad" => __("Ipad (all) / Large phones","maxbuttons"), | |
| 174 | 153 | "ipad_land" => __("Ipad landscape","maxbuttons"), |
| 175 | 154 | "ipad_portrait" => __("Ipad portrait","maxbuttons"), |
| 176 | - "desktop" => __("Desktop, > 1224px","maxbuttons"), | |
| 155 | + "desktop" => __("Desktop","maxbuttons"), | |
| 177 | 156 | "large_desktop" => __("Large desktops","maxbuttons"), |
| 178 | 157 | "custom" => __("Custom size","maxbuttons"), |
| 179 | 158 | ); |
| 180 | 159 | |
| @@ -313,9 +292,8 @@ | ||
| 313 | 292 | |
| 314 | 293 | } |
| 315 | 294 | |
| 316 | 295 | /** Function will try to unload any FA scripts other than MB from WP. In case of conflict */ |
| 317 | - /* 7.0 note - this function is currently not in use due to dynamic font library loading */ | |
| 318 | 296 | static function fixFAConflict() |
| 319 | 297 | { |
| 320 | 298 | $forcefa = get_option('maxbuttons_forcefa'); |
| 321 | 299 | |
| @@ -330,9 +308,8 @@ | ||
| 330 | 308 | { |
| 331 | 309 | if ($script == 'mbpro-font-awesome') |
| 332 | 310 | { |
| 333 | 311 | $our_fa_there = true; |
| 334 | - | |
| 335 | 312 | break; |
| 336 | 313 | } |
| 337 | 314 | } |
| 338 | 315 | |
| @@ -337,12 +314,11 @@ | ||
| 337 | 314 | } |
| 338 | 315 | |
| 339 | 316 | // fix nothing on pages where we are not loading. |
| 340 | 317 | if (! $our_fa_there) |
| 341 | - { | |
| 342 | 318 | return; |
| 343 | - } | |
| 344 | 319 | |
| 320 | + | |
| 345 | 321 | // Loop through all registered styles and remove any that appear to be Font Awesome. |
| 346 | 322 | foreach ( $wp_styles->registered as $script => $details ) { |
| 347 | 323 | $src = isset($details->src) ? $details->src : false; |
| 348 | 324 | |
| @@ -351,14 +327,11 @@ | ||
| 351 | 327 | $mbpro_src = $src; |
| 352 | 328 | continue; // exclude us |
| 353 | 329 | } |
| 354 | 330 | |
| 355 | - // look at script handle | |
| 356 | - | |
| 357 | 331 | if ( false !== strpos( $script, 'fontawesome' ) || false !== strpos( $script, 'font-awesome' ) ) { |
| 358 | 332 | wp_dequeue_style( $script ); |
| 359 | 333 | } |
| 360 | - // look at file source | |
| 361 | 334 | if ($src && ( false !== strpos($src, 'font-awesome') || false !== strpos($src, 'fontawesome') ) ) |
| 362 | 335 | { |
| 363 | 336 | wp_dequeue_style( $script ); |
| 364 | 337 | } |
| @@ -400,9 +373,8 @@ | ||
| 400 | 373 | return; |
| 401 | 374 | |
| 402 | 375 | self::$time_operations[$operation][] = array("start" => microtime(true), |
| 403 | 376 | "end" => 0, |
| 404 | - 'memory_start' => memory_get_usage(), | |
| 405 | 377 | ); |
| 406 | 378 | |
| 407 | 379 | } |
| 408 | 380 | |
| @@ -416,9 +388,8 @@ | ||
| 416 | 388 | { |
| 417 | 389 | if (self::$time_operations[$operation][$i]["end"] == 0) |
| 418 | 390 | { |
| 419 | 391 | self::$time_operations[$operation][$i]["end"] = microtime(true); |
| 420 | - self::$time_operations[$operation][$i]["memory_end"] = memory_get_usage(); | |
| 421 | 392 | break; |
| 422 | 393 | } |
| 423 | 394 | } |
| 424 | 395 | |
| @@ -423,16 +394,10 @@ | ||
| 423 | 394 | } |
| 424 | 395 | |
| 425 | 396 | } |
| 426 | 397 | |
| 427 | - public static function convert_memory($size) | |
| 398 | + static function showTime() | |
| 428 | 399 | { |
| 429 | - $unit=array('b','kb','mb','gb','tb','pb'); | |
| 430 | - return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i]; | |
| 431 | - } | |
| 432 | - | |
| 433 | - public static function showTime() | |
| 434 | - { | |
| 435 | 400 | if ( ! defined('MAXBUTTONS_BENCHMARK') || MAXBUTTONS_BENCHMARK !== true) |
| 436 | 401 | return; |
| 437 | 402 | |
| 438 | 403 | $timer = self::$timer; |
| @@ -446,16 +411,16 @@ | ||
| 446 | 411 | { |
| 447 | 412 | $start = $data["start"]; |
| 448 | 413 | $end = $data["end"]; |
| 449 | 414 | $duration = $end - $start; |
| 450 | - $mem_start = $data['memory_start']; | |
| 451 | - $mem_end = $data['memory_end']; | |
| 452 | 415 | |
| 453 | 416 | |
| 454 | 417 | $text .= "<span class='first'>$duration</span> |
| 455 | 418 | <span class='second'>$operation</span> |
| 456 | - <span class='third'>" . self::convert_memory($mem_start) . " - " . self::convert_memory($mem_end) . "</span><br /> | |
| 419 | + <span class='third'> </span><br /> | |
| 457 | 420 | "; |
| 421 | + | |
| 422 | + | |
| 458 | 423 | } |
| 459 | 424 | } |
| 460 | 425 | |
| 461 | 426 | |