Homepage Control - Version 2.0.1

Version Description

  • 2015-06-01
  • Make sure only components that actually exist are outputted to the customizer control (props valendesigns).
  • Hide by default components added after the initial setup.
Download this release

Release Info

Developer tiagonoronha
Plugin Icon wp plugin Homepage Control
Version 2.0.1
Comparing to
See all releases

Code changes from version 2.0.0 to 2.0.1

classes/class-homepage-control-customizer-control.php CHANGED
@@ -25,7 +25,7 @@ class Homepage_Control_Customizer_Control extends WP_Customize_Control {
25
  } else {
26
  $components = $this->choices;
27
  $order = $this->value();
28
- $disabled = $this->_get_disabled_components( $this->value() );
29
  ?>
30
  <label>
31
  <?php
@@ -38,14 +38,29 @@ class Homepage_Control_Customizer_Control extends WP_Customize_Control {
38
  ?>
39
  <ul class="homepage-control">
40
  <?php $components = $this->_reorder_components( $components, $order ); ?>
41
- <?php foreach ( $components as $k => $v ) : ?>
42
  <?php
43
  $class = '';
44
- if ( in_array( $k, $disabled ) ) {
45
  $class = 'disabled';
46
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  ?>
48
- <li id="<?php echo esc_attr( $k ); ?>" class="<?php echo $class; ?>"><span class="visibility"></span><?php echo esc_attr( $v ); ?></li>
49
  <?php endforeach; ?>
50
  </ul>
51
  <input type="hidden" <?php $this->link(); ?> value="<?php echo esc_attr( $this->value() ); ?>"/>
@@ -74,8 +89,12 @@ class Homepage_Control_Customizer_Control extends WP_Customize_Control {
74
  if ( $this->_is_component_disabled( $v ) ) {
75
  $v = str_replace( '[disabled]', '', $v );
76
  }
77
- $components[ $v ] = $original_components[ $v ];
78
- unset( $original_components[ $v ] );
 
 
 
 
79
  }
80
  if ( 0 < count( $original_components ) ) {
81
  $components = array_merge( $components, $original_components );
@@ -104,16 +123,25 @@ class Homepage_Control_Customizer_Control extends WP_Customize_Control {
104
  * @since 2.0.0
105
  * @return array An array of disabled components.
106
  */
107
- private function _get_disabled_components ( $components ) {
108
  $disabled = array();
109
- if ( '' != $components ) {
110
- $components = explode( ',', $components );
111
 
112
- if ( 0 < count( $components ) ) {
113
- foreach ( $components as $k => $v ) {
114
  if ( $this->_is_component_disabled( $v ) ) {
115
- $disabled[] = str_replace( '[disabled]', '', $v );
 
116
  }
 
 
 
 
 
 
 
 
117
  }
118
  }
119
  }
25
  } else {
26
  $components = $this->choices;
27
  $order = $this->value();
28
+ $disabled = $this->_get_disabled_components( $this->value(), $components );
29
  ?>
30
  <label>
31
  <?php
38
  ?>
39
  <ul class="homepage-control">
40
  <?php $components = $this->_reorder_components( $components, $order ); ?>
41
+ <?php foreach ( $components as $id => $title ) : ?>
42
  <?php
43
  $class = '';
44
+ if ( in_array( $id, $disabled ) ) {
45
  $class = 'disabled';
46
  }
47
+
48
+ /**
49
+ * Filter the control title.
50
+ *
51
+ * @since 2.0.1
52
+ *
53
+ * @param string $title The control title.
54
+ * @param string $id The action hook function ID.
55
+ */
56
+ $title = apply_filters( 'homepage_control_title', $title, $id );
57
+
58
+ // Nothing to display.
59
+ if ( empty( $title ) ) {
60
+ continue;
61
+ }
62
  ?>
63
+ <li id="<?php echo esc_attr( $id ); ?>" class="<?php echo $class; ?>"><span class="visibility"></span><?php echo esc_attr( $title ); ?></li>
64
  <?php endforeach; ?>
65
  </ul>
66
  <input type="hidden" <?php $this->link(); ?> value="<?php echo esc_attr( $this->value() ); ?>"/>
89
  if ( $this->_is_component_disabled( $v ) ) {
90
  $v = str_replace( '[disabled]', '', $v );
91
  }
92
+
93
+ // Only add to array if component still exists
94
+ if ( isset( $original_components[ $v ] ) ) {
95
+ $components[ $v ] = $original_components[ $v ];
96
+ unset( $original_components[ $v ] );
97
+ }
98
  }
99
  if ( 0 < count( $original_components ) ) {
100
  $components = array_merge( $components, $original_components );
123
  * @since 2.0.0
124
  * @return array An array of disabled components.
125
  */
126
+ private function _get_disabled_components ( $saved_components, $all_components ) {
127
  $disabled = array();
128
+ if ( '' != $saved_components ) {
129
+ $saved_components = explode( ',', $saved_components );
130
 
131
+ if ( 0 < count( $saved_components ) ) {
132
+ foreach ( $saved_components as $k => $v ) {
133
  if ( $this->_is_component_disabled( $v ) ) {
134
+ $v = str_replace( '[disabled]', '', $v );
135
+ $disabled[] = $v;
136
  }
137
+ unset( $all_components[ $v ] );
138
+ }
139
+ }
140
+
141
+ // Disable new components
142
+ if ( 0 < count( $all_components ) ) {
143
+ foreach ( $all_components as $k => $v ) {
144
+ $disabled[] = $k;
145
  }
146
  }
147
  }
homepage-control.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Homepage Control
4
  * Plugin URI: http://www.woothemes.com/products/homepage-control/
5
  * Description: Hi! I'm here to assist you with re-ordering or disabling components of your theme's homepage design.
6
- * Version: 2.0.0
7
  * Author: WooThemes
8
  * Author URI: http://woothemes.com/
9
  * Requires at least: 3.8.1
@@ -91,7 +91,7 @@ final class Homepage_Control {
91
  $this->token = 'homepage-control';
92
  $this->plugin_url = plugin_dir_url( __FILE__ );
93
  $this->plugin_path = plugin_dir_path( __FILE__ );
94
- $this->version = '2.0.0';
95
  $this->hook = (string)apply_filters( 'homepage_control_hook', 'homepage' );
96
 
97
  add_action( 'plugins_loaded', array( $this, 'maybe_migrate_data' ) );
3
  * Plugin Name: Homepage Control
4
  * Plugin URI: http://www.woothemes.com/products/homepage-control/
5
  * Description: Hi! I'm here to assist you with re-ordering or disabling components of your theme's homepage design.
6
+ * Version: 2.0.1
7
  * Author: WooThemes
8
  * Author URI: http://woothemes.com/
9
  * Requires at least: 3.8.1
91
  $this->token = 'homepage-control';
92
  $this->plugin_url = plugin_dir_url( __FILE__ );
93
  $this->plugin_path = plugin_dir_path( __FILE__ );
94
+ $this->version = '2.0.1';
95
  $this->hook = (string)apply_filters( 'homepage_control_hook', 'homepage' );
96
 
97
  add_action( 'plugins_loaded', array( $this, 'maybe_migrate_data' ) );
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: woothemes,mattyza,jameskoster,tiagonoronha
3
  Donate link: http://woothemes.com/
4
  Tags: homepage, hooks, theme-mod, components, customizer
5
  Requires at least: 3.8.1
6
- Tested up to: 4.2.1
7
- Stable tag: 2.0.0
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -62,6 +62,11 @@ We encourage everyone to contribute their ideas, thoughts and code snippets. Thi
62
 
63
  == Changelog ==
64
 
 
 
 
 
 
65
  = 2.0.0 =
66
  * 2015-04-28
67
  * Removed custom admin page and moved Homepage Control to the WordPress Customizer in Appearance > Customizer.
3
  Donate link: http://woothemes.com/
4
  Tags: homepage, hooks, theme-mod, components, customizer
5
  Requires at least: 3.8.1
6
+ Tested up to: 4.2.2
7
+ Stable tag: 2.0.1
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
62
 
63
  == Changelog ==
64
 
65
+ = 2.0.1 =
66
+ * 2015-06-01
67
+ * Make sure only components that actually exist are outputted to the customizer control (props valendesigns).
68
+ * Hide by default components added after the initial setup.
69
+
70
  = 2.0.0 =
71
  * 2015-04-28
72
  * Removed custom admin page and moved Homepage Control to the WordPress Customizer in Appearance > Customizer.