Kirki - Version 0.6.2

Version Description

  • 2014-03-02, dev time: 3 hours ==
  • Fix: Frontend styles were not properly enqueued (props @dmgawel)
  • New: Allow multiple output styles per control defined as an array of arrays.
  • Fix: Background control styles
  • Fix: Serialise default values for the sortable control. Now you can define default values as an array.
  • Fix: Required script
  • Fix: '_opacity' was added to a lot of controls by mistake. Removed it and wrote a migration script.

=

Download this release

Release Info

Developer aristath
Plugin Icon 128x128 Kirki
Version 0.6.2
Comparing to
See all releases

Code changes from version 0.6.1 to 0.6.2

includes/class-kirki-controls.php CHANGED
@@ -11,12 +11,13 @@ class Kirki_Controls extends Kirki {
11
  $control['subtitle'] = isset( $control['subtitle'] ) ? $control['subtitle'] : '';
12
  $control['required'] = isset( $control['required'] ) ? $control['required'] : array();
13
  $control['transport'] = isset( $control['transport'] ) ? $control['transport'] : 'refresh';
 
14
 
15
  if ( 'background' != $control['type'] ) {
16
 
17
  $control_class = 'Kirki_Customize_' . ucfirst( $control['type'] ) . '_Control';
18
  $control_class = ( 'group_title' == $control['type'] ) ? 'Kirki_Customize_Group_Title_Control' : $control_class;
19
- $wp_customize->add_control( new $control_class( $wp_customize, $control['setting'] . '_opacity', $control ) );
20
 
21
  } else {
22
 
11
  $control['subtitle'] = isset( $control['subtitle'] ) ? $control['subtitle'] : '';
12
  $control['required'] = isset( $control['required'] ) ? $control['required'] : array();
13
  $control['transport'] = isset( $control['transport'] ) ? $control['transport'] : 'refresh';
14
+ $control['default'] = 'sortable' == $control['type'] ? maybe_serialize( $control['default'] ) : $control['default'];
15
 
16
  if ( 'background' != $control['type'] ) {
17
 
18
  $control_class = 'Kirki_Customize_' . ucfirst( $control['type'] ) . '_Control';
19
  $control_class = ( 'group_title' == $control['type'] ) ? 'Kirki_Customize_Group_Title_Control' : $control_class;
20
+ $wp_customize->add_control( new $control_class( $wp_customize, $control['setting'], $control ) );
21
 
22
  } else {
23
 
includes/{class-kirki-style-fonts.php → class-kirki-fonts-script.php} RENAMED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Kirki_Style_Fonts extends Kirki_Style {
4
 
5
  public $firstrun = true;
6
 
@@ -14,38 +14,6 @@ class Kirki_Style_Fonts extends Kirki_Style {
14
 
15
  }
16
 
17
- function styles( $control, $styles = array() ) {
18
-
19
- // The value of this control
20
- $value = get_theme_mod( $control['setting'], $control['default'] );
21
-
22
- // Check if this is a font-family control
23
- $is_font_family = isset( $control['output']['property'] ) && 'font-family' == $control['output']['property'] ? true : false;
24
- // Check if this is a font-size control
25
- $is_font_size = isset( $control['output']['property'] ) && 'font-size' == $control['output']['property'] ? true : false;
26
- // Check if this is a font-weight control
27
- $is_font_weight = isset( $control['output']['property'] ) && 'font-weight' == $control['output']['property'] ? true : false;
28
-
29
- if ( $is_font_family ) {
30
-
31
- $styles[$control['output']['element']]['font-family'] = $value;
32
-
33
- } else if ( $is_font_size ) {
34
-
35
- // Get the unit we're going to use for the font-size.
36
- $units = isset( $control['output']['units'] ) ? $control['output']['units'] : 'px';
37
- $styles[$control['output']['element']]['font-size'] = $value . $units;
38
-
39
- } else if ( $is_font_weight ) {
40
-
41
- $styles[$control['output']['element']]['font-weight'] = $value;
42
-
43
- }
44
-
45
- return $styles;
46
-
47
- }
48
-
49
  function google_link() {
50
 
51
  // Get the global config and controls
1
  <?php
2
 
3
+ class Kirki_Fonts_Script extends Kirki_Style {
4
 
5
  public $firstrun = true;
6
 
14
 
15
  }
16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  function google_link() {
18
 
19
  // Get the global config and controls
includes/class-kirki-scripts.php CHANGED
@@ -58,6 +58,8 @@ class Kirki_Scripts {
58
  global $kirki;
59
  $config = $kirki->get_config();
60
  $controls = $kirki->get_controls();
 
 
61
 
62
  foreach( $controls as $control ) {
63
  if ( isset( $control['output'] ) ) {
@@ -65,7 +67,7 @@ class Kirki_Scripts {
65
  }
66
  }
67
 
68
- if ( isset( $uses_output ) && ! isset( $config['stylesheet_id'] ) ) {
69
  wp_enqueue_style( 'kirki-styles', $kirki_url . 'assets/css/kirki-styles.css', NULL, NULL );
70
  }
71
 
58
  global $kirki;
59
  $config = $kirki->get_config();
60
  $controls = $kirki->get_controls();
61
+
62
+ $kirki_url = isset( $options['url_path'] ) ? $options['url_path'] : KIRKI_URL;
63
 
64
  foreach( $controls as $control ) {
65
  if ( isset( $control['output'] ) ) {
67
  }
68
  }
69
 
70
+ if ( isset( $uses_output ) && (! isset( $config['stylesheet_id'] ) || $config['stylesheet_id'] === 'kirki-styles' ) ) {
71
  wp_enqueue_style( 'kirki-styles', $kirki_url . 'assets/css/kirki-styles.css', NULL, NULL );
72
  }
73
 
includes/class-kirki-style-background.php DELETED
@@ -1,42 +0,0 @@
1
- <?php
2
-
3
- class Kirki_Style_Background {
4
-
5
- function styles( $control, $styles = array() ) {
6
-
7
- // Add support for previous syntax for output (string instead of array)
8
- $output_element = is_array( $control['output'] ) ? $control['output']['element'] : $control['output'];
9
-
10
- $bg_color = Kirki_Color::sanitize_hex( get_theme_mod( $control['setting'] . '_color', $control['default']['color'] ) );
11
- $bg_image = get_theme_mod( $control['setting'] . '_image', $control['default']['image'] );
12
- $bg_repeat = get_theme_mod( $control['setting'] . '_repeat', $control['default']['repeat'] );
13
- $bg_size = get_theme_mod( $control['setting'] . '_size', $control['default']['size'] );
14
- $bg_attach = get_theme_mod( $control['setting'] . '_attach', $control['default']['attach'] );
15
- $bg_position = get_theme_mod( $control['setting'] . '_position', $control['default']['position'] );
16
- $bg_opacity = get_theme_mod( $control['setting'] . '_opacity', $control['default']['opacity'] );
17
-
18
- if ( false != $control['default']['opacity'] ) {
19
-
20
- $bg_position = get_theme_mod( $control['setting'] . '_opacity', $control['default']['opacity'] );
21
-
22
- // If we're using an opacity other than 100, then convert the color to RGBA.
23
- if ( 100 != $bg_opacity ) {
24
- $bg_color = Kirki_Color::get_rgba( $bg_color, $bg_opacity );
25
- }
26
-
27
- }
28
-
29
- $styles[$output_element]['background-color'] = $bg_color;
30
- if ( '' != $bg_image ) {
31
- $styles[$output_element]['background-image'] = url("' . $bg_image . '");
32
- $styles[$output_element]['background-repeat'] = $bg_repeat;
33
- $styles[$output_element]['background-size'] = $bg_size;
34
- $styles[$output_element]['background-attachment'] = $bg_attach;
35
- $styles[$output_element]['background-position'] = str_replace( '-', ' ', $bg_position );
36
- }
37
-
38
- return $styles;
39
-
40
- }
41
-
42
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-kirki-style-color.php DELETED
@@ -1,14 +0,0 @@
1
- <?php
2
-
3
- class Kirki_Style_Color {
4
-
5
- function styles( $control, $styles = array() ) {
6
-
7
- $color = Kirki_Color::sanitize_hex( get_theme_mod( $control['setting'], $control['default'] ) );
8
- $styles[$control['output']['element']][$control['output']['property']] = $color;
9
-
10
- return $styles;
11
-
12
- }
13
-
14
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-kirki-style.php CHANGED
@@ -2,15 +2,11 @@
2
 
3
  class Kirki_Style {
4
 
5
- public $style_color;
6
- public $style_background;
7
- public $style_font;
8
 
9
  function __construct() {
10
 
11
- $this->style_color = new Kirki_Style_Color();
12
- $this->style_background = new Kirki_Style_Background();
13
- $this->style_font = new Kirki_Style_Fonts();
14
 
15
  add_action( 'wp_enqueue_scripts', array( $this, 'enqueue' ), 150 );
16
 
@@ -22,32 +18,43 @@ class Kirki_Style {
22
  $styles = array();
23
 
24
  foreach ( $controls as $control ) {
 
 
 
25
 
26
- // Early exit if 'output' is not defined
27
  if ( isset( $control['output'] ) ) {
28
 
29
- // Color controls
30
- if ( 'color' == $control['type'] && is_array( $control['output'] ) ) {
31
- $styles = $this->style_color->styles( $control, $styles );
32
- }
33
- // Background Controls
34
- elseif ( 'background' == $control['type'] && ! is_null( $control['output'] ) ) {
35
- $styles = $this->style_background->styles( $control, $styles );
36
- }
37
- // Font controls
38
- elseif ( array( $control['output'] ) && isset( $control['output']['property'] ) && in_array( $control['output']['property'], array( 'font-family', 'font-size', 'font-weight' ) ) ) {
39
- $styles = $this->style_font->styles( $control, $styles );
40
- }
41
- // Generic styles
42
- elseif ( array( $control['output'] ) ) {
43
 
44
- $value = get_theme_mod( $control['setting'], $control['default'] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
- // Do we have a unit specified?
47
- $units = ( isset( $control['output']['units'] ) ) ? $control['output']['units'] : null;
48
- // Generate the styles
49
- if ( isset( $control['output']['element'] ) ) {
50
- $styles[$control['output']['element']][$control['output']['property']] = $value . $units;
51
  }
52
 
53
  }
@@ -60,6 +67,84 @@ class Kirki_Style {
60
 
61
  }
62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  function enqueue() {
64
 
65
  global $kirki;
2
 
3
  class Kirki_Style {
4
 
5
+ public $fonts_script;
 
 
6
 
7
  function __construct() {
8
 
9
+ $this->fonts_script = new Kirki_Fonts_Script();
 
 
10
 
11
  add_action( 'wp_enqueue_scripts', array( $this, 'enqueue' ), 150 );
12
 
18
  $styles = array();
19
 
20
  foreach ( $controls as $control ) {
21
+ $element = '';
22
+ $property = '';
23
+ $units = '';
24
 
25
+ // Only continue if $control['output'] is set
26
  if ( isset( $control['output'] ) ) {
27
 
28
+ // Check if this is an array of style definitions
29
+ $multiple_styles = isset( $control['output'][0]['element'] ) ? true : false;
30
+
31
+ if ( ! $multiple_styles ) { // single style
32
+
33
+ // If $control['output'] is not an array, then use the string as the target element
34
+ if ( is_string( $control['output'] ) ) {
35
+ $element = $control['output'];
36
+ } else {
37
+ $element = isset( $control['output']['element'] ) ? $control['output']['element'] : '';
38
+ $property = isset( $control['output']['property'] ) ? $control['output']['property'] : '';
39
+ $units = isset( $control['output']['units'] ) ? $control['output']['units'] : '';
40
+ }
 
41
 
42
+ $styles = $this->styles( $control, $styles, $element, $property, $units );
43
+
44
+ } else { // Multiple styles set
45
+
46
+ foreach ( $control['output'] as $style ) {
47
+
48
+ if ( ! array( $style ) ) {
49
+ $element = $style;
50
+ } else {
51
+ $element = isset( $style['element'] ) ? $style['element'] : '';
52
+ $property = isset( $style['property'] ) ? $style['property'] : '';
53
+ $units = isset( $style['units'] ) ? $style['units'] : '';
54
+ }
55
+
56
+ $styles = $this->styles( $control, $styles, $element, $property, $units );
57
 
 
 
 
 
 
58
  }
59
 
60
  }
67
 
68
  }
69
 
70
+ function styles( $control, $styles, $element, $property, $units ) {
71
+
72
+ $value = get_theme_mod( $control['setting'], $control['default'] );
73
+
74
+ // Color controls
75
+ if ( 'color' == $control['type'] ) {
76
+
77
+ $color = Kirki_Color::sanitize_hex( $value );
78
+ $styles[$element][$property] = $color;
79
+
80
+ }
81
+
82
+ // Background Controls
83
+ elseif ( 'background' == $control['type'] ) {
84
+
85
+ $bg_color = Kirki_Color::sanitize_hex( get_theme_mod( $control['setting'] . '_color', $control['default']['color'] ) );
86
+ $bg_image = get_theme_mod( $control['setting'] . '_image', $control['default']['image'] );
87
+ $bg_repeat = get_theme_mod( $control['setting'] . '_repeat', $control['default']['repeat'] );
88
+ $bg_size = get_theme_mod( $control['setting'] . '_size', $control['default']['size'] );
89
+ $bg_attach = get_theme_mod( $control['setting'] . '_attach', $control['default']['attach'] );
90
+ $bg_position = get_theme_mod( $control['setting'] . '_position', $control['default']['position'] );
91
+ $bg_opacity = get_theme_mod( $control['setting'] . '_opacity', $control['default']['opacity'] );
92
+
93
+ if ( false != $control['default']['opacity'] ) {
94
+
95
+ $bg_position = get_theme_mod( $control['setting'] . '_opacity', $control['default']['opacity'] );
96
+
97
+ // If we're using an opacity other than 100, then convert the color to RGBA.
98
+ if ( 100 != $bg_opacity ) {
99
+ $bg_color = Kirki_Color::get_rgba( $bg_color, $bg_opacity );
100
+ }
101
+
102
+ }
103
+
104
+ $styles[$element]['background-color'] = $bg_color;
105
+ if ( '' != $bg_image ) {
106
+ $styles[$element]['background-image'] = 'url("' . $bg_image . '")';
107
+ $styles[$element]['background-repeat'] = $bg_repeat;
108
+ $styles[$element]['background-size'] = $bg_size;
109
+ $styles[$element]['background-attachment'] = $bg_attach;
110
+ $styles[$element]['background-position'] = str_replace( '-', ' ', $bg_position );
111
+ }
112
+
113
+ }
114
+
115
+ // Font controls
116
+ elseif ( array( $control['output'] ) && isset( $control['output']['property'] ) && in_array( $control['output']['property'], array( 'font-family', 'font-size', 'font-weight' ) ) ) {
117
+
118
+ $is_font_family = isset( $control['output']['property'] ) && 'font-family' == $control['output']['property'] ? true : false;
119
+ $is_font_size = isset( $control['output']['property'] ) && 'font-size' == $control['output']['property'] ? true : false;
120
+ $is_font_weight = isset( $control['output']['property'] ) && 'font-weight' == $control['output']['property'] ? true : false;
121
+
122
+ if ( 'font-family' == $property ) {
123
+
124
+ $styles[$control['output']['element']]['font-family'] = $value;
125
+
126
+ } else if ( 'font-size' == $property ) {
127
+
128
+ // Get the unit we're going to use for the font-size.
129
+ $units = empty( $units ) ? 'px' : $units;
130
+ $styles[$element]['font-size'] = $value . $units;
131
+
132
+ } else if ( 'font-weight' == $property ) {
133
+
134
+ $styles[$element]['font-weight'] = $value;
135
+
136
+ }
137
+
138
+ } else {
139
+
140
+ $styles[$element][$property] = $value . $units;
141
+
142
+ }
143
+
144
+ return $styles;
145
+
146
+ }
147
+
148
  function enqueue() {
149
 
150
  global $kirki;
kirki.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://kirki.org
5
  Description: An options framework using and extending the WordPress Customizer
6
  Author: Aristeides Stathopoulos
7
  Author URI: http://press.codes
8
- Version: 0.6.1
9
  */
10
 
11
  // Load Kirki_Fonts before everything else
@@ -33,9 +33,7 @@ class Kirki {
33
  include_once( dirname( __FILE__ ) . '/includes/required.php' );
34
  include_once( dirname( __FILE__ ) . '/includes/class-kirki-style.php' );
35
  include_once( dirname( __FILE__ ) . '/includes/class-kirki-scripts.php' );
36
- include_once( dirname( __FILE__ ) . '/includes/class-kirki-style-background.php' );
37
- include_once( dirname( __FILE__ ) . '/includes/class-kirki-style-color.php' );
38
- include_once( dirname( __FILE__ ) . '/includes/class-kirki-style-fonts.php' );
39
  include_once( dirname( __FILE__ ) . '/includes/class-kirki-color.php' );
40
  include_once( dirname( __FILE__ ) . '/includes/class-kirki-settings.php' );
41
  include_once( dirname( __FILE__ ) . '/includes/class-kirki-controls.php' );
@@ -46,6 +44,7 @@ class Kirki {
46
 
47
  add_action( 'customize_register', array( $this, 'include_customizer_controls' ), 1 );
48
  add_action( 'customize_register', array( $this, 'customizer_builder' ), 99 );
 
49
 
50
  }
51
 
@@ -120,6 +119,30 @@ class Kirki {
120
 
121
  }
122
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  }
124
 
125
  global $kirki;
5
  Description: An options framework using and extending the WordPress Customizer
6
  Author: Aristeides Stathopoulos
7
  Author URI: http://press.codes
8
+ Version: 0.6.2
9
  */
10
 
11
  // Load Kirki_Fonts before everything else
33
  include_once( dirname( __FILE__ ) . '/includes/required.php' );
34
  include_once( dirname( __FILE__ ) . '/includes/class-kirki-style.php' );
35
  include_once( dirname( __FILE__ ) . '/includes/class-kirki-scripts.php' );
36
+ include_once( dirname( __FILE__ ) . '/includes/class-kirki-fonts-script.php' );
 
 
37
  include_once( dirname( __FILE__ ) . '/includes/class-kirki-color.php' );
38
  include_once( dirname( __FILE__ ) . '/includes/class-kirki-settings.php' );
39
  include_once( dirname( __FILE__ ) . '/includes/class-kirki-controls.php' );
44
 
45
  add_action( 'customize_register', array( $this, 'include_customizer_controls' ), 1 );
46
  add_action( 'customize_register', array( $this, 'customizer_builder' ), 99 );
47
+ add_action( 'wp', array( $this, 'update' ) );
48
 
49
  }
50
 
119
 
120
  }
121
 
122
+ function update() {
123
+
124
+ // < 0.6.1 -> 0.6.2
125
+ if ( ! get_option( 'kirki_version' ) ) {
126
+
127
+ $control_ids = array();
128
+ $controls = $this->get_controls();
129
+ foreach ( $controls as $control ) {
130
+ if ( 'background' != $control['type'] ) {
131
+ $control_ids[] = $control['setting'];
132
+ }
133
+ }
134
+ foreach ( $control_ids as $control_id ) {
135
+ if ( get_theme_mod( $control_id . '_opacity' ) && ! get_theme_mod( $control_id ) ) {
136
+ update_theme_mod( $control_id, get_theme_mod( $control_id . '_opacity' ) );
137
+ }
138
+ }
139
+
140
+ update_option( 'kirki_version', '0.6.2' );
141
+
142
+ }
143
+
144
+ }
145
+
146
  }
147
 
148
  global $kirki;
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://kirki.org
4
  Tags: customizer
5
  Requires at least: 4.0
6
  Tested up to: 4.1.1
7
- Stable tag: 0.6.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -42,11 +42,19 @@ In addition you can also automatically generate the CSS for a lot of controls an
42
  Just install this plugin and activate it.
43
  For configuration instructions please visit http://kirki.org/#configuration
44
 
45
- == 0.6.1 - 2012-02-25, dev time: 1 hours==
 
 
 
 
 
 
 
 
46
  * Fix: Sortables controls had a JS conflict
47
  * Fix: Switches & Toggles were not properly working
48
 
49
- == 0.6.0 - 2012-02-25, dev time: 9 hours==
50
  * Fix: Tooltips now properly working
51
  * New: Added checkbox switches
52
  * New: Added checkbox toggles
4
  Tags: customizer
5
  Requires at least: 4.0
6
  Tested up to: 4.1.1
7
+ Stable tag: 0.6.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
42
  Just install this plugin and activate it.
43
  For configuration instructions please visit http://kirki.org/#configuration
44
 
45
+ == 0.6.2 - 2014-03-02, dev time: 3 hours ==
46
+ * Fix: Frontend styles were not properly enqueued (props @dmgawel)
47
+ * New: Allow multiple output styles per control defined as an array of arrays.
48
+ * Fix: Background control styles
49
+ * Fix: Serialise default values for the sortable control. Now you can define default values as an array.
50
+ * Fix: Required script
51
+ * Fix: '_opacity' was added to a lot of controls by mistake. Removed it and wrote a migration script.
52
+
53
+ == 0.6.1 - 2014-02-25, dev time: 1 hours ==
54
  * Fix: Sortables controls had a JS conflict
55
  * Fix: Switches & Toggles were not properly working
56
 
57
+ == 0.6.0 - 2014-02-25, dev time: 9 hours ==
58
  * Fix: Tooltips now properly working
59
  * New: Added checkbox switches
60
  * New: Added checkbox toggles