| @@ -78,8 +78,9 @@ | ||
| 78 | 78 | add_action('after_setup_theme', array('ThemeAtelier\Darkify\Admin\Framework\Classes\Darkify', 'setup')); |
| 79 | 79 | add_action('init', array('ThemeAtelier\Darkify\Admin\Framework\Classes\Darkify', 'setup')); |
| 80 | 80 | add_action('switch_theme', array('ThemeAtelier\Darkify\Admin\Framework\Classes\Darkify', 'setup')); |
| 81 | 81 | add_action('admin_enqueue_scripts', array('ThemeAtelier\Darkify\Admin\Framework\Classes\Darkify', 'add_admin_enqueue_scripts')); |
| 82 | + add_action('wp_enqueue_scripts', array('ThemeAtelier\Darkify\Admin\Framework\Classes\Darkify', 'add_typography_enqueue_styles'), 80); | |
| 82 | 83 | add_action('wp_head', array('ThemeAtelier\Darkify\Admin\Framework\Classes\Darkify', 'add_custom_css'), 80); |
| 83 | 84 | add_filter('admin_body_class', array('ThemeAtelier\Darkify\Admin\Framework\Classes\Darkify', 'add_admin_body_class')); |
| 84 | 85 | } |
| 85 | 86 | |
| @@ -110,8 +111,139 @@ | ||
| 110 | 111 | } |
| 111 | 112 | } |
| 112 | 113 | } |
| 113 | 114 | } |
| 115 | + | |
| 116 | + // Setup customize option framework | |
| 117 | + $params = array(); | |
| 118 | + if (class_exists('DarkifyCustomizeOptions') && ! empty(self::$args['customize_options'])) { | |
| 119 | + foreach (self::$args['customize_options'] as $key => $value) { | |
| 120 | + if (! empty(self::$args['sections'][$key]) && ! isset(self::$inited[$key])) { | |
| 121 | + | |
| 122 | + $params['args'] = $value; | |
| 123 | + $params['sections'] = self::$args['sections'][$key]; | |
| 124 | + self::$inited[$key] = true; | |
| 125 | + | |
| 126 | + DarkifyCustomizeOptions::instance($key, $params); | |
| 127 | + } | |
| 128 | + } | |
| 129 | + } | |
| 130 | + | |
| 131 | + // Setup metabox option framework | |
| 132 | + $params = array(); | |
| 133 | + if (class_exists('DarkifyMetabox') && ! empty(self::$args['metabox_options'])) { | |
| 134 | + foreach (self::$args['metabox_options'] as $key => $value) { | |
| 135 | + if (! empty(self::$args['sections'][$key]) && ! isset(self::$inited[$key])) { | |
| 136 | + | |
| 137 | + $params['args'] = $value; | |
| 138 | + $params['sections'] = self::$args['sections'][$key]; | |
| 139 | + self::$inited[$key] = true; | |
| 140 | + | |
| 141 | + DarkifyMetabox::instance($key, $params); | |
| 142 | + } | |
| 143 | + } | |
| 144 | + } | |
| 145 | + | |
| 146 | + // Setup nav menu option framework | |
| 147 | + $params = array(); | |
| 148 | + if (class_exists('DarkifyNavMenuOptions') && ! empty(self::$args['nav_menu_options'])) { | |
| 149 | + foreach (self::$args['nav_menu_options'] as $key => $value) { | |
| 150 | + if (! empty(self::$args['sections'][$key]) && ! isset(self::$inited[$key])) { | |
| 151 | + | |
| 152 | + $params['args'] = $value; | |
| 153 | + $params['sections'] = self::$args['sections'][$key]; | |
| 154 | + self::$inited[$key] = true; | |
| 155 | + | |
| 156 | + DarkifyNavMenuOptions::instance($key, $params); | |
| 157 | + } | |
| 158 | + } | |
| 159 | + } | |
| 160 | + | |
| 161 | + // Setup profile option framework | |
| 162 | + $params = array(); | |
| 163 | + if (class_exists('DarkifyProfileOptions') && ! empty(self::$args['profile_options'])) { | |
| 164 | + foreach (self::$args['profile_options'] as $key => $value) { | |
| 165 | + if (! empty(self::$args['sections'][$key]) && ! isset(self::$inited[$key])) { | |
| 166 | + | |
| 167 | + $params['args'] = $value; | |
| 168 | + $params['sections'] = self::$args['sections'][$key]; | |
| 169 | + self::$inited[$key] = true; | |
| 170 | + | |
| 171 | + DarkifyProfileOptions::instance($key, $params); | |
| 172 | + } | |
| 173 | + } | |
| 174 | + } | |
| 175 | + | |
| 176 | + // Setup taxonomy option framework | |
| 177 | + $params = array(); | |
| 178 | + if (class_exists('DarkifyTaxonomyOptions') && ! empty(self::$args['taxonomy_options'])) { | |
| 179 | + $taxonomy = (isset($_GET['taxonomy'])) ? sanitize_text_field(wp_unslash($_GET['taxonomy'])) : ''; | |
| 180 | + foreach (self::$args['taxonomy_options'] as $key => $value) { | |
| 181 | + if (! empty(self::$args['sections'][$key]) && ! isset(self::$inited[$key])) { | |
| 182 | + | |
| 183 | + $params['args'] = $value; | |
| 184 | + $params['sections'] = self::$args['sections'][$key]; | |
| 185 | + self::$inited[$key] = true; | |
| 186 | + | |
| 187 | + DarkifyTaxonomyOptions::instance($key, $params); | |
| 188 | + } | |
| 189 | + } | |
| 190 | + } | |
| 191 | + | |
| 192 | + // Setup widget option framework | |
| 193 | + if (class_exists('DarkifyWidget') && class_exists('WP_Widget_Factory') && ! empty(self::$args['widget_options'])) { | |
| 194 | + $wp_widget_factory = new WP_Widget_Factory(); | |
| 195 | + global $wp_widget_factory; | |
| 196 | + foreach (self::$args['widget_options'] as $key => $value) { | |
| 197 | + if (! isset(self::$inited[$key])) { | |
| 198 | + | |
| 199 | + self::$inited[$key] = true; | |
| 200 | + $wp_widget_factory->register(DarkifyWidget::instance($key, $value)); | |
| 201 | + } | |
| 202 | + } | |
| 203 | + } | |
| 204 | + | |
| 205 | + // Setup comment option framework | |
| 206 | + $params = array(); | |
| 207 | + if (class_exists('DarkifyCommentMetabox') && ! empty(self::$args['comment_options'])) { | |
| 208 | + foreach (self::$args['comment_options'] as $key => $value) { | |
| 209 | + if (! empty(self::$args['sections'][$key]) && ! isset(self::$inited[$key])) { | |
| 210 | + | |
| 211 | + $params['args'] = $value; | |
| 212 | + $params['sections'] = self::$args['sections'][$key]; | |
| 213 | + self::$inited[$key] = true; | |
| 214 | + | |
| 215 | + DarkifyCommentMetabox::instance($key, $params); | |
| 216 | + } | |
| 217 | + } | |
| 218 | + } | |
| 219 | + | |
| 220 | + // Setup shortcode option framework | |
| 221 | + $params = array(); | |
| 222 | + if (class_exists('DarkifyShortcoder') && ! empty(self::$args['shortcode_options'])) { | |
| 223 | + foreach (self::$args['shortcode_options'] as $key => $value) { | |
| 224 | + if (! empty(self::$args['sections'][$key]) && ! isset(self::$inited[$key])) { | |
| 225 | + | |
| 226 | + $params['args'] = $value; | |
| 227 | + $params['sections'] = self::$args['sections'][$key]; | |
| 228 | + self::$inited[$key] = true; | |
| 229 | + | |
| 230 | + DarkifyShortcoder::instance($key, $params); | |
| 231 | + } | |
| 232 | + } | |
| 233 | + | |
| 234 | + // Once editor setup for gutenberg and media buttons | |
| 235 | + if (class_exists('DarkifyShortcoder') && ! empty(self::$shortcode_instances)) { | |
| 236 | + foreach (self::$shortcode_instances as $instance) { | |
| 237 | + if (! empty($instance['show_in_editor'])) { | |
| 238 | + DarkifyShortcoder::once_editor_setup(); | |
| 239 | + break; | |
| 240 | + } | |
| 241 | + } | |
| 242 | + } | |
| 243 | + } | |
| 244 | + | |
| 245 | + do_action('darkify_loaded'); | |
| 114 | 246 | } |
| 115 | 247 | |
| 116 | 248 | // Create options |
| 117 | 249 | public static function createOptions($id, $args = array()) |
| @@ -286,11 +418,12 @@ | ||
| 286 | 418 | 'group', |
| 287 | 419 | 'heading', |
| 288 | 420 | 'icon', |
| 289 | 421 | 'image_select', |
| 422 | + 'layout_preset', | |
| 290 | 423 | 'link', |
| 291 | 424 | 'link_color', |
| 292 | - 'license', | |
| 425 | + 'map', | |
| 293 | 426 | 'media', |
| 294 | 427 | 'notice', |
| 295 | 428 | 'number', |
| 296 | 429 | 'palette', |
| @@ -304,12 +437,9 @@ | ||
| 304 | 437 | 'spinner', |
| 305 | 438 | 'subheading', |
| 306 | 439 | 'submessage', |
| 307 | 440 | 'switcher_shortcode', |
| 308 | - 'switcher_shortcode_v2', | |
| 309 | 441 | 'switcher', |
| 310 | - 'section_tab', | |
| 311 | - 'section_inner_tab', | |
| 312 | 442 | 'tabbed', |
| 313 | 443 | 'ta_help', |
| 314 | 444 | 'text', |
| 315 | 445 | 'textarea', |
| @@ -340,11 +470,8 @@ | ||
| 340 | 470 | |
| 341 | 471 | if (! empty($field['tabs'])) { |
| 342 | 472 | self::set_used_fields(array('fields' => $field['tabs'])); |
| 343 | 473 | } |
| 344 | - if (! empty($field['tabs'])) { | |
| 345 | - self::set_used_fields(array('fields' => $field['tabs'])); | |
| 346 | - } | |
| 347 | 474 | |
| 348 | 475 | if (! empty($field['accordions'])) { |
| 349 | 476 | self::set_used_fields(array('fields' => $field['accordions'])); |
| 350 | 477 | } |
| @@ -440,20 +567,25 @@ | ||
| 440 | 567 | // Check for developer mode |
| 441 | 568 | $min = (self::$premium && SCRIPT_DEBUG) ? '' : '.min'; |
| 442 | 569 | |
| 443 | 570 | // Main style |
| 571 | + wp_enqueue_style('darkify', self::include_plugin_url('assets/css/style' . $min . '.css'), array(), self::$version, 'all'); | |
| 572 | + | |
| 573 | + // Main RTL styles | |
| 444 | 574 | if (is_rtl()) { |
| 445 | 575 | wp_enqueue_style('darkify-rtl', self::include_plugin_url('assets/css/style-rtl' . $min . '.css'), array(), self::$version, 'all'); |
| 446 | - } else { | |
| 447 | - wp_enqueue_style('darkify', self::include_plugin_url('assets/css/style' . $min . '.css'), array(), self::$version, 'all'); | |
| 448 | 576 | } |
| 449 | 577 | |
| 450 | - // IcoFont Css | |
| 451 | - wp_enqueue_style('icofont', self::include_plugin_url('assets/css/icofont' . $min . '.css'), array(), self::$version, 'all'); | |
| 578 | + // Custom style | |
| 579 | + wp_enqueue_style('taf-custom', self::include_plugin_url('assets/css/taf-custom' . $min . '.css'), array(), self::$version, 'all'); | |
| 452 | 580 | |
| 581 | + // Custom Styles | |
| 582 | + wp_enqueue_style('darkify-help-page', self::include_plugin_url('assets/css/help-page' . $min . '.css'), array(), self::$version, 'all'); | |
| 583 | + | |
| 453 | 584 | // Main scripts |
| 454 | 585 | wp_enqueue_script('darkify-plugins', self::include_plugin_url('assets/js/plugins' . $min . '.js'), array(), self::$version, true); |
| 455 | 586 | wp_enqueue_script('darkify', self::include_plugin_url('assets/js/main' . $min . '.js'), array('darkify-plugins'), self::$version, true); |
| 587 | + wp_enqueue_script('darkify-help-page', self::include_plugin_url('assets/js/help-page' . $min . '.js'), array('darkify-plugins'), self::$version, true); | |
| 456 | 588 | |
| 457 | 589 | // Main variables |
| 458 | 590 | wp_localize_script('darkify', 'darkify_vars', array( |
| 459 | 591 | 'color_palette' => apply_filters('darkify_color_palette', array()), |
| @@ -458,15 +590,13 @@ | ||
| 458 | 590 | wp_localize_script('darkify', 'darkify_vars', array( |
| 459 | 591 | 'color_palette' => apply_filters('darkify_color_palette', array()), |
| 460 | 592 | 'i18n' => array( |
| 461 | 593 | 'confirm' => esc_html__('Are you sure?', 'darkify'), |
| 462 | - | |
| 463 | - /* translators: %s: modify typing text. */ | |
| 464 | 594 | 'typing_text' => esc_html__('Please enter %s or more characters', 'darkify'), |
| 465 | 595 | 'searching_text' => esc_html__('Searching...', 'darkify'), |
| 466 | 596 | 'no_results_text' => esc_html__('No results found.', 'darkify'), |
| 467 | 597 | ), |
| 468 | - 'darkify_ajaxurl' => admin_url('admin-ajax.php'), | |
| 598 | + 'ajaxurl' => admin_url('admin-ajax.php'), | |
| 469 | 599 | 'nonce' => wp_create_nonce('save_options'), |
| 470 | 600 | )); |
| 471 | 601 | |
| 472 | 602 | // Enqueue fields scripts and styles |
| @@ -489,8 +619,49 @@ | ||
| 489 | 619 | |
| 490 | 620 | do_action('darkify_enqueue'); |
| 491 | 621 | } |
| 492 | 622 | |
| 623 | + // Add typography enqueue styles to front page | |
| 624 | + public static function add_typography_enqueue_styles() | |
| 625 | + { | |
| 626 | + | |
| 627 | + if (! empty(self::$webfonts)) { | |
| 628 | + | |
| 629 | + if (! empty(self::$webfonts['enqueue'])) { | |
| 630 | + | |
| 631 | + $query = array(); | |
| 632 | + $fonts = array(); | |
| 633 | + | |
| 634 | + foreach (self::$webfonts['enqueue'] as $family => $styles) { | |
| 635 | + $fonts[] = $family . ((! empty($styles)) ? ':' . implode(',', $styles) : ''); | |
| 636 | + } | |
| 637 | + | |
| 638 | + if (! empty($fonts)) { | |
| 639 | + $query['family'] = implode('%7C', $fonts); | |
| 640 | + } | |
| 641 | + | |
| 642 | + if (! empty(self::$subsets)) { | |
| 643 | + $query['subset'] = implode(',', self::$subsets); | |
| 644 | + } | |
| 645 | + | |
| 646 | + $query['display'] = 'swap'; | |
| 647 | + | |
| 648 | + wp_enqueue_style('darkify-google-web-fonts', esc_url(add_query_arg($query, '//fonts.googleapis.com/css')), array(), null); | |
| 649 | + } | |
| 650 | + | |
| 651 | + if (! empty(self::$webfonts['async'])) { | |
| 652 | + | |
| 653 | + $fonts = array(); | |
| 654 | + | |
| 655 | + foreach (self::$webfonts['async'] as $family => $styles) { | |
| 656 | + $fonts[] = $family . ((! empty($styles)) ? ':' . implode(',', $styles) : ''); | |
| 657 | + } | |
| 658 | + wp_enqueue_script('darkify-google-web-fonts', self::include_plugin_url('assets/js/webfont.js'), array(), self::$version, true); | |
| 659 | + wp_localize_script('darkify-google-web-fonts', 'WebFontConfig', array('google' => array('families' => $fonts))); | |
| 660 | + } | |
| 661 | + } | |
| 662 | + } | |
| 663 | + | |
| 493 | 664 | // Add admin body class |
| 494 | 665 | public static function add_admin_body_class($classes) |
| 495 | 666 | { |
| 496 | 667 | |
| @@ -568,23 +739,10 @@ | ||
| 568 | 739 | |
| 569 | 740 | if (! empty($field_type)) { |
| 570 | 741 | |
| 571 | 742 | if (! empty($field['title'])) { |
| 572 | - $title_help = ''; | |
| 573 | - if (! empty($field['title_help']) || ! empty($field['title_video'])) { | |
| 574 | - $help_text = ! empty($field['title_help']) ? $field['title_help'] : ''; | |
| 575 | - $icon_type = ! empty($field['title_video']) ? 'video_info.svg' : 'info.svg'; | |
| 576 | - $video_help_attr = ! empty($field['title_video']) ? ' title-video-help' : ''; | |
| 577 | - $title_help = sprintf('<span class="darkify-help darkify-title-help"> | |
| 578 | - <span class="darkify-help-text' . esc_attr($video_help_attr) . '">%s</span> | |
| 579 | - <span class="tooltip-icon"> | |
| 580 | - <img src="%s"> | |
| 581 | - </span> | |
| 582 | - </span>', $help_text . (! empty($field['title_video']) ? $field['title_video'] : ''), self::include_plugin_url('assets/images/' . $icon_type)); | |
| 583 | - } | |
| 584 | - | |
| 585 | 743 | echo '<div class="darkify-title">'; |
| 586 | - echo '<h4>' . wp_kses_post($field['title']) . $title_help . '</h4>'; // phpcs:ignore -- Attributes are escaped above. | |
| 744 | + echo '<h4>' . esc_html($field['title']) . '</h4>'; | |
| 587 | 745 | echo (! empty($field['subtitle'])) ? '<div class="darkify-subtitle-text">' . wp_kses_post($field['subtitle']) . '</div>' : ''; |
| 588 | 746 | echo '</div>'; |
| 589 | 747 | } |
| 590 | 748 | |