@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | * Bail if we are not in WP. |
| 14 | 14 | */ |
| 15 | 15 | if ( ! defined( 'ABSPATH' ) ) { |
| 16 | - exit; |
|
| 16 | + exit; |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | /** |
@@ -21,434 +21,434 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | if ( ! class_exists( 'AyeCode_UI_Settings' ) ) { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * A Class to be able to change settings for Font Awesome. |
|
| 26 | - * |
|
| 27 | - * Class AyeCode_UI_Settings |
|
| 28 | - * @ver 1.0.0 |
|
| 29 | - * @todo decide how to implement textdomain |
|
| 30 | - */ |
|
| 31 | - class AyeCode_UI_Settings { |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Class version version. |
|
| 35 | - * |
|
| 36 | - * @var string |
|
| 37 | - */ |
|
| 38 | - public $version = '0.1.83'; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * Class textdomain. |
|
| 42 | - * |
|
| 43 | - * @var string |
|
| 44 | - */ |
|
| 45 | - public $textdomain = 'aui'; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * Latest version of Bootstrap at time of publish published. |
|
| 49 | - * |
|
| 50 | - * @var string |
|
| 51 | - */ |
|
| 52 | - public $latest = "4.5.3"; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * Current version of select2 being used. |
|
| 56 | - * |
|
| 57 | - * @var string |
|
| 58 | - */ |
|
| 59 | - public $select2_version = "4.0.11"; |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * The title. |
|
| 63 | - * |
|
| 64 | - * @var string |
|
| 65 | - */ |
|
| 66 | - public $name = 'AyeCode UI'; |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * The relative url to the assets. |
|
| 70 | - * |
|
| 71 | - * @var string |
|
| 72 | - */ |
|
| 73 | - public $url = ''; |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * Holds the settings values. |
|
| 77 | - * |
|
| 78 | - * @var array |
|
| 79 | - */ |
|
| 80 | - private $settings; |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * AyeCode_UI_Settings instance. |
|
| 84 | - * |
|
| 85 | - * @access private |
|
| 86 | - * @since 1.0.0 |
|
| 87 | - * @var AyeCode_UI_Settings There can be only one! |
|
| 88 | - */ |
|
| 89 | - private static $instance = null; |
|
| 90 | - |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * Main AyeCode_UI_Settings Instance. |
|
| 94 | - * |
|
| 95 | - * Ensures only one instance of AyeCode_UI_Settings is loaded or can be loaded. |
|
| 96 | - * |
|
| 97 | - * @since 1.0.0 |
|
| 98 | - * @static |
|
| 99 | - * @return AyeCode_UI_Settings - Main instance. |
|
| 100 | - */ |
|
| 101 | - public static function instance() { |
|
| 102 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) { |
|
| 103 | - |
|
| 104 | - self::$instance = new AyeCode_UI_Settings; |
|
| 105 | - |
|
| 106 | - add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
| 107 | - |
|
| 108 | - if ( is_admin() ) { |
|
| 109 | - add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
| 110 | - add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
| 111 | - |
|
| 112 | - // Maybe show example page |
|
| 113 | - add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) ); |
|
| 114 | - |
|
| 115 | - if ( defined( 'BLOCKSTRAP_VERSION' ) ) { |
|
| 116 | - add_filter( 'sd_aui_colors', array( self::$instance,'sd_aui_colors' ), 10, 3 ); |
|
| 117 | - } |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - add_action( 'customize_register', array( self::$instance, 'customizer_settings' )); |
|
| 121 | - |
|
| 122 | - do_action( 'ayecode_ui_settings_loaded' ); |
|
| 123 | - } |
|
| 24 | + /** |
|
| 25 | + * A Class to be able to change settings for Font Awesome. |
|
| 26 | + * |
|
| 27 | + * Class AyeCode_UI_Settings |
|
| 28 | + * @ver 1.0.0 |
|
| 29 | + * @todo decide how to implement textdomain |
|
| 30 | + */ |
|
| 31 | + class AyeCode_UI_Settings { |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Class version version. |
|
| 35 | + * |
|
| 36 | + * @var string |
|
| 37 | + */ |
|
| 38 | + public $version = '0.1.83'; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * Class textdomain. |
|
| 42 | + * |
|
| 43 | + * @var string |
|
| 44 | + */ |
|
| 45 | + public $textdomain = 'aui'; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * Latest version of Bootstrap at time of publish published. |
|
| 49 | + * |
|
| 50 | + * @var string |
|
| 51 | + */ |
|
| 52 | + public $latest = "4.5.3"; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * Current version of select2 being used. |
|
| 56 | + * |
|
| 57 | + * @var string |
|
| 58 | + */ |
|
| 59 | + public $select2_version = "4.0.11"; |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * The title. |
|
| 63 | + * |
|
| 64 | + * @var string |
|
| 65 | + */ |
|
| 66 | + public $name = 'AyeCode UI'; |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * The relative url to the assets. |
|
| 70 | + * |
|
| 71 | + * @var string |
|
| 72 | + */ |
|
| 73 | + public $url = ''; |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * Holds the settings values. |
|
| 77 | + * |
|
| 78 | + * @var array |
|
| 79 | + */ |
|
| 80 | + private $settings; |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * AyeCode_UI_Settings instance. |
|
| 84 | + * |
|
| 85 | + * @access private |
|
| 86 | + * @since 1.0.0 |
|
| 87 | + * @var AyeCode_UI_Settings There can be only one! |
|
| 88 | + */ |
|
| 89 | + private static $instance = null; |
|
| 90 | + |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * Main AyeCode_UI_Settings Instance. |
|
| 94 | + * |
|
| 95 | + * Ensures only one instance of AyeCode_UI_Settings is loaded or can be loaded. |
|
| 96 | + * |
|
| 97 | + * @since 1.0.0 |
|
| 98 | + * @static |
|
| 99 | + * @return AyeCode_UI_Settings - Main instance. |
|
| 100 | + */ |
|
| 101 | + public static function instance() { |
|
| 102 | + if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) { |
|
| 103 | + |
|
| 104 | + self::$instance = new AyeCode_UI_Settings; |
|
| 105 | + |
|
| 106 | + add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
| 107 | + |
|
| 108 | + if ( is_admin() ) { |
|
| 109 | + add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
| 110 | + add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
| 111 | + |
|
| 112 | + // Maybe show example page |
|
| 113 | + add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) ); |
|
| 114 | + |
|
| 115 | + if ( defined( 'BLOCKSTRAP_VERSION' ) ) { |
|
| 116 | + add_filter( 'sd_aui_colors', array( self::$instance,'sd_aui_colors' ), 10, 3 ); |
|
| 117 | + } |
|
| 118 | + } |
|
| 124 | 119 | |
| 125 | - return self::$instance; |
|
| 126 | - } |
|
| 120 | + add_action( 'customize_register', array( self::$instance, 'customizer_settings' )); |
|
| 127 | 121 | |
| 128 | - /** |
|
| 129 | - * Add custom colors to the color selector. |
|
| 130 | - * |
|
| 131 | - * @param $theme_colors |
|
| 132 | - * @param $include_outlines |
|
| 133 | - * @param $include_branding |
|
| 134 | - * |
|
| 135 | - * @return mixed |
|
| 136 | - */ |
|
| 137 | - public function sd_aui_colors( $theme_colors, $include_outlines, $include_branding ){ |
|
| 122 | + do_action( 'ayecode_ui_settings_loaded' ); |
|
| 123 | + } |
|
| 138 | 124 | |
| 125 | + return self::$instance; |
|
| 126 | + } |
|
| 139 | 127 | |
| 140 | - $setting = wp_get_global_settings(); |
|
| 128 | + /** |
|
| 129 | + * Add custom colors to the color selector. |
|
| 130 | + * |
|
| 131 | + * @param $theme_colors |
|
| 132 | + * @param $include_outlines |
|
| 133 | + * @param $include_branding |
|
| 134 | + * |
|
| 135 | + * @return mixed |
|
| 136 | + */ |
|
| 137 | + public function sd_aui_colors( $theme_colors, $include_outlines, $include_branding ){ |
|
| 141 | 138 | |
| 142 | - if(!empty($setting['color']['palette']['custom'])){ |
|
| 143 | - foreach($setting['color']['palette']['custom'] as $color){ |
|
| 144 | - $theme_colors[$color['slug']] = esc_attr($color['name']); |
|
| 145 | - } |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - return $theme_colors; |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - /** |
|
| 152 | - * Setup some constants. |
|
| 153 | - */ |
|
| 154 | - public function constants(){ |
|
| 155 | - define( 'AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be" ); |
|
| 156 | - define( 'AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d' ); |
|
| 157 | - define( 'AUI_INFO_COLOR_ORIGINAL', '#17a2b8' ); |
|
| 158 | - define( 'AUI_WARNING_COLOR_ORIGINAL', '#ffc107' ); |
|
| 159 | - define( 'AUI_DANGER_COLOR_ORIGINAL', '#dc3545' ); |
|
| 160 | - define( 'AUI_SUCCESS_COLOR_ORIGINAL', '#44c553' ); |
|
| 161 | - define( 'AUI_LIGHT_COLOR_ORIGINAL', '#f8f9fa' ); |
|
| 162 | - define( 'AUI_DARK_COLOR_ORIGINAL', '#343a40' ); |
|
| 163 | - define( 'AUI_WHITE_COLOR_ORIGINAL', '#fff' ); |
|
| 164 | - define( 'AUI_PURPLE_COLOR_ORIGINAL', '#ad6edd' ); |
|
| 165 | - define( 'AUI_SALMON_COLOR_ORIGINAL', '#ff977a' ); |
|
| 166 | - define( 'AUI_CYAN_COLOR_ORIGINAL', '#35bdff' ); |
|
| 167 | - define( 'AUI_GRAY_COLOR_ORIGINAL', '#ced4da' ); |
|
| 168 | - define( 'AUI_INDIGO_COLOR_ORIGINAL', '#502c6c' ); |
|
| 169 | - define( 'AUI_ORANGE_COLOR_ORIGINAL', '#orange' ); |
|
| 170 | - define( 'AUI_BLACK_COLOR_ORIGINAL', '#000' ); |
|
| 171 | - |
|
| 172 | - if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) { |
|
| 173 | - define( 'AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL ); |
|
| 174 | - } |
|
| 175 | - if ( ! defined( 'AUI_SECONDARY_COLOR' ) ) { |
|
| 176 | - define( 'AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL ); |
|
| 177 | - } |
|
| 178 | - if ( ! defined( 'AUI_INFO_COLOR' ) ) { |
|
| 179 | - define( 'AUI_INFO_COLOR', AUI_INFO_COLOR_ORIGINAL ); |
|
| 180 | - } |
|
| 181 | - if ( ! defined( 'AUI_WARNING_COLOR' ) ) { |
|
| 182 | - define( 'AUI_WARNING_COLOR', AUI_WARNING_COLOR_ORIGINAL ); |
|
| 183 | - } |
|
| 184 | - if ( ! defined( 'AUI_DANGER_COLOR' ) ) { |
|
| 185 | - define( 'AUI_DANGER_COLOR', AUI_DANGER_COLOR_ORIGINAL ); |
|
| 186 | - } |
|
| 187 | - if ( ! defined( 'AUI_SUCCESS_COLOR' ) ) { |
|
| 188 | - define( 'AUI_SUCCESS_COLOR', AUI_SUCCESS_COLOR_ORIGINAL ); |
|
| 189 | - } |
|
| 190 | - if ( ! defined( 'AUI_LIGHT_COLOR' ) ) { |
|
| 191 | - define( 'AUI_LIGHT_COLOR', AUI_LIGHT_COLOR_ORIGINAL ); |
|
| 192 | - } |
|
| 193 | - if ( ! defined( 'AUI_DARK_COLOR' ) ) { |
|
| 194 | - define( 'AUI_DARK_COLOR', AUI_DARK_COLOR_ORIGINAL ); |
|
| 195 | - } |
|
| 196 | - if ( ! defined( 'AUI_WHITE_COLOR' ) ) { |
|
| 197 | - define( 'AUI_WHITE_COLOR', AUI_WHITE_COLOR_ORIGINAL ); |
|
| 198 | - } |
|
| 199 | - if ( ! defined( 'AUI_PURPLE_COLOR' ) ) { |
|
| 200 | - define( 'AUI_PURPLE_COLOR', AUI_PURPLE_COLOR_ORIGINAL ); |
|
| 201 | - } |
|
| 202 | - if ( ! defined( 'AUI_SALMON_COLOR' ) ) { |
|
| 203 | - define( 'AUI_SALMON_COLOR', AUI_SALMON_COLOR_ORIGINAL ); |
|
| 204 | - } |
|
| 205 | - if ( ! defined( 'AUI_CYAN_COLOR' ) ) { |
|
| 206 | - define( 'AUI_CYAN_COLOR', AUI_CYAN_COLOR_ORIGINAL ); |
|
| 207 | - } |
|
| 208 | - if ( ! defined( 'AUI_GRAY_COLOR' ) ) { |
|
| 209 | - define( 'AUI_GRAY_COLOR', AUI_GRAY_COLOR_ORIGINAL ); |
|
| 210 | - } |
|
| 211 | - if ( ! defined( 'AUI_INDIGO_COLOR' ) ) { |
|
| 212 | - define( 'AUI_INDIGO_COLOR', AUI_INDIGO_COLOR_ORIGINAL ); |
|
| 213 | - } |
|
| 214 | - if ( ! defined( 'AUI_ORANGE_COLOR' ) ) { |
|
| 215 | - define( 'AUI_ORANGE_COLOR', AUI_ORANGE_COLOR_ORIGINAL ); |
|
| 216 | - } |
|
| 217 | - if ( ! defined( 'AUI_BLACK_COLOR' ) ) { |
|
| 218 | - define( 'AUI_BLACK_COLOR', AUI_BLACK_COLOR_ORIGINAL ); |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - public static function get_colors( $original = false){ |
|
| 224 | - |
|
| 225 | - if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) { |
|
| 226 | - return array(); |
|
| 227 | - } |
|
| 228 | - if ( $original ) { |
|
| 229 | - return array( |
|
| 230 | - 'primary' => AUI_PRIMARY_COLOR_ORIGINAL, |
|
| 231 | - 'secondary' => AUI_SECONDARY_COLOR_ORIGINAL, |
|
| 232 | - 'info' => AUI_INFO_COLOR_ORIGINAL, |
|
| 233 | - 'warning' => AUI_WARNING_COLOR_ORIGINAL, |
|
| 234 | - 'danger' => AUI_DANGER_COLOR_ORIGINAL, |
|
| 235 | - 'success' => AUI_SUCCESS_COLOR_ORIGINAL, |
|
| 236 | - 'light' => AUI_LIGHT_COLOR_ORIGINAL, |
|
| 237 | - 'dark' => AUI_DARK_COLOR_ORIGINAL, |
|
| 238 | - 'white' => AUI_WHITE_COLOR_ORIGINAL, |
|
| 239 | - 'purple' => AUI_PURPLE_COLOR_ORIGINAL, |
|
| 240 | - 'salmon' => AUI_SALMON_COLOR_ORIGINAL, |
|
| 241 | - 'cyan' => AUI_CYAN_COLOR_ORIGINAL, |
|
| 242 | - 'gray' => AUI_GRAY_COLOR_ORIGINAL, |
|
| 243 | - 'indigo' => AUI_INDIGO_COLOR_ORIGINAL, |
|
| 244 | - 'orange' => AUI_ORANGE_COLOR_ORIGINAL, |
|
| 245 | - 'black' => AUI_BLACK_COLOR_ORIGINAL, |
|
| 246 | - ); |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - return array( |
|
| 250 | - 'primary' => AUI_PRIMARY_COLOR, |
|
| 251 | - 'secondary' => AUI_SECONDARY_COLOR, |
|
| 252 | - 'info' => AUI_INFO_COLOR, |
|
| 253 | - 'warning' => AUI_WARNING_COLOR, |
|
| 254 | - 'danger' => AUI_DANGER_COLOR, |
|
| 255 | - 'success' => AUI_SUCCESS_COLOR, |
|
| 256 | - 'light' => AUI_LIGHT_COLOR, |
|
| 257 | - 'dark' => AUI_DARK_COLOR, |
|
| 258 | - 'white' => AUI_WHITE_COLOR, |
|
| 259 | - 'purple' => AUI_PURPLE_COLOR, |
|
| 260 | - 'salmon' => AUI_SALMON_COLOR, |
|
| 261 | - 'cyan' => AUI_CYAN_COLOR, |
|
| 262 | - 'gray' => AUI_GRAY_COLOR, |
|
| 263 | - 'indigo' => AUI_INDIGO_COLOR, |
|
| 264 | - 'orange' => AUI_ORANGE_COLOR, |
|
| 265 | - 'black' => AUI_BLACK_COLOR, |
|
| 266 | - ); |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - /** |
|
| 270 | - * Initiate the settings and add the required action hooks. |
|
| 271 | - */ |
|
| 272 | - public function init() { |
|
| 273 | - |
|
| 274 | - // Maybe fix settings |
|
| 275 | - if ( ! empty( $_REQUEST['aui-fix-admin'] ) && !empty($_REQUEST['nonce']) && wp_verify_nonce( $_REQUEST['nonce'], "aui-fix-admin" ) ) { |
|
| 276 | - $db_settings = get_option( 'ayecode-ui-settings' ); |
|
| 277 | - if ( ! empty( $db_settings ) ) { |
|
| 278 | - $db_settings['css_backend'] = 'compatibility'; |
|
| 279 | - $db_settings['js_backend'] = 'core-popper'; |
|
| 280 | - update_option( 'ayecode-ui-settings', $db_settings ); |
|
| 281 | - wp_safe_redirect(admin_url("options-general.php?page=ayecode-ui-settings&updated=true")); |
|
| 282 | - } |
|
| 283 | - } |
|
| 284 | 139 | |
| 285 | - $this->constants(); |
|
| 286 | - $this->settings = $this->get_settings(); |
|
| 287 | - $this->url = $this->get_url(); |
|
| 140 | + $setting = wp_get_global_settings(); |
|
| 288 | 141 | |
| 289 | - /** |
|
| 290 | - * Maybe load CSS |
|
| 291 | - * |
|
| 292 | - * We load super early in case there is a theme version that might change the colors |
|
| 293 | - */ |
|
| 294 | - if ( $this->settings['css'] ) { |
|
| 295 | - $priority = $this->is_bs3_compat() ? 100 : 1; |
|
| 296 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), $priority ); |
|
| 297 | - } |
|
| 298 | - if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) { |
|
| 299 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
| 300 | - } |
|
| 301 | - |
|
| 302 | - // maybe load JS |
|
| 303 | - if ( $this->settings['js'] ) { |
|
| 304 | - $priority = $this->is_bs3_compat() ? 100 : 1; |
|
| 305 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority ); |
|
| 306 | - } |
|
| 307 | - if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { |
|
| 308 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
| 309 | - } |
|
| 310 | - |
|
| 311 | - // Maybe set the HTML font size |
|
| 312 | - if ( $this->settings['html_font_size'] ) { |
|
| 313 | - add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 ); |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - // Maybe show backend style error |
|
| 317 | - if( $this->settings['css_backend'] != 'compatibility' || $this->settings['js_backend'] != 'core-popper' ){ |
|
| 318 | - //add_action( 'admin_notices', array( $this, 'show_admin_style_notice' ) ); |
|
| 319 | - } |
|
| 320 | - |
|
| 321 | - } |
|
| 322 | - |
|
| 323 | - /** |
|
| 324 | - * Show admin notice if backend scripts not loaded. |
|
| 325 | - */ |
|
| 326 | - public function show_admin_style_notice(){ |
|
| 327 | - $fix_url = admin_url("options-general.php?page=ayecode-ui-settings&aui-fix-admin=true&nonce=".wp_create_nonce('aui-fix-admin')); |
|
| 328 | - $button = '<a href="'.esc_url($fix_url).'" class="button-primary">Fix Now</a>'; |
|
| 329 | - $message = __( '<b>Style Issue:</b> AyeCode UI is disable or set wrong.')." " .$button; |
|
| 330 | - echo '<div class="notice notice-error aui-settings-error-notice"><p>'.$message.'</p></div>'; |
|
| 331 | - } |
|
| 332 | - |
|
| 333 | - /** |
|
| 334 | - * Check if we should load the admin scripts or not. |
|
| 335 | - * |
|
| 336 | - * @return bool |
|
| 337 | - */ |
|
| 338 | - public function load_admin_scripts(){ |
|
| 339 | - $result = true; |
|
| 340 | - |
|
| 341 | - // check if specifically disabled |
|
| 342 | - if(!empty($this->settings['disable_admin'])){ |
|
| 343 | - $url_parts = explode("\n",$this->settings['disable_admin']); |
|
| 344 | - foreach($url_parts as $part){ |
|
| 345 | - if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){ |
|
| 346 | - return false; // return early, no point checking further |
|
| 347 | - } |
|
| 348 | - } |
|
| 349 | - } |
|
| 350 | - |
|
| 351 | - return $result; |
|
| 352 | - } |
|
| 353 | - |
|
| 354 | - /** |
|
| 355 | - * Add a html font size to the footer. |
|
| 356 | - */ |
|
| 357 | - public function html_font_size(){ |
|
| 358 | - $this->settings = $this->get_settings(); |
|
| 359 | - echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
| 360 | - } |
|
| 361 | - |
|
| 362 | - /** |
|
| 363 | - * Check if the current admin screen should load scripts. |
|
| 364 | - * |
|
| 365 | - * @return bool |
|
| 366 | - */ |
|
| 367 | - public function is_aui_screen(){ |
|
| 142 | + if(!empty($setting['color']['palette']['custom'])){ |
|
| 143 | + foreach($setting['color']['palette']['custom'] as $color){ |
|
| 144 | + $theme_colors[$color['slug']] = esc_attr($color['name']); |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + return $theme_colors; |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + /** |
|
| 152 | + * Setup some constants. |
|
| 153 | + */ |
|
| 154 | + public function constants(){ |
|
| 155 | + define( 'AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be" ); |
|
| 156 | + define( 'AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d' ); |
|
| 157 | + define( 'AUI_INFO_COLOR_ORIGINAL', '#17a2b8' ); |
|
| 158 | + define( 'AUI_WARNING_COLOR_ORIGINAL', '#ffc107' ); |
|
| 159 | + define( 'AUI_DANGER_COLOR_ORIGINAL', '#dc3545' ); |
|
| 160 | + define( 'AUI_SUCCESS_COLOR_ORIGINAL', '#44c553' ); |
|
| 161 | + define( 'AUI_LIGHT_COLOR_ORIGINAL', '#f8f9fa' ); |
|
| 162 | + define( 'AUI_DARK_COLOR_ORIGINAL', '#343a40' ); |
|
| 163 | + define( 'AUI_WHITE_COLOR_ORIGINAL', '#fff' ); |
|
| 164 | + define( 'AUI_PURPLE_COLOR_ORIGINAL', '#ad6edd' ); |
|
| 165 | + define( 'AUI_SALMON_COLOR_ORIGINAL', '#ff977a' ); |
|
| 166 | + define( 'AUI_CYAN_COLOR_ORIGINAL', '#35bdff' ); |
|
| 167 | + define( 'AUI_GRAY_COLOR_ORIGINAL', '#ced4da' ); |
|
| 168 | + define( 'AUI_INDIGO_COLOR_ORIGINAL', '#502c6c' ); |
|
| 169 | + define( 'AUI_ORANGE_COLOR_ORIGINAL', '#orange' ); |
|
| 170 | + define( 'AUI_BLACK_COLOR_ORIGINAL', '#000' ); |
|
| 171 | + |
|
| 172 | + if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) { |
|
| 173 | + define( 'AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL ); |
|
| 174 | + } |
|
| 175 | + if ( ! defined( 'AUI_SECONDARY_COLOR' ) ) { |
|
| 176 | + define( 'AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL ); |
|
| 177 | + } |
|
| 178 | + if ( ! defined( 'AUI_INFO_COLOR' ) ) { |
|
| 179 | + define( 'AUI_INFO_COLOR', AUI_INFO_COLOR_ORIGINAL ); |
|
| 180 | + } |
|
| 181 | + if ( ! defined( 'AUI_WARNING_COLOR' ) ) { |
|
| 182 | + define( 'AUI_WARNING_COLOR', AUI_WARNING_COLOR_ORIGINAL ); |
|
| 183 | + } |
|
| 184 | + if ( ! defined( 'AUI_DANGER_COLOR' ) ) { |
|
| 185 | + define( 'AUI_DANGER_COLOR', AUI_DANGER_COLOR_ORIGINAL ); |
|
| 186 | + } |
|
| 187 | + if ( ! defined( 'AUI_SUCCESS_COLOR' ) ) { |
|
| 188 | + define( 'AUI_SUCCESS_COLOR', AUI_SUCCESS_COLOR_ORIGINAL ); |
|
| 189 | + } |
|
| 190 | + if ( ! defined( 'AUI_LIGHT_COLOR' ) ) { |
|
| 191 | + define( 'AUI_LIGHT_COLOR', AUI_LIGHT_COLOR_ORIGINAL ); |
|
| 192 | + } |
|
| 193 | + if ( ! defined( 'AUI_DARK_COLOR' ) ) { |
|
| 194 | + define( 'AUI_DARK_COLOR', AUI_DARK_COLOR_ORIGINAL ); |
|
| 195 | + } |
|
| 196 | + if ( ! defined( 'AUI_WHITE_COLOR' ) ) { |
|
| 197 | + define( 'AUI_WHITE_COLOR', AUI_WHITE_COLOR_ORIGINAL ); |
|
| 198 | + } |
|
| 199 | + if ( ! defined( 'AUI_PURPLE_COLOR' ) ) { |
|
| 200 | + define( 'AUI_PURPLE_COLOR', AUI_PURPLE_COLOR_ORIGINAL ); |
|
| 201 | + } |
|
| 202 | + if ( ! defined( 'AUI_SALMON_COLOR' ) ) { |
|
| 203 | + define( 'AUI_SALMON_COLOR', AUI_SALMON_COLOR_ORIGINAL ); |
|
| 204 | + } |
|
| 205 | + if ( ! defined( 'AUI_CYAN_COLOR' ) ) { |
|
| 206 | + define( 'AUI_CYAN_COLOR', AUI_CYAN_COLOR_ORIGINAL ); |
|
| 207 | + } |
|
| 208 | + if ( ! defined( 'AUI_GRAY_COLOR' ) ) { |
|
| 209 | + define( 'AUI_GRAY_COLOR', AUI_GRAY_COLOR_ORIGINAL ); |
|
| 210 | + } |
|
| 211 | + if ( ! defined( 'AUI_INDIGO_COLOR' ) ) { |
|
| 212 | + define( 'AUI_INDIGO_COLOR', AUI_INDIGO_COLOR_ORIGINAL ); |
|
| 213 | + } |
|
| 214 | + if ( ! defined( 'AUI_ORANGE_COLOR' ) ) { |
|
| 215 | + define( 'AUI_ORANGE_COLOR', AUI_ORANGE_COLOR_ORIGINAL ); |
|
| 216 | + } |
|
| 217 | + if ( ! defined( 'AUI_BLACK_COLOR' ) ) { |
|
| 218 | + define( 'AUI_BLACK_COLOR', AUI_BLACK_COLOR_ORIGINAL ); |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + public static function get_colors( $original = false){ |
|
| 224 | + |
|
| 225 | + if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) { |
|
| 226 | + return array(); |
|
| 227 | + } |
|
| 228 | + if ( $original ) { |
|
| 229 | + return array( |
|
| 230 | + 'primary' => AUI_PRIMARY_COLOR_ORIGINAL, |
|
| 231 | + 'secondary' => AUI_SECONDARY_COLOR_ORIGINAL, |
|
| 232 | + 'info' => AUI_INFO_COLOR_ORIGINAL, |
|
| 233 | + 'warning' => AUI_WARNING_COLOR_ORIGINAL, |
|
| 234 | + 'danger' => AUI_DANGER_COLOR_ORIGINAL, |
|
| 235 | + 'success' => AUI_SUCCESS_COLOR_ORIGINAL, |
|
| 236 | + 'light' => AUI_LIGHT_COLOR_ORIGINAL, |
|
| 237 | + 'dark' => AUI_DARK_COLOR_ORIGINAL, |
|
| 238 | + 'white' => AUI_WHITE_COLOR_ORIGINAL, |
|
| 239 | + 'purple' => AUI_PURPLE_COLOR_ORIGINAL, |
|
| 240 | + 'salmon' => AUI_SALMON_COLOR_ORIGINAL, |
|
| 241 | + 'cyan' => AUI_CYAN_COLOR_ORIGINAL, |
|
| 242 | + 'gray' => AUI_GRAY_COLOR_ORIGINAL, |
|
| 243 | + 'indigo' => AUI_INDIGO_COLOR_ORIGINAL, |
|
| 244 | + 'orange' => AUI_ORANGE_COLOR_ORIGINAL, |
|
| 245 | + 'black' => AUI_BLACK_COLOR_ORIGINAL, |
|
| 246 | + ); |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + return array( |
|
| 250 | + 'primary' => AUI_PRIMARY_COLOR, |
|
| 251 | + 'secondary' => AUI_SECONDARY_COLOR, |
|
| 252 | + 'info' => AUI_INFO_COLOR, |
|
| 253 | + 'warning' => AUI_WARNING_COLOR, |
|
| 254 | + 'danger' => AUI_DANGER_COLOR, |
|
| 255 | + 'success' => AUI_SUCCESS_COLOR, |
|
| 256 | + 'light' => AUI_LIGHT_COLOR, |
|
| 257 | + 'dark' => AUI_DARK_COLOR, |
|
| 258 | + 'white' => AUI_WHITE_COLOR, |
|
| 259 | + 'purple' => AUI_PURPLE_COLOR, |
|
| 260 | + 'salmon' => AUI_SALMON_COLOR, |
|
| 261 | + 'cyan' => AUI_CYAN_COLOR, |
|
| 262 | + 'gray' => AUI_GRAY_COLOR, |
|
| 263 | + 'indigo' => AUI_INDIGO_COLOR, |
|
| 264 | + 'orange' => AUI_ORANGE_COLOR, |
|
| 265 | + 'black' => AUI_BLACK_COLOR, |
|
| 266 | + ); |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + /** |
|
| 270 | + * Initiate the settings and add the required action hooks. |
|
| 271 | + */ |
|
| 272 | + public function init() { |
|
| 273 | + |
|
| 274 | + // Maybe fix settings |
|
| 275 | + if ( ! empty( $_REQUEST['aui-fix-admin'] ) && !empty($_REQUEST['nonce']) && wp_verify_nonce( $_REQUEST['nonce'], "aui-fix-admin" ) ) { |
|
| 276 | + $db_settings = get_option( 'ayecode-ui-settings' ); |
|
| 277 | + if ( ! empty( $db_settings ) ) { |
|
| 278 | + $db_settings['css_backend'] = 'compatibility'; |
|
| 279 | + $db_settings['js_backend'] = 'core-popper'; |
|
| 280 | + update_option( 'ayecode-ui-settings', $db_settings ); |
|
| 281 | + wp_safe_redirect(admin_url("options-general.php?page=ayecode-ui-settings&updated=true")); |
|
| 282 | + } |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + $this->constants(); |
|
| 286 | + $this->settings = $this->get_settings(); |
|
| 287 | + $this->url = $this->get_url(); |
|
| 288 | + |
|
| 289 | + /** |
|
| 290 | + * Maybe load CSS |
|
| 291 | + * |
|
| 292 | + * We load super early in case there is a theme version that might change the colors |
|
| 293 | + */ |
|
| 294 | + if ( $this->settings['css'] ) { |
|
| 295 | + $priority = $this->is_bs3_compat() ? 100 : 1; |
|
| 296 | + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), $priority ); |
|
| 297 | + } |
|
| 298 | + if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) { |
|
| 299 | + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
| 300 | + } |
|
| 301 | + |
|
| 302 | + // maybe load JS |
|
| 303 | + if ( $this->settings['js'] ) { |
|
| 304 | + $priority = $this->is_bs3_compat() ? 100 : 1; |
|
| 305 | + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority ); |
|
| 306 | + } |
|
| 307 | + if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { |
|
| 308 | + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
| 309 | + } |
|
| 310 | + |
|
| 311 | + // Maybe set the HTML font size |
|
| 312 | + if ( $this->settings['html_font_size'] ) { |
|
| 313 | + add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 ); |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + // Maybe show backend style error |
|
| 317 | + if( $this->settings['css_backend'] != 'compatibility' || $this->settings['js_backend'] != 'core-popper' ){ |
|
| 318 | + //add_action( 'admin_notices', array( $this, 'show_admin_style_notice' ) ); |
|
| 319 | + } |
|
| 320 | + |
|
| 321 | + } |
|
| 322 | + |
|
| 323 | + /** |
|
| 324 | + * Show admin notice if backend scripts not loaded. |
|
| 325 | + */ |
|
| 326 | + public function show_admin_style_notice(){ |
|
| 327 | + $fix_url = admin_url("options-general.php?page=ayecode-ui-settings&aui-fix-admin=true&nonce=".wp_create_nonce('aui-fix-admin')); |
|
| 328 | + $button = '<a href="'.esc_url($fix_url).'" class="button-primary">Fix Now</a>'; |
|
| 329 | + $message = __( '<b>Style Issue:</b> AyeCode UI is disable or set wrong.')." " .$button; |
|
| 330 | + echo '<div class="notice notice-error aui-settings-error-notice"><p>'.$message.'</p></div>'; |
|
| 331 | + } |
|
| 332 | + |
|
| 333 | + /** |
|
| 334 | + * Check if we should load the admin scripts or not. |
|
| 335 | + * |
|
| 336 | + * @return bool |
|
| 337 | + */ |
|
| 338 | + public function load_admin_scripts(){ |
|
| 339 | + $result = true; |
|
| 340 | + |
|
| 341 | + // check if specifically disabled |
|
| 342 | + if(!empty($this->settings['disable_admin'])){ |
|
| 343 | + $url_parts = explode("\n",$this->settings['disable_admin']); |
|
| 344 | + foreach($url_parts as $part){ |
|
| 345 | + if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){ |
|
| 346 | + return false; // return early, no point checking further |
|
| 347 | + } |
|
| 348 | + } |
|
| 349 | + } |
|
| 350 | + |
|
| 351 | + return $result; |
|
| 352 | + } |
|
| 353 | + |
|
| 354 | + /** |
|
| 355 | + * Add a html font size to the footer. |
|
| 356 | + */ |
|
| 357 | + public function html_font_size(){ |
|
| 358 | + $this->settings = $this->get_settings(); |
|
| 359 | + echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
| 360 | + } |
|
| 361 | + |
|
| 362 | + /** |
|
| 363 | + * Check if the current admin screen should load scripts. |
|
| 364 | + * |
|
| 365 | + * @return bool |
|
| 366 | + */ |
|
| 367 | + public function is_aui_screen(){ |
|
| 368 | 368 | // echo '###';exit; |
| 369 | - $load = false; |
|
| 370 | - // check if we should load or not |
|
| 371 | - if ( is_admin() ) { |
|
| 372 | - // Only enable on set pages |
|
| 373 | - $aui_screens = array( |
|
| 374 | - 'page', |
|
| 375 | - 'post', |
|
| 376 | - 'settings_page_ayecode-ui-settings', |
|
| 377 | - 'appearance_page_gutenberg-widgets', |
|
| 378 | - 'widgets', |
|
| 379 | - 'ayecode-ui-settings', |
|
| 380 | - 'site-editor' |
|
| 381 | - ); |
|
| 382 | - $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens ); |
|
| 383 | - |
|
| 384 | - $screen = get_current_screen(); |
|
| 369 | + $load = false; |
|
| 370 | + // check if we should load or not |
|
| 371 | + if ( is_admin() ) { |
|
| 372 | + // Only enable on set pages |
|
| 373 | + $aui_screens = array( |
|
| 374 | + 'page', |
|
| 375 | + 'post', |
|
| 376 | + 'settings_page_ayecode-ui-settings', |
|
| 377 | + 'appearance_page_gutenberg-widgets', |
|
| 378 | + 'widgets', |
|
| 379 | + 'ayecode-ui-settings', |
|
| 380 | + 'site-editor' |
|
| 381 | + ); |
|
| 382 | + $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens ); |
|
| 383 | + |
|
| 384 | + $screen = get_current_screen(); |
|
| 385 | 385 | |
| 386 | 386 | // echo '###'.$screen->id; |
| 387 | 387 | |
| 388 | - // check if we are on a AUI screen |
|
| 389 | - if ( $screen && in_array( $screen->id, $screen_ids ) ) { |
|
| 390 | - $load = true; |
|
| 391 | - } |
|
| 388 | + // check if we are on a AUI screen |
|
| 389 | + if ( $screen && in_array( $screen->id, $screen_ids ) ) { |
|
| 390 | + $load = true; |
|
| 391 | + } |
|
| 392 | 392 | |
| 393 | - //load for widget previews in WP 5.8 |
|
| 394 | - if( !empty($_REQUEST['legacy-widget-preview'])){ |
|
| 395 | - $load = true; |
|
| 396 | - } |
|
| 397 | - } |
|
| 393 | + //load for widget previews in WP 5.8 |
|
| 394 | + if( !empty($_REQUEST['legacy-widget-preview'])){ |
|
| 395 | + $load = true; |
|
| 396 | + } |
|
| 397 | + } |
|
| 398 | 398 | |
| 399 | - return apply_filters( 'aui_load_on_admin' , $load ); |
|
| 400 | - } |
|
| 399 | + return apply_filters( 'aui_load_on_admin' , $load ); |
|
| 400 | + } |
|
| 401 | 401 | |
| 402 | - /** |
|
| 403 | - * Check if the current theme is a block theme. |
|
| 404 | - * |
|
| 405 | - * @return bool |
|
| 406 | - */ |
|
| 407 | - public static function is_block_theme() { |
|
| 408 | - if ( function_exists( 'wp_is_block_theme' && wp_is_block_theme() ) ) { |
|
| 409 | - return true; |
|
| 410 | - } |
|
| 402 | + /** |
|
| 403 | + * Check if the current theme is a block theme. |
|
| 404 | + * |
|
| 405 | + * @return bool |
|
| 406 | + */ |
|
| 407 | + public static function is_block_theme() { |
|
| 408 | + if ( function_exists( 'wp_is_block_theme' && wp_is_block_theme() ) ) { |
|
| 409 | + return true; |
|
| 410 | + } |
|
| 411 | 411 | |
| 412 | - return false; |
|
| 413 | - } |
|
| 412 | + return false; |
|
| 413 | + } |
|
| 414 | 414 | |
| 415 | - /** |
|
| 416 | - * Adds the styles. |
|
| 417 | - */ |
|
| 418 | - public function enqueue_style() { |
|
| 415 | + /** |
|
| 416 | + * Adds the styles. |
|
| 417 | + */ |
|
| 418 | + public function enqueue_style() { |
|
| 419 | 419 | |
| 420 | 420 | |
| 421 | - if( is_admin() && !$this->is_aui_screen()){ |
|
| 422 | - // don't add wp-admin scripts if not requested to |
|
| 423 | - }else{ |
|
| 424 | - $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
|
| 421 | + if( is_admin() && !$this->is_aui_screen()){ |
|
| 422 | + // don't add wp-admin scripts if not requested to |
|
| 423 | + }else{ |
|
| 424 | + $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
|
| 425 | 425 | |
| 426 | - $rtl = is_rtl() ? '-rtl' : ''; |
|
| 426 | + $rtl = is_rtl() ? '-rtl' : ''; |
|
| 427 | 427 | |
| 428 | - if($this->settings[$css_setting]){ |
|
| 429 | - $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
| 430 | - $url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets/css/ayecode-ui-compatibility'.$rtl.'.css'; |
|
| 428 | + if($this->settings[$css_setting]){ |
|
| 429 | + $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
| 430 | + $url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets/css/ayecode-ui-compatibility'.$rtl.'.css'; |
|
| 431 | 431 | |
| 432 | 432 | |
| 433 | 433 | |
| 434 | - wp_register_style( 'ayecode-ui', $url, array(), $this->version ); |
|
| 435 | - wp_enqueue_style( 'ayecode-ui' ); |
|
| 434 | + wp_register_style( 'ayecode-ui', $url, array(), $this->version ); |
|
| 435 | + wp_enqueue_style( 'ayecode-ui' ); |
|
| 436 | 436 | |
| 437 | 437 | |
| 438 | 438 | // if ( is_admin() && !empty($_REQUEST['postType']) ) { |
| 439 | - if ( is_admin() && !empty($_REQUEST['postType']) && ( defined( 'BLOCKSTRAP_VERSION' ) || defined( 'AUI_FSE' ) ) ) { |
|
| 440 | - $url = $this->url.'assets/css/ayecode-ui-fse.css'; |
|
| 441 | - wp_register_style( 'ayecode-ui-fse', $url, array(), $this->version ); |
|
| 442 | - wp_enqueue_style( 'ayecode-ui-fse' ); |
|
| 443 | - } |
|
| 439 | + if ( is_admin() && !empty($_REQUEST['postType']) && ( defined( 'BLOCKSTRAP_VERSION' ) || defined( 'AUI_FSE' ) ) ) { |
|
| 440 | + $url = $this->url.'assets/css/ayecode-ui-fse.css'; |
|
| 441 | + wp_register_style( 'ayecode-ui-fse', $url, array(), $this->version ); |
|
| 442 | + wp_enqueue_style( 'ayecode-ui-fse' ); |
|
| 443 | + } |
|
| 444 | 444 | |
| 445 | 445 | |
| 446 | - // flatpickr |
|
| 447 | - wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->version ); |
|
| 446 | + // flatpickr |
|
| 447 | + wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->version ); |
|
| 448 | 448 | |
| 449 | - // fix some wp-admin issues |
|
| 450 | - if(is_admin()){ |
|
| 451 | - $custom_css = " |
|
| 449 | + // fix some wp-admin issues |
|
| 450 | + if(is_admin()){ |
|
| 451 | + $custom_css = " |
|
| 452 | 452 | body{ |
| 453 | 453 | background-color: #f1f1f1; |
| 454 | 454 | font-family: -apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Oxygen-Sans,Ubuntu,Cantarell,\"Helvetica Neue\",sans-serif; |
@@ -494,35 +494,35 @@ discard block |
||
| 494 | 494 | } |
| 495 | 495 | "; |
| 496 | 496 | |
| 497 | - // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377 |
|
| 498 | - $custom_css .= " |
|
| 497 | + // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377 |
|
| 498 | + $custom_css .= " |
|
| 499 | 499 | .edit-post-sidebar input[type=color].components-text-control__input{ |
| 500 | 500 | padding: 0; |
| 501 | 501 | } |
| 502 | 502 | "; |
| 503 | - wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
| 504 | - } |
|
| 503 | + wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
| 504 | + } |
|
| 505 | 505 | |
| 506 | - // custom changes |
|
| 507 | - wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
| 506 | + // custom changes |
|
| 507 | + wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
| 508 | 508 | |
| 509 | - } |
|
| 510 | - } |
|
| 509 | + } |
|
| 510 | + } |
|
| 511 | 511 | |
| 512 | 512 | |
| 513 | - } |
|
| 513 | + } |
|
| 514 | 514 | |
| 515 | - /** |
|
| 516 | - * Get inline script used if bootstrap enqueued |
|
| 517 | - * |
|
| 518 | - * If this remains small then its best to use this than to add another JS file. |
|
| 519 | - */ |
|
| 520 | - public function inline_script() { |
|
| 521 | - // Flatpickr calendar locale |
|
| 522 | - $flatpickr_locale = self::flatpickr_locale(); |
|
| 515 | + /** |
|
| 516 | + * Get inline script used if bootstrap enqueued |
|
| 517 | + * |
|
| 518 | + * If this remains small then its best to use this than to add another JS file. |
|
| 519 | + */ |
|
| 520 | + public function inline_script() { |
|
| 521 | + // Flatpickr calendar locale |
|
| 522 | + $flatpickr_locale = self::flatpickr_locale(); |
|
| 523 | 523 | |
| 524 | - ob_start(); |
|
| 525 | - ?> |
|
| 524 | + ob_start(); |
|
| 525 | + ?> |
|
| 526 | 526 | <script> |
| 527 | 527 | /** |
| 528 | 528 | * An AUI bootstrap adaptation of GreedyNav.js ( by Luke Jackson ). |
@@ -1459,8 +1459,8 @@ discard block |
||
| 1459 | 1459 | aui_set_data_scroll(); |
| 1460 | 1460 | |
| 1461 | 1461 | <?php |
| 1462 | - // FSE tweaks. |
|
| 1463 | - if(!empty($_REQUEST['postType']) && $_REQUEST['postType']=='wp_template'){ ?> |
|
| 1462 | + // FSE tweaks. |
|
| 1463 | + if(!empty($_REQUEST['postType']) && $_REQUEST['postType']=='wp_template'){ ?> |
|
| 1464 | 1464 | function aui_fse_set_data_scroll() { |
| 1465 | 1465 | console.log('init scroll'); |
| 1466 | 1466 | let Iframe = document.getElementsByClassName("edit-site-visual-editor__editor-canvas"); |
@@ -1493,29 +1493,29 @@ discard block |
||
| 1493 | 1493 | |
| 1494 | 1494 | </script> |
| 1495 | 1495 | <?php |
| 1496 | - $output = ob_get_clean(); |
|
| 1496 | + $output = ob_get_clean(); |
|
| 1497 | 1497 | |
| 1498 | 1498 | |
| 1499 | 1499 | |
| 1500 | - /* |
|
| 1500 | + /* |
|
| 1501 | 1501 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1502 | 1502 | */ |
| 1503 | - return str_replace( array( |
|
| 1504 | - '<script>', |
|
| 1505 | - '</script>' |
|
| 1506 | - ), '', self::minify_js($output) ); |
|
| 1507 | - } |
|
| 1508 | - |
|
| 1509 | - |
|
| 1510 | - /** |
|
| 1511 | - * JS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
| 1512 | - * |
|
| 1513 | - * @TODO we may need this when other conflicts arrise. |
|
| 1514 | - * @return mixed |
|
| 1515 | - */ |
|
| 1516 | - public static function bs3_compat_js() { |
|
| 1517 | - ob_start(); |
|
| 1518 | - ?> |
|
| 1503 | + return str_replace( array( |
|
| 1504 | + '<script>', |
|
| 1505 | + '</script>' |
|
| 1506 | + ), '', self::minify_js($output) ); |
|
| 1507 | + } |
|
| 1508 | + |
|
| 1509 | + |
|
| 1510 | + /** |
|
| 1511 | + * JS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
| 1512 | + * |
|
| 1513 | + * @TODO we may need this when other conflicts arrise. |
|
| 1514 | + * @return mixed |
|
| 1515 | + */ |
|
| 1516 | + public static function bs3_compat_js() { |
|
| 1517 | + ob_start(); |
|
| 1518 | + ?> |
|
| 1519 | 1519 | <script> |
| 1520 | 1520 | <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?> |
| 1521 | 1521 | /* With Avada builder */ |
@@ -1523,20 +1523,20 @@ discard block |
||
| 1523 | 1523 | <?php } ?> |
| 1524 | 1524 | </script> |
| 1525 | 1525 | <?php |
| 1526 | - return str_replace( array( |
|
| 1527 | - '<script>', |
|
| 1528 | - '</script>' |
|
| 1529 | - ), '', ob_get_clean()); |
|
| 1530 | - } |
|
| 1531 | - |
|
| 1532 | - /** |
|
| 1533 | - * Get inline script used if bootstrap file browser enqueued. |
|
| 1534 | - * |
|
| 1535 | - * If this remains small then its best to use this than to add another JS file. |
|
| 1536 | - */ |
|
| 1537 | - public function inline_script_file_browser(){ |
|
| 1538 | - ob_start(); |
|
| 1539 | - ?> |
|
| 1526 | + return str_replace( array( |
|
| 1527 | + '<script>', |
|
| 1528 | + '</script>' |
|
| 1529 | + ), '', ob_get_clean()); |
|
| 1530 | + } |
|
| 1531 | + |
|
| 1532 | + /** |
|
| 1533 | + * Get inline script used if bootstrap file browser enqueued. |
|
| 1534 | + * |
|
| 1535 | + * If this remains small then its best to use this than to add another JS file. |
|
| 1536 | + */ |
|
| 1537 | + public function inline_script_file_browser(){ |
|
| 1538 | + ob_start(); |
|
| 1539 | + ?> |
|
| 1540 | 1540 | <script> |
| 1541 | 1541 | // run on doc ready |
| 1542 | 1542 | jQuery(document).ready(function () { |
@@ -1544,227 +1544,227 @@ discard block |
||
| 1544 | 1544 | }); |
| 1545 | 1545 | </script> |
| 1546 | 1546 | <?php |
| 1547 | - $output = ob_get_clean(); |
|
| 1547 | + $output = ob_get_clean(); |
|
| 1548 | 1548 | |
| 1549 | - /* |
|
| 1549 | + /* |
|
| 1550 | 1550 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1551 | 1551 | */ |
| 1552 | - return str_replace( array( |
|
| 1553 | - '<script>', |
|
| 1554 | - '</script>' |
|
| 1555 | - ), '', $output ); |
|
| 1556 | - } |
|
| 1557 | - |
|
| 1558 | - /** |
|
| 1559 | - * Adds the Font Awesome JS. |
|
| 1560 | - */ |
|
| 1561 | - public function enqueue_scripts() { |
|
| 1562 | - |
|
| 1563 | - if( is_admin() && !$this->is_aui_screen()){ |
|
| 1564 | - // don't add wp-admin scripts if not requested to |
|
| 1565 | - }else { |
|
| 1566 | - |
|
| 1567 | - $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
|
| 1568 | - |
|
| 1569 | - // select2 |
|
| 1570 | - wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version ); |
|
| 1571 | - |
|
| 1572 | - // flatpickr |
|
| 1573 | - wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version ); |
|
| 1574 | - |
|
| 1575 | - // flatpickr |
|
| 1576 | - wp_register_script( 'iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version ); |
|
| 1577 | - |
|
| 1578 | - // Bootstrap file browser |
|
| 1579 | - wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version ); |
|
| 1580 | - wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
| 1581 | - |
|
| 1582 | - $load_inline = false; |
|
| 1583 | - |
|
| 1584 | - if ( $this->settings[ $js_setting ] == 'core-popper' ) { |
|
| 1585 | - // Bootstrap bundle |
|
| 1586 | - $url = $this->url . 'assets/js/bootstrap.bundle.min.js'; |
|
| 1587 | - wp_register_script( 'bootstrap-js-bundle', $url, array( |
|
| 1588 | - 'select2', |
|
| 1589 | - 'jquery' |
|
| 1590 | - ), $this->version, $this->is_bs3_compat() ); |
|
| 1591 | - // if in admin then add to footer for compatibility. |
|
| 1592 | - is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' ); |
|
| 1593 | - $script = $this->inline_script(); |
|
| 1594 | - wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
| 1595 | - } elseif ( $this->settings[ $js_setting ] == 'popper' ) { |
|
| 1596 | - $url = $this->url . 'assets/js/popper.min.js'; |
|
| 1597 | - wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->version ); |
|
| 1598 | - wp_enqueue_script( 'bootstrap-js-popper' ); |
|
| 1599 | - $load_inline = true; |
|
| 1600 | - } else { |
|
| 1601 | - $load_inline = true; |
|
| 1602 | - } |
|
| 1603 | - |
|
| 1604 | - // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
|
| 1605 | - if ( $load_inline ) { |
|
| 1606 | - wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) ); |
|
| 1607 | - wp_enqueue_script( 'bootstrap-dummy' ); |
|
| 1608 | - $script = $this->inline_script(); |
|
| 1609 | - wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
| 1610 | - } |
|
| 1611 | - } |
|
| 1612 | - |
|
| 1613 | - } |
|
| 1614 | - |
|
| 1615 | - /** |
|
| 1616 | - * Enqueue flatpickr if called. |
|
| 1617 | - */ |
|
| 1618 | - public function enqueue_flatpickr(){ |
|
| 1619 | - wp_enqueue_style( 'flatpickr' ); |
|
| 1620 | - wp_enqueue_script( 'flatpickr' ); |
|
| 1621 | - } |
|
| 1622 | - |
|
| 1623 | - /** |
|
| 1624 | - * Enqueue iconpicker if called. |
|
| 1625 | - */ |
|
| 1626 | - public function enqueue_iconpicker(){ |
|
| 1627 | - wp_enqueue_style( 'iconpicker' ); |
|
| 1628 | - wp_enqueue_script( 'iconpicker' ); |
|
| 1629 | - } |
|
| 1630 | - |
|
| 1631 | - /** |
|
| 1632 | - * Get the url path to the current folder. |
|
| 1633 | - * |
|
| 1634 | - * @return string |
|
| 1635 | - */ |
|
| 1636 | - public function get_url() { |
|
| 1637 | - $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) ); |
|
| 1638 | - $content_url = untrailingslashit( WP_CONTENT_URL ); |
|
| 1639 | - |
|
| 1640 | - // Replace http:// to https://. |
|
| 1641 | - if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) { |
|
| 1642 | - $content_url = str_replace( 'http://', 'https://', $content_url ); |
|
| 1643 | - } |
|
| 1644 | - |
|
| 1645 | - // Check if we are inside a plugin |
|
| 1646 | - $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 1647 | - $url = str_replace( $content_dir, $content_url, $file_dir ); |
|
| 1648 | - |
|
| 1649 | - return trailingslashit( $url ); |
|
| 1650 | - } |
|
| 1651 | - |
|
| 1652 | - /** |
|
| 1653 | - * Get the url path to the current folder. |
|
| 1654 | - * |
|
| 1655 | - * @return string |
|
| 1656 | - */ |
|
| 1657 | - public function get_url_old() { |
|
| 1658 | - |
|
| 1659 | - $url = ''; |
|
| 1660 | - // check if we are inside a plugin |
|
| 1661 | - $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 1662 | - |
|
| 1663 | - // add check in-case user has changed wp-content dir name. |
|
| 1664 | - $wp_content_folder_name = basename(WP_CONTENT_DIR); |
|
| 1665 | - $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
| 1666 | - $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
| 1667 | - |
|
| 1668 | - if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
| 1669 | - $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
| 1670 | - } |
|
| 1671 | - |
|
| 1672 | - return $url; |
|
| 1673 | - } |
|
| 1674 | - |
|
| 1675 | - /** |
|
| 1676 | - * Register the database settings with WordPress. |
|
| 1677 | - */ |
|
| 1678 | - public function register_settings() { |
|
| 1679 | - register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
| 1680 | - } |
|
| 1681 | - |
|
| 1682 | - /** |
|
| 1683 | - * Add the WordPress settings menu item. |
|
| 1684 | - * @since 1.0.10 Calling function name direct will fail theme check so we don't. |
|
| 1685 | - */ |
|
| 1686 | - public function menu_item() { |
|
| 1687 | - $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
|
| 1688 | - call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
| 1689 | - $this, |
|
| 1690 | - 'settings_page' |
|
| 1691 | - ) ); |
|
| 1692 | - } |
|
| 1693 | - |
|
| 1694 | - /** |
|
| 1695 | - * Get a list of themes and their default JS settings. |
|
| 1696 | - * |
|
| 1697 | - * @return array |
|
| 1698 | - */ |
|
| 1699 | - public function theme_js_settings(){ |
|
| 1700 | - return array( |
|
| 1701 | - 'ayetheme' => 'popper', |
|
| 1702 | - 'listimia' => 'required', |
|
| 1703 | - 'listimia_backend' => 'core-popper', |
|
| 1704 | - //'avada' => 'required', // removed as we now add compatibility |
|
| 1705 | - ); |
|
| 1706 | - } |
|
| 1707 | - |
|
| 1708 | - /** |
|
| 1709 | - * Get the current Font Awesome output settings. |
|
| 1710 | - * |
|
| 1711 | - * @return array The array of settings. |
|
| 1712 | - */ |
|
| 1713 | - public function get_settings() { |
|
| 1714 | - |
|
| 1715 | - $db_settings = get_option( 'ayecode-ui-settings' ); |
|
| 1716 | - $js_default = 'core-popper'; |
|
| 1717 | - $js_default_backend = $js_default; |
|
| 1718 | - |
|
| 1719 | - // maybe set defaults (if no settings set) |
|
| 1720 | - if(empty($db_settings)){ |
|
| 1721 | - $active_theme = strtolower( get_template() ); // active parent theme. |
|
| 1722 | - $theme_js_settings = self::theme_js_settings(); |
|
| 1723 | - if(isset($theme_js_settings[$active_theme])){ |
|
| 1724 | - $js_default = $theme_js_settings[$active_theme]; |
|
| 1725 | - $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
| 1726 | - } |
|
| 1727 | - } |
|
| 1552 | + return str_replace( array( |
|
| 1553 | + '<script>', |
|
| 1554 | + '</script>' |
|
| 1555 | + ), '', $output ); |
|
| 1556 | + } |
|
| 1557 | + |
|
| 1558 | + /** |
|
| 1559 | + * Adds the Font Awesome JS. |
|
| 1560 | + */ |
|
| 1561 | + public function enqueue_scripts() { |
|
| 1562 | + |
|
| 1563 | + if( is_admin() && !$this->is_aui_screen()){ |
|
| 1564 | + // don't add wp-admin scripts if not requested to |
|
| 1565 | + }else { |
|
| 1566 | + |
|
| 1567 | + $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
|
| 1568 | + |
|
| 1569 | + // select2 |
|
| 1570 | + wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version ); |
|
| 1571 | + |
|
| 1572 | + // flatpickr |
|
| 1573 | + wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version ); |
|
| 1574 | + |
|
| 1575 | + // flatpickr |
|
| 1576 | + wp_register_script( 'iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version ); |
|
| 1577 | + |
|
| 1578 | + // Bootstrap file browser |
|
| 1579 | + wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version ); |
|
| 1580 | + wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
| 1581 | + |
|
| 1582 | + $load_inline = false; |
|
| 1583 | + |
|
| 1584 | + if ( $this->settings[ $js_setting ] == 'core-popper' ) { |
|
| 1585 | + // Bootstrap bundle |
|
| 1586 | + $url = $this->url . 'assets/js/bootstrap.bundle.min.js'; |
|
| 1587 | + wp_register_script( 'bootstrap-js-bundle', $url, array( |
|
| 1588 | + 'select2', |
|
| 1589 | + 'jquery' |
|
| 1590 | + ), $this->version, $this->is_bs3_compat() ); |
|
| 1591 | + // if in admin then add to footer for compatibility. |
|
| 1592 | + is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' ); |
|
| 1593 | + $script = $this->inline_script(); |
|
| 1594 | + wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
| 1595 | + } elseif ( $this->settings[ $js_setting ] == 'popper' ) { |
|
| 1596 | + $url = $this->url . 'assets/js/popper.min.js'; |
|
| 1597 | + wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->version ); |
|
| 1598 | + wp_enqueue_script( 'bootstrap-js-popper' ); |
|
| 1599 | + $load_inline = true; |
|
| 1600 | + } else { |
|
| 1601 | + $load_inline = true; |
|
| 1602 | + } |
|
| 1728 | 1603 | |
| 1729 | - /** |
|
| 1730 | - * Filter the default settings. |
|
| 1731 | - */ |
|
| 1732 | - $defaults = apply_filters( 'ayecode-ui-default-settings', array( |
|
| 1733 | - 'css' => 'compatibility', // core, compatibility |
|
| 1734 | - 'js' => $js_default, // js to load, core-popper, popper |
|
| 1735 | - 'html_font_size' => '16', // js to load, core-popper, popper |
|
| 1736 | - 'css_backend' => 'compatibility', // core, compatibility |
|
| 1737 | - 'js_backend' => $js_default_backend, // js to load, core-popper, popper |
|
| 1738 | - 'disable_admin' => '', // URL snippets to disable loading on admin |
|
| 1739 | - ), $db_settings ); |
|
| 1740 | - |
|
| 1741 | - $settings = wp_parse_args( $db_settings, $defaults ); |
|
| 1742 | - |
|
| 1743 | - /** |
|
| 1744 | - * Filter the Bootstrap settings. |
|
| 1745 | - * |
|
| 1746 | - * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
|
| 1747 | - */ |
|
| 1748 | - return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
| 1749 | - } |
|
| 1750 | - |
|
| 1751 | - |
|
| 1752 | - /** |
|
| 1753 | - * The settings page html output. |
|
| 1754 | - */ |
|
| 1755 | - public function settings_page() { |
|
| 1756 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 1757 | - wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) ); |
|
| 1758 | - } |
|
| 1759 | - ?> |
|
| 1604 | + // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
|
| 1605 | + if ( $load_inline ) { |
|
| 1606 | + wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) ); |
|
| 1607 | + wp_enqueue_script( 'bootstrap-dummy' ); |
|
| 1608 | + $script = $this->inline_script(); |
|
| 1609 | + wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
| 1610 | + } |
|
| 1611 | + } |
|
| 1612 | + |
|
| 1613 | + } |
|
| 1614 | + |
|
| 1615 | + /** |
|
| 1616 | + * Enqueue flatpickr if called. |
|
| 1617 | + */ |
|
| 1618 | + public function enqueue_flatpickr(){ |
|
| 1619 | + wp_enqueue_style( 'flatpickr' ); |
|
| 1620 | + wp_enqueue_script( 'flatpickr' ); |
|
| 1621 | + } |
|
| 1622 | + |
|
| 1623 | + /** |
|
| 1624 | + * Enqueue iconpicker if called. |
|
| 1625 | + */ |
|
| 1626 | + public function enqueue_iconpicker(){ |
|
| 1627 | + wp_enqueue_style( 'iconpicker' ); |
|
| 1628 | + wp_enqueue_script( 'iconpicker' ); |
|
| 1629 | + } |
|
| 1630 | + |
|
| 1631 | + /** |
|
| 1632 | + * Get the url path to the current folder. |
|
| 1633 | + * |
|
| 1634 | + * @return string |
|
| 1635 | + */ |
|
| 1636 | + public function get_url() { |
|
| 1637 | + $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) ); |
|
| 1638 | + $content_url = untrailingslashit( WP_CONTENT_URL ); |
|
| 1639 | + |
|
| 1640 | + // Replace http:// to https://. |
|
| 1641 | + if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) { |
|
| 1642 | + $content_url = str_replace( 'http://', 'https://', $content_url ); |
|
| 1643 | + } |
|
| 1644 | + |
|
| 1645 | + // Check if we are inside a plugin |
|
| 1646 | + $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 1647 | + $url = str_replace( $content_dir, $content_url, $file_dir ); |
|
| 1648 | + |
|
| 1649 | + return trailingslashit( $url ); |
|
| 1650 | + } |
|
| 1651 | + |
|
| 1652 | + /** |
|
| 1653 | + * Get the url path to the current folder. |
|
| 1654 | + * |
|
| 1655 | + * @return string |
|
| 1656 | + */ |
|
| 1657 | + public function get_url_old() { |
|
| 1658 | + |
|
| 1659 | + $url = ''; |
|
| 1660 | + // check if we are inside a plugin |
|
| 1661 | + $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 1662 | + |
|
| 1663 | + // add check in-case user has changed wp-content dir name. |
|
| 1664 | + $wp_content_folder_name = basename(WP_CONTENT_DIR); |
|
| 1665 | + $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
| 1666 | + $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
| 1667 | + |
|
| 1668 | + if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
| 1669 | + $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
| 1670 | + } |
|
| 1671 | + |
|
| 1672 | + return $url; |
|
| 1673 | + } |
|
| 1674 | + |
|
| 1675 | + /** |
|
| 1676 | + * Register the database settings with WordPress. |
|
| 1677 | + */ |
|
| 1678 | + public function register_settings() { |
|
| 1679 | + register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
| 1680 | + } |
|
| 1681 | + |
|
| 1682 | + /** |
|
| 1683 | + * Add the WordPress settings menu item. |
|
| 1684 | + * @since 1.0.10 Calling function name direct will fail theme check so we don't. |
|
| 1685 | + */ |
|
| 1686 | + public function menu_item() { |
|
| 1687 | + $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
|
| 1688 | + call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
| 1689 | + $this, |
|
| 1690 | + 'settings_page' |
|
| 1691 | + ) ); |
|
| 1692 | + } |
|
| 1693 | + |
|
| 1694 | + /** |
|
| 1695 | + * Get a list of themes and their default JS settings. |
|
| 1696 | + * |
|
| 1697 | + * @return array |
|
| 1698 | + */ |
|
| 1699 | + public function theme_js_settings(){ |
|
| 1700 | + return array( |
|
| 1701 | + 'ayetheme' => 'popper', |
|
| 1702 | + 'listimia' => 'required', |
|
| 1703 | + 'listimia_backend' => 'core-popper', |
|
| 1704 | + //'avada' => 'required', // removed as we now add compatibility |
|
| 1705 | + ); |
|
| 1706 | + } |
|
| 1707 | + |
|
| 1708 | + /** |
|
| 1709 | + * Get the current Font Awesome output settings. |
|
| 1710 | + * |
|
| 1711 | + * @return array The array of settings. |
|
| 1712 | + */ |
|
| 1713 | + public function get_settings() { |
|
| 1714 | + |
|
| 1715 | + $db_settings = get_option( 'ayecode-ui-settings' ); |
|
| 1716 | + $js_default = 'core-popper'; |
|
| 1717 | + $js_default_backend = $js_default; |
|
| 1718 | + |
|
| 1719 | + // maybe set defaults (if no settings set) |
|
| 1720 | + if(empty($db_settings)){ |
|
| 1721 | + $active_theme = strtolower( get_template() ); // active parent theme. |
|
| 1722 | + $theme_js_settings = self::theme_js_settings(); |
|
| 1723 | + if(isset($theme_js_settings[$active_theme])){ |
|
| 1724 | + $js_default = $theme_js_settings[$active_theme]; |
|
| 1725 | + $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
| 1726 | + } |
|
| 1727 | + } |
|
| 1728 | + |
|
| 1729 | + /** |
|
| 1730 | + * Filter the default settings. |
|
| 1731 | + */ |
|
| 1732 | + $defaults = apply_filters( 'ayecode-ui-default-settings', array( |
|
| 1733 | + 'css' => 'compatibility', // core, compatibility |
|
| 1734 | + 'js' => $js_default, // js to load, core-popper, popper |
|
| 1735 | + 'html_font_size' => '16', // js to load, core-popper, popper |
|
| 1736 | + 'css_backend' => 'compatibility', // core, compatibility |
|
| 1737 | + 'js_backend' => $js_default_backend, // js to load, core-popper, popper |
|
| 1738 | + 'disable_admin' => '', // URL snippets to disable loading on admin |
|
| 1739 | + ), $db_settings ); |
|
| 1740 | + |
|
| 1741 | + $settings = wp_parse_args( $db_settings, $defaults ); |
|
| 1742 | + |
|
| 1743 | + /** |
|
| 1744 | + * Filter the Bootstrap settings. |
|
| 1745 | + * |
|
| 1746 | + * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
|
| 1747 | + */ |
|
| 1748 | + return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
| 1749 | + } |
|
| 1750 | + |
|
| 1751 | + |
|
| 1752 | + /** |
|
| 1753 | + * The settings page html output. |
|
| 1754 | + */ |
|
| 1755 | + public function settings_page() { |
|
| 1756 | + if ( ! current_user_can( 'manage_options' ) ) { |
|
| 1757 | + wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) ); |
|
| 1758 | + } |
|
| 1759 | + ?> |
|
| 1760 | 1760 | <div class="wrap"> |
| 1761 | 1761 | <h1><?php echo $this->name; ?></h1> |
| 1762 | 1762 | <p><?php echo apply_filters( 'ayecode-ui-settings-message', __("Here you can adjust settings if you are having compatibility issues.",'aui') );?></p> |
| 1763 | 1763 | <form method="post" action="options.php"> |
| 1764 | 1764 | <?php |
| 1765 | - settings_fields( 'ayecode-ui-settings' ); |
|
| 1766 | - do_settings_sections( 'ayecode-ui-settings' ); |
|
| 1767 | - ?> |
|
| 1765 | + settings_fields( 'ayecode-ui-settings' ); |
|
| 1766 | + do_settings_sections( 'ayecode-ui-settings' ); |
|
| 1767 | + ?> |
|
| 1768 | 1768 | |
| 1769 | 1769 | <h2><?php _e( 'Frontend', 'aui' ); ?></h2> |
| 1770 | 1770 | <table class="form-table wpbs-table-settings"> |
@@ -1844,60 +1844,60 @@ discard block |
||
| 1844 | 1844 | </table> |
| 1845 | 1845 | |
| 1846 | 1846 | <?php |
| 1847 | - submit_button(); |
|
| 1848 | - ?> |
|
| 1847 | + submit_button(); |
|
| 1848 | + ?> |
|
| 1849 | 1849 | </form> |
| 1850 | 1850 | |
| 1851 | 1851 | <div id="wpbs-version"><?php echo $this->version; ?></div> |
| 1852 | 1852 | </div> |
| 1853 | 1853 | |
| 1854 | 1854 | <?php |
| 1855 | - } |
|
| 1856 | - |
|
| 1857 | - public function customizer_settings($wp_customize){ |
|
| 1858 | - $wp_customize->add_section('aui_settings', array( |
|
| 1859 | - 'title' => __('AyeCode UI','aui'), |
|
| 1860 | - 'priority' => 120, |
|
| 1861 | - )); |
|
| 1862 | - |
|
| 1863 | - // ============================= |
|
| 1864 | - // = Color Picker = |
|
| 1865 | - // ============================= |
|
| 1866 | - $wp_customize->add_setting('aui_options[color_primary]', array( |
|
| 1867 | - 'default' => AUI_PRIMARY_COLOR, |
|
| 1868 | - 'sanitize_callback' => 'sanitize_hex_color', |
|
| 1869 | - 'capability' => 'edit_theme_options', |
|
| 1870 | - 'type' => 'option', |
|
| 1871 | - 'transport' => 'refresh', |
|
| 1872 | - )); |
|
| 1873 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
| 1874 | - 'label' => __('Primary Color','aui'), |
|
| 1875 | - 'section' => 'aui_settings', |
|
| 1876 | - 'settings' => 'aui_options[color_primary]', |
|
| 1877 | - ))); |
|
| 1878 | - |
|
| 1879 | - $wp_customize->add_setting('aui_options[color_secondary]', array( |
|
| 1880 | - 'default' => '#6c757d', |
|
| 1881 | - 'sanitize_callback' => 'sanitize_hex_color', |
|
| 1882 | - 'capability' => 'edit_theme_options', |
|
| 1883 | - 'type' => 'option', |
|
| 1884 | - 'transport' => 'refresh', |
|
| 1885 | - )); |
|
| 1886 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
| 1887 | - 'label' => __('Secondary Color','aui'), |
|
| 1888 | - 'section' => 'aui_settings', |
|
| 1889 | - 'settings' => 'aui_options[color_secondary]', |
|
| 1890 | - ))); |
|
| 1891 | - } |
|
| 1892 | - |
|
| 1893 | - /** |
|
| 1894 | - * CSS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
| 1895 | - * |
|
| 1896 | - * @return mixed |
|
| 1897 | - */ |
|
| 1898 | - public static function bs3_compat_css() { |
|
| 1899 | - ob_start(); |
|
| 1900 | - ?> |
|
| 1855 | + } |
|
| 1856 | + |
|
| 1857 | + public function customizer_settings($wp_customize){ |
|
| 1858 | + $wp_customize->add_section('aui_settings', array( |
|
| 1859 | + 'title' => __('AyeCode UI','aui'), |
|
| 1860 | + 'priority' => 120, |
|
| 1861 | + )); |
|
| 1862 | + |
|
| 1863 | + // ============================= |
|
| 1864 | + // = Color Picker = |
|
| 1865 | + // ============================= |
|
| 1866 | + $wp_customize->add_setting('aui_options[color_primary]', array( |
|
| 1867 | + 'default' => AUI_PRIMARY_COLOR, |
|
| 1868 | + 'sanitize_callback' => 'sanitize_hex_color', |
|
| 1869 | + 'capability' => 'edit_theme_options', |
|
| 1870 | + 'type' => 'option', |
|
| 1871 | + 'transport' => 'refresh', |
|
| 1872 | + )); |
|
| 1873 | + $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
| 1874 | + 'label' => __('Primary Color','aui'), |
|
| 1875 | + 'section' => 'aui_settings', |
|
| 1876 | + 'settings' => 'aui_options[color_primary]', |
|
| 1877 | + ))); |
|
| 1878 | + |
|
| 1879 | + $wp_customize->add_setting('aui_options[color_secondary]', array( |
|
| 1880 | + 'default' => '#6c757d', |
|
| 1881 | + 'sanitize_callback' => 'sanitize_hex_color', |
|
| 1882 | + 'capability' => 'edit_theme_options', |
|
| 1883 | + 'type' => 'option', |
|
| 1884 | + 'transport' => 'refresh', |
|
| 1885 | + )); |
|
| 1886 | + $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
| 1887 | + 'label' => __('Secondary Color','aui'), |
|
| 1888 | + 'section' => 'aui_settings', |
|
| 1889 | + 'settings' => 'aui_options[color_secondary]', |
|
| 1890 | + ))); |
|
| 1891 | + } |
|
| 1892 | + |
|
| 1893 | + /** |
|
| 1894 | + * CSS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
| 1895 | + * |
|
| 1896 | + * @return mixed |
|
| 1897 | + */ |
|
| 1898 | + public static function bs3_compat_css() { |
|
| 1899 | + ob_start(); |
|
| 1900 | + ?> |
|
| 1901 | 1901 | <style> |
| 1902 | 1902 | /* Bootstrap 3 compatibility */ |
| 1903 | 1903 | body.modal-open .modal-backdrop.show:not(.in) {opacity:0.5;} |
@@ -1926,825 +1926,825 @@ discard block |
||
| 1926 | 1926 | <?php } ?> |
| 1927 | 1927 | </style> |
| 1928 | 1928 | <?php |
| 1929 | - return str_replace( array( |
|
| 1930 | - '<style>', |
|
| 1931 | - '</style>' |
|
| 1932 | - ), '', self::minify_css( ob_get_clean() ) ); |
|
| 1933 | - } |
|
| 1934 | - |
|
| 1935 | - |
|
| 1936 | - public static function custom_css($compatibility = true) { |
|
| 1937 | - $colors = array(); |
|
| 1938 | - if ( defined( 'BLOCKSTRAP_VERSION' ) ) { |
|
| 1939 | - |
|
| 1940 | - $setting = wp_get_global_settings(); |
|
| 1941 | - if(!empty($setting['color']['palette']['theme'])){ |
|
| 1942 | - foreach($setting['color']['palette']['theme'] as $color){ |
|
| 1943 | - $colors[$color['slug']] = esc_attr($color['color']); |
|
| 1944 | - } |
|
| 1945 | - } |
|
| 1929 | + return str_replace( array( |
|
| 1930 | + '<style>', |
|
| 1931 | + '</style>' |
|
| 1932 | + ), '', self::minify_css( ob_get_clean() ) ); |
|
| 1933 | + } |
|
| 1946 | 1934 | |
| 1947 | - if(!empty($setting['color']['palette']['custom'])){ |
|
| 1948 | - foreach($setting['color']['palette']['custom'] as $color){ |
|
| 1949 | - $colors[$color['slug']] = esc_attr($color['color']); |
|
| 1950 | - } |
|
| 1951 | - } |
|
| 1952 | - }else{ |
|
| 1953 | - $settings = get_option('aui_options'); |
|
| 1954 | - $colors = array( |
|
| 1955 | - 'primary' => ! empty( $settings['color_primary'] ) ? $settings['color_primary'] : AUI_PRIMARY_COLOR, |
|
| 1956 | - 'secondary' => ! empty( $settings['color_secondary'] ) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR |
|
| 1957 | - ); |
|
| 1958 | - } |
|
| 1959 | 1935 | |
| 1960 | - ob_start(); |
|
| 1936 | + public static function custom_css($compatibility = true) { |
|
| 1937 | + $colors = array(); |
|
| 1938 | + if ( defined( 'BLOCKSTRAP_VERSION' ) ) { |
|
| 1939 | + |
|
| 1940 | + $setting = wp_get_global_settings(); |
|
| 1941 | + if(!empty($setting['color']['palette']['theme'])){ |
|
| 1942 | + foreach($setting['color']['palette']['theme'] as $color){ |
|
| 1943 | + $colors[$color['slug']] = esc_attr($color['color']); |
|
| 1944 | + } |
|
| 1945 | + } |
|
| 1946 | + |
|
| 1947 | + if(!empty($setting['color']['palette']['custom'])){ |
|
| 1948 | + foreach($setting['color']['palette']['custom'] as $color){ |
|
| 1949 | + $colors[$color['slug']] = esc_attr($color['color']); |
|
| 1950 | + } |
|
| 1951 | + } |
|
| 1952 | + }else{ |
|
| 1953 | + $settings = get_option('aui_options'); |
|
| 1954 | + $colors = array( |
|
| 1955 | + 'primary' => ! empty( $settings['color_primary'] ) ? $settings['color_primary'] : AUI_PRIMARY_COLOR, |
|
| 1956 | + 'secondary' => ! empty( $settings['color_secondary'] ) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR |
|
| 1957 | + ); |
|
| 1958 | + } |
|
| 1961 | 1959 | |
| 1962 | - ?> |
|
| 1960 | + ob_start(); |
|
| 1961 | + |
|
| 1962 | + ?> |
|
| 1963 | 1963 | <style> |
| 1964 | 1964 | <?php |
| 1965 | 1965 | |
| 1966 | - // BS v3 compat |
|
| 1967 | - if( self::is_bs3_compat() ){ |
|
| 1968 | - echo self::bs3_compat_css(); |
|
| 1969 | - } |
|
| 1966 | + // BS v3 compat |
|
| 1967 | + if( self::is_bs3_compat() ){ |
|
| 1968 | + echo self::bs3_compat_css(); |
|
| 1969 | + } |
|
| 1970 | 1970 | |
| 1971 | - if(!empty($colors)){ |
|
| 1972 | - $d_colors = self::get_colors(true); |
|
| 1973 | - //print_r($d_colors );exit; |
|
| 1971 | + if(!empty($colors)){ |
|
| 1972 | + $d_colors = self::get_colors(true); |
|
| 1973 | + //print_r($d_colors );exit; |
|
| 1974 | 1974 | // print_r($colors );exit; |
| 1975 | - $is_fse = !empty($_REQUEST['postType']) && $_REQUEST['postType']=='wp_template'; |
|
| 1976 | - foreach($colors as $key => $color ){ |
|
| 1977 | - if((empty( $d_colors[$key]) || $d_colors[$key] != $color) || $is_fse ) { |
|
| 1978 | - $var = $is_fse ? "var(--wp--preset--color--$key)" : $color; |
|
| 1979 | - $compat = $is_fse ? '.editor-styles-wrapper' : $compatibility; |
|
| 1980 | - echo self::css_overwrite($key,$var,$compat); |
|
| 1981 | - } |
|
| 1982 | - } |
|
| 1983 | - // exit; |
|
| 1984 | - } |
|
| 1975 | + $is_fse = !empty($_REQUEST['postType']) && $_REQUEST['postType']=='wp_template'; |
|
| 1976 | + foreach($colors as $key => $color ){ |
|
| 1977 | + if((empty( $d_colors[$key]) || $d_colors[$key] != $color) || $is_fse ) { |
|
| 1978 | + $var = $is_fse ? "var(--wp--preset--color--$key)" : $color; |
|
| 1979 | + $compat = $is_fse ? '.editor-styles-wrapper' : $compatibility; |
|
| 1980 | + echo self::css_overwrite($key,$var,$compat); |
|
| 1981 | + } |
|
| 1982 | + } |
|
| 1983 | + // exit; |
|
| 1984 | + } |
|
| 1985 | 1985 | |
| 1986 | - // Set admin bar z-index lower when modal is open. |
|
| 1987 | - echo ' body.modal-open #wpadminbar{z-index:999}.embed-responsive-16by9 .fluid-width-video-wrapper{padding:0 !important;position:initial}'; |
|
| 1986 | + // Set admin bar z-index lower when modal is open. |
|
| 1987 | + echo ' body.modal-open #wpadminbar{z-index:999}.embed-responsive-16by9 .fluid-width-video-wrapper{padding:0 !important;position:initial}'; |
|
| 1988 | 1988 | |
| 1989 | - if(is_admin()){ |
|
| 1990 | - echo ' body.modal-open #adminmenuwrap{z-index:999} body.modal-open #wpadminbar{z-index:1025}'; |
|
| 1991 | - } |
|
| 1992 | - ?> |
|
| 1989 | + if(is_admin()){ |
|
| 1990 | + echo ' body.modal-open #adminmenuwrap{z-index:999} body.modal-open #wpadminbar{z-index:1025}'; |
|
| 1991 | + } |
|
| 1992 | + ?> |
|
| 1993 | 1993 | </style> |
| 1994 | 1994 | <?php |
| 1995 | 1995 | |
| 1996 | 1996 | |
| 1997 | - /* |
|
| 1997 | + /* |
|
| 1998 | 1998 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1999 | 1999 | */ |
| 2000 | - return str_replace( array( |
|
| 2001 | - '<style>', |
|
| 2002 | - '</style>' |
|
| 2003 | - ), '', self::minify_css( ob_get_clean() ) ); |
|
| 2004 | - } |
|
| 2005 | - |
|
| 2006 | - |
|
| 2007 | - |
|
| 2008 | - /** |
|
| 2009 | - * Check if we should add booststrap 3 compatibility changes. |
|
| 2010 | - * |
|
| 2011 | - * @return bool |
|
| 2012 | - */ |
|
| 2013 | - public static function is_bs3_compat(){ |
|
| 2014 | - return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
|
| 2015 | - } |
|
| 2016 | - |
|
| 2017 | - /** |
|
| 2018 | - * Build the CSS to overwrite a bootstrap color variable. |
|
| 2019 | - * |
|
| 2020 | - * @param $type |
|
| 2021 | - * @param $color_code |
|
| 2022 | - * @param $compatibility |
|
| 2023 | - * |
|
| 2024 | - * @return string |
|
| 2025 | - */ |
|
| 2026 | - public static function css_overwrite($type,$color_code,$compatibility){ |
|
| 2027 | - |
|
| 2028 | - $is_var = false; |
|
| 2029 | - if(!$color_code){return '';} |
|
| 2030 | - if(!sanitize_hex_color($color_code)){ |
|
| 2031 | - $color_code = esc_attr($color_code); |
|
| 2032 | - $is_var = true; |
|
| 2000 | + return str_replace( array( |
|
| 2001 | + '<style>', |
|
| 2002 | + '</style>' |
|
| 2003 | + ), '', self::minify_css( ob_get_clean() ) ); |
|
| 2004 | + } |
|
| 2005 | + |
|
| 2006 | + |
|
| 2007 | + |
|
| 2008 | + /** |
|
| 2009 | + * Check if we should add booststrap 3 compatibility changes. |
|
| 2010 | + * |
|
| 2011 | + * @return bool |
|
| 2012 | + */ |
|
| 2013 | + public static function is_bs3_compat(){ |
|
| 2014 | + return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
|
| 2015 | + } |
|
| 2016 | + |
|
| 2017 | + /** |
|
| 2018 | + * Build the CSS to overwrite a bootstrap color variable. |
|
| 2019 | + * |
|
| 2020 | + * @param $type |
|
| 2021 | + * @param $color_code |
|
| 2022 | + * @param $compatibility |
|
| 2023 | + * |
|
| 2024 | + * @return string |
|
| 2025 | + */ |
|
| 2026 | + public static function css_overwrite($type,$color_code,$compatibility){ |
|
| 2027 | + |
|
| 2028 | + $is_var = false; |
|
| 2029 | + if(!$color_code){return '';} |
|
| 2030 | + if(!sanitize_hex_color($color_code)){ |
|
| 2031 | + $color_code = esc_attr($color_code); |
|
| 2032 | + $is_var = true; |
|
| 2033 | 2033 | // echo '###1'.$color_code;//exit; |
| 2034 | - } |
|
| 2035 | - if(!$color_code){return '';} |
|
| 2034 | + } |
|
| 2035 | + if(!$color_code){return '';} |
|
| 2036 | 2036 | |
| 2037 | - if($compatibility===true || $compatibility===1){ |
|
| 2038 | - $compatibility = '.bsui'; |
|
| 2039 | - }elseif(!$compatibility){ |
|
| 2040 | - $compatibility = ''; |
|
| 2041 | - }else{ |
|
| 2042 | - $compatibility = esc_attr($compatibility); |
|
| 2043 | - } |
|
| 2037 | + if($compatibility===true || $compatibility===1){ |
|
| 2038 | + $compatibility = '.bsui'; |
|
| 2039 | + }elseif(!$compatibility){ |
|
| 2040 | + $compatibility = ''; |
|
| 2041 | + }else{ |
|
| 2042 | + $compatibility = esc_attr($compatibility); |
|
| 2043 | + } |
|
| 2044 | 2044 | |
| 2045 | 2045 | // echo '####'.$color_code;exit; |
| 2046 | 2046 | |
| 2047 | - $type = sanitize_html_class($type); |
|
| 2048 | - |
|
| 2049 | - /** |
|
| 2050 | - * c = color, b = background color, o = border-color, f = fill |
|
| 2051 | - */ |
|
| 2052 | - $selectors = array( |
|
| 2053 | - ".btn-{$type}" => array( 'b', 'o' ), |
|
| 2054 | - ".btn-{$type}.disabled" => array( 'b', 'o' ), |
|
| 2055 | - ".btn-{$type}:disabled" => array( 'b', 'o' ), |
|
| 2056 | - ".btn-outline-{$type}" => array( 'c', 'o' ), |
|
| 2057 | - ".btn-outline-{$type}:hover" => array( 'b', 'o' ), |
|
| 2058 | - ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ), |
|
| 2059 | - ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ), |
|
| 2060 | - ".show>.btn-outline-{$type}.dropdown-toggle" => array( 'b', 'o' ), |
|
| 2061 | - ".badge-{$type}" => array( 'b' ), |
|
| 2062 | - ".alert-{$type}" => array( 'b', 'o' ), |
|
| 2063 | - ".bg-{$type}" => array( 'b', 'f' ), |
|
| 2064 | - ".btn-link.btn-{$type}" => array( 'c' ), |
|
| 2065 | - ); |
|
| 2066 | - |
|
| 2067 | - if ( $type == 'primary' ) { |
|
| 2068 | - $selectors = $selectors + array( |
|
| 2069 | - 'a' => array( 'c' ), |
|
| 2070 | - '.btn-link' => array( 'c' ), |
|
| 2071 | - '.dropdown-item.active' => array( 'b' ), |
|
| 2072 | - '.custom-control-input:checked~.custom-control-label::before' => array( |
|
| 2073 | - 'b', |
|
| 2074 | - 'o' |
|
| 2075 | - ), |
|
| 2076 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array( |
|
| 2077 | - 'b', |
|
| 2078 | - 'o' |
|
| 2079 | - ), |
|
| 2080 | - '.nav-pills .nav-link.active' => array( 'b' ), |
|
| 2081 | - '.nav-pills .show>.nav-link' => array( 'b' ), |
|
| 2082 | - '.page-link' => array( 'c' ), |
|
| 2083 | - '.page-item.active .page-link' => array( |
|
| 2084 | - 'b', |
|
| 2085 | - 'o' |
|
| 2086 | - ), |
|
| 2087 | - '.progress-bar' => array( 'b' ), |
|
| 2088 | - '.list-group-item.active' => array( |
|
| 2089 | - 'b', |
|
| 2090 | - 'o' |
|
| 2091 | - ), |
|
| 2092 | - '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ), |
|
| 2047 | + $type = sanitize_html_class($type); |
|
| 2048 | + |
|
| 2049 | + /** |
|
| 2050 | + * c = color, b = background color, o = border-color, f = fill |
|
| 2051 | + */ |
|
| 2052 | + $selectors = array( |
|
| 2053 | + ".btn-{$type}" => array( 'b', 'o' ), |
|
| 2054 | + ".btn-{$type}.disabled" => array( 'b', 'o' ), |
|
| 2055 | + ".btn-{$type}:disabled" => array( 'b', 'o' ), |
|
| 2056 | + ".btn-outline-{$type}" => array( 'c', 'o' ), |
|
| 2057 | + ".btn-outline-{$type}:hover" => array( 'b', 'o' ), |
|
| 2058 | + ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ), |
|
| 2059 | + ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ), |
|
| 2060 | + ".show>.btn-outline-{$type}.dropdown-toggle" => array( 'b', 'o' ), |
|
| 2061 | + ".badge-{$type}" => array( 'b' ), |
|
| 2062 | + ".alert-{$type}" => array( 'b', 'o' ), |
|
| 2063 | + ".bg-{$type}" => array( 'b', 'f' ), |
|
| 2064 | + ".btn-link.btn-{$type}" => array( 'c' ), |
|
| 2065 | + ); |
|
| 2066 | + |
|
| 2067 | + if ( $type == 'primary' ) { |
|
| 2068 | + $selectors = $selectors + array( |
|
| 2069 | + 'a' => array( 'c' ), |
|
| 2070 | + '.btn-link' => array( 'c' ), |
|
| 2071 | + '.dropdown-item.active' => array( 'b' ), |
|
| 2072 | + '.custom-control-input:checked~.custom-control-label::before' => array( |
|
| 2073 | + 'b', |
|
| 2074 | + 'o' |
|
| 2075 | + ), |
|
| 2076 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array( |
|
| 2077 | + 'b', |
|
| 2078 | + 'o' |
|
| 2079 | + ), |
|
| 2080 | + '.nav-pills .nav-link.active' => array( 'b' ), |
|
| 2081 | + '.nav-pills .show>.nav-link' => array( 'b' ), |
|
| 2082 | + '.page-link' => array( 'c' ), |
|
| 2083 | + '.page-item.active .page-link' => array( |
|
| 2084 | + 'b', |
|
| 2085 | + 'o' |
|
| 2086 | + ), |
|
| 2087 | + '.progress-bar' => array( 'b' ), |
|
| 2088 | + '.list-group-item.active' => array( |
|
| 2089 | + 'b', |
|
| 2090 | + 'o' |
|
| 2091 | + ), |
|
| 2092 | + '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ), |
|
| 2093 | 2093 | // '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
| 2094 | 2094 | // '.custom-range::-moz-range-thumb' => array('b'), |
| 2095 | 2095 | // '.custom-range::-ms-thumb' => array('b'), |
| 2096 | - ); |
|
| 2097 | - } |
|
| 2098 | - |
|
| 2099 | - $important_selectors = array( |
|
| 2100 | - ".bg-{$type}" => array('b','f'), |
|
| 2101 | - ".border-{$type}" => array('o'), |
|
| 2102 | - ".text-{$type}" => array('c'), |
|
| 2103 | - ); |
|
| 2104 | - |
|
| 2105 | - $color = array(); |
|
| 2106 | - $color_i = array(); |
|
| 2107 | - $background = array(); |
|
| 2108 | - $background_i = array(); |
|
| 2109 | - $border = array(); |
|
| 2110 | - $border_i = array(); |
|
| 2111 | - $fill = array(); |
|
| 2112 | - $fill_i = array(); |
|
| 2113 | - |
|
| 2114 | - $output = ''; |
|
| 2115 | - |
|
| 2116 | - // build rules into each type |
|
| 2117 | - foreach($selectors as $selector => $types){ |
|
| 2118 | - $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
| 2119 | - $types = array_combine($types,$types); |
|
| 2120 | - if(isset($types['c'])){$color[] = $selector;} |
|
| 2121 | - if(isset($types['b'])){$background[] = $selector;} |
|
| 2122 | - if(isset($types['o'])){$border[] = $selector;} |
|
| 2123 | - if(isset($types['f'])){$fill[] = $selector;} |
|
| 2124 | - } |
|
| 2125 | - |
|
| 2126 | - // build rules into each type |
|
| 2127 | - foreach($important_selectors as $selector => $types){ |
|
| 2128 | - $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
| 2129 | - $types = array_combine($types,$types); |
|
| 2130 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
| 2131 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
| 2132 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
| 2133 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 2134 | - } |
|
| 2135 | - |
|
| 2136 | - // add any color rules |
|
| 2137 | - if(!empty($color)){ |
|
| 2138 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 2139 | - } |
|
| 2140 | - if(!empty($color_i)){ |
|
| 2141 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 2142 | - } |
|
| 2143 | - |
|
| 2144 | - // add any background color rules |
|
| 2145 | - if(!empty($background)){ |
|
| 2146 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 2147 | - } |
|
| 2148 | - if(!empty($background_i)){ |
|
| 2149 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 2150 | - } |
|
| 2151 | - |
|
| 2152 | - // add any border color rules |
|
| 2153 | - if(!empty($border)){ |
|
| 2154 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 2155 | - } |
|
| 2156 | - if(!empty($border_i)){ |
|
| 2157 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 2158 | - } |
|
| 2159 | - |
|
| 2160 | - // add any fill color rules |
|
| 2161 | - if(!empty($fill)){ |
|
| 2162 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 2163 | - } |
|
| 2164 | - if(!empty($fill_i)){ |
|
| 2165 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 2166 | - } |
|
| 2167 | - |
|
| 2168 | - |
|
| 2169 | - $prefix = $compatibility ? $compatibility . " " : ""; |
|
| 2170 | - |
|
| 2171 | - $transition = $is_var ? 'transition: color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out,filter 0.15s ease-in-out;' : ''; |
|
| 2172 | - // darken |
|
| 2173 | - $darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 2174 | - $darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 2175 | - $darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 2176 | - |
|
| 2177 | - // lighten |
|
| 2178 | - $lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 2179 | - |
|
| 2180 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 2181 | - $op_25 = $color_code."40"; // 25% opacity |
|
| 2182 | - |
|
| 2183 | - |
|
| 2184 | - // button states |
|
| 2185 | - $output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : ''; |
|
| 2186 | - $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 2096 | + ); |
|
| 2097 | + } |
|
| 2098 | + |
|
| 2099 | + $important_selectors = array( |
|
| 2100 | + ".bg-{$type}" => array('b','f'), |
|
| 2101 | + ".border-{$type}" => array('o'), |
|
| 2102 | + ".text-{$type}" => array('c'), |
|
| 2103 | + ); |
|
| 2104 | + |
|
| 2105 | + $color = array(); |
|
| 2106 | + $color_i = array(); |
|
| 2107 | + $background = array(); |
|
| 2108 | + $background_i = array(); |
|
| 2109 | + $border = array(); |
|
| 2110 | + $border_i = array(); |
|
| 2111 | + $fill = array(); |
|
| 2112 | + $fill_i = array(); |
|
| 2113 | + |
|
| 2114 | + $output = ''; |
|
| 2115 | + |
|
| 2116 | + // build rules into each type |
|
| 2117 | + foreach($selectors as $selector => $types){ |
|
| 2118 | + $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
| 2119 | + $types = array_combine($types,$types); |
|
| 2120 | + if(isset($types['c'])){$color[] = $selector;} |
|
| 2121 | + if(isset($types['b'])){$background[] = $selector;} |
|
| 2122 | + if(isset($types['o'])){$border[] = $selector;} |
|
| 2123 | + if(isset($types['f'])){$fill[] = $selector;} |
|
| 2124 | + } |
|
| 2125 | + |
|
| 2126 | + // build rules into each type |
|
| 2127 | + foreach($important_selectors as $selector => $types){ |
|
| 2128 | + $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
| 2129 | + $types = array_combine($types,$types); |
|
| 2130 | + if(isset($types['c'])){$color_i[] = $selector;} |
|
| 2131 | + if(isset($types['b'])){$background_i[] = $selector;} |
|
| 2132 | + if(isset($types['o'])){$border_i[] = $selector;} |
|
| 2133 | + if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 2134 | + } |
|
| 2135 | + |
|
| 2136 | + // add any color rules |
|
| 2137 | + if(!empty($color)){ |
|
| 2138 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 2139 | + } |
|
| 2140 | + if(!empty($color_i)){ |
|
| 2141 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 2142 | + } |
|
| 2143 | + |
|
| 2144 | + // add any background color rules |
|
| 2145 | + if(!empty($background)){ |
|
| 2146 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 2147 | + } |
|
| 2148 | + if(!empty($background_i)){ |
|
| 2149 | + $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 2150 | + } |
|
| 2151 | + |
|
| 2152 | + // add any border color rules |
|
| 2153 | + if(!empty($border)){ |
|
| 2154 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 2155 | + } |
|
| 2156 | + if(!empty($border_i)){ |
|
| 2157 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 2158 | + } |
|
| 2159 | + |
|
| 2160 | + // add any fill color rules |
|
| 2161 | + if(!empty($fill)){ |
|
| 2162 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 2163 | + } |
|
| 2164 | + if(!empty($fill_i)){ |
|
| 2165 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 2166 | + } |
|
| 2167 | + |
|
| 2168 | + |
|
| 2169 | + $prefix = $compatibility ? $compatibility . " " : ""; |
|
| 2170 | + |
|
| 2171 | + $transition = $is_var ? 'transition: color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out,filter 0.15s ease-in-out;' : ''; |
|
| 2172 | + // darken |
|
| 2173 | + $darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 2174 | + $darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 2175 | + $darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 2176 | + |
|
| 2177 | + // lighten |
|
| 2178 | + $lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 2179 | + |
|
| 2180 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 2181 | + $op_25 = $color_code."40"; // 25% opacity |
|
| 2182 | + |
|
| 2183 | + |
|
| 2184 | + // button states |
|
| 2185 | + $output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : ''; |
|
| 2186 | + $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 2187 | 2187 | // $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: #000; border-color: #000;} "; |
| 2188 | - $output .= $prefix ." .btn-outline-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-{$type}.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2189 | - $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active, $prefix .btn-{$type}:not(:disabled):not(.disabled).active, .show>$prefix .btn-{$type}.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 2190 | - $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-{$type}.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2191 | - |
|
| 2192 | - if ( $type == 'primary' ) { |
|
| 2193 | - // dropdown's |
|
| 2194 | - $output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
| 2195 | - |
|
| 2196 | - // input states |
|
| 2197 | - $output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2198 | - |
|
| 2199 | - // page link |
|
| 2200 | - $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2201 | - } |
|
| 2202 | - |
|
| 2203 | - return $output; |
|
| 2204 | - } |
|
| 2205 | - |
|
| 2206 | - /** |
|
| 2207 | - * |
|
| 2208 | - * @deprecated 0.1.76 Use css_overwrite() |
|
| 2209 | - * |
|
| 2210 | - * @param $color_code |
|
| 2211 | - * @param $compatibility |
|
| 2212 | - * @param $use_variable |
|
| 2213 | - * |
|
| 2214 | - * @return string |
|
| 2215 | - */ |
|
| 2216 | - public static function css_primary($color_code,$compatibility, $use_variable = false){ |
|
| 2217 | - |
|
| 2218 | - if(!$use_variable){ |
|
| 2219 | - $color_code = sanitize_hex_color($color_code); |
|
| 2220 | - if(!$color_code){return '';} |
|
| 2221 | - } |
|
| 2222 | - |
|
| 2223 | - /** |
|
| 2224 | - * c = color, b = background color, o = border-color, f = fill |
|
| 2225 | - */ |
|
| 2226 | - $selectors = array( |
|
| 2227 | - 'a' => array('c'), |
|
| 2228 | - '.btn-primary' => array('b','o'), |
|
| 2229 | - '.btn-primary.disabled' => array('b','o'), |
|
| 2230 | - '.btn-primary:disabled' => array('b','o'), |
|
| 2231 | - '.btn-outline-primary' => array('c','o'), |
|
| 2232 | - '.btn-outline-primary:hover' => array('b','o'), |
|
| 2233 | - '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 2234 | - '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 2235 | - '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
| 2236 | - '.btn-link' => array('c'), |
|
| 2237 | - '.dropdown-item.active' => array('b'), |
|
| 2238 | - '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
| 2239 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
| 2188 | + $output .= $prefix ." .btn-outline-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-{$type}.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2189 | + $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active, $prefix .btn-{$type}:not(:disabled):not(.disabled).active, .show>$prefix .btn-{$type}.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 2190 | + $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-{$type}.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2191 | + |
|
| 2192 | + if ( $type == 'primary' ) { |
|
| 2193 | + // dropdown's |
|
| 2194 | + $output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
| 2195 | + |
|
| 2196 | + // input states |
|
| 2197 | + $output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2198 | + |
|
| 2199 | + // page link |
|
| 2200 | + $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2201 | + } |
|
| 2202 | + |
|
| 2203 | + return $output; |
|
| 2204 | + } |
|
| 2205 | + |
|
| 2206 | + /** |
|
| 2207 | + * |
|
| 2208 | + * @deprecated 0.1.76 Use css_overwrite() |
|
| 2209 | + * |
|
| 2210 | + * @param $color_code |
|
| 2211 | + * @param $compatibility |
|
| 2212 | + * @param $use_variable |
|
| 2213 | + * |
|
| 2214 | + * @return string |
|
| 2215 | + */ |
|
| 2216 | + public static function css_primary($color_code,$compatibility, $use_variable = false){ |
|
| 2217 | + |
|
| 2218 | + if(!$use_variable){ |
|
| 2219 | + $color_code = sanitize_hex_color($color_code); |
|
| 2220 | + if(!$color_code){return '';} |
|
| 2221 | + } |
|
| 2222 | + |
|
| 2223 | + /** |
|
| 2224 | + * c = color, b = background color, o = border-color, f = fill |
|
| 2225 | + */ |
|
| 2226 | + $selectors = array( |
|
| 2227 | + 'a' => array('c'), |
|
| 2228 | + '.btn-primary' => array('b','o'), |
|
| 2229 | + '.btn-primary.disabled' => array('b','o'), |
|
| 2230 | + '.btn-primary:disabled' => array('b','o'), |
|
| 2231 | + '.btn-outline-primary' => array('c','o'), |
|
| 2232 | + '.btn-outline-primary:hover' => array('b','o'), |
|
| 2233 | + '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 2234 | + '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 2235 | + '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
| 2236 | + '.btn-link' => array('c'), |
|
| 2237 | + '.dropdown-item.active' => array('b'), |
|
| 2238 | + '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
| 2239 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
| 2240 | 2240 | // '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
| 2241 | 2241 | // '.custom-range::-moz-range-thumb' => array('b'), |
| 2242 | 2242 | // '.custom-range::-ms-thumb' => array('b'), |
| 2243 | - '.nav-pills .nav-link.active' => array('b'), |
|
| 2244 | - '.nav-pills .show>.nav-link' => array('b'), |
|
| 2245 | - '.page-link' => array('c'), |
|
| 2246 | - '.page-item.active .page-link' => array('b','o'), |
|
| 2247 | - '.badge-primary' => array('b'), |
|
| 2248 | - '.alert-primary' => array('b','o'), |
|
| 2249 | - '.progress-bar' => array('b'), |
|
| 2250 | - '.list-group-item.active' => array('b','o'), |
|
| 2251 | - '.bg-primary' => array('b','f'), |
|
| 2252 | - '.btn-link.btn-primary' => array('c'), |
|
| 2253 | - '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
|
| 2254 | - ); |
|
| 2255 | - |
|
| 2256 | - $important_selectors = array( |
|
| 2257 | - '.bg-primary' => array('b','f'), |
|
| 2258 | - '.border-primary' => array('o'), |
|
| 2259 | - '.text-primary' => array('c'), |
|
| 2260 | - ); |
|
| 2261 | - |
|
| 2262 | - $color = array(); |
|
| 2263 | - $color_i = array(); |
|
| 2264 | - $background = array(); |
|
| 2265 | - $background_i = array(); |
|
| 2266 | - $border = array(); |
|
| 2267 | - $border_i = array(); |
|
| 2268 | - $fill = array(); |
|
| 2269 | - $fill_i = array(); |
|
| 2270 | - |
|
| 2271 | - $output = ''; |
|
| 2272 | - |
|
| 2273 | - // build rules into each type |
|
| 2274 | - foreach($selectors as $selector => $types){ |
|
| 2275 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 2276 | - $types = array_combine($types,$types); |
|
| 2277 | - if(isset($types['c'])){$color[] = $selector;} |
|
| 2278 | - if(isset($types['b'])){$background[] = $selector;} |
|
| 2279 | - if(isset($types['o'])){$border[] = $selector;} |
|
| 2280 | - if(isset($types['f'])){$fill[] = $selector;} |
|
| 2281 | - } |
|
| 2282 | - |
|
| 2283 | - // build rules into each type |
|
| 2284 | - foreach($important_selectors as $selector => $types){ |
|
| 2285 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 2286 | - $types = array_combine($types,$types); |
|
| 2287 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
| 2288 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
| 2289 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
| 2290 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 2291 | - } |
|
| 2292 | - |
|
| 2293 | - // add any color rules |
|
| 2294 | - if(!empty($color)){ |
|
| 2295 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 2296 | - } |
|
| 2297 | - if(!empty($color_i)){ |
|
| 2298 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 2299 | - } |
|
| 2300 | - |
|
| 2301 | - // add any background color rules |
|
| 2302 | - if(!empty($background)){ |
|
| 2303 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 2304 | - } |
|
| 2305 | - if(!empty($background_i)){ |
|
| 2306 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 2307 | - } |
|
| 2308 | - |
|
| 2309 | - // add any border color rules |
|
| 2310 | - if(!empty($border)){ |
|
| 2311 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 2312 | - } |
|
| 2313 | - if(!empty($border_i)){ |
|
| 2314 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 2315 | - } |
|
| 2316 | - |
|
| 2317 | - // add any fill color rules |
|
| 2318 | - if(!empty($fill)){ |
|
| 2319 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 2320 | - } |
|
| 2321 | - if(!empty($fill_i)){ |
|
| 2322 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 2323 | - } |
|
| 2324 | - |
|
| 2325 | - |
|
| 2326 | - $prefix = $compatibility ? ".bsui " : ""; |
|
| 2327 | - |
|
| 2328 | - // darken |
|
| 2329 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 2330 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 2331 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 2332 | - |
|
| 2333 | - // lighten |
|
| 2334 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 2335 | - |
|
| 2336 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 2337 | - $op_25 = $color_code."40"; // 25% opacity |
|
| 2338 | - |
|
| 2339 | - |
|
| 2340 | - // button states |
|
| 2341 | - $output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 2342 | - $output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2343 | - $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 2344 | - $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2345 | - |
|
| 2346 | - |
|
| 2347 | - // dropdown's |
|
| 2348 | - $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
| 2349 | - |
|
| 2350 | - |
|
| 2351 | - // input states |
|
| 2352 | - $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2353 | - |
|
| 2354 | - // page link |
|
| 2355 | - $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2356 | - |
|
| 2357 | - return $output; |
|
| 2358 | - } |
|
| 2359 | - |
|
| 2360 | - /** |
|
| 2361 | - * |
|
| 2362 | - * @deprecated 0.1.76 Use css_overwrite() |
|
| 2363 | - * |
|
| 2364 | - * @param $color_code |
|
| 2365 | - * @param $compatibility |
|
| 2366 | - * |
|
| 2367 | - * @return string |
|
| 2368 | - */ |
|
| 2369 | - public static function css_secondary($color_code,$compatibility){; |
|
| 2370 | - $color_code = sanitize_hex_color($color_code); |
|
| 2371 | - if(!$color_code){return '';} |
|
| 2372 | - /** |
|
| 2373 | - * c = color, b = background color, o = border-color, f = fill |
|
| 2374 | - */ |
|
| 2375 | - $selectors = array( |
|
| 2376 | - '.btn-secondary' => array('b','o'), |
|
| 2377 | - '.btn-secondary.disabled' => array('b','o'), |
|
| 2378 | - '.btn-secondary:disabled' => array('b','o'), |
|
| 2379 | - '.btn-outline-secondary' => array('c','o'), |
|
| 2380 | - '.btn-outline-secondary:hover' => array('b','o'), |
|
| 2381 | - '.btn-outline-secondary.disabled' => array('c'), |
|
| 2382 | - '.btn-outline-secondary:disabled' => array('c'), |
|
| 2383 | - '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 2384 | - '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 2385 | - '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
| 2386 | - '.badge-secondary' => array('b'), |
|
| 2387 | - '.alert-secondary' => array('b','o'), |
|
| 2388 | - '.btn-link.btn-secondary' => array('c'), |
|
| 2389 | - ); |
|
| 2390 | - |
|
| 2391 | - $important_selectors = array( |
|
| 2392 | - '.bg-secondary' => array('b','f'), |
|
| 2393 | - '.border-secondary' => array('o'), |
|
| 2394 | - '.text-secondary' => array('c'), |
|
| 2395 | - ); |
|
| 2396 | - |
|
| 2397 | - $color = array(); |
|
| 2398 | - $color_i = array(); |
|
| 2399 | - $background = array(); |
|
| 2400 | - $background_i = array(); |
|
| 2401 | - $border = array(); |
|
| 2402 | - $border_i = array(); |
|
| 2403 | - $fill = array(); |
|
| 2404 | - $fill_i = array(); |
|
| 2405 | - |
|
| 2406 | - $output = ''; |
|
| 2407 | - |
|
| 2408 | - // build rules into each type |
|
| 2409 | - foreach($selectors as $selector => $types){ |
|
| 2410 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 2411 | - $types = array_combine($types,$types); |
|
| 2412 | - if(isset($types['c'])){$color[] = $selector;} |
|
| 2413 | - if(isset($types['b'])){$background[] = $selector;} |
|
| 2414 | - if(isset($types['o'])){$border[] = $selector;} |
|
| 2415 | - if(isset($types['f'])){$fill[] = $selector;} |
|
| 2416 | - } |
|
| 2417 | - |
|
| 2418 | - // build rules into each type |
|
| 2419 | - foreach($important_selectors as $selector => $types){ |
|
| 2420 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 2421 | - $types = array_combine($types,$types); |
|
| 2422 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
| 2423 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
| 2424 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
| 2425 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 2426 | - } |
|
| 2427 | - |
|
| 2428 | - // add any color rules |
|
| 2429 | - if(!empty($color)){ |
|
| 2430 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 2431 | - } |
|
| 2432 | - if(!empty($color_i)){ |
|
| 2433 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 2434 | - } |
|
| 2435 | - |
|
| 2436 | - // add any background color rules |
|
| 2437 | - if(!empty($background)){ |
|
| 2438 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 2439 | - } |
|
| 2440 | - if(!empty($background_i)){ |
|
| 2441 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 2442 | - } |
|
| 2443 | - |
|
| 2444 | - // add any border color rules |
|
| 2445 | - if(!empty($border)){ |
|
| 2446 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 2447 | - } |
|
| 2448 | - if(!empty($border_i)){ |
|
| 2449 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 2450 | - } |
|
| 2451 | - |
|
| 2452 | - // add any fill color rules |
|
| 2453 | - if(!empty($fill)){ |
|
| 2454 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 2455 | - } |
|
| 2456 | - if(!empty($fill_i)){ |
|
| 2457 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 2458 | - } |
|
| 2459 | - |
|
| 2460 | - |
|
| 2461 | - $prefix = $compatibility ? ".bsui " : ""; |
|
| 2462 | - |
|
| 2463 | - // darken |
|
| 2464 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 2465 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 2466 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 2467 | - |
|
| 2468 | - // lighten |
|
| 2469 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 2470 | - |
|
| 2471 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 2472 | - $op_25 = $color_code."40"; // 25% opacity |
|
| 2473 | - |
|
| 2474 | - |
|
| 2475 | - // button states |
|
| 2476 | - $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 2477 | - $output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2478 | - $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 2479 | - $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2480 | - |
|
| 2481 | - |
|
| 2482 | - return $output; |
|
| 2483 | - } |
|
| 2484 | - |
|
| 2485 | - /** |
|
| 2486 | - * Increases or decreases the brightness of a color by a percentage of the current brightness. |
|
| 2487 | - * |
|
| 2488 | - * @param string $hexCode Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF` |
|
| 2489 | - * @param float $adjustPercent A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker. |
|
| 2490 | - * |
|
| 2491 | - * @return string |
|
| 2492 | - */ |
|
| 2493 | - public static function css_hex_lighten_darken($hexCode, $adjustPercent) { |
|
| 2494 | - $hexCode = ltrim($hexCode, '#'); |
|
| 2495 | - |
|
| 2496 | - if (strlen($hexCode) == 3) { |
|
| 2497 | - $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2]; |
|
| 2498 | - } |
|
| 2499 | - |
|
| 2500 | - $hexCode = array_map('hexdec', str_split($hexCode, 2)); |
|
| 2501 | - |
|
| 2502 | - foreach ($hexCode as & $color) { |
|
| 2503 | - $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color; |
|
| 2504 | - $adjustAmount = ceil($adjustableLimit * $adjustPercent); |
|
| 2505 | - |
|
| 2506 | - $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT); |
|
| 2507 | - } |
|
| 2508 | - |
|
| 2509 | - return '#' . implode($hexCode); |
|
| 2510 | - } |
|
| 2511 | - |
|
| 2512 | - /** |
|
| 2513 | - * Check if we should display examples. |
|
| 2514 | - */ |
|
| 2515 | - public function maybe_show_examples(){ |
|
| 2516 | - if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
| 2517 | - echo "<head>"; |
|
| 2518 | - wp_head(); |
|
| 2519 | - echo "</head>"; |
|
| 2520 | - echo "<body>"; |
|
| 2521 | - echo $this->get_examples(); |
|
| 2522 | - echo "</body>"; |
|
| 2523 | - exit; |
|
| 2524 | - } |
|
| 2525 | - } |
|
| 2526 | - |
|
| 2527 | - /** |
|
| 2528 | - * Get developer examples. |
|
| 2529 | - * |
|
| 2530 | - * @return string |
|
| 2531 | - */ |
|
| 2532 | - public function get_examples(){ |
|
| 2533 | - $output = ''; |
|
| 2534 | - |
|
| 2535 | - |
|
| 2536 | - // open form |
|
| 2537 | - $output .= "<form class='p-5 m-5 border rounded'>"; |
|
| 2538 | - |
|
| 2539 | - // input example |
|
| 2540 | - $output .= aui()->input(array( |
|
| 2541 | - 'type' => 'text', |
|
| 2542 | - 'id' => 'text-example', |
|
| 2543 | - 'name' => 'text-example', |
|
| 2544 | - 'placeholder' => 'text placeholder', |
|
| 2545 | - 'title' => 'Text input example', |
|
| 2546 | - 'value' => '', |
|
| 2547 | - 'required' => false, |
|
| 2548 | - 'help_text' => 'help text', |
|
| 2549 | - 'label' => 'Text input example label' |
|
| 2550 | - )); |
|
| 2551 | - |
|
| 2552 | - // input example |
|
| 2553 | - $output .= aui()->input(array( |
|
| 2554 | - 'type' => 'url', |
|
| 2555 | - 'id' => 'text-example2', |
|
| 2556 | - 'name' => 'text-example', |
|
| 2557 | - 'placeholder' => 'url placeholder', |
|
| 2558 | - 'title' => 'Text input example', |
|
| 2559 | - 'value' => '', |
|
| 2560 | - 'required' => false, |
|
| 2561 | - 'help_text' => 'help text', |
|
| 2562 | - 'label' => 'Text input example label' |
|
| 2563 | - )); |
|
| 2564 | - |
|
| 2565 | - // checkbox example |
|
| 2566 | - $output .= aui()->input(array( |
|
| 2567 | - 'type' => 'checkbox', |
|
| 2568 | - 'id' => 'checkbox-example', |
|
| 2569 | - 'name' => 'checkbox-example', |
|
| 2570 | - 'placeholder' => 'checkbox-example', |
|
| 2571 | - 'title' => 'Checkbox example', |
|
| 2572 | - 'value' => '1', |
|
| 2573 | - 'checked' => true, |
|
| 2574 | - 'required' => false, |
|
| 2575 | - 'help_text' => 'help text', |
|
| 2576 | - 'label' => 'Checkbox checked' |
|
| 2577 | - )); |
|
| 2578 | - |
|
| 2579 | - // checkbox example |
|
| 2580 | - $output .= aui()->input(array( |
|
| 2581 | - 'type' => 'checkbox', |
|
| 2582 | - 'id' => 'checkbox-example2', |
|
| 2583 | - 'name' => 'checkbox-example2', |
|
| 2584 | - 'placeholder' => 'checkbox-example', |
|
| 2585 | - 'title' => 'Checkbox example', |
|
| 2586 | - 'value' => '1', |
|
| 2587 | - 'checked' => false, |
|
| 2588 | - 'required' => false, |
|
| 2589 | - 'help_text' => 'help text', |
|
| 2590 | - 'label' => 'Checkbox un-checked' |
|
| 2591 | - )); |
|
| 2592 | - |
|
| 2593 | - // switch example |
|
| 2594 | - $output .= aui()->input(array( |
|
| 2595 | - 'type' => 'checkbox', |
|
| 2596 | - 'id' => 'switch-example', |
|
| 2597 | - 'name' => 'switch-example', |
|
| 2598 | - 'placeholder' => 'checkbox-example', |
|
| 2599 | - 'title' => 'Switch example', |
|
| 2600 | - 'value' => '1', |
|
| 2601 | - 'checked' => true, |
|
| 2602 | - 'switch' => true, |
|
| 2603 | - 'required' => false, |
|
| 2604 | - 'help_text' => 'help text', |
|
| 2605 | - 'label' => 'Switch on' |
|
| 2606 | - )); |
|
| 2607 | - |
|
| 2608 | - // switch example |
|
| 2609 | - $output .= aui()->input(array( |
|
| 2610 | - 'type' => 'checkbox', |
|
| 2611 | - 'id' => 'switch-example2', |
|
| 2612 | - 'name' => 'switch-example2', |
|
| 2613 | - 'placeholder' => 'checkbox-example', |
|
| 2614 | - 'title' => 'Switch example', |
|
| 2615 | - 'value' => '1', |
|
| 2616 | - 'checked' => false, |
|
| 2617 | - 'switch' => true, |
|
| 2618 | - 'required' => false, |
|
| 2619 | - 'help_text' => 'help text', |
|
| 2620 | - 'label' => 'Switch off' |
|
| 2621 | - )); |
|
| 2622 | - |
|
| 2623 | - // close form |
|
| 2624 | - $output .= "</form>"; |
|
| 2625 | - |
|
| 2626 | - return $output; |
|
| 2627 | - } |
|
| 2628 | - |
|
| 2629 | - /** |
|
| 2630 | - * Calendar params. |
|
| 2631 | - * |
|
| 2632 | - * @since 0.1.44 |
|
| 2633 | - * |
|
| 2634 | - * @return array Calendar params. |
|
| 2635 | - */ |
|
| 2636 | - public static function calendar_params() { |
|
| 2637 | - $params = array( |
|
| 2638 | - 'month_long_1' => __( 'January', 'aui' ), |
|
| 2639 | - 'month_long_2' => __( 'February', 'aui' ), |
|
| 2640 | - 'month_long_3' => __( 'March', 'aui' ), |
|
| 2641 | - 'month_long_4' => __( 'April', 'aui' ), |
|
| 2642 | - 'month_long_5' => __( 'May', 'aui' ), |
|
| 2643 | - 'month_long_6' => __( 'June', 'aui' ), |
|
| 2644 | - 'month_long_7' => __( 'July', 'aui' ), |
|
| 2645 | - 'month_long_8' => __( 'August', 'aui' ), |
|
| 2646 | - 'month_long_9' => __( 'September', 'aui' ), |
|
| 2647 | - 'month_long_10' => __( 'October', 'aui' ), |
|
| 2648 | - 'month_long_11' => __( 'November', 'aui' ), |
|
| 2649 | - 'month_long_12' => __( 'December', 'aui' ), |
|
| 2650 | - 'month_s_1' => _x( 'Jan', 'January abbreviation', 'aui' ), |
|
| 2651 | - 'month_s_2' => _x( 'Feb', 'February abbreviation', 'aui' ), |
|
| 2652 | - 'month_s_3' => _x( 'Mar', 'March abbreviation', 'aui' ), |
|
| 2653 | - 'month_s_4' => _x( 'Apr', 'April abbreviation', 'aui' ), |
|
| 2654 | - 'month_s_5' => _x( 'May', 'May abbreviation', 'aui' ), |
|
| 2655 | - 'month_s_6' => _x( 'Jun', 'June abbreviation', 'aui' ), |
|
| 2656 | - 'month_s_7' => _x( 'Jul', 'July abbreviation', 'aui' ), |
|
| 2657 | - 'month_s_8' => _x( 'Aug', 'August abbreviation', 'aui' ), |
|
| 2658 | - 'month_s_9' => _x( 'Sep', 'September abbreviation', 'aui' ), |
|
| 2659 | - 'month_s_10' => _x( 'Oct', 'October abbreviation', 'aui' ), |
|
| 2660 | - 'month_s_11' => _x( 'Nov', 'November abbreviation', 'aui' ), |
|
| 2661 | - 'month_s_12' => _x( 'Dec', 'December abbreviation', 'aui' ), |
|
| 2662 | - 'day_s1_1' => _x( 'S', 'Sunday initial', 'aui' ), |
|
| 2663 | - 'day_s1_2' => _x( 'M', 'Monday initial', 'aui' ), |
|
| 2664 | - 'day_s1_3' => _x( 'T', 'Tuesday initial', 'aui' ), |
|
| 2665 | - 'day_s1_4' => _x( 'W', 'Wednesday initial', 'aui' ), |
|
| 2666 | - 'day_s1_5' => _x( 'T', 'Friday initial', 'aui' ), |
|
| 2667 | - 'day_s1_6' => _x( 'F', 'Thursday initial', 'aui' ), |
|
| 2668 | - 'day_s1_7' => _x( 'S', 'Saturday initial', 'aui' ), |
|
| 2669 | - 'day_s2_1' => __( 'Su', 'aui' ), |
|
| 2670 | - 'day_s2_2' => __( 'Mo', 'aui' ), |
|
| 2671 | - 'day_s2_3' => __( 'Tu', 'aui' ), |
|
| 2672 | - 'day_s2_4' => __( 'We', 'aui' ), |
|
| 2673 | - 'day_s2_5' => __( 'Th', 'aui' ), |
|
| 2674 | - 'day_s2_6' => __( 'Fr', 'aui' ), |
|
| 2675 | - 'day_s2_7' => __( 'Sa', 'aui' ), |
|
| 2676 | - 'day_s3_1' => __( 'Sun', 'aui' ), |
|
| 2677 | - 'day_s3_2' => __( 'Mon', 'aui' ), |
|
| 2678 | - 'day_s3_3' => __( 'Tue', 'aui' ), |
|
| 2679 | - 'day_s3_4' => __( 'Wed', 'aui' ), |
|
| 2680 | - 'day_s3_5' => __( 'Thu', 'aui' ), |
|
| 2681 | - 'day_s3_6' => __( 'Fri', 'aui' ), |
|
| 2682 | - 'day_s3_7' => __( 'Sat', 'aui' ), |
|
| 2683 | - 'day_s5_1' => __( 'Sunday', 'aui' ), |
|
| 2684 | - 'day_s5_2' => __( 'Monday', 'aui' ), |
|
| 2685 | - 'day_s5_3' => __( 'Tuesday', 'aui' ), |
|
| 2686 | - 'day_s5_4' => __( 'Wednesday', 'aui' ), |
|
| 2687 | - 'day_s5_5' => __( 'Thursday', 'aui' ), |
|
| 2688 | - 'day_s5_6' => __( 'Friday', 'aui' ), |
|
| 2689 | - 'day_s5_7' => __( 'Saturday', 'aui' ), |
|
| 2690 | - 'am_lower' => __( 'am', 'aui' ), |
|
| 2691 | - 'pm_lower' => __( 'pm', 'aui' ), |
|
| 2692 | - 'am_upper' => __( 'AM', 'aui' ), |
|
| 2693 | - 'pm_upper' => __( 'PM', 'aui' ), |
|
| 2694 | - 'firstDayOfWeek' => (int) get_option( 'start_of_week' ), |
|
| 2695 | - 'time_24hr' => false, |
|
| 2696 | - 'year' => __( 'Year', 'aui' ), |
|
| 2697 | - 'hour' => __( 'Hour', 'aui' ), |
|
| 2698 | - 'minute' => __( 'Minute', 'aui' ), |
|
| 2699 | - 'weekAbbreviation' => __( 'Wk', 'aui' ), |
|
| 2700 | - 'rangeSeparator' => __( ' to ', 'aui' ), |
|
| 2701 | - 'scrollTitle' => __( 'Scroll to increment', 'aui' ), |
|
| 2702 | - 'toggleTitle' => __( 'Click to toggle', 'aui' ) |
|
| 2703 | - ); |
|
| 2704 | - |
|
| 2705 | - return apply_filters( 'ayecode_ui_calendar_params', $params ); |
|
| 2706 | - } |
|
| 2707 | - |
|
| 2708 | - /** |
|
| 2709 | - * Flatpickr calendar localize. |
|
| 2710 | - * |
|
| 2711 | - * @since 0.1.44 |
|
| 2712 | - * |
|
| 2713 | - * @return string Calendar locale. |
|
| 2714 | - */ |
|
| 2715 | - public static function flatpickr_locale() { |
|
| 2716 | - $params = self::calendar_params(); |
|
| 2717 | - |
|
| 2718 | - if ( is_string( $params ) ) { |
|
| 2719 | - $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' ); |
|
| 2720 | - } else { |
|
| 2721 | - foreach ( (array) $params as $key => $value ) { |
|
| 2722 | - if ( ! is_scalar( $value ) ) { |
|
| 2723 | - continue; |
|
| 2724 | - } |
|
| 2725 | - |
|
| 2726 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2727 | - } |
|
| 2728 | - } |
|
| 2243 | + '.nav-pills .nav-link.active' => array('b'), |
|
| 2244 | + '.nav-pills .show>.nav-link' => array('b'), |
|
| 2245 | + '.page-link' => array('c'), |
|
| 2246 | + '.page-item.active .page-link' => array('b','o'), |
|
| 2247 | + '.badge-primary' => array('b'), |
|
| 2248 | + '.alert-primary' => array('b','o'), |
|
| 2249 | + '.progress-bar' => array('b'), |
|
| 2250 | + '.list-group-item.active' => array('b','o'), |
|
| 2251 | + '.bg-primary' => array('b','f'), |
|
| 2252 | + '.btn-link.btn-primary' => array('c'), |
|
| 2253 | + '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
|
| 2254 | + ); |
|
| 2255 | + |
|
| 2256 | + $important_selectors = array( |
|
| 2257 | + '.bg-primary' => array('b','f'), |
|
| 2258 | + '.border-primary' => array('o'), |
|
| 2259 | + '.text-primary' => array('c'), |
|
| 2260 | + ); |
|
| 2261 | + |
|
| 2262 | + $color = array(); |
|
| 2263 | + $color_i = array(); |
|
| 2264 | + $background = array(); |
|
| 2265 | + $background_i = array(); |
|
| 2266 | + $border = array(); |
|
| 2267 | + $border_i = array(); |
|
| 2268 | + $fill = array(); |
|
| 2269 | + $fill_i = array(); |
|
| 2270 | + |
|
| 2271 | + $output = ''; |
|
| 2272 | + |
|
| 2273 | + // build rules into each type |
|
| 2274 | + foreach($selectors as $selector => $types){ |
|
| 2275 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 2276 | + $types = array_combine($types,$types); |
|
| 2277 | + if(isset($types['c'])){$color[] = $selector;} |
|
| 2278 | + if(isset($types['b'])){$background[] = $selector;} |
|
| 2279 | + if(isset($types['o'])){$border[] = $selector;} |
|
| 2280 | + if(isset($types['f'])){$fill[] = $selector;} |
|
| 2281 | + } |
|
| 2282 | + |
|
| 2283 | + // build rules into each type |
|
| 2284 | + foreach($important_selectors as $selector => $types){ |
|
| 2285 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 2286 | + $types = array_combine($types,$types); |
|
| 2287 | + if(isset($types['c'])){$color_i[] = $selector;} |
|
| 2288 | + if(isset($types['b'])){$background_i[] = $selector;} |
|
| 2289 | + if(isset($types['o'])){$border_i[] = $selector;} |
|
| 2290 | + if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 2291 | + } |
|
| 2292 | + |
|
| 2293 | + // add any color rules |
|
| 2294 | + if(!empty($color)){ |
|
| 2295 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 2296 | + } |
|
| 2297 | + if(!empty($color_i)){ |
|
| 2298 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 2299 | + } |
|
| 2300 | + |
|
| 2301 | + // add any background color rules |
|
| 2302 | + if(!empty($background)){ |
|
| 2303 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 2304 | + } |
|
| 2305 | + if(!empty($background_i)){ |
|
| 2306 | + $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 2307 | + } |
|
| 2308 | + |
|
| 2309 | + // add any border color rules |
|
| 2310 | + if(!empty($border)){ |
|
| 2311 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 2312 | + } |
|
| 2313 | + if(!empty($border_i)){ |
|
| 2314 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 2315 | + } |
|
| 2316 | + |
|
| 2317 | + // add any fill color rules |
|
| 2318 | + if(!empty($fill)){ |
|
| 2319 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 2320 | + } |
|
| 2321 | + if(!empty($fill_i)){ |
|
| 2322 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 2323 | + } |
|
| 2324 | + |
|
| 2325 | + |
|
| 2326 | + $prefix = $compatibility ? ".bsui " : ""; |
|
| 2327 | + |
|
| 2328 | + // darken |
|
| 2329 | + $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 2330 | + $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 2331 | + $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 2332 | + |
|
| 2333 | + // lighten |
|
| 2334 | + $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 2335 | + |
|
| 2336 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 2337 | + $op_25 = $color_code."40"; // 25% opacity |
|
| 2338 | + |
|
| 2339 | + |
|
| 2340 | + // button states |
|
| 2341 | + $output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 2342 | + $output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2343 | + $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 2344 | + $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2345 | + |
|
| 2346 | + |
|
| 2347 | + // dropdown's |
|
| 2348 | + $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
| 2349 | + |
|
| 2350 | + |
|
| 2351 | + // input states |
|
| 2352 | + $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2353 | + |
|
| 2354 | + // page link |
|
| 2355 | + $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2356 | + |
|
| 2357 | + return $output; |
|
| 2358 | + } |
|
| 2359 | + |
|
| 2360 | + /** |
|
| 2361 | + * |
|
| 2362 | + * @deprecated 0.1.76 Use css_overwrite() |
|
| 2363 | + * |
|
| 2364 | + * @param $color_code |
|
| 2365 | + * @param $compatibility |
|
| 2366 | + * |
|
| 2367 | + * @return string |
|
| 2368 | + */ |
|
| 2369 | + public static function css_secondary($color_code,$compatibility){; |
|
| 2370 | + $color_code = sanitize_hex_color($color_code); |
|
| 2371 | + if(!$color_code){return '';} |
|
| 2372 | + /** |
|
| 2373 | + * c = color, b = background color, o = border-color, f = fill |
|
| 2374 | + */ |
|
| 2375 | + $selectors = array( |
|
| 2376 | + '.btn-secondary' => array('b','o'), |
|
| 2377 | + '.btn-secondary.disabled' => array('b','o'), |
|
| 2378 | + '.btn-secondary:disabled' => array('b','o'), |
|
| 2379 | + '.btn-outline-secondary' => array('c','o'), |
|
| 2380 | + '.btn-outline-secondary:hover' => array('b','o'), |
|
| 2381 | + '.btn-outline-secondary.disabled' => array('c'), |
|
| 2382 | + '.btn-outline-secondary:disabled' => array('c'), |
|
| 2383 | + '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 2384 | + '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 2385 | + '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
| 2386 | + '.badge-secondary' => array('b'), |
|
| 2387 | + '.alert-secondary' => array('b','o'), |
|
| 2388 | + '.btn-link.btn-secondary' => array('c'), |
|
| 2389 | + ); |
|
| 2390 | + |
|
| 2391 | + $important_selectors = array( |
|
| 2392 | + '.bg-secondary' => array('b','f'), |
|
| 2393 | + '.border-secondary' => array('o'), |
|
| 2394 | + '.text-secondary' => array('c'), |
|
| 2395 | + ); |
|
| 2396 | + |
|
| 2397 | + $color = array(); |
|
| 2398 | + $color_i = array(); |
|
| 2399 | + $background = array(); |
|
| 2400 | + $background_i = array(); |
|
| 2401 | + $border = array(); |
|
| 2402 | + $border_i = array(); |
|
| 2403 | + $fill = array(); |
|
| 2404 | + $fill_i = array(); |
|
| 2405 | + |
|
| 2406 | + $output = ''; |
|
| 2407 | + |
|
| 2408 | + // build rules into each type |
|
| 2409 | + foreach($selectors as $selector => $types){ |
|
| 2410 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 2411 | + $types = array_combine($types,$types); |
|
| 2412 | + if(isset($types['c'])){$color[] = $selector;} |
|
| 2413 | + if(isset($types['b'])){$background[] = $selector;} |
|
| 2414 | + if(isset($types['o'])){$border[] = $selector;} |
|
| 2415 | + if(isset($types['f'])){$fill[] = $selector;} |
|
| 2416 | + } |
|
| 2417 | + |
|
| 2418 | + // build rules into each type |
|
| 2419 | + foreach($important_selectors as $selector => $types){ |
|
| 2420 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 2421 | + $types = array_combine($types,$types); |
|
| 2422 | + if(isset($types['c'])){$color_i[] = $selector;} |
|
| 2423 | + if(isset($types['b'])){$background_i[] = $selector;} |
|
| 2424 | + if(isset($types['o'])){$border_i[] = $selector;} |
|
| 2425 | + if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 2426 | + } |
|
| 2427 | + |
|
| 2428 | + // add any color rules |
|
| 2429 | + if(!empty($color)){ |
|
| 2430 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 2431 | + } |
|
| 2432 | + if(!empty($color_i)){ |
|
| 2433 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 2434 | + } |
|
| 2435 | + |
|
| 2436 | + // add any background color rules |
|
| 2437 | + if(!empty($background)){ |
|
| 2438 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 2439 | + } |
|
| 2440 | + if(!empty($background_i)){ |
|
| 2441 | + $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 2442 | + } |
|
| 2443 | + |
|
| 2444 | + // add any border color rules |
|
| 2445 | + if(!empty($border)){ |
|
| 2446 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 2447 | + } |
|
| 2448 | + if(!empty($border_i)){ |
|
| 2449 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 2450 | + } |
|
| 2451 | + |
|
| 2452 | + // add any fill color rules |
|
| 2453 | + if(!empty($fill)){ |
|
| 2454 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 2455 | + } |
|
| 2456 | + if(!empty($fill_i)){ |
|
| 2457 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 2458 | + } |
|
| 2459 | + |
|
| 2460 | + |
|
| 2461 | + $prefix = $compatibility ? ".bsui " : ""; |
|
| 2462 | + |
|
| 2463 | + // darken |
|
| 2464 | + $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 2465 | + $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 2466 | + $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 2467 | + |
|
| 2468 | + // lighten |
|
| 2469 | + $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 2470 | + |
|
| 2471 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 2472 | + $op_25 = $color_code."40"; // 25% opacity |
|
| 2473 | + |
|
| 2474 | + |
|
| 2475 | + // button states |
|
| 2476 | + $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 2477 | + $output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2478 | + $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 2479 | + $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2480 | + |
|
| 2481 | + |
|
| 2482 | + return $output; |
|
| 2483 | + } |
|
| 2484 | + |
|
| 2485 | + /** |
|
| 2486 | + * Increases or decreases the brightness of a color by a percentage of the current brightness. |
|
| 2487 | + * |
|
| 2488 | + * @param string $hexCode Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF` |
|
| 2489 | + * @param float $adjustPercent A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker. |
|
| 2490 | + * |
|
| 2491 | + * @return string |
|
| 2492 | + */ |
|
| 2493 | + public static function css_hex_lighten_darken($hexCode, $adjustPercent) { |
|
| 2494 | + $hexCode = ltrim($hexCode, '#'); |
|
| 2495 | + |
|
| 2496 | + if (strlen($hexCode) == 3) { |
|
| 2497 | + $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2]; |
|
| 2498 | + } |
|
| 2499 | + |
|
| 2500 | + $hexCode = array_map('hexdec', str_split($hexCode, 2)); |
|
| 2501 | + |
|
| 2502 | + foreach ($hexCode as & $color) { |
|
| 2503 | + $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color; |
|
| 2504 | + $adjustAmount = ceil($adjustableLimit * $adjustPercent); |
|
| 2505 | + |
|
| 2506 | + $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT); |
|
| 2507 | + } |
|
| 2508 | + |
|
| 2509 | + return '#' . implode($hexCode); |
|
| 2510 | + } |
|
| 2511 | + |
|
| 2512 | + /** |
|
| 2513 | + * Check if we should display examples. |
|
| 2514 | + */ |
|
| 2515 | + public function maybe_show_examples(){ |
|
| 2516 | + if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
| 2517 | + echo "<head>"; |
|
| 2518 | + wp_head(); |
|
| 2519 | + echo "</head>"; |
|
| 2520 | + echo "<body>"; |
|
| 2521 | + echo $this->get_examples(); |
|
| 2522 | + echo "</body>"; |
|
| 2523 | + exit; |
|
| 2524 | + } |
|
| 2525 | + } |
|
| 2526 | + |
|
| 2527 | + /** |
|
| 2528 | + * Get developer examples. |
|
| 2529 | + * |
|
| 2530 | + * @return string |
|
| 2531 | + */ |
|
| 2532 | + public function get_examples(){ |
|
| 2533 | + $output = ''; |
|
| 2534 | + |
|
| 2535 | + |
|
| 2536 | + // open form |
|
| 2537 | + $output .= "<form class='p-5 m-5 border rounded'>"; |
|
| 2538 | + |
|
| 2539 | + // input example |
|
| 2540 | + $output .= aui()->input(array( |
|
| 2541 | + 'type' => 'text', |
|
| 2542 | + 'id' => 'text-example', |
|
| 2543 | + 'name' => 'text-example', |
|
| 2544 | + 'placeholder' => 'text placeholder', |
|
| 2545 | + 'title' => 'Text input example', |
|
| 2546 | + 'value' => '', |
|
| 2547 | + 'required' => false, |
|
| 2548 | + 'help_text' => 'help text', |
|
| 2549 | + 'label' => 'Text input example label' |
|
| 2550 | + )); |
|
| 2551 | + |
|
| 2552 | + // input example |
|
| 2553 | + $output .= aui()->input(array( |
|
| 2554 | + 'type' => 'url', |
|
| 2555 | + 'id' => 'text-example2', |
|
| 2556 | + 'name' => 'text-example', |
|
| 2557 | + 'placeholder' => 'url placeholder', |
|
| 2558 | + 'title' => 'Text input example', |
|
| 2559 | + 'value' => '', |
|
| 2560 | + 'required' => false, |
|
| 2561 | + 'help_text' => 'help text', |
|
| 2562 | + 'label' => 'Text input example label' |
|
| 2563 | + )); |
|
| 2564 | + |
|
| 2565 | + // checkbox example |
|
| 2566 | + $output .= aui()->input(array( |
|
| 2567 | + 'type' => 'checkbox', |
|
| 2568 | + 'id' => 'checkbox-example', |
|
| 2569 | + 'name' => 'checkbox-example', |
|
| 2570 | + 'placeholder' => 'checkbox-example', |
|
| 2571 | + 'title' => 'Checkbox example', |
|
| 2572 | + 'value' => '1', |
|
| 2573 | + 'checked' => true, |
|
| 2574 | + 'required' => false, |
|
| 2575 | + 'help_text' => 'help text', |
|
| 2576 | + 'label' => 'Checkbox checked' |
|
| 2577 | + )); |
|
| 2578 | + |
|
| 2579 | + // checkbox example |
|
| 2580 | + $output .= aui()->input(array( |
|
| 2581 | + 'type' => 'checkbox', |
|
| 2582 | + 'id' => 'checkbox-example2', |
|
| 2583 | + 'name' => 'checkbox-example2', |
|
| 2584 | + 'placeholder' => 'checkbox-example', |
|
| 2585 | + 'title' => 'Checkbox example', |
|
| 2586 | + 'value' => '1', |
|
| 2587 | + 'checked' => false, |
|
| 2588 | + 'required' => false, |
|
| 2589 | + 'help_text' => 'help text', |
|
| 2590 | + 'label' => 'Checkbox un-checked' |
|
| 2591 | + )); |
|
| 2592 | + |
|
| 2593 | + // switch example |
|
| 2594 | + $output .= aui()->input(array( |
|
| 2595 | + 'type' => 'checkbox', |
|
| 2596 | + 'id' => 'switch-example', |
|
| 2597 | + 'name' => 'switch-example', |
|
| 2598 | + 'placeholder' => 'checkbox-example', |
|
| 2599 | + 'title' => 'Switch example', |
|
| 2600 | + 'value' => '1', |
|
| 2601 | + 'checked' => true, |
|
| 2602 | + 'switch' => true, |
|
| 2603 | + 'required' => false, |
|
| 2604 | + 'help_text' => 'help text', |
|
| 2605 | + 'label' => 'Switch on' |
|
| 2606 | + )); |
|
| 2607 | + |
|
| 2608 | + // switch example |
|
| 2609 | + $output .= aui()->input(array( |
|
| 2610 | + 'type' => 'checkbox', |
|
| 2611 | + 'id' => 'switch-example2', |
|
| 2612 | + 'name' => 'switch-example2', |
|
| 2613 | + 'placeholder' => 'checkbox-example', |
|
| 2614 | + 'title' => 'Switch example', |
|
| 2615 | + 'value' => '1', |
|
| 2616 | + 'checked' => false, |
|
| 2617 | + 'switch' => true, |
|
| 2618 | + 'required' => false, |
|
| 2619 | + 'help_text' => 'help text', |
|
| 2620 | + 'label' => 'Switch off' |
|
| 2621 | + )); |
|
| 2622 | + |
|
| 2623 | + // close form |
|
| 2624 | + $output .= "</form>"; |
|
| 2625 | + |
|
| 2626 | + return $output; |
|
| 2627 | + } |
|
| 2628 | + |
|
| 2629 | + /** |
|
| 2630 | + * Calendar params. |
|
| 2631 | + * |
|
| 2632 | + * @since 0.1.44 |
|
| 2633 | + * |
|
| 2634 | + * @return array Calendar params. |
|
| 2635 | + */ |
|
| 2636 | + public static function calendar_params() { |
|
| 2637 | + $params = array( |
|
| 2638 | + 'month_long_1' => __( 'January', 'aui' ), |
|
| 2639 | + 'month_long_2' => __( 'February', 'aui' ), |
|
| 2640 | + 'month_long_3' => __( 'March', 'aui' ), |
|
| 2641 | + 'month_long_4' => __( 'April', 'aui' ), |
|
| 2642 | + 'month_long_5' => __( 'May', 'aui' ), |
|
| 2643 | + 'month_long_6' => __( 'June', 'aui' ), |
|
| 2644 | + 'month_long_7' => __( 'July', 'aui' ), |
|
| 2645 | + 'month_long_8' => __( 'August', 'aui' ), |
|
| 2646 | + 'month_long_9' => __( 'September', 'aui' ), |
|
| 2647 | + 'month_long_10' => __( 'October', 'aui' ), |
|
| 2648 | + 'month_long_11' => __( 'November', 'aui' ), |
|
| 2649 | + 'month_long_12' => __( 'December', 'aui' ), |
|
| 2650 | + 'month_s_1' => _x( 'Jan', 'January abbreviation', 'aui' ), |
|
| 2651 | + 'month_s_2' => _x( 'Feb', 'February abbreviation', 'aui' ), |
|
| 2652 | + 'month_s_3' => _x( 'Mar', 'March abbreviation', 'aui' ), |
|
| 2653 | + 'month_s_4' => _x( 'Apr', 'April abbreviation', 'aui' ), |
|
| 2654 | + 'month_s_5' => _x( 'May', 'May abbreviation', 'aui' ), |
|
| 2655 | + 'month_s_6' => _x( 'Jun', 'June abbreviation', 'aui' ), |
|
| 2656 | + 'month_s_7' => _x( 'Jul', 'July abbreviation', 'aui' ), |
|
| 2657 | + 'month_s_8' => _x( 'Aug', 'August abbreviation', 'aui' ), |
|
| 2658 | + 'month_s_9' => _x( 'Sep', 'September abbreviation', 'aui' ), |
|
| 2659 | + 'month_s_10' => _x( 'Oct', 'October abbreviation', 'aui' ), |
|
| 2660 | + 'month_s_11' => _x( 'Nov', 'November abbreviation', 'aui' ), |
|
| 2661 | + 'month_s_12' => _x( 'Dec', 'December abbreviation', 'aui' ), |
|
| 2662 | + 'day_s1_1' => _x( 'S', 'Sunday initial', 'aui' ), |
|
| 2663 | + 'day_s1_2' => _x( 'M', 'Monday initial', 'aui' ), |
|
| 2664 | + 'day_s1_3' => _x( 'T', 'Tuesday initial', 'aui' ), |
|
| 2665 | + 'day_s1_4' => _x( 'W', 'Wednesday initial', 'aui' ), |
|
| 2666 | + 'day_s1_5' => _x( 'T', 'Friday initial', 'aui' ), |
|
| 2667 | + 'day_s1_6' => _x( 'F', 'Thursday initial', 'aui' ), |
|
| 2668 | + 'day_s1_7' => _x( 'S', 'Saturday initial', 'aui' ), |
|
| 2669 | + 'day_s2_1' => __( 'Su', 'aui' ), |
|
| 2670 | + 'day_s2_2' => __( 'Mo', 'aui' ), |
|
| 2671 | + 'day_s2_3' => __( 'Tu', 'aui' ), |
|
| 2672 | + 'day_s2_4' => __( 'We', 'aui' ), |
|
| 2673 | + 'day_s2_5' => __( 'Th', 'aui' ), |
|
| 2674 | + 'day_s2_6' => __( 'Fr', 'aui' ), |
|
| 2675 | + 'day_s2_7' => __( 'Sa', 'aui' ), |
|
| 2676 | + 'day_s3_1' => __( 'Sun', 'aui' ), |
|
| 2677 | + 'day_s3_2' => __( 'Mon', 'aui' ), |
|
| 2678 | + 'day_s3_3' => __( 'Tue', 'aui' ), |
|
| 2679 | + 'day_s3_4' => __( 'Wed', 'aui' ), |
|
| 2680 | + 'day_s3_5' => __( 'Thu', 'aui' ), |
|
| 2681 | + 'day_s3_6' => __( 'Fri', 'aui' ), |
|
| 2682 | + 'day_s3_7' => __( 'Sat', 'aui' ), |
|
| 2683 | + 'day_s5_1' => __( 'Sunday', 'aui' ), |
|
| 2684 | + 'day_s5_2' => __( 'Monday', 'aui' ), |
|
| 2685 | + 'day_s5_3' => __( 'Tuesday', 'aui' ), |
|
| 2686 | + 'day_s5_4' => __( 'Wednesday', 'aui' ), |
|
| 2687 | + 'day_s5_5' => __( 'Thursday', 'aui' ), |
|
| 2688 | + 'day_s5_6' => __( 'Friday', 'aui' ), |
|
| 2689 | + 'day_s5_7' => __( 'Saturday', 'aui' ), |
|
| 2690 | + 'am_lower' => __( 'am', 'aui' ), |
|
| 2691 | + 'pm_lower' => __( 'pm', 'aui' ), |
|
| 2692 | + 'am_upper' => __( 'AM', 'aui' ), |
|
| 2693 | + 'pm_upper' => __( 'PM', 'aui' ), |
|
| 2694 | + 'firstDayOfWeek' => (int) get_option( 'start_of_week' ), |
|
| 2695 | + 'time_24hr' => false, |
|
| 2696 | + 'year' => __( 'Year', 'aui' ), |
|
| 2697 | + 'hour' => __( 'Hour', 'aui' ), |
|
| 2698 | + 'minute' => __( 'Minute', 'aui' ), |
|
| 2699 | + 'weekAbbreviation' => __( 'Wk', 'aui' ), |
|
| 2700 | + 'rangeSeparator' => __( ' to ', 'aui' ), |
|
| 2701 | + 'scrollTitle' => __( 'Scroll to increment', 'aui' ), |
|
| 2702 | + 'toggleTitle' => __( 'Click to toggle', 'aui' ) |
|
| 2703 | + ); |
|
| 2704 | + |
|
| 2705 | + return apply_filters( 'ayecode_ui_calendar_params', $params ); |
|
| 2706 | + } |
|
| 2707 | + |
|
| 2708 | + /** |
|
| 2709 | + * Flatpickr calendar localize. |
|
| 2710 | + * |
|
| 2711 | + * @since 0.1.44 |
|
| 2712 | + * |
|
| 2713 | + * @return string Calendar locale. |
|
| 2714 | + */ |
|
| 2715 | + public static function flatpickr_locale() { |
|
| 2716 | + $params = self::calendar_params(); |
|
| 2717 | + |
|
| 2718 | + if ( is_string( $params ) ) { |
|
| 2719 | + $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' ); |
|
| 2720 | + } else { |
|
| 2721 | + foreach ( (array) $params as $key => $value ) { |
|
| 2722 | + if ( ! is_scalar( $value ) ) { |
|
| 2723 | + continue; |
|
| 2724 | + } |
|
| 2725 | + |
|
| 2726 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2727 | + } |
|
| 2728 | + } |
|
| 2729 | 2729 | |
| 2730 | - $day_s3 = array(); |
|
| 2731 | - $day_s5 = array(); |
|
| 2730 | + $day_s3 = array(); |
|
| 2731 | + $day_s5 = array(); |
|
| 2732 | 2732 | |
| 2733 | - for ( $i = 1; $i <= 7; $i ++ ) { |
|
| 2734 | - $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
| 2735 | - $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
| 2736 | - } |
|
| 2733 | + for ( $i = 1; $i <= 7; $i ++ ) { |
|
| 2734 | + $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
| 2735 | + $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
| 2736 | + } |
|
| 2737 | 2737 | |
| 2738 | - $month_s = array(); |
|
| 2739 | - $month_long = array(); |
|
| 2738 | + $month_s = array(); |
|
| 2739 | + $month_long = array(); |
|
| 2740 | 2740 | |
| 2741 | - for ( $i = 1; $i <= 12; $i ++ ) { |
|
| 2742 | - $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); |
|
| 2743 | - $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); |
|
| 2744 | - } |
|
| 2741 | + for ( $i = 1; $i <= 12; $i ++ ) { |
|
| 2742 | + $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); |
|
| 2743 | + $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); |
|
| 2744 | + } |
|
| 2745 | 2745 | |
| 2746 | - ob_start(); |
|
| 2747 | - if ( 0 ) { ?><script><?php } ?> |
|
| 2746 | + ob_start(); |
|
| 2747 | + if ( 0 ) { ?><script><?php } ?> |
|
| 2748 | 2748 | { |
| 2749 | 2749 | weekdays: { |
| 2750 | 2750 | shorthand: ['<?php echo implode( "','", $day_s3 ); ?>'], |
@@ -2783,189 +2783,189 @@ discard block |
||
| 2783 | 2783 | } |
| 2784 | 2784 | <?php if ( 0 ) { ?></script><?php } ?> |
| 2785 | 2785 | <?php |
| 2786 | - $locale = ob_get_clean(); |
|
| 2787 | - |
|
| 2788 | - return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) ); |
|
| 2789 | - } |
|
| 2790 | - |
|
| 2791 | - /** |
|
| 2792 | - * Select2 JS params. |
|
| 2793 | - * |
|
| 2794 | - * @since 0.1.44 |
|
| 2795 | - * |
|
| 2796 | - * @return array Select2 JS params. |
|
| 2797 | - */ |
|
| 2798 | - public static function select2_params() { |
|
| 2799 | - $params = array( |
|
| 2800 | - 'i18n_select_state_text' => esc_attr__( 'Select an option…', 'aui' ), |
|
| 2801 | - 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'aui' ), |
|
| 2802 | - 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'aui' ), |
|
| 2803 | - 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'aui' ), |
|
| 2804 | - 'i18n_input_too_short_n' => _x( 'Please enter %item% or more characters', 'enhanced select', 'aui' ), |
|
| 2805 | - 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'aui' ), |
|
| 2806 | - 'i18n_input_too_long_n' => _x( 'Please delete %item% characters', 'enhanced select', 'aui' ), |
|
| 2807 | - 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'aui' ), |
|
| 2808 | - 'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'aui' ), |
|
| 2809 | - 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'aui' ), |
|
| 2810 | - 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'aui' ) |
|
| 2811 | - ); |
|
| 2812 | - |
|
| 2813 | - return apply_filters( 'ayecode_ui_select2_params', $params ); |
|
| 2814 | - } |
|
| 2815 | - |
|
| 2816 | - /** |
|
| 2817 | - * Select2 JS localize. |
|
| 2818 | - * |
|
| 2819 | - * @since 0.1.44 |
|
| 2820 | - * |
|
| 2821 | - * @return string Select2 JS locale. |
|
| 2822 | - */ |
|
| 2823 | - public static function select2_locale() { |
|
| 2824 | - $params = self::select2_params(); |
|
| 2825 | - |
|
| 2826 | - foreach ( (array) $params as $key => $value ) { |
|
| 2827 | - if ( ! is_scalar( $value ) ) { |
|
| 2828 | - continue; |
|
| 2829 | - } |
|
| 2786 | + $locale = ob_get_clean(); |
|
| 2787 | + |
|
| 2788 | + return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) ); |
|
| 2789 | + } |
|
| 2790 | + |
|
| 2791 | + /** |
|
| 2792 | + * Select2 JS params. |
|
| 2793 | + * |
|
| 2794 | + * @since 0.1.44 |
|
| 2795 | + * |
|
| 2796 | + * @return array Select2 JS params. |
|
| 2797 | + */ |
|
| 2798 | + public static function select2_params() { |
|
| 2799 | + $params = array( |
|
| 2800 | + 'i18n_select_state_text' => esc_attr__( 'Select an option…', 'aui' ), |
|
| 2801 | + 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'aui' ), |
|
| 2802 | + 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'aui' ), |
|
| 2803 | + 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'aui' ), |
|
| 2804 | + 'i18n_input_too_short_n' => _x( 'Please enter %item% or more characters', 'enhanced select', 'aui' ), |
|
| 2805 | + 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'aui' ), |
|
| 2806 | + 'i18n_input_too_long_n' => _x( 'Please delete %item% characters', 'enhanced select', 'aui' ), |
|
| 2807 | + 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'aui' ), |
|
| 2808 | + 'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'aui' ), |
|
| 2809 | + 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'aui' ), |
|
| 2810 | + 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'aui' ) |
|
| 2811 | + ); |
|
| 2812 | + |
|
| 2813 | + return apply_filters( 'ayecode_ui_select2_params', $params ); |
|
| 2814 | + } |
|
| 2815 | + |
|
| 2816 | + /** |
|
| 2817 | + * Select2 JS localize. |
|
| 2818 | + * |
|
| 2819 | + * @since 0.1.44 |
|
| 2820 | + * |
|
| 2821 | + * @return string Select2 JS locale. |
|
| 2822 | + */ |
|
| 2823 | + public static function select2_locale() { |
|
| 2824 | + $params = self::select2_params(); |
|
| 2825 | + |
|
| 2826 | + foreach ( (array) $params as $key => $value ) { |
|
| 2827 | + if ( ! is_scalar( $value ) ) { |
|
| 2828 | + continue; |
|
| 2829 | + } |
|
| 2830 | 2830 | |
| 2831 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2832 | - } |
|
| 2833 | - |
|
| 2834 | - $locale = json_encode( $params ); |
|
| 2835 | - |
|
| 2836 | - return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) ); |
|
| 2837 | - } |
|
| 2838 | - |
|
| 2839 | - /** |
|
| 2840 | - * Time ago JS localize. |
|
| 2841 | - * |
|
| 2842 | - * @since 0.1.47 |
|
| 2843 | - * |
|
| 2844 | - * @return string Time ago JS locale. |
|
| 2845 | - */ |
|
| 2846 | - public static function timeago_locale() { |
|
| 2847 | - $params = array( |
|
| 2848 | - 'prefix_ago' => '', |
|
| 2849 | - 'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'aui' ), |
|
| 2850 | - 'prefix_after' => _x( 'after', 'time ago', 'aui' ) . ' ', |
|
| 2851 | - 'suffix_after' => '', |
|
| 2852 | - 'seconds' => _x( 'less than a minute', 'time ago', 'aui' ), |
|
| 2853 | - 'minute' => _x( 'about a minute', 'time ago', 'aui' ), |
|
| 2854 | - 'minutes' => _x( '%d minutes', 'time ago', 'aui' ), |
|
| 2855 | - 'hour' => _x( 'about an hour', 'time ago', 'aui' ), |
|
| 2856 | - 'hours' => _x( 'about %d hours', 'time ago', 'aui' ), |
|
| 2857 | - 'day' => _x( 'a day', 'time ago', 'aui' ), |
|
| 2858 | - 'days' => _x( '%d days', 'time ago', 'aui' ), |
|
| 2859 | - 'month' => _x( 'about a month', 'time ago', 'aui' ), |
|
| 2860 | - 'months' => _x( '%d months', 'time ago', 'aui' ), |
|
| 2861 | - 'year' => _x( 'about a year', 'time ago', 'aui' ), |
|
| 2862 | - 'years' => _x( '%d years', 'time ago', 'aui' ), |
|
| 2863 | - ); |
|
| 2864 | - |
|
| 2865 | - $params = apply_filters( 'ayecode_ui_timeago_params', $params ); |
|
| 2866 | - |
|
| 2867 | - foreach ( (array) $params as $key => $value ) { |
|
| 2868 | - if ( ! is_scalar( $value ) ) { |
|
| 2869 | - continue; |
|
| 2870 | - } |
|
| 2831 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2832 | + } |
|
| 2833 | + |
|
| 2834 | + $locale = json_encode( $params ); |
|
| 2835 | + |
|
| 2836 | + return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) ); |
|
| 2837 | + } |
|
| 2838 | + |
|
| 2839 | + /** |
|
| 2840 | + * Time ago JS localize. |
|
| 2841 | + * |
|
| 2842 | + * @since 0.1.47 |
|
| 2843 | + * |
|
| 2844 | + * @return string Time ago JS locale. |
|
| 2845 | + */ |
|
| 2846 | + public static function timeago_locale() { |
|
| 2847 | + $params = array( |
|
| 2848 | + 'prefix_ago' => '', |
|
| 2849 | + 'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'aui' ), |
|
| 2850 | + 'prefix_after' => _x( 'after', 'time ago', 'aui' ) . ' ', |
|
| 2851 | + 'suffix_after' => '', |
|
| 2852 | + 'seconds' => _x( 'less than a minute', 'time ago', 'aui' ), |
|
| 2853 | + 'minute' => _x( 'about a minute', 'time ago', 'aui' ), |
|
| 2854 | + 'minutes' => _x( '%d minutes', 'time ago', 'aui' ), |
|
| 2855 | + 'hour' => _x( 'about an hour', 'time ago', 'aui' ), |
|
| 2856 | + 'hours' => _x( 'about %d hours', 'time ago', 'aui' ), |
|
| 2857 | + 'day' => _x( 'a day', 'time ago', 'aui' ), |
|
| 2858 | + 'days' => _x( '%d days', 'time ago', 'aui' ), |
|
| 2859 | + 'month' => _x( 'about a month', 'time ago', 'aui' ), |
|
| 2860 | + 'months' => _x( '%d months', 'time ago', 'aui' ), |
|
| 2861 | + 'year' => _x( 'about a year', 'time ago', 'aui' ), |
|
| 2862 | + 'years' => _x( '%d years', 'time ago', 'aui' ), |
|
| 2863 | + ); |
|
| 2864 | + |
|
| 2865 | + $params = apply_filters( 'ayecode_ui_timeago_params', $params ); |
|
| 2866 | + |
|
| 2867 | + foreach ( (array) $params as $key => $value ) { |
|
| 2868 | + if ( ! is_scalar( $value ) ) { |
|
| 2869 | + continue; |
|
| 2870 | + } |
|
| 2871 | 2871 | |
| 2872 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2873 | - } |
|
| 2874 | - |
|
| 2875 | - $locale = json_encode( $params ); |
|
| 2876 | - |
|
| 2877 | - return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) ); |
|
| 2878 | - } |
|
| 2879 | - |
|
| 2880 | - /** |
|
| 2881 | - * JavaScript Minifier |
|
| 2882 | - * |
|
| 2883 | - * @param $input |
|
| 2884 | - * |
|
| 2885 | - * @return mixed |
|
| 2886 | - */ |
|
| 2887 | - public static function minify_js($input) { |
|
| 2888 | - if(trim($input) === "") return $input; |
|
| 2889 | - return preg_replace( |
|
| 2890 | - array( |
|
| 2891 | - // Remove comment(s) |
|
| 2892 | - '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#', |
|
| 2893 | - // Remove white-space(s) outside the string and regex |
|
| 2894 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s', |
|
| 2895 | - // Remove the last semicolon |
|
| 2896 | - '#;+\}#', |
|
| 2897 | - // Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}` |
|
| 2898 | - '#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i', |
|
| 2899 | - // --ibid. From `foo['bar']` to `foo.bar` |
|
| 2900 | - '#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i' |
|
| 2901 | - ), |
|
| 2902 | - array( |
|
| 2903 | - '$1', |
|
| 2904 | - '$1$2', |
|
| 2905 | - '}', |
|
| 2906 | - '$1$3', |
|
| 2907 | - '$1.$3' |
|
| 2908 | - ), |
|
| 2909 | - $input); |
|
| 2910 | - } |
|
| 2911 | - |
|
| 2912 | - /** |
|
| 2913 | - * Minify CSS |
|
| 2914 | - * |
|
| 2915 | - * @param $input |
|
| 2916 | - * |
|
| 2917 | - * @return mixed |
|
| 2918 | - */ |
|
| 2919 | - public static function minify_css($input) { |
|
| 2920 | - if(trim($input) === "") return $input; |
|
| 2921 | - return preg_replace( |
|
| 2922 | - array( |
|
| 2923 | - // Remove comment(s) |
|
| 2924 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s', |
|
| 2925 | - // Remove unused white-space(s) |
|
| 2926 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si', |
|
| 2927 | - // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0` |
|
| 2928 | - '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si', |
|
| 2929 | - // Replace `:0 0 0 0` with `:0` |
|
| 2930 | - '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i', |
|
| 2931 | - // Replace `background-position:0` with `background-position:0 0` |
|
| 2932 | - '#(background-position):0(?=[;\}])#si', |
|
| 2933 | - // Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space |
|
| 2934 | - '#(?<=[\s:,\-])0+\.(\d+)#s', |
|
| 2935 | - // Minify string value |
|
| 2936 | - '#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si', |
|
| 2937 | - '#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si', |
|
| 2938 | - // Minify HEX color code |
|
| 2939 | - '#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i', |
|
| 2940 | - // Replace `(border|outline):none` with `(border|outline):0` |
|
| 2941 | - '#(?<=[\{;])(border|outline):none(?=[;\}\!])#', |
|
| 2942 | - // Remove empty selector(s) |
|
| 2943 | - '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s' |
|
| 2944 | - ), |
|
| 2945 | - array( |
|
| 2946 | - '$1', |
|
| 2947 | - '$1$2$3$4$5$6$7', |
|
| 2948 | - '$1', |
|
| 2949 | - ':0', |
|
| 2950 | - '$1:0 0', |
|
| 2951 | - '.$1', |
|
| 2952 | - '$1$3', |
|
| 2953 | - '$1$2$4$5', |
|
| 2954 | - '$1$2$3', |
|
| 2955 | - '$1:0', |
|
| 2956 | - '$1$2' |
|
| 2957 | - ), |
|
| 2958 | - $input); |
|
| 2959 | - } |
|
| 2960 | - |
|
| 2961 | - /** |
|
| 2962 | - * Get the conditional fields JavaScript. |
|
| 2963 | - * |
|
| 2964 | - * @return mixed |
|
| 2965 | - */ |
|
| 2966 | - public function conditional_fields_js() { |
|
| 2967 | - ob_start(); |
|
| 2968 | - ?> |
|
| 2872 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2873 | + } |
|
| 2874 | + |
|
| 2875 | + $locale = json_encode( $params ); |
|
| 2876 | + |
|
| 2877 | + return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) ); |
|
| 2878 | + } |
|
| 2879 | + |
|
| 2880 | + /** |
|
| 2881 | + * JavaScript Minifier |
|
| 2882 | + * |
|
| 2883 | + * @param $input |
|
| 2884 | + * |
|
| 2885 | + * @return mixed |
|
| 2886 | + */ |
|
| 2887 | + public static function minify_js($input) { |
|
| 2888 | + if(trim($input) === "") return $input; |
|
| 2889 | + return preg_replace( |
|
| 2890 | + array( |
|
| 2891 | + // Remove comment(s) |
|
| 2892 | + '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#', |
|
| 2893 | + // Remove white-space(s) outside the string and regex |
|
| 2894 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s', |
|
| 2895 | + // Remove the last semicolon |
|
| 2896 | + '#;+\}#', |
|
| 2897 | + // Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}` |
|
| 2898 | + '#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i', |
|
| 2899 | + // --ibid. From `foo['bar']` to `foo.bar` |
|
| 2900 | + '#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i' |
|
| 2901 | + ), |
|
| 2902 | + array( |
|
| 2903 | + '$1', |
|
| 2904 | + '$1$2', |
|
| 2905 | + '}', |
|
| 2906 | + '$1$3', |
|
| 2907 | + '$1.$3' |
|
| 2908 | + ), |
|
| 2909 | + $input); |
|
| 2910 | + } |
|
| 2911 | + |
|
| 2912 | + /** |
|
| 2913 | + * Minify CSS |
|
| 2914 | + * |
|
| 2915 | + * @param $input |
|
| 2916 | + * |
|
| 2917 | + * @return mixed |
|
| 2918 | + */ |
|
| 2919 | + public static function minify_css($input) { |
|
| 2920 | + if(trim($input) === "") return $input; |
|
| 2921 | + return preg_replace( |
|
| 2922 | + array( |
|
| 2923 | + // Remove comment(s) |
|
| 2924 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s', |
|
| 2925 | + // Remove unused white-space(s) |
|
| 2926 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si', |
|
| 2927 | + // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0` |
|
| 2928 | + '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si', |
|
| 2929 | + // Replace `:0 0 0 0` with `:0` |
|
| 2930 | + '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i', |
|
| 2931 | + // Replace `background-position:0` with `background-position:0 0` |
|
| 2932 | + '#(background-position):0(?=[;\}])#si', |
|
| 2933 | + // Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space |
|
| 2934 | + '#(?<=[\s:,\-])0+\.(\d+)#s', |
|
| 2935 | + // Minify string value |
|
| 2936 | + '#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si', |
|
| 2937 | + '#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si', |
|
| 2938 | + // Minify HEX color code |
|
| 2939 | + '#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i', |
|
| 2940 | + // Replace `(border|outline):none` with `(border|outline):0` |
|
| 2941 | + '#(?<=[\{;])(border|outline):none(?=[;\}\!])#', |
|
| 2942 | + // Remove empty selector(s) |
|
| 2943 | + '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s' |
|
| 2944 | + ), |
|
| 2945 | + array( |
|
| 2946 | + '$1', |
|
| 2947 | + '$1$2$3$4$5$6$7', |
|
| 2948 | + '$1', |
|
| 2949 | + ':0', |
|
| 2950 | + '$1:0 0', |
|
| 2951 | + '.$1', |
|
| 2952 | + '$1$3', |
|
| 2953 | + '$1$2$4$5', |
|
| 2954 | + '$1$2$3', |
|
| 2955 | + '$1:0', |
|
| 2956 | + '$1$2' |
|
| 2957 | + ), |
|
| 2958 | + $input); |
|
| 2959 | + } |
|
| 2960 | + |
|
| 2961 | + /** |
|
| 2962 | + * Get the conditional fields JavaScript. |
|
| 2963 | + * |
|
| 2964 | + * @return mixed |
|
| 2965 | + */ |
|
| 2966 | + public function conditional_fields_js() { |
|
| 2967 | + ob_start(); |
|
| 2968 | + ?> |
|
| 2969 | 2969 | <script> |
| 2970 | 2970 | /** |
| 2971 | 2971 | * Conditional Fields |
@@ -3468,14 +3468,14 @@ discard block |
||
| 3468 | 3468 | <?php do_action( 'aui_conditional_fields_js', $this ); ?> |
| 3469 | 3469 | </script> |
| 3470 | 3470 | <?php |
| 3471 | - $output = ob_get_clean(); |
|
| 3471 | + $output = ob_get_clean(); |
|
| 3472 | 3472 | |
| 3473 | - return str_replace( array( '<script>', '</script>' ), '', self::minify_js( $output ) ); |
|
| 3474 | - } |
|
| 3475 | - } |
|
| 3473 | + return str_replace( array( '<script>', '</script>' ), '', self::minify_js( $output ) ); |
|
| 3474 | + } |
|
| 3475 | + } |
|
| 3476 | 3476 | |
| 3477 | - /** |
|
| 3478 | - * Run the class if found. |
|
| 3479 | - */ |
|
| 3480 | - AyeCode_UI_Settings::instance(); |
|
| 3477 | + /** |
|
| 3478 | + * Run the class if found. |
|
| 3479 | + */ |
|
| 3480 | + AyeCode_UI_Settings::instance(); |
|
| 3481 | 3481 | } |
| 3482 | 3482 | \ No newline at end of file |
@@ -7,40 +7,40 @@ |
||
| 7 | 7 | * Bail if we are not in WP. |
| 8 | 8 | */ |
| 9 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 10 | - exit; |
|
| 10 | + exit; |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * Set the version only if its the current newest while loading. |
| 15 | 15 | */ |
| 16 | 16 | add_action('after_setup_theme', function () { |
| 17 | - global $ayecode_ui_version,$ayecode_ui_file_key; |
|
| 18 | - $this_version = "0.1.83"; |
|
| 19 | - if(empty($ayecode_ui_version) || version_compare($this_version , $ayecode_ui_version, '>')){ |
|
| 20 | - $ayecode_ui_version = $this_version ; |
|
| 21 | - $ayecode_ui_file_key = wp_hash( __FILE__ ); |
|
| 22 | - } |
|
| 17 | + global $ayecode_ui_version,$ayecode_ui_file_key; |
|
| 18 | + $this_version = "0.1.83"; |
|
| 19 | + if(empty($ayecode_ui_version) || version_compare($this_version , $ayecode_ui_version, '>')){ |
|
| 20 | + $ayecode_ui_version = $this_version ; |
|
| 21 | + $ayecode_ui_file_key = wp_hash( __FILE__ ); |
|
| 22 | + } |
|
| 23 | 23 | },0); |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Load this version of WP Bootstrap Settings only if the file hash is the current one. |
| 27 | 27 | */ |
| 28 | 28 | add_action('after_setup_theme', function () { |
| 29 | - global $ayecode_ui_file_key; |
|
| 30 | - if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){ |
|
| 31 | - include_once( dirname( __FILE__ ) . '/includes/class-aui.php' ); |
|
| 32 | - include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' ); |
|
| 33 | - } |
|
| 29 | + global $ayecode_ui_file_key; |
|
| 30 | + if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){ |
|
| 31 | + include_once( dirname( __FILE__ ) . '/includes/class-aui.php' ); |
|
| 32 | + include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' ); |
|
| 33 | + } |
|
| 34 | 34 | },1); |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * Add the function that calls the class. |
| 38 | 38 | */ |
| 39 | 39 | if(!function_exists('aui')){ |
| 40 | - function aui(){ |
|
| 41 | - if(!class_exists("AUI",false)){ |
|
| 42 | - return false; |
|
| 43 | - } |
|
| 44 | - return AUI::instance(); |
|
| 45 | - } |
|
| 40 | + function aui(){ |
|
| 41 | + if(!class_exists("AUI",false)){ |
|
| 42 | + return false; |
|
| 43 | + } |
|
| 44 | + return AUI::instance(); |
|
| 45 | + } |
|
| 46 | 46 | } |
@@ -1,60 +1,60 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | - exit; |
|
| 3 | + exit; |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | if ( ! class_exists( 'WP_Super_Duper' ) ) { |
| 7 | 7 | |
| 8 | - define( 'SUPER_DUPER_VER', '1.1.9' ); |
|
| 9 | - |
|
| 10 | - /** |
|
| 11 | - * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress. |
|
| 12 | - * |
|
| 13 | - * Should not be called direct but extended instead. |
|
| 14 | - * |
|
| 15 | - * Class WP_Super_Duper |
|
| 16 | - * @since 1.0.16 change log moved to file change-log.txt - CHANGED |
|
| 17 | - * @ver 1.1.1 |
|
| 18 | - */ |
|
| 19 | - class WP_Super_Duper extends WP_Widget { |
|
| 20 | - |
|
| 21 | - public $version = SUPER_DUPER_VER; |
|
| 22 | - public $font_awesome_icon_version = "5.11.2"; |
|
| 23 | - public $block_code; |
|
| 24 | - public $options; |
|
| 25 | - public $base_id; |
|
| 26 | - public $settings_hash; |
|
| 27 | - public $arguments = array(); |
|
| 28 | - public $instance = array(); |
|
| 29 | - private $class_name; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * The relative url to the current folder. |
|
| 33 | - * |
|
| 34 | - * @var string |
|
| 35 | - */ |
|
| 36 | - public $url = ''; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * Take the array options and use them to build. |
|
| 40 | - */ |
|
| 41 | - public function __construct( $options ) { |
|
| 42 | - global $sd_widgets; |
|
| 43 | - |
|
| 44 | - $sd_widgets[ $options['base_id'] ] = array( |
|
| 45 | - 'name' => $options['name'], |
|
| 46 | - 'class_name' => $options['class_name'], |
|
| 47 | - 'output_types' => !empty($options['output_types']) ? $options['output_types'] : array() |
|
| 48 | - ); |
|
| 49 | - $this->base_id = $options['base_id']; |
|
| 50 | - // lets filter the options before we do anything |
|
| 51 | - $options = apply_filters( "wp_super_duper_options", $options ); |
|
| 52 | - $options = apply_filters( "wp_super_duper_options_{$this->base_id}", $options ); |
|
| 53 | - $options = $this->add_name_from_key( $options ); |
|
| 54 | - $this->options = $options; |
|
| 55 | - |
|
| 56 | - $this->base_id = $options['base_id']; |
|
| 57 | - $this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array(); |
|
| 8 | + define( 'SUPER_DUPER_VER', '1.1.9' ); |
|
| 9 | + |
|
| 10 | + /** |
|
| 11 | + * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress. |
|
| 12 | + * |
|
| 13 | + * Should not be called direct but extended instead. |
|
| 14 | + * |
|
| 15 | + * Class WP_Super_Duper |
|
| 16 | + * @since 1.0.16 change log moved to file change-log.txt - CHANGED |
|
| 17 | + * @ver 1.1.1 |
|
| 18 | + */ |
|
| 19 | + class WP_Super_Duper extends WP_Widget { |
|
| 20 | + |
|
| 21 | + public $version = SUPER_DUPER_VER; |
|
| 22 | + public $font_awesome_icon_version = "5.11.2"; |
|
| 23 | + public $block_code; |
|
| 24 | + public $options; |
|
| 25 | + public $base_id; |
|
| 26 | + public $settings_hash; |
|
| 27 | + public $arguments = array(); |
|
| 28 | + public $instance = array(); |
|
| 29 | + private $class_name; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * The relative url to the current folder. |
|
| 33 | + * |
|
| 34 | + * @var string |
|
| 35 | + */ |
|
| 36 | + public $url = ''; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * Take the array options and use them to build. |
|
| 40 | + */ |
|
| 41 | + public function __construct( $options ) { |
|
| 42 | + global $sd_widgets; |
|
| 43 | + |
|
| 44 | + $sd_widgets[ $options['base_id'] ] = array( |
|
| 45 | + 'name' => $options['name'], |
|
| 46 | + 'class_name' => $options['class_name'], |
|
| 47 | + 'output_types' => !empty($options['output_types']) ? $options['output_types'] : array() |
|
| 48 | + ); |
|
| 49 | + $this->base_id = $options['base_id']; |
|
| 50 | + // lets filter the options before we do anything |
|
| 51 | + $options = apply_filters( "wp_super_duper_options", $options ); |
|
| 52 | + $options = apply_filters( "wp_super_duper_options_{$this->base_id}", $options ); |
|
| 53 | + $options = $this->add_name_from_key( $options ); |
|
| 54 | + $this->options = $options; |
|
| 55 | + |
|
| 56 | + $this->base_id = $options['base_id']; |
|
| 57 | + $this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array(); |
|
| 58 | 58 | |
| 59 | 59 | // nested blocks can't work as a widget |
| 60 | 60 | if(!empty($this->options['nested-block'])){ |
@@ -65,234 +65,234 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - // init parent |
|
| 69 | - if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){ |
|
| 68 | + // init parent |
|
| 69 | + if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){ |
|
| 70 | 70 | parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] ); |
| 71 | - } |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | 73 | |
| 74 | - if ( isset( $options['class_name'] ) ) { |
|
| 75 | - // register widget |
|
| 76 | - $this->class_name = $options['class_name']; |
|
| 74 | + if ( isset( $options['class_name'] ) ) { |
|
| 75 | + // register widget |
|
| 76 | + $this->class_name = $options['class_name']; |
|
| 77 | 77 | |
| 78 | - // register shortcode, this needs to be done even for blocks and widgets |
|
| 78 | + // register shortcode, this needs to be done even for blocks and widgets |
|
| 79 | 79 | $this->register_shortcode(); |
| 80 | 80 | |
| 81 | 81 | |
| 82 | - // Fusion Builder (avada) support |
|
| 83 | - if ( function_exists( 'fusion_builder_map' ) ) { |
|
| 84 | - add_action( 'init', array( $this, 'register_fusion_element' ) ); |
|
| 85 | - } |
|
| 82 | + // Fusion Builder (avada) support |
|
| 83 | + if ( function_exists( 'fusion_builder_map' ) ) { |
|
| 84 | + add_action( 'init', array( $this, 'register_fusion_element' ) ); |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - // register block |
|
| 88 | - if(empty($this->options['output_types']) || in_array('block',$this->options['output_types'])){ |
|
| 89 | - add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) ); |
|
| 87 | + // register block |
|
| 88 | + if(empty($this->options['output_types']) || in_array('block',$this->options['output_types'])){ |
|
| 89 | + add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) ); |
|
| 90 | 90 | } |
| 91 | - } |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - // add the CSS and JS we need ONCE |
|
| 94 | - global $sd_widget_scripts; |
|
| 93 | + // add the CSS and JS we need ONCE |
|
| 94 | + global $sd_widget_scripts; |
|
| 95 | 95 | |
| 96 | - if ( ! $sd_widget_scripts ) { |
|
| 97 | - wp_add_inline_script( 'admin-widgets', $this->widget_js() ); |
|
| 98 | - wp_add_inline_script( 'customize-controls', $this->widget_js() ); |
|
| 99 | - wp_add_inline_style( 'widgets', $this->widget_css() ); |
|
| 96 | + if ( ! $sd_widget_scripts ) { |
|
| 97 | + wp_add_inline_script( 'admin-widgets', $this->widget_js() ); |
|
| 98 | + wp_add_inline_script( 'customize-controls', $this->widget_js() ); |
|
| 99 | + wp_add_inline_style( 'widgets', $this->widget_css() ); |
|
| 100 | 100 | |
| 101 | - // maybe add elementor editor styles |
|
| 102 | - add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'elementor_editor_styles' ) ); |
|
| 101 | + // maybe add elementor editor styles |
|
| 102 | + add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'elementor_editor_styles' ) ); |
|
| 103 | 103 | |
| 104 | - $sd_widget_scripts = true; |
|
| 104 | + $sd_widget_scripts = true; |
|
| 105 | 105 | |
| 106 | - // add shortcode insert button once |
|
| 107 | - add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) ); |
|
| 108 | - // generatepress theme sections compatibility |
|
| 109 | - if ( function_exists( 'generate_sections_sections_metabox' ) ) { |
|
| 110 | - add_action( 'generate_sections_metabox', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 111 | - } |
|
| 112 | - /* Load script on Divi theme builder page */ |
|
| 113 | - if ( function_exists( 'et_builder_is_tb_admin_screen' ) && et_builder_is_tb_admin_screen() ) { |
|
| 114 | - add_thickbox(); |
|
| 115 | - add_action( 'admin_footer', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 116 | - } |
|
| 106 | + // add shortcode insert button once |
|
| 107 | + add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) ); |
|
| 108 | + // generatepress theme sections compatibility |
|
| 109 | + if ( function_exists( 'generate_sections_sections_metabox' ) ) { |
|
| 110 | + add_action( 'generate_sections_metabox', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 111 | + } |
|
| 112 | + /* Load script on Divi theme builder page */ |
|
| 113 | + if ( function_exists( 'et_builder_is_tb_admin_screen' ) && et_builder_is_tb_admin_screen() ) { |
|
| 114 | + add_thickbox(); |
|
| 115 | + add_action( 'admin_footer', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - if ( $this->is_preview() ) { |
|
| 119 | - add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 120 | - // this makes the insert button work for elementor |
|
| 121 | - add_action( 'elementor/editor/after_enqueue_scripts', array( |
|
| 122 | - $this, |
|
| 123 | - 'shortcode_insert_button_script' |
|
| 124 | - ) ); // for elementor |
|
| 125 | - } |
|
| 126 | - // this makes the insert button work for cornerstone |
|
| 127 | - add_action( 'wp_print_footer_scripts', array( __CLASS__, 'maybe_cornerstone_builder' ) ); |
|
| 118 | + if ( $this->is_preview() ) { |
|
| 119 | + add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 120 | + // this makes the insert button work for elementor |
|
| 121 | + add_action( 'elementor/editor/after_enqueue_scripts', array( |
|
| 122 | + $this, |
|
| 123 | + 'shortcode_insert_button_script' |
|
| 124 | + ) ); // for elementor |
|
| 125 | + } |
|
| 126 | + // this makes the insert button work for cornerstone |
|
| 127 | + add_action( 'wp_print_footer_scripts', array( __CLASS__, 'maybe_cornerstone_builder' ) ); |
|
| 128 | 128 | |
| 129 | - add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) ); |
|
| 130 | - add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) ); |
|
| 129 | + add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) ); |
|
| 130 | + add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) ); |
|
| 131 | 131 | |
| 132 | - // add generator text to admin head |
|
| 133 | - add_action( 'admin_head', array( $this, 'generator' ) ); |
|
| 134 | - } |
|
| 132 | + // add generator text to admin head |
|
| 133 | + add_action( 'admin_head', array( $this, 'generator' ) ); |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | - do_action( 'wp_super_duper_widget_init', $options, $this ); |
|
| 137 | - } |
|
| 136 | + do_action( 'wp_super_duper_widget_init', $options, $this ); |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | 139 | /** |
| 140 | 140 | * The register widget function |
| 141 | 141 | * @return void |
| 142 | 142 | */ |
| 143 | - public function _register() { |
|
| 143 | + public function _register() { |
|
| 144 | 144 | if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){ |
| 145 | 145 | parent::_register(); |
| 146 | - } |
|
| 147 | - } |
|
| 146 | + } |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - /** |
|
| 150 | - * Add our widget CSS to elementor editor. |
|
| 151 | - */ |
|
| 152 | - public function elementor_editor_styles() { |
|
| 153 | - wp_add_inline_style( 'elementor-editor', $this->widget_css( false ) ); |
|
| 154 | - } |
|
| 149 | + /** |
|
| 150 | + * Add our widget CSS to elementor editor. |
|
| 151 | + */ |
|
| 152 | + public function elementor_editor_styles() { |
|
| 153 | + wp_add_inline_style( 'elementor-editor', $this->widget_css( false ) ); |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - public function register_fusion_element() { |
|
| 156 | + public function register_fusion_element() { |
|
| 157 | 157 | |
| 158 | - $options = $this->options; |
|
| 158 | + $options = $this->options; |
|
| 159 | 159 | |
| 160 | - if ( $this->base_id ) { |
|
| 160 | + if ( $this->base_id ) { |
|
| 161 | 161 | |
| 162 | - $params = $this->get_fusion_params(); |
|
| 162 | + $params = $this->get_fusion_params(); |
|
| 163 | 163 | |
| 164 | - $args = array( |
|
| 165 | - 'name' => $options['name'], |
|
| 166 | - 'shortcode' => $this->base_id, |
|
| 167 | - 'icon' => $options['block-icon'] ? $options['block-icon'] : 'far fa-square', |
|
| 168 | - 'allow_generator' => true, |
|
| 169 | - ); |
|
| 164 | + $args = array( |
|
| 165 | + 'name' => $options['name'], |
|
| 166 | + 'shortcode' => $this->base_id, |
|
| 167 | + 'icon' => $options['block-icon'] ? $options['block-icon'] : 'far fa-square', |
|
| 168 | + 'allow_generator' => true, |
|
| 169 | + ); |
|
| 170 | 170 | |
| 171 | - if ( ! empty( $params ) ) { |
|
| 172 | - $args['params'] = $params; |
|
| 173 | - } |
|
| 171 | + if ( ! empty( $params ) ) { |
|
| 172 | + $args['params'] = $params; |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | - fusion_builder_map( $args ); |
|
| 176 | - } |
|
| 175 | + fusion_builder_map( $args ); |
|
| 176 | + } |
|
| 177 | 177 | |
| 178 | - } |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | - public function get_fusion_params() { |
|
| 181 | - $params = array(); |
|
| 182 | - $arguments = $this->get_arguments(); |
|
| 183 | - |
|
| 184 | - if ( ! empty( $arguments ) ) { |
|
| 185 | - foreach ( $arguments as $key => $val ) { |
|
| 186 | - $param = array(); |
|
| 187 | - // type |
|
| 188 | - $param['type'] = str_replace( |
|
| 189 | - array( |
|
| 190 | - "text", |
|
| 191 | - "number", |
|
| 192 | - "email", |
|
| 193 | - "color", |
|
| 194 | - "checkbox" |
|
| 195 | - ), |
|
| 196 | - array( |
|
| 197 | - "textfield", |
|
| 198 | - "textfield", |
|
| 199 | - "textfield", |
|
| 200 | - "colorpicker", |
|
| 201 | - "select", |
|
| 202 | - |
|
| 203 | - ), |
|
| 204 | - $val['type'] ); |
|
| 205 | - |
|
| 206 | - // multiselect |
|
| 207 | - if ( $val['type'] == 'multiselect' || ( ( $param['type'] == 'select' || $val['type'] == 'select' ) && ! empty( $val['multiple'] ) ) ) { |
|
| 208 | - $param['type'] = 'multiple_select'; |
|
| 209 | - $param['multiple'] = true; |
|
| 210 | - } |
|
| 180 | + public function get_fusion_params() { |
|
| 181 | + $params = array(); |
|
| 182 | + $arguments = $this->get_arguments(); |
|
| 183 | + |
|
| 184 | + if ( ! empty( $arguments ) ) { |
|
| 185 | + foreach ( $arguments as $key => $val ) { |
|
| 186 | + $param = array(); |
|
| 187 | + // type |
|
| 188 | + $param['type'] = str_replace( |
|
| 189 | + array( |
|
| 190 | + "text", |
|
| 191 | + "number", |
|
| 192 | + "email", |
|
| 193 | + "color", |
|
| 194 | + "checkbox" |
|
| 195 | + ), |
|
| 196 | + array( |
|
| 197 | + "textfield", |
|
| 198 | + "textfield", |
|
| 199 | + "textfield", |
|
| 200 | + "colorpicker", |
|
| 201 | + "select", |
|
| 211 | 202 | |
| 212 | - // heading |
|
| 213 | - $param['heading'] = $val['title']; |
|
| 203 | + ), |
|
| 204 | + $val['type'] ); |
|
| 214 | 205 | |
| 215 | - // description |
|
| 216 | - $param['description'] = isset( $val['desc'] ) ? $val['desc'] : ''; |
|
| 206 | + // multiselect |
|
| 207 | + if ( $val['type'] == 'multiselect' || ( ( $param['type'] == 'select' || $val['type'] == 'select' ) && ! empty( $val['multiple'] ) ) ) { |
|
| 208 | + $param['type'] = 'multiple_select'; |
|
| 209 | + $param['multiple'] = true; |
|
| 210 | + } |
|
| 217 | 211 | |
| 218 | - // param_name |
|
| 219 | - $param['param_name'] = $key; |
|
| 212 | + // heading |
|
| 213 | + $param['heading'] = $val['title']; |
|
| 220 | 214 | |
| 221 | - // Default |
|
| 222 | - $param['default'] = isset( $val['default'] ) ? $val['default'] : ''; |
|
| 215 | + // description |
|
| 216 | + $param['description'] = isset( $val['desc'] ) ? $val['desc'] : ''; |
|
| 223 | 217 | |
| 224 | - // Group |
|
| 225 | - if ( isset( $val['group'] ) ) { |
|
| 226 | - $param['group'] = $val['group']; |
|
| 227 | - } |
|
| 218 | + // param_name |
|
| 219 | + $param['param_name'] = $key; |
|
| 228 | 220 | |
| 229 | - // value |
|
| 230 | - if ( $val['type'] == 'checkbox' ) { |
|
| 231 | - if ( isset( $val['default'] ) && $val['default'] == '0' ) { |
|
| 232 | - unset( $param['default'] ); |
|
| 233 | - } |
|
| 234 | - $param['value'] = array( '' => __( "No" ), '1' => __( "Yes" ) ); |
|
| 235 | - } elseif ( $param['type'] == 'select' || $param['type'] == 'multiple_select' ) { |
|
| 236 | - $param['value'] = isset( $val['options'] ) ? $val['options'] : array(); |
|
| 237 | - } else { |
|
| 238 | - $param['value'] = isset( $val['default'] ) ? $val['default'] : ''; |
|
| 239 | - } |
|
| 221 | + // Default |
|
| 222 | + $param['default'] = isset( $val['default'] ) ? $val['default'] : ''; |
|
| 240 | 223 | |
| 241 | - // setup the param |
|
| 242 | - $params[] = $param; |
|
| 224 | + // Group |
|
| 225 | + if ( isset( $val['group'] ) ) { |
|
| 226 | + $param['group'] = $val['group']; |
|
| 227 | + } |
|
| 243 | 228 | |
| 244 | - } |
|
| 245 | - } |
|
| 229 | + // value |
|
| 230 | + if ( $val['type'] == 'checkbox' ) { |
|
| 231 | + if ( isset( $val['default'] ) && $val['default'] == '0' ) { |
|
| 232 | + unset( $param['default'] ); |
|
| 233 | + } |
|
| 234 | + $param['value'] = array( '' => __( "No" ), '1' => __( "Yes" ) ); |
|
| 235 | + } elseif ( $param['type'] == 'select' || $param['type'] == 'multiple_select' ) { |
|
| 236 | + $param['value'] = isset( $val['options'] ) ? $val['options'] : array(); |
|
| 237 | + } else { |
|
| 238 | + $param['value'] = isset( $val['default'] ) ? $val['default'] : ''; |
|
| 239 | + } |
|
| 246 | 240 | |
| 241 | + // setup the param |
|
| 242 | + $params[] = $param; |
|
| 247 | 243 | |
| 248 | - return $params; |
|
| 249 | - } |
|
| 244 | + } |
|
| 245 | + } |
|
| 250 | 246 | |
| 251 | - /** |
|
| 252 | - * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder |
|
| 253 | - */ |
|
| 254 | - public static function maybe_cornerstone_builder() { |
|
| 255 | - if ( did_action( 'cornerstone_before_boot_app' ) ) { |
|
| 256 | - self::shortcode_insert_button_script(); |
|
| 257 | - } |
|
| 258 | - } |
|
| 259 | 247 | |
| 260 | - /** |
|
| 261 | - * A function to ge the shortcode builder picker html. |
|
| 262 | - * |
|
| 263 | - * @param string $editor_id |
|
| 264 | - * |
|
| 265 | - * @return string |
|
| 266 | - */ |
|
| 267 | - public static function get_picker( $editor_id = '' ) { |
|
| 268 | - |
|
| 269 | - ob_start(); |
|
| 270 | - if ( isset( $_POST['editor_id'] ) ) { |
|
| 271 | - $editor_id = esc_attr( $_POST['editor_id'] ); |
|
| 272 | - } elseif ( isset( $_REQUEST['et_fb'] ) ) { |
|
| 273 | - $editor_id = 'main_content_content_vb_tiny_mce'; |
|
| 274 | - } |
|
| 248 | + return $params; |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + /** |
|
| 252 | + * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder |
|
| 253 | + */ |
|
| 254 | + public static function maybe_cornerstone_builder() { |
|
| 255 | + if ( did_action( 'cornerstone_before_boot_app' ) ) { |
|
| 256 | + self::shortcode_insert_button_script(); |
|
| 257 | + } |
|
| 258 | + } |
|
| 259 | + |
|
| 260 | + /** |
|
| 261 | + * A function to ge the shortcode builder picker html. |
|
| 262 | + * |
|
| 263 | + * @param string $editor_id |
|
| 264 | + * |
|
| 265 | + * @return string |
|
| 266 | + */ |
|
| 267 | + public static function get_picker( $editor_id = '' ) { |
|
| 268 | + |
|
| 269 | + ob_start(); |
|
| 270 | + if ( isset( $_POST['editor_id'] ) ) { |
|
| 271 | + $editor_id = esc_attr( $_POST['editor_id'] ); |
|
| 272 | + } elseif ( isset( $_REQUEST['et_fb'] ) ) { |
|
| 273 | + $editor_id = 'main_content_content_vb_tiny_mce'; |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | - global $sd_widgets; |
|
| 276 | + global $sd_widgets; |
|
| 277 | 277 | |
| 278 | 278 | // print_r($sd_widgets);exit; |
| 279 | - ?> |
|
| 279 | + ?> |
|
| 280 | 280 | |
| 281 | 281 | <div class="sd-shortcode-left-wrap"> |
| 282 | 282 | <?php |
| 283 | - ksort( $sd_widgets ); |
|
| 284 | - // print_r($sd_widgets);exit; |
|
| 285 | - if ( ! empty( $sd_widgets ) ) { |
|
| 286 | - echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">'; |
|
| 287 | - echo "<option>" . __( 'Select shortcode' ) . "</option>"; |
|
| 288 | - foreach ( $sd_widgets as $shortcode => $class ) { |
|
| 289 | - if(!empty($class['output_types']) && !in_array('shortcode', $class['output_types'])){ continue; } |
|
| 290 | - echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>"; |
|
| 291 | - } |
|
| 292 | - echo "</select>"; |
|
| 283 | + ksort( $sd_widgets ); |
|
| 284 | + // print_r($sd_widgets);exit; |
|
| 285 | + if ( ! empty( $sd_widgets ) ) { |
|
| 286 | + echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">'; |
|
| 287 | + echo "<option>" . __( 'Select shortcode' ) . "</option>"; |
|
| 288 | + foreach ( $sd_widgets as $shortcode => $class ) { |
|
| 289 | + if(!empty($class['output_types']) && !in_array('shortcode', $class['output_types'])){ continue; } |
|
| 290 | + echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>"; |
|
| 291 | + } |
|
| 292 | + echo "</select>"; |
|
| 293 | 293 | |
| 294 | - } |
|
| 295 | - ?> |
|
| 294 | + } |
|
| 295 | + ?> |
|
| 296 | 296 | <div class="sd-shortcode-settings"></div> |
| 297 | 297 | |
| 298 | 298 | </div> |
@@ -303,8 +303,8 @@ discard block |
||
| 303 | 303 | <?php if ( $editor_id != '' ) { ?> |
| 304 | 304 | <button class="button sd-insert-shortcode-button" |
| 305 | 305 | onclick="sd_insert_shortcode(<?php if ( ! empty( $editor_id ) ) { |
| 306 | - echo "'" . $editor_id . "'"; |
|
| 307 | - } ?>)"><?php _e( 'Insert shortcode' ); ?></button> |
|
| 306 | + echo "'" . $editor_id . "'"; |
|
| 307 | + } ?>)"><?php _e( 'Insert shortcode' ); ?></button> |
|
| 308 | 308 | <?php } ?> |
| 309 | 309 | <button class="button" |
| 310 | 310 | onclick="sd_copy_to_clipboard()"><?php _e( 'Copy shortcode' ); ?></button> |
@@ -312,135 +312,135 @@ discard block |
||
| 312 | 312 | </div> |
| 313 | 313 | <?php |
| 314 | 314 | |
| 315 | - $html = ob_get_clean(); |
|
| 315 | + $html = ob_get_clean(); |
|
| 316 | 316 | |
| 317 | - if ( wp_doing_ajax() ) { |
|
| 318 | - echo $html; |
|
| 319 | - $should_die = true; |
|
| 317 | + if ( wp_doing_ajax() ) { |
|
| 318 | + echo $html; |
|
| 319 | + $should_die = true; |
|
| 320 | 320 | |
| 321 | - // some builder get the editor via ajax so we should not die on those occasions |
|
| 322 | - $dont_die = array( |
|
| 323 | - 'parent_tag',// WP Bakery |
|
| 324 | - 'avia_request' // enfold |
|
| 325 | - ); |
|
| 321 | + // some builder get the editor via ajax so we should not die on those occasions |
|
| 322 | + $dont_die = array( |
|
| 323 | + 'parent_tag',// WP Bakery |
|
| 324 | + 'avia_request' // enfold |
|
| 325 | + ); |
|
| 326 | 326 | |
| 327 | - foreach ( $dont_die as $request ) { |
|
| 328 | - if ( isset( $_REQUEST[ $request ] ) ) { |
|
| 329 | - $should_die = false; |
|
| 330 | - } |
|
| 331 | - } |
|
| 327 | + foreach ( $dont_die as $request ) { |
|
| 328 | + if ( isset( $_REQUEST[ $request ] ) ) { |
|
| 329 | + $should_die = false; |
|
| 330 | + } |
|
| 331 | + } |
|
| 332 | 332 | |
| 333 | - if ( $should_die ) { |
|
| 334 | - wp_die(); |
|
| 335 | - } |
|
| 333 | + if ( $should_die ) { |
|
| 334 | + wp_die(); |
|
| 335 | + } |
|
| 336 | 336 | |
| 337 | - } else { |
|
| 338 | - return $html; |
|
| 339 | - } |
|
| 337 | + } else { |
|
| 338 | + return $html; |
|
| 339 | + } |
|
| 340 | 340 | |
| 341 | - return ''; |
|
| 341 | + return ''; |
|
| 342 | 342 | |
| 343 | - } |
|
| 343 | + } |
|
| 344 | 344 | |
| 345 | - /** |
|
| 346 | - * Output the version in the admin header. |
|
| 347 | - */ |
|
| 348 | - public function generator() { |
|
| 349 | - echo '<meta name="generator" content="WP Super Duper v' . $this->version . '" />'; |
|
| 350 | - } |
|
| 345 | + /** |
|
| 346 | + * Output the version in the admin header. |
|
| 347 | + */ |
|
| 348 | + public function generator() { |
|
| 349 | + echo '<meta name="generator" content="WP Super Duper v' . $this->version . '" />'; |
|
| 350 | + } |
|
| 351 | 351 | |
| 352 | - /** |
|
| 353 | - * Get widget settings. |
|
| 354 | - * |
|
| 355 | - * @since 1.0.0 |
|
| 356 | - */ |
|
| 357 | - public static function get_widget_settings() { |
|
| 358 | - global $sd_widgets; |
|
| 359 | - |
|
| 360 | - $shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : ''; |
|
| 361 | - if ( ! $shortcode ) { |
|
| 362 | - wp_die(); |
|
| 363 | - } |
|
| 364 | - $widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : ''; |
|
| 365 | - if ( ! $widget_args ) { |
|
| 366 | - wp_die(); |
|
| 367 | - } |
|
| 368 | - $class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : ''; |
|
| 369 | - if ( ! $class_name ) { |
|
| 370 | - wp_die(); |
|
| 371 | - } |
|
| 352 | + /** |
|
| 353 | + * Get widget settings. |
|
| 354 | + * |
|
| 355 | + * @since 1.0.0 |
|
| 356 | + */ |
|
| 357 | + public static function get_widget_settings() { |
|
| 358 | + global $sd_widgets; |
|
| 359 | + |
|
| 360 | + $shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : ''; |
|
| 361 | + if ( ! $shortcode ) { |
|
| 362 | + wp_die(); |
|
| 363 | + } |
|
| 364 | + $widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : ''; |
|
| 365 | + if ( ! $widget_args ) { |
|
| 366 | + wp_die(); |
|
| 367 | + } |
|
| 368 | + $class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : ''; |
|
| 369 | + if ( ! $class_name ) { |
|
| 370 | + wp_die(); |
|
| 371 | + } |
|
| 372 | 372 | |
| 373 | - // invoke an instance method |
|
| 374 | - $widget = new $class_name; |
|
| 373 | + // invoke an instance method |
|
| 374 | + $widget = new $class_name; |
|
| 375 | 375 | |
| 376 | - ob_start(); |
|
| 377 | - $widget->form( array() ); |
|
| 378 | - $form = ob_get_clean(); |
|
| 379 | - echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>"; |
|
| 380 | - echo "<style>" . $widget->widget_css() . "</style>"; |
|
| 381 | - echo "<script>" . $widget->widget_js() . "</script>"; |
|
| 382 | - ?> |
|
| 376 | + ob_start(); |
|
| 377 | + $widget->form( array() ); |
|
| 378 | + $form = ob_get_clean(); |
|
| 379 | + echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>"; |
|
| 380 | + echo "<style>" . $widget->widget_css() . "</style>"; |
|
| 381 | + echo "<script>" . $widget->widget_js() . "</script>"; |
|
| 382 | + ?> |
|
| 383 | 383 | <?php |
| 384 | - wp_die(); |
|
| 385 | - } |
|
| 384 | + wp_die(); |
|
| 385 | + } |
|
| 386 | 386 | |
| 387 | - /** |
|
| 388 | - * Insert shortcode builder button to classic editor (not inside Gutenberg, not needed). |
|
| 389 | - * |
|
| 390 | - * @param string $editor_id Optional. Shortcode editor id. Default null. |
|
| 391 | - * @param string $insert_shortcode_function Optional. Insert shortcode function. Default null. |
|
| 392 | - * |
|
| 393 | - *@since 1.0.0 |
|
| 394 | - * |
|
| 395 | - */ |
|
| 396 | - public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) { |
|
| 397 | - global $sd_widgets, $shortcode_insert_button_once; |
|
| 398 | - if ( $shortcode_insert_button_once ) { |
|
| 399 | - return; |
|
| 400 | - } |
|
| 401 | - add_thickbox(); |
|
| 387 | + /** |
|
| 388 | + * Insert shortcode builder button to classic editor (not inside Gutenberg, not needed). |
|
| 389 | + * |
|
| 390 | + * @param string $editor_id Optional. Shortcode editor id. Default null. |
|
| 391 | + * @param string $insert_shortcode_function Optional. Insert shortcode function. Default null. |
|
| 392 | + * |
|
| 393 | + *@since 1.0.0 |
|
| 394 | + * |
|
| 395 | + */ |
|
| 396 | + public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) { |
|
| 397 | + global $sd_widgets, $shortcode_insert_button_once; |
|
| 398 | + if ( $shortcode_insert_button_once ) { |
|
| 399 | + return; |
|
| 400 | + } |
|
| 401 | + add_thickbox(); |
|
| 402 | 402 | |
| 403 | 403 | |
| 404 | - /** |
|
| 405 | - * Cornerstone makes us play dirty tricks :/ |
|
| 406 | - * All media_buttons are removed via JS unless they are two specific id's so we wrap our content in this ID so it is not removed. |
|
| 407 | - */ |
|
| 408 | - if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
| 409 | - echo '<span id="insert-media-button">'; |
|
| 410 | - } |
|
| 404 | + /** |
|
| 405 | + * Cornerstone makes us play dirty tricks :/ |
|
| 406 | + * All media_buttons are removed via JS unless they are two specific id's so we wrap our content in this ID so it is not removed. |
|
| 407 | + */ |
|
| 408 | + if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
| 409 | + echo '<span id="insert-media-button">'; |
|
| 410 | + } |
|
| 411 | 411 | |
| 412 | - echo self::shortcode_button( 'this', 'true' ); |
|
| 412 | + echo self::shortcode_button( 'this', 'true' ); |
|
| 413 | 413 | |
| 414 | - // see opening note |
|
| 415 | - if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
| 416 | - echo '</span>'; // end #insert-media-button |
|
| 417 | - } |
|
| 414 | + // see opening note |
|
| 415 | + if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
| 416 | + echo '</span>'; // end #insert-media-button |
|
| 417 | + } |
|
| 418 | 418 | |
| 419 | - // Add separate script for generatepress theme sections |
|
| 420 | - if ( function_exists( 'generate_sections_sections_metabox' ) && did_action( 'generate_sections_metabox' ) ) { |
|
| 421 | - } else { |
|
| 422 | - self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function ); |
|
| 423 | - } |
|
| 419 | + // Add separate script for generatepress theme sections |
|
| 420 | + if ( function_exists( 'generate_sections_sections_metabox' ) && did_action( 'generate_sections_metabox' ) ) { |
|
| 421 | + } else { |
|
| 422 | + self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function ); |
|
| 423 | + } |
|
| 424 | 424 | |
| 425 | - $shortcode_insert_button_once = true; |
|
| 426 | - } |
|
| 425 | + $shortcode_insert_button_once = true; |
|
| 426 | + } |
|
| 427 | 427 | |
| 428 | - /** |
|
| 429 | - * Gets the shortcode insert button html. |
|
| 430 | - * |
|
| 431 | - * @param string $id |
|
| 432 | - * @param string $search_for_id |
|
| 433 | - * |
|
| 434 | - * @return mixed |
|
| 435 | - */ |
|
| 436 | - public static function shortcode_button( $id = '', $search_for_id = '' ) { |
|
| 437 | - ob_start(); |
|
| 438 | - ?> |
|
| 428 | + /** |
|
| 429 | + * Gets the shortcode insert button html. |
|
| 430 | + * |
|
| 431 | + * @param string $id |
|
| 432 | + * @param string $search_for_id |
|
| 433 | + * |
|
| 434 | + * @return mixed |
|
| 435 | + */ |
|
| 436 | + public static function shortcode_button( $id = '', $search_for_id = '' ) { |
|
| 437 | + ob_start(); |
|
| 438 | + ?> |
|
| 439 | 439 | <span class="sd-lable-shortcode-inserter"> |
| 440 | 440 | <a onclick="sd_ajax_get_picker(<?php echo $id; |
| 441 | - if ( $search_for_id ) { |
|
| 442 | - echo "," . $search_for_id; |
|
| 443 | - } ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed" |
|
| 441 | + if ( $search_for_id ) { |
|
| 442 | + echo "," . $search_for_id; |
|
| 443 | + } ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed" |
|
| 444 | 444 | class="thickbox button super-duper-content-open" title="Add Shortcode"> |
| 445 | 445 | <span style="vertical-align: middle;line-height: 18px;font-size: 20px;" |
| 446 | 446 | class="dashicons dashicons-screenoptions"></span> |
@@ -451,21 +451,21 @@ discard block |
||
| 451 | 451 | </span> |
| 452 | 452 | |
| 453 | 453 | <?php |
| 454 | - $html = ob_get_clean(); |
|
| 454 | + $html = ob_get_clean(); |
|
| 455 | 455 | |
| 456 | - // remove line breaks so we can use it in js |
|
| 457 | - return preg_replace( "/\r|\n/", "", trim( $html ) ); |
|
| 458 | - } |
|
| 456 | + // remove line breaks so we can use it in js |
|
| 457 | + return preg_replace( "/\r|\n/", "", trim( $html ) ); |
|
| 458 | + } |
|
| 459 | 459 | |
| 460 | - /** |
|
| 461 | - * Makes SD work with the siteOrigin page builder. |
|
| 462 | - * |
|
| 463 | - * @return mixed |
|
| 464 | - *@since 1.0.6 |
|
| 465 | - */ |
|
| 466 | - public static function siteorigin_js() { |
|
| 467 | - ob_start(); |
|
| 468 | - ?> |
|
| 460 | + /** |
|
| 461 | + * Makes SD work with the siteOrigin page builder. |
|
| 462 | + * |
|
| 463 | + * @return mixed |
|
| 464 | + *@since 1.0.6 |
|
| 465 | + */ |
|
| 466 | + public static function siteorigin_js() { |
|
| 467 | + ob_start(); |
|
| 468 | + ?> |
|
| 469 | 469 | <script> |
| 470 | 470 | /** |
| 471 | 471 | * Check a form to see what items should be shown or hidden. |
@@ -541,29 +541,29 @@ discard block |
||
| 541 | 541 | }); |
| 542 | 542 | </script> |
| 543 | 543 | <?php |
| 544 | - $output = ob_get_clean(); |
|
| 544 | + $output = ob_get_clean(); |
|
| 545 | 545 | |
| 546 | - /* |
|
| 546 | + /* |
|
| 547 | 547 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 548 | 548 | */ |
| 549 | 549 | |
| 550 | - return str_replace( array( |
|
| 551 | - '<script>', |
|
| 552 | - '</script>' |
|
| 553 | - ), '', $output ); |
|
| 554 | - } |
|
| 550 | + return str_replace( array( |
|
| 551 | + '<script>', |
|
| 552 | + '</script>' |
|
| 553 | + ), '', $output ); |
|
| 554 | + } |
|
| 555 | 555 | |
| 556 | - /** |
|
| 557 | - * Output the JS and CSS for the shortcode insert button. |
|
| 558 | - * |
|
| 559 | - * @param string $editor_id |
|
| 560 | - * @param string $insert_shortcode_function |
|
| 561 | - * |
|
| 562 | - *@since 1.0.6 |
|
| 563 | - * |
|
| 564 | - */ |
|
| 565 | - public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) { |
|
| 566 | - ?> |
|
| 556 | + /** |
|
| 557 | + * Output the JS and CSS for the shortcode insert button. |
|
| 558 | + * |
|
| 559 | + * @param string $editor_id |
|
| 560 | + * @param string $insert_shortcode_function |
|
| 561 | + * |
|
| 562 | + *@since 1.0.6 |
|
| 563 | + * |
|
| 564 | + */ |
|
| 565 | + public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) { |
|
| 566 | + ?> |
|
| 567 | 567 | <style> |
| 568 | 568 | .sd-shortcode-left-wrap { |
| 569 | 569 | float: left; |
@@ -691,35 +691,35 @@ discard block |
||
| 691 | 691 | <?php } ?> |
| 692 | 692 | </style> |
| 693 | 693 | <?php |
| 694 | - if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
| 695 | - echo "<script>" . self::siteorigin_js() . "</script>"; |
|
| 696 | - } |
|
| 697 | - ?> |
|
| 694 | + if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
| 695 | + echo "<script>" . self::siteorigin_js() . "</script>"; |
|
| 696 | + } |
|
| 697 | + ?> |
|
| 698 | 698 | <script> |
| 699 | 699 | <?php |
| 700 | - if(! empty( $insert_shortcode_function )){ |
|
| 701 | - echo $insert_shortcode_function; |
|
| 702 | - }else{ |
|
| 703 | - |
|
| 704 | - /** |
|
| 705 | - * Function for super duper insert shortcode. |
|
| 706 | - * |
|
| 707 | - * @since 1.0.0 |
|
| 708 | - */ |
|
| 709 | - ?> |
|
| 700 | + if(! empty( $insert_shortcode_function )){ |
|
| 701 | + echo $insert_shortcode_function; |
|
| 702 | + }else{ |
|
| 703 | + |
|
| 704 | + /** |
|
| 705 | + * Function for super duper insert shortcode. |
|
| 706 | + * |
|
| 707 | + * @since 1.0.0 |
|
| 708 | + */ |
|
| 709 | + ?> |
|
| 710 | 710 | function sd_insert_shortcode($editor_id) { |
| 711 | 711 | $shortcode = jQuery('#TB_ajaxContent #sd-shortcode-output').val(); |
| 712 | 712 | if ($shortcode) { |
| 713 | 713 | if (!$editor_id) { |
| 714 | 714 | <?php |
| 715 | - if ( isset( $_REQUEST['et_fb'] ) ) { |
|
| 716 | - echo '$editor_id = "#main_content_content_vb_tiny_mce";'; |
|
| 717 | - } elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) { |
|
| 718 | - echo '$editor_id = "#elementor-controls .wp-editor-container textarea";'; |
|
| 719 | - } else { |
|
| 720 | - echo '$editor_id = "#wp-content-editor-container textarea";'; |
|
| 721 | - } |
|
| 722 | - ?> |
|
| 715 | + if ( isset( $_REQUEST['et_fb'] ) ) { |
|
| 716 | + echo '$editor_id = "#main_content_content_vb_tiny_mce";'; |
|
| 717 | + } elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) { |
|
| 718 | + echo '$editor_id = "#elementor-controls .wp-editor-container textarea";'; |
|
| 719 | + } else { |
|
| 720 | + echo '$editor_id = "#wp-content-editor-container textarea";'; |
|
| 721 | + } |
|
| 722 | + ?> |
|
| 723 | 723 | } else { |
| 724 | 724 | $editor_id = '#' + $editor_id; |
| 725 | 725 | } |
@@ -1046,18 +1046,18 @@ discard block |
||
| 1046 | 1046 | |
| 1047 | 1047 | </script> |
| 1048 | 1048 | <?php |
| 1049 | - } |
|
| 1049 | + } |
|
| 1050 | 1050 | |
| 1051 | - /** |
|
| 1052 | - * Gets some CSS for the widgets screen. |
|
| 1053 | - * |
|
| 1054 | - * @param bool $advanced If we should include advanced CSS. |
|
| 1055 | - * |
|
| 1056 | - * @return mixed |
|
| 1057 | - */ |
|
| 1058 | - public function widget_css( $advanced = true ) { |
|
| 1059 | - ob_start(); |
|
| 1060 | - ?> |
|
| 1051 | + /** |
|
| 1052 | + * Gets some CSS for the widgets screen. |
|
| 1053 | + * |
|
| 1054 | + * @param bool $advanced If we should include advanced CSS. |
|
| 1055 | + * |
|
| 1056 | + * @return mixed |
|
| 1057 | + */ |
|
| 1058 | + public function widget_css( $advanced = true ) { |
|
| 1059 | + ob_start(); |
|
| 1060 | + ?> |
|
| 1061 | 1061 | <style> |
| 1062 | 1062 | <?php if( $advanced ){ ?> |
| 1063 | 1063 | .sd-advanced-setting { |
@@ -1095,26 +1095,26 @@ discard block |
||
| 1095 | 1095 | } |
| 1096 | 1096 | </style> |
| 1097 | 1097 | <?php |
| 1098 | - $output = ob_get_clean(); |
|
| 1098 | + $output = ob_get_clean(); |
|
| 1099 | 1099 | |
| 1100 | - /* |
|
| 1100 | + /* |
|
| 1101 | 1101 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1102 | 1102 | */ |
| 1103 | 1103 | |
| 1104 | - return str_replace( array( |
|
| 1105 | - '<style>', |
|
| 1106 | - '</style>' |
|
| 1107 | - ), '', $output ); |
|
| 1108 | - } |
|
| 1104 | + return str_replace( array( |
|
| 1105 | + '<style>', |
|
| 1106 | + '</style>' |
|
| 1107 | + ), '', $output ); |
|
| 1108 | + } |
|
| 1109 | 1109 | |
| 1110 | - /** |
|
| 1111 | - * Gets some JS for the widgets screen. |
|
| 1112 | - * |
|
| 1113 | - * @return mixed |
|
| 1114 | - */ |
|
| 1115 | - public function widget_js() { |
|
| 1116 | - ob_start(); |
|
| 1117 | - ?> |
|
| 1110 | + /** |
|
| 1111 | + * Gets some JS for the widgets screen. |
|
| 1112 | + * |
|
| 1113 | + * @return mixed |
|
| 1114 | + */ |
|
| 1115 | + public function widget_js() { |
|
| 1116 | + ob_start(); |
|
| 1117 | + ?> |
|
| 1118 | 1118 | <script> |
| 1119 | 1119 | |
| 1120 | 1120 | /** |
@@ -1265,471 +1265,471 @@ discard block |
||
| 1265 | 1265 | <?php do_action( 'wp_super_duper_widget_js', $this ); ?> |
| 1266 | 1266 | </script> |
| 1267 | 1267 | <?php |
| 1268 | - $output = ob_get_clean(); |
|
| 1268 | + $output = ob_get_clean(); |
|
| 1269 | 1269 | |
| 1270 | - /* |
|
| 1270 | + /* |
|
| 1271 | 1271 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1272 | 1272 | */ |
| 1273 | 1273 | |
| 1274 | - return str_replace( array( |
|
| 1275 | - '<script>', |
|
| 1276 | - '</script>' |
|
| 1277 | - ), '', $output ); |
|
| 1278 | - } |
|
| 1274 | + return str_replace( array( |
|
| 1275 | + '<script>', |
|
| 1276 | + '</script>' |
|
| 1277 | + ), '', $output ); |
|
| 1278 | + } |
|
| 1279 | 1279 | |
| 1280 | 1280 | |
| 1281 | - /** |
|
| 1282 | - * Set the name from the argument key. |
|
| 1283 | - * |
|
| 1284 | - * @param $options |
|
| 1285 | - * |
|
| 1286 | - * @return mixed |
|
| 1287 | - */ |
|
| 1288 | - private function add_name_from_key( $options, $arguments = false ) { |
|
| 1289 | - if ( ! empty( $options['arguments'] ) ) { |
|
| 1290 | - foreach ( $options['arguments'] as $key => $val ) { |
|
| 1291 | - $options['arguments'][ $key ]['name'] = $key; |
|
| 1292 | - } |
|
| 1293 | - } elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) { |
|
| 1294 | - foreach ( $options as $key => $val ) { |
|
| 1295 | - $options[ $key ]['name'] = $key; |
|
| 1296 | - } |
|
| 1297 | - } |
|
| 1281 | + /** |
|
| 1282 | + * Set the name from the argument key. |
|
| 1283 | + * |
|
| 1284 | + * @param $options |
|
| 1285 | + * |
|
| 1286 | + * @return mixed |
|
| 1287 | + */ |
|
| 1288 | + private function add_name_from_key( $options, $arguments = false ) { |
|
| 1289 | + if ( ! empty( $options['arguments'] ) ) { |
|
| 1290 | + foreach ( $options['arguments'] as $key => $val ) { |
|
| 1291 | + $options['arguments'][ $key ]['name'] = $key; |
|
| 1292 | + } |
|
| 1293 | + } elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) { |
|
| 1294 | + foreach ( $options as $key => $val ) { |
|
| 1295 | + $options[ $key ]['name'] = $key; |
|
| 1296 | + } |
|
| 1297 | + } |
|
| 1298 | 1298 | |
| 1299 | - return $options; |
|
| 1300 | - } |
|
| 1299 | + return $options; |
|
| 1300 | + } |
|
| 1301 | 1301 | |
| 1302 | - /** |
|
| 1303 | - * Register the parent shortcode. |
|
| 1304 | - * |
|
| 1305 | - * @since 1.0.0 |
|
| 1306 | - */ |
|
| 1307 | - public function register_shortcode() { |
|
| 1308 | - add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) ); |
|
| 1309 | - add_action( 'wp_ajax_super_duper_output_shortcode', array( $this, 'render_shortcode' ) ); |
|
| 1310 | - } |
|
| 1302 | + /** |
|
| 1303 | + * Register the parent shortcode. |
|
| 1304 | + * |
|
| 1305 | + * @since 1.0.0 |
|
| 1306 | + */ |
|
| 1307 | + public function register_shortcode() { |
|
| 1308 | + add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) ); |
|
| 1309 | + add_action( 'wp_ajax_super_duper_output_shortcode', array( $this, 'render_shortcode' ) ); |
|
| 1310 | + } |
|
| 1311 | 1311 | |
| 1312 | - /** |
|
| 1313 | - * Render the shortcode via ajax so we can return it to Gutenberg. |
|
| 1314 | - * |
|
| 1315 | - * @since 1.0.0 |
|
| 1316 | - */ |
|
| 1317 | - public function render_shortcode() { |
|
| 1318 | - check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true ); |
|
| 1319 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 1320 | - wp_die(); |
|
| 1321 | - } |
|
| 1312 | + /** |
|
| 1313 | + * Render the shortcode via ajax so we can return it to Gutenberg. |
|
| 1314 | + * |
|
| 1315 | + * @since 1.0.0 |
|
| 1316 | + */ |
|
| 1317 | + public function render_shortcode() { |
|
| 1318 | + check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true ); |
|
| 1319 | + if ( ! current_user_can( 'manage_options' ) ) { |
|
| 1320 | + wp_die(); |
|
| 1321 | + } |
|
| 1322 | 1322 | |
| 1323 | - // we might need the $post value here so lets set it. |
|
| 1324 | - if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) { |
|
| 1325 | - $post_obj = get_post( absint( $_POST['post_id'] ) ); |
|
| 1326 | - if ( ! empty( $post_obj ) && empty( $post ) ) { |
|
| 1327 | - global $post; |
|
| 1328 | - $post = $post_obj; |
|
| 1329 | - } |
|
| 1330 | - } |
|
| 1323 | + // we might need the $post value here so lets set it. |
|
| 1324 | + if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) { |
|
| 1325 | + $post_obj = get_post( absint( $_POST['post_id'] ) ); |
|
| 1326 | + if ( ! empty( $post_obj ) && empty( $post ) ) { |
|
| 1327 | + global $post; |
|
| 1328 | + $post = $post_obj; |
|
| 1329 | + } |
|
| 1330 | + } |
|
| 1331 | 1331 | |
| 1332 | - if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) { |
|
| 1333 | - $is_preview = $this->is_preview(); |
|
| 1334 | - $shortcode_name = sanitize_title_with_dashes( $_POST['shortcode'] ); |
|
| 1335 | - $attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array(); |
|
| 1336 | - $attributes = ''; |
|
| 1337 | - if ( ! empty( $attributes_array ) ) { |
|
| 1338 | - foreach ( $attributes_array as $key => $value ) { |
|
| 1339 | - if ( is_array( $value ) ) { |
|
| 1340 | - $value = implode( ",", $value ); |
|
| 1341 | - } |
|
| 1332 | + if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) { |
|
| 1333 | + $is_preview = $this->is_preview(); |
|
| 1334 | + $shortcode_name = sanitize_title_with_dashes( $_POST['shortcode'] ); |
|
| 1335 | + $attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array(); |
|
| 1336 | + $attributes = ''; |
|
| 1337 | + if ( ! empty( $attributes_array ) ) { |
|
| 1338 | + foreach ( $attributes_array as $key => $value ) { |
|
| 1339 | + if ( is_array( $value ) ) { |
|
| 1340 | + $value = implode( ",", $value ); |
|
| 1341 | + } |
|
| 1342 | 1342 | |
| 1343 | - if ( ! empty( $value ) ) { |
|
| 1344 | - $value = wp_unslash( $value ); |
|
| 1343 | + if ( ! empty( $value ) ) { |
|
| 1344 | + $value = wp_unslash( $value ); |
|
| 1345 | 1345 | |
| 1346 | - // Encode [ and ]. |
|
| 1347 | - if ( $is_preview ) { |
|
| 1348 | - $value = $this->encode_shortcodes( $value ); |
|
| 1349 | - } |
|
| 1350 | - } |
|
| 1351 | - $attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . esc_attr( $value ) . "' "; |
|
| 1352 | - } |
|
| 1353 | - } |
|
| 1346 | + // Encode [ and ]. |
|
| 1347 | + if ( $is_preview ) { |
|
| 1348 | + $value = $this->encode_shortcodes( $value ); |
|
| 1349 | + } |
|
| 1350 | + } |
|
| 1351 | + $attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . esc_attr( $value ) . "' "; |
|
| 1352 | + } |
|
| 1353 | + } |
|
| 1354 | 1354 | |
| 1355 | - $shortcode = "[" . $shortcode_name . " " . $attributes . "]"; |
|
| 1355 | + $shortcode = "[" . $shortcode_name . " " . $attributes . "]"; |
|
| 1356 | 1356 | |
| 1357 | - $content = do_shortcode( $shortcode ); |
|
| 1357 | + $content = do_shortcode( $shortcode ); |
|
| 1358 | 1358 | |
| 1359 | - // Decode [ and ]. |
|
| 1360 | - if ( ! empty( $content ) && $is_preview ) { |
|
| 1361 | - $content = $this->decode_shortcodes( $content ); |
|
| 1362 | - } |
|
| 1359 | + // Decode [ and ]. |
|
| 1360 | + if ( ! empty( $content ) && $is_preview ) { |
|
| 1361 | + $content = $this->decode_shortcodes( $content ); |
|
| 1362 | + } |
|
| 1363 | 1363 | |
| 1364 | - echo $content; |
|
| 1365 | - } |
|
| 1366 | - wp_die(); |
|
| 1367 | - } |
|
| 1364 | + echo $content; |
|
| 1365 | + } |
|
| 1366 | + wp_die(); |
|
| 1367 | + } |
|
| 1368 | 1368 | |
| 1369 | - /** |
|
| 1370 | - * Output the shortcode. |
|
| 1371 | - * |
|
| 1372 | - * @param array $args |
|
| 1373 | - * @param string $content |
|
| 1374 | - * |
|
| 1375 | - * @return string |
|
| 1376 | - */ |
|
| 1377 | - public function shortcode_output( $args = array(), $content = '' ) { |
|
| 1378 | - $_instance = $args; |
|
| 1379 | - |
|
| 1380 | - $args = $this->argument_values( $args ); |
|
| 1381 | - |
|
| 1382 | - // add extra argument so we know its a output to gutenberg |
|
| 1383 | - //$args |
|
| 1384 | - $args = $this->string_to_bool( $args ); |
|
| 1385 | - |
|
| 1386 | - // if we have a enclosed shortcode we add it to the special `html` argument |
|
| 1387 | - if ( ! empty( $content ) ) { |
|
| 1388 | - $args['html'] = $content; |
|
| 1389 | - } |
|
| 1369 | + /** |
|
| 1370 | + * Output the shortcode. |
|
| 1371 | + * |
|
| 1372 | + * @param array $args |
|
| 1373 | + * @param string $content |
|
| 1374 | + * |
|
| 1375 | + * @return string |
|
| 1376 | + */ |
|
| 1377 | + public function shortcode_output( $args = array(), $content = '' ) { |
|
| 1378 | + $_instance = $args; |
|
| 1390 | 1379 | |
| 1391 | - if ( ! $this->is_preview() ) { |
|
| 1392 | - /** |
|
| 1393 | - * Filters the settings for a particular widget args. |
|
| 1394 | - * |
|
| 1395 | - * @param array $args The current widget instance's settings. |
|
| 1396 | - * @param WP_Super_Duper $widget The current widget settings. |
|
| 1397 | - * @param array $_instance An array of default widget arguments. |
|
| 1398 | - * |
|
| 1399 | - *@since 1.0.28 |
|
| 1400 | - * |
|
| 1401 | - */ |
|
| 1402 | - $args = apply_filters( 'wp_super_duper_widget_display_callback', $args, $this, $_instance ); |
|
| 1380 | + $args = $this->argument_values( $args ); |
|
| 1403 | 1381 | |
| 1404 | - if ( ! is_array( $args ) ) { |
|
| 1405 | - return $args; |
|
| 1406 | - } |
|
| 1407 | - } |
|
| 1382 | + // add extra argument so we know its a output to gutenberg |
|
| 1383 | + //$args |
|
| 1384 | + $args = $this->string_to_bool( $args ); |
|
| 1408 | 1385 | |
| 1409 | - $class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : ''; |
|
| 1410 | - $class .= " sdel-".$this->get_instance_hash(); |
|
| 1386 | + // if we have a enclosed shortcode we add it to the special `html` argument |
|
| 1387 | + if ( ! empty( $content ) ) { |
|
| 1388 | + $args['html'] = $content; |
|
| 1389 | + } |
|
| 1411 | 1390 | |
| 1412 | - $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this ); |
|
| 1413 | - $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this ); |
|
| 1391 | + if ( ! $this->is_preview() ) { |
|
| 1392 | + /** |
|
| 1393 | + * Filters the settings for a particular widget args. |
|
| 1394 | + * |
|
| 1395 | + * @param array $args The current widget instance's settings. |
|
| 1396 | + * @param WP_Super_Duper $widget The current widget settings. |
|
| 1397 | + * @param array $_instance An array of default widget arguments. |
|
| 1398 | + * |
|
| 1399 | + *@since 1.0.28 |
|
| 1400 | + * |
|
| 1401 | + */ |
|
| 1402 | + $args = apply_filters( 'wp_super_duper_widget_display_callback', $args, $this, $_instance ); |
|
| 1403 | + |
|
| 1404 | + if ( ! is_array( $args ) ) { |
|
| 1405 | + return $args; |
|
| 1406 | + } |
|
| 1407 | + } |
|
| 1414 | 1408 | |
| 1415 | - $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this ); |
|
| 1416 | - $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); |
|
| 1409 | + $class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : ''; |
|
| 1410 | + $class .= " sdel-".$this->get_instance_hash(); |
|
| 1417 | 1411 | |
| 1418 | - $shortcode_args = array(); |
|
| 1419 | - $output = ''; |
|
| 1420 | - $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; |
|
| 1421 | - if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) { |
|
| 1422 | - $no_wrap = true; |
|
| 1423 | - } |
|
| 1424 | - $main_content = $this->output( $args, $shortcode_args, $content ); |
|
| 1425 | - if ( $main_content && ! $no_wrap ) { |
|
| 1426 | - // wrap the shortcode in a div with the same class as the widget |
|
| 1427 | - $output .= '<div class="' . $class . '" ' . $attrs . '>'; |
|
| 1428 | - if ( ! empty( $args['title'] ) ) { |
|
| 1429 | - // if its a shortcode and there is a title try to grab the title wrappers |
|
| 1430 | - $shortcode_args = array( 'before_title' => '', 'after_title' => '' ); |
|
| 1431 | - if ( empty( $instance ) ) { |
|
| 1432 | - global $wp_registered_sidebars; |
|
| 1433 | - if ( ! empty( $wp_registered_sidebars ) ) { |
|
| 1434 | - foreach ( $wp_registered_sidebars as $sidebar ) { |
|
| 1435 | - if ( ! empty( $sidebar['before_title'] ) ) { |
|
| 1436 | - $shortcode_args['before_title'] = $sidebar['before_title']; |
|
| 1437 | - $shortcode_args['after_title'] = $sidebar['after_title']; |
|
| 1438 | - break; |
|
| 1439 | - } |
|
| 1440 | - } |
|
| 1441 | - } |
|
| 1442 | - } |
|
| 1443 | - $output .= $this->output_title( $shortcode_args, $args ); |
|
| 1444 | - } |
|
| 1445 | - $output .= $main_content; |
|
| 1446 | - $output .= '</div>'; |
|
| 1447 | - } elseif ( $main_content && $no_wrap ) { |
|
| 1448 | - $output .= $main_content; |
|
| 1449 | - } |
|
| 1412 | + $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this ); |
|
| 1413 | + $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this ); |
|
| 1450 | 1414 | |
| 1451 | - // if preview show a placeholder if empty |
|
| 1452 | - if ( $this->is_preview() && $output == '' ) { |
|
| 1453 | - $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" ); |
|
| 1454 | - } |
|
| 1415 | + $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this ); |
|
| 1416 | + $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); |
|
| 1455 | 1417 | |
| 1456 | - return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this ); |
|
| 1457 | - } |
|
| 1418 | + $shortcode_args = array(); |
|
| 1419 | + $output = ''; |
|
| 1420 | + $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; |
|
| 1421 | + if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) { |
|
| 1422 | + $no_wrap = true; |
|
| 1423 | + } |
|
| 1424 | + $main_content = $this->output( $args, $shortcode_args, $content ); |
|
| 1425 | + if ( $main_content && ! $no_wrap ) { |
|
| 1426 | + // wrap the shortcode in a div with the same class as the widget |
|
| 1427 | + $output .= '<div class="' . $class . '" ' . $attrs . '>'; |
|
| 1428 | + if ( ! empty( $args['title'] ) ) { |
|
| 1429 | + // if its a shortcode and there is a title try to grab the title wrappers |
|
| 1430 | + $shortcode_args = array( 'before_title' => '', 'after_title' => '' ); |
|
| 1431 | + if ( empty( $instance ) ) { |
|
| 1432 | + global $wp_registered_sidebars; |
|
| 1433 | + if ( ! empty( $wp_registered_sidebars ) ) { |
|
| 1434 | + foreach ( $wp_registered_sidebars as $sidebar ) { |
|
| 1435 | + if ( ! empty( $sidebar['before_title'] ) ) { |
|
| 1436 | + $shortcode_args['before_title'] = $sidebar['before_title']; |
|
| 1437 | + $shortcode_args['after_title'] = $sidebar['after_title']; |
|
| 1438 | + break; |
|
| 1439 | + } |
|
| 1440 | + } |
|
| 1441 | + } |
|
| 1442 | + } |
|
| 1443 | + $output .= $this->output_title( $shortcode_args, $args ); |
|
| 1444 | + } |
|
| 1445 | + $output .= $main_content; |
|
| 1446 | + $output .= '</div>'; |
|
| 1447 | + } elseif ( $main_content && $no_wrap ) { |
|
| 1448 | + $output .= $main_content; |
|
| 1449 | + } |
|
| 1458 | 1450 | |
| 1459 | - /** |
|
| 1460 | - * Placeholder text to show if output is empty and we are on a preview/builder page. |
|
| 1461 | - * |
|
| 1462 | - * @param string $name |
|
| 1463 | - * |
|
| 1464 | - * @return string |
|
| 1465 | - */ |
|
| 1466 | - public function preview_placeholder_text( $name = '' ) { |
|
| 1467 | - return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf( __( 'Placeholder for: %s' ), $name ) . "</div>"; |
|
| 1468 | - } |
|
| 1451 | + // if preview show a placeholder if empty |
|
| 1452 | + if ( $this->is_preview() && $output == '' ) { |
|
| 1453 | + $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" ); |
|
| 1454 | + } |
|
| 1469 | 1455 | |
| 1470 | - /** |
|
| 1471 | - * Sometimes booleans values can be turned to strings, so we fix that. |
|
| 1472 | - * |
|
| 1473 | - * @param $options |
|
| 1474 | - * |
|
| 1475 | - * @return mixed |
|
| 1476 | - */ |
|
| 1477 | - public function string_to_bool( $options ) { |
|
| 1478 | - // convert bool strings to booleans |
|
| 1479 | - foreach ( $options as $key => $val ) { |
|
| 1480 | - if ( $val == 'false' ) { |
|
| 1481 | - $options[ $key ] = false; |
|
| 1482 | - } elseif ( $val == 'true' ) { |
|
| 1483 | - $options[ $key ] = true; |
|
| 1484 | - } |
|
| 1485 | - } |
|
| 1456 | + return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this ); |
|
| 1457 | + } |
|
| 1486 | 1458 | |
| 1487 | - return $options; |
|
| 1488 | - } |
|
| 1459 | + /** |
|
| 1460 | + * Placeholder text to show if output is empty and we are on a preview/builder page. |
|
| 1461 | + * |
|
| 1462 | + * @param string $name |
|
| 1463 | + * |
|
| 1464 | + * @return string |
|
| 1465 | + */ |
|
| 1466 | + public function preview_placeholder_text( $name = '' ) { |
|
| 1467 | + return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf( __( 'Placeholder for: %s' ), $name ) . "</div>"; |
|
| 1468 | + } |
|
| 1489 | 1469 | |
| 1490 | - /** |
|
| 1491 | - * Get the argument values that are also filterable. |
|
| 1492 | - * |
|
| 1493 | - * @param $instance |
|
| 1494 | - * |
|
| 1495 | - * @return array |
|
| 1496 | - *@since 1.0.12 Don't set checkbox default value if the value is empty. |
|
| 1497 | - * |
|
| 1498 | - */ |
|
| 1499 | - public function argument_values( $instance ) { |
|
| 1500 | - $argument_values = array(); |
|
| 1501 | - |
|
| 1502 | - // set widget instance |
|
| 1503 | - $this->instance = $instance; |
|
| 1504 | - |
|
| 1505 | - if ( empty( $this->arguments ) ) { |
|
| 1506 | - $this->arguments = $this->get_arguments(); |
|
| 1507 | - } |
|
| 1470 | + /** |
|
| 1471 | + * Sometimes booleans values can be turned to strings, so we fix that. |
|
| 1472 | + * |
|
| 1473 | + * @param $options |
|
| 1474 | + * |
|
| 1475 | + * @return mixed |
|
| 1476 | + */ |
|
| 1477 | + public function string_to_bool( $options ) { |
|
| 1478 | + // convert bool strings to booleans |
|
| 1479 | + foreach ( $options as $key => $val ) { |
|
| 1480 | + if ( $val == 'false' ) { |
|
| 1481 | + $options[ $key ] = false; |
|
| 1482 | + } elseif ( $val == 'true' ) { |
|
| 1483 | + $options[ $key ] = true; |
|
| 1484 | + } |
|
| 1485 | + } |
|
| 1508 | 1486 | |
| 1509 | - if ( ! empty( $this->arguments ) ) { |
|
| 1510 | - foreach ( $this->arguments as $key => $args ) { |
|
| 1511 | - // set the input name from the key |
|
| 1512 | - $args['name'] = $key; |
|
| 1513 | - // |
|
| 1514 | - $argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : ''; |
|
| 1515 | - if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) { |
|
| 1516 | - // don't set default for an empty checkbox |
|
| 1517 | - } elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) { |
|
| 1518 | - $argument_values[ $key ] = $args['default']; |
|
| 1519 | - } |
|
| 1520 | - } |
|
| 1521 | - } |
|
| 1487 | + return $options; |
|
| 1488 | + } |
|
| 1522 | 1489 | |
| 1523 | - return $argument_values; |
|
| 1524 | - } |
|
| 1490 | + /** |
|
| 1491 | + * Get the argument values that are also filterable. |
|
| 1492 | + * |
|
| 1493 | + * @param $instance |
|
| 1494 | + * |
|
| 1495 | + * @return array |
|
| 1496 | + *@since 1.0.12 Don't set checkbox default value if the value is empty. |
|
| 1497 | + * |
|
| 1498 | + */ |
|
| 1499 | + public function argument_values( $instance ) { |
|
| 1500 | + $argument_values = array(); |
|
| 1525 | 1501 | |
| 1526 | - /** |
|
| 1527 | - * Set arguments in super duper. |
|
| 1528 | - * |
|
| 1529 | - * @return array Set arguments. |
|
| 1530 | - *@since 1.0.0 |
|
| 1531 | - * |
|
| 1532 | - */ |
|
| 1533 | - public function set_arguments() { |
|
| 1534 | - return $this->arguments; |
|
| 1535 | - } |
|
| 1502 | + // set widget instance |
|
| 1503 | + $this->instance = $instance; |
|
| 1536 | 1504 | |
| 1537 | - /** |
|
| 1538 | - * Get arguments in super duper. |
|
| 1539 | - * |
|
| 1540 | - * @return array Get arguments. |
|
| 1541 | - *@since 1.0.0 |
|
| 1542 | - * |
|
| 1543 | - */ |
|
| 1544 | - public function get_arguments() { |
|
| 1545 | - if ( empty( $this->arguments ) ) { |
|
| 1546 | - $this->arguments = $this->set_arguments(); |
|
| 1547 | - } |
|
| 1505 | + if ( empty( $this->arguments ) ) { |
|
| 1506 | + $this->arguments = $this->get_arguments(); |
|
| 1507 | + } |
|
| 1548 | 1508 | |
| 1549 | - $this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance ); |
|
| 1550 | - $this->arguments = $this->add_name_from_key( $this->arguments, true ); |
|
| 1509 | + if ( ! empty( $this->arguments ) ) { |
|
| 1510 | + foreach ( $this->arguments as $key => $args ) { |
|
| 1511 | + // set the input name from the key |
|
| 1512 | + $args['name'] = $key; |
|
| 1513 | + // |
|
| 1514 | + $argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : ''; |
|
| 1515 | + if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) { |
|
| 1516 | + // don't set default for an empty checkbox |
|
| 1517 | + } elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) { |
|
| 1518 | + $argument_values[ $key ] = $args['default']; |
|
| 1519 | + } |
|
| 1520 | + } |
|
| 1521 | + } |
|
| 1551 | 1522 | |
| 1552 | - return $this->arguments; |
|
| 1553 | - } |
|
| 1523 | + return $argument_values; |
|
| 1524 | + } |
|
| 1554 | 1525 | |
| 1555 | - /** |
|
| 1556 | - * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class. |
|
| 1557 | - * |
|
| 1558 | - * @param array $args |
|
| 1559 | - * @param array $widget_args |
|
| 1560 | - * @param string $content |
|
| 1561 | - */ |
|
| 1562 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 1526 | + /** |
|
| 1527 | + * Set arguments in super duper. |
|
| 1528 | + * |
|
| 1529 | + * @return array Set arguments. |
|
| 1530 | + *@since 1.0.0 |
|
| 1531 | + * |
|
| 1532 | + */ |
|
| 1533 | + public function set_arguments() { |
|
| 1534 | + return $this->arguments; |
|
| 1535 | + } |
|
| 1563 | 1536 | |
| 1564 | - } |
|
| 1537 | + /** |
|
| 1538 | + * Get arguments in super duper. |
|
| 1539 | + * |
|
| 1540 | + * @return array Get arguments. |
|
| 1541 | + *@since 1.0.0 |
|
| 1542 | + * |
|
| 1543 | + */ |
|
| 1544 | + public function get_arguments() { |
|
| 1545 | + if ( empty( $this->arguments ) ) { |
|
| 1546 | + $this->arguments = $this->set_arguments(); |
|
| 1547 | + } |
|
| 1565 | 1548 | |
| 1566 | - /** |
|
| 1567 | - * Add the dynamic block code inline when the wp-block in enqueued. |
|
| 1568 | - */ |
|
| 1569 | - public function register_block() { |
|
| 1570 | - wp_add_inline_script( 'wp-blocks', $this->block() ); |
|
| 1571 | - if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
| 1572 | - wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() ); |
|
| 1573 | - } |
|
| 1574 | - } |
|
| 1549 | + $this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance ); |
|
| 1550 | + $this->arguments = $this->add_name_from_key( $this->arguments, true ); |
|
| 1575 | 1551 | |
| 1576 | - /** |
|
| 1577 | - * Check if we need to show advanced options. |
|
| 1578 | - * |
|
| 1579 | - * @return bool |
|
| 1580 | - */ |
|
| 1581 | - public function block_show_advanced() { |
|
| 1582 | - |
|
| 1583 | - $show = false; |
|
| 1584 | - $arguments = $this->get_arguments(); |
|
| 1585 | - |
|
| 1586 | - if ( ! empty( $arguments ) ) { |
|
| 1587 | - foreach ( $arguments as $argument ) { |
|
| 1588 | - if ( isset( $argument['advanced'] ) && $argument['advanced'] ) { |
|
| 1589 | - $show = true; |
|
| 1590 | - break; // no need to continue if we know we have it |
|
| 1591 | - } |
|
| 1592 | - } |
|
| 1593 | - } |
|
| 1552 | + return $this->arguments; |
|
| 1553 | + } |
|
| 1594 | 1554 | |
| 1595 | - return $show; |
|
| 1596 | - } |
|
| 1555 | + /** |
|
| 1556 | + * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class. |
|
| 1557 | + * |
|
| 1558 | + * @param array $args |
|
| 1559 | + * @param array $widget_args |
|
| 1560 | + * @param string $content |
|
| 1561 | + */ |
|
| 1562 | + public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 1597 | 1563 | |
| 1598 | - /** |
|
| 1599 | - * Get the url path to the current folder. |
|
| 1600 | - * |
|
| 1601 | - * @return string |
|
| 1602 | - */ |
|
| 1603 | - public function get_url() { |
|
| 1604 | - $url = $this->url; |
|
| 1605 | - |
|
| 1606 | - if ( ! $url ) { |
|
| 1607 | - $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) ); |
|
| 1608 | - $content_url = untrailingslashit( WP_CONTENT_URL ); |
|
| 1609 | - |
|
| 1610 | - // Replace http:// to https://. |
|
| 1611 | - if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) { |
|
| 1612 | - $content_url = str_replace( 'http://', 'https://', $content_url ); |
|
| 1613 | - } |
|
| 1564 | + } |
|
| 1614 | 1565 | |
| 1615 | - // Check if we are inside a plugin |
|
| 1616 | - $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 1617 | - $url = str_replace( $content_dir, $content_url, $file_dir ); |
|
| 1618 | - $url = trailingslashit( $url ); |
|
| 1619 | - $this->url = $url; |
|
| 1620 | - } |
|
| 1566 | + /** |
|
| 1567 | + * Add the dynamic block code inline when the wp-block in enqueued. |
|
| 1568 | + */ |
|
| 1569 | + public function register_block() { |
|
| 1570 | + wp_add_inline_script( 'wp-blocks', $this->block() ); |
|
| 1571 | + if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
| 1572 | + wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() ); |
|
| 1573 | + } |
|
| 1574 | + } |
|
| 1621 | 1575 | |
| 1622 | - return $url; |
|
| 1623 | - } |
|
| 1576 | + /** |
|
| 1577 | + * Check if we need to show advanced options. |
|
| 1578 | + * |
|
| 1579 | + * @return bool |
|
| 1580 | + */ |
|
| 1581 | + public function block_show_advanced() { |
|
| 1624 | 1582 | |
| 1625 | - /** |
|
| 1626 | - * Get the url path to the current folder. |
|
| 1627 | - * |
|
| 1628 | - * @return string |
|
| 1629 | - */ |
|
| 1630 | - public function get_url_old() { |
|
| 1583 | + $show = false; |
|
| 1584 | + $arguments = $this->get_arguments(); |
|
| 1631 | 1585 | |
| 1632 | - $url = $this->url; |
|
| 1586 | + if ( ! empty( $arguments ) ) { |
|
| 1587 | + foreach ( $arguments as $argument ) { |
|
| 1588 | + if ( isset( $argument['advanced'] ) && $argument['advanced'] ) { |
|
| 1589 | + $show = true; |
|
| 1590 | + break; // no need to continue if we know we have it |
|
| 1591 | + } |
|
| 1592 | + } |
|
| 1593 | + } |
|
| 1633 | 1594 | |
| 1634 | - if ( ! $url ) { |
|
| 1635 | - // check if we are inside a plugin |
|
| 1636 | - $file_dir = str_replace( "/includes", "", dirname( __FILE__ ) ); |
|
| 1595 | + return $show; |
|
| 1596 | + } |
|
| 1637 | 1597 | |
| 1638 | - $dir_parts = explode( "/wp-content/", $file_dir ); |
|
| 1639 | - $url_parts = explode( "/wp-content/", plugins_url() ); |
|
| 1598 | + /** |
|
| 1599 | + * Get the url path to the current folder. |
|
| 1600 | + * |
|
| 1601 | + * @return string |
|
| 1602 | + */ |
|
| 1603 | + public function get_url() { |
|
| 1604 | + $url = $this->url; |
|
| 1640 | 1605 | |
| 1641 | - if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) { |
|
| 1642 | - $url = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] ); |
|
| 1643 | - $this->url = $url; |
|
| 1644 | - } |
|
| 1645 | - } |
|
| 1606 | + if ( ! $url ) { |
|
| 1607 | + $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) ); |
|
| 1608 | + $content_url = untrailingslashit( WP_CONTENT_URL ); |
|
| 1646 | 1609 | |
| 1610 | + // Replace http:// to https://. |
|
| 1611 | + if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) { |
|
| 1612 | + $content_url = str_replace( 'http://', 'https://', $content_url ); |
|
| 1613 | + } |
|
| 1647 | 1614 | |
| 1648 | - return $url; |
|
| 1649 | - } |
|
| 1615 | + // Check if we are inside a plugin |
|
| 1616 | + $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 1617 | + $url = str_replace( $content_dir, $content_url, $file_dir ); |
|
| 1618 | + $url = trailingslashit( $url ); |
|
| 1619 | + $this->url = $url; |
|
| 1620 | + } |
|
| 1650 | 1621 | |
| 1651 | - /** |
|
| 1652 | - * Generate the block icon. |
|
| 1653 | - * |
|
| 1654 | - * Enables the use of Font Awesome icons. |
|
| 1655 | - * |
|
| 1656 | - * @note xlink:href is actually deprecated but href is not supported by all so we use both. |
|
| 1657 | - * |
|
| 1658 | - * @param $icon |
|
| 1659 | - * |
|
| 1660 | - * @return string |
|
| 1661 | - *@since 1.1.0 |
|
| 1662 | - */ |
|
| 1663 | - public function get_block_icon( $icon ) { |
|
| 1664 | - |
|
| 1665 | - // check if we have a Font Awesome icon |
|
| 1666 | - $fa_type = ''; |
|
| 1667 | - if ( substr( $icon, 0, 7 ) === "fas fa-" ) { |
|
| 1668 | - $fa_type = 'solid'; |
|
| 1669 | - } elseif ( substr( $icon, 0, 7 ) === "far fa-" ) { |
|
| 1670 | - $fa_type = 'regular'; |
|
| 1671 | - } elseif ( substr( $icon, 0, 7 ) === "fab fa-" ) { |
|
| 1672 | - $fa_type = 'brands'; |
|
| 1673 | - } else { |
|
| 1674 | - $icon = "'" . $icon . "'"; |
|
| 1675 | - } |
|
| 1622 | + return $url; |
|
| 1623 | + } |
|
| 1676 | 1624 | |
| 1677 | - // set the icon if we found one |
|
| 1678 | - if ( $fa_type ) { |
|
| 1679 | - $fa_icon = str_replace( array( "fas fa-", "far fa-", "fab fa-" ), "", $icon ); |
|
| 1680 | - $icon = "el('svg',{width: 20, height: 20, viewBox: '0 0 20 20'},el('use', {'xlink:href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "','href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "'}))"; |
|
| 1681 | - } |
|
| 1625 | + /** |
|
| 1626 | + * Get the url path to the current folder. |
|
| 1627 | + * |
|
| 1628 | + * @return string |
|
| 1629 | + */ |
|
| 1630 | + public function get_url_old() { |
|
| 1682 | 1631 | |
| 1683 | - return $icon; |
|
| 1684 | - } |
|
| 1632 | + $url = $this->url; |
|
| 1633 | + |
|
| 1634 | + if ( ! $url ) { |
|
| 1635 | + // check if we are inside a plugin |
|
| 1636 | + $file_dir = str_replace( "/includes", "", dirname( __FILE__ ) ); |
|
| 1637 | + |
|
| 1638 | + $dir_parts = explode( "/wp-content/", $file_dir ); |
|
| 1639 | + $url_parts = explode( "/wp-content/", plugins_url() ); |
|
| 1640 | + |
|
| 1641 | + if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) { |
|
| 1642 | + $url = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] ); |
|
| 1643 | + $this->url = $url; |
|
| 1644 | + } |
|
| 1645 | + } |
|
| 1646 | + |
|
| 1647 | + |
|
| 1648 | + return $url; |
|
| 1649 | + } |
|
| 1650 | + |
|
| 1651 | + /** |
|
| 1652 | + * Generate the block icon. |
|
| 1653 | + * |
|
| 1654 | + * Enables the use of Font Awesome icons. |
|
| 1655 | + * |
|
| 1656 | + * @note xlink:href is actually deprecated but href is not supported by all so we use both. |
|
| 1657 | + * |
|
| 1658 | + * @param $icon |
|
| 1659 | + * |
|
| 1660 | + * @return string |
|
| 1661 | + *@since 1.1.0 |
|
| 1662 | + */ |
|
| 1663 | + public function get_block_icon( $icon ) { |
|
| 1664 | + |
|
| 1665 | + // check if we have a Font Awesome icon |
|
| 1666 | + $fa_type = ''; |
|
| 1667 | + if ( substr( $icon, 0, 7 ) === "fas fa-" ) { |
|
| 1668 | + $fa_type = 'solid'; |
|
| 1669 | + } elseif ( substr( $icon, 0, 7 ) === "far fa-" ) { |
|
| 1670 | + $fa_type = 'regular'; |
|
| 1671 | + } elseif ( substr( $icon, 0, 7 ) === "fab fa-" ) { |
|
| 1672 | + $fa_type = 'brands'; |
|
| 1673 | + } else { |
|
| 1674 | + $icon = "'" . $icon . "'"; |
|
| 1675 | + } |
|
| 1685 | 1676 | |
| 1686 | - public function group_arguments( $arguments ) { |
|
| 1677 | + // set the icon if we found one |
|
| 1678 | + if ( $fa_type ) { |
|
| 1679 | + $fa_icon = str_replace( array( "fas fa-", "far fa-", "fab fa-" ), "", $icon ); |
|
| 1680 | + $icon = "el('svg',{width: 20, height: 20, viewBox: '0 0 20 20'},el('use', {'xlink:href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "','href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "'}))"; |
|
| 1681 | + } |
|
| 1682 | + |
|
| 1683 | + return $icon; |
|
| 1684 | + } |
|
| 1685 | + |
|
| 1686 | + public function group_arguments( $arguments ) { |
|
| 1687 | 1687 | // echo '###';print_r($arguments); |
| 1688 | - if ( ! empty( $arguments ) ) { |
|
| 1689 | - $temp_arguments = array(); |
|
| 1690 | - $general = __( "General" ); |
|
| 1691 | - $add_sections = false; |
|
| 1692 | - foreach ( $arguments as $key => $args ) { |
|
| 1693 | - if ( isset( $args['group'] ) ) { |
|
| 1694 | - $temp_arguments[ $args['group'] ][ $key ] = $args; |
|
| 1695 | - $add_sections = true; |
|
| 1696 | - } else { |
|
| 1697 | - $temp_arguments[ $general ][ $key ] = $args; |
|
| 1698 | - } |
|
| 1699 | - } |
|
| 1688 | + if ( ! empty( $arguments ) ) { |
|
| 1689 | + $temp_arguments = array(); |
|
| 1690 | + $general = __( "General" ); |
|
| 1691 | + $add_sections = false; |
|
| 1692 | + foreach ( $arguments as $key => $args ) { |
|
| 1693 | + if ( isset( $args['group'] ) ) { |
|
| 1694 | + $temp_arguments[ $args['group'] ][ $key ] = $args; |
|
| 1695 | + $add_sections = true; |
|
| 1696 | + } else { |
|
| 1697 | + $temp_arguments[ $general ][ $key ] = $args; |
|
| 1698 | + } |
|
| 1699 | + } |
|
| 1700 | 1700 | |
| 1701 | - // only add sections if more than one |
|
| 1702 | - if ( $add_sections ) { |
|
| 1703 | - $arguments = $temp_arguments; |
|
| 1704 | - } |
|
| 1705 | - } |
|
| 1701 | + // only add sections if more than one |
|
| 1702 | + if ( $add_sections ) { |
|
| 1703 | + $arguments = $temp_arguments; |
|
| 1704 | + } |
|
| 1705 | + } |
|
| 1706 | 1706 | |
| 1707 | 1707 | // echo '###';print_r($arguments); |
| 1708 | - return $arguments; |
|
| 1709 | - } |
|
| 1708 | + return $arguments; |
|
| 1709 | + } |
|
| 1710 | 1710 | |
| 1711 | 1711 | |
| 1712 | - /** |
|
| 1713 | - * Output the JS for building the dynamic Guntenberg block. |
|
| 1714 | - * |
|
| 1715 | - * @return mixed |
|
| 1716 | - *@since 1.0.9 Save numbers as numbers and not strings. |
|
| 1717 | - * @since 1.1.0 Font Awesome classes can be used for icons. |
|
| 1718 | - * @since 1.0.4 Added block_wrap property which will set the block wrapping output element ie: div, span, p or empty for no wrap. |
|
| 1719 | - */ |
|
| 1720 | - public function block() { |
|
| 1712 | + /** |
|
| 1713 | + * Output the JS for building the dynamic Guntenberg block. |
|
| 1714 | + * |
|
| 1715 | + * @return mixed |
|
| 1716 | + *@since 1.0.9 Save numbers as numbers and not strings. |
|
| 1717 | + * @since 1.1.0 Font Awesome classes can be used for icons. |
|
| 1718 | + * @since 1.0.4 Added block_wrap property which will set the block wrapping output element ie: div, span, p or empty for no wrap. |
|
| 1719 | + */ |
|
| 1720 | + public function block() { |
|
| 1721 | 1721 | global $sd_is_js_functions_loaded; |
| 1722 | 1722 | |
| 1723 | - ob_start(); |
|
| 1723 | + ob_start(); |
|
| 1724 | 1724 | |
| 1725 | - $show_advanced = $this->block_show_advanced(); |
|
| 1725 | + $show_advanced = $this->block_show_advanced(); |
|
| 1726 | 1726 | |
| 1727 | 1727 | |
| 1728 | - ?> |
|
| 1728 | + ?> |
|
| 1729 | 1729 | <script> |
| 1730 | 1730 | |
| 1731 | 1731 | <?php |
| 1732 | - if(!$sd_is_js_functions_loaded){ |
|
| 1732 | + if(!$sd_is_js_functions_loaded){ |
|
| 1733 | 1733 | $sd_is_js_functions_loaded = true; |
| 1734 | 1734 | ?> |
| 1735 | 1735 | |
@@ -2103,10 +2103,10 @@ discard block |
||
| 2103 | 2103 | |
| 2104 | 2104 | } |
| 2105 | 2105 | |
| 2106 | - if(method_exists($this,'block_global_js')){ |
|
| 2107 | - echo $this->block_global_js(); |
|
| 2108 | - } |
|
| 2109 | - ?> |
|
| 2106 | + if(method_exists($this,'block_global_js')){ |
|
| 2107 | + echo $this->block_global_js(); |
|
| 2108 | + } |
|
| 2109 | + ?> |
|
| 2110 | 2110 | |
| 2111 | 2111 | jQuery(function() { |
| 2112 | 2112 | |
@@ -2156,14 +2156,14 @@ discard block |
||
| 2156 | 2156 | icon: <?php echo $this->get_block_icon( $this->options['block-icon'] );?>,//'<?php echo isset( $this->options['block-icon'] ) ? esc_attr( $this->options['block-icon'] ) : 'shield-alt';?>', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/. |
| 2157 | 2157 | supports: { |
| 2158 | 2158 | <?php |
| 2159 | - if ( isset( $this->options['block-supports'] ) ) { |
|
| 2160 | - echo $this->array_to_attributes( $this->options['block-supports'] ); |
|
| 2161 | - } |
|
| 2162 | - ?> |
|
| 2159 | + if ( isset( $this->options['block-supports'] ) ) { |
|
| 2160 | + echo $this->array_to_attributes( $this->options['block-supports'] ); |
|
| 2161 | + } |
|
| 2162 | + ?> |
|
| 2163 | 2163 | }, |
| 2164 | 2164 | <?php |
| 2165 | - if ( isset( $this->options['block-label'] ) ) { |
|
| 2166 | - ?> |
|
| 2165 | + if ( isset( $this->options['block-label'] ) ) { |
|
| 2166 | + ?> |
|
| 2167 | 2167 | __experimentalLabel( attributes, { context } ) { |
| 2168 | 2168 | return <?php echo $this->options['block-label']; ?>; |
| 2169 | 2169 | }, |
@@ -2172,7 +2172,7 @@ discard block |
||
| 2172 | 2172 | ?> |
| 2173 | 2173 | category: '<?php echo isset( $this->options['block-category'] ) ? esc_attr( $this->options['block-category'] ) : 'common';?>', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed. |
| 2174 | 2174 | <?php if ( isset( $this->options['block-keywords'] ) ) { |
| 2175 | - echo "keywords : " . $this->options['block-keywords'] . ","; |
|
| 2175 | + echo "keywords : " . $this->options['block-keywords'] . ","; |
|
| 2176 | 2176 | |
| 2177 | 2177 | // // block hover preview. |
| 2178 | 2178 | // $example_args = array(); |
@@ -2197,86 +2197,86 @@ discard block |
||
| 2197 | 2197 | |
| 2198 | 2198 | } |
| 2199 | 2199 | |
| 2200 | - // maybe set no_wrap |
|
| 2201 | - $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; |
|
| 2202 | - if ( isset( $this->arguments['no_wrap'] ) && $this->arguments['no_wrap'] ) { |
|
| 2203 | - $no_wrap = true; |
|
| 2204 | - } |
|
| 2205 | - if ( $no_wrap ) { |
|
| 2206 | - $this->options['block-wrap'] = ''; |
|
| 2207 | - } |
|
| 2200 | + // maybe set no_wrap |
|
| 2201 | + $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; |
|
| 2202 | + if ( isset( $this->arguments['no_wrap'] ) && $this->arguments['no_wrap'] ) { |
|
| 2203 | + $no_wrap = true; |
|
| 2204 | + } |
|
| 2205 | + if ( $no_wrap ) { |
|
| 2206 | + $this->options['block-wrap'] = ''; |
|
| 2207 | + } |
|
| 2208 | 2208 | |
| 2209 | - // maybe load the drag/drop functions. |
|
| 2210 | - $img_drag_drop = false; |
|
| 2209 | + // maybe load the drag/drop functions. |
|
| 2210 | + $img_drag_drop = false; |
|
| 2211 | 2211 | |
| 2212 | - $show_alignment = false; |
|
| 2213 | - // align feature |
|
| 2214 | - /*echo "supports: {"; |
|
| 2212 | + $show_alignment = false; |
|
| 2213 | + // align feature |
|
| 2214 | + /*echo "supports: {"; |
|
| 2215 | 2215 | echo " align: true,"; |
| 2216 | 2216 | echo " html: false"; |
| 2217 | 2217 | echo "},";*/ |
| 2218 | 2218 | |
| 2219 | - if ( ! empty( $this->arguments ) ) { |
|
| 2220 | - echo "attributes : {"; |
|
| 2219 | + if ( ! empty( $this->arguments ) ) { |
|
| 2220 | + echo "attributes : {"; |
|
| 2221 | 2221 | |
| 2222 | - if ( $show_advanced ) { |
|
| 2223 | - echo "show_advanced: {"; |
|
| 2224 | - echo " type: 'boolean',"; |
|
| 2225 | - echo " default: false,"; |
|
| 2226 | - echo "},"; |
|
| 2227 | - } |
|
| 2222 | + if ( $show_advanced ) { |
|
| 2223 | + echo "show_advanced: {"; |
|
| 2224 | + echo " type: 'boolean',"; |
|
| 2225 | + echo " default: false,"; |
|
| 2226 | + echo "},"; |
|
| 2227 | + } |
|
| 2228 | 2228 | |
| 2229 | - // block wrap element |
|
| 2230 | - if ( ! empty( $this->options['block-wrap'] ) ) { //@todo we should validate this? |
|
| 2231 | - echo "block_wrap: {"; |
|
| 2232 | - echo " type: 'string',"; |
|
| 2233 | - echo " default: '" . esc_attr( $this->options['block-wrap'] ) . "',"; |
|
| 2234 | - echo "},"; |
|
| 2235 | - } |
|
| 2229 | + // block wrap element |
|
| 2230 | + if ( ! empty( $this->options['block-wrap'] ) ) { //@todo we should validate this? |
|
| 2231 | + echo "block_wrap: {"; |
|
| 2232 | + echo " type: 'string',"; |
|
| 2233 | + echo " default: '" . esc_attr( $this->options['block-wrap'] ) . "',"; |
|
| 2234 | + echo "},"; |
|
| 2235 | + } |
|
| 2236 | 2236 | |
| 2237 | 2237 | |
| 2238 | 2238 | |
| 2239 | - foreach ( $this->arguments as $key => $args ) { |
|
| 2239 | + foreach ( $this->arguments as $key => $args ) { |
|
| 2240 | 2240 | |
| 2241 | - if( $args['type'] == 'image' || $args['type'] == 'images' ){ |
|
| 2242 | - $img_drag_drop = true; |
|
| 2243 | - } |
|
| 2241 | + if( $args['type'] == 'image' || $args['type'] == 'images' ){ |
|
| 2242 | + $img_drag_drop = true; |
|
| 2243 | + } |
|
| 2244 | 2244 | |
| 2245 | - // set if we should show alignment |
|
| 2246 | - if ( $key == 'alignment' ) { |
|
| 2247 | - $show_alignment = true; |
|
| 2248 | - } |
|
| 2245 | + // set if we should show alignment |
|
| 2246 | + if ( $key == 'alignment' ) { |
|
| 2247 | + $show_alignment = true; |
|
| 2248 | + } |
|
| 2249 | 2249 | |
| 2250 | - $extra = ''; |
|
| 2250 | + $extra = ''; |
|
| 2251 | 2251 | |
| 2252 | - if ( $args['type'] == 'notice' || $args['type'] == 'tab' ) { |
|
| 2253 | - continue; |
|
| 2254 | - } |
|
| 2255 | - elseif ( $args['type'] == 'checkbox' ) { |
|
| 2256 | - $type = 'boolean'; |
|
| 2257 | - $default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false'; |
|
| 2258 | - } elseif ( $args['type'] == 'number' ) { |
|
| 2259 | - $type = 'number'; |
|
| 2260 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2261 | - } elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) { |
|
| 2262 | - $type = 'array'; |
|
| 2263 | - if ( isset( $args['default'] ) && is_array( $args['default'] ) ) { |
|
| 2264 | - $default = ! empty( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]"; |
|
| 2265 | - } else { |
|
| 2266 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2267 | - } |
|
| 2268 | - } elseif ( $args['type'] == 'tagselect' ) { |
|
| 2269 | - $type = 'array'; |
|
| 2270 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2271 | - } elseif ( $args['type'] == 'multiselect' ) { |
|
| 2272 | - $type = 'array'; |
|
| 2273 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2274 | - } elseif ( $args['type'] == 'image_xy' ) { |
|
| 2275 | - $type = 'object'; |
|
| 2276 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2277 | - } elseif ( $args['type'] == 'image' ) { |
|
| 2278 | - $type = 'string'; |
|
| 2279 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2252 | + if ( $args['type'] == 'notice' || $args['type'] == 'tab' ) { |
|
| 2253 | + continue; |
|
| 2254 | + } |
|
| 2255 | + elseif ( $args['type'] == 'checkbox' ) { |
|
| 2256 | + $type = 'boolean'; |
|
| 2257 | + $default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false'; |
|
| 2258 | + } elseif ( $args['type'] == 'number' ) { |
|
| 2259 | + $type = 'number'; |
|
| 2260 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2261 | + } elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) { |
|
| 2262 | + $type = 'array'; |
|
| 2263 | + if ( isset( $args['default'] ) && is_array( $args['default'] ) ) { |
|
| 2264 | + $default = ! empty( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]"; |
|
| 2265 | + } else { |
|
| 2266 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2267 | + } |
|
| 2268 | + } elseif ( $args['type'] == 'tagselect' ) { |
|
| 2269 | + $type = 'array'; |
|
| 2270 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2271 | + } elseif ( $args['type'] == 'multiselect' ) { |
|
| 2272 | + $type = 'array'; |
|
| 2273 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2274 | + } elseif ( $args['type'] == 'image_xy' ) { |
|
| 2275 | + $type = 'object'; |
|
| 2276 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2277 | + } elseif ( $args['type'] == 'image' ) { |
|
| 2278 | + $type = 'string'; |
|
| 2279 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2280 | 2280 | |
| 2281 | 2281 | // add a field for ID |
| 2282 | 2282 | // echo $key . "_id : {"; |
@@ -2286,25 +2286,25 @@ discard block |
||
| 2286 | 2286 | // echo "type : 'object',"; |
| 2287 | 2287 | // echo "},"; |
| 2288 | 2288 | |
| 2289 | - } else { |
|
| 2290 | - $type = !empty($args['hidden_type']) ? esc_attr($args['hidden_type']) : 'string'; |
|
| 2291 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2289 | + } else { |
|
| 2290 | + $type = !empty($args['hidden_type']) ? esc_attr($args['hidden_type']) : 'string'; |
|
| 2291 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2292 | 2292 | |
| 2293 | - } |
|
| 2294 | - echo $key . " : {"; |
|
| 2295 | - echo "type : '$type',"; |
|
| 2296 | - echo "default : $default,"; |
|
| 2297 | - echo "},"; |
|
| 2298 | - } |
|
| 2293 | + } |
|
| 2294 | + echo $key . " : {"; |
|
| 2295 | + echo "type : '$type',"; |
|
| 2296 | + echo "default : $default,"; |
|
| 2297 | + echo "},"; |
|
| 2298 | + } |
|
| 2299 | 2299 | |
| 2300 | - echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},"; |
|
| 2301 | - echo "className: { type: 'string', default: '' },"; |
|
| 2300 | + echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},"; |
|
| 2301 | + echo "className: { type: 'string', default: '' },"; |
|
| 2302 | 2302 | |
| 2303 | - echo "},"; |
|
| 2303 | + echo "},"; |
|
| 2304 | 2304 | |
| 2305 | - } |
|
| 2305 | + } |
|
| 2306 | 2306 | |
| 2307 | - ?> |
|
| 2307 | + ?> |
|
| 2308 | 2308 | |
| 2309 | 2309 | // The "edit" property must be a valid function. |
| 2310 | 2310 | edit: function (props) { |
@@ -2404,9 +2404,9 @@ discard block |
||
| 2404 | 2404 | |
| 2405 | 2405 | var $value = ''; |
| 2406 | 2406 | <?php |
| 2407 | - // if we have a post_type and a category then link them |
|
| 2408 | - if( isset($this->arguments['post_type']) && isset($this->arguments['category']) && !empty($this->arguments['category']['post_type_linked']) ){ |
|
| 2409 | - ?> |
|
| 2407 | + // if we have a post_type and a category then link them |
|
| 2408 | + if( isset($this->arguments['post_type']) && isset($this->arguments['category']) && !empty($this->arguments['category']['post_type_linked']) ){ |
|
| 2409 | + ?> |
|
| 2410 | 2410 | if(typeof(prev_attributes[props.clientId]) != 'undefined' ){ |
| 2411 | 2411 | $pt = props.attributes.post_type; |
| 2412 | 2412 | if(post_type_rest_slugs.length){ |
@@ -2469,7 +2469,7 @@ discard block |
||
| 2469 | 2469 | <?php |
| 2470 | 2470 | $current_screen = function_exists('get_current_screen') ? get_current_screen() : ''; |
| 2471 | 2471 | if(!empty($current_screen->base) && $current_screen->base==='widgets'){ |
| 2472 | - echo 'const { deviceType } = "";'; |
|
| 2472 | + echo 'const { deviceType } = "";'; |
|
| 2473 | 2473 | }else{ |
| 2474 | 2474 | ?> |
| 2475 | 2475 | /** Get device type const. */ |
@@ -2503,8 +2503,8 @@ discard block |
||
| 2503 | 2503 | 'attributes': props.attributes, |
| 2504 | 2504 | 'block_parent_name': parentBlocks.length ? parentBlocks[parentBlocks.length - 1].name : '', |
| 2505 | 2505 | 'post_id': <?php global $post; if ( isset( $post->ID ) ) { |
| 2506 | - echo $post->ID; |
|
| 2507 | - }else{echo '0';}?>, |
|
| 2506 | + echo $post->ID; |
|
| 2507 | + }else{echo '0';}?>, |
|
| 2508 | 2508 | '_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>' |
| 2509 | 2509 | }; |
| 2510 | 2510 | |
@@ -2581,10 +2581,10 @@ discard block |
||
| 2581 | 2581 | |
| 2582 | 2582 | <?php |
| 2583 | 2583 | |
| 2584 | - if(! empty( $this->arguments )){ |
|
| 2584 | + if(! empty( $this->arguments )){ |
|
| 2585 | 2585 | |
| 2586 | - if ( $show_advanced ) { |
|
| 2587 | - ?> |
|
| 2586 | + if ( $show_advanced ) { |
|
| 2587 | + ?> |
|
| 2588 | 2588 | el('div', { |
| 2589 | 2589 | style: {'padding-left': '16px','padding-right': '16px'} |
| 2590 | 2590 | }, |
@@ -2602,146 +2602,146 @@ discard block |
||
| 2602 | 2602 | , |
| 2603 | 2603 | <?php |
| 2604 | 2604 | |
| 2605 | - } |
|
| 2605 | + } |
|
| 2606 | 2606 | |
| 2607 | - // print_r( $this->arguments); |
|
| 2607 | + // print_r( $this->arguments); |
|
| 2608 | 2608 | |
| 2609 | - //echo '####'; |
|
| 2609 | + //echo '####'; |
|
| 2610 | 2610 | |
| 2611 | - $arguments = $this->group_arguments( $this->arguments ); |
|
| 2611 | + $arguments = $this->group_arguments( $this->arguments ); |
|
| 2612 | 2612 | //print_r($arguments ); exit; |
| 2613 | - // Do we have sections? |
|
| 2614 | - $has_sections = $arguments == $this->arguments ? false : true; |
|
| 2613 | + // Do we have sections? |
|
| 2614 | + $has_sections = $arguments == $this->arguments ? false : true; |
|
| 2615 | 2615 | |
| 2616 | 2616 | |
| 2617 | - if($has_sections){ |
|
| 2618 | - $panel_count = 0; |
|
| 2619 | - $open_tab = ''; |
|
| 2617 | + if($has_sections){ |
|
| 2618 | + $panel_count = 0; |
|
| 2619 | + $open_tab = ''; |
|
| 2620 | 2620 | |
| 2621 | - $open_tab_groups = array(); |
|
| 2622 | - $used_tabs = array(); |
|
| 2623 | - foreach($arguments as $key => $args){ |
|
| 2621 | + $open_tab_groups = array(); |
|
| 2622 | + $used_tabs = array(); |
|
| 2623 | + foreach($arguments as $key => $args){ |
|
| 2624 | 2624 | |
| 2625 | - $close_tab = false; |
|
| 2626 | - $close_tabs = false; |
|
| 2625 | + $close_tab = false; |
|
| 2626 | + $close_tabs = false; |
|
| 2627 | 2627 | |
| 2628 | - if(!empty($this->options['block_group_tabs'])) { |
|
| 2629 | - foreach($this->options['block_group_tabs'] as $tab_name => $tab_args){ |
|
| 2630 | - if(in_array($key,$tab_args['groups'])){ |
|
| 2628 | + if(!empty($this->options['block_group_tabs'])) { |
|
| 2629 | + foreach($this->options['block_group_tabs'] as $tab_name => $tab_args){ |
|
| 2630 | + if(in_array($key,$tab_args['groups'])){ |
|
| 2631 | 2631 | |
| 2632 | - $open_tab_groups[] = $key; |
|
| 2632 | + $open_tab_groups[] = $key; |
|
| 2633 | 2633 | |
| 2634 | - if($open_tab != $tab_name){ |
|
| 2635 | - $tab_args['tab']['tabs_open'] = $open_tab == '' ? true : false; |
|
| 2636 | - $tab_args['tab']['open'] = true; |
|
| 2634 | + if($open_tab != $tab_name){ |
|
| 2635 | + $tab_args['tab']['tabs_open'] = $open_tab == '' ? true : false; |
|
| 2636 | + $tab_args['tab']['open'] = true; |
|
| 2637 | 2637 | |
| 2638 | - $this->block_tab_start( '', $tab_args ); |
|
| 2638 | + $this->block_tab_start( '', $tab_args ); |
|
| 2639 | 2639 | // echo '###open'.$tab_name;print_r($tab_args); |
| 2640 | - $open_tab = $tab_name; |
|
| 2641 | - $used_tabs[] = $tab_name; |
|
| 2642 | - } |
|
| 2640 | + $open_tab = $tab_name; |
|
| 2641 | + $used_tabs[] = $tab_name; |
|
| 2642 | + } |
|
| 2643 | 2643 | |
| 2644 | - if($open_tab_groups == $tab_args['groups']){ |
|
| 2645 | - //$open_tab = ''; |
|
| 2646 | - $close_tab = true; |
|
| 2647 | - $open_tab_groups = array(); |
|
| 2644 | + if($open_tab_groups == $tab_args['groups']){ |
|
| 2645 | + //$open_tab = ''; |
|
| 2646 | + $close_tab = true; |
|
| 2647 | + $open_tab_groups = array(); |
|
| 2648 | 2648 | |
| 2649 | 2649 | // print_r(array_keys($this->options['block_group_tabs']));echo '####';print_r($used_tabs); |
| 2650 | - if($used_tabs == array_keys($this->options['block_group_tabs'])){ |
|
| 2650 | + if($used_tabs == array_keys($this->options['block_group_tabs'])){ |
|
| 2651 | 2651 | // echo '@@@'; |
| 2652 | - $close_tabs = true; |
|
| 2653 | - } |
|
| 2654 | - } |
|
| 2652 | + $close_tabs = true; |
|
| 2653 | + } |
|
| 2654 | + } |
|
| 2655 | 2655 | |
| 2656 | - } |
|
| 2657 | - } |
|
| 2658 | - } |
|
| 2656 | + } |
|
| 2657 | + } |
|
| 2658 | + } |
|
| 2659 | 2659 | |
| 2660 | 2660 | // |
| 2661 | 2661 | |
| 2662 | - // print_r($arguments);exit; |
|
| 2662 | + // print_r($arguments);exit; |
|
| 2663 | 2663 | |
| 2664 | - ?> |
|
| 2664 | + ?> |
|
| 2665 | 2665 | el(wp.components.PanelBody, { |
| 2666 | 2666 | title: '<?php esc_attr_e( $key ); ?>', |
| 2667 | 2667 | initialOpen: <?php if ( $panel_count ) { |
| 2668 | - echo "false"; |
|
| 2669 | - } else { |
|
| 2670 | - echo "true"; |
|
| 2671 | - }?> |
|
| 2668 | + echo "false"; |
|
| 2669 | + } else { |
|
| 2670 | + echo "true"; |
|
| 2671 | + }?> |
|
| 2672 | 2672 | }, |
| 2673 | 2673 | <?php |
| 2674 | 2674 | |
| 2675 | 2675 | |
| 2676 | 2676 | |
| 2677 | - foreach ( $args as $k => $a ) { |
|
| 2677 | + foreach ( $args as $k => $a ) { |
|
| 2678 | 2678 | |
| 2679 | - $this->block_tab_start( $k, $a ); |
|
| 2680 | - $this->block_row_start( $k, $a ); |
|
| 2681 | - $this->build_block_arguments( $k, $a ); |
|
| 2682 | - $this->block_row_end( $k, $a ); |
|
| 2683 | - $this->block_tab_end( $k, $a ); |
|
| 2684 | - } |
|
| 2685 | - ?> |
|
| 2679 | + $this->block_tab_start( $k, $a ); |
|
| 2680 | + $this->block_row_start( $k, $a ); |
|
| 2681 | + $this->build_block_arguments( $k, $a ); |
|
| 2682 | + $this->block_row_end( $k, $a ); |
|
| 2683 | + $this->block_tab_end( $k, $a ); |
|
| 2684 | + } |
|
| 2685 | + ?> |
|
| 2686 | 2686 | ), |
| 2687 | 2687 | <?php |
| 2688 | - $panel_count ++; |
|
| 2688 | + $panel_count ++; |
|
| 2689 | 2689 | |
| 2690 | 2690 | |
| 2691 | - if($close_tab || $close_tabs){ |
|
| 2692 | - $tab_args = array( |
|
| 2693 | - 'tab' => array( |
|
| 2694 | - 'tabs_close' => $close_tabs, |
|
| 2695 | - 'close' => true, |
|
| 2696 | - ) |
|
| 2691 | + if($close_tab || $close_tabs){ |
|
| 2692 | + $tab_args = array( |
|
| 2693 | + 'tab' => array( |
|
| 2694 | + 'tabs_close' => $close_tabs, |
|
| 2695 | + 'close' => true, |
|
| 2696 | + ) |
|
| 2697 | 2697 | |
| 2698 | - ); |
|
| 2699 | - $this->block_tab_end( '', $tab_args ); |
|
| 2698 | + ); |
|
| 2699 | + $this->block_tab_end( '', $tab_args ); |
|
| 2700 | 2700 | // echo '###close'; print_r($tab_args); |
| 2701 | - $panel_count = 0; |
|
| 2702 | - } |
|
| 2701 | + $panel_count = 0; |
|
| 2702 | + } |
|
| 2703 | 2703 | // |
| 2704 | 2704 | |
| 2705 | - } |
|
| 2706 | - }else { |
|
| 2707 | - ?> |
|
| 2705 | + } |
|
| 2706 | + }else { |
|
| 2707 | + ?> |
|
| 2708 | 2708 | el(wp.components.PanelBody, { |
| 2709 | 2709 | title: '<?php esc_attr_e( "Settings" ); ?>', |
| 2710 | 2710 | initialOpen: true |
| 2711 | 2711 | }, |
| 2712 | 2712 | <?php |
| 2713 | - foreach ( $this->arguments as $key => $args ) { |
|
| 2714 | - $this->block_row_start( $key, $args ); |
|
| 2715 | - $this->build_block_arguments( $key, $args ); |
|
| 2716 | - $this->block_row_end( $key, $args ); |
|
| 2717 | - } |
|
| 2718 | - ?> |
|
| 2713 | + foreach ( $this->arguments as $key => $args ) { |
|
| 2714 | + $this->block_row_start( $key, $args ); |
|
| 2715 | + $this->build_block_arguments( $key, $args ); |
|
| 2716 | + $this->block_row_end( $key, $args ); |
|
| 2717 | + } |
|
| 2718 | + ?> |
|
| 2719 | 2719 | ), |
| 2720 | 2720 | <?php |
| 2721 | - } |
|
| 2721 | + } |
|
| 2722 | 2722 | |
| 2723 | - } |
|
| 2724 | - ?> |
|
| 2723 | + } |
|
| 2724 | + ?> |
|
| 2725 | 2725 | |
| 2726 | 2726 | ), |
| 2727 | 2727 | |
| 2728 | 2728 | <?php |
| 2729 | - // If the user sets block-output array then build it |
|
| 2730 | - if ( ! empty( $this->options['block-output'] ) ) { |
|
| 2731 | - $this->block_element( $this->options['block-output'] ); |
|
| 2732 | - }elseif(!empty($this->options['block-edit-return'])){ |
|
| 2733 | - echo $this->options['block-edit-return']; |
|
| 2734 | - }else{ |
|
| 2735 | - // if no block-output is set then we try and get the shortcode html output via ajax. |
|
| 2736 | - ?> |
|
| 2729 | + // If the user sets block-output array then build it |
|
| 2730 | + if ( ! empty( $this->options['block-output'] ) ) { |
|
| 2731 | + $this->block_element( $this->options['block-output'] ); |
|
| 2732 | + }elseif(!empty($this->options['block-edit-return'])){ |
|
| 2733 | + echo $this->options['block-edit-return']; |
|
| 2734 | + }else{ |
|
| 2735 | + // if no block-output is set then we try and get the shortcode html output via ajax. |
|
| 2736 | + ?> |
|
| 2737 | 2737 | el('div', wp.blockEditor.useBlockProps({ |
| 2738 | 2738 | dangerouslySetInnerHTML: {__html: onChangeContent()}, |
| 2739 | 2739 | className: props.className, |
| 2740 | 2740 | style: {'minHeight': '30px'} |
| 2741 | 2741 | })) |
| 2742 | 2742 | <?php |
| 2743 | - } |
|
| 2744 | - ?> |
|
| 2743 | + } |
|
| 2744 | + ?> |
|
| 2745 | 2745 | ]; // end return |
| 2746 | 2746 | |
| 2747 | 2747 | <?php |
@@ -2760,11 +2760,11 @@ discard block |
||
| 2760 | 2760 | $html = ''; |
| 2761 | 2761 | <?php |
| 2762 | 2762 | |
| 2763 | - if(! empty( $this->arguments )){ |
|
| 2763 | + if(! empty( $this->arguments )){ |
|
| 2764 | 2764 | |
| 2765 | - foreach($this->arguments as $key => $args){ |
|
| 2766 | - // if($args['type']=='tabs'){continue;} |
|
| 2767 | - ?> |
|
| 2765 | + foreach($this->arguments as $key => $args){ |
|
| 2766 | + // if($args['type']=='tabs'){continue;} |
|
| 2767 | + ?> |
|
| 2768 | 2768 | if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) { |
| 2769 | 2769 | if ('<?php echo esc_attr( $key );?>' == 'html') { |
| 2770 | 2770 | $html = attr.<?php echo esc_attr( $key );?>; |
@@ -2775,10 +2775,10 @@ discard block |
||
| 2775 | 2775 | } |
| 2776 | 2776 | } |
| 2777 | 2777 | <?php |
| 2778 | - } |
|
| 2779 | - } |
|
| 2778 | + } |
|
| 2779 | + } |
|
| 2780 | 2780 | |
| 2781 | - ?> |
|
| 2781 | + ?> |
|
| 2782 | 2782 | content += "]"; |
| 2783 | 2783 | |
| 2784 | 2784 | <?php |
@@ -2825,7 +2825,7 @@ discard block |
||
| 2825 | 2825 | // $this->block_element( $this->options['block-output'], true ); |
| 2826 | 2826 | // echo ";"; |
| 2827 | 2827 | |
| 2828 | - ?> |
|
| 2828 | + ?> |
|
| 2829 | 2829 | return el( |
| 2830 | 2830 | '', |
| 2831 | 2831 | {}, |
@@ -2835,9 +2835,9 @@ discard block |
||
| 2835 | 2835 | ); |
| 2836 | 2836 | <?php |
| 2837 | 2837 | |
| 2838 | - }elseif(!empty($this->options['block-save-return'])){ |
|
| 2839 | - echo 'return ' . $this->options['block-save-return']; |
|
| 2840 | - }elseif(!empty($this->options['nested-block'])){ |
|
| 2838 | + }elseif(!empty($this->options['block-save-return'])){ |
|
| 2839 | + echo 'return ' . $this->options['block-save-return']; |
|
| 2840 | + }elseif(!empty($this->options['nested-block'])){ |
|
| 2841 | 2841 | ?> |
| 2842 | 2842 | return el( |
| 2843 | 2843 | '', |
@@ -2847,22 +2847,22 @@ discard block |
||
| 2847 | 2847 | el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id'];?>]"}}) |
| 2848 | 2848 | ); |
| 2849 | 2849 | <?php |
| 2850 | - }elseif(!empty( $this->options['block-save-return'] ) ){ |
|
| 2850 | + }elseif(!empty( $this->options['block-save-return'] ) ){ |
|
| 2851 | 2851 | echo "return ". $this->options['block-edit-return'].";"; |
| 2852 | - }elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){ |
|
| 2853 | - ?> |
|
| 2852 | + }elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){ |
|
| 2853 | + ?> |
|
| 2854 | 2854 | return content; |
| 2855 | 2855 | <?php |
| 2856 | - }else{ |
|
| 2857 | - ?> |
|
| 2856 | + }else{ |
|
| 2857 | + ?> |
|
| 2858 | 2858 | var block_wrap = 'div'; |
| 2859 | 2859 | if (attr.hasOwnProperty("block_wrap")) { |
| 2860 | 2860 | block_wrap = attr.block_wrap; |
| 2861 | 2861 | } |
| 2862 | 2862 | return el(block_wrap, wp.blockEditor.useBlockProps.save( {dangerouslySetInnerHTML: {__html: content}, className: align} )); |
| 2863 | 2863 | <?php |
| 2864 | - } |
|
| 2865 | - ?> |
|
| 2864 | + } |
|
| 2865 | + ?> |
|
| 2866 | 2866 | |
| 2867 | 2867 | |
| 2868 | 2868 | } |
@@ -2876,29 +2876,29 @@ discard block |
||
| 2876 | 2876 | }); |
| 2877 | 2877 | </script> |
| 2878 | 2878 | <?php |
| 2879 | - $output = ob_get_clean(); |
|
| 2879 | + $output = ob_get_clean(); |
|
| 2880 | 2880 | |
| 2881 | - /* |
|
| 2881 | + /* |
|
| 2882 | 2882 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 2883 | 2883 | */ |
| 2884 | 2884 | |
| 2885 | - return str_replace( array( |
|
| 2886 | - '<script>', |
|
| 2887 | - '</script>' |
|
| 2888 | - ), '', $output ); |
|
| 2889 | - } |
|
| 2885 | + return str_replace( array( |
|
| 2886 | + '<script>', |
|
| 2887 | + '</script>' |
|
| 2888 | + ), '', $output ); |
|
| 2889 | + } |
|
| 2890 | 2890 | |
| 2891 | 2891 | |
| 2892 | 2892 | |
| 2893 | - public function block_row_start($key, $args){ |
|
| 2893 | + public function block_row_start($key, $args){ |
|
| 2894 | 2894 | |
| 2895 | - // check for row |
|
| 2896 | - if(!empty($args['row'])){ |
|
| 2895 | + // check for row |
|
| 2896 | + if(!empty($args['row'])){ |
|
| 2897 | 2897 | |
| 2898 | - if(!empty($args['row']['open'])){ |
|
| 2898 | + if(!empty($args['row']['open'])){ |
|
| 2899 | 2899 | |
| 2900 | - // element require |
|
| 2901 | - $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : ""; |
|
| 2900 | + // element require |
|
| 2901 | + $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : ""; |
|
| 2902 | 2902 | $device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : ''; |
| 2903 | 2903 | $device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : ''; |
| 2904 | 2904 | $device_type_icon = ''; |
@@ -2909,10 +2909,10 @@ discard block |
||
| 2909 | 2909 | }elseif($device_type=='Mobile'){ |
| 2910 | 2910 | $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>'; |
| 2911 | 2911 | } |
| 2912 | - echo $element_require; |
|
| 2912 | + echo $element_require; |
|
| 2913 | 2913 | echo $device_type_require; |
| 2914 | 2914 | |
| 2915 | - if(false){?><script><?php }?> |
|
| 2915 | + if(false){?><script><?php }?> |
|
| 2916 | 2916 | el('div', { |
| 2917 | 2917 | className: 'bsui components-base-control', |
| 2918 | 2918 | }, |
@@ -2950,51 +2950,51 @@ discard block |
||
| 2950 | 2950 | }, |
| 2951 | 2951 | |
| 2952 | 2952 | <?php |
| 2953 | - if(false){?></script><?php } |
|
| 2954 | - }elseif(!empty($args['row']['close'])){ |
|
| 2955 | - if(false){?><script><?php }?> |
|
| 2953 | + if(false){?></script><?php } |
|
| 2954 | + }elseif(!empty($args['row']['close'])){ |
|
| 2955 | + if(false){?><script><?php }?> |
|
| 2956 | 2956 | el( |
| 2957 | 2957 | 'div', |
| 2958 | 2958 | { |
| 2959 | 2959 | className: 'col pl-0', |
| 2960 | 2960 | }, |
| 2961 | 2961 | <?php |
| 2962 | - if(false){?></script><?php } |
|
| 2963 | - }else{ |
|
| 2964 | - if(false){?><script><?php }?> |
|
| 2962 | + if(false){?></script><?php } |
|
| 2963 | + }else{ |
|
| 2964 | + if(false){?><script><?php }?> |
|
| 2965 | 2965 | el( |
| 2966 | 2966 | 'div', |
| 2967 | 2967 | { |
| 2968 | 2968 | className: 'col pl-0 pr-2', |
| 2969 | 2969 | }, |
| 2970 | 2970 | <?php |
| 2971 | - if(false){?></script><?php } |
|
| 2972 | - } |
|
| 2971 | + if(false){?></script><?php } |
|
| 2972 | + } |
|
| 2973 | 2973 | |
| 2974 | - } |
|
| 2974 | + } |
|
| 2975 | 2975 | |
| 2976 | - } |
|
| 2976 | + } |
|
| 2977 | 2977 | |
| 2978 | - public function block_row_end($key, $args){ |
|
| 2978 | + public function block_row_end($key, $args){ |
|
| 2979 | 2979 | |
| 2980 | - if(!empty($args['row'])){ |
|
| 2981 | - // maybe close |
|
| 2982 | - if(!empty($args['row']['close'])){ |
|
| 2983 | - echo "))"; |
|
| 2984 | - } |
|
| 2980 | + if(!empty($args['row'])){ |
|
| 2981 | + // maybe close |
|
| 2982 | + if(!empty($args['row']['close'])){ |
|
| 2983 | + echo "))"; |
|
| 2984 | + } |
|
| 2985 | 2985 | |
| 2986 | - echo "),"; |
|
| 2987 | - } |
|
| 2988 | - } |
|
| 2986 | + echo "),"; |
|
| 2987 | + } |
|
| 2988 | + } |
|
| 2989 | 2989 | |
| 2990 | - public function block_tab_start($key, $args){ |
|
| 2990 | + public function block_tab_start($key, $args){ |
|
| 2991 | 2991 | |
| 2992 | - // check for row |
|
| 2993 | - if(!empty($args['tab'])){ |
|
| 2992 | + // check for row |
|
| 2993 | + if(!empty($args['tab'])){ |
|
| 2994 | 2994 | |
| 2995 | - if(!empty($args['tab']['tabs_open'])){ |
|
| 2995 | + if(!empty($args['tab']['tabs_open'])){ |
|
| 2996 | 2996 | |
| 2997 | - if(false){?><script><?php }?> |
|
| 2997 | + if(false){?><script><?php }?> |
|
| 2998 | 2998 | |
| 2999 | 2999 | el('div',{className: 'bsui'}, |
| 3000 | 3000 | |
@@ -3007,12 +3007,12 @@ discard block |
||
| 3007 | 3007 | tabs: [ |
| 3008 | 3008 | |
| 3009 | 3009 | <?php |
| 3010 | - if(false){?></script><?php } |
|
| 3011 | - } |
|
| 3010 | + if(false){?></script><?php } |
|
| 3011 | + } |
|
| 3012 | 3012 | |
| 3013 | - if(!empty($args['tab']['open'])){ |
|
| 3013 | + if(!empty($args['tab']['open'])){ |
|
| 3014 | 3014 | |
| 3015 | - if(false){?><script><?php }?> |
|
| 3015 | + if(false){?><script><?php }?> |
|
| 3016 | 3016 | { |
| 3017 | 3017 | name: '<?php echo addslashes( esc_attr( $args['tab']['key']) ); ?>', |
| 3018 | 3018 | title: el('div', {dangerouslySetInnerHTML: {__html: '<?php echo addslashes( esc_attr( $args['tab']['title']) ); ?>'}}), |
@@ -3021,23 +3021,23 @@ discard block |
||
| 3021 | 3021 | className: 'components-base-control__help mb-0', |
| 3022 | 3022 | dangerouslySetInnerHTML: {__html:'<?php echo addslashes( $args['tab']['desc'] ); ?>'} |
| 3023 | 3023 | }),<?php } |
| 3024 | - if(false){?></script><?php } |
|
| 3025 | - } |
|
| 3024 | + if(false){?></script><?php } |
|
| 3025 | + } |
|
| 3026 | 3026 | |
| 3027 | - } |
|
| 3027 | + } |
|
| 3028 | 3028 | |
| 3029 | - } |
|
| 3029 | + } |
|
| 3030 | 3030 | |
| 3031 | - public function block_tab_end($key, $args){ |
|
| 3031 | + public function block_tab_end($key, $args){ |
|
| 3032 | 3032 | |
| 3033 | - if(!empty($args['tab'])){ |
|
| 3034 | - // maybe close |
|
| 3035 | - if(!empty($args['tab']['close'])){ |
|
| 3036 | - echo ")}, /* tab close */"; |
|
| 3037 | - } |
|
| 3033 | + if(!empty($args['tab'])){ |
|
| 3034 | + // maybe close |
|
| 3035 | + if(!empty($args['tab']['close'])){ |
|
| 3036 | + echo ")}, /* tab close */"; |
|
| 3037 | + } |
|
| 3038 | 3038 | |
| 3039 | - if(!empty($args['tab']['tabs_close'])){ |
|
| 3040 | - if(false){?><script><?php }?> |
|
| 3039 | + if(!empty($args['tab']['tabs_close'])){ |
|
| 3040 | + if(false){?><script><?php }?> |
|
| 3041 | 3041 | ], |
| 3042 | 3042 | }, |
| 3043 | 3043 | ( tab ) => { |
@@ -3047,22 +3047,22 @@ discard block |
||
| 3047 | 3047 | } |
| 3048 | 3048 | )), /* tabs close */ |
| 3049 | 3049 | <?php if(false){ ?></script><?php } |
| 3050 | - } |
|
| 3051 | - } |
|
| 3052 | - } |
|
| 3050 | + } |
|
| 3051 | + } |
|
| 3052 | + } |
|
| 3053 | 3053 | |
| 3054 | - public function build_block_arguments( $key, $args ) { |
|
| 3055 | - $custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : ''; |
|
| 3056 | - $options = ''; |
|
| 3057 | - $extra = ''; |
|
| 3058 | - $require = ''; |
|
| 3054 | + public function build_block_arguments( $key, $args ) { |
|
| 3055 | + $custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : ''; |
|
| 3056 | + $options = ''; |
|
| 3057 | + $extra = ''; |
|
| 3058 | + $require = ''; |
|
| 3059 | 3059 | $inside_elements = ''; |
| 3060 | - $after_elements = ''; |
|
| 3060 | + $after_elements = ''; |
|
| 3061 | 3061 | |
| 3062 | - // `content` is a protected and special argument |
|
| 3063 | - if ( $key == 'content' ) { |
|
| 3064 | - return; |
|
| 3065 | - } |
|
| 3062 | + // `content` is a protected and special argument |
|
| 3063 | + if ( $key == 'content' ) { |
|
| 3064 | + return; |
|
| 3065 | + } |
|
| 3066 | 3066 | |
| 3067 | 3067 | $device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : ''; |
| 3068 | 3068 | $device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : ''; |
@@ -3075,51 +3075,51 @@ discard block |
||
| 3075 | 3075 | $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>'; |
| 3076 | 3076 | } |
| 3077 | 3077 | |
| 3078 | - // icon |
|
| 3079 | - $icon = ''; |
|
| 3080 | - if( !empty( $args['icon'] ) ){ |
|
| 3081 | - $icon .= "el('div', {"; |
|
| 3082 | - $icon .= "dangerouslySetInnerHTML: {__html: '".self::get_widget_icon( esc_attr($args['icon']))."'},"; |
|
| 3083 | - $icon .= "className: 'text-center',"; |
|
| 3084 | - $icon .= "title: '".addslashes( $args['title'] )."',"; |
|
| 3085 | - $icon .= "}),"; |
|
| 3086 | - |
|
| 3087 | - // blank title as its added to the icon. |
|
| 3088 | - $args['title'] = ''; |
|
| 3089 | - } |
|
| 3078 | + // icon |
|
| 3079 | + $icon = ''; |
|
| 3080 | + if( !empty( $args['icon'] ) ){ |
|
| 3081 | + $icon .= "el('div', {"; |
|
| 3082 | + $icon .= "dangerouslySetInnerHTML: {__html: '".self::get_widget_icon( esc_attr($args['icon']))."'},"; |
|
| 3083 | + $icon .= "className: 'text-center',"; |
|
| 3084 | + $icon .= "title: '".addslashes( $args['title'] )."',"; |
|
| 3085 | + $icon .= "}),"; |
|
| 3086 | + |
|
| 3087 | + // blank title as its added to the icon. |
|
| 3088 | + $args['title'] = ''; |
|
| 3089 | + } |
|
| 3090 | 3090 | |
| 3091 | - // require advanced |
|
| 3092 | - $require_advanced = ! empty( $args['advanced'] ) ? "props.attributes.show_advanced && " : ""; |
|
| 3091 | + // require advanced |
|
| 3092 | + $require_advanced = ! empty( $args['advanced'] ) ? "props.attributes.show_advanced && " : ""; |
|
| 3093 | 3093 | |
| 3094 | - // element require |
|
| 3095 | - $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : ""; |
|
| 3094 | + // element require |
|
| 3095 | + $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : ""; |
|
| 3096 | 3096 | |
| 3097 | 3097 | |
| 3098 | - $onchange = "props.setAttributes({ $key: $key } )"; |
|
| 3099 | - $onchangecomplete = ""; |
|
| 3100 | - $value = "props.attributes.$key"; |
|
| 3101 | - $text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'colorx','range' ); |
|
| 3102 | - if ( in_array( $args['type'], $text_type ) ) { |
|
| 3103 | - $type = 'TextControl'; |
|
| 3104 | - // Save numbers as numbers and not strings |
|
| 3105 | - if ( $args['type'] == 'number' ) { |
|
| 3106 | - $onchange = "props.setAttributes({ $key: $key ? Number($key) : '' } )"; |
|
| 3107 | - } |
|
| 3108 | - }else if ( $args['type'] == 'styleid' ) { |
|
| 3109 | - $type = 'TextControl'; |
|
| 3110 | - $args['type'] == 'text'; |
|
| 3111 | - // Save numbers as numbers and not strings |
|
| 3112 | - $value = "props.attributes.$key ? props.attributes.$key : 'aaabbbccc'"; |
|
| 3113 | - }else if ( $args['type'] == 'notice' ) { |
|
| 3114 | - |
|
| 3115 | - $notice_message = !empty($args['desc']) ? addslashes($args['desc']) : ''; |
|
| 3116 | - $notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info'; |
|
| 3117 | - |
|
| 3118 | - $notice = "el('div',{className:'bsui'},el(wp.components.Notice, {status: '$notice_status',isDismissible: false,className: 'm-0 pr-0 mb-3'},el('div',{dangerouslySetInnerHTML: {__html: '$notice_message'}}))),"; |
|
| 3119 | - echo $notice_message ? $element_require . $notice : ''; |
|
| 3120 | - return; |
|
| 3121 | - } |
|
| 3122 | - /* |
|
| 3098 | + $onchange = "props.setAttributes({ $key: $key } )"; |
|
| 3099 | + $onchangecomplete = ""; |
|
| 3100 | + $value = "props.attributes.$key"; |
|
| 3101 | + $text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'colorx','range' ); |
|
| 3102 | + if ( in_array( $args['type'], $text_type ) ) { |
|
| 3103 | + $type = 'TextControl'; |
|
| 3104 | + // Save numbers as numbers and not strings |
|
| 3105 | + if ( $args['type'] == 'number' ) { |
|
| 3106 | + $onchange = "props.setAttributes({ $key: $key ? Number($key) : '' } )"; |
|
| 3107 | + } |
|
| 3108 | + }else if ( $args['type'] == 'styleid' ) { |
|
| 3109 | + $type = 'TextControl'; |
|
| 3110 | + $args['type'] == 'text'; |
|
| 3111 | + // Save numbers as numbers and not strings |
|
| 3112 | + $value = "props.attributes.$key ? props.attributes.$key : 'aaabbbccc'"; |
|
| 3113 | + }else if ( $args['type'] == 'notice' ) { |
|
| 3114 | + |
|
| 3115 | + $notice_message = !empty($args['desc']) ? addslashes($args['desc']) : ''; |
|
| 3116 | + $notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info'; |
|
| 3117 | + |
|
| 3118 | + $notice = "el('div',{className:'bsui'},el(wp.components.Notice, {status: '$notice_status',isDismissible: false,className: 'm-0 pr-0 mb-3'},el('div',{dangerouslySetInnerHTML: {__html: '$notice_message'}}))),"; |
|
| 3119 | + echo $notice_message ? $element_require . $notice : ''; |
|
| 3120 | + return; |
|
| 3121 | + } |
|
| 3122 | + /* |
|
| 3123 | 3123 | * https://www.wptricks.com/question/set-current-tab-on-a-gutenberg-tabpanel-component-from-outside-that-component/ es5 layout |
| 3124 | 3124 | elseif($args['type']=='tabs'){ |
| 3125 | 3125 | ?> |
@@ -3172,23 +3172,23 @@ discard block |
||
| 3172 | 3172 | return; |
| 3173 | 3173 | } |
| 3174 | 3174 | */ |
| 3175 | - elseif ( $args['type'] == 'color' ) { |
|
| 3176 | - $type = 'ColorPicker'; |
|
| 3177 | - $onchange = ""; |
|
| 3178 | - $extra = "color: $value,"; |
|
| 3179 | - if(!empty($args['disable_alpha'])){ |
|
| 3180 | - $extra .= "disableAlpha: true,"; |
|
| 3181 | - } |
|
| 3182 | - $onchangecomplete = "onChangeComplete: function($key) { |
|
| 3175 | + elseif ( $args['type'] == 'color' ) { |
|
| 3176 | + $type = 'ColorPicker'; |
|
| 3177 | + $onchange = ""; |
|
| 3178 | + $extra = "color: $value,"; |
|
| 3179 | + if(!empty($args['disable_alpha'])){ |
|
| 3180 | + $extra .= "disableAlpha: true,"; |
|
| 3181 | + } |
|
| 3182 | + $onchangecomplete = "onChangeComplete: function($key) { |
|
| 3183 | 3183 | value = $key.rgb.a && $key.rgb.a < 1 ? \"rgba(\"+$key.rgb.r+\",\"+$key.rgb.g+\",\"+$key.rgb.b+\",\"+$key.rgb.a+\")\" : $key.hex; |
| 3184 | 3184 | props.setAttributes({ |
| 3185 | 3185 | $key: value |
| 3186 | 3186 | }); |
| 3187 | 3187 | },"; |
| 3188 | - }elseif ( $args['type'] == 'gradient' ) { |
|
| 3189 | - $type = 'GradientPicker'; |
|
| 3188 | + }elseif ( $args['type'] == 'gradient' ) { |
|
| 3189 | + $type = 'GradientPicker'; |
|
| 3190 | 3190 | |
| 3191 | - }elseif ( $args['type'] == 'image' ) { |
|
| 3191 | + }elseif ( $args['type'] == 'image' ) { |
|
| 3192 | 3192 | // print_r($args); |
| 3193 | 3193 | |
| 3194 | 3194 | $img_preview = isset($args['focalpoint']) && !$args['focalpoint'] ? " props.attributes.$key && el('img', { src: props.attributes.$key,style: {maxWidth:'100%',background: '#ccc'}})," : " ( props.attributes.$key || props.attributes.{$key}_use_featured ) && el(wp.components.FocalPointPicker,{ |
@@ -3213,15 +3213,15 @@ discard block |
||
| 3213 | 3213 | |
| 3214 | 3214 | |
| 3215 | 3215 | $value = '""'; |
| 3216 | - $type = 'MediaUpload'; |
|
| 3216 | + $type = 'MediaUpload'; |
|
| 3217 | 3217 | $extra .= "onSelect: function(media){ |
| 3218 | 3218 | return props.setAttributes({ |
| 3219 | 3219 | $key: media.url, |
| 3220 | 3220 | {$key}_id: media.id |
| 3221 | 3221 | }); |
| 3222 | 3222 | },"; |
| 3223 | - $extra .= "type: 'image',"; |
|
| 3224 | - $extra .= "render: function (obj) { |
|
| 3223 | + $extra .= "type: 'image',"; |
|
| 3224 | + $extra .= "render: function (obj) { |
|
| 3225 | 3225 | return el( 'div',{}, |
| 3226 | 3226 | ( !props.attributes.$key && !props.attributes.{$key}_use_featured ) && el( wp.components.Button, { |
| 3227 | 3227 | className: 'components-button components-circular-option-picker__clear is-primary is-smallx', |
@@ -3250,8 +3250,8 @@ discard block |
||
| 3250 | 3250 | $onchange = ""; |
| 3251 | 3251 | |
| 3252 | 3252 | //$inside_elements = ",el('div',{},'file upload')"; |
| 3253 | - }elseif ( $args['type'] == 'images' ) { |
|
| 3254 | - // print_r($args); |
|
| 3253 | + }elseif ( $args['type'] == 'images' ) { |
|
| 3254 | + // print_r($args); |
|
| 3255 | 3255 | |
| 3256 | 3256 | $img_preview = "props.attributes.$key && (function() { |
| 3257 | 3257 | |
@@ -3280,7 +3280,7 @@ discard block |
||
| 3280 | 3280 | |
| 3281 | 3281 | |
| 3282 | 3282 | $value = '""'; |
| 3283 | - $type = 'MediaUpload'; |
|
| 3283 | + $type = 'MediaUpload'; |
|
| 3284 | 3284 | $extra .= "onSelect: function(media){ |
| 3285 | 3285 | |
| 3286 | 3286 | let slim_images = props.attributes.$key ? JSON.parse('['+props.attributes.$key+']') : []; |
@@ -3294,9 +3294,9 @@ discard block |
||
| 3294 | 3294 | $key: JSON.stringify(slim_images).replace('[','').replace(']',''), |
| 3295 | 3295 | }); |
| 3296 | 3296 | },"; |
| 3297 | - $extra .= "type: 'image',"; |
|
| 3298 | - $extra .= "multiple: true,"; |
|
| 3299 | - $extra .= "render: function (obj) { |
|
| 3297 | + $extra .= "type: 'image',"; |
|
| 3298 | + $extra .= "multiple: true,"; |
|
| 3299 | + $extra .= "render: function (obj) { |
|
| 3300 | 3300 | |
| 3301 | 3301 | // init the sort |
| 3302 | 3302 | enableDragSort('sd-sortable'); |
@@ -3335,37 +3335,37 @@ discard block |
||
| 3335 | 3335 | $onchange = ""; |
| 3336 | 3336 | |
| 3337 | 3337 | //$inside_elements = ",el('div',{},'file upload')"; |
| 3338 | - } |
|
| 3339 | - elseif ( $args['type'] == 'checkbox' ) { |
|
| 3340 | - $type = 'CheckboxControl'; |
|
| 3341 | - $extra .= "checked: props.attributes.$key,"; |
|
| 3342 | - $onchange = "props.setAttributes({ $key: ! props.attributes.$key } )"; |
|
| 3343 | - } elseif ( $args['type'] == 'textarea' ) { |
|
| 3344 | - $type = 'TextareaControl'; |
|
| 3345 | - |
|
| 3346 | - } elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) { |
|
| 3347 | - $type = 'SelectControl'; |
|
| 3348 | - |
|
| 3349 | - if($args['name'] == 'category' && !empty($args['post_type_linked'])){ |
|
| 3350 | - $options .= "options: taxonomies_".str_replace("-","_", $this->id).","; |
|
| 3351 | - }elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){ |
|
| 3352 | - $options .= "options: sort_by_".str_replace("-","_", $this->id).","; |
|
| 3353 | - }else { |
|
| 3354 | - |
|
| 3355 | - if ( ! empty( $args['options'] ) ) { |
|
| 3356 | - $options .= "options: ["; |
|
| 3357 | - foreach ( $args['options'] as $option_val => $option_label ) { |
|
| 3358 | - $options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . addslashes( $option_label ) . "' },"; |
|
| 3359 | - } |
|
| 3360 | - $options .= "],"; |
|
| 3361 | - } |
|
| 3362 | - } |
|
| 3363 | - if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550 |
|
| 3364 | - $extra .= ' multiple:true,style:{height:"auto",paddingRight:"8px","overflow-y":"auto"}, '; |
|
| 3365 | - } |
|
| 3338 | + } |
|
| 3339 | + elseif ( $args['type'] == 'checkbox' ) { |
|
| 3340 | + $type = 'CheckboxControl'; |
|
| 3341 | + $extra .= "checked: props.attributes.$key,"; |
|
| 3342 | + $onchange = "props.setAttributes({ $key: ! props.attributes.$key } )"; |
|
| 3343 | + } elseif ( $args['type'] == 'textarea' ) { |
|
| 3344 | + $type = 'TextareaControl'; |
|
| 3345 | + |
|
| 3346 | + } elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) { |
|
| 3347 | + $type = 'SelectControl'; |
|
| 3348 | + |
|
| 3349 | + if($args['name'] == 'category' && !empty($args['post_type_linked'])){ |
|
| 3350 | + $options .= "options: taxonomies_".str_replace("-","_", $this->id).","; |
|
| 3351 | + }elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){ |
|
| 3352 | + $options .= "options: sort_by_".str_replace("-","_", $this->id).","; |
|
| 3353 | + }else { |
|
| 3354 | + |
|
| 3355 | + if ( ! empty( $args['options'] ) ) { |
|
| 3356 | + $options .= "options: ["; |
|
| 3357 | + foreach ( $args['options'] as $option_val => $option_label ) { |
|
| 3358 | + $options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . addslashes( $option_label ) . "' },"; |
|
| 3359 | + } |
|
| 3360 | + $options .= "],"; |
|
| 3361 | + } |
|
| 3362 | + } |
|
| 3363 | + if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550 |
|
| 3364 | + $extra .= ' multiple:true,style:{height:"auto",paddingRight:"8px","overflow-y":"auto"}, '; |
|
| 3365 | + } |
|
| 3366 | 3366 | |
| 3367 | - if($args['type'] == 'multiselect' || ( isset( $args['multiple'] ) && $args['multiple'] ) ){ |
|
| 3368 | - $after_elements .= "props.attributes.$key && el( wp.components.Button, { |
|
| 3367 | + if($args['type'] == 'multiselect' || ( isset( $args['multiple'] ) && $args['multiple'] ) ){ |
|
| 3368 | + $after_elements .= "props.attributes.$key && el( wp.components.Button, { |
|
| 3369 | 3369 | className: 'components-button components-circular-option-picker__clear is-secondary is-small', |
| 3370 | 3370 | style: {margin:'-8px 0 8px 0',display: 'block'}, |
| 3371 | 3371 | onClick: function(){ |
@@ -3376,8 +3376,8 @@ discard block |
||
| 3376 | 3376 | }, |
| 3377 | 3377 | 'Clear' |
| 3378 | 3378 | ),"; |
| 3379 | - } |
|
| 3380 | - } elseif ( $args['type'] == 'tagselect' ) { |
|
| 3379 | + } |
|
| 3380 | + } elseif ( $args['type'] == 'tagselect' ) { |
|
| 3381 | 3381 | // $type = 'FormTokenField'; |
| 3382 | 3382 | // |
| 3383 | 3383 | // if ( ! empty( $args['options'] ) ) { |
@@ -3412,39 +3412,39 @@ discard block |
||
| 3412 | 3412 | // $value = "[]"; |
| 3413 | 3413 | // $extra .= ' __experimentalExpandOnFocus: true,'; |
| 3414 | 3414 | |
| 3415 | - } elseif ( $args['type'] == 'alignment' ) { |
|
| 3416 | - $type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example |
|
| 3417 | - }elseif ( $args['type'] == 'margins' ) { |
|
| 3415 | + } elseif ( $args['type'] == 'alignment' ) { |
|
| 3416 | + $type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example |
|
| 3417 | + }elseif ( $args['type'] == 'margins' ) { |
|
| 3418 | 3418 | |
| 3419 | - } else { |
|
| 3420 | - return;// if we have not implemented the control then don't break the JS. |
|
| 3421 | - } |
|
| 3419 | + } else { |
|
| 3420 | + return;// if we have not implemented the control then don't break the JS. |
|
| 3421 | + } |
|
| 3422 | 3422 | |
| 3423 | 3423 | |
| 3424 | 3424 | |
| 3425 | - // color input does not show the labels so we add them |
|
| 3426 | - if($args['type']=='color'){ |
|
| 3427 | - // add show only if advanced |
|
| 3428 | - echo $require_advanced; |
|
| 3429 | - // add setting require if defined |
|
| 3430 | - echo $element_require; |
|
| 3431 | - echo "el('div', {style: {'marginBottom': '8px'}}, '".addslashes( $args['title'] )."'),"; |
|
| 3432 | - } |
|
| 3425 | + // color input does not show the labels so we add them |
|
| 3426 | + if($args['type']=='color'){ |
|
| 3427 | + // add show only if advanced |
|
| 3428 | + echo $require_advanced; |
|
| 3429 | + // add setting require if defined |
|
| 3430 | + echo $element_require; |
|
| 3431 | + echo "el('div', {style: {'marginBottom': '8px'}}, '".addslashes( $args['title'] )."'),"; |
|
| 3432 | + } |
|
| 3433 | 3433 | |
| 3434 | - // add show only if advanced |
|
| 3435 | - echo $require_advanced; |
|
| 3436 | - // add setting require if defined |
|
| 3437 | - echo $element_require; |
|
| 3434 | + // add show only if advanced |
|
| 3435 | + echo $require_advanced; |
|
| 3436 | + // add setting require if defined |
|
| 3437 | + echo $element_require; |
|
| 3438 | 3438 | echo $device_type_require; |
| 3439 | 3439 | |
| 3440 | - // icon |
|
| 3441 | - echo $icon; |
|
| 3442 | - ?> |
|
| 3440 | + // icon |
|
| 3441 | + echo $icon; |
|
| 3442 | + ?> |
|
| 3443 | 3443 | el( <?php echo $args['type'] == 'image' || $args['type'] == 'images' ? $type : "wp.components.".$type; ?>, { |
| 3444 | 3444 | label: <?php |
| 3445 | - if(empty($args['title'])){ |
|
| 3445 | + if(empty($args['title'])){ |
|
| 3446 | 3446 | echo "''"; |
| 3447 | - }elseif(empty($args['row']) && !empty($args['device_type'])){ |
|
| 3447 | + }elseif(empty($args['row']) && !empty($args['device_type'])){ |
|
| 3448 | 3448 | ?>el('label', { |
| 3449 | 3449 | className: 'components-base-control__label', |
| 3450 | 3450 | style: {width:"100%"} |
@@ -3459,22 +3459,22 @@ discard block |
||
| 3459 | 3459 | |
| 3460 | 3460 | )<?php |
| 3461 | 3461 | |
| 3462 | - }else{ |
|
| 3463 | - ?>'<?php echo addslashes( $args['title'] ); ?>'<?php |
|
| 3462 | + }else{ |
|
| 3463 | + ?>'<?php echo addslashes( $args['title'] ); ?>'<?php |
|
| 3464 | 3464 | |
| 3465 | - } |
|
| 3465 | + } |
|
| 3466 | 3466 | |
| 3467 | - ?>, |
|
| 3467 | + ?>, |
|
| 3468 | 3468 | help: <?php if ( isset( $args['desc'] ) ) { |
| 3469 | - echo "el('span',{dangerouslySetInnerHTML: {__html: '".wp_kses_post( addslashes($args['desc']) )."'}})"; |
|
| 3470 | - }else{ echo "''"; } ?>, |
|
| 3469 | + echo "el('span',{dangerouslySetInnerHTML: {__html: '".wp_kses_post( addslashes($args['desc']) )."'}})"; |
|
| 3470 | + }else{ echo "''"; } ?>, |
|
| 3471 | 3471 | value: <?php echo $value; ?>, |
| 3472 | 3472 | <?php if ( $type == 'TextControl' && $args['type'] != 'text' ) { |
| 3473 | - echo "type: '" . addslashes( $args['type'] ) . "',"; |
|
| 3474 | - } ?> |
|
| 3473 | + echo "type: '" . addslashes( $args['type'] ) . "',"; |
|
| 3474 | + } ?> |
|
| 3475 | 3475 | <?php if ( ! empty( $args['placeholder'] ) ) { |
| 3476 | - echo "placeholder: '" . addslashes( $args['placeholder'] ) . "',"; |
|
| 3477 | - } ?> |
|
| 3476 | + echo "placeholder: '" . addslashes( $args['placeholder'] ) . "',"; |
|
| 3477 | + } ?> |
|
| 3478 | 3478 | <?php echo $options; ?> |
| 3479 | 3479 | <?php echo $extra; ?> |
| 3480 | 3480 | <?php echo $custom_attributes; ?> |
@@ -3487,69 +3487,69 @@ discard block |
||
| 3487 | 3487 | <?php }?> |
| 3488 | 3488 | } <?php echo $inside_elements; ?> ), |
| 3489 | 3489 | <?php |
| 3490 | - echo $after_elements; |
|
| 3490 | + echo $after_elements; |
|
| 3491 | 3491 | |
| 3492 | - } |
|
| 3492 | + } |
|
| 3493 | 3493 | |
| 3494 | - /** |
|
| 3495 | - * Convert an array of attributes to block string. |
|
| 3496 | - * |
|
| 3497 | - * @param $custom_attributes |
|
| 3498 | - * |
|
| 3499 | - * @return string |
|
| 3500 | - *@todo there is prob a faster way to do this, also we could add some validation here. |
|
| 3501 | - * |
|
| 3502 | - */ |
|
| 3503 | - public function array_to_attributes( $custom_attributes, $html = false ) { |
|
| 3504 | - $attributes = ''; |
|
| 3505 | - if ( ! empty( $custom_attributes ) ) { |
|
| 3506 | - |
|
| 3507 | - foreach ( $custom_attributes as $key => $val ) { |
|
| 3508 | - if(is_array($val)){ |
|
| 3509 | - $attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},'; |
|
| 3510 | - }else{ |
|
| 3511 | - $attributes .= $html ? " $key='$val' " : "'$key': '$val',"; |
|
| 3512 | - } |
|
| 3513 | - } |
|
| 3494 | + /** |
|
| 3495 | + * Convert an array of attributes to block string. |
|
| 3496 | + * |
|
| 3497 | + * @param $custom_attributes |
|
| 3498 | + * |
|
| 3499 | + * @return string |
|
| 3500 | + *@todo there is prob a faster way to do this, also we could add some validation here. |
|
| 3501 | + * |
|
| 3502 | + */ |
|
| 3503 | + public function array_to_attributes( $custom_attributes, $html = false ) { |
|
| 3504 | + $attributes = ''; |
|
| 3505 | + if ( ! empty( $custom_attributes ) ) { |
|
| 3514 | 3506 | |
| 3515 | - } |
|
| 3507 | + foreach ( $custom_attributes as $key => $val ) { |
|
| 3508 | + if(is_array($val)){ |
|
| 3509 | + $attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},'; |
|
| 3510 | + }else{ |
|
| 3511 | + $attributes .= $html ? " $key='$val' " : "'$key': '$val',"; |
|
| 3512 | + } |
|
| 3513 | + } |
|
| 3516 | 3514 | |
| 3517 | - return $attributes; |
|
| 3518 | - } |
|
| 3515 | + } |
|
| 3516 | + |
|
| 3517 | + return $attributes; |
|
| 3518 | + } |
|
| 3519 | 3519 | |
| 3520 | 3520 | |
| 3521 | 3521 | |
| 3522 | - /** |
|
| 3523 | - * A self looping function to create the output for JS block elements. |
|
| 3524 | - * |
|
| 3525 | - * This is what is output in the WP Editor visual view. |
|
| 3526 | - * |
|
| 3527 | - * @param $args |
|
| 3528 | - */ |
|
| 3529 | - public function block_element( $args, $save = false ) { |
|
| 3522 | + /** |
|
| 3523 | + * A self looping function to create the output for JS block elements. |
|
| 3524 | + * |
|
| 3525 | + * This is what is output in the WP Editor visual view. |
|
| 3526 | + * |
|
| 3527 | + * @param $args |
|
| 3528 | + */ |
|
| 3529 | + public function block_element( $args, $save = false ) { |
|
| 3530 | 3530 | |
| 3531 | 3531 | |
| 3532 | - if ( ! empty( $args ) ) { |
|
| 3533 | - foreach ( $args as $element => $new_args ) { |
|
| 3532 | + if ( ! empty( $args ) ) { |
|
| 3533 | + foreach ( $args as $element => $new_args ) { |
|
| 3534 | 3534 | |
| 3535 | - if ( is_array( $new_args ) ) { // its an element |
|
| 3535 | + if ( is_array( $new_args ) ) { // its an element |
|
| 3536 | 3536 | |
| 3537 | 3537 | |
| 3538 | - if ( isset( $new_args['element'] ) ) { |
|
| 3538 | + if ( isset( $new_args['element'] ) ) { |
|
| 3539 | 3539 | |
| 3540 | - if ( isset( $new_args['element_require'] ) ) { |
|
| 3541 | - echo str_replace( array( |
|
| 3542 | - "'+", |
|
| 3543 | - "+'" |
|
| 3544 | - ), '', $this->block_props_replace( $new_args['element_require'] ) ) . " && "; |
|
| 3545 | - unset( $new_args['element_require'] ); |
|
| 3546 | - } |
|
| 3540 | + if ( isset( $new_args['element_require'] ) ) { |
|
| 3541 | + echo str_replace( array( |
|
| 3542 | + "'+", |
|
| 3543 | + "+'" |
|
| 3544 | + ), '', $this->block_props_replace( $new_args['element_require'] ) ) . " && "; |
|
| 3545 | + unset( $new_args['element_require'] ); |
|
| 3546 | + } |
|
| 3547 | 3547 | |
| 3548 | 3548 | if($new_args['element']=='InnerBlocks'){ |
| 3549 | 3549 | echo "\n el( InnerBlocks, {"; |
| 3550 | 3550 | }elseif($new_args['element']=='innerBlocksProps'){ |
| 3551 | 3551 | $element = isset($new_args['inner_element']) ? esc_attr($new_args['inner_element']) : 'div'; |
| 3552 | - // echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {"; |
|
| 3552 | + // echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {"; |
|
| 3553 | 3553 | // echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( "; |
| 3554 | 3554 | echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( "; |
| 3555 | 3555 | echo $save ? "wp.blockEditor.useBlockProps.save( {" : "wp.blockEditor.useBlockProps( {"; |
@@ -3559,74 +3559,74 @@ discard block |
||
| 3559 | 3559 | echo !empty($new_args['innerBlocksProps']) && !$save ? $this->block_element( $new_args['innerBlocksProps'],$save ) : ''; |
| 3560 | 3560 | // echo '###'; |
| 3561 | 3561 | |
| 3562 | - // echo '###'; |
|
| 3562 | + // echo '###'; |
|
| 3563 | 3563 | }elseif($new_args['element']=='BlocksProps'){ |
| 3564 | 3564 | |
| 3565 | - if ( isset($new_args['if_inner_element']) ) { |
|
| 3566 | - $element = $new_args['if_inner_element']; |
|
| 3567 | - }else { |
|
| 3568 | - $element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'"; |
|
| 3569 | - } |
|
| 3565 | + if ( isset($new_args['if_inner_element']) ) { |
|
| 3566 | + $element = $new_args['if_inner_element']; |
|
| 3567 | + }else { |
|
| 3568 | + $element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'"; |
|
| 3569 | + } |
|
| 3570 | 3570 | |
| 3571 | - unset($new_args['inner_element']); |
|
| 3571 | + unset($new_args['inner_element']); |
|
| 3572 | 3572 | echo $save ? "\n el( $element, wp.blockEditor.useBlockProps.save( {" : "\n el( $element, wp.blockEditor.useBlockProps( {"; |
| 3573 | 3573 | echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : ''; |
| 3574 | 3574 | |
| 3575 | 3575 | |
| 3576 | - // echo "} ),"; |
|
| 3576 | + // echo "} ),"; |
|
| 3577 | 3577 | |
| 3578 | 3578 | }else{ |
| 3579 | 3579 | echo "\n el( '" . $new_args['element'] . "', {"; |
| 3580 | 3580 | } |
| 3581 | 3581 | |
| 3582 | 3582 | |
| 3583 | - // get the attributes |
|
| 3584 | - foreach ( $new_args as $new_key => $new_value ) { |
|
| 3583 | + // get the attributes |
|
| 3584 | + foreach ( $new_args as $new_key => $new_value ) { |
|
| 3585 | 3585 | |
| 3586 | 3586 | |
| 3587 | - if ( $new_key == 'element' || $new_key == 'content'|| $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) { |
|
| 3588 | - // do nothing |
|
| 3589 | - } else { |
|
| 3590 | - echo $this->block_element( array( $new_key => $new_value ),$save ); |
|
| 3591 | - } |
|
| 3592 | - } |
|
| 3587 | + if ( $new_key == 'element' || $new_key == 'content'|| $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) { |
|
| 3588 | + // do nothing |
|
| 3589 | + } else { |
|
| 3590 | + echo $this->block_element( array( $new_key => $new_value ),$save ); |
|
| 3591 | + } |
|
| 3592 | + } |
|
| 3593 | 3593 | |
| 3594 | - echo $new_args['element']=='BlocksProps' ? '} ),' : "},";// end attributes |
|
| 3594 | + echo $new_args['element']=='BlocksProps' ? '} ),' : "},";// end attributes |
|
| 3595 | 3595 | |
| 3596 | - // get the content |
|
| 3597 | - $first_item = 0; |
|
| 3598 | - foreach ( $new_args as $new_key => $new_value ) { |
|
| 3599 | - if ( $new_key === 'content' || $new_key === 'if_content' || is_array( $new_value ) ) { |
|
| 3596 | + // get the content |
|
| 3597 | + $first_item = 0; |
|
| 3598 | + foreach ( $new_args as $new_key => $new_value ) { |
|
| 3599 | + if ( $new_key === 'content' || $new_key === 'if_content' || is_array( $new_value ) ) { |
|
| 3600 | 3600 | |
| 3601 | - if ( $new_key === 'content' ) { |
|
| 3602 | - echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'"; |
|
| 3603 | - }else if ( $new_key === 'if_content' ) { |
|
| 3604 | - echo $this->block_props_replace( $new_value ); |
|
| 3605 | - } |
|
| 3601 | + if ( $new_key === 'content' ) { |
|
| 3602 | + echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'"; |
|
| 3603 | + }else if ( $new_key === 'if_content' ) { |
|
| 3604 | + echo $this->block_props_replace( $new_value ); |
|
| 3605 | + } |
|
| 3606 | 3606 | |
| 3607 | - if ( is_array( $new_value ) ) { |
|
| 3607 | + if ( is_array( $new_value ) ) { |
|
| 3608 | 3608 | |
| 3609 | - if ( isset( $new_value['element_require'] ) ) { |
|
| 3610 | - echo str_replace( array( |
|
| 3611 | - "'+", |
|
| 3612 | - "+'" |
|
| 3613 | - ), '', $this->block_props_replace( $new_value['element_require'] ) ) . " && "; |
|
| 3614 | - unset( $new_value['element_require'] ); |
|
| 3615 | - } |
|
| 3609 | + if ( isset( $new_value['element_require'] ) ) { |
|
| 3610 | + echo str_replace( array( |
|
| 3611 | + "'+", |
|
| 3612 | + "+'" |
|
| 3613 | + ), '', $this->block_props_replace( $new_value['element_require'] ) ) . " && "; |
|
| 3614 | + unset( $new_value['element_require'] ); |
|
| 3615 | + } |
|
| 3616 | 3616 | |
| 3617 | - if ( isset( $new_value['element_repeat'] ) ) { |
|
| 3618 | - $x = 1; |
|
| 3619 | - while ( $x <= absint( $new_value['element_repeat'] ) ) { |
|
| 3620 | - $this->block_element( array( '' => $new_value ),$save ); |
|
| 3621 | - $x ++; |
|
| 3622 | - } |
|
| 3623 | - } else { |
|
| 3624 | - $this->block_element( array( '' => $new_value ),$save ); |
|
| 3625 | - } |
|
| 3626 | - } |
|
| 3627 | - $first_item ++; |
|
| 3628 | - } |
|
| 3629 | - } |
|
| 3617 | + if ( isset( $new_value['element_repeat'] ) ) { |
|
| 3618 | + $x = 1; |
|
| 3619 | + while ( $x <= absint( $new_value['element_repeat'] ) ) { |
|
| 3620 | + $this->block_element( array( '' => $new_value ),$save ); |
|
| 3621 | + $x ++; |
|
| 3622 | + } |
|
| 3623 | + } else { |
|
| 3624 | + $this->block_element( array( '' => $new_value ),$save ); |
|
| 3625 | + } |
|
| 3626 | + } |
|
| 3627 | + $first_item ++; |
|
| 3628 | + } |
|
| 3629 | + } |
|
| 3630 | 3630 | |
| 3631 | 3631 | if($new_args['element']=='innerBlocksProps' || $new_args['element']=='xBlocksProps'){ |
| 3632 | 3632 | echo "))";// end content |
@@ -3635,517 +3635,517 @@ discard block |
||
| 3635 | 3635 | } |
| 3636 | 3636 | |
| 3637 | 3637 | |
| 3638 | - echo ", \n"; |
|
| 3638 | + echo ", \n"; |
|
| 3639 | 3639 | |
| 3640 | - } |
|
| 3641 | - } else { |
|
| 3640 | + } |
|
| 3641 | + } else { |
|
| 3642 | 3642 | |
| 3643 | - if ( substr( $element, 0, 3 ) === "if_" ) { |
|
| 3644 | - $extra = ''; |
|
| 3645 | - if( strpos($new_args, '[%WrapClass%]') !== false ){ |
|
| 3646 | - $new_args = str_replace('[%WrapClass%]"','" + sd_build_aui_class(props.attributes)',$new_args); |
|
| 3647 | - $new_args = str_replace('[%WrapClass%]','+ sd_build_aui_class(props.attributes)',$new_args); |
|
| 3648 | - } |
|
| 3649 | - echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ","; |
|
| 3650 | - } elseif ( $element == 'style' && strpos($new_args, '[%WrapStyle%]') !== false ) { |
|
| 3643 | + if ( substr( $element, 0, 3 ) === "if_" ) { |
|
| 3644 | + $extra = ''; |
|
| 3645 | + if( strpos($new_args, '[%WrapClass%]') !== false ){ |
|
| 3646 | + $new_args = str_replace('[%WrapClass%]"','" + sd_build_aui_class(props.attributes)',$new_args); |
|
| 3647 | + $new_args = str_replace('[%WrapClass%]','+ sd_build_aui_class(props.attributes)',$new_args); |
|
| 3648 | + } |
|
| 3649 | + echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ","; |
|
| 3650 | + } elseif ( $element == 'style' && strpos($new_args, '[%WrapStyle%]') !== false ) { |
|
| 3651 | 3651 | $new_args = str_replace('[%WrapStyle%]','',$new_args); |
| 3652 | 3652 | echo $element . ": {..." . $this->block_props_replace( $new_args ) . " , ...sd_build_aui_styles(props.attributes) },"; |
| 3653 | 3653 | // echo $element . ": " . $this->block_props_replace( $new_args ) . ","; |
| 3654 | - } elseif ( $element == 'style' ) { |
|
| 3655 | - echo $element . ": " . $this->block_props_replace( $new_args ) . ","; |
|
| 3656 | - } elseif ( ( $element == 'class' || $element == 'className' ) && strpos($new_args, '[%WrapClass%]') !== false ) { |
|
| 3654 | + } elseif ( $element == 'style' ) { |
|
| 3655 | + echo $element . ": " . $this->block_props_replace( $new_args ) . ","; |
|
| 3656 | + } elseif ( ( $element == 'class' || $element == 'className' ) && strpos($new_args, '[%WrapClass%]') !== false ) { |
|
| 3657 | 3657 | $new_args = str_replace('[%WrapClass%]','',$new_args); |
| 3658 | 3658 | echo $element . ": '" . $this->block_props_replace( $new_args ) . "' + sd_build_aui_class(props.attributes),"; |
| 3659 | - } elseif ( $element == 'template' && $new_args ) { |
|
| 3660 | - echo $element . ": $new_args,"; |
|
| 3661 | - } else { |
|
| 3662 | - echo $element . ": '" . $this->block_props_replace( $new_args ) . "',"; |
|
| 3663 | - } |
|
| 3659 | + } elseif ( $element == 'template' && $new_args ) { |
|
| 3660 | + echo $element . ": $new_args,"; |
|
| 3661 | + } else { |
|
| 3662 | + echo $element . ": '" . $this->block_props_replace( $new_args ) . "',"; |
|
| 3663 | + } |
|
| 3664 | 3664 | |
| 3665 | - } |
|
| 3666 | - } |
|
| 3667 | - } |
|
| 3668 | - } |
|
| 3665 | + } |
|
| 3666 | + } |
|
| 3667 | + } |
|
| 3668 | + } |
|
| 3669 | 3669 | |
| 3670 | - /** |
|
| 3671 | - * Replace block attributes placeholders with the proper naming. |
|
| 3672 | - * |
|
| 3673 | - * @param $string |
|
| 3674 | - * |
|
| 3675 | - * @return mixed |
|
| 3676 | - */ |
|
| 3677 | - public function block_props_replace( $string, $no_wrap = false ) { |
|
| 3678 | - |
|
| 3679 | - if ( $no_wrap ) { |
|
| 3680 | - $string = str_replace( array( "[%", "%]" ), array( "props.attributes.", "" ), $string ); |
|
| 3681 | - } else { |
|
| 3682 | - $string = str_replace( array( "[%", "%]" ), array( "'+props.attributes.", "+'" ), $string ); |
|
| 3683 | - } |
|
| 3670 | + /** |
|
| 3671 | + * Replace block attributes placeholders with the proper naming. |
|
| 3672 | + * |
|
| 3673 | + * @param $string |
|
| 3674 | + * |
|
| 3675 | + * @return mixed |
|
| 3676 | + */ |
|
| 3677 | + public function block_props_replace( $string, $no_wrap = false ) { |
|
| 3684 | 3678 | |
| 3685 | - return $string; |
|
| 3686 | - } |
|
| 3679 | + if ( $no_wrap ) { |
|
| 3680 | + $string = str_replace( array( "[%", "%]" ), array( "props.attributes.", "" ), $string ); |
|
| 3681 | + } else { |
|
| 3682 | + $string = str_replace( array( "[%", "%]" ), array( "'+props.attributes.", "+'" ), $string ); |
|
| 3683 | + } |
|
| 3687 | 3684 | |
| 3688 | - /** |
|
| 3689 | - * Outputs the content of the widget |
|
| 3690 | - * |
|
| 3691 | - * @param array $args |
|
| 3692 | - * @param array $instance |
|
| 3693 | - */ |
|
| 3694 | - public function widget( $args, $instance ) { |
|
| 3695 | - |
|
| 3696 | - // get the filtered values |
|
| 3697 | - $argument_values = $this->argument_values( $instance ); |
|
| 3698 | - $argument_values = $this->string_to_bool( $argument_values ); |
|
| 3699 | - $output = $this->output( $argument_values, $args ); |
|
| 3700 | - |
|
| 3701 | - $no_wrap = false; |
|
| 3702 | - if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) { |
|
| 3703 | - $no_wrap = true; |
|
| 3704 | - } |
|
| 3685 | + return $string; |
|
| 3686 | + } |
|
| 3705 | 3687 | |
| 3706 | - ob_start(); |
|
| 3707 | - if ( $output && ! $no_wrap ) { |
|
| 3688 | + /** |
|
| 3689 | + * Outputs the content of the widget |
|
| 3690 | + * |
|
| 3691 | + * @param array $args |
|
| 3692 | + * @param array $instance |
|
| 3693 | + */ |
|
| 3694 | + public function widget( $args, $instance ) { |
|
| 3708 | 3695 | |
| 3709 | - $class_original = $this->options['widget_ops']['classname']; |
|
| 3710 | - $class = $this->options['widget_ops']['classname']." sdel-".$this->get_instance_hash(); |
|
| 3696 | + // get the filtered values |
|
| 3697 | + $argument_values = $this->argument_values( $instance ); |
|
| 3698 | + $argument_values = $this->string_to_bool( $argument_values ); |
|
| 3699 | + $output = $this->output( $argument_values, $args ); |
|
| 3711 | 3700 | |
| 3712 | - // Before widget |
|
| 3713 | - $before_widget = $args['before_widget']; |
|
| 3714 | - $before_widget = str_replace($class_original,$class,$before_widget); |
|
| 3715 | - $before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this ); |
|
| 3716 | - $before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this ); |
|
| 3701 | + $no_wrap = false; |
|
| 3702 | + if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) { |
|
| 3703 | + $no_wrap = true; |
|
| 3704 | + } |
|
| 3717 | 3705 | |
| 3718 | - // After widget |
|
| 3719 | - $after_widget = $args['after_widget']; |
|
| 3720 | - $after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this ); |
|
| 3721 | - $after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this ); |
|
| 3706 | + ob_start(); |
|
| 3707 | + if ( $output && ! $no_wrap ) { |
|
| 3722 | 3708 | |
| 3723 | - echo $before_widget; |
|
| 3724 | - // elementor strips the widget wrapping div so we check for and add it back if needed |
|
| 3725 | - if ( $this->is_elementor_widget_output() ) { |
|
| 3726 | - // Filter class & attrs for elementor widget output. |
|
| 3727 | - $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this ); |
|
| 3728 | - $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this ); |
|
| 3709 | + $class_original = $this->options['widget_ops']['classname']; |
|
| 3710 | + $class = $this->options['widget_ops']['classname']." sdel-".$this->get_instance_hash(); |
|
| 3729 | 3711 | |
| 3730 | - $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this ); |
|
| 3731 | - $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); |
|
| 3712 | + // Before widget |
|
| 3713 | + $before_widget = $args['before_widget']; |
|
| 3714 | + $before_widget = str_replace($class_original,$class,$before_widget); |
|
| 3715 | + $before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this ); |
|
| 3716 | + $before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this ); |
|
| 3732 | 3717 | |
| 3733 | - echo "<span class='" . esc_attr( $class ) . "' " . $attrs . ">"; |
|
| 3734 | - } |
|
| 3735 | - echo $this->output_title( $args, $instance ); |
|
| 3736 | - echo $output; |
|
| 3737 | - if ( $this->is_elementor_widget_output() ) { |
|
| 3738 | - echo "</span>"; |
|
| 3739 | - } |
|
| 3740 | - echo $after_widget; |
|
| 3741 | - } elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty |
|
| 3742 | - $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" ); |
|
| 3743 | - echo $output; |
|
| 3744 | - } elseif ( $output && $no_wrap ) { |
|
| 3745 | - echo $output; |
|
| 3746 | - } |
|
| 3747 | - $output = ob_get_clean(); |
|
| 3718 | + // After widget |
|
| 3719 | + $after_widget = $args['after_widget']; |
|
| 3720 | + $after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this ); |
|
| 3721 | + $after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this ); |
|
| 3748 | 3722 | |
| 3749 | - $output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this ); |
|
| 3723 | + echo $before_widget; |
|
| 3724 | + // elementor strips the widget wrapping div so we check for and add it back if needed |
|
| 3725 | + if ( $this->is_elementor_widget_output() ) { |
|
| 3726 | + // Filter class & attrs for elementor widget output. |
|
| 3727 | + $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this ); |
|
| 3728 | + $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this ); |
|
| 3750 | 3729 | |
| 3751 | - echo $output; |
|
| 3752 | - } |
|
| 3730 | + $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this ); |
|
| 3731 | + $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); |
|
| 3753 | 3732 | |
| 3754 | - /** |
|
| 3755 | - * Tests if the current output is inside a elementor container. |
|
| 3756 | - * |
|
| 3757 | - * @return bool |
|
| 3758 | - *@since 1.0.4 |
|
| 3759 | - */ |
|
| 3760 | - public function is_elementor_widget_output() { |
|
| 3761 | - $result = false; |
|
| 3762 | - if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) { |
|
| 3763 | - $result = true; |
|
| 3764 | - } |
|
| 3733 | + echo "<span class='" . esc_attr( $class ) . "' " . $attrs . ">"; |
|
| 3734 | + } |
|
| 3735 | + echo $this->output_title( $args, $instance ); |
|
| 3736 | + echo $output; |
|
| 3737 | + if ( $this->is_elementor_widget_output() ) { |
|
| 3738 | + echo "</span>"; |
|
| 3739 | + } |
|
| 3740 | + echo $after_widget; |
|
| 3741 | + } elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty |
|
| 3742 | + $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" ); |
|
| 3743 | + echo $output; |
|
| 3744 | + } elseif ( $output && $no_wrap ) { |
|
| 3745 | + echo $output; |
|
| 3746 | + } |
|
| 3747 | + $output = ob_get_clean(); |
|
| 3765 | 3748 | |
| 3766 | - return $result; |
|
| 3767 | - } |
|
| 3749 | + $output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this ); |
|
| 3768 | 3750 | |
| 3769 | - /** |
|
| 3770 | - * Tests if the current output is inside a elementor preview. |
|
| 3771 | - * |
|
| 3772 | - * @return bool |
|
| 3773 | - *@since 1.0.4 |
|
| 3774 | - */ |
|
| 3775 | - public function is_elementor_preview() { |
|
| 3776 | - $result = false; |
|
| 3777 | - if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) { |
|
| 3778 | - $result = true; |
|
| 3779 | - } |
|
| 3751 | + echo $output; |
|
| 3752 | + } |
|
| 3780 | 3753 | |
| 3781 | - return $result; |
|
| 3782 | - } |
|
| 3754 | + /** |
|
| 3755 | + * Tests if the current output is inside a elementor container. |
|
| 3756 | + * |
|
| 3757 | + * @return bool |
|
| 3758 | + *@since 1.0.4 |
|
| 3759 | + */ |
|
| 3760 | + public function is_elementor_widget_output() { |
|
| 3761 | + $result = false; |
|
| 3762 | + if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) { |
|
| 3763 | + $result = true; |
|
| 3764 | + } |
|
| 3783 | 3765 | |
| 3784 | - /** |
|
| 3785 | - * Tests if the current output is inside a Divi preview. |
|
| 3786 | - * |
|
| 3787 | - * @return bool |
|
| 3788 | - *@since 1.0.6 |
|
| 3789 | - */ |
|
| 3790 | - public function is_divi_preview() { |
|
| 3791 | - $result = false; |
|
| 3792 | - if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) { |
|
| 3793 | - $result = true; |
|
| 3794 | - } |
|
| 3766 | + return $result; |
|
| 3767 | + } |
|
| 3795 | 3768 | |
| 3796 | - return $result; |
|
| 3797 | - } |
|
| 3769 | + /** |
|
| 3770 | + * Tests if the current output is inside a elementor preview. |
|
| 3771 | + * |
|
| 3772 | + * @return bool |
|
| 3773 | + *@since 1.0.4 |
|
| 3774 | + */ |
|
| 3775 | + public function is_elementor_preview() { |
|
| 3776 | + $result = false; |
|
| 3777 | + if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) { |
|
| 3778 | + $result = true; |
|
| 3779 | + } |
|
| 3798 | 3780 | |
| 3799 | - /** |
|
| 3800 | - * Tests if the current output is inside a Beaver builder preview. |
|
| 3801 | - * |
|
| 3802 | - * @return bool |
|
| 3803 | - *@since 1.0.6 |
|
| 3804 | - */ |
|
| 3805 | - public function is_beaver_preview() { |
|
| 3806 | - $result = false; |
|
| 3807 | - if ( isset( $_REQUEST['fl_builder'] ) ) { |
|
| 3808 | - $result = true; |
|
| 3809 | - } |
|
| 3781 | + return $result; |
|
| 3782 | + } |
|
| 3810 | 3783 | |
| 3811 | - return $result; |
|
| 3812 | - } |
|
| 3784 | + /** |
|
| 3785 | + * Tests if the current output is inside a Divi preview. |
|
| 3786 | + * |
|
| 3787 | + * @return bool |
|
| 3788 | + *@since 1.0.6 |
|
| 3789 | + */ |
|
| 3790 | + public function is_divi_preview() { |
|
| 3791 | + $result = false; |
|
| 3792 | + if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) { |
|
| 3793 | + $result = true; |
|
| 3794 | + } |
|
| 3813 | 3795 | |
| 3814 | - /** |
|
| 3815 | - * Tests if the current output is inside a siteorigin builder preview. |
|
| 3816 | - * |
|
| 3817 | - * @return bool |
|
| 3818 | - *@since 1.0.6 |
|
| 3819 | - */ |
|
| 3820 | - public function is_siteorigin_preview() { |
|
| 3821 | - $result = false; |
|
| 3822 | - if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) { |
|
| 3823 | - $result = true; |
|
| 3824 | - } |
|
| 3796 | + return $result; |
|
| 3797 | + } |
|
| 3825 | 3798 | |
| 3826 | - return $result; |
|
| 3827 | - } |
|
| 3799 | + /** |
|
| 3800 | + * Tests if the current output is inside a Beaver builder preview. |
|
| 3801 | + * |
|
| 3802 | + * @return bool |
|
| 3803 | + *@since 1.0.6 |
|
| 3804 | + */ |
|
| 3805 | + public function is_beaver_preview() { |
|
| 3806 | + $result = false; |
|
| 3807 | + if ( isset( $_REQUEST['fl_builder'] ) ) { |
|
| 3808 | + $result = true; |
|
| 3809 | + } |
|
| 3828 | 3810 | |
| 3829 | - /** |
|
| 3830 | - * Tests if the current output is inside a cornerstone builder preview. |
|
| 3831 | - * |
|
| 3832 | - * @return bool |
|
| 3833 | - *@since 1.0.8 |
|
| 3834 | - */ |
|
| 3835 | - public function is_cornerstone_preview() { |
|
| 3836 | - $result = false; |
|
| 3837 | - if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) { |
|
| 3838 | - $result = true; |
|
| 3839 | - } |
|
| 3811 | + return $result; |
|
| 3812 | + } |
|
| 3840 | 3813 | |
| 3841 | - return $result; |
|
| 3842 | - } |
|
| 3814 | + /** |
|
| 3815 | + * Tests if the current output is inside a siteorigin builder preview. |
|
| 3816 | + * |
|
| 3817 | + * @return bool |
|
| 3818 | + *@since 1.0.6 |
|
| 3819 | + */ |
|
| 3820 | + public function is_siteorigin_preview() { |
|
| 3821 | + $result = false; |
|
| 3822 | + if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) { |
|
| 3823 | + $result = true; |
|
| 3824 | + } |
|
| 3843 | 3825 | |
| 3844 | - /** |
|
| 3845 | - * Tests if the current output is inside a fusion builder preview. |
|
| 3846 | - * |
|
| 3847 | - * @return bool |
|
| 3848 | - *@since 1.1.0 |
|
| 3849 | - */ |
|
| 3850 | - public function is_fusion_preview() { |
|
| 3851 | - $result = false; |
|
| 3852 | - if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) { |
|
| 3853 | - $result = true; |
|
| 3854 | - } |
|
| 3826 | + return $result; |
|
| 3827 | + } |
|
| 3855 | 3828 | |
| 3856 | - return $result; |
|
| 3857 | - } |
|
| 3829 | + /** |
|
| 3830 | + * Tests if the current output is inside a cornerstone builder preview. |
|
| 3831 | + * |
|
| 3832 | + * @return bool |
|
| 3833 | + *@since 1.0.8 |
|
| 3834 | + */ |
|
| 3835 | + public function is_cornerstone_preview() { |
|
| 3836 | + $result = false; |
|
| 3837 | + if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) { |
|
| 3838 | + $result = true; |
|
| 3839 | + } |
|
| 3858 | 3840 | |
| 3859 | - /** |
|
| 3860 | - * Tests if the current output is inside a Oxygen builder preview. |
|
| 3861 | - * |
|
| 3862 | - * @return bool |
|
| 3863 | - *@since 1.0.18 |
|
| 3864 | - */ |
|
| 3865 | - public function is_oxygen_preview() { |
|
| 3866 | - $result = false; |
|
| 3867 | - if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) { |
|
| 3868 | - $result = true; |
|
| 3869 | - } |
|
| 3841 | + return $result; |
|
| 3842 | + } |
|
| 3870 | 3843 | |
| 3871 | - return $result; |
|
| 3872 | - } |
|
| 3844 | + /** |
|
| 3845 | + * Tests if the current output is inside a fusion builder preview. |
|
| 3846 | + * |
|
| 3847 | + * @return bool |
|
| 3848 | + *@since 1.1.0 |
|
| 3849 | + */ |
|
| 3850 | + public function is_fusion_preview() { |
|
| 3851 | + $result = false; |
|
| 3852 | + if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) { |
|
| 3853 | + $result = true; |
|
| 3854 | + } |
|
| 3873 | 3855 | |
| 3874 | - /** |
|
| 3875 | - * General function to check if we are in a preview situation. |
|
| 3876 | - * |
|
| 3877 | - * @return bool |
|
| 3878 | - *@since 1.0.6 |
|
| 3879 | - */ |
|
| 3880 | - public function is_preview() { |
|
| 3881 | - $preview = false; |
|
| 3882 | - if ( $this->is_divi_preview() ) { |
|
| 3883 | - $preview = true; |
|
| 3884 | - } elseif ( $this->is_elementor_preview() ) { |
|
| 3885 | - $preview = true; |
|
| 3886 | - } elseif ( $this->is_beaver_preview() ) { |
|
| 3887 | - $preview = true; |
|
| 3888 | - } elseif ( $this->is_siteorigin_preview() ) { |
|
| 3889 | - $preview = true; |
|
| 3890 | - } elseif ( $this->is_cornerstone_preview() ) { |
|
| 3891 | - $preview = true; |
|
| 3892 | - } elseif ( $this->is_fusion_preview() ) { |
|
| 3893 | - $preview = true; |
|
| 3894 | - } elseif ( $this->is_oxygen_preview() ) { |
|
| 3895 | - $preview = true; |
|
| 3896 | - } elseif( $this->is_block_content_call() ) { |
|
| 3897 | - $preview = true; |
|
| 3898 | - } |
|
| 3856 | + return $result; |
|
| 3857 | + } |
|
| 3899 | 3858 | |
| 3900 | - return $preview; |
|
| 3901 | - } |
|
| 3859 | + /** |
|
| 3860 | + * Tests if the current output is inside a Oxygen builder preview. |
|
| 3861 | + * |
|
| 3862 | + * @return bool |
|
| 3863 | + *@since 1.0.18 |
|
| 3864 | + */ |
|
| 3865 | + public function is_oxygen_preview() { |
|
| 3866 | + $result = false; |
|
| 3867 | + if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) { |
|
| 3868 | + $result = true; |
|
| 3869 | + } |
|
| 3902 | 3870 | |
| 3903 | - /** |
|
| 3904 | - * Output the super title. |
|
| 3905 | - * |
|
| 3906 | - * @param $args |
|
| 3907 | - * @param array $instance |
|
| 3908 | - * |
|
| 3909 | - * @return string |
|
| 3910 | - */ |
|
| 3911 | - public function output_title( $args, $instance = array() ) { |
|
| 3912 | - $output = ''; |
|
| 3913 | - if ( ! empty( $instance['title'] ) ) { |
|
| 3914 | - /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ |
|
| 3915 | - $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); |
|
| 3916 | - |
|
| 3917 | - if(empty($instance['widget_title_tag'])){ |
|
| 3918 | - $output = $args['before_title'] . $title . $args['after_title']; |
|
| 3919 | - }else{ |
|
| 3920 | - $title_tag = esc_attr( $instance['widget_title_tag'] ); |
|
| 3921 | - |
|
| 3922 | - // classes |
|
| 3923 | - $title_classes = array(); |
|
| 3924 | - $title_classes[] = !empty( $instance['widget_title_size_class'] ) ? sanitize_html_class( $instance['widget_title_size_class'] ) : ''; |
|
| 3925 | - $title_classes[] = !empty( $instance['widget_title_align_class'] ) ? sanitize_html_class( $instance['widget_title_align_class'] ) : ''; |
|
| 3926 | - $title_classes[] = !empty( $instance['widget_title_color_class'] ) ? "text-".sanitize_html_class( $instance['widget_title_color_class'] ) : ''; |
|
| 3927 | - $title_classes[] = !empty( $instance['widget_title_border_class'] ) ? sanitize_html_class( $instance['widget_title_border_class'] ) : ''; |
|
| 3928 | - $title_classes[] = !empty( $instance['widget_title_border_color_class'] ) ? "border-".sanitize_html_class( $instance['widget_title_border_color_class'] ) : ''; |
|
| 3929 | - $title_classes[] = !empty( $instance['widget_title_mt_class'] ) ? "mt-".absint( $instance['widget_title_mt_class'] ) : ''; |
|
| 3930 | - $title_classes[] = !empty( $instance['widget_title_mr_class'] ) ? "mr-".absint( $instance['widget_title_mr_class'] ) : ''; |
|
| 3931 | - $title_classes[] = !empty( $instance['widget_title_mb_class'] ) ? "mb-".absint( $instance['widget_title_mb_class'] ) : ''; |
|
| 3932 | - $title_classes[] = !empty( $instance['widget_title_ml_class'] ) ? "ml-".absint( $instance['widget_title_ml_class'] ) : ''; |
|
| 3933 | - $title_classes[] = !empty( $instance['widget_title_pt_class'] ) ? "pt-".absint( $instance['widget_title_pt_class'] ) : ''; |
|
| 3934 | - $title_classes[] = !empty( $instance['widget_title_pr_class'] ) ? "pr-".absint( $instance['widget_title_pr_class'] ) : ''; |
|
| 3935 | - $title_classes[] = !empty( $instance['widget_title_pb_class'] ) ? "pb-".absint( $instance['widget_title_pb_class'] ) : ''; |
|
| 3936 | - $title_classes[] = !empty( $instance['widget_title_pl_class'] ) ? "pl-".absint( $instance['widget_title_pl_class'] ) : ''; |
|
| 3937 | - |
|
| 3938 | - $class = !empty( $title_classes ) ? implode(" ",$title_classes) : ''; |
|
| 3939 | - $output = "<$title_tag class='$class' >$title</$title_tag>"; |
|
| 3940 | - } |
|
| 3871 | + return $result; |
|
| 3872 | + } |
|
| 3941 | 3873 | |
| 3942 | - } |
|
| 3874 | + /** |
|
| 3875 | + * General function to check if we are in a preview situation. |
|
| 3876 | + * |
|
| 3877 | + * @return bool |
|
| 3878 | + *@since 1.0.6 |
|
| 3879 | + */ |
|
| 3880 | + public function is_preview() { |
|
| 3881 | + $preview = false; |
|
| 3882 | + if ( $this->is_divi_preview() ) { |
|
| 3883 | + $preview = true; |
|
| 3884 | + } elseif ( $this->is_elementor_preview() ) { |
|
| 3885 | + $preview = true; |
|
| 3886 | + } elseif ( $this->is_beaver_preview() ) { |
|
| 3887 | + $preview = true; |
|
| 3888 | + } elseif ( $this->is_siteorigin_preview() ) { |
|
| 3889 | + $preview = true; |
|
| 3890 | + } elseif ( $this->is_cornerstone_preview() ) { |
|
| 3891 | + $preview = true; |
|
| 3892 | + } elseif ( $this->is_fusion_preview() ) { |
|
| 3893 | + $preview = true; |
|
| 3894 | + } elseif ( $this->is_oxygen_preview() ) { |
|
| 3895 | + $preview = true; |
|
| 3896 | + } elseif( $this->is_block_content_call() ) { |
|
| 3897 | + $preview = true; |
|
| 3898 | + } |
|
| 3943 | 3899 | |
| 3944 | - return $output; |
|
| 3945 | - } |
|
| 3900 | + return $preview; |
|
| 3901 | + } |
|
| 3902 | + |
|
| 3903 | + /** |
|
| 3904 | + * Output the super title. |
|
| 3905 | + * |
|
| 3906 | + * @param $args |
|
| 3907 | + * @param array $instance |
|
| 3908 | + * |
|
| 3909 | + * @return string |
|
| 3910 | + */ |
|
| 3911 | + public function output_title( $args, $instance = array() ) { |
|
| 3912 | + $output = ''; |
|
| 3913 | + if ( ! empty( $instance['title'] ) ) { |
|
| 3914 | + /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ |
|
| 3915 | + $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); |
|
| 3916 | + |
|
| 3917 | + if(empty($instance['widget_title_tag'])){ |
|
| 3918 | + $output = $args['before_title'] . $title . $args['after_title']; |
|
| 3919 | + }else{ |
|
| 3920 | + $title_tag = esc_attr( $instance['widget_title_tag'] ); |
|
| 3921 | + |
|
| 3922 | + // classes |
|
| 3923 | + $title_classes = array(); |
|
| 3924 | + $title_classes[] = !empty( $instance['widget_title_size_class'] ) ? sanitize_html_class( $instance['widget_title_size_class'] ) : ''; |
|
| 3925 | + $title_classes[] = !empty( $instance['widget_title_align_class'] ) ? sanitize_html_class( $instance['widget_title_align_class'] ) : ''; |
|
| 3926 | + $title_classes[] = !empty( $instance['widget_title_color_class'] ) ? "text-".sanitize_html_class( $instance['widget_title_color_class'] ) : ''; |
|
| 3927 | + $title_classes[] = !empty( $instance['widget_title_border_class'] ) ? sanitize_html_class( $instance['widget_title_border_class'] ) : ''; |
|
| 3928 | + $title_classes[] = !empty( $instance['widget_title_border_color_class'] ) ? "border-".sanitize_html_class( $instance['widget_title_border_color_class'] ) : ''; |
|
| 3929 | + $title_classes[] = !empty( $instance['widget_title_mt_class'] ) ? "mt-".absint( $instance['widget_title_mt_class'] ) : ''; |
|
| 3930 | + $title_classes[] = !empty( $instance['widget_title_mr_class'] ) ? "mr-".absint( $instance['widget_title_mr_class'] ) : ''; |
|
| 3931 | + $title_classes[] = !empty( $instance['widget_title_mb_class'] ) ? "mb-".absint( $instance['widget_title_mb_class'] ) : ''; |
|
| 3932 | + $title_classes[] = !empty( $instance['widget_title_ml_class'] ) ? "ml-".absint( $instance['widget_title_ml_class'] ) : ''; |
|
| 3933 | + $title_classes[] = !empty( $instance['widget_title_pt_class'] ) ? "pt-".absint( $instance['widget_title_pt_class'] ) : ''; |
|
| 3934 | + $title_classes[] = !empty( $instance['widget_title_pr_class'] ) ? "pr-".absint( $instance['widget_title_pr_class'] ) : ''; |
|
| 3935 | + $title_classes[] = !empty( $instance['widget_title_pb_class'] ) ? "pb-".absint( $instance['widget_title_pb_class'] ) : ''; |
|
| 3936 | + $title_classes[] = !empty( $instance['widget_title_pl_class'] ) ? "pl-".absint( $instance['widget_title_pl_class'] ) : ''; |
|
| 3937 | + |
|
| 3938 | + $class = !empty( $title_classes ) ? implode(" ",$title_classes) : ''; |
|
| 3939 | + $output = "<$title_tag class='$class' >$title</$title_tag>"; |
|
| 3940 | + } |
|
| 3941 | + |
|
| 3942 | + } |
|
| 3946 | 3943 | |
| 3947 | - /** |
|
| 3948 | - * Outputs the options form inputs for the widget. |
|
| 3949 | - * |
|
| 3950 | - * @param array $instance The widget options. |
|
| 3951 | - */ |
|
| 3952 | - public function form( $instance ) { |
|
| 3944 | + return $output; |
|
| 3945 | + } |
|
| 3946 | + |
|
| 3947 | + /** |
|
| 3948 | + * Outputs the options form inputs for the widget. |
|
| 3949 | + * |
|
| 3950 | + * @param array $instance The widget options. |
|
| 3951 | + */ |
|
| 3952 | + public function form( $instance ) { |
|
| 3953 | 3953 | |
| 3954 | - // set widget instance |
|
| 3955 | - $this->instance = $instance; |
|
| 3954 | + // set widget instance |
|
| 3955 | + $this->instance = $instance; |
|
| 3956 | 3956 | |
| 3957 | - // set it as a SD widget |
|
| 3958 | - echo $this->widget_advanced_toggle(); |
|
| 3957 | + // set it as a SD widget |
|
| 3958 | + echo $this->widget_advanced_toggle(); |
|
| 3959 | 3959 | |
| 3960 | - echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>"; |
|
| 3961 | - $arguments_raw = $this->get_arguments(); |
|
| 3960 | + echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>"; |
|
| 3961 | + $arguments_raw = $this->get_arguments(); |
|
| 3962 | 3962 | |
| 3963 | - if ( is_array( $arguments_raw ) ) { |
|
| 3963 | + if ( is_array( $arguments_raw ) ) { |
|
| 3964 | 3964 | |
| 3965 | - $arguments = $this->group_arguments( $arguments_raw ); |
|
| 3965 | + $arguments = $this->group_arguments( $arguments_raw ); |
|
| 3966 | 3966 | |
| 3967 | - // Do we have sections? |
|
| 3968 | - $has_sections = $arguments == $arguments_raw ? false : true; |
|
| 3967 | + // Do we have sections? |
|
| 3968 | + $has_sections = $arguments == $arguments_raw ? false : true; |
|
| 3969 | 3969 | |
| 3970 | 3970 | |
| 3971 | - if ( $has_sections ) { |
|
| 3972 | - $panel_count = 0; |
|
| 3973 | - foreach ( $arguments as $key => $args ) { |
|
| 3971 | + if ( $has_sections ) { |
|
| 3972 | + $panel_count = 0; |
|
| 3973 | + foreach ( $arguments as $key => $args ) { |
|
| 3974 | 3974 | |
| 3975 | - ?> |
|
| 3975 | + ?> |
|
| 3976 | 3976 | <script> |
| 3977 | 3977 | // jQuery(this).find("i").toggleClass("fas fa-chevron-up fas fa-chevron-down");jQuery(this).next().toggle(); |
| 3978 | 3978 | </script> |
| 3979 | 3979 | <?php |
| 3980 | 3980 | |
| 3981 | - $hide = $panel_count ? ' style="display:none;" ' : ''; |
|
| 3982 | - $icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down'; |
|
| 3983 | - echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes( $key ) . "'>" . esc_attr( $key ) . " <i style='float:right;' class='" . $icon_class . "'></i></button>"; |
|
| 3984 | - echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>"; |
|
| 3981 | + $hide = $panel_count ? ' style="display:none;" ' : ''; |
|
| 3982 | + $icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down'; |
|
| 3983 | + echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes( $key ) . "'>" . esc_attr( $key ) . " <i style='float:right;' class='" . $icon_class . "'></i></button>"; |
|
| 3984 | + echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>"; |
|
| 3985 | 3985 | |
| 3986 | - foreach ( $args as $k => $a ) { |
|
| 3986 | + foreach ( $args as $k => $a ) { |
|
| 3987 | 3987 | |
| 3988 | - $this->widget_inputs_row_start($k, $a); |
|
| 3989 | - $this->widget_inputs( $a, $instance ); |
|
| 3990 | - $this->widget_inputs_row_end($k, $a); |
|
| 3988 | + $this->widget_inputs_row_start($k, $a); |
|
| 3989 | + $this->widget_inputs( $a, $instance ); |
|
| 3990 | + $this->widget_inputs_row_end($k, $a); |
|
| 3991 | 3991 | |
| 3992 | - } |
|
| 3992 | + } |
|
| 3993 | 3993 | |
| 3994 | - echo "</div>"; |
|
| 3994 | + echo "</div>"; |
|
| 3995 | 3995 | |
| 3996 | - $panel_count ++; |
|
| 3996 | + $panel_count ++; |
|
| 3997 | 3997 | |
| 3998 | - } |
|
| 3999 | - } else { |
|
| 4000 | - foreach ( $arguments as $key => $args ) { |
|
| 4001 | - $this->widget_inputs_row_start($key, $args); |
|
| 4002 | - $this->widget_inputs( $args, $instance ); |
|
| 4003 | - $this->widget_inputs_row_end($key, $args); |
|
| 4004 | - } |
|
| 4005 | - } |
|
| 3998 | + } |
|
| 3999 | + } else { |
|
| 4000 | + foreach ( $arguments as $key => $args ) { |
|
| 4001 | + $this->widget_inputs_row_start($key, $args); |
|
| 4002 | + $this->widget_inputs( $args, $instance ); |
|
| 4003 | + $this->widget_inputs_row_end($key, $args); |
|
| 4004 | + } |
|
| 4005 | + } |
|
| 4006 | 4006 | |
| 4007 | - } |
|
| 4008 | - } |
|
| 4007 | + } |
|
| 4008 | + } |
|
| 4009 | 4009 | |
| 4010 | - public function widget_inputs_row_start($key, $args){ |
|
| 4011 | - if(!empty($args['row'])){ |
|
| 4012 | - // maybe open |
|
| 4013 | - if(!empty($args['row']['open'])){ |
|
| 4014 | - ?> |
|
| 4010 | + public function widget_inputs_row_start($key, $args){ |
|
| 4011 | + if(!empty($args['row'])){ |
|
| 4012 | + // maybe open |
|
| 4013 | + if(!empty($args['row']['open'])){ |
|
| 4014 | + ?> |
|
| 4015 | 4015 | <div class='bsui sd-argument ' data-argument='<?php echo esc_attr( $args['row']['key'] ); ?>' data-element_require='<?php if ( !empty($args['row']['element_require'])) { |
| 4016 | - echo $this->convert_element_require( $args['row']['element_require'] ); |
|
| 4017 | - } ?>'> |
|
| 4016 | + echo $this->convert_element_require( $args['row']['element_require'] ); |
|
| 4017 | + } ?>'> |
|
| 4018 | 4018 | <?php if(!empty($args['row']['title'])){ ?> |
| 4019 | 4019 | <label class="mb-0 "><?php echo esc_attr( $args['row']['title'] ); ?><?php echo $this->widget_field_desc( $args['row'] ); ?></label> |
| 4020 | 4020 | <?php }?> |
| 4021 | 4021 | <div class='row <?php if(!empty($args['row']['class'])){ echo esc_attr($args['row']['class']);} ?>'> |
| 4022 | 4022 | <div class='col pr-2'> |
| 4023 | 4023 | <?php |
| 4024 | - }elseif(!empty($args['row']['close'])){ |
|
| 4025 | - echo "<div class='col pl-0'>"; |
|
| 4026 | - }else{ |
|
| 4027 | - echo "<div class='col pl-0 pr-2'>"; |
|
| 4028 | - } |
|
| 4029 | - } |
|
| 4030 | - } |
|
| 4024 | + }elseif(!empty($args['row']['close'])){ |
|
| 4025 | + echo "<div class='col pl-0'>"; |
|
| 4026 | + }else{ |
|
| 4027 | + echo "<div class='col pl-0 pr-2'>"; |
|
| 4028 | + } |
|
| 4029 | + } |
|
| 4030 | + } |
|
| 4031 | 4031 | |
| 4032 | - public function widget_inputs_row_end($key, $args){ |
|
| 4032 | + public function widget_inputs_row_end($key, $args){ |
|
| 4033 | 4033 | |
| 4034 | - if(!empty($args['row'])){ |
|
| 4035 | - // maybe close |
|
| 4036 | - if(!empty($args['row']['close'])){ |
|
| 4037 | - echo "</div></div>"; |
|
| 4038 | - } |
|
| 4034 | + if(!empty($args['row'])){ |
|
| 4035 | + // maybe close |
|
| 4036 | + if(!empty($args['row']['close'])){ |
|
| 4037 | + echo "</div></div>"; |
|
| 4038 | + } |
|
| 4039 | 4039 | |
| 4040 | - echo "</div>"; |
|
| 4041 | - } |
|
| 4042 | - } |
|
| 4040 | + echo "</div>"; |
|
| 4041 | + } |
|
| 4042 | + } |
|
| 4043 | 4043 | |
| 4044 | - /** |
|
| 4045 | - * Get the hidden input that when added makes the advanced button show on widget settings. |
|
| 4046 | - * |
|
| 4047 | - * @return string |
|
| 4048 | - */ |
|
| 4049 | - public function widget_advanced_toggle() { |
|
| 4050 | - |
|
| 4051 | - $output = ''; |
|
| 4052 | - if ( $this->block_show_advanced() ) { |
|
| 4053 | - $val = 1; |
|
| 4054 | - } else { |
|
| 4055 | - $val = 0; |
|
| 4056 | - } |
|
| 4044 | + /** |
|
| 4045 | + * Get the hidden input that when added makes the advanced button show on widget settings. |
|
| 4046 | + * |
|
| 4047 | + * @return string |
|
| 4048 | + */ |
|
| 4049 | + public function widget_advanced_toggle() { |
|
| 4057 | 4050 | |
| 4058 | - $output .= "<input type='hidden' class='sd-show-advanced' value='$val' />"; |
|
| 4051 | + $output = ''; |
|
| 4052 | + if ( $this->block_show_advanced() ) { |
|
| 4053 | + $val = 1; |
|
| 4054 | + } else { |
|
| 4055 | + $val = 0; |
|
| 4056 | + } |
|
| 4059 | 4057 | |
| 4060 | - return $output; |
|
| 4061 | - } |
|
| 4058 | + $output .= "<input type='hidden' class='sd-show-advanced' value='$val' />"; |
|
| 4062 | 4059 | |
| 4063 | - /** |
|
| 4064 | - * Convert require element. |
|
| 4065 | - * |
|
| 4066 | - * @param string $input Input element. |
|
| 4067 | - * |
|
| 4068 | - * @return string $output |
|
| 4069 | - *@since 1.0.0 |
|
| 4070 | - * |
|
| 4071 | - */ |
|
| 4072 | - public function convert_element_require( $input ) { |
|
| 4073 | - |
|
| 4074 | - $input = str_replace( "'", '"', $input );// we only want double quotes |
|
| 4075 | - |
|
| 4076 | - $output = esc_attr( str_replace( array( "[%", "%]" ), array( |
|
| 4077 | - "jQuery(form).find('[data-argument=\"", |
|
| 4078 | - "\"]').find('input,select,textarea').val()" |
|
| 4079 | - ), $input ) ); |
|
| 4080 | - |
|
| 4081 | - return $output; |
|
| 4082 | - } |
|
| 4060 | + return $output; |
|
| 4061 | + } |
|
| 4083 | 4062 | |
| 4084 | - /** |
|
| 4085 | - * Builds the inputs for the widget options. |
|
| 4086 | - * |
|
| 4087 | - * @param $args |
|
| 4088 | - * @param $instance |
|
| 4089 | - */ |
|
| 4090 | - public function widget_inputs( $args, $instance ) { |
|
| 4091 | - |
|
| 4092 | - $class = ""; |
|
| 4093 | - $element_require = ""; |
|
| 4094 | - $custom_attributes = ""; |
|
| 4095 | - |
|
| 4096 | - // get value |
|
| 4097 | - if ( isset( $instance[ $args['name'] ] ) ) { |
|
| 4098 | - $value = $instance[ $args['name'] ]; |
|
| 4099 | - } elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) { |
|
| 4100 | - $value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] ); |
|
| 4101 | - } else { |
|
| 4102 | - $value = ''; |
|
| 4103 | - } |
|
| 4063 | + /** |
|
| 4064 | + * Convert require element. |
|
| 4065 | + * |
|
| 4066 | + * @param string $input Input element. |
|
| 4067 | + * |
|
| 4068 | + * @return string $output |
|
| 4069 | + *@since 1.0.0 |
|
| 4070 | + * |
|
| 4071 | + */ |
|
| 4072 | + public function convert_element_require( $input ) { |
|
| 4104 | 4073 | |
| 4105 | - // get placeholder |
|
| 4106 | - if ( ! empty( $args['placeholder'] ) ) { |
|
| 4107 | - $placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'"; |
|
| 4108 | - } else { |
|
| 4109 | - $placeholder = ''; |
|
| 4110 | - } |
|
| 4074 | + $input = str_replace( "'", '"', $input );// we only want double quotes |
|
| 4111 | 4075 | |
| 4112 | - // get if advanced |
|
| 4113 | - if ( isset( $args['advanced'] ) && $args['advanced'] ) { |
|
| 4114 | - $class .= " sd-advanced-setting "; |
|
| 4115 | - } |
|
| 4076 | + $output = esc_attr( str_replace( array( "[%", "%]" ), array( |
|
| 4077 | + "jQuery(form).find('[data-argument=\"", |
|
| 4078 | + "\"]').find('input,select,textarea').val()" |
|
| 4079 | + ), $input ) ); |
|
| 4116 | 4080 | |
| 4117 | - // element_require |
|
| 4118 | - if ( isset( $args['element_require'] ) && $args['element_require'] ) { |
|
| 4119 | - $element_require = $args['element_require']; |
|
| 4120 | - } |
|
| 4081 | + return $output; |
|
| 4082 | + } |
|
| 4121 | 4083 | |
| 4122 | - // custom_attributes |
|
| 4123 | - if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) { |
|
| 4124 | - $custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true ); |
|
| 4125 | - } |
|
| 4084 | + /** |
|
| 4085 | + * Builds the inputs for the widget options. |
|
| 4086 | + * |
|
| 4087 | + * @param $args |
|
| 4088 | + * @param $instance |
|
| 4089 | + */ |
|
| 4090 | + public function widget_inputs( $args, $instance ) { |
|
| 4091 | + |
|
| 4092 | + $class = ""; |
|
| 4093 | + $element_require = ""; |
|
| 4094 | + $custom_attributes = ""; |
|
| 4095 | + |
|
| 4096 | + // get value |
|
| 4097 | + if ( isset( $instance[ $args['name'] ] ) ) { |
|
| 4098 | + $value = $instance[ $args['name'] ]; |
|
| 4099 | + } elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) { |
|
| 4100 | + $value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] ); |
|
| 4101 | + } else { |
|
| 4102 | + $value = ''; |
|
| 4103 | + } |
|
| 4104 | + |
|
| 4105 | + // get placeholder |
|
| 4106 | + if ( ! empty( $args['placeholder'] ) ) { |
|
| 4107 | + $placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'"; |
|
| 4108 | + } else { |
|
| 4109 | + $placeholder = ''; |
|
| 4110 | + } |
|
| 4126 | 4111 | |
| 4112 | + // get if advanced |
|
| 4113 | + if ( isset( $args['advanced'] ) && $args['advanced'] ) { |
|
| 4114 | + $class .= " sd-advanced-setting "; |
|
| 4115 | + } |
|
| 4127 | 4116 | |
| 4128 | - // before wrapper |
|
| 4129 | - ?> |
|
| 4117 | + // element_require |
|
| 4118 | + if ( isset( $args['element_require'] ) && $args['element_require'] ) { |
|
| 4119 | + $element_require = $args['element_require']; |
|
| 4120 | + } |
|
| 4121 | + |
|
| 4122 | + // custom_attributes |
|
| 4123 | + if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) { |
|
| 4124 | + $custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true ); |
|
| 4125 | + } |
|
| 4126 | + |
|
| 4127 | + |
|
| 4128 | + // before wrapper |
|
| 4129 | + ?> |
|
| 4130 | 4130 | <p class="sd-argument <?php echo esc_attr( $class ); ?>" |
| 4131 | 4131 | data-argument='<?php echo esc_attr( $args['name'] ); ?>' |
| 4132 | 4132 | data-element_require='<?php if ( $element_require ) { |
| 4133 | - echo $this->convert_element_require( $element_require ); |
|
| 4134 | - } ?>' |
|
| 4133 | + echo $this->convert_element_require( $element_require ); |
|
| 4134 | + } ?>' |
|
| 4135 | 4135 | > |
| 4136 | 4136 | <?php |
| 4137 | 4137 | |
| 4138 | 4138 | |
| 4139 | - switch ( $args['type'] ) { |
|
| 4140 | - //array('text','password','number','email','tel','url','color') |
|
| 4141 | - case "text": |
|
| 4142 | - case "password": |
|
| 4143 | - case "number": |
|
| 4144 | - case "email": |
|
| 4145 | - case "tel": |
|
| 4146 | - case "url": |
|
| 4147 | - case "color": |
|
| 4148 | - ?> |
|
| 4139 | + switch ( $args['type'] ) { |
|
| 4140 | + //array('text','password','number','email','tel','url','color') |
|
| 4141 | + case "text": |
|
| 4142 | + case "password": |
|
| 4143 | + case "number": |
|
| 4144 | + case "email": |
|
| 4145 | + case "tel": |
|
| 4146 | + case "url": |
|
| 4147 | + case "color": |
|
| 4148 | + ?> |
|
| 4149 | 4149 | <label |
| 4150 | 4150 | for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args );?><?php echo $this->widget_field_desc( $args ); ?></label> |
| 4151 | 4151 | <input <?php echo $placeholder; ?> class="widefat" |
@@ -4156,47 +4156,47 @@ discard block |
||
| 4156 | 4156 | value="<?php echo esc_attr( $value ); ?>"> |
| 4157 | 4157 | <?php |
| 4158 | 4158 | |
| 4159 | - break; |
|
| 4160 | - case "select": |
|
| 4161 | - $multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false; |
|
| 4162 | - if ( $multiple ) { |
|
| 4163 | - if ( empty( $value ) ) { |
|
| 4164 | - $value = array(); |
|
| 4165 | - } |
|
| 4166 | - } |
|
| 4167 | - ?> |
|
| 4159 | + break; |
|
| 4160 | + case "select": |
|
| 4161 | + $multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false; |
|
| 4162 | + if ( $multiple ) { |
|
| 4163 | + if ( empty( $value ) ) { |
|
| 4164 | + $value = array(); |
|
| 4165 | + } |
|
| 4166 | + } |
|
| 4167 | + ?> |
|
| 4168 | 4168 | <label |
| 4169 | 4169 | for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
| 4170 | 4170 | <select <?php echo $placeholder; ?> class="widefat" |
| 4171 | 4171 | <?php echo $custom_attributes; ?> |
| 4172 | 4172 | id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
| 4173 | 4173 | name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); |
| 4174 | - if ( $multiple ) { |
|
| 4175 | - echo "[]"; |
|
| 4176 | - } ?>" |
|
| 4174 | + if ( $multiple ) { |
|
| 4175 | + echo "[]"; |
|
| 4176 | + } ?>" |
|
| 4177 | 4177 | <?php if ( $multiple ) { |
| 4178 | - echo "multiple"; |
|
| 4179 | - } //@todo not implemented yet due to gutenberg not supporting it |
|
| 4180 | - ?> |
|
| 4178 | + echo "multiple"; |
|
| 4179 | + } //@todo not implemented yet due to gutenberg not supporting it |
|
| 4180 | + ?> |
|
| 4181 | 4181 | > |
| 4182 | 4182 | <?php |
| 4183 | 4183 | |
| 4184 | - if ( ! empty( $args['options'] ) ) { |
|
| 4185 | - foreach ( $args['options'] as $val => $label ) { |
|
| 4186 | - if ( $multiple ) { |
|
| 4187 | - $selected = in_array( $val, $value ) ? 'selected="selected"' : ''; |
|
| 4188 | - } else { |
|
| 4189 | - $selected = selected( $value, $val, false ); |
|
| 4190 | - } |
|
| 4191 | - echo "<option value='$val' " . $selected . ">$label</option>"; |
|
| 4192 | - } |
|
| 4193 | - } |
|
| 4194 | - ?> |
|
| 4184 | + if ( ! empty( $args['options'] ) ) { |
|
| 4185 | + foreach ( $args['options'] as $val => $label ) { |
|
| 4186 | + if ( $multiple ) { |
|
| 4187 | + $selected = in_array( $val, $value ) ? 'selected="selected"' : ''; |
|
| 4188 | + } else { |
|
| 4189 | + $selected = selected( $value, $val, false ); |
|
| 4190 | + } |
|
| 4191 | + echo "<option value='$val' " . $selected . ">$label</option>"; |
|
| 4192 | + } |
|
| 4193 | + } |
|
| 4194 | + ?> |
|
| 4195 | 4195 | </select> |
| 4196 | 4196 | <?php |
| 4197 | - break; |
|
| 4198 | - case "checkbox": |
|
| 4199 | - ?> |
|
| 4197 | + break; |
|
| 4198 | + case "checkbox": |
|
| 4199 | + ?> |
|
| 4200 | 4200 | <input <?php echo $placeholder; ?> |
| 4201 | 4201 | <?php checked( 1, $value, true ) ?> |
| 4202 | 4202 | <?php echo $custom_attributes; ?> |
@@ -4206,9 +4206,9 @@ discard block |
||
| 4206 | 4206 | <label |
| 4207 | 4207 | for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args );?><?php echo $this->widget_field_desc( $args ); ?></label> |
| 4208 | 4208 | <?php |
| 4209 | - break; |
|
| 4210 | - case "textarea": |
|
| 4211 | - ?> |
|
| 4209 | + break; |
|
| 4210 | + case "textarea": |
|
| 4211 | + ?> |
|
| 4212 | 4212 | <label |
| 4213 | 4213 | for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
| 4214 | 4214 | <textarea <?php echo $placeholder; ?> class="widefat" |
@@ -4218,282 +4218,282 @@ discard block |
||
| 4218 | 4218 | ><?php echo esc_attr( $value ); ?></textarea> |
| 4219 | 4219 | <?php |
| 4220 | 4220 | |
| 4221 | - break; |
|
| 4222 | - case "hidden": |
|
| 4223 | - ?> |
|
| 4221 | + break; |
|
| 4222 | + case "hidden": |
|
| 4223 | + ?> |
|
| 4224 | 4224 | <input id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
| 4225 | 4225 | name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="hidden" |
| 4226 | 4226 | value="<?php echo esc_attr( $value ); ?>"> |
| 4227 | 4227 | <?php |
| 4228 | - break; |
|
| 4229 | - default: |
|
| 4230 | - echo "No input type found!"; // @todo we need to add more input types. |
|
| 4231 | - } |
|
| 4228 | + break; |
|
| 4229 | + default: |
|
| 4230 | + echo "No input type found!"; // @todo we need to add more input types. |
|
| 4231 | + } |
|
| 4232 | 4232 | |
| 4233 | - // after wrapper |
|
| 4234 | - ?> |
|
| 4233 | + // after wrapper |
|
| 4234 | + ?> |
|
| 4235 | 4235 | </p> |
| 4236 | 4236 | <?php |
| 4237 | 4237 | |
| 4238 | 4238 | |
| 4239 | - } |
|
| 4239 | + } |
|
| 4240 | 4240 | |
| 4241 | - public function get_widget_icon($icon = 'box-top', $title = ''){ |
|
| 4242 | - if($icon=='box-top'){ |
|
| 4243 | - return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.048" height="9.017" fill="#555D66"></rect><rect x="16.265" y="5.498" width="1.023" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.186" width="8.964" height="2.482" fill="#272B2F"></rect><rect x="5.487" y="16.261" width="9.026" height="1.037" fill="#555D66"></rect></svg>'; |
|
| 4244 | - }elseif($icon=='box-right'){ |
|
| 4245 | - return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.046" height="9.017" fill="#555D66"></rect><rect x="15.244" y="5.498" width="2.518" height="9.003" fill="#272B2F"></rect><rect x="5.518" y="2.719" width="8.964" height="0.954" fill="#555D66"></rect><rect x="5.487" y="16.308" width="9.026" height="0.99" fill="#555D66"></rect></svg>'; |
|
| 4246 | - }elseif($icon=='box-bottom'){ |
|
| 4247 | - return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1" height="9.017" fill="#555D66"></rect><rect x="16.261" y="5.498" width="1.027" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.968" fill="#555D66"></rect><rect x="5.487" y="15.28" width="9.026" height="2.499" fill="#272B2F"></rect></svg>'; |
|
| 4248 | - }elseif($icon=='box-left'){ |
|
| 4249 | - return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.202" y="5.492" width="2.503" height="9.017" fill="#272B2F"></rect><rect x="16.276" y="5.498" width="1.012" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.966" fill="#555D66"></rect><rect x="5.487" y="16.303" width="9.026" height="0.995" fill="#555D66"></rect></svg>'; |
|
| 4250 | - } |
|
| 4251 | - } |
|
| 4241 | + public function get_widget_icon($icon = 'box-top', $title = ''){ |
|
| 4242 | + if($icon=='box-top'){ |
|
| 4243 | + return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.048" height="9.017" fill="#555D66"></rect><rect x="16.265" y="5.498" width="1.023" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.186" width="8.964" height="2.482" fill="#272B2F"></rect><rect x="5.487" y="16.261" width="9.026" height="1.037" fill="#555D66"></rect></svg>'; |
|
| 4244 | + }elseif($icon=='box-right'){ |
|
| 4245 | + return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.046" height="9.017" fill="#555D66"></rect><rect x="15.244" y="5.498" width="2.518" height="9.003" fill="#272B2F"></rect><rect x="5.518" y="2.719" width="8.964" height="0.954" fill="#555D66"></rect><rect x="5.487" y="16.308" width="9.026" height="0.99" fill="#555D66"></rect></svg>'; |
|
| 4246 | + }elseif($icon=='box-bottom'){ |
|
| 4247 | + return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1" height="9.017" fill="#555D66"></rect><rect x="16.261" y="5.498" width="1.027" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.968" fill="#555D66"></rect><rect x="5.487" y="15.28" width="9.026" height="2.499" fill="#272B2F"></rect></svg>'; |
|
| 4248 | + }elseif($icon=='box-left'){ |
|
| 4249 | + return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.202" y="5.492" width="2.503" height="9.017" fill="#272B2F"></rect><rect x="16.276" y="5.498" width="1.012" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.966" fill="#555D66"></rect><rect x="5.487" y="16.303" width="9.026" height="0.995" fill="#555D66"></rect></svg>'; |
|
| 4250 | + } |
|
| 4251 | + } |
|
| 4252 | 4252 | |
| 4253 | - /** |
|
| 4254 | - * Get the widget input description html. |
|
| 4255 | - * |
|
| 4256 | - * @param $args |
|
| 4257 | - * |
|
| 4258 | - * @return string |
|
| 4259 | - * @todo, need to make its own tooltip script |
|
| 4260 | - */ |
|
| 4261 | - public function widget_field_desc( $args ) { |
|
| 4262 | - |
|
| 4263 | - $description = ''; |
|
| 4264 | - if ( isset( $args['desc'] ) && $args['desc'] ) { |
|
| 4265 | - if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) { |
|
| 4266 | - $description = $this->desc_tip( $args['desc'] ); |
|
| 4267 | - } else { |
|
| 4268 | - $description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>'; |
|
| 4269 | - } |
|
| 4270 | - } |
|
| 4253 | + /** |
|
| 4254 | + * Get the widget input description html. |
|
| 4255 | + * |
|
| 4256 | + * @param $args |
|
| 4257 | + * |
|
| 4258 | + * @return string |
|
| 4259 | + * @todo, need to make its own tooltip script |
|
| 4260 | + */ |
|
| 4261 | + public function widget_field_desc( $args ) { |
|
| 4262 | + |
|
| 4263 | + $description = ''; |
|
| 4264 | + if ( isset( $args['desc'] ) && $args['desc'] ) { |
|
| 4265 | + if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) { |
|
| 4266 | + $description = $this->desc_tip( $args['desc'] ); |
|
| 4267 | + } else { |
|
| 4268 | + $description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>'; |
|
| 4269 | + } |
|
| 4270 | + } |
|
| 4271 | 4271 | |
| 4272 | - return $description; |
|
| 4273 | - } |
|
| 4272 | + return $description; |
|
| 4273 | + } |
|
| 4274 | 4274 | |
| 4275 | - /** |
|
| 4276 | - * Get the widget input title html. |
|
| 4277 | - * |
|
| 4278 | - * @param $args |
|
| 4279 | - * |
|
| 4280 | - * @return string |
|
| 4281 | - */ |
|
| 4282 | - public function widget_field_title( $args ) { |
|
| 4283 | - |
|
| 4284 | - $title = ''; |
|
| 4285 | - if ( isset( $args['title'] ) && $args['title'] ) { |
|
| 4286 | - if ( isset( $args['icon'] ) && $args['icon'] ) { |
|
| 4287 | - $title = self::get_widget_icon( $args['icon'], $args['title'] ); |
|
| 4288 | - } else { |
|
| 4289 | - $title = esc_attr($args['title']); |
|
| 4290 | - } |
|
| 4291 | - } |
|
| 4275 | + /** |
|
| 4276 | + * Get the widget input title html. |
|
| 4277 | + * |
|
| 4278 | + * @param $args |
|
| 4279 | + * |
|
| 4280 | + * @return string |
|
| 4281 | + */ |
|
| 4282 | + public function widget_field_title( $args ) { |
|
| 4283 | + |
|
| 4284 | + $title = ''; |
|
| 4285 | + if ( isset( $args['title'] ) && $args['title'] ) { |
|
| 4286 | + if ( isset( $args['icon'] ) && $args['icon'] ) { |
|
| 4287 | + $title = self::get_widget_icon( $args['icon'], $args['title'] ); |
|
| 4288 | + } else { |
|
| 4289 | + $title = esc_attr($args['title']); |
|
| 4290 | + } |
|
| 4291 | + } |
|
| 4292 | 4292 | |
| 4293 | - return $title; |
|
| 4294 | - } |
|
| 4293 | + return $title; |
|
| 4294 | + } |
|
| 4295 | 4295 | |
| 4296 | - /** |
|
| 4297 | - * Get the tool tip html. |
|
| 4298 | - * |
|
| 4299 | - * @param $tip |
|
| 4300 | - * @param bool $allow_html |
|
| 4301 | - * |
|
| 4302 | - * @return string |
|
| 4303 | - */ |
|
| 4304 | - function desc_tip( $tip, $allow_html = false ) { |
|
| 4305 | - if ( $allow_html ) { |
|
| 4306 | - $tip = $this->sanitize_tooltip( $tip ); |
|
| 4307 | - } else { |
|
| 4308 | - $tip = esc_attr( $tip ); |
|
| 4309 | - } |
|
| 4296 | + /** |
|
| 4297 | + * Get the tool tip html. |
|
| 4298 | + * |
|
| 4299 | + * @param $tip |
|
| 4300 | + * @param bool $allow_html |
|
| 4301 | + * |
|
| 4302 | + * @return string |
|
| 4303 | + */ |
|
| 4304 | + function desc_tip( $tip, $allow_html = false ) { |
|
| 4305 | + if ( $allow_html ) { |
|
| 4306 | + $tip = $this->sanitize_tooltip( $tip ); |
|
| 4307 | + } else { |
|
| 4308 | + $tip = esc_attr( $tip ); |
|
| 4309 | + } |
|
| 4310 | 4310 | |
| 4311 | - return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
|
| 4312 | - } |
|
| 4311 | + return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
|
| 4312 | + } |
|
| 4313 | 4313 | |
| 4314 | - /** |
|
| 4315 | - * Sanitize a string destined to be a tooltip. |
|
| 4316 | - * |
|
| 4317 | - * @param string $var |
|
| 4318 | - * |
|
| 4319 | - * @return string |
|
| 4320 | - */ |
|
| 4321 | - public function sanitize_tooltip( $var ) { |
|
| 4322 | - return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( |
|
| 4323 | - 'br' => array(), |
|
| 4324 | - 'em' => array(), |
|
| 4325 | - 'strong' => array(), |
|
| 4326 | - 'small' => array(), |
|
| 4327 | - 'span' => array(), |
|
| 4328 | - 'ul' => array(), |
|
| 4329 | - 'li' => array(), |
|
| 4330 | - 'ol' => array(), |
|
| 4331 | - 'p' => array(), |
|
| 4332 | - ) ) ); |
|
| 4333 | - } |
|
| 4314 | + /** |
|
| 4315 | + * Sanitize a string destined to be a tooltip. |
|
| 4316 | + * |
|
| 4317 | + * @param string $var |
|
| 4318 | + * |
|
| 4319 | + * @return string |
|
| 4320 | + */ |
|
| 4321 | + public function sanitize_tooltip( $var ) { |
|
| 4322 | + return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( |
|
| 4323 | + 'br' => array(), |
|
| 4324 | + 'em' => array(), |
|
| 4325 | + 'strong' => array(), |
|
| 4326 | + 'small' => array(), |
|
| 4327 | + 'span' => array(), |
|
| 4328 | + 'ul' => array(), |
|
| 4329 | + 'li' => array(), |
|
| 4330 | + 'ol' => array(), |
|
| 4331 | + 'p' => array(), |
|
| 4332 | + ) ) ); |
|
| 4333 | + } |
|
| 4334 | 4334 | |
| 4335 | - /** |
|
| 4336 | - * Processing widget options on save |
|
| 4337 | - * |
|
| 4338 | - * @param array $new_instance The new options |
|
| 4339 | - * @param array $old_instance The previous options |
|
| 4340 | - * |
|
| 4341 | - * @return array |
|
| 4342 | - * @todo we should add some sanitation here. |
|
| 4343 | - */ |
|
| 4344 | - public function update( $new_instance, $old_instance ) { |
|
| 4345 | - |
|
| 4346 | - //save the widget |
|
| 4347 | - $instance = array_merge( (array) $old_instance, (array) $new_instance ); |
|
| 4348 | - |
|
| 4349 | - // set widget instance |
|
| 4350 | - $this->instance = $instance; |
|
| 4351 | - |
|
| 4352 | - if ( empty( $this->arguments ) ) { |
|
| 4353 | - $this->get_arguments(); |
|
| 4354 | - } |
|
| 4335 | + /** |
|
| 4336 | + * Processing widget options on save |
|
| 4337 | + * |
|
| 4338 | + * @param array $new_instance The new options |
|
| 4339 | + * @param array $old_instance The previous options |
|
| 4340 | + * |
|
| 4341 | + * @return array |
|
| 4342 | + * @todo we should add some sanitation here. |
|
| 4343 | + */ |
|
| 4344 | + public function update( $new_instance, $old_instance ) { |
|
| 4355 | 4345 | |
| 4356 | - // check for checkboxes |
|
| 4357 | - if ( ! empty( $this->arguments ) ) { |
|
| 4358 | - foreach ( $this->arguments as $argument ) { |
|
| 4359 | - if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) { |
|
| 4360 | - $instance[ $argument['name'] ] = '0'; |
|
| 4361 | - } |
|
| 4362 | - } |
|
| 4363 | - } |
|
| 4346 | + //save the widget |
|
| 4347 | + $instance = array_merge( (array) $old_instance, (array) $new_instance ); |
|
| 4364 | 4348 | |
| 4365 | - return $instance; |
|
| 4366 | - } |
|
| 4349 | + // set widget instance |
|
| 4350 | + $this->instance = $instance; |
|
| 4367 | 4351 | |
| 4368 | - /** |
|
| 4369 | - * Checks if the current call is a ajax call to get the block content. |
|
| 4370 | - * |
|
| 4371 | - * This can be used in your widget to return different content as the block content. |
|
| 4372 | - * |
|
| 4373 | - * @return bool |
|
| 4374 | - *@since 1.0.3 |
|
| 4375 | - */ |
|
| 4376 | - public function is_block_content_call() { |
|
| 4377 | - $result = false; |
|
| 4378 | - if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) { |
|
| 4379 | - $result = true; |
|
| 4380 | - } |
|
| 4352 | + if ( empty( $this->arguments ) ) { |
|
| 4353 | + $this->get_arguments(); |
|
| 4354 | + } |
|
| 4381 | 4355 | |
| 4382 | - return $result; |
|
| 4383 | - } |
|
| 4356 | + // check for checkboxes |
|
| 4357 | + if ( ! empty( $this->arguments ) ) { |
|
| 4358 | + foreach ( $this->arguments as $argument ) { |
|
| 4359 | + if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) { |
|
| 4360 | + $instance[ $argument['name'] ] = '0'; |
|
| 4361 | + } |
|
| 4362 | + } |
|
| 4363 | + } |
|
| 4384 | 4364 | |
| 4385 | - /** |
|
| 4386 | - * Get an instance hash that will be unique to the type and settings. |
|
| 4387 | - * |
|
| 4388 | - * @return string |
|
| 4389 | - *@since 1.0.20 |
|
| 4390 | - */ |
|
| 4391 | - public function get_instance_hash(){ |
|
| 4392 | - $instance_string = $this->base_id.serialize($this->instance); |
|
| 4393 | - return hash('crc32b',$instance_string); |
|
| 4394 | - } |
|
| 4365 | + return $instance; |
|
| 4366 | + } |
|
| 4395 | 4367 | |
| 4396 | - /** |
|
| 4397 | - * Generate and return inline styles from CSS rules that will match the unique class of the instance. |
|
| 4398 | - * |
|
| 4399 | - * @param array $rules |
|
| 4400 | - * |
|
| 4401 | - * @return string |
|
| 4402 | - *@since 1.0.20 |
|
| 4403 | - */ |
|
| 4404 | - public function get_instance_style($rules = array()){ |
|
| 4405 | - $css = ''; |
|
| 4406 | - |
|
| 4407 | - if(!empty($rules)){ |
|
| 4408 | - $rules = array_unique($rules); |
|
| 4409 | - $instance_hash = $this->get_instance_hash(); |
|
| 4410 | - $css .= "<style>"; |
|
| 4411 | - foreach($rules as $rule){ |
|
| 4412 | - $css .= ".sdel-$instance_hash $rule"; |
|
| 4413 | - } |
|
| 4414 | - $css .= "</style>"; |
|
| 4415 | - } |
|
| 4368 | + /** |
|
| 4369 | + * Checks if the current call is a ajax call to get the block content. |
|
| 4370 | + * |
|
| 4371 | + * This can be used in your widget to return different content as the block content. |
|
| 4372 | + * |
|
| 4373 | + * @return bool |
|
| 4374 | + *@since 1.0.3 |
|
| 4375 | + */ |
|
| 4376 | + public function is_block_content_call() { |
|
| 4377 | + $result = false; |
|
| 4378 | + if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) { |
|
| 4379 | + $result = true; |
|
| 4380 | + } |
|
| 4416 | 4381 | |
| 4417 | - return $css; |
|
| 4418 | - } |
|
| 4382 | + return $result; |
|
| 4383 | + } |
|
| 4384 | + |
|
| 4385 | + /** |
|
| 4386 | + * Get an instance hash that will be unique to the type and settings. |
|
| 4387 | + * |
|
| 4388 | + * @return string |
|
| 4389 | + *@since 1.0.20 |
|
| 4390 | + */ |
|
| 4391 | + public function get_instance_hash(){ |
|
| 4392 | + $instance_string = $this->base_id.serialize($this->instance); |
|
| 4393 | + return hash('crc32b',$instance_string); |
|
| 4394 | + } |
|
| 4395 | + |
|
| 4396 | + /** |
|
| 4397 | + * Generate and return inline styles from CSS rules that will match the unique class of the instance. |
|
| 4398 | + * |
|
| 4399 | + * @param array $rules |
|
| 4400 | + * |
|
| 4401 | + * @return string |
|
| 4402 | + *@since 1.0.20 |
|
| 4403 | + */ |
|
| 4404 | + public function get_instance_style($rules = array()){ |
|
| 4405 | + $css = ''; |
|
| 4406 | + |
|
| 4407 | + if(!empty($rules)){ |
|
| 4408 | + $rules = array_unique($rules); |
|
| 4409 | + $instance_hash = $this->get_instance_hash(); |
|
| 4410 | + $css .= "<style>"; |
|
| 4411 | + foreach($rules as $rule){ |
|
| 4412 | + $css .= ".sdel-$instance_hash $rule"; |
|
| 4413 | + } |
|
| 4414 | + $css .= "</style>"; |
|
| 4415 | + } |
|
| 4416 | + |
|
| 4417 | + return $css; |
|
| 4418 | + } |
|
| 4419 | 4419 | |
| 4420 | - /** |
|
| 4421 | - * Encode shortcodes tags. |
|
| 4422 | - * |
|
| 4423 | - * @param string $content Content to search for shortcode tags. |
|
| 4424 | - * |
|
| 4420 | + /** |
|
| 4421 | + * Encode shortcodes tags. |
|
| 4422 | + * |
|
| 4423 | + * @param string $content Content to search for shortcode tags. |
|
| 4424 | + * |
|
| 4425 | 4425 | *@return string Content with shortcode tags removed. |
| 4426 | - *@since 1.0.28 |
|
| 4427 | - * |
|
| 4428 | - */ |
|
| 4429 | - public function encode_shortcodes( $content ) { |
|
| 4430 | - // Avoids existing encoded tags. |
|
| 4431 | - $trans = array( |
|
| 4432 | - '[' => '[', |
|
| 4433 | - ']' => ']', |
|
| 4434 | - '&#91;' => '[', |
|
| 4435 | - '&#93;' => ']', |
|
| 4436 | - '<' => '&0lt;', |
|
| 4437 | - '>' => '&0gt;', |
|
| 4438 | - '&lt;' => '&0lt;', |
|
| 4439 | - '&gt;' => '&0gt;', |
|
| 4440 | - ); |
|
| 4441 | - |
|
| 4442 | - $content = strtr( $content, $trans ); |
|
| 4443 | - |
|
| 4444 | - $trans = array( |
|
| 4445 | - '[' => '[', |
|
| 4446 | - ']' => ']', |
|
| 4447 | - '<' => '<', |
|
| 4448 | - '>' => '>', |
|
| 4449 | - '"' => '"', |
|
| 4450 | - "'" => ''', |
|
| 4451 | - ); |
|
| 4452 | - |
|
| 4453 | - $content = strtr( $content, $trans ); |
|
| 4454 | - |
|
| 4455 | - return $content; |
|
| 4456 | - } |
|
| 4426 | + *@since 1.0.28 |
|
| 4427 | + * |
|
| 4428 | + */ |
|
| 4429 | + public function encode_shortcodes( $content ) { |
|
| 4430 | + // Avoids existing encoded tags. |
|
| 4431 | + $trans = array( |
|
| 4432 | + '[' => '[', |
|
| 4433 | + ']' => ']', |
|
| 4434 | + '&#91;' => '[', |
|
| 4435 | + '&#93;' => ']', |
|
| 4436 | + '<' => '&0lt;', |
|
| 4437 | + '>' => '&0gt;', |
|
| 4438 | + '&lt;' => '&0lt;', |
|
| 4439 | + '&gt;' => '&0gt;', |
|
| 4440 | + ); |
|
| 4441 | + |
|
| 4442 | + $content = strtr( $content, $trans ); |
|
| 4443 | + |
|
| 4444 | + $trans = array( |
|
| 4445 | + '[' => '[', |
|
| 4446 | + ']' => ']', |
|
| 4447 | + '<' => '<', |
|
| 4448 | + '>' => '>', |
|
| 4449 | + '"' => '"', |
|
| 4450 | + "'" => ''', |
|
| 4451 | + ); |
|
| 4452 | + |
|
| 4453 | + $content = strtr( $content, $trans ); |
|
| 4454 | + |
|
| 4455 | + return $content; |
|
| 4456 | + } |
|
| 4457 | 4457 | |
| 4458 | - /** |
|
| 4459 | - * Remove encoded shortcod tags. |
|
| 4460 | - * |
|
| 4461 | - * @param string $content Content to search for shortcode tags. |
|
| 4462 | - * |
|
| 4458 | + /** |
|
| 4459 | + * Remove encoded shortcod tags. |
|
| 4460 | + * |
|
| 4461 | + * @param string $content Content to search for shortcode tags. |
|
| 4462 | + * |
|
| 4463 | 4463 | *@return string Content with decoded shortcode tags. |
| 4464 | - *@since 1.0.28 |
|
| 4465 | - * |
|
| 4466 | - */ |
|
| 4467 | - public function decode_shortcodes( $content ) { |
|
| 4468 | - $trans = array( |
|
| 4469 | - '[' => '[', |
|
| 4470 | - ']' => ']', |
|
| 4471 | - '&#91;' => '[', |
|
| 4472 | - '&#93;' => ']', |
|
| 4473 | - '<' => '<', |
|
| 4474 | - '>' => '>', |
|
| 4475 | - '&lt;' => '<', |
|
| 4476 | - '&gt;' => '>', |
|
| 4477 | - '"' => '"', |
|
| 4478 | - ''' => "'", |
|
| 4479 | - ); |
|
| 4480 | - |
|
| 4481 | - $content = strtr( $content, $trans ); |
|
| 4482 | - |
|
| 4483 | - $trans = array( |
|
| 4484 | - '[' => '[', |
|
| 4485 | - ']' => ']', |
|
| 4486 | - '&#091;' => '[', |
|
| 4487 | - '&#093;' => ']', |
|
| 4488 | - '&0lt;' => '<', |
|
| 4489 | - '&0gt;' => '>', |
|
| 4490 | - '&0lt;' => '<', |
|
| 4491 | - '&0gt;' => '>', |
|
| 4492 | - ); |
|
| 4493 | - |
|
| 4494 | - $content = strtr( $content, $trans ); |
|
| 4495 | - |
|
| 4496 | - return $content; |
|
| 4497 | - } |
|
| 4498 | - } |
|
| 4464 | + *@since 1.0.28 |
|
| 4465 | + * |
|
| 4466 | + */ |
|
| 4467 | + public function decode_shortcodes( $content ) { |
|
| 4468 | + $trans = array( |
|
| 4469 | + '[' => '[', |
|
| 4470 | + ']' => ']', |
|
| 4471 | + '&#91;' => '[', |
|
| 4472 | + '&#93;' => ']', |
|
| 4473 | + '<' => '<', |
|
| 4474 | + '>' => '>', |
|
| 4475 | + '&lt;' => '<', |
|
| 4476 | + '&gt;' => '>', |
|
| 4477 | + '"' => '"', |
|
| 4478 | + ''' => "'", |
|
| 4479 | + ); |
|
| 4480 | + |
|
| 4481 | + $content = strtr( $content, $trans ); |
|
| 4482 | + |
|
| 4483 | + $trans = array( |
|
| 4484 | + '[' => '[', |
|
| 4485 | + ']' => ']', |
|
| 4486 | + '&#091;' => '[', |
|
| 4487 | + '&#093;' => ']', |
|
| 4488 | + '&0lt;' => '<', |
|
| 4489 | + '&0gt;' => '>', |
|
| 4490 | + '&0lt;' => '<', |
|
| 4491 | + '&0gt;' => '>', |
|
| 4492 | + ); |
|
| 4493 | + |
|
| 4494 | + $content = strtr( $content, $trans ); |
|
| 4495 | + |
|
| 4496 | + return $content; |
|
| 4497 | + } |
|
| 4498 | + } |
|
| 4499 | 4499 | } |
@@ -11,21 +11,21 @@ discard block |
||
| 11 | 11 | * @return mixed|void |
| 12 | 12 | */ |
| 13 | 13 | function sd_pagenow_exclude() { |
| 14 | - return apply_filters( |
|
| 15 | - 'sd_pagenow_exclude', |
|
| 16 | - array( |
|
| 17 | - 'upload.php', |
|
| 18 | - 'edit-comments.php', |
|
| 19 | - 'edit-tags.php', |
|
| 20 | - 'index.php', |
|
| 21 | - 'media-new.php', |
|
| 22 | - 'options-discussion.php', |
|
| 23 | - 'options-writing.php', |
|
| 24 | - 'edit.php', |
|
| 25 | - 'themes.php', |
|
| 26 | - 'users.php', |
|
| 27 | - ) |
|
| 28 | - ); |
|
| 14 | + return apply_filters( |
|
| 15 | + 'sd_pagenow_exclude', |
|
| 16 | + array( |
|
| 17 | + 'upload.php', |
|
| 18 | + 'edit-comments.php', |
|
| 19 | + 'edit-tags.php', |
|
| 20 | + 'index.php', |
|
| 21 | + 'media-new.php', |
|
| 22 | + 'options-discussion.php', |
|
| 23 | + 'options-writing.php', |
|
| 24 | + 'edit.php', |
|
| 25 | + 'themes.php', |
|
| 26 | + 'users.php', |
|
| 27 | + ) |
|
| 28 | + ); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * @return mixed|void |
| 38 | 38 | */ |
| 39 | 39 | function sd_widget_exclude() { |
| 40 | - return apply_filters( 'sd_widget_exclude', array() ); |
|
| 40 | + return apply_filters( 'sd_widget_exclude', array() ); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | |
@@ -50,82 +50,82 @@ discard block |
||
| 50 | 50 | * @return array |
| 51 | 51 | */ |
| 52 | 52 | function sd_get_margin_input( $type = 'mt', $overwrite = array(), $include_negatives = true ) { |
| 53 | - $options = array( |
|
| 54 | - '' => __( 'None', 'super-duper' ), |
|
| 55 | - 'auto' => __( 'auto', 'super-duper' ), |
|
| 56 | - '0' => '0', |
|
| 57 | - '1' => '1', |
|
| 58 | - '2' => '2', |
|
| 59 | - '3' => '3', |
|
| 60 | - '4' => '4', |
|
| 61 | - '5' => '5', |
|
| 62 | - '6' => '6', |
|
| 63 | - '7' => '7', |
|
| 64 | - '8' => '8', |
|
| 65 | - '9' => '9', |
|
| 66 | - '10' => '10', |
|
| 67 | - '11' => '11', |
|
| 68 | - '12' => '12', |
|
| 69 | - ); |
|
| 70 | - |
|
| 71 | - if ( $include_negatives ) { |
|
| 72 | - $options['n1'] = '-1'; |
|
| 73 | - $options['n2'] = '-2'; |
|
| 74 | - $options['n3'] = '-3'; |
|
| 75 | - $options['n4'] = '-4'; |
|
| 76 | - $options['n5'] = '-5'; |
|
| 77 | - $options['n6'] = '-6'; |
|
| 78 | - $options['n7'] = '-7'; |
|
| 79 | - $options['n8'] = '-8'; |
|
| 80 | - $options['n9'] = '-9'; |
|
| 81 | - $options['n10'] = '-10'; |
|
| 82 | - $options['n11'] = '-11'; |
|
| 83 | - $options['n12'] = '-12'; |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - $defaults = array( |
|
| 87 | - 'type' => 'select', |
|
| 88 | - 'title' => __( 'Margin top', 'super-duper' ), |
|
| 89 | - 'options' => $options, |
|
| 90 | - 'default' => '', |
|
| 91 | - 'desc_tip' => true, |
|
| 92 | - 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 93 | - ); |
|
| 94 | - |
|
| 95 | - // title |
|
| 96 | - if ( $type == 'mt' ) { |
|
| 97 | - $defaults['title'] = __( 'Margin top', 'super-duper' ); |
|
| 98 | - $defaults['icon'] = 'box-top'; |
|
| 99 | - $defaults['row'] = array( |
|
| 100 | - 'title' => __( 'Margins', 'super-duper' ), |
|
| 101 | - 'key' => 'wrapper-margins', |
|
| 102 | - 'open' => true, |
|
| 103 | - 'class' => 'text-center', |
|
| 104 | - ); |
|
| 105 | - } elseif ( $type == 'mr' ) { |
|
| 106 | - $defaults['title'] = __( 'Margin right', 'super-duper' ); |
|
| 107 | - $defaults['icon'] = 'box-right'; |
|
| 108 | - $defaults['row'] = array( |
|
| 109 | - 'key' => 'wrapper-margins', |
|
| 110 | - ); |
|
| 111 | - } elseif ( $type == 'mb' ) { |
|
| 112 | - $defaults['title'] = __( 'Margin bottom', 'super-duper' ); |
|
| 113 | - $defaults['icon'] = 'box-bottom'; |
|
| 114 | - $defaults['row'] = array( |
|
| 115 | - 'key' => 'wrapper-margins', |
|
| 116 | - ); |
|
| 117 | - } elseif ( $type == 'ml' ) { |
|
| 118 | - $defaults['title'] = __( 'Margin left', 'super-duper' ); |
|
| 119 | - $defaults['icon'] = 'box-left'; |
|
| 120 | - $defaults['row'] = array( |
|
| 121 | - 'key' => 'wrapper-margins', |
|
| 122 | - 'close' => true, |
|
| 123 | - ); |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 127 | - |
|
| 128 | - return $input; |
|
| 53 | + $options = array( |
|
| 54 | + '' => __( 'None', 'super-duper' ), |
|
| 55 | + 'auto' => __( 'auto', 'super-duper' ), |
|
| 56 | + '0' => '0', |
|
| 57 | + '1' => '1', |
|
| 58 | + '2' => '2', |
|
| 59 | + '3' => '3', |
|
| 60 | + '4' => '4', |
|
| 61 | + '5' => '5', |
|
| 62 | + '6' => '6', |
|
| 63 | + '7' => '7', |
|
| 64 | + '8' => '8', |
|
| 65 | + '9' => '9', |
|
| 66 | + '10' => '10', |
|
| 67 | + '11' => '11', |
|
| 68 | + '12' => '12', |
|
| 69 | + ); |
|
| 70 | + |
|
| 71 | + if ( $include_negatives ) { |
|
| 72 | + $options['n1'] = '-1'; |
|
| 73 | + $options['n2'] = '-2'; |
|
| 74 | + $options['n3'] = '-3'; |
|
| 75 | + $options['n4'] = '-4'; |
|
| 76 | + $options['n5'] = '-5'; |
|
| 77 | + $options['n6'] = '-6'; |
|
| 78 | + $options['n7'] = '-7'; |
|
| 79 | + $options['n8'] = '-8'; |
|
| 80 | + $options['n9'] = '-9'; |
|
| 81 | + $options['n10'] = '-10'; |
|
| 82 | + $options['n11'] = '-11'; |
|
| 83 | + $options['n12'] = '-12'; |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + $defaults = array( |
|
| 87 | + 'type' => 'select', |
|
| 88 | + 'title' => __( 'Margin top', 'super-duper' ), |
|
| 89 | + 'options' => $options, |
|
| 90 | + 'default' => '', |
|
| 91 | + 'desc_tip' => true, |
|
| 92 | + 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 93 | + ); |
|
| 94 | + |
|
| 95 | + // title |
|
| 96 | + if ( $type == 'mt' ) { |
|
| 97 | + $defaults['title'] = __( 'Margin top', 'super-duper' ); |
|
| 98 | + $defaults['icon'] = 'box-top'; |
|
| 99 | + $defaults['row'] = array( |
|
| 100 | + 'title' => __( 'Margins', 'super-duper' ), |
|
| 101 | + 'key' => 'wrapper-margins', |
|
| 102 | + 'open' => true, |
|
| 103 | + 'class' => 'text-center', |
|
| 104 | + ); |
|
| 105 | + } elseif ( $type == 'mr' ) { |
|
| 106 | + $defaults['title'] = __( 'Margin right', 'super-duper' ); |
|
| 107 | + $defaults['icon'] = 'box-right'; |
|
| 108 | + $defaults['row'] = array( |
|
| 109 | + 'key' => 'wrapper-margins', |
|
| 110 | + ); |
|
| 111 | + } elseif ( $type == 'mb' ) { |
|
| 112 | + $defaults['title'] = __( 'Margin bottom', 'super-duper' ); |
|
| 113 | + $defaults['icon'] = 'box-bottom'; |
|
| 114 | + $defaults['row'] = array( |
|
| 115 | + 'key' => 'wrapper-margins', |
|
| 116 | + ); |
|
| 117 | + } elseif ( $type == 'ml' ) { |
|
| 118 | + $defaults['title'] = __( 'Margin left', 'super-duper' ); |
|
| 119 | + $defaults['icon'] = 'box-left'; |
|
| 120 | + $defaults['row'] = array( |
|
| 121 | + 'key' => 'wrapper-margins', |
|
| 122 | + 'close' => true, |
|
| 123 | + ); |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 127 | + |
|
| 128 | + return $input; |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -137,67 +137,67 @@ discard block |
||
| 137 | 137 | * @return array |
| 138 | 138 | */ |
| 139 | 139 | function sd_get_padding_input( $type = 'pt', $overwrite = array() ) { |
| 140 | - $options = array( |
|
| 141 | - '' => __( 'None', 'super-duper' ), |
|
| 142 | - '0' => '0', |
|
| 143 | - '1' => '1', |
|
| 144 | - '2' => '2', |
|
| 145 | - '3' => '3', |
|
| 146 | - '4' => '4', |
|
| 147 | - '5' => '5', |
|
| 148 | - '6' => '6', |
|
| 149 | - '7' => '7', |
|
| 150 | - '8' => '8', |
|
| 151 | - '9' => '9', |
|
| 152 | - '10' => '10', |
|
| 153 | - '11' => '11', |
|
| 154 | - '12' => '12', |
|
| 155 | - ); |
|
| 156 | - |
|
| 157 | - $defaults = array( |
|
| 158 | - 'type' => 'select', |
|
| 159 | - 'title' => __( 'Padding top', 'super-duper' ), |
|
| 160 | - 'options' => $options, |
|
| 161 | - 'default' => '', |
|
| 162 | - 'desc_tip' => true, |
|
| 163 | - 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 164 | - ); |
|
| 165 | - |
|
| 166 | - // title |
|
| 167 | - if ( $type == 'pt' ) { |
|
| 168 | - $defaults['title'] = __( 'Padding top', 'super-duper' ); |
|
| 169 | - $defaults['icon'] = 'box-top'; |
|
| 170 | - $defaults['row'] = array( |
|
| 171 | - 'title' => __( 'Padding', 'super-duper' ), |
|
| 172 | - 'key' => 'wrapper-padding', |
|
| 173 | - 'open' => true, |
|
| 174 | - 'class' => 'text-center', |
|
| 175 | - ); |
|
| 176 | - } elseif ( $type == 'pr' ) { |
|
| 177 | - $defaults['title'] = __( 'Padding right', 'super-duper' ); |
|
| 178 | - $defaults['icon'] = 'box-right'; |
|
| 179 | - $defaults['row'] = array( |
|
| 180 | - 'key' => 'wrapper-padding', |
|
| 181 | - ); |
|
| 182 | - } elseif ( $type == 'pb' ) { |
|
| 183 | - $defaults['title'] = __( 'Padding bottom', 'super-duper' ); |
|
| 184 | - $defaults['icon'] = 'box-bottom'; |
|
| 185 | - $defaults['row'] = array( |
|
| 186 | - 'key' => 'wrapper-padding', |
|
| 187 | - ); |
|
| 188 | - } elseif ( $type == 'pl' ) { |
|
| 189 | - $defaults['title'] = __( 'Padding left', 'super-duper' ); |
|
| 190 | - $defaults['icon'] = 'box-left'; |
|
| 191 | - $defaults['row'] = array( |
|
| 192 | - 'key' => 'wrapper-padding', |
|
| 193 | - 'close' => true, |
|
| 194 | - |
|
| 195 | - ); |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 199 | - |
|
| 200 | - return $input; |
|
| 140 | + $options = array( |
|
| 141 | + '' => __( 'None', 'super-duper' ), |
|
| 142 | + '0' => '0', |
|
| 143 | + '1' => '1', |
|
| 144 | + '2' => '2', |
|
| 145 | + '3' => '3', |
|
| 146 | + '4' => '4', |
|
| 147 | + '5' => '5', |
|
| 148 | + '6' => '6', |
|
| 149 | + '7' => '7', |
|
| 150 | + '8' => '8', |
|
| 151 | + '9' => '9', |
|
| 152 | + '10' => '10', |
|
| 153 | + '11' => '11', |
|
| 154 | + '12' => '12', |
|
| 155 | + ); |
|
| 156 | + |
|
| 157 | + $defaults = array( |
|
| 158 | + 'type' => 'select', |
|
| 159 | + 'title' => __( 'Padding top', 'super-duper' ), |
|
| 160 | + 'options' => $options, |
|
| 161 | + 'default' => '', |
|
| 162 | + 'desc_tip' => true, |
|
| 163 | + 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 164 | + ); |
|
| 165 | + |
|
| 166 | + // title |
|
| 167 | + if ( $type == 'pt' ) { |
|
| 168 | + $defaults['title'] = __( 'Padding top', 'super-duper' ); |
|
| 169 | + $defaults['icon'] = 'box-top'; |
|
| 170 | + $defaults['row'] = array( |
|
| 171 | + 'title' => __( 'Padding', 'super-duper' ), |
|
| 172 | + 'key' => 'wrapper-padding', |
|
| 173 | + 'open' => true, |
|
| 174 | + 'class' => 'text-center', |
|
| 175 | + ); |
|
| 176 | + } elseif ( $type == 'pr' ) { |
|
| 177 | + $defaults['title'] = __( 'Padding right', 'super-duper' ); |
|
| 178 | + $defaults['icon'] = 'box-right'; |
|
| 179 | + $defaults['row'] = array( |
|
| 180 | + 'key' => 'wrapper-padding', |
|
| 181 | + ); |
|
| 182 | + } elseif ( $type == 'pb' ) { |
|
| 183 | + $defaults['title'] = __( 'Padding bottom', 'super-duper' ); |
|
| 184 | + $defaults['icon'] = 'box-bottom'; |
|
| 185 | + $defaults['row'] = array( |
|
| 186 | + 'key' => 'wrapper-padding', |
|
| 187 | + ); |
|
| 188 | + } elseif ( $type == 'pl' ) { |
|
| 189 | + $defaults['title'] = __( 'Padding left', 'super-duper' ); |
|
| 190 | + $defaults['icon'] = 'box-left'; |
|
| 191 | + $defaults['row'] = array( |
|
| 192 | + 'key' => 'wrapper-padding', |
|
| 193 | + 'close' => true, |
|
| 194 | + |
|
| 195 | + ); |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 199 | + |
|
| 200 | + return $input; |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -210,57 +210,57 @@ discard block |
||
| 210 | 210 | */ |
| 211 | 211 | function sd_get_border_input( $type = 'border', $overwrite = array() ) { |
| 212 | 212 | |
| 213 | - $defaults = array( |
|
| 214 | - 'type' => 'select', |
|
| 215 | - 'title' => __( 'Border' ), |
|
| 216 | - 'options' => array(), |
|
| 217 | - 'default' => '', |
|
| 218 | - 'desc_tip' => true, |
|
| 219 | - 'group' => __( 'Wrapper Styles', 'geodirectory' ), |
|
| 220 | - ); |
|
| 221 | - |
|
| 222 | - // title |
|
| 223 | - if ( $type == 'rounded' ) { |
|
| 224 | - $defaults['title'] = __( 'Border radius type', 'super-duper' ); |
|
| 225 | - $defaults['options'] = array( |
|
| 226 | - '' => __( 'Default', 'super-duper' ), |
|
| 227 | - 'rounded' => 'rounded', |
|
| 228 | - 'rounded-top' => 'rounded-top', |
|
| 229 | - 'rounded-right' => 'rounded-right', |
|
| 230 | - 'rounded-bottom' => 'rounded-bottom', |
|
| 231 | - 'rounded-left' => 'rounded-left', |
|
| 232 | - 'rounded-circle' => 'rounded-circle', |
|
| 233 | - 'rounded-pill' => 'rounded-pill', |
|
| 234 | - 'rounded-0' => 'rounded-0', |
|
| 235 | - ); |
|
| 236 | - } elseif ( $type == 'rounded_size' ) { |
|
| 237 | - $defaults['title'] = __( 'Border radius size', 'super-duper' ); |
|
| 238 | - $defaults['options'] = array( |
|
| 239 | - '' => __( 'Default', 'super-duper' ), |
|
| 240 | - 'sm' => __( 'Small', 'super-duper' ), |
|
| 241 | - 'lg' => __( 'Large', 'super-duper' ), |
|
| 242 | - ); |
|
| 243 | - } elseif ( $type == 'type' ) { |
|
| 244 | - $defaults['title'] = __( 'Border type', 'super-duper' ); |
|
| 245 | - $defaults['options'] = array( |
|
| 246 | - '' => __( 'None', 'super-duper' ), |
|
| 247 | - 'border' => __( 'Full', 'super-duper' ), |
|
| 248 | - 'border-top' => __( 'Top', 'super-duper' ), |
|
| 249 | - 'border-bottom' => __( 'Bottom', 'super-duper' ), |
|
| 250 | - 'border-left' => __( 'Left', 'super-duper' ), |
|
| 251 | - 'border-right' => __( 'Right', 'super-duper' ), |
|
| 252 | - ); |
|
| 253 | - } else { |
|
| 254 | - $defaults['title'] = __( 'Border color' ); |
|
| 255 | - $defaults['options'] = array( |
|
| 256 | - '' => __( 'Default', 'super-duper' ), |
|
| 257 | - '0' => __( 'None', 'super-duper' ), |
|
| 258 | - ) + sd_aui_colors(); |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 262 | - |
|
| 263 | - return $input; |
|
| 213 | + $defaults = array( |
|
| 214 | + 'type' => 'select', |
|
| 215 | + 'title' => __( 'Border' ), |
|
| 216 | + 'options' => array(), |
|
| 217 | + 'default' => '', |
|
| 218 | + 'desc_tip' => true, |
|
| 219 | + 'group' => __( 'Wrapper Styles', 'geodirectory' ), |
|
| 220 | + ); |
|
| 221 | + |
|
| 222 | + // title |
|
| 223 | + if ( $type == 'rounded' ) { |
|
| 224 | + $defaults['title'] = __( 'Border radius type', 'super-duper' ); |
|
| 225 | + $defaults['options'] = array( |
|
| 226 | + '' => __( 'Default', 'super-duper' ), |
|
| 227 | + 'rounded' => 'rounded', |
|
| 228 | + 'rounded-top' => 'rounded-top', |
|
| 229 | + 'rounded-right' => 'rounded-right', |
|
| 230 | + 'rounded-bottom' => 'rounded-bottom', |
|
| 231 | + 'rounded-left' => 'rounded-left', |
|
| 232 | + 'rounded-circle' => 'rounded-circle', |
|
| 233 | + 'rounded-pill' => 'rounded-pill', |
|
| 234 | + 'rounded-0' => 'rounded-0', |
|
| 235 | + ); |
|
| 236 | + } elseif ( $type == 'rounded_size' ) { |
|
| 237 | + $defaults['title'] = __( 'Border radius size', 'super-duper' ); |
|
| 238 | + $defaults['options'] = array( |
|
| 239 | + '' => __( 'Default', 'super-duper' ), |
|
| 240 | + 'sm' => __( 'Small', 'super-duper' ), |
|
| 241 | + 'lg' => __( 'Large', 'super-duper' ), |
|
| 242 | + ); |
|
| 243 | + } elseif ( $type == 'type' ) { |
|
| 244 | + $defaults['title'] = __( 'Border type', 'super-duper' ); |
|
| 245 | + $defaults['options'] = array( |
|
| 246 | + '' => __( 'None', 'super-duper' ), |
|
| 247 | + 'border' => __( 'Full', 'super-duper' ), |
|
| 248 | + 'border-top' => __( 'Top', 'super-duper' ), |
|
| 249 | + 'border-bottom' => __( 'Bottom', 'super-duper' ), |
|
| 250 | + 'border-left' => __( 'Left', 'super-duper' ), |
|
| 251 | + 'border-right' => __( 'Right', 'super-duper' ), |
|
| 252 | + ); |
|
| 253 | + } else { |
|
| 254 | + $defaults['title'] = __( 'Border color' ); |
|
| 255 | + $defaults['options'] = array( |
|
| 256 | + '' => __( 'Default', 'super-duper' ), |
|
| 257 | + '0' => __( 'None', 'super-duper' ), |
|
| 258 | + ) + sd_aui_colors(); |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 262 | + |
|
| 263 | + return $input; |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | /** |
@@ -272,25 +272,25 @@ discard block |
||
| 272 | 272 | * @return array |
| 273 | 273 | */ |
| 274 | 274 | function sd_get_shadow_input( $type = 'shadow', $overwrite = array() ) { |
| 275 | - $options = array( |
|
| 276 | - '' => __( 'None', 'super-duper' ), |
|
| 277 | - 'shadow-sm' => __( 'Small', 'super-duper' ), |
|
| 278 | - 'shadow' => __( 'Regular', 'super-duper' ), |
|
| 279 | - 'shadow-lg' => __( 'Large', 'super-duper' ), |
|
| 280 | - ); |
|
| 281 | - |
|
| 282 | - $defaults = array( |
|
| 283 | - 'type' => 'select', |
|
| 284 | - 'title' => __( 'Shadow', 'super-duper' ), |
|
| 285 | - 'options' => $options, |
|
| 286 | - 'default' => '', |
|
| 287 | - 'desc_tip' => true, |
|
| 288 | - 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 289 | - ); |
|
| 290 | - |
|
| 291 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 292 | - |
|
| 293 | - return $input; |
|
| 275 | + $options = array( |
|
| 276 | + '' => __( 'None', 'super-duper' ), |
|
| 277 | + 'shadow-sm' => __( 'Small', 'super-duper' ), |
|
| 278 | + 'shadow' => __( 'Regular', 'super-duper' ), |
|
| 279 | + 'shadow-lg' => __( 'Large', 'super-duper' ), |
|
| 280 | + ); |
|
| 281 | + |
|
| 282 | + $defaults = array( |
|
| 283 | + 'type' => 'select', |
|
| 284 | + 'title' => __( 'Shadow', 'super-duper' ), |
|
| 285 | + 'options' => $options, |
|
| 286 | + 'default' => '', |
|
| 287 | + 'desc_tip' => true, |
|
| 288 | + 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 289 | + ); |
|
| 290 | + |
|
| 291 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 292 | + |
|
| 293 | + return $input; |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | /** |
@@ -302,23 +302,23 @@ discard block |
||
| 302 | 302 | * @return array |
| 303 | 303 | */ |
| 304 | 304 | function sd_get_background_input( $type = 'bg', $overwrite = array() ) { |
| 305 | - $options = array( |
|
| 306 | - '' => __( 'None', 'super-duper' ), |
|
| 307 | - 'transparent' => __( 'Transparent', 'super-duper' ), |
|
| 308 | - ) + sd_aui_colors(); |
|
| 309 | - |
|
| 310 | - $defaults = array( |
|
| 311 | - 'type' => 'select', |
|
| 312 | - 'title' => __( 'Background color', 'super-duper' ), |
|
| 313 | - 'options' => $options, |
|
| 314 | - 'default' => '', |
|
| 315 | - 'desc_tip' => true, |
|
| 316 | - 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 317 | - ); |
|
| 318 | - |
|
| 319 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 320 | - |
|
| 321 | - return $input; |
|
| 305 | + $options = array( |
|
| 306 | + '' => __( 'None', 'super-duper' ), |
|
| 307 | + 'transparent' => __( 'Transparent', 'super-duper' ), |
|
| 308 | + ) + sd_aui_colors(); |
|
| 309 | + |
|
| 310 | + $defaults = array( |
|
| 311 | + 'type' => 'select', |
|
| 312 | + 'title' => __( 'Background color', 'super-duper' ), |
|
| 313 | + 'options' => $options, |
|
| 314 | + 'default' => '', |
|
| 315 | + 'desc_tip' => true, |
|
| 316 | + 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 317 | + ); |
|
| 318 | + |
|
| 319 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 320 | + |
|
| 321 | + return $input; |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | /** |
@@ -330,118 +330,118 @@ discard block |
||
| 330 | 330 | * @return array |
| 331 | 331 | */ |
| 332 | 332 | function sd_get_background_inputs( $type = 'bg', $overwrite = array(), $overwrite_color = array(), $overwrite_gradient = array(), $overwrite_image = array() ) { |
| 333 | - $options = array( |
|
| 334 | - '' => __( 'None', 'super-duper' ), |
|
| 335 | - 'transparent' => __( 'Transparent', 'super-duper' ), |
|
| 336 | - ) + sd_aui_colors() |
|
| 337 | - + array( |
|
| 338 | - 'custom-color' => __( 'Custom Color', 'super-duper' ), |
|
| 339 | - 'custom-gradient' => __( 'Custom Gradient', 'super-duper' ), |
|
| 340 | - ); |
|
| 341 | - |
|
| 342 | - $defaults = array( |
|
| 343 | - 'type' => 'select', |
|
| 344 | - 'title' => __( 'Background Color', 'super-duper' ), |
|
| 345 | - 'options' => $options, |
|
| 346 | - 'default' => '', |
|
| 347 | - 'desc_tip' => true, |
|
| 348 | - 'group' => __( 'Background', 'super-duper' ), |
|
| 349 | - ); |
|
| 350 | - |
|
| 351 | - if ( $overwrite !== false ) { |
|
| 352 | - $input[ $type ] = wp_parse_args( $overwrite, $defaults ); |
|
| 353 | - } |
|
| 354 | - |
|
| 355 | - if ( $overwrite_color !== false ) { |
|
| 356 | - $input[ $type . '_color' ] = wp_parse_args( |
|
| 357 | - $overwrite_color, |
|
| 358 | - array( |
|
| 359 | - 'type' => 'color', |
|
| 360 | - 'title' => __( 'Custom color', 'super-duper' ), |
|
| 361 | - 'placeholder' => '', |
|
| 362 | - 'default' => '#0073aa', |
|
| 363 | - 'desc_tip' => true, |
|
| 364 | - 'group' => __( 'Background', 'super-duper' ), |
|
| 365 | - 'element_require' => '[%' . $type . '%]=="custom-color"', |
|
| 366 | - ) |
|
| 367 | - ); |
|
| 368 | - } |
|
| 369 | - |
|
| 370 | - if ( $overwrite_gradient !== false ) { |
|
| 371 | - $input[ $type . '_gradient' ] = wp_parse_args( |
|
| 372 | - $overwrite_gradient, |
|
| 373 | - array( |
|
| 374 | - 'type' => 'gradient', |
|
| 375 | - 'title' => __( 'Custom gradient', 'super-duper' ), |
|
| 376 | - 'placeholder' => '', |
|
| 377 | - 'default' => 'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)', |
|
| 378 | - 'desc_tip' => true, |
|
| 379 | - 'group' => __( 'Background', 'super-duper' ), |
|
| 380 | - 'element_require' => '[%' . $type . '%]=="custom-gradient"', |
|
| 381 | - ) |
|
| 382 | - ); |
|
| 383 | - } |
|
| 384 | - |
|
| 385 | - if ( $overwrite_image !== false ) { |
|
| 386 | - |
|
| 387 | - $input[ $type . '_image_fixed' ] = array( |
|
| 388 | - 'type' => 'checkbox', |
|
| 389 | - 'title' => __( 'Fixed background', 'super-duper' ), |
|
| 390 | - 'default' => '', |
|
| 391 | - 'desc_tip' => true, |
|
| 392 | - 'group' => ! empty( $overwrite_image['group'] ) ? $overwrite_image['group'] : __( 'Background' ), |
|
| 393 | - 'element_require' => '( [%' . $type . '%]=="" || [%' . $type . '%]=="custom-color" || [%' . $type . '%]=="custom-gradient" || [%' . $type . '%]=="transparent" )', |
|
| 394 | - |
|
| 395 | - ); |
|
| 396 | - |
|
| 397 | - $input[ $type . '_image_use_featured' ] = array( |
|
| 398 | - 'type' => 'checkbox', |
|
| 399 | - 'title' => __( 'Use featured image', 'super-duper' ), |
|
| 400 | - 'default' => '', |
|
| 401 | - 'desc_tip' => true, |
|
| 402 | - 'group' => ! empty( $overwrite_image['group'] ) ? $overwrite_image['group'] : __( 'Background', 'super-duper' ), |
|
| 403 | - 'element_require' => '( [%' . $type . '%]=="" || [%' . $type . '%]=="custom-color" || [%' . $type . '%]=="custom-gradient" || [%' . $type . '%]=="transparent" )', |
|
| 404 | - |
|
| 405 | - ); |
|
| 406 | - |
|
| 407 | - $input[ $type . '_image' ] = wp_parse_args( |
|
| 408 | - $overwrite_image, |
|
| 409 | - array( |
|
| 410 | - 'type' => 'image', |
|
| 411 | - 'title' => __( 'Custom image', 'super-duper' ), |
|
| 412 | - 'placeholder' => '', |
|
| 413 | - 'default' => '', |
|
| 414 | - 'desc_tip' => true, |
|
| 415 | - 'group' => __( 'Background', 'super-duper' ), |
|
| 416 | - // 'element_require' => ' ![%' . $type . '_image_use_featured%] ' |
|
| 417 | - ) |
|
| 418 | - ); |
|
| 419 | - |
|
| 420 | - $input[ $type . '_image_id' ] = wp_parse_args( |
|
| 421 | - $overwrite_image, |
|
| 422 | - array( |
|
| 423 | - 'type' => 'hidden', |
|
| 424 | - 'hidden_type' => 'number', |
|
| 425 | - 'title' => '', |
|
| 426 | - 'placeholder' => '', |
|
| 427 | - 'default' => '', |
|
| 428 | - 'group' => __( 'Background', 'super-duper' ), |
|
| 429 | - ) |
|
| 430 | - ); |
|
| 431 | - |
|
| 432 | - $input[ $type . '_image_xy' ] = wp_parse_args( |
|
| 433 | - $overwrite_image, |
|
| 434 | - array( |
|
| 435 | - 'type' => 'image_xy', |
|
| 436 | - 'title' => '', |
|
| 437 | - 'placeholder' => '', |
|
| 438 | - 'default' => '', |
|
| 439 | - 'group' => __( 'Background', 'super-duper' ), |
|
| 440 | - ) |
|
| 441 | - ); |
|
| 442 | - } |
|
| 443 | - |
|
| 444 | - return $input; |
|
| 333 | + $options = array( |
|
| 334 | + '' => __( 'None', 'super-duper' ), |
|
| 335 | + 'transparent' => __( 'Transparent', 'super-duper' ), |
|
| 336 | + ) + sd_aui_colors() |
|
| 337 | + + array( |
|
| 338 | + 'custom-color' => __( 'Custom Color', 'super-duper' ), |
|
| 339 | + 'custom-gradient' => __( 'Custom Gradient', 'super-duper' ), |
|
| 340 | + ); |
|
| 341 | + |
|
| 342 | + $defaults = array( |
|
| 343 | + 'type' => 'select', |
|
| 344 | + 'title' => __( 'Background Color', 'super-duper' ), |
|
| 345 | + 'options' => $options, |
|
| 346 | + 'default' => '', |
|
| 347 | + 'desc_tip' => true, |
|
| 348 | + 'group' => __( 'Background', 'super-duper' ), |
|
| 349 | + ); |
|
| 350 | + |
|
| 351 | + if ( $overwrite !== false ) { |
|
| 352 | + $input[ $type ] = wp_parse_args( $overwrite, $defaults ); |
|
| 353 | + } |
|
| 354 | + |
|
| 355 | + if ( $overwrite_color !== false ) { |
|
| 356 | + $input[ $type . '_color' ] = wp_parse_args( |
|
| 357 | + $overwrite_color, |
|
| 358 | + array( |
|
| 359 | + 'type' => 'color', |
|
| 360 | + 'title' => __( 'Custom color', 'super-duper' ), |
|
| 361 | + 'placeholder' => '', |
|
| 362 | + 'default' => '#0073aa', |
|
| 363 | + 'desc_tip' => true, |
|
| 364 | + 'group' => __( 'Background', 'super-duper' ), |
|
| 365 | + 'element_require' => '[%' . $type . '%]=="custom-color"', |
|
| 366 | + ) |
|
| 367 | + ); |
|
| 368 | + } |
|
| 369 | + |
|
| 370 | + if ( $overwrite_gradient !== false ) { |
|
| 371 | + $input[ $type . '_gradient' ] = wp_parse_args( |
|
| 372 | + $overwrite_gradient, |
|
| 373 | + array( |
|
| 374 | + 'type' => 'gradient', |
|
| 375 | + 'title' => __( 'Custom gradient', 'super-duper' ), |
|
| 376 | + 'placeholder' => '', |
|
| 377 | + 'default' => 'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)', |
|
| 378 | + 'desc_tip' => true, |
|
| 379 | + 'group' => __( 'Background', 'super-duper' ), |
|
| 380 | + 'element_require' => '[%' . $type . '%]=="custom-gradient"', |
|
| 381 | + ) |
|
| 382 | + ); |
|
| 383 | + } |
|
| 384 | + |
|
| 385 | + if ( $overwrite_image !== false ) { |
|
| 386 | + |
|
| 387 | + $input[ $type . '_image_fixed' ] = array( |
|
| 388 | + 'type' => 'checkbox', |
|
| 389 | + 'title' => __( 'Fixed background', 'super-duper' ), |
|
| 390 | + 'default' => '', |
|
| 391 | + 'desc_tip' => true, |
|
| 392 | + 'group' => ! empty( $overwrite_image['group'] ) ? $overwrite_image['group'] : __( 'Background' ), |
|
| 393 | + 'element_require' => '( [%' . $type . '%]=="" || [%' . $type . '%]=="custom-color" || [%' . $type . '%]=="custom-gradient" || [%' . $type . '%]=="transparent" )', |
|
| 394 | + |
|
| 395 | + ); |
|
| 396 | + |
|
| 397 | + $input[ $type . '_image_use_featured' ] = array( |
|
| 398 | + 'type' => 'checkbox', |
|
| 399 | + 'title' => __( 'Use featured image', 'super-duper' ), |
|
| 400 | + 'default' => '', |
|
| 401 | + 'desc_tip' => true, |
|
| 402 | + 'group' => ! empty( $overwrite_image['group'] ) ? $overwrite_image['group'] : __( 'Background', 'super-duper' ), |
|
| 403 | + 'element_require' => '( [%' . $type . '%]=="" || [%' . $type . '%]=="custom-color" || [%' . $type . '%]=="custom-gradient" || [%' . $type . '%]=="transparent" )', |
|
| 404 | + |
|
| 405 | + ); |
|
| 406 | + |
|
| 407 | + $input[ $type . '_image' ] = wp_parse_args( |
|
| 408 | + $overwrite_image, |
|
| 409 | + array( |
|
| 410 | + 'type' => 'image', |
|
| 411 | + 'title' => __( 'Custom image', 'super-duper' ), |
|
| 412 | + 'placeholder' => '', |
|
| 413 | + 'default' => '', |
|
| 414 | + 'desc_tip' => true, |
|
| 415 | + 'group' => __( 'Background', 'super-duper' ), |
|
| 416 | + // 'element_require' => ' ![%' . $type . '_image_use_featured%] ' |
|
| 417 | + ) |
|
| 418 | + ); |
|
| 419 | + |
|
| 420 | + $input[ $type . '_image_id' ] = wp_parse_args( |
|
| 421 | + $overwrite_image, |
|
| 422 | + array( |
|
| 423 | + 'type' => 'hidden', |
|
| 424 | + 'hidden_type' => 'number', |
|
| 425 | + 'title' => '', |
|
| 426 | + 'placeholder' => '', |
|
| 427 | + 'default' => '', |
|
| 428 | + 'group' => __( 'Background', 'super-duper' ), |
|
| 429 | + ) |
|
| 430 | + ); |
|
| 431 | + |
|
| 432 | + $input[ $type . '_image_xy' ] = wp_parse_args( |
|
| 433 | + $overwrite_image, |
|
| 434 | + array( |
|
| 435 | + 'type' => 'image_xy', |
|
| 436 | + 'title' => '', |
|
| 437 | + 'placeholder' => '', |
|
| 438 | + 'default' => '', |
|
| 439 | + 'group' => __( 'Background', 'super-duper' ), |
|
| 440 | + ) |
|
| 441 | + ); |
|
| 442 | + } |
|
| 443 | + |
|
| 444 | + return $input; |
|
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | /** |
@@ -454,175 +454,175 @@ discard block |
||
| 454 | 454 | */ |
| 455 | 455 | function sd_get_shape_divider_inputs( $type = 'sd', $overwrite = array(), $overwrite_color = array(), $overwrite_gradient = array(), $overwrite_image = array() ) { |
| 456 | 456 | |
| 457 | - $options = array( |
|
| 458 | - '' => __( 'None', 'super-duper' ), |
|
| 459 | - 'mountains' => __( 'Mountains', 'super-duper' ), |
|
| 460 | - 'drops' => __( 'Drops', 'super-duper' ), |
|
| 461 | - 'clouds' => __( 'Clouds', 'super-duper' ), |
|
| 462 | - 'zigzag' => __( 'Zigzag', 'super-duper' ), |
|
| 463 | - 'pyramids' => __( 'Pyramids', 'super-duper' ), |
|
| 464 | - 'triangle' => __( 'Triangle', 'super-duper' ), |
|
| 465 | - 'triangle-asymmetrical' => __( 'Triangle Asymmetrical', 'super-duper' ), |
|
| 466 | - 'tilt' => __( 'Tilt', 'super-duper' ), |
|
| 467 | - 'opacity-tilt' => __( 'Opacity Tilt', 'super-duper' ), |
|
| 468 | - 'opacity-fan' => __( 'Opacity Fan', 'super-duper' ), |
|
| 469 | - 'curve' => __( 'Curve', 'super-duper' ), |
|
| 470 | - 'curve-asymmetrical' => __( 'Curve Asymmetrical', 'super-duper' ), |
|
| 471 | - 'waves' => __( 'Waves', 'super-duper' ), |
|
| 472 | - 'wave-brush' => __( 'Wave Brush', 'super-duper' ), |
|
| 473 | - 'waves-pattern' => __( 'Waves Pattern', 'super-duper' ), |
|
| 474 | - 'arrow' => __( 'Arrow', 'super-duper' ), |
|
| 475 | - 'split' => __( 'Split', 'super-duper' ), |
|
| 476 | - 'book' => __( 'Book', 'super-duper' ), |
|
| 477 | - ); |
|
| 478 | - |
|
| 479 | - $defaults = array( |
|
| 480 | - 'type' => 'select', |
|
| 481 | - 'title' => __( 'Type', 'super-duper' ), |
|
| 482 | - 'options' => $options, |
|
| 483 | - 'default' => '', |
|
| 484 | - 'desc_tip' => true, |
|
| 485 | - 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 486 | - ); |
|
| 487 | - |
|
| 488 | - $input[ $type ] = wp_parse_args( $overwrite, $defaults ); |
|
| 489 | - |
|
| 490 | - $input[ $type . '_notice' ] = array( |
|
| 491 | - 'type' => 'notice', |
|
| 492 | - 'desc' => __( 'Parent element must be position `relative`', 'super-duper' ), |
|
| 493 | - 'status' => 'warning', |
|
| 494 | - 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 495 | - 'element_require' => '[%' . $type . '%]!=""', |
|
| 496 | - ); |
|
| 497 | - |
|
| 498 | - $input[ $type . '_position' ] = wp_parse_args( |
|
| 499 | - $overwrite_color, |
|
| 500 | - array( |
|
| 501 | - 'type' => 'select', |
|
| 502 | - 'title' => __( 'Position', 'super-duper' ), |
|
| 503 | - 'options' => array( |
|
| 504 | - 'top' => __( 'Top', 'super-duper' ), |
|
| 505 | - 'bottom' => __( 'Bottom', 'super-duper' ), |
|
| 506 | - ), |
|
| 507 | - 'desc_tip' => true, |
|
| 508 | - 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 509 | - 'element_require' => '[%' . $type . '%]!=""', |
|
| 510 | - ) |
|
| 511 | - ); |
|
| 512 | - |
|
| 513 | - $options = array( |
|
| 514 | - '' => __( 'None', 'super-duper' ), |
|
| 515 | - 'transparent' => __( 'Transparent', 'super-duper' ), |
|
| 516 | - ) + sd_aui_colors() |
|
| 517 | - + array( |
|
| 518 | - 'custom-color' => __( 'Custom Color', 'super-duper' ), |
|
| 519 | - ); |
|
| 520 | - |
|
| 521 | - $input[ $type . '_color' ] = wp_parse_args( |
|
| 522 | - $overwrite_color, |
|
| 523 | - array( |
|
| 524 | - 'type' => 'select', |
|
| 525 | - 'title' => __( 'Color', 'super-duper' ), |
|
| 526 | - 'options' => $options, |
|
| 527 | - 'desc_tip' => true, |
|
| 528 | - 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 529 | - 'element_require' => '[%' . $type . '%]!=""', |
|
| 530 | - ) |
|
| 531 | - ); |
|
| 532 | - |
|
| 533 | - $input[ $type . '_custom_color' ] = wp_parse_args( |
|
| 534 | - $overwrite_color, |
|
| 535 | - array( |
|
| 536 | - 'type' => 'color', |
|
| 537 | - 'title' => __( 'Custom color', 'super-duper' ), |
|
| 538 | - 'placeholder' => '', |
|
| 539 | - 'default' => '#0073aa', |
|
| 540 | - 'desc_tip' => true, |
|
| 541 | - 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 542 | - 'element_require' => '[%' . $type . '_color%]=="custom-color" && [%' . $type . '%]!=""', |
|
| 543 | - ) |
|
| 544 | - ); |
|
| 545 | - |
|
| 546 | - $input[ $type . '_width' ] = wp_parse_args( |
|
| 547 | - $overwrite_gradient, |
|
| 548 | - array( |
|
| 549 | - 'type' => 'range', |
|
| 550 | - 'title' => __( 'Width', 'super-duper' ), |
|
| 551 | - 'placeholder' => '', |
|
| 552 | - 'default' => '200', |
|
| 553 | - 'desc_tip' => true, |
|
| 554 | - 'custom_attributes' => array( |
|
| 555 | - 'min' => 100, |
|
| 556 | - 'max' => 300, |
|
| 557 | - ), |
|
| 558 | - 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 559 | - 'element_require' => '[%' . $type . '%]!=""', |
|
| 560 | - ) |
|
| 561 | - ); |
|
| 562 | - |
|
| 563 | - $input[ $type . '_height' ] = array( |
|
| 564 | - 'type' => 'range', |
|
| 565 | - 'title' => __( 'Height', 'super-duper' ), |
|
| 566 | - 'default' => '100', |
|
| 567 | - 'desc_tip' => true, |
|
| 568 | - 'custom_attributes' => array( |
|
| 569 | - 'min' => 0, |
|
| 570 | - 'max' => 500, |
|
| 571 | - ), |
|
| 572 | - 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 573 | - 'element_require' => '[%' . $type . '%]!=""', |
|
| 574 | - ); |
|
| 575 | - |
|
| 576 | - $requires = array( |
|
| 577 | - 'mountains' => array( 'flip' ), |
|
| 578 | - 'drops' => array( 'flip', 'invert' ), |
|
| 579 | - 'clouds' => array( 'flip', 'invert' ), |
|
| 580 | - 'zigzag' => array(), |
|
| 581 | - 'pyramids' => array( 'flip', 'invert' ), |
|
| 582 | - 'triangle' => array( 'invert' ), |
|
| 583 | - 'triangle-asymmetrical' => array( 'flip', 'invert' ), |
|
| 584 | - 'tilt' => array( 'flip' ), |
|
| 585 | - 'opacity-tilt' => array( 'flip' ), |
|
| 586 | - 'opacity-fan' => array(), |
|
| 587 | - 'curve' => array( 'invert' ), |
|
| 588 | - 'curve-asymmetrical' => array( 'flip', 'invert' ), |
|
| 589 | - 'waves' => array( 'flip', 'invert' ), |
|
| 590 | - 'wave-brush' => array( 'flip' ), |
|
| 591 | - 'waves-pattern' => array( 'flip' ), |
|
| 592 | - 'arrow' => array( 'invert' ), |
|
| 593 | - 'split' => array( 'invert' ), |
|
| 594 | - 'book' => array( 'invert' ), |
|
| 595 | - ); |
|
| 596 | - |
|
| 597 | - $input[ $type . '_flip' ] = array( |
|
| 598 | - 'type' => 'checkbox', |
|
| 599 | - 'title' => __( 'Flip', 'super-duper' ), |
|
| 600 | - 'default' => '', |
|
| 601 | - 'desc_tip' => true, |
|
| 602 | - 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 603 | - 'element_require' => sd_get_element_require_string( $requires, 'flip', 'sd' ), |
|
| 604 | - ); |
|
| 605 | - |
|
| 606 | - $input[ $type . '_invert' ] = array( |
|
| 607 | - 'type' => 'checkbox', |
|
| 608 | - 'title' => __( 'Invert', 'super-duper' ), |
|
| 609 | - 'default' => '', |
|
| 610 | - 'desc_tip' => true, |
|
| 611 | - 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 612 | - 'element_require' => sd_get_element_require_string( $requires, 'invert', 'sd' ), |
|
| 613 | - ); |
|
| 614 | - |
|
| 615 | - $input[ $type . '_btf' ] = array( |
|
| 616 | - 'type' => 'checkbox', |
|
| 617 | - 'title' => __( 'Bring to front', 'super-duper' ), |
|
| 618 | - 'default' => '', |
|
| 619 | - 'desc_tip' => true, |
|
| 620 | - 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 621 | - 'element_require' => '[%' . $type . '%]!=""', |
|
| 622 | - |
|
| 623 | - ); |
|
| 624 | - |
|
| 625 | - return $input; |
|
| 457 | + $options = array( |
|
| 458 | + '' => __( 'None', 'super-duper' ), |
|
| 459 | + 'mountains' => __( 'Mountains', 'super-duper' ), |
|
| 460 | + 'drops' => __( 'Drops', 'super-duper' ), |
|
| 461 | + 'clouds' => __( 'Clouds', 'super-duper' ), |
|
| 462 | + 'zigzag' => __( 'Zigzag', 'super-duper' ), |
|
| 463 | + 'pyramids' => __( 'Pyramids', 'super-duper' ), |
|
| 464 | + 'triangle' => __( 'Triangle', 'super-duper' ), |
|
| 465 | + 'triangle-asymmetrical' => __( 'Triangle Asymmetrical', 'super-duper' ), |
|
| 466 | + 'tilt' => __( 'Tilt', 'super-duper' ), |
|
| 467 | + 'opacity-tilt' => __( 'Opacity Tilt', 'super-duper' ), |
|
| 468 | + 'opacity-fan' => __( 'Opacity Fan', 'super-duper' ), |
|
| 469 | + 'curve' => __( 'Curve', 'super-duper' ), |
|
| 470 | + 'curve-asymmetrical' => __( 'Curve Asymmetrical', 'super-duper' ), |
|
| 471 | + 'waves' => __( 'Waves', 'super-duper' ), |
|
| 472 | + 'wave-brush' => __( 'Wave Brush', 'super-duper' ), |
|
| 473 | + 'waves-pattern' => __( 'Waves Pattern', 'super-duper' ), |
|
| 474 | + 'arrow' => __( 'Arrow', 'super-duper' ), |
|
| 475 | + 'split' => __( 'Split', 'super-duper' ), |
|
| 476 | + 'book' => __( 'Book', 'super-duper' ), |
|
| 477 | + ); |
|
| 478 | + |
|
| 479 | + $defaults = array( |
|
| 480 | + 'type' => 'select', |
|
| 481 | + 'title' => __( 'Type', 'super-duper' ), |
|
| 482 | + 'options' => $options, |
|
| 483 | + 'default' => '', |
|
| 484 | + 'desc_tip' => true, |
|
| 485 | + 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 486 | + ); |
|
| 487 | + |
|
| 488 | + $input[ $type ] = wp_parse_args( $overwrite, $defaults ); |
|
| 489 | + |
|
| 490 | + $input[ $type . '_notice' ] = array( |
|
| 491 | + 'type' => 'notice', |
|
| 492 | + 'desc' => __( 'Parent element must be position `relative`', 'super-duper' ), |
|
| 493 | + 'status' => 'warning', |
|
| 494 | + 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 495 | + 'element_require' => '[%' . $type . '%]!=""', |
|
| 496 | + ); |
|
| 497 | + |
|
| 498 | + $input[ $type . '_position' ] = wp_parse_args( |
|
| 499 | + $overwrite_color, |
|
| 500 | + array( |
|
| 501 | + 'type' => 'select', |
|
| 502 | + 'title' => __( 'Position', 'super-duper' ), |
|
| 503 | + 'options' => array( |
|
| 504 | + 'top' => __( 'Top', 'super-duper' ), |
|
| 505 | + 'bottom' => __( 'Bottom', 'super-duper' ), |
|
| 506 | + ), |
|
| 507 | + 'desc_tip' => true, |
|
| 508 | + 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 509 | + 'element_require' => '[%' . $type . '%]!=""', |
|
| 510 | + ) |
|
| 511 | + ); |
|
| 512 | + |
|
| 513 | + $options = array( |
|
| 514 | + '' => __( 'None', 'super-duper' ), |
|
| 515 | + 'transparent' => __( 'Transparent', 'super-duper' ), |
|
| 516 | + ) + sd_aui_colors() |
|
| 517 | + + array( |
|
| 518 | + 'custom-color' => __( 'Custom Color', 'super-duper' ), |
|
| 519 | + ); |
|
| 520 | + |
|
| 521 | + $input[ $type . '_color' ] = wp_parse_args( |
|
| 522 | + $overwrite_color, |
|
| 523 | + array( |
|
| 524 | + 'type' => 'select', |
|
| 525 | + 'title' => __( 'Color', 'super-duper' ), |
|
| 526 | + 'options' => $options, |
|
| 527 | + 'desc_tip' => true, |
|
| 528 | + 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 529 | + 'element_require' => '[%' . $type . '%]!=""', |
|
| 530 | + ) |
|
| 531 | + ); |
|
| 532 | + |
|
| 533 | + $input[ $type . '_custom_color' ] = wp_parse_args( |
|
| 534 | + $overwrite_color, |
|
| 535 | + array( |
|
| 536 | + 'type' => 'color', |
|
| 537 | + 'title' => __( 'Custom color', 'super-duper' ), |
|
| 538 | + 'placeholder' => '', |
|
| 539 | + 'default' => '#0073aa', |
|
| 540 | + 'desc_tip' => true, |
|
| 541 | + 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 542 | + 'element_require' => '[%' . $type . '_color%]=="custom-color" && [%' . $type . '%]!=""', |
|
| 543 | + ) |
|
| 544 | + ); |
|
| 545 | + |
|
| 546 | + $input[ $type . '_width' ] = wp_parse_args( |
|
| 547 | + $overwrite_gradient, |
|
| 548 | + array( |
|
| 549 | + 'type' => 'range', |
|
| 550 | + 'title' => __( 'Width', 'super-duper' ), |
|
| 551 | + 'placeholder' => '', |
|
| 552 | + 'default' => '200', |
|
| 553 | + 'desc_tip' => true, |
|
| 554 | + 'custom_attributes' => array( |
|
| 555 | + 'min' => 100, |
|
| 556 | + 'max' => 300, |
|
| 557 | + ), |
|
| 558 | + 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 559 | + 'element_require' => '[%' . $type . '%]!=""', |
|
| 560 | + ) |
|
| 561 | + ); |
|
| 562 | + |
|
| 563 | + $input[ $type . '_height' ] = array( |
|
| 564 | + 'type' => 'range', |
|
| 565 | + 'title' => __( 'Height', 'super-duper' ), |
|
| 566 | + 'default' => '100', |
|
| 567 | + 'desc_tip' => true, |
|
| 568 | + 'custom_attributes' => array( |
|
| 569 | + 'min' => 0, |
|
| 570 | + 'max' => 500, |
|
| 571 | + ), |
|
| 572 | + 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 573 | + 'element_require' => '[%' . $type . '%]!=""', |
|
| 574 | + ); |
|
| 575 | + |
|
| 576 | + $requires = array( |
|
| 577 | + 'mountains' => array( 'flip' ), |
|
| 578 | + 'drops' => array( 'flip', 'invert' ), |
|
| 579 | + 'clouds' => array( 'flip', 'invert' ), |
|
| 580 | + 'zigzag' => array(), |
|
| 581 | + 'pyramids' => array( 'flip', 'invert' ), |
|
| 582 | + 'triangle' => array( 'invert' ), |
|
| 583 | + 'triangle-asymmetrical' => array( 'flip', 'invert' ), |
|
| 584 | + 'tilt' => array( 'flip' ), |
|
| 585 | + 'opacity-tilt' => array( 'flip' ), |
|
| 586 | + 'opacity-fan' => array(), |
|
| 587 | + 'curve' => array( 'invert' ), |
|
| 588 | + 'curve-asymmetrical' => array( 'flip', 'invert' ), |
|
| 589 | + 'waves' => array( 'flip', 'invert' ), |
|
| 590 | + 'wave-brush' => array( 'flip' ), |
|
| 591 | + 'waves-pattern' => array( 'flip' ), |
|
| 592 | + 'arrow' => array( 'invert' ), |
|
| 593 | + 'split' => array( 'invert' ), |
|
| 594 | + 'book' => array( 'invert' ), |
|
| 595 | + ); |
|
| 596 | + |
|
| 597 | + $input[ $type . '_flip' ] = array( |
|
| 598 | + 'type' => 'checkbox', |
|
| 599 | + 'title' => __( 'Flip', 'super-duper' ), |
|
| 600 | + 'default' => '', |
|
| 601 | + 'desc_tip' => true, |
|
| 602 | + 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 603 | + 'element_require' => sd_get_element_require_string( $requires, 'flip', 'sd' ), |
|
| 604 | + ); |
|
| 605 | + |
|
| 606 | + $input[ $type . '_invert' ] = array( |
|
| 607 | + 'type' => 'checkbox', |
|
| 608 | + 'title' => __( 'Invert', 'super-duper' ), |
|
| 609 | + 'default' => '', |
|
| 610 | + 'desc_tip' => true, |
|
| 611 | + 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 612 | + 'element_require' => sd_get_element_require_string( $requires, 'invert', 'sd' ), |
|
| 613 | + ); |
|
| 614 | + |
|
| 615 | + $input[ $type . '_btf' ] = array( |
|
| 616 | + 'type' => 'checkbox', |
|
| 617 | + 'title' => __( 'Bring to front', 'super-duper' ), |
|
| 618 | + 'default' => '', |
|
| 619 | + 'desc_tip' => true, |
|
| 620 | + 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 621 | + 'element_require' => '[%' . $type . '%]!=""', |
|
| 622 | + |
|
| 623 | + ); |
|
| 624 | + |
|
| 625 | + return $input; |
|
| 626 | 626 | } |
| 627 | 627 | |
| 628 | 628 | /** |
@@ -635,22 +635,22 @@ discard block |
||
| 635 | 635 | * @return string |
| 636 | 636 | */ |
| 637 | 637 | function sd_get_element_require_string( $args, $key, $type ) { |
| 638 | - $output = ''; |
|
| 639 | - $requires = array(); |
|
| 640 | - |
|
| 641 | - if ( ! empty( $args ) ) { |
|
| 642 | - foreach ( $args as $t => $k ) { |
|
| 643 | - if ( in_array( $key, $k ) ) { |
|
| 644 | - $requires[] = '[%' . $type . '%]=="' . $t . '"'; |
|
| 645 | - } |
|
| 646 | - } |
|
| 647 | - |
|
| 648 | - if ( ! empty( $requires ) ) { |
|
| 649 | - $output = '(' . implode( ' || ', $requires ) . ')'; |
|
| 650 | - } |
|
| 651 | - } |
|
| 652 | - |
|
| 653 | - return $output; |
|
| 638 | + $output = ''; |
|
| 639 | + $requires = array(); |
|
| 640 | + |
|
| 641 | + if ( ! empty( $args ) ) { |
|
| 642 | + foreach ( $args as $t => $k ) { |
|
| 643 | + if ( in_array( $key, $k ) ) { |
|
| 644 | + $requires[] = '[%' . $type . '%]=="' . $t . '"'; |
|
| 645 | + } |
|
| 646 | + } |
|
| 647 | + |
|
| 648 | + if ( ! empty( $requires ) ) { |
|
| 649 | + $output = '(' . implode( ' || ', $requires ) . ')'; |
|
| 650 | + } |
|
| 651 | + } |
|
| 652 | + |
|
| 653 | + return $output; |
|
| 654 | 654 | } |
| 655 | 655 | |
| 656 | 656 | /** |
@@ -662,41 +662,41 @@ discard block |
||
| 662 | 662 | * @return array |
| 663 | 663 | */ |
| 664 | 664 | function sd_get_text_color_input( $type = 'text_color', $overwrite = array(), $has_custom = false ) { |
| 665 | - $options = array( |
|
| 666 | - '' => __( 'None', 'super-duper' ), |
|
| 667 | - ) + sd_aui_colors(); |
|
| 668 | - |
|
| 669 | - if ( $has_custom ) { |
|
| 670 | - $options['custom'] = __( 'Custom color', 'super-duper' ); |
|
| 671 | - } |
|
| 672 | - |
|
| 673 | - $defaults = array( |
|
| 674 | - 'type' => 'select', |
|
| 675 | - 'title' => __( 'Text color', 'super-duper' ), |
|
| 676 | - 'options' => $options, |
|
| 677 | - 'default' => '', |
|
| 678 | - 'desc_tip' => true, |
|
| 679 | - 'group' => __( 'Typography', 'super-duper' ), |
|
| 680 | - ); |
|
| 681 | - |
|
| 682 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 683 | - |
|
| 684 | - return $input; |
|
| 665 | + $options = array( |
|
| 666 | + '' => __( 'None', 'super-duper' ), |
|
| 667 | + ) + sd_aui_colors(); |
|
| 668 | + |
|
| 669 | + if ( $has_custom ) { |
|
| 670 | + $options['custom'] = __( 'Custom color', 'super-duper' ); |
|
| 671 | + } |
|
| 672 | + |
|
| 673 | + $defaults = array( |
|
| 674 | + 'type' => 'select', |
|
| 675 | + 'title' => __( 'Text color', 'super-duper' ), |
|
| 676 | + 'options' => $options, |
|
| 677 | + 'default' => '', |
|
| 678 | + 'desc_tip' => true, |
|
| 679 | + 'group' => __( 'Typography', 'super-duper' ), |
|
| 680 | + ); |
|
| 681 | + |
|
| 682 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 683 | + |
|
| 684 | + return $input; |
|
| 685 | 685 | } |
| 686 | 686 | |
| 687 | 687 | function sd_get_text_color_input_group( $type = 'text_color', $overwrite = array(), $overwrite_custom = array() ) { |
| 688 | - $inputs = array(); |
|
| 688 | + $inputs = array(); |
|
| 689 | 689 | |
| 690 | - if ( $overwrite !== false ) { |
|
| 691 | - $inputs[ $type ] = sd_get_text_color_input( $type, $overwrite, true ); |
|
| 692 | - } |
|
| 690 | + if ( $overwrite !== false ) { |
|
| 691 | + $inputs[ $type ] = sd_get_text_color_input( $type, $overwrite, true ); |
|
| 692 | + } |
|
| 693 | 693 | |
| 694 | - if ( $overwrite_custom !== false ) { |
|
| 695 | - $custom = $type . '_custom'; |
|
| 696 | - $inputs[ $custom ] = sd_get_custom_color_input( $custom, $overwrite_custom, $type ); |
|
| 697 | - } |
|
| 694 | + if ( $overwrite_custom !== false ) { |
|
| 695 | + $custom = $type . '_custom'; |
|
| 696 | + $inputs[ $custom ] = sd_get_custom_color_input( $custom, $overwrite_custom, $type ); |
|
| 697 | + } |
|
| 698 | 698 | |
| 699 | - return $inputs; |
|
| 699 | + return $inputs; |
|
| 700 | 700 | } |
| 701 | 701 | |
| 702 | 702 | /** |
@@ -709,22 +709,22 @@ discard block |
||
| 709 | 709 | */ |
| 710 | 710 | function sd_get_custom_color_input( $type = 'color_custom', $overwrite = array(), $parent_type = '' ) { |
| 711 | 711 | |
| 712 | - $defaults = array( |
|
| 713 | - 'type' => 'color', |
|
| 714 | - 'title' => __( 'Custom color', 'super-duper' ), |
|
| 715 | - 'default' => '', |
|
| 716 | - 'placeholder' => '', |
|
| 717 | - 'desc_tip' => true, |
|
| 718 | - 'group' => __( 'Typography', 'super-duper' ), |
|
| 719 | - ); |
|
| 712 | + $defaults = array( |
|
| 713 | + 'type' => 'color', |
|
| 714 | + 'title' => __( 'Custom color', 'super-duper' ), |
|
| 715 | + 'default' => '', |
|
| 716 | + 'placeholder' => '', |
|
| 717 | + 'desc_tip' => true, |
|
| 718 | + 'group' => __( 'Typography', 'super-duper' ), |
|
| 719 | + ); |
|
| 720 | 720 | |
| 721 | - if ( $parent_type ) { |
|
| 722 | - $defaults['element_require'] = '[%' . $parent_type . '%]=="custom"'; |
|
| 723 | - } |
|
| 721 | + if ( $parent_type ) { |
|
| 722 | + $defaults['element_require'] = '[%' . $parent_type . '%]=="custom"'; |
|
| 723 | + } |
|
| 724 | 724 | |
| 725 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 725 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 726 | 726 | |
| 727 | - return $input; |
|
| 727 | + return $input; |
|
| 728 | 728 | } |
| 729 | 729 | |
| 730 | 730 | /** |
@@ -737,43 +737,43 @@ discard block |
||
| 737 | 737 | */ |
| 738 | 738 | function sd_get_col_input( $type = 'col', $overwrite = array() ) { |
| 739 | 739 | |
| 740 | - $device_size = ''; |
|
| 741 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 742 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 743 | - $device_size = '-md'; |
|
| 744 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 745 | - $device_size = '-lg'; |
|
| 746 | - } |
|
| 747 | - } |
|
| 748 | - $options = array( |
|
| 749 | - '' => __( 'auto', 'super-duper' ), |
|
| 750 | - '1' => '1/12', |
|
| 751 | - '2' => '2/12', |
|
| 752 | - '3' => '3/12', |
|
| 753 | - '4' => '4/12', |
|
| 754 | - '5' => '5/12', |
|
| 755 | - '6' => '6/12', |
|
| 756 | - '7' => '7/12', |
|
| 757 | - '8' => '8/12', |
|
| 758 | - '9' => '9/12', |
|
| 759 | - '10' => '10/12', |
|
| 760 | - '11' => '11/12', |
|
| 761 | - '12' => '12/12', |
|
| 762 | - ); |
|
| 763 | - |
|
| 764 | - $defaults = array( |
|
| 765 | - 'type' => 'select', |
|
| 766 | - 'title' => __( 'Column width', 'super-duper' ), |
|
| 767 | - 'options' => $options, |
|
| 768 | - 'default' => '', |
|
| 769 | - 'desc_tip' => true, |
|
| 770 | - 'group' => __( 'Container', 'super-duper' ), |
|
| 771 | - 'element_require' => '[%container%]=="col"', |
|
| 772 | - ); |
|
| 773 | - |
|
| 774 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 775 | - |
|
| 776 | - return $input; |
|
| 740 | + $device_size = ''; |
|
| 741 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 742 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 743 | + $device_size = '-md'; |
|
| 744 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 745 | + $device_size = '-lg'; |
|
| 746 | + } |
|
| 747 | + } |
|
| 748 | + $options = array( |
|
| 749 | + '' => __( 'auto', 'super-duper' ), |
|
| 750 | + '1' => '1/12', |
|
| 751 | + '2' => '2/12', |
|
| 752 | + '3' => '3/12', |
|
| 753 | + '4' => '4/12', |
|
| 754 | + '5' => '5/12', |
|
| 755 | + '6' => '6/12', |
|
| 756 | + '7' => '7/12', |
|
| 757 | + '8' => '8/12', |
|
| 758 | + '9' => '9/12', |
|
| 759 | + '10' => '10/12', |
|
| 760 | + '11' => '11/12', |
|
| 761 | + '12' => '12/12', |
|
| 762 | + ); |
|
| 763 | + |
|
| 764 | + $defaults = array( |
|
| 765 | + 'type' => 'select', |
|
| 766 | + 'title' => __( 'Column width', 'super-duper' ), |
|
| 767 | + 'options' => $options, |
|
| 768 | + 'default' => '', |
|
| 769 | + 'desc_tip' => true, |
|
| 770 | + 'group' => __( 'Container', 'super-duper' ), |
|
| 771 | + 'element_require' => '[%container%]=="col"', |
|
| 772 | + ); |
|
| 773 | + |
|
| 774 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 775 | + |
|
| 776 | + return $input; |
|
| 777 | 777 | } |
| 778 | 778 | |
| 779 | 779 | /** |
@@ -786,37 +786,37 @@ discard block |
||
| 786 | 786 | */ |
| 787 | 787 | function sd_get_row_cols_input( $type = 'row_cols', $overwrite = array() ) { |
| 788 | 788 | |
| 789 | - $device_size = ''; |
|
| 790 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 791 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 792 | - $device_size = '-md'; |
|
| 793 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 794 | - $device_size = '-lg'; |
|
| 795 | - } |
|
| 796 | - } |
|
| 797 | - $options = array( |
|
| 798 | - '' => __( 'auto', 'super-duper' ), |
|
| 799 | - '1' => '1', |
|
| 800 | - '2' => '2', |
|
| 801 | - '3' => '3', |
|
| 802 | - '4' => '4', |
|
| 803 | - '5' => '5', |
|
| 804 | - '6' => '6', |
|
| 805 | - ); |
|
| 806 | - |
|
| 807 | - $defaults = array( |
|
| 808 | - 'type' => 'select', |
|
| 809 | - 'title' => __( 'Row columns', 'super-duper' ), |
|
| 810 | - 'options' => $options, |
|
| 811 | - 'default' => '', |
|
| 812 | - 'desc_tip' => true, |
|
| 813 | - 'group' => __( 'Container', 'super-duper' ), |
|
| 814 | - 'element_require' => '[%container%]=="row"', |
|
| 815 | - ); |
|
| 816 | - |
|
| 817 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 818 | - |
|
| 819 | - return $input; |
|
| 789 | + $device_size = ''; |
|
| 790 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 791 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 792 | + $device_size = '-md'; |
|
| 793 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 794 | + $device_size = '-lg'; |
|
| 795 | + } |
|
| 796 | + } |
|
| 797 | + $options = array( |
|
| 798 | + '' => __( 'auto', 'super-duper' ), |
|
| 799 | + '1' => '1', |
|
| 800 | + '2' => '2', |
|
| 801 | + '3' => '3', |
|
| 802 | + '4' => '4', |
|
| 803 | + '5' => '5', |
|
| 804 | + '6' => '6', |
|
| 805 | + ); |
|
| 806 | + |
|
| 807 | + $defaults = array( |
|
| 808 | + 'type' => 'select', |
|
| 809 | + 'title' => __( 'Row columns', 'super-duper' ), |
|
| 810 | + 'options' => $options, |
|
| 811 | + 'default' => '', |
|
| 812 | + 'desc_tip' => true, |
|
| 813 | + 'group' => __( 'Container', 'super-duper' ), |
|
| 814 | + 'element_require' => '[%container%]=="row"', |
|
| 815 | + ); |
|
| 816 | + |
|
| 817 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 818 | + |
|
| 819 | + return $input; |
|
| 820 | 820 | } |
| 821 | 821 | |
| 822 | 822 | /** |
@@ -829,33 +829,33 @@ discard block |
||
| 829 | 829 | */ |
| 830 | 830 | function sd_get_text_align_input( $type = 'text_align', $overwrite = array() ) { |
| 831 | 831 | |
| 832 | - $device_size = ''; |
|
| 833 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 834 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 835 | - $device_size = '-md'; |
|
| 836 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 837 | - $device_size = '-lg'; |
|
| 838 | - } |
|
| 839 | - } |
|
| 840 | - $options = array( |
|
| 841 | - '' => __( 'Default', 'super-duper' ), |
|
| 842 | - 'text' . $device_size . '-left' => __( 'Left', 'super-duper' ), |
|
| 843 | - 'text' . $device_size . '-right' => __( 'Right', 'super-duper' ), |
|
| 844 | - 'text' . $device_size . '-center' => __( 'Center', 'super-duper' ), |
|
| 845 | - ); |
|
| 846 | - |
|
| 847 | - $defaults = array( |
|
| 848 | - 'type' => 'select', |
|
| 849 | - 'title' => __( 'Text align', 'super-duper' ), |
|
| 850 | - 'options' => $options, |
|
| 851 | - 'default' => '', |
|
| 852 | - 'desc_tip' => true, |
|
| 853 | - 'group' => __( 'Typography', 'super-duper' ), |
|
| 854 | - ); |
|
| 855 | - |
|
| 856 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 857 | - |
|
| 858 | - return $input; |
|
| 832 | + $device_size = ''; |
|
| 833 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 834 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 835 | + $device_size = '-md'; |
|
| 836 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 837 | + $device_size = '-lg'; |
|
| 838 | + } |
|
| 839 | + } |
|
| 840 | + $options = array( |
|
| 841 | + '' => __( 'Default', 'super-duper' ), |
|
| 842 | + 'text' . $device_size . '-left' => __( 'Left', 'super-duper' ), |
|
| 843 | + 'text' . $device_size . '-right' => __( 'Right', 'super-duper' ), |
|
| 844 | + 'text' . $device_size . '-center' => __( 'Center', 'super-duper' ), |
|
| 845 | + ); |
|
| 846 | + |
|
| 847 | + $defaults = array( |
|
| 848 | + 'type' => 'select', |
|
| 849 | + 'title' => __( 'Text align', 'super-duper' ), |
|
| 850 | + 'options' => $options, |
|
| 851 | + 'default' => '', |
|
| 852 | + 'desc_tip' => true, |
|
| 853 | + 'group' => __( 'Typography', 'super-duper' ), |
|
| 854 | + ); |
|
| 855 | + |
|
| 856 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 857 | + |
|
| 858 | + return $input; |
|
| 859 | 859 | } |
| 860 | 860 | |
| 861 | 861 | /** |
@@ -868,39 +868,39 @@ discard block |
||
| 868 | 868 | */ |
| 869 | 869 | function sd_get_display_input( $type = 'display', $overwrite = array() ) { |
| 870 | 870 | |
| 871 | - $device_size = ''; |
|
| 872 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 873 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 874 | - $device_size = '-md'; |
|
| 875 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 876 | - $device_size = '-lg'; |
|
| 877 | - } |
|
| 878 | - } |
|
| 879 | - $options = array( |
|
| 880 | - '' => __( 'Default', 'super-duper' ), |
|
| 881 | - 'd' . $device_size . '-none' => 'none', |
|
| 882 | - 'd' . $device_size . '-inline' => 'inline', |
|
| 883 | - 'd' . $device_size . '-inline-block' => 'inline-block', |
|
| 884 | - 'd' . $device_size . '-block' => 'block', |
|
| 885 | - 'd' . $device_size . '-table' => 'table', |
|
| 886 | - 'd' . $device_size . '-table-cell' => 'table-cell', |
|
| 887 | - 'd' . $device_size . '-table-row' => 'table-row', |
|
| 888 | - 'd' . $device_size . '-flex' => 'flex', |
|
| 889 | - 'd' . $device_size . '-inline-flex' => 'inline-flex', |
|
| 890 | - ); |
|
| 891 | - |
|
| 892 | - $defaults = array( |
|
| 893 | - 'type' => 'select', |
|
| 894 | - 'title' => __( 'Display', 'super-duper' ), |
|
| 895 | - 'options' => $options, |
|
| 896 | - 'default' => '', |
|
| 897 | - 'desc_tip' => true, |
|
| 898 | - 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 899 | - ); |
|
| 900 | - |
|
| 901 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 902 | - |
|
| 903 | - return $input; |
|
| 871 | + $device_size = ''; |
|
| 872 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 873 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 874 | + $device_size = '-md'; |
|
| 875 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 876 | + $device_size = '-lg'; |
|
| 877 | + } |
|
| 878 | + } |
|
| 879 | + $options = array( |
|
| 880 | + '' => __( 'Default', 'super-duper' ), |
|
| 881 | + 'd' . $device_size . '-none' => 'none', |
|
| 882 | + 'd' . $device_size . '-inline' => 'inline', |
|
| 883 | + 'd' . $device_size . '-inline-block' => 'inline-block', |
|
| 884 | + 'd' . $device_size . '-block' => 'block', |
|
| 885 | + 'd' . $device_size . '-table' => 'table', |
|
| 886 | + 'd' . $device_size . '-table-cell' => 'table-cell', |
|
| 887 | + 'd' . $device_size . '-table-row' => 'table-row', |
|
| 888 | + 'd' . $device_size . '-flex' => 'flex', |
|
| 889 | + 'd' . $device_size . '-inline-flex' => 'inline-flex', |
|
| 890 | + ); |
|
| 891 | + |
|
| 892 | + $defaults = array( |
|
| 893 | + 'type' => 'select', |
|
| 894 | + 'title' => __( 'Display', 'super-duper' ), |
|
| 895 | + 'options' => $options, |
|
| 896 | + 'default' => '', |
|
| 897 | + 'desc_tip' => true, |
|
| 898 | + 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 899 | + ); |
|
| 900 | + |
|
| 901 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 902 | + |
|
| 903 | + return $input; |
|
| 904 | 904 | } |
| 905 | 905 | |
| 906 | 906 | /** |
@@ -913,17 +913,17 @@ discard block |
||
| 913 | 913 | */ |
| 914 | 914 | function sd_get_text_justify_input( $type = 'text_justify', $overwrite = array() ) { |
| 915 | 915 | |
| 916 | - $defaults = array( |
|
| 917 | - 'type' => 'checkbox', |
|
| 918 | - 'title' => __( 'Text justify', 'super-duper' ), |
|
| 919 | - 'default' => '', |
|
| 920 | - 'desc_tip' => true, |
|
| 921 | - 'group' => __( 'Typography', 'super-duper' ), |
|
| 922 | - ); |
|
| 916 | + $defaults = array( |
|
| 917 | + 'type' => 'checkbox', |
|
| 918 | + 'title' => __( 'Text justify', 'super-duper' ), |
|
| 919 | + 'default' => '', |
|
| 920 | + 'desc_tip' => true, |
|
| 921 | + 'group' => __( 'Typography', 'super-duper' ), |
|
| 922 | + ); |
|
| 923 | 923 | |
| 924 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 924 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 925 | 925 | |
| 926 | - return $input; |
|
| 926 | + return $input; |
|
| 927 | 927 | } |
| 928 | 928 | |
| 929 | 929 | /** |
@@ -936,50 +936,50 @@ discard block |
||
| 936 | 936 | * @return array |
| 937 | 937 | */ |
| 938 | 938 | function sd_aui_colors( $include_branding = false, $include_outlines = false, $outline_button_only_text = false ) { |
| 939 | - $theme_colors = array(); |
|
| 940 | - |
|
| 941 | - $theme_colors['primary'] = __( 'Primary', 'super-duper' ); |
|
| 942 | - $theme_colors['secondary'] = __( 'Secondary', 'super-duper' ); |
|
| 943 | - $theme_colors['success'] = __( 'Success', 'super-duper' ); |
|
| 944 | - $theme_colors['danger'] = __( 'Danger', 'super-duper' ); |
|
| 945 | - $theme_colors['warning'] = __( 'Warning', 'super-duper' ); |
|
| 946 | - $theme_colors['info'] = __( 'Info', 'super-duper' ); |
|
| 947 | - $theme_colors['light'] = __( 'Light', 'super-duper' ); |
|
| 948 | - $theme_colors['dark'] = __( 'Dark', 'super-duper' ); |
|
| 949 | - $theme_colors['white'] = __( 'White', 'super-duper' ); |
|
| 950 | - $theme_colors['purple'] = __( 'Purple', 'super-duper' ); |
|
| 951 | - $theme_colors['salmon'] = __( 'Salmon', 'super-duper' ); |
|
| 952 | - $theme_colors['cyan'] = __( 'Cyan', 'super-duper' ); |
|
| 953 | - $theme_colors['gray'] = __( 'Gray', 'super-duper' ); |
|
| 954 | - $theme_colors['gray-dark'] = __( 'Gray dark', 'super-duper' ); |
|
| 955 | - $theme_colors['indigo'] = __( 'Indigo', 'super-duper' ); |
|
| 956 | - $theme_colors['orange'] = __( 'Orange', 'super-duper' ); |
|
| 957 | - |
|
| 958 | - if ( $include_outlines ) { |
|
| 959 | - $button_only = $outline_button_only_text ? ' ' . __( '(button only)', 'super-duper' ) : ''; |
|
| 960 | - $theme_colors['outline-primary'] = __( 'Primary outline', 'super-duper' ) . $button_only; |
|
| 961 | - $theme_colors['outline-secondary'] = __( 'Secondary outline', 'super-duper' ) . $button_only; |
|
| 962 | - $theme_colors['outline-success'] = __( 'Success outline', 'super-duper' ) . $button_only; |
|
| 963 | - $theme_colors['outline-danger'] = __( 'Danger outline', 'super-duper' ) . $button_only; |
|
| 964 | - $theme_colors['outline-warning'] = __( 'Warning outline', 'super-duper' ) . $button_only; |
|
| 965 | - $theme_colors['outline-info'] = __( 'Info outline', 'super-duper' ) . $button_only; |
|
| 966 | - $theme_colors['outline-light'] = __( 'Light outline', 'super-duper' ) . $button_only; |
|
| 967 | - $theme_colors['outline-dark'] = __( 'Dark outline', 'super-duper' ) . $button_only; |
|
| 968 | - $theme_colors['outline-white'] = __( 'White outline', 'super-duper' ) . $button_only; |
|
| 969 | - $theme_colors['outline-purple'] = __( 'Purple outline', 'super-duper' ) . $button_only; |
|
| 970 | - $theme_colors['outline-salmon'] = __( 'Salmon outline', 'super-duper' ) . $button_only; |
|
| 971 | - $theme_colors['outline-cyan'] = __( 'Cyan outline', 'super-duper' ) . $button_only; |
|
| 972 | - $theme_colors['outline-gray'] = __( 'Gray outline', 'super-duper' ) . $button_only; |
|
| 973 | - $theme_colors['outline-gray-dark'] = __( 'Gray dark outline', 'super-duper' ) . $button_only; |
|
| 974 | - $theme_colors['outline-indigo'] = __( 'Indigo outline', 'super-duper' ) . $button_only; |
|
| 975 | - $theme_colors['outline-orange'] = __( 'Orange outline', 'super-duper' ) . $button_only; |
|
| 976 | - } |
|
| 977 | - |
|
| 978 | - if ( $include_branding ) { |
|
| 979 | - $theme_colors = $theme_colors + sd_aui_branding_colors(); |
|
| 980 | - } |
|
| 981 | - |
|
| 982 | - return apply_filters( 'sd_aui_colors', $theme_colors, $include_outlines, $include_branding ); |
|
| 939 | + $theme_colors = array(); |
|
| 940 | + |
|
| 941 | + $theme_colors['primary'] = __( 'Primary', 'super-duper' ); |
|
| 942 | + $theme_colors['secondary'] = __( 'Secondary', 'super-duper' ); |
|
| 943 | + $theme_colors['success'] = __( 'Success', 'super-duper' ); |
|
| 944 | + $theme_colors['danger'] = __( 'Danger', 'super-duper' ); |
|
| 945 | + $theme_colors['warning'] = __( 'Warning', 'super-duper' ); |
|
| 946 | + $theme_colors['info'] = __( 'Info', 'super-duper' ); |
|
| 947 | + $theme_colors['light'] = __( 'Light', 'super-duper' ); |
|
| 948 | + $theme_colors['dark'] = __( 'Dark', 'super-duper' ); |
|
| 949 | + $theme_colors['white'] = __( 'White', 'super-duper' ); |
|
| 950 | + $theme_colors['purple'] = __( 'Purple', 'super-duper' ); |
|
| 951 | + $theme_colors['salmon'] = __( 'Salmon', 'super-duper' ); |
|
| 952 | + $theme_colors['cyan'] = __( 'Cyan', 'super-duper' ); |
|
| 953 | + $theme_colors['gray'] = __( 'Gray', 'super-duper' ); |
|
| 954 | + $theme_colors['gray-dark'] = __( 'Gray dark', 'super-duper' ); |
|
| 955 | + $theme_colors['indigo'] = __( 'Indigo', 'super-duper' ); |
|
| 956 | + $theme_colors['orange'] = __( 'Orange', 'super-duper' ); |
|
| 957 | + |
|
| 958 | + if ( $include_outlines ) { |
|
| 959 | + $button_only = $outline_button_only_text ? ' ' . __( '(button only)', 'super-duper' ) : ''; |
|
| 960 | + $theme_colors['outline-primary'] = __( 'Primary outline', 'super-duper' ) . $button_only; |
|
| 961 | + $theme_colors['outline-secondary'] = __( 'Secondary outline', 'super-duper' ) . $button_only; |
|
| 962 | + $theme_colors['outline-success'] = __( 'Success outline', 'super-duper' ) . $button_only; |
|
| 963 | + $theme_colors['outline-danger'] = __( 'Danger outline', 'super-duper' ) . $button_only; |
|
| 964 | + $theme_colors['outline-warning'] = __( 'Warning outline', 'super-duper' ) . $button_only; |
|
| 965 | + $theme_colors['outline-info'] = __( 'Info outline', 'super-duper' ) . $button_only; |
|
| 966 | + $theme_colors['outline-light'] = __( 'Light outline', 'super-duper' ) . $button_only; |
|
| 967 | + $theme_colors['outline-dark'] = __( 'Dark outline', 'super-duper' ) . $button_only; |
|
| 968 | + $theme_colors['outline-white'] = __( 'White outline', 'super-duper' ) . $button_only; |
|
| 969 | + $theme_colors['outline-purple'] = __( 'Purple outline', 'super-duper' ) . $button_only; |
|
| 970 | + $theme_colors['outline-salmon'] = __( 'Salmon outline', 'super-duper' ) . $button_only; |
|
| 971 | + $theme_colors['outline-cyan'] = __( 'Cyan outline', 'super-duper' ) . $button_only; |
|
| 972 | + $theme_colors['outline-gray'] = __( 'Gray outline', 'super-duper' ) . $button_only; |
|
| 973 | + $theme_colors['outline-gray-dark'] = __( 'Gray dark outline', 'super-duper' ) . $button_only; |
|
| 974 | + $theme_colors['outline-indigo'] = __( 'Indigo outline', 'super-duper' ) . $button_only; |
|
| 975 | + $theme_colors['outline-orange'] = __( 'Orange outline', 'super-duper' ) . $button_only; |
|
| 976 | + } |
|
| 977 | + |
|
| 978 | + if ( $include_branding ) { |
|
| 979 | + $theme_colors = $theme_colors + sd_aui_branding_colors(); |
|
| 980 | + } |
|
| 981 | + |
|
| 982 | + return apply_filters( 'sd_aui_colors', $theme_colors, $include_outlines, $include_branding ); |
|
| 983 | 983 | } |
| 984 | 984 | |
| 985 | 985 | /** |
@@ -988,19 +988,19 @@ discard block |
||
| 988 | 988 | * @return array |
| 989 | 989 | */ |
| 990 | 990 | function sd_aui_branding_colors() { |
| 991 | - return array( |
|
| 992 | - 'facebook' => __( 'Facebook', 'super-duper' ), |
|
| 993 | - 'twitter' => __( 'Twitter', 'super-duper' ), |
|
| 994 | - 'instagram' => __( 'Instagram', 'super-duper' ), |
|
| 995 | - 'linkedin' => __( 'Linkedin', 'super-duper' ), |
|
| 996 | - 'flickr' => __( 'Flickr', 'super-duper' ), |
|
| 997 | - 'github' => __( 'GitHub', 'super-duper' ), |
|
| 998 | - 'youtube' => __( 'YouTube', 'super-duper' ), |
|
| 999 | - 'wordpress' => __( 'WordPress', 'super-duper' ), |
|
| 1000 | - 'google' => __( 'Google', 'super-duper' ), |
|
| 1001 | - 'yahoo' => __( 'Yahoo', 'super-duper' ), |
|
| 1002 | - 'vkontakte' => __( 'Vkontakte', 'super-duper' ), |
|
| 1003 | - ); |
|
| 991 | + return array( |
|
| 992 | + 'facebook' => __( 'Facebook', 'super-duper' ), |
|
| 993 | + 'twitter' => __( 'Twitter', 'super-duper' ), |
|
| 994 | + 'instagram' => __( 'Instagram', 'super-duper' ), |
|
| 995 | + 'linkedin' => __( 'Linkedin', 'super-duper' ), |
|
| 996 | + 'flickr' => __( 'Flickr', 'super-duper' ), |
|
| 997 | + 'github' => __( 'GitHub', 'super-duper' ), |
|
| 998 | + 'youtube' => __( 'YouTube', 'super-duper' ), |
|
| 999 | + 'wordpress' => __( 'WordPress', 'super-duper' ), |
|
| 1000 | + 'google' => __( 'Google', 'super-duper' ), |
|
| 1001 | + 'yahoo' => __( 'Yahoo', 'super-duper' ), |
|
| 1002 | + 'vkontakte' => __( 'Vkontakte', 'super-duper' ), |
|
| 1003 | + ); |
|
| 1004 | 1004 | } |
| 1005 | 1005 | |
| 1006 | 1006 | |
@@ -1014,36 +1014,36 @@ discard block |
||
| 1014 | 1014 | */ |
| 1015 | 1015 | function sd_get_container_class_input( $type = 'container', $overwrite = array() ) { |
| 1016 | 1016 | |
| 1017 | - $options = array( |
|
| 1018 | - 'container' => __( 'container (default)', 'super-duper' ), |
|
| 1019 | - 'container-sm' => 'container-sm', |
|
| 1020 | - 'container-md' => 'container-md', |
|
| 1021 | - 'container-lg' => 'container-lg', |
|
| 1022 | - 'container-xl' => 'container-xl', |
|
| 1023 | - 'container-xxl' => 'container-xxl', |
|
| 1024 | - 'container-fluid' => 'container-fluid', |
|
| 1025 | - 'row' => 'row', |
|
| 1026 | - 'col' => 'col', |
|
| 1027 | - 'card' => 'card', |
|
| 1028 | - 'card-header' => 'card-header', |
|
| 1029 | - 'card-body' => 'card-body', |
|
| 1030 | - 'card-footer' => 'card-footer', |
|
| 1031 | - 'list-group' => 'list-group', |
|
| 1032 | - 'list-group-item' => 'list-group-item', |
|
| 1033 | - ); |
|
| 1034 | - |
|
| 1035 | - $defaults = array( |
|
| 1036 | - 'type' => 'select', |
|
| 1037 | - 'title' => __( 'Type', 'super-duper' ), |
|
| 1038 | - 'options' => $options, |
|
| 1039 | - 'default' => '', |
|
| 1040 | - 'desc_tip' => true, |
|
| 1041 | - 'group' => __( 'Container', 'super-duper' ), |
|
| 1042 | - ); |
|
| 1043 | - |
|
| 1044 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1045 | - |
|
| 1046 | - return $input; |
|
| 1017 | + $options = array( |
|
| 1018 | + 'container' => __( 'container (default)', 'super-duper' ), |
|
| 1019 | + 'container-sm' => 'container-sm', |
|
| 1020 | + 'container-md' => 'container-md', |
|
| 1021 | + 'container-lg' => 'container-lg', |
|
| 1022 | + 'container-xl' => 'container-xl', |
|
| 1023 | + 'container-xxl' => 'container-xxl', |
|
| 1024 | + 'container-fluid' => 'container-fluid', |
|
| 1025 | + 'row' => 'row', |
|
| 1026 | + 'col' => 'col', |
|
| 1027 | + 'card' => 'card', |
|
| 1028 | + 'card-header' => 'card-header', |
|
| 1029 | + 'card-body' => 'card-body', |
|
| 1030 | + 'card-footer' => 'card-footer', |
|
| 1031 | + 'list-group' => 'list-group', |
|
| 1032 | + 'list-group-item' => 'list-group-item', |
|
| 1033 | + ); |
|
| 1034 | + |
|
| 1035 | + $defaults = array( |
|
| 1036 | + 'type' => 'select', |
|
| 1037 | + 'title' => __( 'Type', 'super-duper' ), |
|
| 1038 | + 'options' => $options, |
|
| 1039 | + 'default' => '', |
|
| 1040 | + 'desc_tip' => true, |
|
| 1041 | + 'group' => __( 'Container', 'super-duper' ), |
|
| 1042 | + ); |
|
| 1043 | + |
|
| 1044 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1045 | + |
|
| 1046 | + return $input; |
|
| 1047 | 1047 | } |
| 1048 | 1048 | |
| 1049 | 1049 | /** |
@@ -1056,30 +1056,30 @@ discard block |
||
| 1056 | 1056 | */ |
| 1057 | 1057 | function sd_get_position_class_input( $type = 'position', $overwrite = array() ) { |
| 1058 | 1058 | |
| 1059 | - $options = array( |
|
| 1060 | - '' => __( 'Default', 'super-duper' ), |
|
| 1061 | - 'position-static' => 'static', |
|
| 1062 | - 'position-relative' => 'relative', |
|
| 1063 | - 'position-absolute' => 'absolute', |
|
| 1064 | - 'position-fixed' => 'fixed', |
|
| 1065 | - 'position-sticky' => 'sticky', |
|
| 1066 | - 'fixed-top' => 'fixed-top', |
|
| 1067 | - 'fixed-bottom' => 'fixed-bottom', |
|
| 1068 | - 'sticky-top' => 'sticky-top', |
|
| 1069 | - ); |
|
| 1070 | - |
|
| 1071 | - $defaults = array( |
|
| 1072 | - 'type' => 'select', |
|
| 1073 | - 'title' => __( 'Position', 'super-duper' ), |
|
| 1074 | - 'options' => $options, |
|
| 1075 | - 'default' => '', |
|
| 1076 | - 'desc_tip' => true, |
|
| 1077 | - 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 1078 | - ); |
|
| 1079 | - |
|
| 1080 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1081 | - |
|
| 1082 | - return $input; |
|
| 1059 | + $options = array( |
|
| 1060 | + '' => __( 'Default', 'super-duper' ), |
|
| 1061 | + 'position-static' => 'static', |
|
| 1062 | + 'position-relative' => 'relative', |
|
| 1063 | + 'position-absolute' => 'absolute', |
|
| 1064 | + 'position-fixed' => 'fixed', |
|
| 1065 | + 'position-sticky' => 'sticky', |
|
| 1066 | + 'fixed-top' => 'fixed-top', |
|
| 1067 | + 'fixed-bottom' => 'fixed-bottom', |
|
| 1068 | + 'sticky-top' => 'sticky-top', |
|
| 1069 | + ); |
|
| 1070 | + |
|
| 1071 | + $defaults = array( |
|
| 1072 | + 'type' => 'select', |
|
| 1073 | + 'title' => __( 'Position', 'super-duper' ), |
|
| 1074 | + 'options' => $options, |
|
| 1075 | + 'default' => '', |
|
| 1076 | + 'desc_tip' => true, |
|
| 1077 | + 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 1078 | + ); |
|
| 1079 | + |
|
| 1080 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1081 | + |
|
| 1082 | + return $input; |
|
| 1083 | 1083 | } |
| 1084 | 1084 | |
| 1085 | 1085 | /** |
@@ -1092,38 +1092,38 @@ discard block |
||
| 1092 | 1092 | */ |
| 1093 | 1093 | function sd_get_sticky_offset_input( $type = 'top', $overwrite = array() ) { |
| 1094 | 1094 | |
| 1095 | - $defaults = array( |
|
| 1096 | - 'type' => 'number', |
|
| 1097 | - 'title' => __( 'Sticky offset', 'super-duper' ), |
|
| 1098 | - //'desc' => __('Sticky offset'), |
|
| 1099 | - 'default' => '', |
|
| 1100 | - 'desc_tip' => true, |
|
| 1101 | - 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 1102 | - 'element_require' => '[%position%]=="sticky" || [%position%]=="sticky-top"', |
|
| 1103 | - ); |
|
| 1104 | - |
|
| 1105 | - // title |
|
| 1106 | - if ( $type == 'top' ) { |
|
| 1107 | - $defaults['title'] = __( 'Top offset', 'super-duper' ); |
|
| 1108 | - $defaults['icon'] = 'box-top'; |
|
| 1109 | - $defaults['row'] = array( |
|
| 1110 | - 'title' => __( 'Sticky offset', 'super-duper' ), |
|
| 1111 | - 'key' => 'sticky-offset', |
|
| 1112 | - 'open' => true, |
|
| 1113 | - 'class' => 'text-center', |
|
| 1114 | - ); |
|
| 1115 | - } elseif ( $type == 'bottom' ) { |
|
| 1116 | - $defaults['title'] = __( 'Bottom offset', 'super-duper' ); |
|
| 1117 | - $defaults['icon'] = 'box-bottom'; |
|
| 1118 | - $defaults['row'] = array( |
|
| 1119 | - 'key' => 'sticky-offset', |
|
| 1120 | - 'close' => true, |
|
| 1121 | - ); |
|
| 1122 | - } |
|
| 1123 | - |
|
| 1124 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1125 | - |
|
| 1126 | - return $input; |
|
| 1095 | + $defaults = array( |
|
| 1096 | + 'type' => 'number', |
|
| 1097 | + 'title' => __( 'Sticky offset', 'super-duper' ), |
|
| 1098 | + //'desc' => __('Sticky offset'), |
|
| 1099 | + 'default' => '', |
|
| 1100 | + 'desc_tip' => true, |
|
| 1101 | + 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 1102 | + 'element_require' => '[%position%]=="sticky" || [%position%]=="sticky-top"', |
|
| 1103 | + ); |
|
| 1104 | + |
|
| 1105 | + // title |
|
| 1106 | + if ( $type == 'top' ) { |
|
| 1107 | + $defaults['title'] = __( 'Top offset', 'super-duper' ); |
|
| 1108 | + $defaults['icon'] = 'box-top'; |
|
| 1109 | + $defaults['row'] = array( |
|
| 1110 | + 'title' => __( 'Sticky offset', 'super-duper' ), |
|
| 1111 | + 'key' => 'sticky-offset', |
|
| 1112 | + 'open' => true, |
|
| 1113 | + 'class' => 'text-center', |
|
| 1114 | + ); |
|
| 1115 | + } elseif ( $type == 'bottom' ) { |
|
| 1116 | + $defaults['title'] = __( 'Bottom offset', 'super-duper' ); |
|
| 1117 | + $defaults['icon'] = 'box-bottom'; |
|
| 1118 | + $defaults['row'] = array( |
|
| 1119 | + 'key' => 'sticky-offset', |
|
| 1120 | + 'close' => true, |
|
| 1121 | + ); |
|
| 1122 | + } |
|
| 1123 | + |
|
| 1124 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1125 | + |
|
| 1126 | + return $input; |
|
| 1127 | 1127 | } |
| 1128 | 1128 | |
| 1129 | 1129 | /** |
@@ -1136,36 +1136,36 @@ discard block |
||
| 1136 | 1136 | */ |
| 1137 | 1137 | function sd_get_font_size_input( $type = 'font_size', $overwrite = array(), $has_custom = false ) { |
| 1138 | 1138 | |
| 1139 | - $options = array( |
|
| 1140 | - '' => __( 'Inherit from parent', 'super-duper' ), |
|
| 1141 | - 'h6' => 'h6', |
|
| 1142 | - 'h5' => 'h5', |
|
| 1143 | - 'h4' => 'h4', |
|
| 1144 | - 'h3' => 'h3', |
|
| 1145 | - 'h2' => 'h2', |
|
| 1146 | - 'h1' => 'h1', |
|
| 1147 | - 'display-1' => 'display-1', |
|
| 1148 | - 'display-2' => 'display-2', |
|
| 1149 | - 'display-3' => 'display-3', |
|
| 1150 | - 'display-4' => 'display-4', |
|
| 1151 | - ); |
|
| 1152 | - |
|
| 1153 | - if ( $has_custom ) { |
|
| 1154 | - $options['custom'] = __( 'Custom size', 'super-duper' ); |
|
| 1155 | - } |
|
| 1156 | - |
|
| 1157 | - $defaults = array( |
|
| 1158 | - 'type' => 'select', |
|
| 1159 | - 'title' => __( 'Font size', 'super-duper' ), |
|
| 1160 | - 'options' => $options, |
|
| 1161 | - 'default' => '', |
|
| 1162 | - 'desc_tip' => true, |
|
| 1163 | - 'group' => __( 'Typography', 'super-duper' ), |
|
| 1164 | - ); |
|
| 1165 | - |
|
| 1166 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1167 | - |
|
| 1168 | - return $input; |
|
| 1139 | + $options = array( |
|
| 1140 | + '' => __( 'Inherit from parent', 'super-duper' ), |
|
| 1141 | + 'h6' => 'h6', |
|
| 1142 | + 'h5' => 'h5', |
|
| 1143 | + 'h4' => 'h4', |
|
| 1144 | + 'h3' => 'h3', |
|
| 1145 | + 'h2' => 'h2', |
|
| 1146 | + 'h1' => 'h1', |
|
| 1147 | + 'display-1' => 'display-1', |
|
| 1148 | + 'display-2' => 'display-2', |
|
| 1149 | + 'display-3' => 'display-3', |
|
| 1150 | + 'display-4' => 'display-4', |
|
| 1151 | + ); |
|
| 1152 | + |
|
| 1153 | + if ( $has_custom ) { |
|
| 1154 | + $options['custom'] = __( 'Custom size', 'super-duper' ); |
|
| 1155 | + } |
|
| 1156 | + |
|
| 1157 | + $defaults = array( |
|
| 1158 | + 'type' => 'select', |
|
| 1159 | + 'title' => __( 'Font size', 'super-duper' ), |
|
| 1160 | + 'options' => $options, |
|
| 1161 | + 'default' => '', |
|
| 1162 | + 'desc_tip' => true, |
|
| 1163 | + 'group' => __( 'Typography', 'super-duper' ), |
|
| 1164 | + ); |
|
| 1165 | + |
|
| 1166 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1167 | + |
|
| 1168 | + return $input; |
|
| 1169 | 1169 | } |
| 1170 | 1170 | |
| 1171 | 1171 | /** |
@@ -1178,27 +1178,27 @@ discard block |
||
| 1178 | 1178 | */ |
| 1179 | 1179 | function sd_get_font_custom_size_input( $type = 'font_size_custom', $overwrite = array(), $parent_type = '' ) { |
| 1180 | 1180 | |
| 1181 | - $defaults = array( |
|
| 1182 | - 'type' => 'number', |
|
| 1183 | - 'title' => __( 'Font size (rem)', 'super-duper' ), |
|
| 1184 | - 'default' => '', |
|
| 1185 | - 'placeholder' => '1.25', |
|
| 1186 | - 'custom_attributes' => array( |
|
| 1187 | - 'step' => '0.1', |
|
| 1188 | - 'min' => '0', |
|
| 1189 | - 'max' => '100', |
|
| 1190 | - ), |
|
| 1191 | - 'desc_tip' => true, |
|
| 1192 | - 'group' => __( 'Typography', 'super-duper' ), |
|
| 1193 | - ); |
|
| 1194 | - |
|
| 1195 | - if ( $parent_type ) { |
|
| 1196 | - $defaults['element_require'] = '[%' . $parent_type . '%]=="custom"'; |
|
| 1197 | - } |
|
| 1198 | - |
|
| 1199 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1200 | - |
|
| 1201 | - return $input; |
|
| 1181 | + $defaults = array( |
|
| 1182 | + 'type' => 'number', |
|
| 1183 | + 'title' => __( 'Font size (rem)', 'super-duper' ), |
|
| 1184 | + 'default' => '', |
|
| 1185 | + 'placeholder' => '1.25', |
|
| 1186 | + 'custom_attributes' => array( |
|
| 1187 | + 'step' => '0.1', |
|
| 1188 | + 'min' => '0', |
|
| 1189 | + 'max' => '100', |
|
| 1190 | + ), |
|
| 1191 | + 'desc_tip' => true, |
|
| 1192 | + 'group' => __( 'Typography', 'super-duper' ), |
|
| 1193 | + ); |
|
| 1194 | + |
|
| 1195 | + if ( $parent_type ) { |
|
| 1196 | + $defaults['element_require'] = '[%' . $parent_type . '%]=="custom"'; |
|
| 1197 | + } |
|
| 1198 | + |
|
| 1199 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1200 | + |
|
| 1201 | + return $input; |
|
| 1202 | 1202 | } |
| 1203 | 1203 | |
| 1204 | 1204 | /** |
@@ -1211,23 +1211,23 @@ discard block |
||
| 1211 | 1211 | */ |
| 1212 | 1212 | function sd_get_font_line_height_input( $type = 'font_line_height', $overwrite = array() ) { |
| 1213 | 1213 | |
| 1214 | - $defaults = array( |
|
| 1215 | - 'type' => 'number', |
|
| 1216 | - 'title' => __( 'Font Line Height', 'super-duper' ), |
|
| 1217 | - 'default' => '', |
|
| 1218 | - 'placeholder' => '1.75', |
|
| 1219 | - 'custom_attributes' => array( |
|
| 1220 | - 'step' => '0.1', |
|
| 1221 | - 'min' => '0', |
|
| 1222 | - 'max' => '100', |
|
| 1223 | - ), |
|
| 1224 | - 'desc_tip' => true, |
|
| 1225 | - 'group' => __( 'Typography', 'super-duper' ), |
|
| 1226 | - ); |
|
| 1227 | - |
|
| 1228 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1229 | - |
|
| 1230 | - return $input; |
|
| 1214 | + $defaults = array( |
|
| 1215 | + 'type' => 'number', |
|
| 1216 | + 'title' => __( 'Font Line Height', 'super-duper' ), |
|
| 1217 | + 'default' => '', |
|
| 1218 | + 'placeholder' => '1.75', |
|
| 1219 | + 'custom_attributes' => array( |
|
| 1220 | + 'step' => '0.1', |
|
| 1221 | + 'min' => '0', |
|
| 1222 | + 'max' => '100', |
|
| 1223 | + ), |
|
| 1224 | + 'desc_tip' => true, |
|
| 1225 | + 'group' => __( 'Typography', 'super-duper' ), |
|
| 1226 | + ); |
|
| 1227 | + |
|
| 1228 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1229 | + |
|
| 1230 | + return $input; |
|
| 1231 | 1231 | } |
| 1232 | 1232 | |
| 1233 | 1233 | /** |
@@ -1240,18 +1240,18 @@ discard block |
||
| 1240 | 1240 | */ |
| 1241 | 1241 | function sd_get_font_size_input_group( $type = 'font_size', $overwrite = array(), $overwrite_custom = array() ) { |
| 1242 | 1242 | |
| 1243 | - $inputs = array(); |
|
| 1243 | + $inputs = array(); |
|
| 1244 | 1244 | |
| 1245 | - if ( $overwrite !== false ) { |
|
| 1246 | - $inputs[ $type ] = sd_get_font_size_input( $type, $overwrite, true ); |
|
| 1247 | - } |
|
| 1245 | + if ( $overwrite !== false ) { |
|
| 1246 | + $inputs[ $type ] = sd_get_font_size_input( $type, $overwrite, true ); |
|
| 1247 | + } |
|
| 1248 | 1248 | |
| 1249 | - if ( $overwrite_custom !== false ) { |
|
| 1250 | - $custom = $type . '_custom'; |
|
| 1251 | - $inputs[ $custom ] = sd_get_font_custom_size_input( $custom, $overwrite_custom, $type ); |
|
| 1252 | - } |
|
| 1249 | + if ( $overwrite_custom !== false ) { |
|
| 1250 | + $custom = $type . '_custom'; |
|
| 1251 | + $inputs[ $custom ] = sd_get_font_custom_size_input( $custom, $overwrite_custom, $type ); |
|
| 1252 | + } |
|
| 1253 | 1253 | |
| 1254 | - return $inputs; |
|
| 1254 | + return $inputs; |
|
| 1255 | 1255 | } |
| 1256 | 1256 | |
| 1257 | 1257 | /** |
@@ -1264,33 +1264,33 @@ discard block |
||
| 1264 | 1264 | */ |
| 1265 | 1265 | function sd_get_font_weight_input( $type = 'font_weight', $overwrite = array() ) { |
| 1266 | 1266 | |
| 1267 | - $options = array( |
|
| 1268 | - '' => __( 'Inherit', 'super-duper' ), |
|
| 1269 | - 'font-weight-bold' => 'bold', |
|
| 1270 | - 'font-weight-bolder' => 'bolder', |
|
| 1271 | - 'font-weight-normal' => 'normal', |
|
| 1272 | - 'font-weight-light' => 'light', |
|
| 1273 | - 'font-weight-lighter' => 'lighter', |
|
| 1274 | - 'font-italic' => 'italic', |
|
| 1275 | - 'font-weight-bold font-italic' => 'bold italic', |
|
| 1276 | - 'font-weight-bolder font-italic' => 'bolder italic', |
|
| 1277 | - 'font-weight-normal font-italic' => 'normal italic', |
|
| 1278 | - 'font-weight-light font-italic' => 'light italic', |
|
| 1279 | - 'font-weight-lighter font-italic' => 'lighter italic', |
|
| 1280 | - ); |
|
| 1281 | - |
|
| 1282 | - $defaults = array( |
|
| 1283 | - 'type' => 'select', |
|
| 1284 | - 'title' => __( 'Appearance', 'super-duper' ), |
|
| 1285 | - 'options' => $options, |
|
| 1286 | - 'default' => '', |
|
| 1287 | - 'desc_tip' => true, |
|
| 1288 | - 'group' => __( 'Typography', 'super-duper' ), |
|
| 1289 | - ); |
|
| 1290 | - |
|
| 1291 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1292 | - |
|
| 1293 | - return $input; |
|
| 1267 | + $options = array( |
|
| 1268 | + '' => __( 'Inherit', 'super-duper' ), |
|
| 1269 | + 'font-weight-bold' => 'bold', |
|
| 1270 | + 'font-weight-bolder' => 'bolder', |
|
| 1271 | + 'font-weight-normal' => 'normal', |
|
| 1272 | + 'font-weight-light' => 'light', |
|
| 1273 | + 'font-weight-lighter' => 'lighter', |
|
| 1274 | + 'font-italic' => 'italic', |
|
| 1275 | + 'font-weight-bold font-italic' => 'bold italic', |
|
| 1276 | + 'font-weight-bolder font-italic' => 'bolder italic', |
|
| 1277 | + 'font-weight-normal font-italic' => 'normal italic', |
|
| 1278 | + 'font-weight-light font-italic' => 'light italic', |
|
| 1279 | + 'font-weight-lighter font-italic' => 'lighter italic', |
|
| 1280 | + ); |
|
| 1281 | + |
|
| 1282 | + $defaults = array( |
|
| 1283 | + 'type' => 'select', |
|
| 1284 | + 'title' => __( 'Appearance', 'super-duper' ), |
|
| 1285 | + 'options' => $options, |
|
| 1286 | + 'default' => '', |
|
| 1287 | + 'desc_tip' => true, |
|
| 1288 | + 'group' => __( 'Typography', 'super-duper' ), |
|
| 1289 | + ); |
|
| 1290 | + |
|
| 1291 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1292 | + |
|
| 1293 | + return $input; |
|
| 1294 | 1294 | } |
| 1295 | 1295 | |
| 1296 | 1296 | /** |
@@ -1303,25 +1303,25 @@ discard block |
||
| 1303 | 1303 | */ |
| 1304 | 1304 | function sd_get_font_case_input( $type = 'font_weight', $overwrite = array() ) { |
| 1305 | 1305 | |
| 1306 | - $options = array( |
|
| 1307 | - '' => __( 'Default', 'super-duper' ), |
|
| 1308 | - 'text-lowercase' => __( 'lowercase', 'super-duper' ), |
|
| 1309 | - 'text-uppercase' => __( 'UPPERCASE', 'super-duper' ), |
|
| 1310 | - 'text-capitalize' => __( 'Capitalize', 'super-duper' ), |
|
| 1311 | - ); |
|
| 1312 | - |
|
| 1313 | - $defaults = array( |
|
| 1314 | - 'type' => 'select', |
|
| 1315 | - 'title' => __( 'Letter case', 'super-duper' ), |
|
| 1316 | - 'options' => $options, |
|
| 1317 | - 'default' => '', |
|
| 1318 | - 'desc_tip' => true, |
|
| 1319 | - 'group' => __( 'Typography', 'super-duper' ), |
|
| 1320 | - ); |
|
| 1321 | - |
|
| 1322 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1323 | - |
|
| 1324 | - return $input; |
|
| 1306 | + $options = array( |
|
| 1307 | + '' => __( 'Default', 'super-duper' ), |
|
| 1308 | + 'text-lowercase' => __( 'lowercase', 'super-duper' ), |
|
| 1309 | + 'text-uppercase' => __( 'UPPERCASE', 'super-duper' ), |
|
| 1310 | + 'text-capitalize' => __( 'Capitalize', 'super-duper' ), |
|
| 1311 | + ); |
|
| 1312 | + |
|
| 1313 | + $defaults = array( |
|
| 1314 | + 'type' => 'select', |
|
| 1315 | + 'title' => __( 'Letter case', 'super-duper' ), |
|
| 1316 | + 'options' => $options, |
|
| 1317 | + 'default' => '', |
|
| 1318 | + 'desc_tip' => true, |
|
| 1319 | + 'group' => __( 'Typography', 'super-duper' ), |
|
| 1320 | + ); |
|
| 1321 | + |
|
| 1322 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1323 | + |
|
| 1324 | + return $input; |
|
| 1325 | 1325 | } |
| 1326 | 1326 | |
| 1327 | 1327 | /** |
@@ -1335,23 +1335,23 @@ discard block |
||
| 1335 | 1335 | */ |
| 1336 | 1336 | function sd_get_font_italic_input( $type = 'font_italic', $overwrite = array() ) { |
| 1337 | 1337 | |
| 1338 | - $options = array( |
|
| 1339 | - '' => __( 'No', 'super-duper' ), |
|
| 1340 | - 'font-italic' => __( 'Yes', 'super-duper' ), |
|
| 1341 | - ); |
|
| 1338 | + $options = array( |
|
| 1339 | + '' => __( 'No', 'super-duper' ), |
|
| 1340 | + 'font-italic' => __( 'Yes', 'super-duper' ), |
|
| 1341 | + ); |
|
| 1342 | 1342 | |
| 1343 | - $defaults = array( |
|
| 1344 | - 'type' => 'select', |
|
| 1345 | - 'title' => __( 'Font italic', 'super-duper' ), |
|
| 1346 | - 'options' => $options, |
|
| 1347 | - 'default' => '', |
|
| 1348 | - 'desc_tip' => true, |
|
| 1349 | - 'group' => __( 'Typography', 'super-duper' ), |
|
| 1350 | - ); |
|
| 1343 | + $defaults = array( |
|
| 1344 | + 'type' => 'select', |
|
| 1345 | + 'title' => __( 'Font italic', 'super-duper' ), |
|
| 1346 | + 'options' => $options, |
|
| 1347 | + 'default' => '', |
|
| 1348 | + 'desc_tip' => true, |
|
| 1349 | + 'group' => __( 'Typography', 'super-duper' ), |
|
| 1350 | + ); |
|
| 1351 | 1351 | |
| 1352 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1352 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1353 | 1353 | |
| 1354 | - return $input; |
|
| 1354 | + return $input; |
|
| 1355 | 1355 | } |
| 1356 | 1356 | |
| 1357 | 1357 | /** |
@@ -1364,18 +1364,18 @@ discard block |
||
| 1364 | 1364 | */ |
| 1365 | 1365 | function sd_get_anchor_input( $type = 'anchor', $overwrite = array() ) { |
| 1366 | 1366 | |
| 1367 | - $defaults = array( |
|
| 1368 | - 'type' => 'text', |
|
| 1369 | - 'title' => __( 'HTML anchor', 'super-duper' ), |
|
| 1370 | - 'desc' => __( 'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.' ), |
|
| 1371 | - 'default' => '', |
|
| 1372 | - 'desc_tip' => true, |
|
| 1373 | - 'group' => __( 'Advanced', 'super-duper' ), |
|
| 1374 | - ); |
|
| 1367 | + $defaults = array( |
|
| 1368 | + 'type' => 'text', |
|
| 1369 | + 'title' => __( 'HTML anchor', 'super-duper' ), |
|
| 1370 | + 'desc' => __( 'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.' ), |
|
| 1371 | + 'default' => '', |
|
| 1372 | + 'desc_tip' => true, |
|
| 1373 | + 'group' => __( 'Advanced', 'super-duper' ), |
|
| 1374 | + ); |
|
| 1375 | 1375 | |
| 1376 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1376 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1377 | 1377 | |
| 1378 | - return $input; |
|
| 1378 | + return $input; |
|
| 1379 | 1379 | } |
| 1380 | 1380 | |
| 1381 | 1381 | /** |
@@ -1388,18 +1388,18 @@ discard block |
||
| 1388 | 1388 | */ |
| 1389 | 1389 | function sd_get_class_input( $type = 'css_class', $overwrite = array() ) { |
| 1390 | 1390 | |
| 1391 | - $defaults = array( |
|
| 1392 | - 'type' => 'text', |
|
| 1393 | - 'title' => __( 'Additional CSS class(es)', 'super-duper' ), |
|
| 1394 | - 'desc' => __( 'Separate multiple classes with spaces.', 'super-duper' ), |
|
| 1395 | - 'default' => '', |
|
| 1396 | - 'desc_tip' => true, |
|
| 1397 | - 'group' => __( 'Advanced', 'super-duper' ), |
|
| 1398 | - ); |
|
| 1391 | + $defaults = array( |
|
| 1392 | + 'type' => 'text', |
|
| 1393 | + 'title' => __( 'Additional CSS class(es)', 'super-duper' ), |
|
| 1394 | + 'desc' => __( 'Separate multiple classes with spaces.', 'super-duper' ), |
|
| 1395 | + 'default' => '', |
|
| 1396 | + 'desc_tip' => true, |
|
| 1397 | + 'group' => __( 'Advanced', 'super-duper' ), |
|
| 1398 | + ); |
|
| 1399 | 1399 | |
| 1400 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1400 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1401 | 1401 | |
| 1402 | - return $input; |
|
| 1402 | + return $input; |
|
| 1403 | 1403 | } |
| 1404 | 1404 | |
| 1405 | 1405 | /** |
@@ -1412,244 +1412,244 @@ discard block |
||
| 1412 | 1412 | */ |
| 1413 | 1413 | function sd_get_hover_animations_input( $type = 'hover_animations', $overwrite = array() ) { |
| 1414 | 1414 | |
| 1415 | - $options = array( |
|
| 1416 | - '' => __( 'none', 'super-duper' ), |
|
| 1417 | - 'hover-zoom' => __( 'Zoom', 'super-duper' ), |
|
| 1418 | - 'hover-shadow' => __( 'Shadow', 'super-duper' ), |
|
| 1419 | - 'hover-move-up' => __( 'Move up', 'super-duper' ), |
|
| 1420 | - 'hover-move-down' => __( 'Move down', 'super-duper' ), |
|
| 1421 | - 'hover-move-left' => __( 'Move left', 'super-duper' ), |
|
| 1422 | - 'hover-move-right' => __( 'Move right', 'super-duper' ), |
|
| 1423 | - ); |
|
| 1424 | - |
|
| 1425 | - $defaults = array( |
|
| 1426 | - 'type' => 'select', |
|
| 1427 | - 'multiple' => true, |
|
| 1428 | - 'title' => __( 'Hover Animations', 'super-duper' ), |
|
| 1429 | - 'options' => $options, |
|
| 1430 | - 'default' => '', |
|
| 1431 | - 'desc_tip' => true, |
|
| 1432 | - 'group' => __( 'Hover Animations', 'super-duper' ), |
|
| 1433 | - ); |
|
| 1434 | - |
|
| 1435 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1436 | - |
|
| 1437 | - return $input; |
|
| 1415 | + $options = array( |
|
| 1416 | + '' => __( 'none', 'super-duper' ), |
|
| 1417 | + 'hover-zoom' => __( 'Zoom', 'super-duper' ), |
|
| 1418 | + 'hover-shadow' => __( 'Shadow', 'super-duper' ), |
|
| 1419 | + 'hover-move-up' => __( 'Move up', 'super-duper' ), |
|
| 1420 | + 'hover-move-down' => __( 'Move down', 'super-duper' ), |
|
| 1421 | + 'hover-move-left' => __( 'Move left', 'super-duper' ), |
|
| 1422 | + 'hover-move-right' => __( 'Move right', 'super-duper' ), |
|
| 1423 | + ); |
|
| 1424 | + |
|
| 1425 | + $defaults = array( |
|
| 1426 | + 'type' => 'select', |
|
| 1427 | + 'multiple' => true, |
|
| 1428 | + 'title' => __( 'Hover Animations', 'super-duper' ), |
|
| 1429 | + 'options' => $options, |
|
| 1430 | + 'default' => '', |
|
| 1431 | + 'desc_tip' => true, |
|
| 1432 | + 'group' => __( 'Hover Animations', 'super-duper' ), |
|
| 1433 | + ); |
|
| 1434 | + |
|
| 1435 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1436 | + |
|
| 1437 | + return $input; |
|
| 1438 | 1438 | } |
| 1439 | 1439 | |
| 1440 | 1440 | |
| 1441 | 1441 | function sd_get_flex_align_items_input( $type = 'align-items', $overwrite = array() ) { |
| 1442 | - $device_size = ''; |
|
| 1443 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 1444 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 1445 | - $device_size = '-md'; |
|
| 1446 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 1447 | - $device_size = '-lg'; |
|
| 1448 | - } |
|
| 1449 | - } |
|
| 1450 | - $options = array( |
|
| 1451 | - '' => __( 'Default', 'super-duper' ), |
|
| 1452 | - 'align-items' . $device_size . '-start' => 'align-items-start', |
|
| 1453 | - 'align-items' . $device_size . '-end' => 'align-items-end', |
|
| 1454 | - 'align-items' . $device_size . '-center' => 'align-items-center', |
|
| 1455 | - 'align-items' . $device_size . '-baseline' => 'align-items-baseline', |
|
| 1456 | - 'align-items' . $device_size . '-stretch' => 'align-items-stretch', |
|
| 1457 | - ); |
|
| 1458 | - |
|
| 1459 | - $defaults = array( |
|
| 1460 | - 'type' => 'select', |
|
| 1461 | - 'title' => __( 'Vertical Align Items', 'super-duper' ), |
|
| 1462 | - 'options' => $options, |
|
| 1463 | - 'default' => '', |
|
| 1464 | - 'desc_tip' => true, |
|
| 1465 | - 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 1466 | - 'element_require' => ' ( ( [%container%]=="row" ) || ( [%display%]=="d-flex" || [%display_md%]=="d-md-flex" || [%display_lg%]=="d-lg-flex" ) ) ', |
|
| 1467 | - |
|
| 1468 | - ); |
|
| 1469 | - |
|
| 1470 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1471 | - |
|
| 1472 | - return $input; |
|
| 1442 | + $device_size = ''; |
|
| 1443 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 1444 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 1445 | + $device_size = '-md'; |
|
| 1446 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 1447 | + $device_size = '-lg'; |
|
| 1448 | + } |
|
| 1449 | + } |
|
| 1450 | + $options = array( |
|
| 1451 | + '' => __( 'Default', 'super-duper' ), |
|
| 1452 | + 'align-items' . $device_size . '-start' => 'align-items-start', |
|
| 1453 | + 'align-items' . $device_size . '-end' => 'align-items-end', |
|
| 1454 | + 'align-items' . $device_size . '-center' => 'align-items-center', |
|
| 1455 | + 'align-items' . $device_size . '-baseline' => 'align-items-baseline', |
|
| 1456 | + 'align-items' . $device_size . '-stretch' => 'align-items-stretch', |
|
| 1457 | + ); |
|
| 1458 | + |
|
| 1459 | + $defaults = array( |
|
| 1460 | + 'type' => 'select', |
|
| 1461 | + 'title' => __( 'Vertical Align Items', 'super-duper' ), |
|
| 1462 | + 'options' => $options, |
|
| 1463 | + 'default' => '', |
|
| 1464 | + 'desc_tip' => true, |
|
| 1465 | + 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 1466 | + 'element_require' => ' ( ( [%container%]=="row" ) || ( [%display%]=="d-flex" || [%display_md%]=="d-md-flex" || [%display_lg%]=="d-lg-flex" ) ) ', |
|
| 1467 | + |
|
| 1468 | + ); |
|
| 1469 | + |
|
| 1470 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1471 | + |
|
| 1472 | + return $input; |
|
| 1473 | 1473 | } |
| 1474 | 1474 | |
| 1475 | 1475 | function sd_get_flex_align_items_input_group( $type = 'flex_align_items', $overwrite = array() ) { |
| 1476 | - $inputs = array(); |
|
| 1477 | - $sizes = array( |
|
| 1478 | - '' => 'Mobile', |
|
| 1479 | - '_md' => 'Tablet', |
|
| 1480 | - '_lg' => 'Desktop', |
|
| 1481 | - ); |
|
| 1482 | - |
|
| 1483 | - if ( $overwrite !== false ) { |
|
| 1484 | - |
|
| 1485 | - foreach ( $sizes as $ds => $dt ) { |
|
| 1486 | - $overwrite['device_type'] = $dt; |
|
| 1487 | - $inputs[ $type . $ds ] = sd_get_flex_align_items_input( $type, $overwrite ); |
|
| 1488 | - } |
|
| 1489 | - } |
|
| 1490 | - |
|
| 1491 | - return $inputs; |
|
| 1476 | + $inputs = array(); |
|
| 1477 | + $sizes = array( |
|
| 1478 | + '' => 'Mobile', |
|
| 1479 | + '_md' => 'Tablet', |
|
| 1480 | + '_lg' => 'Desktop', |
|
| 1481 | + ); |
|
| 1482 | + |
|
| 1483 | + if ( $overwrite !== false ) { |
|
| 1484 | + |
|
| 1485 | + foreach ( $sizes as $ds => $dt ) { |
|
| 1486 | + $overwrite['device_type'] = $dt; |
|
| 1487 | + $inputs[ $type . $ds ] = sd_get_flex_align_items_input( $type, $overwrite ); |
|
| 1488 | + } |
|
| 1489 | + } |
|
| 1490 | + |
|
| 1491 | + return $inputs; |
|
| 1492 | 1492 | } |
| 1493 | 1493 | |
| 1494 | 1494 | function sd_get_flex_justify_content_input( $type = 'flex_justify_content', $overwrite = array() ) { |
| 1495 | - $device_size = ''; |
|
| 1496 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 1497 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 1498 | - $device_size = '-md'; |
|
| 1499 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 1500 | - $device_size = '-lg'; |
|
| 1501 | - } |
|
| 1502 | - } |
|
| 1503 | - $options = array( |
|
| 1504 | - '' => __( 'Default', 'super-duper' ), |
|
| 1505 | - 'justify-content' . $device_size . '-start' => 'justify-content-start', |
|
| 1506 | - 'justify-content' . $device_size . '-end' => 'justify-content-end', |
|
| 1507 | - 'justify-content' . $device_size . '-center' => 'justify-content-center', |
|
| 1508 | - 'justify-content' . $device_size . '-between' => 'justify-content-between', |
|
| 1509 | - 'justify-content' . $device_size . '-stretch' => 'justify-content-around', |
|
| 1510 | - ); |
|
| 1511 | - |
|
| 1512 | - $defaults = array( |
|
| 1513 | - 'type' => 'select', |
|
| 1514 | - 'title' => __( 'Justify content' ), |
|
| 1515 | - 'options' => $options, |
|
| 1516 | - 'default' => '', |
|
| 1517 | - 'desc_tip' => true, |
|
| 1518 | - 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 1519 | - 'element_require' => '( ( [%container%]=="row" ) || ( [%display%]=="d-flex" || [%display_md%]=="d-md-flex" || [%display_lg%]=="d-lg-flex" ) ) ', |
|
| 1520 | - |
|
| 1521 | - ); |
|
| 1522 | - |
|
| 1523 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1524 | - |
|
| 1525 | - return $input; |
|
| 1495 | + $device_size = ''; |
|
| 1496 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 1497 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 1498 | + $device_size = '-md'; |
|
| 1499 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 1500 | + $device_size = '-lg'; |
|
| 1501 | + } |
|
| 1502 | + } |
|
| 1503 | + $options = array( |
|
| 1504 | + '' => __( 'Default', 'super-duper' ), |
|
| 1505 | + 'justify-content' . $device_size . '-start' => 'justify-content-start', |
|
| 1506 | + 'justify-content' . $device_size . '-end' => 'justify-content-end', |
|
| 1507 | + 'justify-content' . $device_size . '-center' => 'justify-content-center', |
|
| 1508 | + 'justify-content' . $device_size . '-between' => 'justify-content-between', |
|
| 1509 | + 'justify-content' . $device_size . '-stretch' => 'justify-content-around', |
|
| 1510 | + ); |
|
| 1511 | + |
|
| 1512 | + $defaults = array( |
|
| 1513 | + 'type' => 'select', |
|
| 1514 | + 'title' => __( 'Justify content' ), |
|
| 1515 | + 'options' => $options, |
|
| 1516 | + 'default' => '', |
|
| 1517 | + 'desc_tip' => true, |
|
| 1518 | + 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 1519 | + 'element_require' => '( ( [%container%]=="row" ) || ( [%display%]=="d-flex" || [%display_md%]=="d-md-flex" || [%display_lg%]=="d-lg-flex" ) ) ', |
|
| 1520 | + |
|
| 1521 | + ); |
|
| 1522 | + |
|
| 1523 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1524 | + |
|
| 1525 | + return $input; |
|
| 1526 | 1526 | } |
| 1527 | 1527 | |
| 1528 | 1528 | function sd_get_flex_justify_content_input_group( $type = 'flex_justify_content', $overwrite = array() ) { |
| 1529 | - $inputs = array(); |
|
| 1530 | - $sizes = array( |
|
| 1531 | - '' => 'Mobile', |
|
| 1532 | - '_md' => 'Tablet', |
|
| 1533 | - '_lg' => 'Desktop', |
|
| 1534 | - ); |
|
| 1535 | - |
|
| 1536 | - if ( $overwrite !== false ) { |
|
| 1537 | - |
|
| 1538 | - foreach ( $sizes as $ds => $dt ) { |
|
| 1539 | - $overwrite['device_type'] = $dt; |
|
| 1540 | - $inputs[ $type . $ds ] = sd_get_flex_justify_content_input( $type, $overwrite ); |
|
| 1541 | - } |
|
| 1542 | - } |
|
| 1543 | - |
|
| 1544 | - return $inputs; |
|
| 1529 | + $inputs = array(); |
|
| 1530 | + $sizes = array( |
|
| 1531 | + '' => 'Mobile', |
|
| 1532 | + '_md' => 'Tablet', |
|
| 1533 | + '_lg' => 'Desktop', |
|
| 1534 | + ); |
|
| 1535 | + |
|
| 1536 | + if ( $overwrite !== false ) { |
|
| 1537 | + |
|
| 1538 | + foreach ( $sizes as $ds => $dt ) { |
|
| 1539 | + $overwrite['device_type'] = $dt; |
|
| 1540 | + $inputs[ $type . $ds ] = sd_get_flex_justify_content_input( $type, $overwrite ); |
|
| 1541 | + } |
|
| 1542 | + } |
|
| 1543 | + |
|
| 1544 | + return $inputs; |
|
| 1545 | 1545 | } |
| 1546 | 1546 | |
| 1547 | 1547 | |
| 1548 | 1548 | function sd_get_flex_align_self_input( $type = 'flex_align_self', $overwrite = array() ) { |
| 1549 | - $device_size = ''; |
|
| 1550 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 1551 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 1552 | - $device_size = '-md'; |
|
| 1553 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 1554 | - $device_size = '-lg'; |
|
| 1555 | - } |
|
| 1556 | - } |
|
| 1557 | - $options = array( |
|
| 1558 | - '' => __( 'Default', 'super-duper' ), |
|
| 1559 | - 'align-items' . $device_size . '-start' => 'align-items-start', |
|
| 1560 | - 'align-items' . $device_size . '-end' => 'align-items-end', |
|
| 1561 | - 'align-items' . $device_size . '-center' => 'align-items-center', |
|
| 1562 | - 'align-items' . $device_size . '-baseline' => 'align-items-baseline', |
|
| 1563 | - 'align-items' . $device_size . '-stretch' => 'align-items-stretch', |
|
| 1564 | - ); |
|
| 1565 | - |
|
| 1566 | - $defaults = array( |
|
| 1567 | - 'type' => 'select', |
|
| 1568 | - 'title' => __( 'Align Self', 'super-duper' ), |
|
| 1569 | - 'options' => $options, |
|
| 1570 | - 'default' => '', |
|
| 1571 | - 'desc_tip' => true, |
|
| 1572 | - 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 1573 | - 'element_require' => ' [%container%]=="col" ', |
|
| 1574 | - |
|
| 1575 | - ); |
|
| 1576 | - |
|
| 1577 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1578 | - |
|
| 1579 | - return $input; |
|
| 1549 | + $device_size = ''; |
|
| 1550 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 1551 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 1552 | + $device_size = '-md'; |
|
| 1553 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 1554 | + $device_size = '-lg'; |
|
| 1555 | + } |
|
| 1556 | + } |
|
| 1557 | + $options = array( |
|
| 1558 | + '' => __( 'Default', 'super-duper' ), |
|
| 1559 | + 'align-items' . $device_size . '-start' => 'align-items-start', |
|
| 1560 | + 'align-items' . $device_size . '-end' => 'align-items-end', |
|
| 1561 | + 'align-items' . $device_size . '-center' => 'align-items-center', |
|
| 1562 | + 'align-items' . $device_size . '-baseline' => 'align-items-baseline', |
|
| 1563 | + 'align-items' . $device_size . '-stretch' => 'align-items-stretch', |
|
| 1564 | + ); |
|
| 1565 | + |
|
| 1566 | + $defaults = array( |
|
| 1567 | + 'type' => 'select', |
|
| 1568 | + 'title' => __( 'Align Self', 'super-duper' ), |
|
| 1569 | + 'options' => $options, |
|
| 1570 | + 'default' => '', |
|
| 1571 | + 'desc_tip' => true, |
|
| 1572 | + 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 1573 | + 'element_require' => ' [%container%]=="col" ', |
|
| 1574 | + |
|
| 1575 | + ); |
|
| 1576 | + |
|
| 1577 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1578 | + |
|
| 1579 | + return $input; |
|
| 1580 | 1580 | } |
| 1581 | 1581 | |
| 1582 | 1582 | function sd_get_flex_align_self_input_group( $type = 'flex_align_self', $overwrite = array() ) { |
| 1583 | - $inputs = array(); |
|
| 1584 | - $sizes = array( |
|
| 1585 | - '' => 'Mobile', |
|
| 1586 | - '_md' => 'Tablet', |
|
| 1587 | - '_lg' => 'Desktop', |
|
| 1588 | - ); |
|
| 1589 | - |
|
| 1590 | - if ( $overwrite !== false ) { |
|
| 1591 | - |
|
| 1592 | - foreach ( $sizes as $ds => $dt ) { |
|
| 1593 | - $overwrite['device_type'] = $dt; |
|
| 1594 | - $inputs[ $type . $ds ] = sd_get_flex_align_self_input( $type, $overwrite ); |
|
| 1595 | - } |
|
| 1596 | - } |
|
| 1597 | - |
|
| 1598 | - return $inputs; |
|
| 1583 | + $inputs = array(); |
|
| 1584 | + $sizes = array( |
|
| 1585 | + '' => 'Mobile', |
|
| 1586 | + '_md' => 'Tablet', |
|
| 1587 | + '_lg' => 'Desktop', |
|
| 1588 | + ); |
|
| 1589 | + |
|
| 1590 | + if ( $overwrite !== false ) { |
|
| 1591 | + |
|
| 1592 | + foreach ( $sizes as $ds => $dt ) { |
|
| 1593 | + $overwrite['device_type'] = $dt; |
|
| 1594 | + $inputs[ $type . $ds ] = sd_get_flex_align_self_input( $type, $overwrite ); |
|
| 1595 | + } |
|
| 1596 | + } |
|
| 1597 | + |
|
| 1598 | + return $inputs; |
|
| 1599 | 1599 | } |
| 1600 | 1600 | |
| 1601 | 1601 | function sd_get_flex_order_input( $type = 'flex_order', $overwrite = array() ) { |
| 1602 | - $device_size = ''; |
|
| 1603 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 1604 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 1605 | - $device_size = '-md'; |
|
| 1606 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 1607 | - $device_size = '-lg'; |
|
| 1608 | - } |
|
| 1609 | - } |
|
| 1610 | - $options = array( |
|
| 1611 | - '' => __( 'Default', 'super-duper' ), |
|
| 1612 | - ); |
|
| 1613 | - |
|
| 1614 | - $i = 0; |
|
| 1615 | - while ( $i <= 12 ) { |
|
| 1616 | - $options[ 'order' . $device_size . '-' . $i ] = $i; |
|
| 1617 | - $i++; |
|
| 1618 | - } |
|
| 1619 | - |
|
| 1620 | - $defaults = array( |
|
| 1621 | - 'type' => 'select', |
|
| 1622 | - 'title' => __( 'Flex Order', 'super-duper' ), |
|
| 1623 | - 'options' => $options, |
|
| 1624 | - 'default' => '', |
|
| 1625 | - 'desc_tip' => true, |
|
| 1626 | - 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 1627 | - 'element_require' => ' [%container%]=="col" ', |
|
| 1628 | - |
|
| 1629 | - ); |
|
| 1630 | - |
|
| 1631 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1632 | - |
|
| 1633 | - return $input; |
|
| 1602 | + $device_size = ''; |
|
| 1603 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 1604 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 1605 | + $device_size = '-md'; |
|
| 1606 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 1607 | + $device_size = '-lg'; |
|
| 1608 | + } |
|
| 1609 | + } |
|
| 1610 | + $options = array( |
|
| 1611 | + '' => __( 'Default', 'super-duper' ), |
|
| 1612 | + ); |
|
| 1613 | + |
|
| 1614 | + $i = 0; |
|
| 1615 | + while ( $i <= 12 ) { |
|
| 1616 | + $options[ 'order' . $device_size . '-' . $i ] = $i; |
|
| 1617 | + $i++; |
|
| 1618 | + } |
|
| 1619 | + |
|
| 1620 | + $defaults = array( |
|
| 1621 | + 'type' => 'select', |
|
| 1622 | + 'title' => __( 'Flex Order', 'super-duper' ), |
|
| 1623 | + 'options' => $options, |
|
| 1624 | + 'default' => '', |
|
| 1625 | + 'desc_tip' => true, |
|
| 1626 | + 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 1627 | + 'element_require' => ' [%container%]=="col" ', |
|
| 1628 | + |
|
| 1629 | + ); |
|
| 1630 | + |
|
| 1631 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1632 | + |
|
| 1633 | + return $input; |
|
| 1634 | 1634 | } |
| 1635 | 1635 | |
| 1636 | 1636 | function sd_get_flex_order_input_group( $type = 'flex_order', $overwrite = array() ) { |
| 1637 | - $inputs = array(); |
|
| 1638 | - $sizes = array( |
|
| 1639 | - '' => 'Mobile', |
|
| 1640 | - '_md' => 'Tablet', |
|
| 1641 | - '_lg' => 'Desktop', |
|
| 1642 | - ); |
|
| 1643 | - |
|
| 1644 | - if ( $overwrite !== false ) { |
|
| 1645 | - |
|
| 1646 | - foreach ( $sizes as $ds => $dt ) { |
|
| 1647 | - $overwrite['device_type'] = $dt; |
|
| 1648 | - $inputs[ $type . $ds ] = sd_get_flex_order_input( $type, $overwrite ); |
|
| 1649 | - } |
|
| 1650 | - } |
|
| 1651 | - |
|
| 1652 | - return $inputs; |
|
| 1637 | + $inputs = array(); |
|
| 1638 | + $sizes = array( |
|
| 1639 | + '' => 'Mobile', |
|
| 1640 | + '_md' => 'Tablet', |
|
| 1641 | + '_lg' => 'Desktop', |
|
| 1642 | + ); |
|
| 1643 | + |
|
| 1644 | + if ( $overwrite !== false ) { |
|
| 1645 | + |
|
| 1646 | + foreach ( $sizes as $ds => $dt ) { |
|
| 1647 | + $overwrite['device_type'] = $dt; |
|
| 1648 | + $inputs[ $type . $ds ] = sd_get_flex_order_input( $type, $overwrite ); |
|
| 1649 | + } |
|
| 1650 | + } |
|
| 1651 | + |
|
| 1652 | + return $inputs; |
|
| 1653 | 1653 | } |
| 1654 | 1654 | |
| 1655 | 1655 | /** |
@@ -1662,345 +1662,345 @@ discard block |
||
| 1662 | 1662 | */ |
| 1663 | 1663 | function sd_build_aui_class( $args ) { |
| 1664 | 1664 | |
| 1665 | - $classes = array(); |
|
| 1666 | - |
|
| 1667 | - // margins. |
|
| 1668 | - if ( isset( $args['mt'] ) && $args['mt'] !== '' ) { |
|
| 1669 | - $classes[] = 'mt-' . sanitize_html_class( $args['mt'] ); |
|
| 1670 | - $mt = $args['mt']; |
|
| 1671 | - } else { |
|
| 1672 | - $mt = null; |
|
| 1673 | - } |
|
| 1674 | - if ( isset( $args['mr'] ) && $args['mr'] !== '' ) { |
|
| 1675 | - $classes[] = 'mr-' . sanitize_html_class( $args['mr'] ); |
|
| 1676 | - $mr = $args['mr']; |
|
| 1677 | - } else { |
|
| 1678 | - $mr = null; |
|
| 1679 | - } |
|
| 1680 | - if ( isset( $args['mb'] ) && $args['mb'] !== '' ) { |
|
| 1681 | - $classes[] = 'mb-' . sanitize_html_class( $args['mb'] ); |
|
| 1682 | - $mb = $args['mb']; |
|
| 1683 | - } else { |
|
| 1684 | - $mb = null; |
|
| 1685 | - } |
|
| 1686 | - if ( isset( $args['ml'] ) && $args['ml'] !== '' ) { |
|
| 1687 | - $classes[] = 'ml-' . sanitize_html_class( $args['ml'] ); |
|
| 1688 | - $ml = $args['ml']; |
|
| 1689 | - } else { |
|
| 1690 | - $ml = null; |
|
| 1691 | - } |
|
| 1692 | - |
|
| 1693 | - // margins tablet. |
|
| 1694 | - if ( isset( $args['mt_md'] ) && $args['mt_md'] !== '' ) { |
|
| 1695 | - $classes[] = 'mt-md-' . sanitize_html_class( $args['mt_md'] ); |
|
| 1696 | - $mt_md = $args['mt_md']; |
|
| 1697 | - } else { |
|
| 1698 | - $mt_md = null; |
|
| 1699 | - } |
|
| 1700 | - if ( isset( $args['mr_md'] ) && $args['mr_md'] !== '' ) { |
|
| 1701 | - $classes[] = 'mr-md-' . sanitize_html_class( $args['mr_md'] ); |
|
| 1702 | - $mt_md = $args['mr_md']; |
|
| 1703 | - } else { |
|
| 1704 | - $mr_md = null; |
|
| 1705 | - } |
|
| 1706 | - if ( isset( $args['mb_md'] ) && $args['mb_md'] !== '' ) { |
|
| 1707 | - $classes[] = 'mb-md-' . sanitize_html_class( $args['mb_md'] ); |
|
| 1708 | - $mt_md = $args['mb_md']; |
|
| 1709 | - } else { |
|
| 1710 | - $mb_md = null; |
|
| 1711 | - } |
|
| 1712 | - if ( isset( $args['ml_md'] ) && $args['ml_md'] !== '' ) { |
|
| 1713 | - $classes[] = 'ml-md-' . sanitize_html_class( $args['ml_md'] ); |
|
| 1714 | - $mt_md = $args['ml_md']; |
|
| 1715 | - } else { |
|
| 1716 | - $ml_md = null; |
|
| 1717 | - } |
|
| 1718 | - |
|
| 1719 | - // margins desktop. |
|
| 1720 | - if ( isset( $args['mt_lg'] ) && $args['mt_lg'] !== '' ) { |
|
| 1721 | - if ( $mt == null && $mt_md == null ) { |
|
| 1722 | - $classes[] = 'mt-' . sanitize_html_class( $args['mt_lg'] ); |
|
| 1723 | - } else { |
|
| 1724 | - $classes[] = 'mt-lg-' . sanitize_html_class( $args['mt_lg'] ); |
|
| 1725 | - } |
|
| 1726 | - } |
|
| 1727 | - if ( isset( $args['mr_lg'] ) && $args['mr_lg'] !== '' ) { |
|
| 1728 | - if ( $mr == null && $mr_md == null ) { |
|
| 1729 | - $classes[] = 'mr-' . sanitize_html_class( $args['mr_lg'] ); |
|
| 1730 | - } else { |
|
| 1731 | - $classes[] = 'mr-lg-' . sanitize_html_class( $args['mr_lg'] ); |
|
| 1732 | - } |
|
| 1733 | - } |
|
| 1734 | - if ( isset( $args['mb_lg'] ) && $args['mb_lg'] !== '' ) { |
|
| 1735 | - if ( $mb == null && $mb_md == null ) { |
|
| 1736 | - $classes[] = 'mb-' . sanitize_html_class( $args['mb_lg'] ); |
|
| 1737 | - } else { |
|
| 1738 | - $classes[] = 'mb-lg-' . sanitize_html_class( $args['mb_lg'] ); |
|
| 1739 | - } |
|
| 1740 | - } |
|
| 1741 | - if ( isset( $args['ml_lg'] ) && $args['ml_lg'] !== '' ) { |
|
| 1742 | - if ( $ml == null && $ml_md == null ) { |
|
| 1743 | - $classes[] = 'ml-' . sanitize_html_class( $args['ml_lg'] ); |
|
| 1744 | - } else { |
|
| 1745 | - $classes[] = 'ml-lg-' . sanitize_html_class( $args['ml_lg'] ); |
|
| 1746 | - } |
|
| 1747 | - } |
|
| 1748 | - |
|
| 1749 | - // padding. |
|
| 1750 | - if ( isset( $args['pt'] ) && $args['pt'] !== '' ) { |
|
| 1751 | - $classes[] = 'pt-' . sanitize_html_class( $args['pt'] ); |
|
| 1752 | - $pt = $args['pt']; |
|
| 1753 | - } else { |
|
| 1754 | - $pt = null; |
|
| 1755 | - } |
|
| 1756 | - if ( isset( $args['pr'] ) && $args['pr'] !== '' ) { |
|
| 1757 | - $classes[] = 'pr-' . sanitize_html_class( $args['pr'] ); |
|
| 1758 | - $pr = $args['pr']; |
|
| 1759 | - } else { |
|
| 1760 | - $pr = null; |
|
| 1761 | - } |
|
| 1762 | - if ( isset( $args['pb'] ) && $args['pb'] !== '' ) { |
|
| 1763 | - $classes[] = 'pb-' . sanitize_html_class( $args['pb'] ); |
|
| 1764 | - $pb = $args['pb']; |
|
| 1765 | - } else { |
|
| 1766 | - $pb = null; |
|
| 1767 | - } |
|
| 1768 | - if ( isset( $args['pl'] ) && $args['pl'] !== '' ) { |
|
| 1769 | - $classes[] = 'pl-' . sanitize_html_class( $args['pl'] ); |
|
| 1770 | - $pl = $args['pl']; |
|
| 1771 | - } else { |
|
| 1772 | - $pl = null; |
|
| 1773 | - } |
|
| 1774 | - |
|
| 1775 | - // padding tablet. |
|
| 1776 | - if ( isset( $args['pt_md'] ) && $args['pt_md'] !== '' ) { |
|
| 1777 | - $classes[] = 'pt-md-' . sanitize_html_class( $args['pt_md'] ); |
|
| 1778 | - $pt_md = $args['pt_md']; |
|
| 1779 | - } else { |
|
| 1780 | - $pt_md = null; |
|
| 1781 | - } |
|
| 1782 | - if ( isset( $args['pr_md'] ) && $args['pr_md'] !== '' ) { |
|
| 1783 | - $classes[] = 'pr-md-' . sanitize_html_class( $args['pr_md'] ); |
|
| 1784 | - $pt_md = $args['pr_md']; |
|
| 1785 | - } else { |
|
| 1786 | - $pr_md = null; |
|
| 1787 | - } |
|
| 1788 | - if ( isset( $args['pb_md'] ) && $args['pb_md'] !== '' ) { |
|
| 1789 | - $classes[] = 'pb-md-' . sanitize_html_class( $args['pb_md'] ); |
|
| 1790 | - $pt_md = $args['pb_md']; |
|
| 1791 | - } else { |
|
| 1792 | - $pb_md = null; |
|
| 1793 | - } |
|
| 1794 | - if ( isset( $args['pl_md'] ) && $args['pl_md'] !== '' ) { |
|
| 1795 | - $classes[] = 'pl-md-' . sanitize_html_class( $args['pl_md'] ); |
|
| 1796 | - $pt_md = $args['pl_md']; |
|
| 1797 | - } else { |
|
| 1798 | - $pl_md = null; |
|
| 1799 | - } |
|
| 1800 | - |
|
| 1801 | - // padding desktop. |
|
| 1802 | - if ( isset( $args['pt_lg'] ) && $args['pt_lg'] !== '' ) { |
|
| 1803 | - if ( $pt == null && $pt_md == null ) { |
|
| 1804 | - $classes[] = 'pt-' . sanitize_html_class( $args['pt_lg'] ); |
|
| 1805 | - } else { |
|
| 1806 | - $classes[] = 'pt-lg-' . sanitize_html_class( $args['pt_lg'] ); |
|
| 1807 | - } |
|
| 1808 | - } |
|
| 1809 | - if ( isset( $args['pr_lg'] ) && $args['pr_lg'] !== '' ) { |
|
| 1810 | - if ( $pr == null && $pr_md == null ) { |
|
| 1811 | - $classes[] = 'pr-' . sanitize_html_class( $args['pr_lg'] ); |
|
| 1812 | - } else { |
|
| 1813 | - $classes[] = 'pr-lg-' . sanitize_html_class( $args['pr_lg'] ); |
|
| 1814 | - } |
|
| 1815 | - } |
|
| 1816 | - if ( isset( $args['pb_lg'] ) && $args['pb_lg'] !== '' ) { |
|
| 1817 | - if ( $pb == null && $pb_md == null ) { |
|
| 1818 | - $classes[] = 'pb-' . sanitize_html_class( $args['pb_lg'] ); |
|
| 1819 | - } else { |
|
| 1820 | - $classes[] = 'pb-lg-' . sanitize_html_class( $args['pb_lg'] ); |
|
| 1821 | - } |
|
| 1822 | - } |
|
| 1823 | - if ( isset( $args['pl_lg'] ) && $args['pl_lg'] !== '' ) { |
|
| 1824 | - if ( $pl == null && $pl_md == null ) { |
|
| 1825 | - $classes[] = 'pl-' . sanitize_html_class( $args['pl_lg'] ); |
|
| 1826 | - } else { |
|
| 1827 | - $classes[] = 'pl-lg-' . sanitize_html_class( $args['pl_lg'] ); |
|
| 1828 | - } |
|
| 1829 | - } |
|
| 1830 | - |
|
| 1831 | - // row cols, mobile, tablet, desktop |
|
| 1832 | - if ( ! empty( $args['row_cols'] ) && $args['row_cols'] !== '' ) { |
|
| 1833 | - $classes[] = sanitize_html_class( 'row-cols-' . $args['row_cols'] ); |
|
| 1834 | - $row_cols = $args['row_cols']; |
|
| 1835 | - } else { |
|
| 1836 | - $row_cols = null; |
|
| 1837 | - } |
|
| 1838 | - if ( ! empty( $args['row_cols_md'] ) && $args['row_cols_md'] !== '' ) { |
|
| 1839 | - $classes[] = sanitize_html_class( 'row-cols-md-' . $args['row_cols_md'] ); |
|
| 1840 | - $row_cols_md = $args['row_cols_md']; |
|
| 1841 | - } else { |
|
| 1842 | - $row_cols_md = null; |
|
| 1843 | - } |
|
| 1844 | - if ( ! empty( $args['row_cols_lg'] ) && $args['row_cols_lg'] !== '' ) { |
|
| 1845 | - if ( $row_cols == null && $row_cols_md == null ) { |
|
| 1846 | - $classes[] = sanitize_html_class( 'row-cols-' . $args['row_cols_lg'] ); |
|
| 1847 | - } else { |
|
| 1848 | - $classes[] = sanitize_html_class( 'row-cols-lg-' . $args['row_cols_lg'] ); |
|
| 1849 | - } |
|
| 1850 | - } |
|
| 1851 | - |
|
| 1852 | - // columns , mobile, tablet, desktop |
|
| 1853 | - if ( ! empty( $args['col'] ) && $args['col'] !== '' ) { |
|
| 1854 | - $classes[] = sanitize_html_class( 'col-' . $args['col'] ); |
|
| 1855 | - $col = $args['col']; |
|
| 1856 | - } else { |
|
| 1857 | - $col = null; |
|
| 1858 | - } |
|
| 1859 | - if ( ! empty( $args['col_md'] ) && $args['col_md'] !== '' ) { |
|
| 1860 | - $classes[] = sanitize_html_class( 'col-md-' . $args['col_md'] ); |
|
| 1861 | - $col_md = $args['col_md']; |
|
| 1862 | - } else { |
|
| 1863 | - $col_md = null; |
|
| 1864 | - } |
|
| 1865 | - if ( ! empty( $args['col_lg'] ) && $args['col_lg'] !== '' ) { |
|
| 1866 | - if ( $col == null && $col_md == null ) { |
|
| 1867 | - $classes[] = sanitize_html_class( 'col-' . $args['col_lg'] ); |
|
| 1868 | - } else { |
|
| 1869 | - $classes[] = sanitize_html_class( 'col-lg-' . $args['col_lg'] ); |
|
| 1870 | - } |
|
| 1871 | - } |
|
| 1872 | - |
|
| 1873 | - // border |
|
| 1874 | - if ( ! empty( $args['border'] ) && ( $args['border'] == 'none' || $args['border'] === '0' ) ) { |
|
| 1875 | - $classes[] = 'border-0'; |
|
| 1876 | - } elseif ( ! empty( $args['border'] ) ) { |
|
| 1877 | - $classes[] = 'border border-' . sanitize_html_class( $args['border'] ); |
|
| 1878 | - } |
|
| 1879 | - |
|
| 1880 | - // border radius type |
|
| 1881 | - if ( ! empty( $args['rounded'] ) ) { |
|
| 1882 | - $classes[] = sanitize_html_class( $args['rounded'] ); |
|
| 1883 | - } |
|
| 1884 | - |
|
| 1885 | - // border radius size |
|
| 1886 | - if ( ! empty( $args['rounded_size'] ) ) { |
|
| 1887 | - $classes[] = 'rounded-' . sanitize_html_class( $args['rounded_size'] ); |
|
| 1888 | - // if we set a size then we need to remove "rounded" if set |
|
| 1889 | - if ( ( $key = array_search( 'rounded', $classes ) ) !== false ) { |
|
| 1890 | - unset( $classes[ $key ] ); |
|
| 1891 | - } |
|
| 1892 | - } |
|
| 1893 | - |
|
| 1894 | - // shadow |
|
| 1895 | - //if ( !empty( $args['shadow'] ) ) { $classes[] = sanitize_html_class($args['shadow']); } |
|
| 1896 | - |
|
| 1897 | - // background |
|
| 1898 | - if ( ! empty( $args['bg'] ) ) { |
|
| 1899 | - $classes[] = 'bg-' . sanitize_html_class( $args['bg'] ); |
|
| 1900 | - } |
|
| 1901 | - |
|
| 1902 | - // text_color |
|
| 1903 | - if ( ! empty( $args['text_color'] ) ) { |
|
| 1904 | - $classes[] = 'text-' . sanitize_html_class( $args['text_color'] ); |
|
| 1905 | - } |
|
| 1906 | - |
|
| 1907 | - // text_align |
|
| 1908 | - if ( ! empty( $args['text_justify'] ) ) { |
|
| 1909 | - $classes[] = 'text-justify'; |
|
| 1910 | - } else { |
|
| 1911 | - if ( ! empty( $args['text_align'] ) ) { |
|
| 1912 | - $classes[] = sanitize_html_class( $args['text_align'] ); |
|
| 1913 | - $text_align = $args['text_align']; |
|
| 1914 | - } else { |
|
| 1915 | - $text_align = null; |
|
| 1916 | - } |
|
| 1917 | - if ( ! empty( $args['text_align_md'] ) && $args['text_align_md'] !== '' ) { |
|
| 1918 | - $classes[] = sanitize_html_class( $args['text_align_md'] ); |
|
| 1919 | - $text_align_md = $args['text_align_md']; |
|
| 1920 | - } else { |
|
| 1921 | - $text_align_md = null; |
|
| 1922 | - } |
|
| 1923 | - if ( ! empty( $args['text_align_lg'] ) && $args['text_align_lg'] !== '' ) { |
|
| 1924 | - if ( $text_align == null && $text_align_md == null ) { |
|
| 1925 | - $classes[] = sanitize_html_class( str_replace( '-lg', '', $args['text_align_lg'] ) ); |
|
| 1926 | - } else { |
|
| 1927 | - $classes[] = sanitize_html_class( $args['text_align_lg'] ); |
|
| 1928 | - } |
|
| 1929 | - } |
|
| 1930 | - } |
|
| 1931 | - |
|
| 1932 | - // display |
|
| 1933 | - if ( ! empty( $args['display'] ) ) { |
|
| 1934 | - $classes[] = sanitize_html_class( $args['display'] ); |
|
| 1935 | - $display = $args['display']; |
|
| 1936 | - } else { |
|
| 1937 | - $display = null; |
|
| 1938 | - } |
|
| 1939 | - if ( ! empty( $args['display_md'] ) && $args['display_md'] !== '' ) { |
|
| 1940 | - $classes[] = sanitize_html_class( $args['display_md'] ); |
|
| 1941 | - $display_md = $args['display_md']; |
|
| 1942 | - } else { |
|
| 1943 | - $display_md = null; |
|
| 1944 | - } |
|
| 1945 | - if ( ! empty( $args['display_lg'] ) && $args['display_lg'] !== '' ) { |
|
| 1946 | - if ( $display == null && $display_md == null ) { |
|
| 1947 | - $classes[] = sanitize_html_class( str_replace( '-lg', '', $args['display_lg'] ) ); |
|
| 1948 | - } else { |
|
| 1949 | - $classes[] = sanitize_html_class( $args['display_lg'] ); |
|
| 1950 | - } |
|
| 1951 | - } |
|
| 1952 | - |
|
| 1953 | - // bgtus - background transparent until scroll |
|
| 1954 | - if ( ! empty( $args['bgtus'] ) ) { |
|
| 1955 | - $classes[] = sanitize_html_class( 'bg-transparent-until-scroll' ); |
|
| 1956 | - } |
|
| 1957 | - |
|
| 1958 | - // hover animations |
|
| 1959 | - if ( ! empty( $args['hover_animations'] ) ) { |
|
| 1960 | - $classes[] = sd_sanitize_html_classes( str_replace( ',', ' ', $args['hover_animations'] ) ); |
|
| 1961 | - } |
|
| 1962 | - |
|
| 1963 | - // build classes from build keys |
|
| 1964 | - $build_keys = sd_get_class_build_keys(); |
|
| 1965 | - if ( ! empty( $build_keys ) ) { |
|
| 1966 | - foreach ( $build_keys as $key ) { |
|
| 1967 | - |
|
| 1968 | - if ( substr( $key, -4 ) == '-MTD' ) { |
|
| 1969 | - |
|
| 1970 | - $k = str_replace( '_MTD', '', $key ); |
|
| 1971 | - |
|
| 1972 | - // Mobile, Tablet, Desktop |
|
| 1973 | - if ( ! empty( $args[ $k ] ) && $args[ $k ] !== '' ) { |
|
| 1974 | - $classes[] = sanitize_html_class( $args[ $k ] ); |
|
| 1975 | - $v = $args[ $k ]; |
|
| 1976 | - } else { |
|
| 1977 | - $v = null; |
|
| 1978 | - } |
|
| 1979 | - if ( ! empty( $args[ $k . '_md' ] ) && $args[ $k . '_md' ] !== '' ) { |
|
| 1980 | - $classes[] = sanitize_html_class( $args[ $k . '_md' ] ); |
|
| 1981 | - $v_md = $args[ $k . '_md' ]; |
|
| 1982 | - } else { |
|
| 1983 | - $v_md = null; |
|
| 1984 | - } |
|
| 1985 | - if ( ! empty( $args[ $k . '_lg' ] ) && $args[ $k . '_lg' ] !== '' ) { |
|
| 1986 | - if ( $v == null && $v_md == null ) { |
|
| 1987 | - $classes[] = sanitize_html_class( str_replace( '-lg', '', $args[ $k . '_lg' ] ) ); |
|
| 1988 | - } else { |
|
| 1989 | - $classes[] = sanitize_html_class( $args[ $k . '_lg' ] ); |
|
| 1990 | - } |
|
| 1991 | - } |
|
| 1992 | - } else { |
|
| 1993 | - if ( $key == 'font_size' && ! empty( $args[ $key ] ) && $args[ $key ] == 'custom' ) { |
|
| 1994 | - continue; |
|
| 1995 | - } |
|
| 1996 | - if ( ! empty( $args[ $key ] ) ) { |
|
| 1997 | - $classes[] = sd_sanitize_html_classes( $args[ $key ] ); |
|
| 1998 | - } |
|
| 1999 | - } |
|
| 2000 | - } |
|
| 2001 | - } |
|
| 2002 | - |
|
| 2003 | - return implode( ' ', $classes ); |
|
| 1665 | + $classes = array(); |
|
| 1666 | + |
|
| 1667 | + // margins. |
|
| 1668 | + if ( isset( $args['mt'] ) && $args['mt'] !== '' ) { |
|
| 1669 | + $classes[] = 'mt-' . sanitize_html_class( $args['mt'] ); |
|
| 1670 | + $mt = $args['mt']; |
|
| 1671 | + } else { |
|
| 1672 | + $mt = null; |
|
| 1673 | + } |
|
| 1674 | + if ( isset( $args['mr'] ) && $args['mr'] !== '' ) { |
|
| 1675 | + $classes[] = 'mr-' . sanitize_html_class( $args['mr'] ); |
|
| 1676 | + $mr = $args['mr']; |
|
| 1677 | + } else { |
|
| 1678 | + $mr = null; |
|
| 1679 | + } |
|
| 1680 | + if ( isset( $args['mb'] ) && $args['mb'] !== '' ) { |
|
| 1681 | + $classes[] = 'mb-' . sanitize_html_class( $args['mb'] ); |
|
| 1682 | + $mb = $args['mb']; |
|
| 1683 | + } else { |
|
| 1684 | + $mb = null; |
|
| 1685 | + } |
|
| 1686 | + if ( isset( $args['ml'] ) && $args['ml'] !== '' ) { |
|
| 1687 | + $classes[] = 'ml-' . sanitize_html_class( $args['ml'] ); |
|
| 1688 | + $ml = $args['ml']; |
|
| 1689 | + } else { |
|
| 1690 | + $ml = null; |
|
| 1691 | + } |
|
| 1692 | + |
|
| 1693 | + // margins tablet. |
|
| 1694 | + if ( isset( $args['mt_md'] ) && $args['mt_md'] !== '' ) { |
|
| 1695 | + $classes[] = 'mt-md-' . sanitize_html_class( $args['mt_md'] ); |
|
| 1696 | + $mt_md = $args['mt_md']; |
|
| 1697 | + } else { |
|
| 1698 | + $mt_md = null; |
|
| 1699 | + } |
|
| 1700 | + if ( isset( $args['mr_md'] ) && $args['mr_md'] !== '' ) { |
|
| 1701 | + $classes[] = 'mr-md-' . sanitize_html_class( $args['mr_md'] ); |
|
| 1702 | + $mt_md = $args['mr_md']; |
|
| 1703 | + } else { |
|
| 1704 | + $mr_md = null; |
|
| 1705 | + } |
|
| 1706 | + if ( isset( $args['mb_md'] ) && $args['mb_md'] !== '' ) { |
|
| 1707 | + $classes[] = 'mb-md-' . sanitize_html_class( $args['mb_md'] ); |
|
| 1708 | + $mt_md = $args['mb_md']; |
|
| 1709 | + } else { |
|
| 1710 | + $mb_md = null; |
|
| 1711 | + } |
|
| 1712 | + if ( isset( $args['ml_md'] ) && $args['ml_md'] !== '' ) { |
|
| 1713 | + $classes[] = 'ml-md-' . sanitize_html_class( $args['ml_md'] ); |
|
| 1714 | + $mt_md = $args['ml_md']; |
|
| 1715 | + } else { |
|
| 1716 | + $ml_md = null; |
|
| 1717 | + } |
|
| 1718 | + |
|
| 1719 | + // margins desktop. |
|
| 1720 | + if ( isset( $args['mt_lg'] ) && $args['mt_lg'] !== '' ) { |
|
| 1721 | + if ( $mt == null && $mt_md == null ) { |
|
| 1722 | + $classes[] = 'mt-' . sanitize_html_class( $args['mt_lg'] ); |
|
| 1723 | + } else { |
|
| 1724 | + $classes[] = 'mt-lg-' . sanitize_html_class( $args['mt_lg'] ); |
|
| 1725 | + } |
|
| 1726 | + } |
|
| 1727 | + if ( isset( $args['mr_lg'] ) && $args['mr_lg'] !== '' ) { |
|
| 1728 | + if ( $mr == null && $mr_md == null ) { |
|
| 1729 | + $classes[] = 'mr-' . sanitize_html_class( $args['mr_lg'] ); |
|
| 1730 | + } else { |
|
| 1731 | + $classes[] = 'mr-lg-' . sanitize_html_class( $args['mr_lg'] ); |
|
| 1732 | + } |
|
| 1733 | + } |
|
| 1734 | + if ( isset( $args['mb_lg'] ) && $args['mb_lg'] !== '' ) { |
|
| 1735 | + if ( $mb == null && $mb_md == null ) { |
|
| 1736 | + $classes[] = 'mb-' . sanitize_html_class( $args['mb_lg'] ); |
|
| 1737 | + } else { |
|
| 1738 | + $classes[] = 'mb-lg-' . sanitize_html_class( $args['mb_lg'] ); |
|
| 1739 | + } |
|
| 1740 | + } |
|
| 1741 | + if ( isset( $args['ml_lg'] ) && $args['ml_lg'] !== '' ) { |
|
| 1742 | + if ( $ml == null && $ml_md == null ) { |
|
| 1743 | + $classes[] = 'ml-' . sanitize_html_class( $args['ml_lg'] ); |
|
| 1744 | + } else { |
|
| 1745 | + $classes[] = 'ml-lg-' . sanitize_html_class( $args['ml_lg'] ); |
|
| 1746 | + } |
|
| 1747 | + } |
|
| 1748 | + |
|
| 1749 | + // padding. |
|
| 1750 | + if ( isset( $args['pt'] ) && $args['pt'] !== '' ) { |
|
| 1751 | + $classes[] = 'pt-' . sanitize_html_class( $args['pt'] ); |
|
| 1752 | + $pt = $args['pt']; |
|
| 1753 | + } else { |
|
| 1754 | + $pt = null; |
|
| 1755 | + } |
|
| 1756 | + if ( isset( $args['pr'] ) && $args['pr'] !== '' ) { |
|
| 1757 | + $classes[] = 'pr-' . sanitize_html_class( $args['pr'] ); |
|
| 1758 | + $pr = $args['pr']; |
|
| 1759 | + } else { |
|
| 1760 | + $pr = null; |
|
| 1761 | + } |
|
| 1762 | + if ( isset( $args['pb'] ) && $args['pb'] !== '' ) { |
|
| 1763 | + $classes[] = 'pb-' . sanitize_html_class( $args['pb'] ); |
|
| 1764 | + $pb = $args['pb']; |
|
| 1765 | + } else { |
|
| 1766 | + $pb = null; |
|
| 1767 | + } |
|
| 1768 | + if ( isset( $args['pl'] ) && $args['pl'] !== '' ) { |
|
| 1769 | + $classes[] = 'pl-' . sanitize_html_class( $args['pl'] ); |
|
| 1770 | + $pl = $args['pl']; |
|
| 1771 | + } else { |
|
| 1772 | + $pl = null; |
|
| 1773 | + } |
|
| 1774 | + |
|
| 1775 | + // padding tablet. |
|
| 1776 | + if ( isset( $args['pt_md'] ) && $args['pt_md'] !== '' ) { |
|
| 1777 | + $classes[] = 'pt-md-' . sanitize_html_class( $args['pt_md'] ); |
|
| 1778 | + $pt_md = $args['pt_md']; |
|
| 1779 | + } else { |
|
| 1780 | + $pt_md = null; |
|
| 1781 | + } |
|
| 1782 | + if ( isset( $args['pr_md'] ) && $args['pr_md'] !== '' ) { |
|
| 1783 | + $classes[] = 'pr-md-' . sanitize_html_class( $args['pr_md'] ); |
|
| 1784 | + $pt_md = $args['pr_md']; |
|
| 1785 | + } else { |
|
| 1786 | + $pr_md = null; |
|
| 1787 | + } |
|
| 1788 | + if ( isset( $args['pb_md'] ) && $args['pb_md'] !== '' ) { |
|
| 1789 | + $classes[] = 'pb-md-' . sanitize_html_class( $args['pb_md'] ); |
|
| 1790 | + $pt_md = $args['pb_md']; |
|
| 1791 | + } else { |
|
| 1792 | + $pb_md = null; |
|
| 1793 | + } |
|
| 1794 | + if ( isset( $args['pl_md'] ) && $args['pl_md'] !== '' ) { |
|
| 1795 | + $classes[] = 'pl-md-' . sanitize_html_class( $args['pl_md'] ); |
|
| 1796 | + $pt_md = $args['pl_md']; |
|
| 1797 | + } else { |
|
| 1798 | + $pl_md = null; |
|
| 1799 | + } |
|
| 1800 | + |
|
| 1801 | + // padding desktop. |
|
| 1802 | + if ( isset( $args['pt_lg'] ) && $args['pt_lg'] !== '' ) { |
|
| 1803 | + if ( $pt == null && $pt_md == null ) { |
|
| 1804 | + $classes[] = 'pt-' . sanitize_html_class( $args['pt_lg'] ); |
|
| 1805 | + } else { |
|
| 1806 | + $classes[] = 'pt-lg-' . sanitize_html_class( $args['pt_lg'] ); |
|
| 1807 | + } |
|
| 1808 | + } |
|
| 1809 | + if ( isset( $args['pr_lg'] ) && $args['pr_lg'] !== '' ) { |
|
| 1810 | + if ( $pr == null && $pr_md == null ) { |
|
| 1811 | + $classes[] = 'pr-' . sanitize_html_class( $args['pr_lg'] ); |
|
| 1812 | + } else { |
|
| 1813 | + $classes[] = 'pr-lg-' . sanitize_html_class( $args['pr_lg'] ); |
|
| 1814 | + } |
|
| 1815 | + } |
|
| 1816 | + if ( isset( $args['pb_lg'] ) && $args['pb_lg'] !== '' ) { |
|
| 1817 | + if ( $pb == null && $pb_md == null ) { |
|
| 1818 | + $classes[] = 'pb-' . sanitize_html_class( $args['pb_lg'] ); |
|
| 1819 | + } else { |
|
| 1820 | + $classes[] = 'pb-lg-' . sanitize_html_class( $args['pb_lg'] ); |
|
| 1821 | + } |
|
| 1822 | + } |
|
| 1823 | + if ( isset( $args['pl_lg'] ) && $args['pl_lg'] !== '' ) { |
|
| 1824 | + if ( $pl == null && $pl_md == null ) { |
|
| 1825 | + $classes[] = 'pl-' . sanitize_html_class( $args['pl_lg'] ); |
|
| 1826 | + } else { |
|
| 1827 | + $classes[] = 'pl-lg-' . sanitize_html_class( $args['pl_lg'] ); |
|
| 1828 | + } |
|
| 1829 | + } |
|
| 1830 | + |
|
| 1831 | + // row cols, mobile, tablet, desktop |
|
| 1832 | + if ( ! empty( $args['row_cols'] ) && $args['row_cols'] !== '' ) { |
|
| 1833 | + $classes[] = sanitize_html_class( 'row-cols-' . $args['row_cols'] ); |
|
| 1834 | + $row_cols = $args['row_cols']; |
|
| 1835 | + } else { |
|
| 1836 | + $row_cols = null; |
|
| 1837 | + } |
|
| 1838 | + if ( ! empty( $args['row_cols_md'] ) && $args['row_cols_md'] !== '' ) { |
|
| 1839 | + $classes[] = sanitize_html_class( 'row-cols-md-' . $args['row_cols_md'] ); |
|
| 1840 | + $row_cols_md = $args['row_cols_md']; |
|
| 1841 | + } else { |
|
| 1842 | + $row_cols_md = null; |
|
| 1843 | + } |
|
| 1844 | + if ( ! empty( $args['row_cols_lg'] ) && $args['row_cols_lg'] !== '' ) { |
|
| 1845 | + if ( $row_cols == null && $row_cols_md == null ) { |
|
| 1846 | + $classes[] = sanitize_html_class( 'row-cols-' . $args['row_cols_lg'] ); |
|
| 1847 | + } else { |
|
| 1848 | + $classes[] = sanitize_html_class( 'row-cols-lg-' . $args['row_cols_lg'] ); |
|
| 1849 | + } |
|
| 1850 | + } |
|
| 1851 | + |
|
| 1852 | + // columns , mobile, tablet, desktop |
|
| 1853 | + if ( ! empty( $args['col'] ) && $args['col'] !== '' ) { |
|
| 1854 | + $classes[] = sanitize_html_class( 'col-' . $args['col'] ); |
|
| 1855 | + $col = $args['col']; |
|
| 1856 | + } else { |
|
| 1857 | + $col = null; |
|
| 1858 | + } |
|
| 1859 | + if ( ! empty( $args['col_md'] ) && $args['col_md'] !== '' ) { |
|
| 1860 | + $classes[] = sanitize_html_class( 'col-md-' . $args['col_md'] ); |
|
| 1861 | + $col_md = $args['col_md']; |
|
| 1862 | + } else { |
|
| 1863 | + $col_md = null; |
|
| 1864 | + } |
|
| 1865 | + if ( ! empty( $args['col_lg'] ) && $args['col_lg'] !== '' ) { |
|
| 1866 | + if ( $col == null && $col_md == null ) { |
|
| 1867 | + $classes[] = sanitize_html_class( 'col-' . $args['col_lg'] ); |
|
| 1868 | + } else { |
|
| 1869 | + $classes[] = sanitize_html_class( 'col-lg-' . $args['col_lg'] ); |
|
| 1870 | + } |
|
| 1871 | + } |
|
| 1872 | + |
|
| 1873 | + // border |
|
| 1874 | + if ( ! empty( $args['border'] ) && ( $args['border'] == 'none' || $args['border'] === '0' ) ) { |
|
| 1875 | + $classes[] = 'border-0'; |
|
| 1876 | + } elseif ( ! empty( $args['border'] ) ) { |
|
| 1877 | + $classes[] = 'border border-' . sanitize_html_class( $args['border'] ); |
|
| 1878 | + } |
|
| 1879 | + |
|
| 1880 | + // border radius type |
|
| 1881 | + if ( ! empty( $args['rounded'] ) ) { |
|
| 1882 | + $classes[] = sanitize_html_class( $args['rounded'] ); |
|
| 1883 | + } |
|
| 1884 | + |
|
| 1885 | + // border radius size |
|
| 1886 | + if ( ! empty( $args['rounded_size'] ) ) { |
|
| 1887 | + $classes[] = 'rounded-' . sanitize_html_class( $args['rounded_size'] ); |
|
| 1888 | + // if we set a size then we need to remove "rounded" if set |
|
| 1889 | + if ( ( $key = array_search( 'rounded', $classes ) ) !== false ) { |
|
| 1890 | + unset( $classes[ $key ] ); |
|
| 1891 | + } |
|
| 1892 | + } |
|
| 1893 | + |
|
| 1894 | + // shadow |
|
| 1895 | + //if ( !empty( $args['shadow'] ) ) { $classes[] = sanitize_html_class($args['shadow']); } |
|
| 1896 | + |
|
| 1897 | + // background |
|
| 1898 | + if ( ! empty( $args['bg'] ) ) { |
|
| 1899 | + $classes[] = 'bg-' . sanitize_html_class( $args['bg'] ); |
|
| 1900 | + } |
|
| 1901 | + |
|
| 1902 | + // text_color |
|
| 1903 | + if ( ! empty( $args['text_color'] ) ) { |
|
| 1904 | + $classes[] = 'text-' . sanitize_html_class( $args['text_color'] ); |
|
| 1905 | + } |
|
| 1906 | + |
|
| 1907 | + // text_align |
|
| 1908 | + if ( ! empty( $args['text_justify'] ) ) { |
|
| 1909 | + $classes[] = 'text-justify'; |
|
| 1910 | + } else { |
|
| 1911 | + if ( ! empty( $args['text_align'] ) ) { |
|
| 1912 | + $classes[] = sanitize_html_class( $args['text_align'] ); |
|
| 1913 | + $text_align = $args['text_align']; |
|
| 1914 | + } else { |
|
| 1915 | + $text_align = null; |
|
| 1916 | + } |
|
| 1917 | + if ( ! empty( $args['text_align_md'] ) && $args['text_align_md'] !== '' ) { |
|
| 1918 | + $classes[] = sanitize_html_class( $args['text_align_md'] ); |
|
| 1919 | + $text_align_md = $args['text_align_md']; |
|
| 1920 | + } else { |
|
| 1921 | + $text_align_md = null; |
|
| 1922 | + } |
|
| 1923 | + if ( ! empty( $args['text_align_lg'] ) && $args['text_align_lg'] !== '' ) { |
|
| 1924 | + if ( $text_align == null && $text_align_md == null ) { |
|
| 1925 | + $classes[] = sanitize_html_class( str_replace( '-lg', '', $args['text_align_lg'] ) ); |
|
| 1926 | + } else { |
|
| 1927 | + $classes[] = sanitize_html_class( $args['text_align_lg'] ); |
|
| 1928 | + } |
|
| 1929 | + } |
|
| 1930 | + } |
|
| 1931 | + |
|
| 1932 | + // display |
|
| 1933 | + if ( ! empty( $args['display'] ) ) { |
|
| 1934 | + $classes[] = sanitize_html_class( $args['display'] ); |
|
| 1935 | + $display = $args['display']; |
|
| 1936 | + } else { |
|
| 1937 | + $display = null; |
|
| 1938 | + } |
|
| 1939 | + if ( ! empty( $args['display_md'] ) && $args['display_md'] !== '' ) { |
|
| 1940 | + $classes[] = sanitize_html_class( $args['display_md'] ); |
|
| 1941 | + $display_md = $args['display_md']; |
|
| 1942 | + } else { |
|
| 1943 | + $display_md = null; |
|
| 1944 | + } |
|
| 1945 | + if ( ! empty( $args['display_lg'] ) && $args['display_lg'] !== '' ) { |
|
| 1946 | + if ( $display == null && $display_md == null ) { |
|
| 1947 | + $classes[] = sanitize_html_class( str_replace( '-lg', '', $args['display_lg'] ) ); |
|
| 1948 | + } else { |
|
| 1949 | + $classes[] = sanitize_html_class( $args['display_lg'] ); |
|
| 1950 | + } |
|
| 1951 | + } |
|
| 1952 | + |
|
| 1953 | + // bgtus - background transparent until scroll |
|
| 1954 | + if ( ! empty( $args['bgtus'] ) ) { |
|
| 1955 | + $classes[] = sanitize_html_class( 'bg-transparent-until-scroll' ); |
|
| 1956 | + } |
|
| 1957 | + |
|
| 1958 | + // hover animations |
|
| 1959 | + if ( ! empty( $args['hover_animations'] ) ) { |
|
| 1960 | + $classes[] = sd_sanitize_html_classes( str_replace( ',', ' ', $args['hover_animations'] ) ); |
|
| 1961 | + } |
|
| 1962 | + |
|
| 1963 | + // build classes from build keys |
|
| 1964 | + $build_keys = sd_get_class_build_keys(); |
|
| 1965 | + if ( ! empty( $build_keys ) ) { |
|
| 1966 | + foreach ( $build_keys as $key ) { |
|
| 1967 | + |
|
| 1968 | + if ( substr( $key, -4 ) == '-MTD' ) { |
|
| 1969 | + |
|
| 1970 | + $k = str_replace( '_MTD', '', $key ); |
|
| 1971 | + |
|
| 1972 | + // Mobile, Tablet, Desktop |
|
| 1973 | + if ( ! empty( $args[ $k ] ) && $args[ $k ] !== '' ) { |
|
| 1974 | + $classes[] = sanitize_html_class( $args[ $k ] ); |
|
| 1975 | + $v = $args[ $k ]; |
|
| 1976 | + } else { |
|
| 1977 | + $v = null; |
|
| 1978 | + } |
|
| 1979 | + if ( ! empty( $args[ $k . '_md' ] ) && $args[ $k . '_md' ] !== '' ) { |
|
| 1980 | + $classes[] = sanitize_html_class( $args[ $k . '_md' ] ); |
|
| 1981 | + $v_md = $args[ $k . '_md' ]; |
|
| 1982 | + } else { |
|
| 1983 | + $v_md = null; |
|
| 1984 | + } |
|
| 1985 | + if ( ! empty( $args[ $k . '_lg' ] ) && $args[ $k . '_lg' ] !== '' ) { |
|
| 1986 | + if ( $v == null && $v_md == null ) { |
|
| 1987 | + $classes[] = sanitize_html_class( str_replace( '-lg', '', $args[ $k . '_lg' ] ) ); |
|
| 1988 | + } else { |
|
| 1989 | + $classes[] = sanitize_html_class( $args[ $k . '_lg' ] ); |
|
| 1990 | + } |
|
| 1991 | + } |
|
| 1992 | + } else { |
|
| 1993 | + if ( $key == 'font_size' && ! empty( $args[ $key ] ) && $args[ $key ] == 'custom' ) { |
|
| 1994 | + continue; |
|
| 1995 | + } |
|
| 1996 | + if ( ! empty( $args[ $key ] ) ) { |
|
| 1997 | + $classes[] = sd_sanitize_html_classes( $args[ $key ] ); |
|
| 1998 | + } |
|
| 1999 | + } |
|
| 2000 | + } |
|
| 2001 | + } |
|
| 2002 | + |
|
| 2003 | + return implode( ' ', $classes ); |
|
| 2004 | 2004 | } |
| 2005 | 2005 | |
| 2006 | 2006 | /** |
@@ -2012,85 +2012,85 @@ discard block |
||
| 2012 | 2012 | */ |
| 2013 | 2013 | function sd_build_aui_styles( $args ) { |
| 2014 | 2014 | |
| 2015 | - $styles = array(); |
|
| 2016 | - |
|
| 2017 | - // background color |
|
| 2018 | - if ( ! empty( $args['bg'] ) && $args['bg'] !== '' ) { |
|
| 2019 | - if ( $args['bg'] == 'custom-color' ) { |
|
| 2020 | - $styles['background-color'] = $args['bg_color']; |
|
| 2021 | - } elseif ( $args['bg'] == 'custom-gradient' ) { |
|
| 2022 | - $styles['background-image'] = $args['bg_gradient']; |
|
| 2023 | - |
|
| 2024 | - // use background on text. |
|
| 2025 | - if ( ! empty( $args['bg_on_text'] ) && $args['bg_on_text'] ) { |
|
| 2026 | - $styles['background-clip'] = 'text'; |
|
| 2027 | - $styles['-webkit-background-clip'] = 'text'; |
|
| 2028 | - $styles['text-fill-color'] = 'transparent'; |
|
| 2029 | - $styles['-webkit-text-fill-color'] = 'transparent'; |
|
| 2030 | - } |
|
| 2031 | - } |
|
| 2032 | - } |
|
| 2033 | - |
|
| 2034 | - if ( ! empty( $args['bg_image'] ) && $args['bg_image'] !== '' ) { |
|
| 2035 | - $hasImage = true; |
|
| 2036 | - if ( ! empty( $styles['background-color'] ) && $args['bg'] == 'custom-color' ) { |
|
| 2037 | - $styles['background-image'] = 'url(' . $args['bg_image'] . ')'; |
|
| 2038 | - $styles['background-blend-mode'] = 'overlay'; |
|
| 2039 | - } elseif ( ! empty( $styles['background-image'] ) && $args['bg'] == 'custom-gradient' ) { |
|
| 2040 | - $styles['background-image'] .= ',url(' . $args['bg_image'] . ')'; |
|
| 2041 | - } elseif ( ! empty( $args['bg'] ) && $args['bg'] != '' && $args['bg'] != 'transparent' ) { |
|
| 2042 | - // do nothing as we alreay have a preset |
|
| 2043 | - $hasImage = false; |
|
| 2044 | - } else { |
|
| 2045 | - $styles['background-image'] = 'url(' . $args['bg_image'] . ')'; |
|
| 2046 | - } |
|
| 2047 | - |
|
| 2048 | - if ( $hasImage ) { |
|
| 2049 | - $styles['background-size'] = 'cover'; |
|
| 2050 | - |
|
| 2051 | - if ( ! empty( $args['bg_image_fixed'] ) && $args['bg_image_fixed'] ) { |
|
| 2052 | - $styles['background-attachment'] = 'fixed'; |
|
| 2053 | - } |
|
| 2054 | - } |
|
| 2055 | - |
|
| 2056 | - if ( $hasImage && ! empty( $args['bg_image_xy'] ) && ! empty( $args['bg_image_xy']['x'] ) ) { |
|
| 2057 | - $styles['background-position'] = ( $args['bg_image_xy']['x'] * 100 ) . '% ' . ( $args['bg_image_xy']['y'] * 100 ) . '%'; |
|
| 2058 | - } |
|
| 2059 | - } |
|
| 2060 | - |
|
| 2061 | - // sticky offset top |
|
| 2062 | - if ( ! empty( $args['sticky_offset_top'] ) && $args['sticky_offset_top'] !== '' ) { |
|
| 2063 | - $styles['top'] = absint( $args['sticky_offset_top'] ); |
|
| 2064 | - } |
|
| 2065 | - |
|
| 2066 | - // sticky offset bottom |
|
| 2067 | - if ( ! empty( $args['sticky_offset_bottom'] ) && $args['sticky_offset_bottom'] !== '' ) { |
|
| 2068 | - $styles['bottom'] = absint( $args['sticky_offset_bottom'] ); |
|
| 2069 | - } |
|
| 2070 | - |
|
| 2071 | - // font size |
|
| 2072 | - if ( ! empty( $args['font_size_custom'] ) && $args['font_size_custom'] !== '' ) { |
|
| 2073 | - $styles['font-size'] = (float) $args['font_size_custom'] . 'rem'; |
|
| 2074 | - } |
|
| 2075 | - |
|
| 2076 | - // font color |
|
| 2077 | - if ( ! empty( $args['text_color_custom'] ) && $args['text_color_custom'] !== '' ) { |
|
| 2078 | - $styles['color'] = esc_attr( $args['text_color_custom'] ); |
|
| 2079 | - } |
|
| 2080 | - |
|
| 2081 | - // font line height |
|
| 2082 | - if ( ! empty( $args['font_line_height'] ) && $args['font_line_height'] !== '' ) { |
|
| 2083 | - $styles['line-height'] = esc_attr( $args['font_line_height'] ); |
|
| 2084 | - } |
|
| 2085 | - |
|
| 2086 | - $style_string = ''; |
|
| 2087 | - if ( ! empty( $styles ) ) { |
|
| 2088 | - foreach ( $styles as $key => $val ) { |
|
| 2089 | - $style_string .= esc_attr( $key ) . ':' . esc_attr( $val ) . ';'; |
|
| 2090 | - } |
|
| 2091 | - } |
|
| 2092 | - |
|
| 2093 | - return $style_string; |
|
| 2015 | + $styles = array(); |
|
| 2016 | + |
|
| 2017 | + // background color |
|
| 2018 | + if ( ! empty( $args['bg'] ) && $args['bg'] !== '' ) { |
|
| 2019 | + if ( $args['bg'] == 'custom-color' ) { |
|
| 2020 | + $styles['background-color'] = $args['bg_color']; |
|
| 2021 | + } elseif ( $args['bg'] == 'custom-gradient' ) { |
|
| 2022 | + $styles['background-image'] = $args['bg_gradient']; |
|
| 2023 | + |
|
| 2024 | + // use background on text. |
|
| 2025 | + if ( ! empty( $args['bg_on_text'] ) && $args['bg_on_text'] ) { |
|
| 2026 | + $styles['background-clip'] = 'text'; |
|
| 2027 | + $styles['-webkit-background-clip'] = 'text'; |
|
| 2028 | + $styles['text-fill-color'] = 'transparent'; |
|
| 2029 | + $styles['-webkit-text-fill-color'] = 'transparent'; |
|
| 2030 | + } |
|
| 2031 | + } |
|
| 2032 | + } |
|
| 2033 | + |
|
| 2034 | + if ( ! empty( $args['bg_image'] ) && $args['bg_image'] !== '' ) { |
|
| 2035 | + $hasImage = true; |
|
| 2036 | + if ( ! empty( $styles['background-color'] ) && $args['bg'] == 'custom-color' ) { |
|
| 2037 | + $styles['background-image'] = 'url(' . $args['bg_image'] . ')'; |
|
| 2038 | + $styles['background-blend-mode'] = 'overlay'; |
|
| 2039 | + } elseif ( ! empty( $styles['background-image'] ) && $args['bg'] == 'custom-gradient' ) { |
|
| 2040 | + $styles['background-image'] .= ',url(' . $args['bg_image'] . ')'; |
|
| 2041 | + } elseif ( ! empty( $args['bg'] ) && $args['bg'] != '' && $args['bg'] != 'transparent' ) { |
|
| 2042 | + // do nothing as we alreay have a preset |
|
| 2043 | + $hasImage = false; |
|
| 2044 | + } else { |
|
| 2045 | + $styles['background-image'] = 'url(' . $args['bg_image'] . ')'; |
|
| 2046 | + } |
|
| 2047 | + |
|
| 2048 | + if ( $hasImage ) { |
|
| 2049 | + $styles['background-size'] = 'cover'; |
|
| 2050 | + |
|
| 2051 | + if ( ! empty( $args['bg_image_fixed'] ) && $args['bg_image_fixed'] ) { |
|
| 2052 | + $styles['background-attachment'] = 'fixed'; |
|
| 2053 | + } |
|
| 2054 | + } |
|
| 2055 | + |
|
| 2056 | + if ( $hasImage && ! empty( $args['bg_image_xy'] ) && ! empty( $args['bg_image_xy']['x'] ) ) { |
|
| 2057 | + $styles['background-position'] = ( $args['bg_image_xy']['x'] * 100 ) . '% ' . ( $args['bg_image_xy']['y'] * 100 ) . '%'; |
|
| 2058 | + } |
|
| 2059 | + } |
|
| 2060 | + |
|
| 2061 | + // sticky offset top |
|
| 2062 | + if ( ! empty( $args['sticky_offset_top'] ) && $args['sticky_offset_top'] !== '' ) { |
|
| 2063 | + $styles['top'] = absint( $args['sticky_offset_top'] ); |
|
| 2064 | + } |
|
| 2065 | + |
|
| 2066 | + // sticky offset bottom |
|
| 2067 | + if ( ! empty( $args['sticky_offset_bottom'] ) && $args['sticky_offset_bottom'] !== '' ) { |
|
| 2068 | + $styles['bottom'] = absint( $args['sticky_offset_bottom'] ); |
|
| 2069 | + } |
|
| 2070 | + |
|
| 2071 | + // font size |
|
| 2072 | + if ( ! empty( $args['font_size_custom'] ) && $args['font_size_custom'] !== '' ) { |
|
| 2073 | + $styles['font-size'] = (float) $args['font_size_custom'] . 'rem'; |
|
| 2074 | + } |
|
| 2075 | + |
|
| 2076 | + // font color |
|
| 2077 | + if ( ! empty( $args['text_color_custom'] ) && $args['text_color_custom'] !== '' ) { |
|
| 2078 | + $styles['color'] = esc_attr( $args['text_color_custom'] ); |
|
| 2079 | + } |
|
| 2080 | + |
|
| 2081 | + // font line height |
|
| 2082 | + if ( ! empty( $args['font_line_height'] ) && $args['font_line_height'] !== '' ) { |
|
| 2083 | + $styles['line-height'] = esc_attr( $args['font_line_height'] ); |
|
| 2084 | + } |
|
| 2085 | + |
|
| 2086 | + $style_string = ''; |
|
| 2087 | + if ( ! empty( $styles ) ) { |
|
| 2088 | + foreach ( $styles as $key => $val ) { |
|
| 2089 | + $style_string .= esc_attr( $key ) . ':' . esc_attr( $val ) . ';'; |
|
| 2090 | + } |
|
| 2091 | + } |
|
| 2092 | + |
|
| 2093 | + return $style_string; |
|
| 2094 | 2094 | |
| 2095 | 2095 | } |
| 2096 | 2096 | |
@@ -2103,19 +2103,19 @@ discard block |
||
| 2103 | 2103 | * @return string |
| 2104 | 2104 | */ |
| 2105 | 2105 | function sd_sanitize_html_classes( $classes, $sep = ' ' ) { |
| 2106 | - $return = ''; |
|
| 2106 | + $return = ''; |
|
| 2107 | 2107 | |
| 2108 | - if ( ! is_array( $classes ) ) { |
|
| 2109 | - $classes = explode( $sep, $classes ); |
|
| 2110 | - } |
|
| 2108 | + if ( ! is_array( $classes ) ) { |
|
| 2109 | + $classes = explode( $sep, $classes ); |
|
| 2110 | + } |
|
| 2111 | 2111 | |
| 2112 | - if ( ! empty( $classes ) ) { |
|
| 2113 | - foreach ( $classes as $class ) { |
|
| 2114 | - $return .= sanitize_html_class( $class ) . ' '; |
|
| 2115 | - } |
|
| 2116 | - } |
|
| 2112 | + if ( ! empty( $classes ) ) { |
|
| 2113 | + foreach ( $classes as $class ) { |
|
| 2114 | + $return .= sanitize_html_class( $class ) . ' '; |
|
| 2115 | + } |
|
| 2116 | + } |
|
| 2117 | 2117 | |
| 2118 | - return $return; |
|
| 2118 | + return $return; |
|
| 2119 | 2119 | } |
| 2120 | 2120 | |
| 2121 | 2121 | |
@@ -2125,25 +2125,25 @@ discard block |
||
| 2125 | 2125 | * @return void |
| 2126 | 2126 | */ |
| 2127 | 2127 | function sd_get_class_build_keys() { |
| 2128 | - $keys = array( |
|
| 2129 | - 'container', |
|
| 2130 | - 'position', |
|
| 2131 | - 'flex_direction', |
|
| 2132 | - 'shadow', |
|
| 2133 | - 'rounded', |
|
| 2134 | - 'nav_style', |
|
| 2135 | - 'horizontal_alignment', |
|
| 2136 | - 'nav_fill', |
|
| 2137 | - 'width', |
|
| 2138 | - 'font_weight', |
|
| 2139 | - 'font_size', |
|
| 2140 | - 'font_case', |
|
| 2141 | - 'css_class', |
|
| 2142 | - 'flex_align_items-MTD', |
|
| 2143 | - 'flex_justify_content-MTD', |
|
| 2144 | - 'flex_align_self-MTD', |
|
| 2145 | - 'flex_order-MTD', |
|
| 2146 | - ); |
|
| 2147 | - |
|
| 2148 | - return apply_filters( 'sd_class_build_keys', $keys ); |
|
| 2128 | + $keys = array( |
|
| 2129 | + 'container', |
|
| 2130 | + 'position', |
|
| 2131 | + 'flex_direction', |
|
| 2132 | + 'shadow', |
|
| 2133 | + 'rounded', |
|
| 2134 | + 'nav_style', |
|
| 2135 | + 'horizontal_alignment', |
|
| 2136 | + 'nav_fill', |
|
| 2137 | + 'width', |
|
| 2138 | + 'font_weight', |
|
| 2139 | + 'font_size', |
|
| 2140 | + 'font_case', |
|
| 2141 | + 'css_class', |
|
| 2142 | + 'flex_align_items-MTD', |
|
| 2143 | + 'flex_justify_content-MTD', |
|
| 2144 | + 'flex_align_self-MTD', |
|
| 2145 | + 'flex_order-MTD', |
|
| 2146 | + ); |
|
| 2147 | + |
|
| 2148 | + return apply_filters( 'sd_class_build_keys', $keys ); |
|
| 2149 | 2149 | } |
@@ -19,16 +19,16 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | // Define constants. |
| 21 | 21 | if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) { |
| 22 | - define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
| 22 | + define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | if ( ! defined( 'WPINV_VERSION' ) ) { |
| 26 | - define( 'WPINV_VERSION', '2.6.18' ); |
|
| 26 | + define( 'WPINV_VERSION', '2.6.18' ); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | // Include the main Invoicing class. |
| 30 | 30 | if ( ! class_exists( 'WPInv_Plugin', false ) ) { |
| 31 | - require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php'; |
|
| 31 | + require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php'; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | $GLOBALS['invoicing'] = new WPInv_Plugin(); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - return $GLOBALS['invoicing']; |
|
| 46 | + return $GLOBALS['invoicing']; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |