Customify – A Theme Customizer Booster - Version 1.5.0

Version Description

  • Plugin core refactored for a better performance
  • Fixed Font Weight saving
  • Fixed Font Subset saving
  • Fix Select2 enqueue_script
Download this release

Release Info

Developer euthelup
Plugin Icon Customify – A Theme Customizer Booster
Version 1.5.0
Comparing to
See all releases

Code changes from version 1.4.2 to 1.5.0

README.md CHANGED
@@ -1,4 +1,4 @@
1
- Customify [![Build Status](https://travis-ci.org/pixelgrade/customify.svg?branch=wporg)](https://travis-ci.org/pixelgrade/customify)
2
  ========
3
  **A Theme Customizer Booster**
4
 
@@ -466,4 +466,4 @@ This plugin also includes the following libraries:
466
 
467
  * Select 2 - https://select2.github.io/
468
  * Ace Editor - https://ace.c9.io/
469
- * React jQuery Plugin - https://github.com/natedavisolds/jquery-react
1
+ Customify [![Build Status](https://travis-ci.org/pixelgrade/customify.svg?branch=wporg)](https://travis-ci.org/pixelgrade/customify) [![Code Climate](https://lima.codeclimate.com/github/pixelgrade/customify/badges/gpa.svg)](https://lima.codeclimate.com/github/pixelgrade/customify) [![Issue Count](https://lima.codeclimate.com/github/pixelgrade/customify/badges/issue_count.svg)](https://lima.codeclimate.com/github/pixelgrade/customify)
2
  ========
3
  **A Theme Customizer Booster**
4
 
466
 
467
  * Select 2 - https://select2.github.io/
468
  * Ace Editor - https://ace.c9.io/
469
+ * React jQuery Plugin - https://github.com/natedavisolds/jquery-react
class-pixcustomify.php CHANGED
@@ -4,8 +4,8 @@
4
  * @package PixCustomify
5
  * @author Pixelgrade <contact@pixelgrade.com>
6
  * @license GPL-2.0+
7
- * @link http://pixelgrade.com
8
- * @copyright 2014 Pixelgrade
9
  */
10
 
11
  /**
@@ -17,10 +17,10 @@ class PixCustomifyPlugin {
17
 
18
  /**
19
  * Plugin version, used for cache-busting of style and script file references.
20
- * @since 1.0.0
21
  * @const string
22
  */
23
- protected $version = '1.4.2';
24
  /**
25
  * Unique identifier for your plugin.
26
  * Use this value (not the variable name) as the text domain when internationalizing strings of text. It should
@@ -32,10 +32,10 @@ class PixCustomifyPlugin {
32
 
33
  /**
34
  * Instance of this class.
35
- * @since 1.0.0
36
  * @var object
37
  */
38
- protected static $instance = null;
39
 
40
  /**
41
  * Slug of the plugin screen.
@@ -53,27 +53,27 @@ class PixCustomifyPlugin {
53
 
54
  public $display_admin_menu = false;
55
 
56
- private static $config;
57
 
58
- private static $customizer_config;
59
 
60
- public static $plugin_settings;
61
 
62
- protected static $localized = array();
63
 
64
- protected static $current_values = array();
65
 
66
- protected static $options_list = array();
67
 
68
- protected static $media_queries = array();
69
 
70
- protected static $opt_name;
71
 
72
- protected static $typo_settings;
73
 
74
- protected static $google_fonts = null;
75
 
76
- protected static $theme_fonts = null;
77
 
78
  // these properties will get 'px' as a default unit
79
  protected static $pixel_dependent_css_properties = array(
@@ -113,45 +113,103 @@ class PixCustomifyPlugin {
113
  'border-top-width'
114
  );
115
 
116
- protected static $jetpack_default_modules = array();
117
- protected static $jetpack_blocked_modules = array();
118
- protected static $jetpack_sharing_default_options = array();
119
 
120
  /**
121
- * Initialize the plugin by setting localization, filters, and administration functions.
122
- * @since 1.0.0
 
 
123
  */
124
- protected function __construct() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
 
126
- $this->plugin_basepath = plugin_dir_path( __FILE__ );
127
- self::$config = self::get_config();
128
- self::$plugin_settings = get_option( 'pixcustomify_settings' );
 
 
129
 
130
- // load custom modules
131
- include_once( self::get_base_path() . '/features/class-CSS_Editor.php' );
132
- include_once( self::get_base_path() . 'features/class-Font_Selector.php' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
 
134
- // Load plugin text domain
 
 
135
  add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
136
 
137
- add_action( 'wp_loaded', array( $this, 'init_plugin_configs' ), 5 );
 
 
 
 
 
 
 
138
 
 
 
 
 
139
  add_action( 'admin_menu', array( $this, 'add_plugin_admin_menu' ) );
140
 
141
  // Add an action link pointing to the options page.
142
- $plugin_basename = plugin_basename( plugin_dir_path( __FILE__ ) . 'pixcustomify.php' );
143
  add_filter( 'plugin_action_links_' . $plugin_basename, array( $this, 'add_action_links' ) );
144
 
145
  // Load admin style sheet and JavaScript.
146
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) );
147
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
148
 
149
- // add_action( 'plugins_loaded', array( $this, 'register_metaboxes' ), 14 );
 
 
 
150
  add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_admin_customizer_styles' ), 10 );
151
  add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_admin_customizer_scripts' ), 10 );
152
  add_action( 'customize_preview_init', array( $this, 'customizer_live_preview_enqueue_scripts' ), 99999 );
153
 
154
- $load_location = self::get_plugin_option( 'style_resources_location', 'wp_head' );
155
 
156
  add_action( $load_location, array( $this, 'output_dynamic_style' ), 99999 );
157
  add_action( 'wp_head', array( $this, 'output_typography_dynamic_style' ), 10 );
@@ -159,11 +217,13 @@ class PixCustomifyPlugin {
159
  add_action( 'customize_register', array( $this, 'remove_default_sections' ), 11 );
160
  add_action( 'customize_register', array( $this, 'register_customizer' ), 12 );
161
 
162
- if ( self::get_plugin_option( 'enable_editor_style', true ) ) {
163
  add_action( 'admin_head', array( $this, 'add_customizer_settings_into_wp_editor' ) );
164
  }
165
 
166
- // Jetpack Related
 
 
167
  add_action( 'init', array( $this, 'set_jetpack_modules_config') );
168
  add_filter( 'default_option_jetpack_active_modules', array( $this, 'default_jetpack_active_modules' ), 10, 1 );
169
  add_filter( 'jetpack_get_available_modules', array( $this, 'jetpack_hide_blocked_modules'), 10, 1 );
@@ -171,59 +231,48 @@ class PixCustomifyPlugin {
171
  }
172
 
173
  /**
174
- * Return an instance of this class.
175
- * @since 1.0.0
176
- * @return object A single instance of this class.
177
  */
178
- public static function get_instance() {
 
179
 
180
- // If the single instance hasn't been set, set it now.
181
- if ( null == self::$instance ) {
182
- self::$instance = new self;
183
  }
184
 
185
- return self::$instance;
 
 
186
  }
187
 
188
  /**
189
- * Configs, Options and Values methods
190
  */
191
-
192
- function init_plugin_configs() {
193
- self::$customizer_config = get_option( 'pixcustomify_config' );
194
-
195
- // no option so go for default
196
- if ( empty( self::$customizer_config ) ) {
197
- self::$customizer_config = self::get_config_option( 'default_options' );
198
- }
199
-
200
- if ( empty( self::$customizer_config ) ) {
201
- self::$customizer_config = array();
202
- }
203
 
204
  // allow themes or other plugins to filter the config
205
- self::$customizer_config = apply_filters( 'customify_filter_fields', self::$customizer_config );
 
 
206
 
207
- self::$opt_name = self::$localized['options_name'] = self::$customizer_config['opt-name'];
208
-
209
- self::get_current_values();
210
- self::$options_list = $this->get_options();
211
 
212
  if ( $this->import_button_exists() ) {
213
- self::$opt_name = self::$localized['import_rest_url'] = get_rest_url( '/customify/1.0/' );
214
- self::$opt_name = self::$localized['import_rest_nonce'] = wp_create_nonce( 'wp_rest' );
215
 
216
  $this->register_import_api();
217
  }
218
 
219
- $font_selector = new Customify_Font_Selector( $this );
220
- self::$localized['theme_fonts'] = self::$theme_fonts = Customify_Font_Selector::$theme_fonts;
221
  }
222
 
223
  function set_jetpack_modules_config() {
224
  // We expect an array of string module names like array( 'infinite-scroll', 'widgets' )
225
  // See jetpack/modules/modules-heading.php for module names
226
- self::$jetpack_default_modules = apply_filters ( 'customify_filter_jetpack_default_modules', array(
227
  'shortcodes',
228
  'widget-visibility',
229
  'widgets',
@@ -231,9 +280,9 @@ class PixCustomifyPlugin {
231
 
232
  // We expect an array of string module names like array( 'infinite-scroll', 'widgets' )
233
  // See jetpack/modules/modules-heading.php for module names
234
- self::$jetpack_blocked_modules = apply_filters ( 'customify_filter_jetpack_blocked_modules', array() );
235
 
236
- self::$jetpack_sharing_default_options = apply_filters ( 'customify_filter_jetpack_sharing_default_options', array() );
237
  }
238
 
239
  /**
@@ -249,7 +298,7 @@ class PixCustomifyPlugin {
249
  $default = array();
250
  }
251
 
252
- return array_merge( $default, self::$jetpack_default_modules );
253
  }
254
 
255
  /**
@@ -266,7 +315,7 @@ class PixCustomifyPlugin {
266
  $default = array();
267
  }
268
 
269
- return array_merge( $default, self::$jetpack_sharing_default_options );
270
  }
271
 
272
  /**
@@ -278,7 +327,7 @@ class PixCustomifyPlugin {
278
  * @return array
279
  */
280
  function jetpack_hide_blocked_modules( $modules ) {
281
- return array_diff_key( $modules, array_flip( self::$jetpack_blocked_modules ) );
282
  }
283
 
284
  /**
@@ -288,7 +337,7 @@ class PixCustomifyPlugin {
288
  * @param boolean $network_wide True if WPMU superadmin uses "Network Activate" action, false if WPMU is disabled or plugin is activated on an individual blog.
289
  */
290
  public static function activate( $network_wide ) {
291
-
292
  }
293
 
294
  /**
@@ -298,7 +347,7 @@ class PixCustomifyPlugin {
298
  * @param boolean $network_wide True if WPMU superadmin uses "Network Deactivate" action, false if WPMU is disabled or plugin is deactivated on an individual blog.
299
  */
300
  static function deactivate( $network_wide ) {
301
- // TODO: Define deactivation functionality here
302
  }
303
 
304
  /**
@@ -307,7 +356,7 @@ class PixCustomifyPlugin {
307
  */
308
  function load_plugin_textdomain() {
309
  $domain = $this->plugin_slug;
310
- load_plugin_textdomain( $domain, false, basename( dirname( __FILE__ ) ) . '/languages/' );
311
  }
312
 
313
  /** === RESOURCES === **/
@@ -316,8 +365,8 @@ class PixCustomifyPlugin {
316
  * Customizer admin styles
317
  */
318
  function enqueue_admin_customizer_styles() {
319
- wp_enqueue_style( 'select2', plugins_url( 'js/select2/css/select2.css', __FILE__ ), array(), $this->version );
320
- wp_enqueue_style( 'customify_style', plugins_url( 'css/customizer.css', __FILE__ ), array(), $this->version );
321
  }
322
 
323
  /**
@@ -325,33 +374,34 @@ class PixCustomifyPlugin {
325
  */
326
  function enqueue_admin_customizer_scripts() {
327
 
328
- wp_enqueue_script( 'select2', plugins_url( 'js/select2/js/select2.js', __FILE__ ), array( 'jquery' ), $this->version );
329
- wp_enqueue_script( 'jquery-react', plugins_url( 'js/jquery-react.js', __FILE__ ), array( 'jquery' ), $this->version );
330
- wp_enqueue_script( $this->plugin_slug . '-customizer-scripts', plugins_url( 'js/customizer.js', __FILE__ ), array(
331
  'jquery',
332
- 'select2',
333
  'underscore',
334
  'customize-controls'
335
- ), $this->version );
336
 
337
- wp_localize_script( $this->plugin_slug . '-customizer-scripts', 'customify_settings', self::$localized );
338
  }
339
 
340
  /** Customizer scripts loaded only on previewer page */
341
  function customizer_live_preview_enqueue_scripts() {
342
 
343
- wp_register_script( $this->plugin_slug . 'CSSOM', plugins_url( 'js/CSSOM.js', __FILE__ ), array( 'jquery' ), $this->version, true );
344
- wp_register_script( $this->plugin_slug . 'cssUpdate', plugins_url( 'js/jquery.cssUpdate.js', __FILE__ ), array(), $this->version, true );
345
- wp_enqueue_script( $this->plugin_slug . '-previewer-scripts', plugins_url( 'js/customizer_preview.js', __FILE__ ), array(
346
  'jquery',
 
347
  $this->plugin_slug . 'CSSOM',
348
  $this->plugin_slug . 'cssUpdate'
349
- ), $this->version, true );
350
 
351
  // when a live preview field is in action we need to know which props need 'px' as defaults
352
- self::$localized['px_dependent_css_props'] = self::$pixel_dependent_css_properties;
353
 
354
- wp_localize_script( $this->plugin_slug . '-previewer-scripts', 'customify_settings', self::$localized );
355
  }
356
 
357
  /**
@@ -369,7 +419,7 @@ class PixCustomifyPlugin {
369
 
370
  $screen = get_current_screen();
371
  if ( $screen->id == $this->plugin_screen_hook_suffix ) {
372
- wp_enqueue_style( $this->plugin_slug . '-admin-styles', plugins_url( 'css/admin.css', __FILE__ ), array(), $this->version );
373
  }
374
  }
375
 
@@ -384,7 +434,7 @@ class PixCustomifyPlugin {
384
 
385
  $screen = get_current_screen();
386
  if ( $screen->id == $this->plugin_screen_hook_suffix ) {
387
- wp_enqueue_script( $this->plugin_slug . '-admin-script', plugins_url( 'js/admin.js', __FILE__ ), array( 'jquery' ), $this->version );
388
  wp_localize_script( $this->plugin_slug . '-admin-script', 'locals', array(
389
  'ajax_url' => admin_url( 'admin-ajax.php' )
390
  ) );
@@ -400,7 +450,7 @@ class PixCustomifyPlugin {
400
  function output_dynamic_style() {
401
  $custom_css = "\n";
402
 
403
- foreach ( self::$options_list as $option_id => $option ) {
404
 
405
  if ( isset( $option['css'] ) && ! empty( $option['css'] ) ) {
406
  // now process each
@@ -412,9 +462,9 @@ class PixCustomifyPlugin {
412
  }
413
  }
414
 
415
- if ( ! empty( self::$media_queries ) ) {
416
 
417
- foreach ( self::$media_queries as $media_query => $properties ) {
418
 
419
  if ( empty( $properties ) ) {
420
  continue;
@@ -425,7 +475,7 @@ class PixCustomifyPlugin {
425
  foreach ( $properties as $key => $property ) {
426
  $property_settings = $property['property'];
427
  $property_value = $property['value'];
428
- $custom_css .= self::proccess_css_property( $property_settings, $property_value );
429
  }
430
 
431
  $custom_css .= " }\n";
@@ -434,10 +484,8 @@ class PixCustomifyPlugin {
434
  }
435
 
436
  $custom_css .= "\n";
437
-
438
- //@todo maybe add a filter to this output ?>
439
- <style id="customify_output_style">
440
- <?php echo( $custom_css ); ?>
441
  </style><?php
442
 
443
  /**
@@ -448,10 +496,10 @@ class PixCustomifyPlugin {
448
  return;
449
  }
450
 
451
- foreach ( self::$options_list as $option_id => $options ) {
452
 
453
  if ( $options['type'] === 'custom_background' ) {
454
- $options['value'] = self::get_option( $option_id );
455
  $custom_background_output = $this->process_custom_background_field_output( $option_id, $options ); ?>
456
 
457
  <style id="custom_backgorund_output_for_<?php echo $option_id; ?>">
@@ -466,7 +514,7 @@ class PixCustomifyPlugin {
466
  continue;
467
  }
468
 
469
- $this_value = self::get_option( $option_id );
470
  foreach ( $options['css'] as $key => $properties_set ) { ?>
471
  <style id="dynamic_setting_<?php echo $option_id . '_property_' . str_replace( '-', '_', $properties_set['property'] ); ?>" type="text/css"><?php
472
 
@@ -475,7 +523,7 @@ class PixCustomifyPlugin {
475
  }
476
 
477
  if ( isset( $properties_set['selector'] ) && isset( $properties_set['property'] ) ) {
478
- echo self::proccess_css_property($properties_set, $this_value);
479
  }
480
 
481
  if ( isset( $properties_set['media'] ) && ! empty( $properties_set['media'] ) ) {
@@ -485,9 +533,9 @@ class PixCustomifyPlugin {
485
  <?php }
486
  }
487
 
488
- if ( ! empty( self::$media_queries ) ) {
489
 
490
- foreach ( self::$media_queries as $media_query => $properties ) {
491
 
492
  if ( empty( $properties ) ) {
493
  continue;
@@ -506,7 +554,7 @@ class PixCustomifyPlugin {
506
  <style id="dynamic_setting_<?php echo $key; ?>" type="text/css"><?php
507
  $property_settings = $property['property'];
508
  $property_value = $property['value'];
509
- $media_q .= "\t" . self::proccess_css_property( $property_settings, $property_value );?>
510
  </style>
511
  <?php }
512
 
@@ -520,31 +568,29 @@ class PixCustomifyPlugin {
520
  }
521
 
522
  protected function load_google_fonts() {
523
-
524
- $fonts_path = plugin_dir_path( __FILE__ ) . 'features/customizer/controls/resources/google.fonts.php';
525
 
526
  if ( file_exists( $fonts_path ) ) {
527
- self::$google_fonts = require( $fonts_path );
528
  }
529
 
530
- if ( ! empty( self::$google_fonts ) ) {
531
- return self::$google_fonts;
532
  }
533
 
534
  return false;
535
  }
536
 
537
  function output_typography_dynamic_style() {
 
538
 
539
- self::get_typography_fields( self::$options_list, 'type', 'typography', self::$typo_settings );
540
-
541
- if ( empty( self::$typo_settings ) ) {
542
  return;
543
  }
544
 
545
  $families = '';
546
 
547
- foreach ( self::$typo_settings as $id => $font ) {
548
  if ( isset ( $font['value'] ) ) {
549
 
550
  $load_all_weights = false;
@@ -571,7 +617,7 @@ class PixCustomifyPlugin {
571
  }
572
 
573
  //Handle special logic for when the $value array is not an associative array
574
- if ( ! self::is_assoc( $value ) ) {
575
  $value = $this->process_a_not_associative_font_default( $value );
576
  }
577
 
@@ -613,7 +659,7 @@ class PixCustomifyPlugin {
613
  }
614
  }
615
 
616
- if ( ! empty ( $families ) && self::get_plugin_option( 'typography', '1' ) && self::get_plugin_option( 'typography_google_fonts', 1 ) ) { ?>
617
  <script type="text/javascript">
618
  if ( typeof WebFont !== 'undefined' ) {<?php // if there is a WebFont object, use it ?>
619
  WebFont.load( {
@@ -642,7 +688,7 @@ class PixCustomifyPlugin {
642
  <?php } ?>
643
  <style id="customify_typography_output_style">
644
  <?php
645
- foreach ( self::$typo_settings as $key => $font ) {
646
  $load_all_weights = false;
647
  if ( isset( $font['load_all_weights'] ) && $font['load_all_weights'] == 'true' ) {
648
  $load_all_weights = true;
@@ -662,7 +708,7 @@ class PixCustomifyPlugin {
662
  }
663
 
664
  //Handle special logic for when the $value array is not an associative array
665
- if ( ! self::is_assoc( $value ) ) {
666
  $value = $this->process_a_not_associative_font_default( $value );
667
  }
668
 
@@ -739,7 +785,7 @@ class PixCustomifyPlugin {
739
  * Handle special logic for when the $value array is not an associative array
740
  * Return a new associative array with proper keys
741
  */
742
- protected function process_a_not_associative_font_default( $value ) {
743
 
744
  $new_value = array();
745
 
@@ -774,22 +820,22 @@ class PixCustomifyPlugin {
774
  *
775
  * @return null
776
  */
777
- protected function get_font_defaults_value( $font_name ) {
778
 
779
- if ( empty( self::$google_fonts ) ) {
780
  $this->load_google_fonts();
781
  }
782
 
783
- if ( isset( self::$google_fonts[ $font_name ] ) ) {
784
- $value = self::$google_fonts[ $font_name ];
785
  $value['font_family'] = $font_name;
786
  $value['type'] = 'google';
787
  return $value;
788
- } elseif ( isset( self::$theme_fonts[ $font_name ] ) ) {
789
  $value['type'] = 'theme_font';
790
- $value['src'] = self::$theme_fonts[ $font_name ]['src'];
791
- $value['variants'] = self::$theme_fonts[ $font_name ]['variants'];
792
- $value['font_family'] = self::$theme_fonts[ $font_name ]['family'];
793
  return $value;
794
  }
795
 
@@ -807,7 +853,7 @@ class PixCustomifyPlugin {
807
  protected function convert_setting_to_css( $option_id, $css_config = array() ) {
808
  $output = '';
809
 
810
- $this_value = self::get_option( $option_id );
811
 
812
  if ( empty( $css_config ) ) {
813
  return $output;
@@ -816,7 +862,7 @@ class PixCustomifyPlugin {
816
  foreach ( $css_config as $css_property ) {
817
 
818
  if ( isset( $css_property['media'] ) && ! empty( $css_property['media'] ) ) {
819
- self::$media_queries[ $css_property['media'] ][ $option_id ] = array(
820
  'property' => $css_property,
821
  'value' => $this_value
822
  );
@@ -824,7 +870,7 @@ class PixCustomifyPlugin {
824
  }
825
 
826
  if ( ! isset( $css_property['selector'] ) || isset( $css_property['property'] ) ) {
827
- $output .= self::proccess_css_property( $css_property, $this_value );
828
  }
829
  }
830
 
@@ -991,18 +1037,21 @@ class PixCustomifyPlugin {
991
  protected function register_customizer_controls() {
992
 
993
  // first get the base customizer extend class
994
- require_once( self::get_base_path() . '/features/customizer/class-Pix_Customize_Control.php' );
995
 
996
  // now get all the controls
997
- $path = self::get_base_path() . '/features/customizer/controls/';
998
  pixcustomify::require_all( $path );
999
  }
1000
 
 
 
 
1001
  function register_customizer( $wp_customize ) {
1002
 
1003
  $this->register_customizer_controls();
1004
 
1005
- $customizer_settings = self::$customizer_config;
1006
 
1007
  if ( ! empty ( $customizer_settings ) ) {
1008
 
@@ -1060,7 +1109,7 @@ class PixCustomifyPlugin {
1060
  }
1061
  }
1062
 
1063
- if ( self::$plugin_settings['enable_reset_buttons'] ) {
1064
  // create a toolbar section which will be present all the time
1065
  $reset_section_settings = array(
1066
  'title' => 'Customify toolbar',
@@ -1124,7 +1173,7 @@ class PixCustomifyPlugin {
1124
 
1125
  protected function register_section( $panel_id, $section_key, $options_name, $section_settings, $wp_customize ) {
1126
 
1127
- if ( isset( self::$plugin_settings['disable_customify_sections'] ) && isset( self::$plugin_settings['disable_customify_sections'][ $section_key ] ) ) {
1128
  return;
1129
  }
1130
 
@@ -1167,6 +1216,12 @@ class PixCustomifyPlugin {
1167
 
1168
  }
1169
 
 
 
 
 
 
 
1170
  protected function register_field( $section_id, $setting_id, $setting_config, $wp_customize ) {
1171
 
1172
  $add_control = true;
@@ -1182,7 +1237,7 @@ class PixCustomifyPlugin {
1182
  'settings' => $setting_id,
1183
  );
1184
 
1185
- self::$localized['settings'][ $setting_id ] = $setting_config;
1186
 
1187
  // sanitize settings
1188
  if ( ( isset( $setting_config['live'] ) && $setting_config['live'] ) || $setting_config['type'] === 'font' ) {
@@ -1197,7 +1252,7 @@ class PixCustomifyPlugin {
1197
  $setting_args['capability'] = $setting_config['capability'];
1198
  }
1199
 
1200
- if ( self::$plugin_settings['values_store_mod'] == 'option' ) {
1201
  $setting_args['type'] = 'option';
1202
  }
1203
 
@@ -1274,7 +1329,6 @@ class PixCustomifyPlugin {
1274
  switch ( $setting_config['type'] ) {
1275
 
1276
  case 'text':
1277
-
1278
  if ( isset( $setting_config['live'] ) ) {
1279
  $control_args['live'] = $setting_config['live'];
1280
  }
@@ -1283,7 +1337,6 @@ class PixCustomifyPlugin {
1283
  break;
1284
 
1285
  case 'textarea':
1286
-
1287
  if ( isset( $setting_config['live'] ) ) {
1288
  $control_args['live'] = $setting_config['live'];
1289
  }
@@ -1292,17 +1345,14 @@ class PixCustomifyPlugin {
1292
  break;
1293
 
1294
  case 'color':
1295
-
1296
  $control_class_name = 'WP_Customize_Color_Control';
1297
  break;
1298
 
1299
  case 'color_drop':
1300
-
1301
  $control_class_name = 'Pix_Customize_Color_Drop_Control';
1302
  break;
1303
 
1304
  case 'ace_editor':
1305
-
1306
  if ( isset( $setting_config['live'] ) ) {
1307
  $control_args['live'] = $setting_config['live'];
1308
  }
@@ -1315,17 +1365,14 @@ class PixCustomifyPlugin {
1315
  break;
1316
 
1317
  case 'upload':
1318
-
1319
  $control_class_name = 'WP_Customize_Upload_Control';
1320
  break;
1321
 
1322
  case 'image':
1323
-
1324
  $control_class_name = 'WP_Customize_Image_Control';
1325
  break;
1326
 
1327
  case 'media':
1328
-
1329
  $control_class_name = 'WP_Customize_Media_Control';
1330
  break;
1331
 
@@ -1338,7 +1385,6 @@ class PixCustomifyPlugin {
1338
  break;
1339
 
1340
  case 'cropped_media':
1341
-
1342
  if ( isset( $setting_config['width'] ) ) {
1343
  $control_args['width'] = $setting_config['width'];
1344
  }
@@ -1360,8 +1406,7 @@ class PixCustomifyPlugin {
1360
 
1361
  // Custom types
1362
  case 'typography' :
1363
-
1364
- $use_typography = self::get_plugin_option( 'typography', '1' );
1365
 
1366
  if ( $use_typography === false ) {
1367
  $add_control = false;
@@ -1398,8 +1443,7 @@ class PixCustomifyPlugin {
1398
 
1399
  // Custom types
1400
  case 'font' :
1401
-
1402
- $use_typography = self::get_plugin_option( 'typography', '1' );
1403
 
1404
  if ( $use_typography === false ) {
1405
  $add_control = false;
@@ -1440,7 +1484,6 @@ class PixCustomifyPlugin {
1440
  break;
1441
 
1442
  case 'select2' :
1443
-
1444
  if ( ! isset( $setting_config['choices'] ) || empty( $setting_config['choices'] ) ) {
1445
  return;
1446
  }
@@ -1451,7 +1494,6 @@ class PixCustomifyPlugin {
1451
  break;
1452
 
1453
  case 'preset' :
1454
-
1455
  if ( ! isset( $setting_config['choices'] ) || empty( $setting_config['choices'] ) ) {
1456
  return;
1457
  }
@@ -1471,7 +1513,6 @@ class PixCustomifyPlugin {
1471
  break;
1472
 
1473
  case 'radio_image' :
1474
-
1475
  if ( ! isset( $setting_config['choices'] ) || empty( $setting_config['choices'] ) ) {
1476
  return;
1477
  }
@@ -1491,7 +1532,6 @@ class PixCustomifyPlugin {
1491
  break;
1492
 
1493
  case 'button' :
1494
-
1495
  if ( ! isset( $setting_config['action'] ) || empty( $setting_config['action'] ) ) {
1496
  return;
1497
  }
@@ -1503,7 +1543,6 @@ class PixCustomifyPlugin {
1503
  break;
1504
 
1505
  case 'html' :
1506
-
1507
  if ( isset( $setting_config['html'] ) || ! empty( $setting_config['html'] ) ) {
1508
  $control_args['html'] = $setting_config['html'];
1509
  }
@@ -1512,7 +1551,6 @@ class PixCustomifyPlugin {
1512
  break;
1513
 
1514
  case 'import_demo_data' :
1515
-
1516
  if ( isset( $setting_config['html'] ) || ! empty( $setting_config['html'] ) ) {
1517
  $control_args['html'] = $setting_config['html'];
1518
  }
@@ -1550,12 +1588,12 @@ class PixCustomifyPlugin {
1550
  /**
1551
  * Remove the sections selected by user
1552
  *
1553
- * @param $wp_customize
1554
  */
1555
  function remove_default_sections( $wp_customize ) {
1556
  global $wp_registered_sidebars;
1557
 
1558
- $to_remove = self::get_plugin_option( 'disable_default_sections' );
1559
 
1560
  if ( ! empty( $to_remove ) ) {
1561
  foreach ( $to_remove as $section => $nothing ) {
@@ -1572,11 +1610,11 @@ class PixCustomifyPlugin {
1572
  }
1573
  }
1574
 
1575
- static function get_base_path() {
1576
- return plugin_dir_path( __FILE__ );
1577
  }
1578
 
1579
- protected static function get_typography_fields( $array, $key, $value, &$results, $input_key = 0 ) {
1580
  if ( ! is_array( $array ) ) {
1581
  return;
1582
  }
@@ -1590,17 +1628,17 @@ class PixCustomifyPlugin {
1590
  $default = json_encode( $array['default'] );
1591
  }
1592
 
1593
- $results[ $input_key ]['value'] = self::get_option( $input_key, $default );
1594
  }
1595
 
1596
  foreach ( $array as $i => $subarray ) {
1597
- self::get_typography_fields( $subarray, $key, $value, $results, $i );
1598
  }
1599
  }
1600
 
1601
  function get_options_key() {
1602
- if ( ! empty( self::$opt_name ) ) {
1603
- return self::$opt_name;
1604
  }
1605
 
1606
  return false;
@@ -1612,11 +1650,11 @@ class PixCustomifyPlugin {
1612
  */
1613
  function import_button_exists() {
1614
 
1615
- if ( empty( self::$options_list ) ) {
1616
- self::$options_list = $this->get_options();
1617
  }
1618
 
1619
- foreach ( self::$options_list as $option ) {
1620
  if ( isset( $option['type'] ) && 'import_demo_data' === $option['type'] ) {
1621
  return true;
1622
  break;
@@ -1628,30 +1666,42 @@ class PixCustomifyPlugin {
1628
 
1629
  /** == Helpers == */
1630
 
1631
- protected static function get_current_values() {
1632
- $store_type = self::get_plugin_option( 'values_store_mod', 'option' );
 
 
 
 
 
 
 
 
 
 
1633
  if ( $store_type === 'option' ) {
1634
- self::$current_values = get_option( self::$opt_name );
1635
  } elseif ( $store_type === 'theme_mod' ) {
1636
- self::$current_values = get_theme_mod( self::$opt_name );
1637
  }
 
 
1638
  }
1639
 
1640
  public function get_options() {
1641
 
1642
  $settings = array();
1643
 
1644
- if ( isset ( self::$customizer_config['panels'] ) ) {
1645
 
1646
- foreach ( self::$customizer_config['panels'] as $pane_id => $panel_settings ) {
1647
 
1648
  if ( isset( $panel_settings['sections'] ) ) {
1649
  foreach ( $panel_settings['sections'] as $section_id => $section_settings ) {
1650
  if ( isset( $section_settings['options'] ) ) {
1651
  foreach ( $section_settings['options'] as $option_id => $option ) {
1652
  $settings[ $option_id ] = $option;
1653
- if ( isset( self::$current_values[ $option_id ] ) ) {
1654
- $settings[ $option_id ]['value'] = self::$current_values[ $option_id ];
1655
  }
1656
  }
1657
  }
@@ -1660,13 +1710,13 @@ class PixCustomifyPlugin {
1660
  }
1661
  }
1662
 
1663
- if ( isset ( self::$customizer_config['sections'] ) ) {
1664
- foreach ( self::$customizer_config['sections'] as $section_id => $section_settings ) {
1665
  if ( isset( $section_settings['options'] ) ) {
1666
  foreach ( $section_settings['options'] as $option_id => $option ) {
1667
  $settings[ $option_id ] = $option;
1668
- if ( isset( self::$current_values[ $option_id ] ) ) {
1669
- $settings[ $option_id ]['value'] = self::$current_values[ $option_id ];
1670
  }
1671
  }
1672
  }
@@ -1676,12 +1726,21 @@ class PixCustomifyPlugin {
1676
  return $settings;
1677
  }
1678
 
1679
- protected static function get_value( $option ) {
1680
  global $wp_customize;
1681
 
 
 
 
 
 
 
 
 
 
1682
  if ( ! empty( $wp_customize ) && method_exists( $wp_customize, 'get_setting') ) {
1683
 
1684
- $option_key = self::$opt_name . '[' . $option . ']';
1685
  $setting = $wp_customize->get_setting( $option_key );
1686
  if ( ! empty( $setting ) ) {
1687
  $value = $setting->value();
@@ -1690,14 +1749,14 @@ class PixCustomifyPlugin {
1690
  }
1691
 
1692
  // shim
1693
- if ( strpos( $option, self::$opt_name . '[' ) !== false ) {
1694
  // get only the setting id
1695
  $option = explode( '[', $option );
1696
  $option = rtrim( $option[1], ']' );
1697
  }
1698
 
1699
- if ( isset( self::$current_values[ $option ] ) ) {
1700
- return self::$current_values[ $option ];
1701
  }
1702
 
1703
  return null;
@@ -1709,37 +1768,41 @@ class PixCustomifyPlugin {
1709
  * Otherwise try to get the default parameter or the default from config
1710
  *
1711
  * @param $option
1712
- * @param null $default
 
1713
  *
1714
  * @return bool|null|string
1715
  */
1716
- static function get_option( $option, $default = null ) {
1717
 
1718
- $return = self::get_value( $option );
1719
 
1720
  if ( $return !== null ) {
1721
  return $return;
1722
  } elseif ( $default !== null ) {
1723
  return $default;
1724
- } elseif ( isset( self::$options_list[ $option ] ) && isset( self::$options_list[ $option ]['default'] ) ) {
1725
- return self::$options_list[ $option ]['default'];
1726
  }
1727
 
1728
  return null;
1729
  }
1730
 
1731
- static function has_option( $option ) {
1732
 
1733
- if ( isset( self::$options_list[ $option ] ) ) {
1734
  return true;
1735
  }
1736
 
1737
  return false;
1738
  }
1739
 
1740
- protected static function get_config() {
1741
- // @TODO maybe check this
1742
- return include 'plugin-config.php';
 
 
 
1743
  }
1744
 
1745
  /**
@@ -1750,10 +1813,10 @@ class PixCustomifyPlugin {
1750
  *
1751
  * @return bool|null
1752
  */
1753
- public static function get_config_option( $option, $default = null ) {
1754
 
1755
- if ( isset( self::$config[ $option ] ) ) {
1756
- return self::$config[ $option ];
1757
  } elseif ( $default !== null ) {
1758
  return $default;
1759
  }
@@ -1761,10 +1824,10 @@ class PixCustomifyPlugin {
1761
  return false;
1762
  }
1763
 
1764
- static function get_plugin_option( $option, $default = null ) {
1765
 
1766
- if ( isset( self::$plugin_settings[ $option ] ) ) {
1767
- return self::$plugin_settings[ $option ];
1768
  } elseif ( $default !== null ) {
1769
  return $default;
1770
  }
@@ -1798,7 +1861,7 @@ class PixCustomifyPlugin {
1798
  *
1799
  * @return bool
1800
  */
1801
- public static function is_assoc( $array ) {
1802
 
1803
  if ( ! is_array( $array ) ) {
1804
  return false;
@@ -1814,13 +1877,13 @@ class PixCustomifyPlugin {
1814
 
1815
  function register_import_api(){
1816
 
1817
- include_once( self::get_base_path() . '/features/class-Customify_Importer.php' );
1818
  $controller = new Customify_Importer_Controller();
1819
  $controller->init();
1820
  }
1821
 
1822
  function get_options_configs () {
1823
- return self::$options_list;
1824
  }
1825
 
1826
  /**
@@ -1859,4 +1922,64 @@ class PixCustomifyPlugin {
1859
 
1860
  return $str;
1861
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1862
  }
4
  * @package PixCustomify
5
  * @author Pixelgrade <contact@pixelgrade.com>
6
  * @license GPL-2.0+
7
+ * @link https://pixelgrade.com
8
+ * @copyright 2014-2017 Pixelgrade
9
  */
10
 
11
  /**
17
 
18
  /**
19
  * Plugin version, used for cache-busting of style and script file references.
20
+ * @since 1.5.0
21
  * @const string
22
  */
23
+ protected $_version;
24
  /**
25
  * Unique identifier for your plugin.
26
  * Use this value (not the variable name) as the text domain when internationalizing strings of text. It should
32
 
33
  /**
34
  * Instance of this class.
35
+ * @since 1.5.0
36
  * @var object
37
  */
38
+ protected static $_instance = null;
39
 
40
  /**
41
  * Slug of the plugin screen.
53
 
54
  public $display_admin_menu = false;
55
 
56
+ private $config;
57
 
58
+ private $customizer_config;
59
 
60
+ public $plugin_settings;
61
 
62
+ protected $localized = array();
63
 
64
+ protected $current_values = array();
65
 
66
+ protected $options_list = array();
67
 
68
+ protected $media_queries = array();
69
 
70
+ protected $opt_name;
71
 
72
+ protected $typo_settings;
73
 
74
+ protected $google_fonts = null;
75
 
76
+ protected $theme_fonts = null;
77
 
78
  // these properties will get 'px' as a default unit
79
  protected static $pixel_dependent_css_properties = array(
113
  'border-top-width'
114
  );
115
 
116
+ protected $jetpack_default_modules = array();
117
+ protected $jetpack_blocked_modules = array();
118
+ protected $jetpack_sharing_default_options = array();
119
 
120
  /**
121
+ * The main plugin file.
122
+ * @var string
123
+ * @access public
124
+ * @since 1.5.0
125
  */
126
+ public $file;
127
+
128
+ /**
129
+ * Minimal Required PHP Version
130
+ * @var string
131
+ * @access private
132
+ * @since 1.5.0
133
+ */
134
+ private $minimalRequiredPhpVersion = 5.2;
135
+
136
+ protected function __construct( $file, $version = '1.0.0' ) {
137
+ //the main plugin file (the one that loads all this)
138
+ $this->file = $file;
139
+ //the current plugin version
140
+ $this->_version = $version;
141
+
142
+ // Remember our base path
143
+ $this->plugin_basepath = plugin_dir_path( $file );
144
 
145
+ if ( $this->php_version_check() ) {
146
+ // Only load and run the init function if we know PHP version can parse it.
147
+ $this->init();
148
+ }
149
+ }
150
 
151
+ /**
152
+ * Initialize plugin
153
+ */
154
+ private function init() {
155
+ // Load the config file
156
+ $this->config = $this->get_config();
157
+ // Load the plugin's settings from the DB
158
+ $this->plugin_settings = get_option( $this->config['settings-key'] );
159
+
160
+ // Register all the needed hooks
161
+ $this->register_hooks();
162
+ }
163
+
164
+ /**
165
+ * Register our actions and filters
166
+ *
167
+ * @return null
168
+ */
169
+ function register_hooks() {
170
+ /*
171
+ * Register hooks that are fired when the plugin is activated, deactivated, and uninstalled, respectively.
172
+ */
173
+ register_activation_hook( $this->file, array( $this, 'activate' ) );
174
+ register_deactivation_hook( $this->file, array( $this, 'deactivate' ) );
175
 
176
+ /*
177
+ * Load plugin text domain
178
+ */
179
  add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
180
 
181
+ /*
182
+ * Prepare and load the configuration
183
+ */
184
+ $this->init_plugin_configs();
185
+
186
+ // We can load the actual plugins config only on after_setup_theme so we can give the themes a change to have their say
187
+ // DO NOT TRY to use the Customify values before this!
188
+ add_action( 'after_setup_theme', array( $this, 'load_plugin_configs' ), 5 );
189
 
190
+ /*
191
+ * Now setup the admin side of things
192
+ */
193
+ // Starting with the menu item for this plugin
194
  add_action( 'admin_menu', array( $this, 'add_plugin_admin_menu' ) );
195
 
196
  // Add an action link pointing to the options page.
197
+ $plugin_basename = plugin_basename( plugin_dir_path( $this->file ) . 'pixcustomify.php' );
198
  add_filter( 'plugin_action_links_' . $plugin_basename, array( $this, 'add_action_links' ) );
199
 
200
  // Load admin style sheet and JavaScript.
201
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) );
202
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
203
 
204
+ /*
205
+ * Now it's time for the Customizer logic to kick in
206
+ */
207
+ // Both in the Customizer and on the frontend
208
  add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_admin_customizer_styles' ), 10 );
209
  add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_admin_customizer_scripts' ), 10 );
210
  add_action( 'customize_preview_init', array( $this, 'customizer_live_preview_enqueue_scripts' ), 99999 );
211
 
212
+ $load_location = $this->get_plugin_setting( 'style_resources_location', 'wp_head' );
213
 
214
  add_action( $load_location, array( $this, 'output_dynamic_style' ), 99999 );
215
  add_action( 'wp_head', array( $this, 'output_typography_dynamic_style' ), 10 );
217
  add_action( 'customize_register', array( $this, 'remove_default_sections' ), 11 );
218
  add_action( 'customize_register', array( $this, 'register_customizer' ), 12 );
219
 
220
+ if ( $this->get_plugin_setting( 'enable_editor_style', true ) ) {
221
  add_action( 'admin_head', array( $this, 'add_customizer_settings_into_wp_editor' ) );
222
  }
223
 
224
+ /*
225
+ * Jetpack Related
226
+ */
227
  add_action( 'init', array( $this, 'set_jetpack_modules_config') );
228
  add_filter( 'default_option_jetpack_active_modules', array( $this, 'default_jetpack_active_modules' ), 10, 1 );
229
  add_filter( 'jetpack_get_available_modules', array( $this, 'jetpack_hide_blocked_modules'), 10, 1 );
231
  }
232
 
233
  /**
234
+ * Initialize Configs, Options and Values methods
 
 
235
  */
236
+ function init_plugin_configs() {
237
+ $this->customizer_config = get_option( 'pixcustomify_config' );
238
 
239
+ // no option so go for default
240
+ if ( empty( $this->customizer_config ) ) {
241
+ $this->customizer_config = $this->get_config_option( 'default_options' );
242
  }
243
 
244
+ if ( empty( $this->customizer_config ) ) {
245
+ $this->customizer_config = array();
246
+ }
247
  }
248
 
249
  /**
250
+ * Load the plugin configuration and options
251
  */
252
+ function load_plugin_configs() {
 
 
 
 
 
 
 
 
 
 
 
253
 
254
  // allow themes or other plugins to filter the config
255
+ $this->customizer_config = apply_filters( 'customify_filter_fields', $this->customizer_config );
256
+ $this->opt_name = $this->localized['options_name'] = $this->customizer_config['opt-name'];
257
+ $this->options_list = $this->get_options();
258
 
259
+ // Load the current options values
260
+ $this->current_values = $this->get_current_values();
 
 
261
 
262
  if ( $this->import_button_exists() ) {
263
+ $this->localized['import_rest_url'] = get_rest_url( '/customify/1.0/' );
264
+ $this->localized['import_rest_nonce'] = wp_create_nonce( 'wp_rest' );
265
 
266
  $this->register_import_api();
267
  }
268
 
269
+ $this->localized['theme_fonts'] = $this->theme_fonts = Customify_Font_Selector::instance()->get_theme_fonts();
 
270
  }
271
 
272
  function set_jetpack_modules_config() {
273
  // We expect an array of string module names like array( 'infinite-scroll', 'widgets' )
274
  // See jetpack/modules/modules-heading.php for module names
275
+ $this->jetpack_default_modules = apply_filters ( 'customify_filter_jetpack_default_modules', array(
276
  'shortcodes',
277
  'widget-visibility',
278
  'widgets',
280
 
281
  // We expect an array of string module names like array( 'infinite-scroll', 'widgets' )
282
  // See jetpack/modules/modules-heading.php for module names
283
+ $this->jetpack_blocked_modules = apply_filters ( 'customify_filter_jetpack_blocked_modules', array() );
284
 
285
+ $this->jetpack_sharing_default_options = apply_filters ( 'customify_filter_jetpack_sharing_default_options', array() );
286
  }
287
 
288
  /**
298
  $default = array();
299
  }
300
 
301
+ return array_merge( $default, $this->jetpack_default_modules );
302
  }
303
 
304
  /**
315
  $default = array();
316
  }
317
 
318
+ return array_merge( $default, $this->jetpack_sharing_default_options );
319
  }
320
 
321
  /**
327
  * @return array
328
  */
329
  function jetpack_hide_blocked_modules( $modules ) {
330
+ return array_diff_key( $modules, array_flip( $this->jetpack_blocked_modules ) );
331
  }
332
 
333
  /**
337
  * @param boolean $network_wide True if WPMU superadmin uses "Network Activate" action, false if WPMU is disabled or plugin is activated on an individual blog.
338
  */
339
  public static function activate( $network_wide ) {
340
+ //@todo Define activation functionality here
341
  }
342
 
343
  /**
347
  * @param boolean $network_wide True if WPMU superadmin uses "Network Deactivate" action, false if WPMU is disabled or plugin is deactivated on an individual blog.
348
  */
349
  static function deactivate( $network_wide ) {
350
+ //@todo Define deactivation functionality here
351
  }
352
 
353
  /**
356
  */
357
  function load_plugin_textdomain() {
358
  $domain = $this->plugin_slug;
359
+ load_plugin_textdomain( $domain, false, basename( dirname( $this->file ) ) . '/languages/' );
360
  }
361
 
362
  /** === RESOURCES === **/
365
  * Customizer admin styles
366
  */
367
  function enqueue_admin_customizer_styles() {
368
+ wp_enqueue_style( 'customify_select2', plugins_url( 'js/select2/css/select2.css', $this->file ), array(), $this->_version );
369
+ wp_enqueue_style( 'customify_style', plugins_url( 'css/customizer.css', $this->file ), array(), $this->_version );
370
  }
371
 
372
  /**
374
  */
375
  function enqueue_admin_customizer_scripts() {
376
 
377
+ wp_enqueue_script( 'customify_select2', plugins_url( 'js/select2/js/select2.js', $this->file ), array( 'jquery' ), $this->_version );
378
+ wp_enqueue_script( 'jquery-react', plugins_url( 'js/jquery-react.js', $this->file ), array( 'jquery' ), $this->_version );
379
+ wp_enqueue_script( $this->plugin_slug . '-customizer-scripts', plugins_url( 'js/customizer.js', $this->file ), array(
380
  'jquery',
381
+ 'customify_select2',
382
  'underscore',
383
  'customize-controls'
384
+ ), $this->_version );
385
 
386
+ wp_localize_script( $this->plugin_slug . '-customizer-scripts', 'customify_settings', $this->localized );
387
  }
388
 
389
  /** Customizer scripts loaded only on previewer page */
390
  function customizer_live_preview_enqueue_scripts() {
391
 
392
+ wp_register_script( $this->plugin_slug . 'CSSOM', plugins_url( 'js/CSSOM.js', $this->file ), array( 'jquery' ), $this->_version, true );
393
+ wp_register_script( $this->plugin_slug . 'cssUpdate', plugins_url( 'js/jquery.cssUpdate.js', $this->file ), array(), $this->_version, true );
394
+ wp_enqueue_script( $this->plugin_slug . '-previewer-scripts', plugins_url( 'js/customizer_preview.js', $this->file ), array(
395
  'jquery',
396
+ 'customize-preview',
397
  $this->plugin_slug . 'CSSOM',
398
  $this->plugin_slug . 'cssUpdate'
399
+ ), $this->_version, true );
400
 
401
  // when a live preview field is in action we need to know which props need 'px' as defaults
402
+ $this->localized['px_dependent_css_props'] = self::$pixel_dependent_css_properties;
403
 
404
+ wp_localize_script( $this->plugin_slug . '-previewer-scripts', 'customify_settings', $this->localized );
405
  }
406
 
407
  /**
419
 
420
  $screen = get_current_screen();
421
  if ( $screen->id == $this->plugin_screen_hook_suffix ) {
422
+ wp_enqueue_style( $this->plugin_slug . '-admin-styles', plugins_url( 'css/admin.css', $this->file ), array(), $this->_version );
423
  }
424
  }
425
 
434
 
435
  $screen = get_current_screen();
436
  if ( $screen->id == $this->plugin_screen_hook_suffix ) {
437
+ wp_enqueue_script( $this->plugin_slug . '-admin-script', plugins_url( 'js/admin.js', $this->file ), array( 'jquery' ), $this->_version );
438
  wp_localize_script( $this->plugin_slug . '-admin-script', 'locals', array(
439
  'ajax_url' => admin_url( 'admin-ajax.php' )
440
  ) );
450
  function output_dynamic_style() {
451
  $custom_css = "\n";
452
 
453
+ foreach ( $this->options_list as $option_id => $option ) {
454
 
455
  if ( isset( $option['css'] ) && ! empty( $option['css'] ) ) {
456
  // now process each
462
  }
463
  }
464
 
465
+ if ( ! empty( $this->media_queries ) ) {
466
 
467
+ foreach ( $this->media_queries as $media_query => $properties ) {
468
 
469
  if ( empty( $properties ) ) {
470
  continue;
475
  foreach ( $properties as $key => $property ) {
476
  $property_settings = $property['property'];
477
  $property_value = $property['value'];
478
+ $custom_css .= $this->proccess_css_property( $property_settings, $property_value );
479
  }
480
 
481
  $custom_css .= " }\n";
484
  }
485
 
486
  $custom_css .= "\n";
487
+ ?><style id="customify_output_style">
488
+ <?php echo apply_filters( 'customify_dynamic_style', $custom_css ); ?>
 
 
489
  </style><?php
490
 
491
  /**
496
  return;
497
  }
498
 
499
+ foreach ( $this->options_list as $option_id => $options ) {
500
 
501
  if ( $options['type'] === 'custom_background' ) {
502
+ $options['value'] = $this->get_option( $option_id );
503
  $custom_background_output = $this->process_custom_background_field_output( $option_id, $options ); ?>
504
 
505
  <style id="custom_backgorund_output_for_<?php echo $option_id; ?>">
514
  continue;
515
  }
516
 
517
+ $this_value = $this->get_option( $option_id );
518
  foreach ( $options['css'] as $key => $properties_set ) { ?>
519
  <style id="dynamic_setting_<?php echo $option_id . '_property_' . str_replace( '-', '_', $properties_set['property'] ); ?>" type="text/css"><?php
520
 
523
  }
524
 
525
  if ( isset( $properties_set['selector'] ) && isset( $properties_set['property'] ) ) {
526
+ echo $this->proccess_css_property($properties_set, $this_value);
527
  }
528
 
529
  if ( isset( $properties_set['media'] ) && ! empty( $properties_set['media'] ) ) {
533
  <?php }
534
  }
535
 
536
+ if ( ! empty( $this->media_queries ) ) {
537
 
538
+ foreach ( $this->media_queries as $media_query => $properties ) {
539
 
540
  if ( empty( $properties ) ) {
541
  continue;
554
  <style id="dynamic_setting_<?php echo $key; ?>" type="text/css"><?php
555
  $property_settings = $property['property'];
556
  $property_value = $property['value'];
557
+ $media_q .= "\t" . $this->proccess_css_property( $property_settings, $property_value );?>
558
  </style>
559
  <?php }
560
 
568
  }
569
 
570
  protected function load_google_fonts() {
571
+ $fonts_path = plugin_dir_path( $this->file ) . 'features/customizer/controls/resources/google.fonts.php';
 
572
 
573
  if ( file_exists( $fonts_path ) ) {
574
+ $this->google_fonts = require( $fonts_path );
575
  }
576
 
577
+ if ( ! empty( $this->google_fonts ) ) {
578
+ return $this->google_fonts;
579
  }
580
 
581
  return false;
582
  }
583
 
584
  function output_typography_dynamic_style() {
585
+ $this->get_typography_fields( $this->options_list, 'type', 'typography', $this->typo_settings );
586
 
587
+ if ( empty( $this->typo_settings ) ) {
 
 
588
  return;
589
  }
590
 
591
  $families = '';
592
 
593
+ foreach ( $this->typo_settings as $id => $font ) {
594
  if ( isset ( $font['value'] ) ) {
595
 
596
  $load_all_weights = false;
617
  }
618
 
619
  //Handle special logic for when the $value array is not an associative array
620
+ if ( ! $this->is_assoc( $value ) ) {
621
  $value = $this->process_a_not_associative_font_default( $value );
622
  }
623
 
659
  }
660
  }
661
 
662
+ if ( ! empty ( $families ) && $this->get_plugin_setting( 'typography', '1' ) && $this->get_plugin_setting( 'typography_google_fonts', 1 ) ) { ?>
663
  <script type="text/javascript">
664
  if ( typeof WebFont !== 'undefined' ) {<?php // if there is a WebFont object, use it ?>
665
  WebFont.load( {
688
  <?php } ?>
689
  <style id="customify_typography_output_style">
690
  <?php
691
+ foreach ( $this->typo_settings as $key => $font ) {
692
  $load_all_weights = false;
693
  if ( isset( $font['load_all_weights'] ) && $font['load_all_weights'] == 'true' ) {
694
  $load_all_weights = true;
708
  }
709
 
710
  //Handle special logic for when the $value array is not an associative array
711
+ if ( ! $this->is_assoc( $value ) ) {
712
  $value = $this->process_a_not_associative_font_default( $value );
713
  }
714
 
785
  * Handle special logic for when the $value array is not an associative array
786
  * Return a new associative array with proper keys
787
  */
788
+ public function process_a_not_associative_font_default( $value ) {
789
 
790
  $new_value = array();
791
 
820
  *
821
  * @return null
822
  */
823
+ public function get_font_defaults_value( $font_name ) {
824
 
825
+ if ( empty( $this->google_fonts ) ) {
826
  $this->load_google_fonts();
827
  }
828
 
829
+ if ( isset( $this->google_fonts[ $font_name ] ) ) {
830
+ $value = $this->google_fonts[ $font_name ];
831
  $value['font_family'] = $font_name;
832
  $value['type'] = 'google';
833
  return $value;
834
+ } elseif ( isset( $this->theme_fonts[ $font_name ] ) ) {
835
  $value['type'] = 'theme_font';
836
+ $value['src'] = $this->theme_fonts[ $font_name ]['src'];
837
+ $value['variants'] = $this->theme_fonts[ $font_name ]['variants'];
838
+ $value['font_family'] = $this->theme_fonts[ $font_name ]['family'];
839
  return $value;
840
  }
841
 
853
  protected function convert_setting_to_css( $option_id, $css_config = array() ) {
854
  $output = '';
855
 
856
+ $this_value = $this->get_option( $option_id );
857
 
858
  if ( empty( $css_config ) ) {
859
  return $output;
862
  foreach ( $css_config as $css_property ) {
863
 
864
  if ( isset( $css_property['media'] ) && ! empty( $css_property['media'] ) ) {
865
+ $this->media_queries[ $css_property['media'] ][ $option_id ] = array(
866
  'property' => $css_property,
867
  'value' => $this_value
868
  );
870
  }
871
 
872
  if ( ! isset( $css_property['selector'] ) || isset( $css_property['property'] ) ) {
873
+ $output .= $this->proccess_css_property( $css_property, $this_value );
874
  }
875
  }
876
 
1037
  protected function register_customizer_controls() {
1038
 
1039
  // first get the base customizer extend class
1040
+ require_once( $this->get_base_path() . '/features/customizer/class-Pix_Customize_Control.php' );
1041
 
1042
  // now get all the controls
1043
+ $path = $this->get_base_path() . '/features/customizer/controls/';
1044
  pixcustomify::require_all( $path );
1045
  }
1046
 
1047
+ /**
1048
+ * @param WP_Customize_Manager $wp_customize
1049
+ */
1050
  function register_customizer( $wp_customize ) {
1051
 
1052
  $this->register_customizer_controls();
1053
 
1054
+ $customizer_settings = $this->customizer_config;
1055
 
1056
  if ( ! empty ( $customizer_settings ) ) {
1057
 
1109
  }
1110
  }
1111
 
1112
+ if ( $this->plugin_settings['enable_reset_buttons'] ) {
1113
  // create a toolbar section which will be present all the time
1114
  $reset_section_settings = array(
1115
  'title' => 'Customify toolbar',
1173
 
1174
  protected function register_section( $panel_id, $section_key, $options_name, $section_settings, $wp_customize ) {
1175
 
1176
+ if ( isset( $this->plugin_settings['disable_customify_sections'] ) && isset( $this->plugin_settings['disable_customify_sections'][ $section_key ] ) ) {
1177
  return;
1178
  }
1179
 
1216
 
1217
  }
1218
 
1219
+ /**
1220
+ * @param string $section_id
1221
+ * @param string $setting_id
1222
+ * @param array $setting_config
1223
+ * @param WP_Customize_Manager $wp_customize
1224
+ */
1225
  protected function register_field( $section_id, $setting_id, $setting_config, $wp_customize ) {
1226
 
1227
  $add_control = true;
1237
  'settings' => $setting_id,
1238
  );
1239
 
1240
+ $this->localized['settings'][ $setting_id ] = $setting_config;
1241
 
1242
  // sanitize settings
1243
  if ( ( isset( $setting_config['live'] ) && $setting_config['live'] ) || $setting_config['type'] === 'font' ) {
1252
  $setting_args['capability'] = $setting_config['capability'];
1253
  }
1254
 
1255
+ if ( $this->plugin_settings['values_store_mod'] == 'option' ) {
1256
  $setting_args['type'] = 'option';
1257
  }
1258
 
1329
  switch ( $setting_config['type'] ) {
1330
 
1331
  case 'text':
 
1332
  if ( isset( $setting_config['live'] ) ) {
1333
  $control_args['live'] = $setting_config['live'];
1334
  }
1337
  break;
1338
 
1339
  case 'textarea':
 
1340
  if ( isset( $setting_config['live'] ) ) {
1341
  $control_args['live'] = $setting_config['live'];
1342
  }
1345
  break;
1346
 
1347
  case 'color':
 
1348
  $control_class_name = 'WP_Customize_Color_Control';
1349
  break;
1350
 
1351
  case 'color_drop':
 
1352
  $control_class_name = 'Pix_Customize_Color_Drop_Control';
1353
  break;
1354
 
1355
  case 'ace_editor':
 
1356
  if ( isset( $setting_config['live'] ) ) {
1357
  $control_args['live'] = $setting_config['live'];
1358
  }
1365
  break;
1366
 
1367
  case 'upload':
 
1368
  $control_class_name = 'WP_Customize_Upload_Control';
1369
  break;
1370
 
1371
  case 'image':
 
1372
  $control_class_name = 'WP_Customize_Image_Control';
1373
  break;
1374
 
1375
  case 'media':
 
1376
  $control_class_name = 'WP_Customize_Media_Control';
1377
  break;
1378
 
1385
  break;
1386
 
1387
  case 'cropped_media':
 
1388
  if ( isset( $setting_config['width'] ) ) {
1389
  $control_args['width'] = $setting_config['width'];
1390
  }
1406
 
1407
  // Custom types
1408
  case 'typography' :
1409
+ $use_typography = $this->get_plugin_setting( 'typography', '1' );
 
1410
 
1411
  if ( $use_typography === false ) {
1412
  $add_control = false;
1443
 
1444
  // Custom types
1445
  case 'font' :
1446
+ $use_typography = $this->get_plugin_setting( 'typography', '1' );
 
1447
 
1448
  if ( $use_typography === false ) {
1449
  $add_control = false;
1484
  break;
1485
 
1486
  case 'select2' :
 
1487
  if ( ! isset( $setting_config['choices'] ) || empty( $setting_config['choices'] ) ) {
1488
  return;
1489
  }
1494
  break;
1495
 
1496
  case 'preset' :
 
1497
  if ( ! isset( $setting_config['choices'] ) || empty( $setting_config['choices'] ) ) {
1498
  return;
1499
  }
1513
  break;
1514
 
1515
  case 'radio_image' :
 
1516
  if ( ! isset( $setting_config['choices'] ) || empty( $setting_config['choices'] ) ) {
1517
  return;
1518
  }
1532
  break;
1533
 
1534
  case 'button' :
 
1535
  if ( ! isset( $setting_config['action'] ) || empty( $setting_config['action'] ) ) {
1536
  return;
1537
  }
1543
  break;
1544
 
1545
  case 'html' :
 
1546
  if ( isset( $setting_config['html'] ) || ! empty( $setting_config['html'] ) ) {
1547
  $control_args['html'] = $setting_config['html'];
1548
  }
1551
  break;
1552
 
1553
  case 'import_demo_data' :
 
1554
  if ( isset( $setting_config['html'] ) || ! empty( $setting_config['html'] ) ) {
1555
  $control_args['html'] = $setting_config['html'];
1556
  }
1588
  /**
1589
  * Remove the sections selected by user
1590
  *
1591
+ * @param WP_Customize_Manager $wp_customize
1592
  */
1593
  function remove_default_sections( $wp_customize ) {
1594
  global $wp_registered_sidebars;
1595
 
1596
+ $to_remove = $this->get_plugin_setting( 'disable_default_sections' );
1597
 
1598
  if ( ! empty( $to_remove ) ) {
1599
  foreach ( $to_remove as $section => $nothing ) {
1610
  }
1611
  }
1612
 
1613
+ public function get_base_path() {
1614
+ return plugin_dir_path( $this->file );
1615
  }
1616
 
1617
+ public function get_typography_fields( $array, $key, $value, &$results, $input_key = 0 ) {
1618
  if ( ! is_array( $array ) ) {
1619
  return;
1620
  }
1628
  $default = json_encode( $array['default'] );
1629
  }
1630
 
1631
+ $results[ $input_key ]['value'] = $this->get_option( $input_key, $default );
1632
  }
1633
 
1634
  foreach ( $array as $i => $subarray ) {
1635
+ $this->get_typography_fields( $subarray, $key, $value, $results, $i );
1636
  }
1637
  }
1638
 
1639
  function get_options_key() {
1640
+ if ( ! empty( $this->opt_name ) ) {
1641
+ return $this->opt_name;
1642
  }
1643
 
1644
  return false;
1650
  */
1651
  function import_button_exists() {
1652
 
1653
+ if ( empty( $this->options_list ) ) {
1654
+ $this->options_list = $this->get_options();
1655
  }
1656
 
1657
+ foreach ( $this->options_list as $option ) {
1658
  if ( isset( $option['type'] ) && 'import_demo_data' === $option['type'] ) {
1659
  return true;
1660
  break;
1666
 
1667
  /** == Helpers == */
1668
 
1669
+ protected function get_current_values( $opt_name = null ) {
1670
+ // Fallback to the global $opt_name
1671
+ if ( empty( $opt_name ) ) {
1672
+ $opt_name = $this->opt_name;
1673
+ }
1674
+
1675
+ // Bail as we have nothing to work with
1676
+ if ( empty( $opt_name ) ) {
1677
+ return false;
1678
+ }
1679
+
1680
+ $store_type = $this->get_plugin_setting( 'values_store_mod', 'option' );
1681
  if ( $store_type === 'option' ) {
1682
+ return get_option( $opt_name );
1683
  } elseif ( $store_type === 'theme_mod' ) {
1684
+ return get_theme_mod( $opt_name );
1685
  }
1686
+
1687
+ return false;
1688
  }
1689
 
1690
  public function get_options() {
1691
 
1692
  $settings = array();
1693
 
1694
+ if ( isset ( $this->customizer_config['panels'] ) ) {
1695
 
1696
+ foreach ( $this->customizer_config['panels'] as $pane_id => $panel_settings ) {
1697
 
1698
  if ( isset( $panel_settings['sections'] ) ) {
1699
  foreach ( $panel_settings['sections'] as $section_id => $section_settings ) {
1700
  if ( isset( $section_settings['options'] ) ) {
1701
  foreach ( $section_settings['options'] as $option_id => $option ) {
1702
  $settings[ $option_id ] = $option;
1703
+ if ( isset( $this->current_values[ $option_id ] ) ) {
1704
+ $settings[ $option_id ]['value'] = $this->current_values[ $option_id ];
1705
  }
1706
  }
1707
  }
1710
  }
1711
  }
1712
 
1713
+ if ( isset ( $this->customizer_config['sections'] ) ) {
1714
+ foreach ( $this->customizer_config['sections'] as $section_id => $section_settings ) {
1715
  if ( isset( $section_settings['options'] ) ) {
1716
  foreach ( $section_settings['options'] as $option_id => $option ) {
1717
  $settings[ $option_id ] = $option;
1718
+ if ( isset( $this->current_values[ $option_id ] ) ) {
1719
+ $settings[ $option_id ]['value'] = $this->current_values[ $option_id ];
1720
  }
1721
  }
1722
  }
1726
  return $settings;
1727
  }
1728
 
1729
+ protected function get_value( $option, $alt_opt_name ) {
1730
  global $wp_customize;
1731
 
1732
+ $opt_name = $this->opt_name;
1733
+ $values = $this->current_values;
1734
+
1735
+ // In case someone asked for a DB value too early but it has given us the opt_name under which to search, let's do it
1736
+ if ( empty( $opt_name ) && ! empty( $alt_opt_name ) ) {
1737
+ $opt_name = $alt_opt_name;
1738
+ $values = $this->get_current_values( $opt_name );
1739
+ }
1740
+
1741
  if ( ! empty( $wp_customize ) && method_exists( $wp_customize, 'get_setting') ) {
1742
 
1743
+ $option_key = $opt_name . '[' . $option . ']';
1744
  $setting = $wp_customize->get_setting( $option_key );
1745
  if ( ! empty( $setting ) ) {
1746
  $value = $setting->value();
1749
  }
1750
 
1751
  // shim
1752
+ if ( strpos( $option, $opt_name . '[' ) !== false ) {
1753
  // get only the setting id
1754
  $option = explode( '[', $option );
1755
  $option = rtrim( $option[1], ']' );
1756
  }
1757
 
1758
+ if ( isset( $values[ $option ] ) ) {
1759
+ return $values[ $option ];
1760
  }
1761
 
1762
  return null;
1768
  * Otherwise try to get the default parameter or the default from config
1769
  *
1770
  * @param $option
1771
+ * @param mixed $default Optional.
1772
+ * @param string $alt_opt_name Optional. We can use this to bypass the fact that the DB values are loaded on after_setup_theme, if we know what to look for.
1773
  *
1774
  * @return bool|null|string
1775
  */
1776
+ public function get_option( $option, $default = null, $alt_opt_name = null ) {
1777
 
1778
+ $return = $this->get_value( $option, $alt_opt_name );
1779
 
1780
  if ( $return !== null ) {
1781
  return $return;
1782
  } elseif ( $default !== null ) {
1783
  return $default;
1784
+ } elseif ( isset( $this->options_list[ $option ] ) && isset( $this->options_list[ $option ]['default'] ) ) {
1785
+ return $this->options_list[ $option ]['default'];
1786
  }
1787
 
1788
  return null;
1789
  }
1790
 
1791
+ public function has_option( $option ) {
1792
 
1793
+ if ( isset( $this->options_list[ $option ] ) ) {
1794
  return true;
1795
  }
1796
 
1797
  return false;
1798
  }
1799
 
1800
+ protected function get_config() {
1801
+ if ( file_exists( $this->get_base_path() . 'plugin-config.php' ) ) {
1802
+ return include( $this->get_base_path() . 'plugin-config.php' );
1803
+ }
1804
+
1805
+ return false;
1806
  }
1807
 
1808
  /**
1813
  *
1814
  * @return bool|null
1815
  */
1816
+ public function get_config_option( $option, $default = null ) {
1817
 
1818
+ if ( isset( $this->config[ $option ] ) ) {
1819
+ return $this->config[ $option ];
1820
  } elseif ( $default !== null ) {
1821
  return $default;
1822
  }
1824
  return false;
1825
  }
1826
 
1827
+ public function get_plugin_setting( $option, $default = null ) {
1828
 
1829
+ if ( isset( $this->plugin_settings[ $option ] ) ) {
1830
+ return $this->plugin_settings[ $option ];
1831
  } elseif ( $default !== null ) {
1832
  return $default;
1833
  }
1861
  *
1862
  * @return bool
1863
  */
1864
+ public function is_assoc( $array ) {
1865
 
1866
  if ( ! is_array( $array ) ) {
1867
  return false;
1877
 
1878
  function register_import_api(){
1879
 
1880
+ include_once( $this->get_base_path() . '/features/class-Customify_Importer.php' );
1881
  $controller = new Customify_Importer_Controller();
1882
  $controller->init();
1883
  }
1884
 
1885
  function get_options_configs () {
1886
+ return $this->options_list;
1887
  }
1888
 
1889
  /**
1922
 
1923
  return $str;
1924
  }
1925
+
1926
+ /**
1927
+ * PHP version check
1928
+ */
1929
+ protected function php_version_check() {
1930
+
1931
+ if ( version_compare( phpversion(), $this->minimalRequiredPhpVersion ) < 0 ) {
1932
+ add_action( 'admin_notices', array( $this, 'notice_php_version_wrong' ) );
1933
+ return false;
1934
+ }
1935
+
1936
+ return true;
1937
+ }
1938
+
1939
+ /**
1940
+ * Return an instance of this class.
1941
+ * @since 1.0.0
1942
+ * @return PixCustomifyPlugin A single instance of this class.
1943
+ */
1944
+ /**
1945
+ * Main PixCustomifyPlugin Instance
1946
+ *
1947
+ * Ensures only one instance of PixCustomifyPlugin is loaded or can be loaded.
1948
+ *
1949
+ * @since 1.0.0
1950
+ * @static
1951
+ * @param string $file File.
1952
+ * @param string $version Version.
1953
+ *
1954
+ * @see PixCustomifyPlugin()
1955
+ * @return object Main PixCustomifyPlugin instance
1956
+ */
1957
+ public static function instance( $file = '', $version = '1.0.0' ) {
1958
+ // If the single instance hasn't been set, set it now.
1959
+ if ( is_null( self::$_instance ) ) {
1960
+ self::$_instance = new self( $file, $version );
1961
+ }
1962
+
1963
+ return self::$_instance;
1964
+ }
1965
+
1966
+ /**
1967
+ * Cloning is forbidden.
1968
+ *
1969
+ * @since 1.5.0
1970
+ */
1971
+ public function __clone() {
1972
+
1973
+ _doing_it_wrong( __FUNCTION__,esc_html( __( 'Cheatin&#8217; huh?' ) ), esc_html( $this->_version ) );
1974
+ } // End __clone ()
1975
+
1976
+ /**
1977
+ * Unserializing instances of this class is forbidden.
1978
+ *
1979
+ * @since 1.5.0
1980
+ */
1981
+ public function __wakeup() {
1982
+
1983
+ _doing_it_wrong( __FUNCTION__, esc_html( __( 'Cheatin&#8217; huh?' ) ), esc_html( $this->_version ) );
1984
+ } // End __wakeup ()
1985
  }
core/classes/HTMLElement.php CHANGED
@@ -1,9 +1,5 @@
1
  <?php defined('ABSPATH') or die;
2
 
3
- /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
4
- * it. Please see the license that came with your copy for more information.
5
- */
6
-
7
  /**
8
  * A HTMLElement is a HTMLTag with meta support integrated into it. A normal
9
  * HTMLTag only cares for it's attributes meta and nothing else, but more
@@ -12,8 +8,8 @@
12
  *
13
  * @package pixcustomify
14
  * @category core
15
- * @author Pixel Grade Team
16
- * @copyright (c) 2013, Pixel Grade Media
17
  */
18
  class PixCustomifyHTMLElementImpl extends PixCustomifyHTMLTagImpl implements PixCustomifyHTMLElement {
19
 
1
  <?php defined('ABSPATH') or die;
2
 
 
 
 
 
3
  /**
4
  * A HTMLElement is a HTMLTag with meta support integrated into it. A normal
5
  * HTMLTag only cares for it's attributes meta and nothing else, but more
8
  *
9
  * @package pixcustomify
10
  * @category core
11
+ * @author Pixelgrade Team
12
+ * @copyright (c) 2013, Pixelgrade
13
  */
14
  class PixCustomifyHTMLElementImpl extends PixCustomifyHTMLTagImpl implements PixCustomifyHTMLElement {
15
 
core/classes/HTMLTag.php CHANGED
@@ -1,14 +1,10 @@
1
  <?php defined('ABSPATH') or die;
2
 
3
- /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
4
- * it. Please see the license that came with your copy for more information.
5
- */
6
-
7
  /**
8
  * @package pixcustomify
9
  * @category core
10
- * @author Pixel Grade Team
11
- * @copyright (c) 2013, Pixel Grade Media
12
  */
13
  class PixCustomifyHTMLTagImpl implements PixCustomifyHTMLTag {
14
 
1
  <?php defined('ABSPATH') or die;
2
 
 
 
 
 
3
  /**
4
  * @package pixcustomify
5
  * @category core
6
+ * @author Pixelgrade Team
7
+ * @copyright (c) 2013, Pixelgrade
8
  */
9
  class PixCustomifyHTMLTagImpl implements PixCustomifyHTMLTag {
10
 
core/classes/Meta.php CHANGED
@@ -1,14 +1,10 @@
1
  <?php defined('ABSPATH') or die;
2
 
3
- /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
4
- * it. Please see the license that came with your copy for more information.
5
- */
6
-
7
  /**
8
  * @package pixcustomify
9
  * @category core
10
- * @author Pixel Grade Team
11
- * @copyright (c) 2013, Pixel Grade Media
12
  */
13
  class PixCustomifyMetaImpl implements PixCustomifyMeta {
14
 
1
  <?php defined('ABSPATH') or die;
2
 
 
 
 
 
3
  /**
4
  * @package pixcustomify
5
  * @category core
6
+ * @author Pixelgrade Team
7
+ * @copyright (c) 2013, Pixelgrade
8
  */
9
  class PixCustomifyMetaImpl implements PixCustomifyMeta {
10
 
core/classes/Processor.php CHANGED
@@ -1,14 +1,10 @@
1
  <?php defined('ABSPATH') or die;
2
 
3
- /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
4
- * it. Please see the license that came with your copy for more information.
5
- */
6
-
7
  /**
8
  * @package pixcustomify
9
  * @category core
10
- * @author Pixel Grade Team
11
- * @copyright (c) 2013, Pixel Grade Media
12
  */
13
  class PixCustomifyProcessorImpl implements PixCustomifyProcessor {
14
 
1
  <?php defined('ABSPATH') or die;
2
 
 
 
 
 
3
  /**
4
  * @package pixcustomify
5
  * @category core
6
+ * @author Pixelgrade Team
7
+ * @copyright (c) 2013, Pixelgrade
8
  */
9
  class PixCustomifyProcessorImpl implements PixCustomifyProcessor {
10
 
core/classes/Validator.php CHANGED
@@ -1,14 +1,10 @@
1
  <?php defined('ABSPATH') or die;
2
 
3
- /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
4
- * it. Please see the license that came with your copy for more information.
5
- */
6
-
7
  /**
8
  * @package pixcustomify
9
  * @category core
10
- * @author Pixel Grade Team
11
- * @copyright (c) 2013, Pixel Grade Media
12
  */
13
  class PixCustomifyValidatorImpl implements PixCustomifyValidator {
14
 
1
  <?php defined('ABSPATH') or die;
2
 
 
 
 
 
3
  /**
4
  * @package pixcustomify
5
  * @category core
6
+ * @author Pixelgrade Team
7
+ * @copyright (c) 2013, Pixelgrade
8
  */
9
  class PixCustomifyValidatorImpl implements PixCustomifyValidator {
10
 
core/classes/forms/Form.php CHANGED
@@ -1,14 +1,10 @@
1
  <?php defined('ABSPATH') or die;
2
 
3
- /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
4
- * it. Please see the license that came with your copy for more information.
5
- */
6
-
7
  /**
8
  * @package pixcustomify
9
  * @category core
10
- * @author Pixel Grade Team
11
- * @copyright (c) 2013, Pixel Grade Media
12
  */
13
  class PixCustomifyFormImpl extends PixCustomifyHTMLElementImpl implements PixCustomifyForm {
14
 
1
  <?php defined('ABSPATH') or die;
2
 
 
 
 
 
3
  /**
4
  * @package pixcustomify
5
  * @category core
6
+ * @author Pixelgrade Team
7
+ * @copyright (c) 2013, Pixelgrade
8
  */
9
  class PixCustomifyFormImpl extends PixCustomifyHTMLElementImpl implements PixCustomifyForm {
10
 
core/classes/forms/FormField.php CHANGED
@@ -1,14 +1,10 @@
1
  <?php defined('ABSPATH') or die;
2
 
3
- /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
4
- * it. Please see the license that came with your copy for more information.
5
- */
6
-
7
  /**
8
  * @package pixcustomify
9
  * @category core
10
- * @author Pixel Grade Team
11
- * @copyright (c) 2013, Pixel Grade Media
12
  */
13
  class PixCustomifyFormFieldImpl extends PixCustomifyHTMLElementImpl implements PixCustomifyFormField {
14
 
1
  <?php defined('ABSPATH') or die;
2
 
 
 
 
 
3
  /**
4
  * @package pixcustomify
5
  * @category core
6
+ * @author Pixelgrade Team
7
+ * @copyright (c) 2013, Pixelgrade
8
  */
9
  class PixCustomifyFormFieldImpl extends PixCustomifyHTMLElementImpl implements PixCustomifyFormField {
10
 
core/core.php CHANGED
@@ -1,9 +1,5 @@
1
  <?php defined('ABSPATH') or die;
2
 
3
- /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
4
- * it. Please see the license that came with your copy for more information.
5
- */
6
-
7
  /**
8
  * @package pixcustomify
9
  * @category core
@@ -268,7 +264,7 @@ class pixcustomify {
268
 
269
  foreach ($priority_list as $file => $priority) {
270
  if (strpos($file, EXT)) {
271
- require $file;
272
  }
273
  }
274
  }
@@ -287,8 +283,10 @@ class pixcustomify {
287
  }
288
 
289
  static function option( $option, $default = null ) {
 
 
290
 
291
- return PixCustomifyPlugin::get_option($option, $default = null);
292
 
293
  }
294
 
1
  <?php defined('ABSPATH') or die;
2
 
 
 
 
 
3
  /**
4
  * @package pixcustomify
5
  * @category core
264
 
265
  foreach ($priority_list as $file => $priority) {
266
  if (strpos($file, EXT)) {
267
+ require_once $file;
268
  }
269
  }
270
  }
283
  }
284
 
285
  static function option( $option, $default = null ) {
286
+ /** @var PixCustomifyPlugin $local_plugin */
287
+ $local_plugin = PixCustomifyPlugin();
288
 
289
+ return $local_plugin->get_option($option, $default = null);
290
 
291
  }
292
 
core/interfaces/HTMLElement.php CHANGED
@@ -1,14 +1,10 @@
1
  <?php defined('ABSPATH') or die;
2
 
3
- /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
4
- * it. Please see the license that came with your copy for more information.
5
- */
6
-
7
  /**
8
  * @package pixcustomify
9
  * @category core
10
- * @author Pixel Grade Team
11
- * @copyright (c) 2013, Pixel Grade Media
12
  */
13
  interface PixCustomifyHTMLElement extends PixCustomifyHTMLTag {
14
 
1
  <?php defined('ABSPATH') or die;
2
 
 
 
 
 
3
  /**
4
  * @package pixcustomify
5
  * @category core
6
+ * @author Pixelgrade Team
7
+ * @copyright (c) 2013, Pixelgrade
8
  */
9
  interface PixCustomifyHTMLElement extends PixCustomifyHTMLTag {
10
 
core/interfaces/HTMLTag.php CHANGED
@@ -1,14 +1,10 @@
1
  <?php defined('ABSPATH') or die;
2
 
3
- /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
4
- * it. Please see the license that came with your copy for more information.
5
- */
6
-
7
  /**
8
  * @package pixcustomify
9
  * @category core
10
- * @author Pixel Grade Team
11
- * @copyright (c) 2013, Pixel Grade Media
12
  */
13
  interface PixCustomifyHTMLTag {
14
 
1
  <?php defined('ABSPATH') or die;
2
 
 
 
 
 
3
  /**
4
  * @package pixcustomify
5
  * @category core
6
+ * @author Pixelgrade Team
7
+ * @copyright (c) 2013, Pixelgrade
8
  */
9
  interface PixCustomifyHTMLTag {
10
 
core/interfaces/Meta.php CHANGED
@@ -1,14 +1,10 @@
1
  <?php defined('ABSPATH') or die;
2
 
3
- /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
4
- * it. Please see the license that came with your copy for more information.
5
- */
6
-
7
  /**
8
  * @package pixcustomify
9
  * @category core
10
- * @author Pixel Grade Team
11
- * @copyright (c) 2013, Pixel Grade Media
12
  */
13
  interface PixCustomifyMeta {
14
 
1
  <?php defined('ABSPATH') or die;
2
 
 
 
 
 
3
  /**
4
  * @package pixcustomify
5
  * @category core
6
+ * @author Pixelgrade Team
7
+ * @copyright (c) 2013, Pixelgrade
8
  */
9
  interface PixCustomifyMeta {
10
 
core/interfaces/Processor.php CHANGED
@@ -1,14 +1,10 @@
1
  <?php defined('ABSPATH') or die;
2
 
3
- /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
4
- * it. Please see the license that came with your copy for more information.
5
- */
6
-
7
  /**
8
  * @package pixcustomify
9
  * @category core
10
- * @author Pixel Grade Team
11
- * @copyright (c) 2013, Pixel Grade Media
12
  */
13
  interface PixCustomifyProcessor {
14
 
1
  <?php defined('ABSPATH') or die;
2
 
 
 
 
 
3
  /**
4
  * @package pixcustomify
5
  * @category core
6
+ * @author Pixelgrade Team
7
+ * @copyright (c) 2013, Pixelgrade
8
  */
9
  interface PixCustomifyProcessor {
10
 
core/interfaces/Validator.php CHANGED
@@ -1,14 +1,10 @@
1
  <?php defined('ABSPATH') or die;
2
 
3
- /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
4
- * it. Please see the license that came with your copy for more information.
5
- */
6
-
7
  /**
8
  * @package pixcustomify
9
  * @category core
10
- * @author Pixel Grade Team
11
- * @copyright (c) 2013, Pixel Grade Media
12
  */
13
  interface PixCustomifyValidator {
14
 
1
  <?php defined('ABSPATH') or die;
2
 
 
 
 
 
3
  /**
4
  * @package pixcustomify
5
  * @category core
6
+ * @author Pixelgrade Team
7
+ * @copyright (c) 2013, Pixelgrade
8
  */
9
  interface PixCustomifyValidator {
10
 
core/interfaces/extended/Form.php CHANGED
@@ -1,14 +1,10 @@
1
  <?php defined('ABSPATH') or die;
2
 
3
- /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
4
- * it. Please see the license that came with your copy for more information.
5
- */
6
-
7
  /**
8
  * @package pixcustomify
9
  * @category core
10
- * @author Pixel Grade Team
11
- * @copyright (c) 2013, Pixel Grade Media
12
  */
13
  interface PixCustomifyForm extends PixCustomifyHTMLElement {
14
 
1
  <?php defined('ABSPATH') or die;
2
 
 
 
 
 
3
  /**
4
  * @package pixcustomify
5
  * @category core
6
+ * @author Pixelgrade Team
7
+ * @copyright (c) 2013, Pixelgrade
8
  */
9
  interface PixCustomifyForm extends PixCustomifyHTMLElement {
10
 
core/interfaces/extended/FormField.php CHANGED
@@ -1,14 +1,10 @@
1
  <?php defined('ABSPATH') or die;
2
 
3
- /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
4
- * it. Please see the license that came with your copy for more information.
5
- */
6
-
7
  /**
8
  * @package pixcustomify
9
  * @category core
10
- * @author Pixel Grade Team
11
- * @copyright (c) 2013, Pixel Grade Media
12
  */
13
  interface PixCustomifyFormField extends PixCustomifyHTMLElement {
14
 
1
  <?php defined('ABSPATH') or die;
2
 
 
 
 
 
3
  /**
4
  * @package pixcustomify
5
  * @category core
6
+ * @author Pixelgrade Team
7
+ * @copyright (c) 2013, Pixelgrade
8
  */
9
  interface PixCustomifyFormField extends PixCustomifyHTMLElement {
10
 
customify.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
  /*
3
  Plugin Name: Customify
4
- Plugin URI: https://pixelgrade.com
5
  Description: A Theme Customizer Booster
6
- Version: 1.4.2
7
  Author: PixelGrade
8
  Author URI: https://pixelgrade.com
9
  Author Email: contact@pixelgrade.com
@@ -35,33 +35,33 @@ pixcustomify::settextdomain('customify');
35
 
36
  $defaults = include 'plugin-defaults'.EXT;
37
 
38
- $current_data = get_option($config['settings-key']);
39
 
40
- if ($current_data === false) {
41
- add_option($config['settings-key'], $defaults);
42
- }
43
- else if (count(array_diff_key($defaults, $current_data)) != 0) {
44
- $plugindata = array_merge($defaults, $current_data);
45
- update_option($config['settings-key'], $plugindata);
46
  }
47
  # else: data is available; do nothing
48
 
49
- // Load Callbacks
50
- // --------------
51
-
52
- $basepath = dirname(__FILE__).DIRECTORY_SEPARATOR;
53
- $callbackpath = $basepath.'callbacks'.DIRECTORY_SEPARATOR;
54
- pixcustomify::require_all($callbackpath);
55
-
56
- require_once( plugin_dir_path( __FILE__ ) . 'class-pixcustomify.php' );
57
 
58
- // Register hooks that are fired when the plugin is activated, deactivated, and uninstalled, respectively.
59
- register_activation_hook( __FILE__, array( 'PixCustomifyPlugin', 'activate' ) );
60
- //register_deactivation_hook( __FILE__, array( 'customifyPlugin', 'deactivate' ) );
 
61
 
 
 
 
62
 
63
- function customify_init_plugin () {
64
- global $pixcustomify_plugin;
65
- $pixcustomify_plugin = PixCustomifyPlugin::get_instance();
66
- }
67
- add_action('plugins_loaded', 'customify_init_plugin', 20 );
1
  <?php
2
  /*
3
  Plugin Name: Customify
4
+ Plugin URI: https://wordpress.org/plugins/customify/
5
  Description: A Theme Customizer Booster
6
+ Version: 1.5.0
7
  Author: PixelGrade
8
  Author URI: https://pixelgrade.com
9
  Author Email: contact@pixelgrade.com
35
 
36
  $defaults = include 'plugin-defaults'.EXT;
37
 
38
+ $current_data = get_option( $config['settings-key'] );
39
 
40
+ if ( $current_data === false ) {
41
+ add_option( $config['settings-key'], $defaults );
42
+ } elseif ( count( array_diff_key( $defaults, $current_data ) ) != 0) {
43
+ $plugindata = array_merge( $defaults, $current_data );
44
+ update_option( $config['settings-key'], $plugindata );
 
45
  }
46
  # else: data is available; do nothing
47
 
48
+ /**
49
+ * Returns the main instance of PixCustomifyPlugin to prevent the need to use globals.
50
+ *
51
+ * @since 1.5.0
52
+ * @return PixCustomifyPlugin
53
+ */
54
+ function PixCustomifyPlugin() {
 
55
 
56
+ require_once( plugin_dir_path( __FILE__ ) . 'class-pixcustomify.php' );
57
+ $instance = PixCustomifyPlugin::instance( __FILE__, '1.5.0' );
58
+ return $instance;
59
+ }
60
 
61
+ // Now get the party started
62
+ // We will keep this global variable for legacy
63
+ $pixcustomify_plugin = PixCustomifyPlugin();
64
 
65
+ // Load custom modules
66
+ require_once( 'features/class-CSS_Editor.php' );
67
+ require_once( 'features/class-Font_Selector.php' );
 
 
features/class-CSS_Editor.php CHANGED
@@ -13,7 +13,7 @@ class Customify_CSS_Live_Editor {
13
 
14
  add_action( 'customify_create_custom_control', array( $this, 'cle_create_custom_control' ), 10, 1 );
15
  add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_admin_customizer_styles' ), 10 );
16
- $load_location = PixCustomifyPlugin::get_plugin_option( 'style_resources_location', 'wp_head' );
17
 
18
  if ( function_exists( 'wp_custom_css_cb' ) ) {
19
  remove_action( 'wp_head', 'wp_custom_css_cb', 11 );
@@ -35,7 +35,7 @@ class Customify_CSS_Live_Editor {
35
  public static function get_instance() {
36
 
37
  // If the single instance hasn't been set, set it now.
38
- if ( null == self::$instance ) {
39
  self::$instance = new self;
40
  }
41
 
@@ -63,7 +63,7 @@ class Customify_CSS_Live_Editor {
63
  // port CSS if
64
  if ( function_exists( 'wp_update_custom_css_post' ) ) {
65
  // Migrate any existing theme CSS to the core option added in WordPress 4.7.
66
- $store_type = PixCustomifyPlugin::get_plugin_option( 'values_store_mod', 'option' );
67
 
68
  $default_css = __( "/*
69
  * Welcome to the Custom CSS Editor
@@ -120,7 +120,7 @@ selector {
120
  'title' => __( 'CSS Editor', 'customify' ),
121
  ) );
122
 
123
- $saving_type = PixCustomifyPlugin::get_plugin_option( 'values_store_mod', 'option' );
124
 
125
  $wp_customize->add_setting( 'live_css_edit', array(
126
  'type' => $saving_type,
@@ -168,7 +168,7 @@ selector {
168
  return;
169
  }
170
 
171
- $store_type = PixCustomifyPlugin::get_plugin_option( 'values_store_mod', 'option' );
172
  if ( $store_type === 'option' ) {
173
  $output = get_option( 'live_css_edit' );
174
  } elseif ( $store_type === 'theme_mod' ) {
13
 
14
  add_action( 'customify_create_custom_control', array( $this, 'cle_create_custom_control' ), 10, 1 );
15
  add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_admin_customizer_styles' ), 10 );
16
+ $load_location = PixCustomifyPlugin()->get_plugin_setting( 'style_resources_location', 'wp_head' );
17
 
18
  if ( function_exists( 'wp_custom_css_cb' ) ) {
19
  remove_action( 'wp_head', 'wp_custom_css_cb', 11 );
35
  public static function get_instance() {
36
 
37
  // If the single instance hasn't been set, set it now.
38
+ if ( is_null( self::$instance ) ) {
39
  self::$instance = new self;
40
  }
41
 
63
  // port CSS if
64
  if ( function_exists( 'wp_update_custom_css_post' ) ) {
65
  // Migrate any existing theme CSS to the core option added in WordPress 4.7.
66
+ $store_type = PixCustomifyPlugin()->get_plugin_setting( 'values_store_mod', 'option' );
67
 
68
  $default_css = __( "/*
69
  * Welcome to the Custom CSS Editor
120
  'title' => __( 'CSS Editor', 'customify' ),
121
  ) );
122
 
123
+ $saving_type = PixCustomifyPlugin()->get_plugin_setting( 'values_store_mod', 'option' );
124
 
125
  $wp_customize->add_setting( 'live_css_edit', array(
126
  'type' => $saving_type,
168
  return;
169
  }
170
 
171
+ $store_type = PixCustomifyPlugin()->get_plugin_setting( 'values_store_mod', 'option' );
172
  if ( $store_type === 'option' ) {
173
  $output = get_option( 'live_css_edit' );
174
  } elseif ( $store_type === 'theme_mod' ) {
features/class-Customify_Importer.php CHANGED
@@ -468,9 +468,7 @@ final class Customify_Importer_Controller {
468
 
469
  protected function get_customify_field_data( $option_key, $step_id ) {
470
 
471
- global $pixcustomify_plugin;
472
-
473
- $options = $pixcustomify_plugin->get_options_configs();
474
 
475
  if ( ! isset( $options[ $option_key ] ) ) {
476
  wp_send_json_error( 'inexistent key' );
468
 
469
  protected function get_customify_field_data( $option_key, $step_id ) {
470
 
471
+ $options = PixCustomifyPlugin()->get_options_configs();
 
 
472
 
473
  if ( ! isset( $options[ $option_key ] ) ) {
474
  wp_send_json_error( 'inexistent key' );
features/class-Font_Selector.php CHANGED
@@ -1,41 +1,40 @@
1
  <?php
2
 
3
- class Customify_Font_Selector extends PixCustomifyPlugin {
4
 
5
  /**
6
  * Instance of this class.
7
  * @since 1.0.0
8
  * @var object
9
  */
10
- protected static $instance = null;
11
- protected $parent = null;
12
  protected static $typo_settings = null;
13
  protected static $options_list = null;
14
- static $theme_fonts = null;
15
  protected $customify_CSS_output = array();
16
 
17
 
18
- function __construct( $parent ) {
19
- global $pixcustomify_plugin;
20
-
21
- $load_location = PixCustomifyPlugin::get_plugin_option( 'style_resources_location', 'wp_head' );
22
 
 
23
  add_action( $load_location, array( $this, 'output_font_dynamic_style' ), 999999999 );
24
-
25
- $this->parent = $parent;
26
- self::$theme_fonts = apply_filters( 'customify_theme_fonts', array() );
27
-
28
  add_action( 'customify_font_family_before_options', array( $this, 'add_customify_theme_fonts' ), 11, 2 );
29
  }
30
 
 
 
 
 
31
  function add_customify_theme_fonts( $active_font_family, $val ) {
32
  //first get all the published custom fonts
33
- if ( empty( self::$theme_fonts ) ) {
34
  return;
35
  }
36
 
37
  echo '<optgroup label="' . esc_html__( 'Theme Fonts', 'customify' ) . '">';
38
- foreach ( self::$theme_fonts as $font ) {
39
  if ( ! empty( $font ) ) {
40
  //display the select option's HTML
41
  Pix_Customize_Font_Control::output_font_option( $font['family'], $active_font_family, $font, 'theme_font' );
@@ -56,9 +55,12 @@ class Customify_Font_Selector extends PixCustomifyPlugin {
56
 
57
  function output_font_dynamic_style() {
58
 
59
- self::$options_list = $this->get_options();
 
 
 
60
 
61
- self::get_typography_fields( self::$options_list, 'type', 'font', self::$typo_settings );
62
 
63
  if ( empty( self::$typo_settings ) ) {
64
  return;
@@ -86,7 +88,7 @@ class Customify_Font_Selector extends PixCustomifyPlugin {
86
 
87
  // in case the value is still null, try default value(mostly for google fonts)
88
  if ( ! is_array( $value ) || $value === null ) {
89
- $value = $this->get_font_defaults_value( str_replace( '"', '', $font['value'] ) );
90
  }
91
 
92
  //bail if by this time we don't have a value of some sort
@@ -95,8 +97,8 @@ class Customify_Font_Selector extends PixCustomifyPlugin {
95
  }
96
 
97
  //Handle special logic for when the $value array is not an associative array
98
- if ( ! self::is_assoc( $value ) ) {
99
- $value = $this->process_a_not_associative_font_default( $value );
100
  }
101
 
102
  if ( isset( $value['font_family'] ) && isset( $value['type'] ) && $value['type'] == 'google' ) {
@@ -133,24 +135,24 @@ class Customify_Font_Selector extends PixCustomifyPlugin {
133
  }
134
 
135
  $args['google_families'] .= '\',';
136
- } elseif ( isset( self::$theme_fonts[ $value['font_family'] ] ) ) {
137
 
138
  // $value['type'] = 'theme_font';
139
- // $args['local_srcs'] .= self::$theme_fonts[ $value['font_family'] ]['src'] . ',';
140
- // $value['variants'] = self::$theme_fonts[ $value['font_family'] ]['variants'];
141
 
142
  if ( false === strpos( $args['local_families'], $value['font_family'] ) ) {
143
  $args['local_families'] .= "'" . $value['font_family'] . "',";
144
  }
145
 
146
- if ( false === strpos( $args['local_srcs'], self::$theme_fonts[ $value['font_family'] ]['src'] ) ) {
147
- $args['local_srcs'] .= "'" . self::$theme_fonts[ $value['font_family'] ]['src'] . "',";
148
  }
149
  }
150
  }
151
  }
152
 
153
- if ( ( ! empty ( $args['local_families'] ) || ! empty ( $args['google_families'] ) ) && self::get_plugin_option( 'typography', '1' ) && self::get_plugin_option( 'typography_google_fonts', 1 ) ) {
154
  $this->display_webfont_script( $args );
155
  }
156
 
@@ -161,7 +163,7 @@ class Customify_Font_Selector extends PixCustomifyPlugin {
161
  $value = $this->maybe_decode_value( $font['value'] );
162
 
163
  if ( $value === null ) {
164
- $value = $this->get_font_defaults_value( $font['value'] );
165
  }
166
 
167
  // shim the old case when the default was only the font name
@@ -170,8 +172,8 @@ class Customify_Font_Selector extends PixCustomifyPlugin {
170
  }
171
 
172
  //Handle special logic for when the $value array is not an associative array
173
- if ( ! self::is_assoc( $value ) ) {
174
- $value = $this->process_a_not_associative_font_default( $value );
175
  }
176
 
177
  $this->output_font_style( $key, $font, $value );
@@ -336,7 +338,7 @@ class Customify_Font_Selector extends PixCustomifyPlugin {
336
 
337
  if ( isset( $GLOBALS['wp_customize'] ) ) { ?>
338
  <style id="customify_font_output_for_<?php echo $field; ?>">
339
- <?php $CSS ?>
340
  </style><?php
341
  return;
342
  } else {
@@ -406,4 +408,42 @@ class Customify_Font_Selector extends PixCustomifyPlugin {
406
 
407
  return $has_style;
408
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
409
  }
1
  <?php
2
 
3
+ class Customify_Font_Selector {
4
 
5
  /**
6
  * Instance of this class.
7
  * @since 1.0.0
8
  * @var object
9
  */
10
+ protected static $_instance = null;
11
+
12
  protected static $typo_settings = null;
13
  protected static $options_list = null;
14
+ protected $theme_fonts = null;
15
  protected $customify_CSS_output = array();
16
 
17
 
18
+ function __construct() {
19
+ $this->theme_fonts = apply_filters( 'customify_theme_fonts', array() );
 
 
20
 
21
+ $load_location = PixCustomifyPlugin()->get_plugin_setting( 'style_resources_location', 'wp_head' );
22
  add_action( $load_location, array( $this, 'output_font_dynamic_style' ), 999999999 );
 
 
 
 
23
  add_action( 'customify_font_family_before_options', array( $this, 'add_customify_theme_fonts' ), 11, 2 );
24
  }
25
 
26
+ public function get_theme_fonts() {
27
+ return $this->theme_fonts;
28
+ }
29
+
30
  function add_customify_theme_fonts( $active_font_family, $val ) {
31
  //first get all the published custom fonts
32
+ if ( empty( $this->theme_fonts ) ) {
33
  return;
34
  }
35
 
36
  echo '<optgroup label="' . esc_html__( 'Theme Fonts', 'customify' ) . '">';
37
+ foreach ( $this->theme_fonts as $font ) {
38
  if ( ! empty( $font ) ) {
39
  //display the select option's HTML
40
  Pix_Customize_Font_Control::output_font_option( $font['family'], $active_font_family, $font, 'theme_font' );
55
 
56
  function output_font_dynamic_style() {
57
 
58
+ /** @var PixCustomifyPlugin $local_plugin */
59
+ $local_plugin = PixCustomifyPlugin();
60
+
61
+ self::$options_list = $local_plugin->get_options();
62
 
63
+ $local_plugin->get_typography_fields( self::$options_list, 'type', 'font', self::$typo_settings );
64
 
65
  if ( empty( self::$typo_settings ) ) {
66
  return;
88
 
89
  // in case the value is still null, try default value(mostly for google fonts)
90
  if ( ! is_array( $value ) || $value === null ) {
91
+ $value = $local_plugin->get_font_defaults_value( str_replace( '"', '', $font['value'] ) );
92
  }
93
 
94
  //bail if by this time we don't have a value of some sort
97
  }
98
 
99
  //Handle special logic for when the $value array is not an associative array
100
+ if ( ! $local_plugin->is_assoc( $value ) ) {
101
+ $value = $local_plugin->process_a_not_associative_font_default( $value );
102
  }
103
 
104
  if ( isset( $value['font_family'] ) && isset( $value['type'] ) && $value['type'] == 'google' ) {
135
  }
136
 
137
  $args['google_families'] .= '\',';
138
+ } elseif ( isset( $this->theme_fonts[ $value['font_family'] ] ) ) {
139
 
140
  // $value['type'] = 'theme_font';
141
+ // $args['local_srcs'] .= $this->theme_fonts[ $value['font_family'] ]['src'] . ',';
142
+ // $value['variants'] = $this->theme_fonts[ $value['font_family'] ]['variants'];
143
 
144
  if ( false === strpos( $args['local_families'], $value['font_family'] ) ) {
145
  $args['local_families'] .= "'" . $value['font_family'] . "',";
146
  }
147
 
148
+ if ( false === strpos( $args['local_srcs'], $this->theme_fonts[ $value['font_family'] ]['src'] ) ) {
149
+ $args['local_srcs'] .= "'" . $this->theme_fonts[ $value['font_family'] ]['src'] . "',";
150
  }
151
  }
152
  }
153
  }
154
 
155
+ if ( ( ! empty ( $args['local_families'] ) || ! empty ( $args['google_families'] ) ) && PixCustomifyPlugin()->get_plugin_setting( 'typography', '1' ) && PixCustomifyPlugin()->get_plugin_setting( 'typography_google_fonts', 1 ) ) {
156
  $this->display_webfont_script( $args );
157
  }
158
 
163
  $value = $this->maybe_decode_value( $font['value'] );
164
 
165
  if ( $value === null ) {
166
+ $value = $local_plugin->get_font_defaults_value( $font['value'] );
167
  }
168
 
169
  // shim the old case when the default was only the font name
172
  }
173
 
174
  //Handle special logic for when the $value array is not an associative array
175
+ if ( ! $local_plugin->is_assoc( $value ) ) {
176
+ $value = $local_plugin->process_a_not_associative_font_default( $value );
177
  }
178
 
179
  $this->output_font_style( $key, $font, $value );
338
 
339
  if ( isset( $GLOBALS['wp_customize'] ) ) { ?>
340
  <style id="customify_font_output_for_<?php echo $field; ?>">
341
+ <?php echo $CSS ?>
342
  </style><?php
343
  return;
344
  } else {
408
 
409
  return $has_style;
410
  }
411
+
412
+ /**
413
+ * Main Customify_Font_Selector Instance
414
+ *
415
+ * Ensures only one instance of Customify_Font_Selector is loaded or can be loaded.
416
+ *
417
+ * @since 1.0.0
418
+ * @static
419
+ *
420
+ * @return Customify_Font_Selector Main Customify_Font_Selector instance
421
+ */
422
+ public static function instance() {
423
+
424
+ if ( is_null( self::$_instance ) ) {
425
+ self::$_instance = new self();
426
+ }
427
+ return self::$_instance;
428
+ } // End instance ()
429
+
430
+ /**
431
+ * Cloning is forbidden.
432
+ *
433
+ * @since 1.0.0
434
+ */
435
+ public function __clone() {
436
+
437
+ _doing_it_wrong( __FUNCTION__,esc_html( __( 'Cheatin&#8217; huh?' ) ), '' );
438
+ } // End __clone ()
439
+
440
+ /**
441
+ * Unserializing instances of this class is forbidden.
442
+ *
443
+ * @since 1.0.0
444
+ */
445
+ public function __wakeup() {
446
+
447
+ _doing_it_wrong( __FUNCTION__, esc_html( __( 'Cheatin&#8217; huh?' ) ), '' );
448
+ } // End __wakeup ()
449
  }
features/customizer/controls/class-Pix_Customize_Font_Control.php CHANGED
@@ -168,9 +168,9 @@ class Pix_Customize_Font_Control extends Pix_Customize_Control {
168
 
169
  do_action( 'customify_font_family_before_google_fonts_options' );
170
 
171
- if ( PixCustomifyPlugin::get_plugin_option( 'typography_google_fonts' ) ) {
172
 
173
- if ( PixCustomifyPlugin::get_plugin_option( 'typography_group_google_fonts' ) ) {
174
 
175
  $grouped_google_fonts = array();
176
  foreach ( self::$google_fonts as $key => $font ) {
@@ -276,7 +276,7 @@ class Pix_Customize_Font_Control extends Pix_Customize_Control {
276
  // Allow others to add options here
277
  do_action( 'customify_font_family_before_standard_fonts_options', $font_family, $current_value );
278
 
279
- if ( PixCustomifyPlugin::get_plugin_option( 'typography_standard_fonts' ) ) {
280
 
281
  echo '<optgroup label="' . __( 'Standard fonts', 'customify' ) . '">';
282
  foreach ( self::$std_fonts as $key => $font ) {
@@ -579,7 +579,7 @@ class Pix_Customize_Font_Control extends Pix_Customize_Control {
579
  if ( isset( $this->default ) && is_array( $this->default ) ) {
580
 
581
  //Handle special logic for when the $value array is not an associative array
582
- if ( ! PixCustomifyPlugin::is_assoc( $this->default ) ) {
583
 
584
  //Let's determine some type of font
585
  if ( ! isset( $this->default[2] ) || ( isset( $this->default[2] ) && 'google' == $this->default[2] ) ) {
@@ -690,7 +690,7 @@ class Pix_Customize_Font_Control extends Pix_Customize_Control {
690
  */
691
  public function input_field_atts( $atts ) {
692
 
693
- if ( ! PixCustomifyPlugin::is_assoc( $atts ) ) {
694
  $defaults = array(
695
  'min',
696
  'max',
168
 
169
  do_action( 'customify_font_family_before_google_fonts_options' );
170
 
171
+ if ( PixCustomifyPlugin()->get_plugin_setting( 'typography_google_fonts' ) ) {
172
 
173
+ if ( PixCustomifyPlugin()->get_plugin_setting( 'typography_group_google_fonts' ) ) {
174
 
175
  $grouped_google_fonts = array();
176
  foreach ( self::$google_fonts as $key => $font ) {
276
  // Allow others to add options here
277
  do_action( 'customify_font_family_before_standard_fonts_options', $font_family, $current_value );
278
 
279
+ if ( PixCustomifyPlugin()->get_plugin_setting( 'typography_standard_fonts' ) ) {
280
 
281
  echo '<optgroup label="' . __( 'Standard fonts', 'customify' ) . '">';
282
  foreach ( self::$std_fonts as $key => $font ) {
579
  if ( isset( $this->default ) && is_array( $this->default ) ) {
580
 
581
  //Handle special logic for when the $value array is not an associative array
582
+ if ( ! PixCustomifyPlugin()->is_assoc( $this->default ) ) {
583
 
584
  //Let's determine some type of font
585
  if ( ! isset( $this->default[2] ) || ( isset( $this->default[2] ) && 'google' == $this->default[2] ) ) {
690
  */
691
  public function input_field_atts( $atts ) {
692
 
693
+ if ( ! PixCustomifyPlugin()->is_assoc( $atts ) ) {
694
  $defaults = array(
695
  'min',
696
  'max',
features/customizer/controls/class-Pix_Customize_Text_Control.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * Class Pix_Customize_Text_Control
5
  * A simple Text Control
1
  <?php
 
2
  /**
3
  * Class Pix_Customize_Text_Control
4
  * A simple Text Control
features/customizer/controls/class-Pix_Customize_Textarea_Control.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /**
4
- * Class Pix_Customize_Text_Control
5
  * A simple Text Control
6
  */
7
  class Pix_Customize_Textarea_Control extends Pix_Customize_Control {
1
  <?php
2
 
3
  /**
4
+ * Class Pix_Customize_Textarea_Control
5
  * A simple Text Control
6
  */
7
  class Pix_Customize_Textarea_Control extends Pix_Customize_Control {
features/customizer/controls/class-Pix_Customize_Typography_Control.php CHANGED
@@ -188,7 +188,7 @@ class Pix_Customize_Typography_Control extends Pix_Customize_Control {
188
  // Allow others to add options here
189
  do_action( 'customify_typography_font_family_before_standard_fonts_options', $font_family, $current_value );
190
 
191
- if ( PixCustomifyPlugin::get_plugin_option( 'typography_standard_fonts' ) ) {
192
 
193
  echo '<optgroup label="' . __( 'Standard fonts', 'customify' ) . '">';
194
  foreach ( self::$std_fonts as $key => $font ) {
@@ -200,9 +200,9 @@ class Pix_Customize_Typography_Control extends Pix_Customize_Control {
200
  // Allow others to add options here
201
  do_action( 'customify_typography_font_family_before_google_fonts_options' );
202
 
203
- if ( PixCustomifyPlugin::get_plugin_option( 'typography_google_fonts' ) ) {
204
 
205
- if ( PixCustomifyPlugin::get_plugin_option( 'typography_group_google_fonts' ) ) {
206
 
207
  $grouped_google_fonts = array();
208
  foreach ( self::$google_fonts as $key => $font ) {
@@ -401,7 +401,7 @@ class Pix_Customize_Typography_Control extends Pix_Customize_Control {
401
  if (isset( $this->default ) && is_array( $this->default ) ) {
402
 
403
  //Handle special logic for when the $value array is not an associative array
404
- if ( ! PixCustomifyPlugin::is_assoc( $this->default ) ) {
405
 
406
  //Let's determine some type of font
407
  if ( ! isset( $this->default[2] ) || ( isset( $this->default[2] ) && 'google' == $this->default[2] ) ) {
188
  // Allow others to add options here
189
  do_action( 'customify_typography_font_family_before_standard_fonts_options', $font_family, $current_value );
190
 
191
+ if ( PixCustomifyPlugin()->get_plugin_setting( 'typography_standard_fonts' ) ) {
192
 
193
  echo '<optgroup label="' . __( 'Standard fonts', 'customify' ) . '">';
194
  foreach ( self::$std_fonts as $key => $font ) {
200
  // Allow others to add options here
201
  do_action( 'customify_typography_font_family_before_google_fonts_options' );
202
 
203
+ if ( PixCustomifyPlugin()->get_plugin_setting( 'typography_google_fonts' ) ) {
204
 
205
+ if ( PixCustomifyPlugin()->get_plugin_setting( 'typography_group_google_fonts' ) ) {
206
 
207
  $grouped_google_fonts = array();
208
  foreach ( self::$google_fonts as $key => $font ) {
401
  if (isset( $this->default ) && is_array( $this->default ) ) {
402
 
403
  //Handle special logic for when the $value array is not an associative array
404
+ if ( ! PixCustomifyPlugin()->is_assoc( $this->default ) ) {
405
 
406
  //Let's determine some type of font
407
  if ( ! isset( $this->default[2] ) || ( isset( $this->default[2] ) && 'google' == $this->default[2] ) ) {
js/customizer.js CHANGED
@@ -1,8 +1,10 @@
1
- (function ( $, exports, api ) {
2
  'use strict';
3
 
 
 
4
  // when the customizer is ready prepare our fields events
5
- api.bind('ready', function () {
6
  var timeout = null;
7
 
8
  // add ace editors
@@ -38,7 +40,9 @@
38
  // simple select2 field
39
  $('.customify_select2').select2();
40
 
41
- customifyFontSelect.init(this);
 
 
42
 
43
  prepare_typography_field();
44
 
@@ -259,14 +263,6 @@
259
 
260
  // bind our event on click
261
  $(document).on('click', '.customify_import_demo_data_button', function ( event ) {
262
- //if ( $( this ).hasClass( '.wpGrade_button_inactive' ) ) {
263
- // return false;
264
- //} else {
265
- // $( this ).addClass( '.wpGrade_button_inactive' );
266
- // $( this ).attr( 'disabled', 'disabled' );
267
- //}
268
- //var confirmImport = confirm( listable_demodata_params.l10n.import_confirm );
269
- //if ( confirmImport == false ) return false;
270
 
271
  //@todo start an animation here
272
  var key = $(this).data('key');
@@ -972,17 +968,12 @@
972
  })(jQuery);
973
 
974
  var customifyFontSelect = (function () {
975
- var wpapi = null,
976
- fontSelector = '.customify_font_family',
977
  selectPlacehoder = "Select a font family",
978
  weightPlaceholder = "Select a font weight",
979
  subsetPlaceholder = "Select a font subset";
980
 
981
  function init( wpapi ) {
982
-
983
- this.wpapi = wpapi;
984
-
985
- setTimeout(function () {
986
  $(fontSelector).select2({
987
  placeholder: selectPlacehoder
988
  }).on('change', function ( e ) {
@@ -997,7 +988,6 @@
997
  // serialize stuff and refresh
998
  update_font_value(wraper);
999
  });
1000
- }, 333);
1001
 
1002
  $('.customify_font_weight').each(function ( i, el ) {
1003
 
@@ -1024,6 +1014,7 @@
1024
  id: weight,
1025
  text: weight
1026
  };
 
1027
  if ( selecter_variants !== null && weight == selecter_variants ) {
1028
  this_value.selected = true;
1029
  }
@@ -1044,7 +1035,7 @@
1044
  // we may update this with a live version sometime
1045
  var value_holder = wraper.children('.customify_font_values');
1046
  var setting_id = $(value_holder).data('customize-setting-link');
1047
- var setting = wpapi(setting_id);
1048
  setting.set(encodeValues(current_value));
1049
  });
1050
  });
@@ -1060,7 +1051,7 @@
1060
  // we may update this with a live version sometime
1061
  var value_holder = wraper.children('.customify_font_values');
1062
  var setting_id = $(value_holder).data('customize-setting-link');
1063
- var setting = wpapi(setting_id);
1064
  setting.set(encodeValues(current_value));
1065
  });
1066
 
@@ -1075,7 +1066,7 @@
1075
  // we may update this with a live version sometime
1076
  var value_holder = wraper.children('.customify_font_values');
1077
  var setting_id = $(value_holder).data('customize-setting-link');
1078
- var setting = wpapi(setting_id);
1079
  setting.set(encodeValues(current_value));
1080
  });
1081
  }
@@ -1088,19 +1079,18 @@
1088
  // we may update this with a live version sometime
1089
  var value_holder = wraper.children('.customify_font_values');
1090
  var setting_id = $(value_holder).data('customize-setting-link');
1091
- var setting = wpapi(setting_id);
1092
  setting.set(encodeValues(current_value));
1093
 
1094
- wpapi.previewer.send( 'font-changed' );
1095
  });
1096
  }
1097
 
1098
  var self = this;
1099
- wpapi.previewer.bind('synced', function ( e ) {
1100
- // setTimeout( function () {
1101
- self.render_fonts();
1102
- // },100);
1103
- })
1104
  }
1105
 
1106
  /**
@@ -1112,6 +1102,7 @@
1112
  function update_weight_field( option, wraper ) {
1113
  var variants = $(option).data('variants'),
1114
  font_weights = wraper.find('.customify_font_weight'),
 
1115
  new_variants = [],
1116
  type = $(option).data('type'),
1117
  id = wraper.find('.customify_font_values').data('customizeSettingLink');
@@ -1124,8 +1115,6 @@
1124
  font_weights.parent().show();
1125
  }
1126
 
1127
- var selected = 1;
1128
-
1129
  // we need to turn the data array into a specific form like [{id:"id", text:"Text"}]
1130
  $.each(variants, function ( i, j ) {
1131
  new_variants[i] = {
@@ -1133,10 +1122,9 @@
1133
  'text': j
1134
  };
1135
 
1136
- if ( selected === 3 ) {
1137
  new_variants[i].selected = true;
1138
  }
1139
- selected++;
1140
  });
1141
 
1142
  // we need to clear the old values
@@ -1158,6 +1146,7 @@
1158
  function update_subset_field( option, wraper ) {
1159
  var subsets = $(option).data('subsets'),
1160
  font_subsets = wraper.find('.customify_font_subsets'),
 
1161
  new_subsets = [],
1162
  type = $(option).data('type');
1163
 
@@ -1166,7 +1155,12 @@
1166
  return;
1167
  }
1168
 
1169
- subsets = maybeJsonParse(subsets);
 
 
 
 
 
1170
 
1171
  if ( Object.keys(subsets).length < 2 ) {
1172
  font_subsets.parent().hide();
@@ -1179,6 +1173,11 @@
1179
  new_subsets[i] = {
1180
  'id': j,
1181
  'text': j
 
 
 
 
 
1182
  }
1183
  });
1184
 
@@ -1450,4 +1449,4 @@
1450
  }
1451
  return true;
1452
  };
1453
- })(jQuery, window, wp.customize);
1
+ (function ( $, exports, wp ) {
2
  'use strict';
3
 
4
+ var api = wp.customize;
5
+
6
  // when the customizer is ready prepare our fields events
7
+ wp.customize.bind('ready', function () {
8
  var timeout = null;
9
 
10
  // add ace editors
40
  // simple select2 field
41
  $('.customify_select2').select2();
42
 
43
+ setTimeout(function () {
44
+ customifyFontSelect.init(this);
45
+ }, 333);
46
 
47
  prepare_typography_field();
48
 
263
 
264
  // bind our event on click
265
  $(document).on('click', '.customify_import_demo_data_button', function ( event ) {
 
 
 
 
 
 
 
 
266
 
267
  //@todo start an animation here
268
  var key = $(this).data('key');
968
  })(jQuery);
969
 
970
  var customifyFontSelect = (function () {
971
+ var fontSelector = '.customify_font_family',
 
972
  selectPlacehoder = "Select a font family",
973
  weightPlaceholder = "Select a font weight",
974
  subsetPlaceholder = "Select a font subset";
975
 
976
  function init( wpapi ) {
 
 
 
 
977
  $(fontSelector).select2({
978
  placeholder: selectPlacehoder
979
  }).on('change', function ( e ) {
988
  // serialize stuff and refresh
989
  update_font_value(wraper);
990
  });
 
991
 
992
  $('.customify_font_weight').each(function ( i, el ) {
993
 
1014
  id: weight,
1015
  text: weight
1016
  };
1017
+
1018
  if ( selecter_variants !== null && weight == selecter_variants ) {
1019
  this_value.selected = true;
1020
  }
1035
  // we may update this with a live version sometime
1036
  var value_holder = wraper.children('.customify_font_values');
1037
  var setting_id = $(value_holder).data('customize-setting-link');
1038
+ var setting = wp.customize(setting_id);
1039
  setting.set(encodeValues(current_value));
1040
  });
1041
  });
1051
  // we may update this with a live version sometime
1052
  var value_holder = wraper.children('.customify_font_values');
1053
  var setting_id = $(value_holder).data('customize-setting-link');
1054
+ var setting = wp.customize(setting_id);
1055
  setting.set(encodeValues(current_value));
1056
  });
1057
 
1066
  // we may update this with a live version sometime
1067
  var value_holder = wraper.children('.customify_font_values');
1068
  var setting_id = $(value_holder).data('customize-setting-link');
1069
+ var setting = wp.customize(setting_id);
1070
  setting.set(encodeValues(current_value));
1071
  });
1072
  }
1079
  // we may update this with a live version sometime
1080
  var value_holder = wraper.children('.customify_font_values');
1081
  var setting_id = $(value_holder).data('customize-setting-link');
1082
+ var setting = wp.customize(setting_id);
1083
  setting.set(encodeValues(current_value));
1084
 
1085
+ wp.customize.previewer.send( 'font-changed' );
1086
  });
1087
  }
1088
 
1089
  var self = this;
1090
+
1091
+ wp.customize.previewer.bind( 'ready', function () {
1092
+ self.render_fonts();
1093
+ });
 
1094
  }
1095
 
1096
  /**
1102
  function update_weight_field( option, wraper ) {
1103
  var variants = $(option).data('variants'),
1104
  font_weights = wraper.find('.customify_font_weight'),
1105
+ selected_variant = font_weights.data('default'),
1106
  new_variants = [],
1107
  type = $(option).data('type'),
1108
  id = wraper.find('.customify_font_values').data('customizeSettingLink');
1115
  font_weights.parent().show();
1116
  }
1117
 
 
 
1118
  // we need to turn the data array into a specific form like [{id:"id", text:"Text"}]
1119
  $.each(variants, function ( i, j ) {
1120
  new_variants[i] = {
1122
  'text': j
1123
  };
1124
 
1125
+ if ( selected_variant == j ) {
1126
  new_variants[i].selected = true;
1127
  }
 
1128
  });
1129
 
1130
  // we need to clear the old values
1146
  function update_subset_field( option, wraper ) {
1147
  var subsets = $(option).data('subsets'),
1148
  font_subsets = wraper.find('.customify_font_subsets'),
1149
+ selected_subsets = font_subsets.data('default'),
1150
  new_subsets = [],
1151
  type = $(option).data('type');
1152
 
1155
  return;
1156
  }
1157
 
1158
+ var current_value = wraper.children('.customify_font_values').val();
1159
+
1160
+ current_value = maybeJsonParse( current_value );
1161
+ current_value = current_value.selected_subsets;
1162
+
1163
+ subsets = maybeJsonParse( subsets );
1164
 
1165
  if ( Object.keys(subsets).length < 2 ) {
1166
  font_subsets.parent().hide();
1173
  new_subsets[i] = {
1174
  'id': j,
1175
  'text': j
1176
+ };
1177
+
1178
+ // current_subsets
1179
+ if ( typeof current_value !== 'undefined' && current_value !== null && current_value.indexOf( j ) !== -1 ) {
1180
+ new_subsets[i].selected = true;
1181
  }
1182
  });
1183
 
1449
  }
1450
  return true;
1451
  };
1452
+ })(jQuery, window, wp);
js/customizer_preview.js CHANGED
@@ -29,6 +29,7 @@
29
  field_style.html(CSS);
30
  });
31
  });
 
32
  } else if (typeof wp_settings[key] !== "undefined" && typeof el.css !== "undefined" && typeof el.live !== 'undefined' && el.live === true) {
33
 
34
  var sliced_id = key.slice(0, -1);
@@ -234,8 +235,11 @@
234
 
235
  family = family + v;
236
 
237
- if (Object.keys(variants).length > (parseInt(k) + 1)) {
238
  family = family + ',';
 
 
 
239
  }
240
  });
241
  }
@@ -245,13 +249,13 @@
245
 
246
  $.each(subsets, function (k, v) {
247
 
248
- if (k === "0") {
249
  family = family + ':';
250
  }
251
 
252
  family = family + v;
253
 
254
- if (Object.keys(subsets).length > (parseInt(k) + 1)) {
255
  family = family + ',';
256
  }
257
  });
29
  field_style.html(CSS);
30
  });
31
  });
32
+
33
  } else if (typeof wp_settings[key] !== "undefined" && typeof el.css !== "undefined" && typeof el.live !== 'undefined' && el.live === true) {
34
 
35
  var sliced_id = key.slice(0, -1);
235
 
236
  family = family + v;
237
 
238
+ if ( Object.keys(variants).length > ( parseInt(k) + 1 ) ) {
239
  family = family + ',';
240
+ } else if ( typeof font.selected_subsets !== "undefined" ) {
241
+ // in case there is a subset selected, we need to separate it from the font weight
242
+ family = family + ':';
243
  }
244
  });
245
  }
249
 
250
  $.each(subsets, function (k, v) {
251
 
252
+ if ( k === "0" ) {
253
  family = family + ':';
254
  }
255
 
256
  family = family + v;
257
 
258
+ if ( Object.keys(subsets).length > ( parseInt(k) + 1 ) ) {
259
  family = family + ',';
260
  }
261
  });
languages/customify.pot CHANGED
@@ -2,7 +2,7 @@
2
  # This file is distributed under the same license as the Customify package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Customify 1.4.2\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/customify\n"
7
  "POT-Creation-Date: 2017-02-13 13:29:14+00:00\n"
8
  "MIME-Version: 1.0\n"
2
  # This file is distributed under the same license as the Customify package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Customify 1.5.0\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/customify\n"
7
  "POT-Creation-Date: 2017-02-13 13:29:14+00:00\n"
8
  "MIME-Version: 1.0\n"
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: pixelgrade, euthelup, babbardel, vlad.olaru, cristianfrumusanu, raduconstantin
3
  Tags: customizer, css, editor, live, preview, customise
4
  Requires at least: 4.5.0
5
- Tested up to: 4.7.2
6
- Stable tag: 1.4.2
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -37,6 +37,12 @@ With [Customify](https://github.com/pixelgrade/customify), developers can easily
37
 
38
  == Changelog ==
39
 
 
 
 
 
 
 
40
  = 1.4.2 =
41
  * Improved Font style output in front-end. Now is just one style element with all the fonts inside.
42
  * Improved Fonts panels, now only one can be opened to avoid confusion
2
  Contributors: pixelgrade, euthelup, babbardel, vlad.olaru, cristianfrumusanu, raduconstantin
3
  Tags: customizer, css, editor, live, preview, customise
4
  Requires at least: 4.5.0
5
+ Tested up to: 4.7.3
6
+ Stable tag: 1.5.0
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
37
 
38
  == Changelog ==
39
 
40
+ = 1.5.0 =
41
+ * Plugin core refactored for a better performance
42
+ * Fixed Font Weight saving
43
+ * Fixed Font Subset saving
44
+ * Fix Select2 enqueue_script
45
+
46
  = 1.4.2 =
47
  * Improved Font style output in front-end. Now is just one style element with all the fonts inside.
48
  * Improved Fonts panels, now only one can be opened to avoid confusion
views/admin.php CHANGED
@@ -12,7 +12,7 @@
12
  * @copyright 2013 Pixel Grade Media
13
  */
14
 
15
- $config = include pixcustomify::pluginpath() . 'plugin-config' . EXT;
16
 
17
  // invoke processor
18
  $processor = pixcustomify::processor( $config );
12
  * @copyright 2013 Pixel Grade Media
13
  */
14
 
15
+ $config = include PixCustomifyPlugin()->get_base_path() . 'plugin-config' . EXT;
16
 
17
  // invoke processor
18
  $processor = pixcustomify::processor( $config );