66 * Plugin Name: Genesis Widget Column Classes
77 * Description: Add Genesis (old Bootstrap) column classes to widgets
88 * Plugin URI: https://wordpress.org/plugins/genesis-widget-column-classes/
9- * Version: 1.1.5
9+ * Version: 1.2
1010 * Author: Jory Hogeveen
1111 * Author URI: http://www.keraweb.nl
1212 * Text Domain: genesis-widget-column-classes
3333 * MA 02110-1301, USA.
3434 *
3535 */
36-
36+
3737! defined ( 'ABSPATH ' ) and die ( 'You shall not pass! ' );
3838
3939if ( ! class_exists ( 'WCC_Genesis_Widget_Column_Classes ' ) ) {
40-
41- final class WCC_Genesis_Widget_Column_Classes
40+
41+ final class WCC_Genesis_Widget_Column_Classes
4242{
4343
4444 /**
@@ -55,7 +55,7 @@ final class WCC_Genesis_Widget_Column_Classes
5555 * @since 1.1
5656 * @var string
5757 */
58- private $ version = '1.1.5 ' ;
58+ private $ version = '1.2 ' ;
5959
6060 /**
6161 * User ignore nag key
@@ -64,35 +64,35 @@ final class WCC_Genesis_Widget_Column_Classes
6464 * @var string
6565 */
6666 private $ noticeKey = 'wcc_ignore_genesis_notice ' ;
67-
67+
6868 /**
6969 * Array of possible column classes
7070 *
7171 * @since 1.1.4
7272 * @var array
73- */
74- private $ column_classes = array (
75- 'one-half ' ,
76- 'one-third ' ,
77- 'one-fourth ' ,
78- 'one-sixth ' ,
79- 'two-thirds ' ,
80- 'two-fourths ' ,
73+ */
74+ private $ column_classes = array (
75+ 'one-half ' ,
76+ 'one-third ' ,
77+ 'one-fourth ' ,
78+ 'one-sixth ' ,
79+ 'two-thirds ' ,
80+ 'two-fourths ' ,
8181 'two-sixths ' ,
8282 'three-fourths ' ,
8383 'three-sixths ' ,
8484 'four-sixths ' ,
8585 'five-sixths '
8686 );
87-
87+
8888 /**
8989 * Current user object
9090 *
9191 * @since 1.1
9292 * @var object
93- */
93+ */
9494 private $ curUser = false ;
95-
95+
9696 /**
9797 * Init function to register plugin hook
9898 *
@@ -102,11 +102,11 @@ final class WCC_Genesis_Widget_Column_Classes
102102 */
103103 private function __construct () {
104104 self ::$ _instance = $ this ;
105-
105+
106106 // Lets start!
107107 add_action ( 'init ' , array ( $ this , 'init ' ) );
108108 }
109-
109+
110110 /**
111111 * Main Genesis Widget Column Classes Instance.
112112 *
@@ -133,20 +133,20 @@ public static function get_instance() {
133133 * @return void
134134 */
135135 public function init () {
136-
136+
137137 // Get the current user
138138 $ this ->curUser = wp_get_current_user ();
139139
140140 /**
141141 * Change the default column classes
142- *
142+ *
143143 * @since 1.1.4
144144 * @param array The column classes
145145 */
146146 $ this ->column_classes = apply_filters ( 'genesis_widget_column_classes ' , $ this ->column_classes );
147147
148148 if ( isset ( $ this ->curUser ->ID ) ) {
149- add_action ( 'admin_notices ' , array ( $ this , 'genesis_notice ' ) );
149+ add_action ( 'admin_notices ' , array ( $ this , 'genesis_notice ' ) );
150150 add_action ( 'wp_ajax_ ' .$ this ->noticeKey , array ( $ this , 'ignore_genesis_notice ' ) );
151151 }
152152 // widget_form_callback instead of in_widget_form because we want these fields to show BEFORE the other fields
@@ -156,7 +156,7 @@ public function init() {
156156 add_action ( 'init ' , array ( $ this , 'load_textdomain ' ) );
157157
158158 }
159-
159+
160160 /**
161161 * Add notice when theme is nog based on the Genesis Framework
162162 * Checks for version in the notice ignore meta value. If the version is the same (user has clicked ignore), then hide it
@@ -177,7 +177,7 @@ public function genesis_notice() {
177177 }
178178 }
179179 }
180-
180+
181181 /**
182182 * AJAX handler
183183 * Stores plugin version
@@ -192,7 +192,7 @@ public function ignore_genesis_notice() {
192192 update_user_meta ( $ this ->curUser ->ID , $ this ->noticeKey , $ this ->version );
193193 wp_die ();
194194 }
195-
195+
196196 /**
197197 * Add options to the widgets
198198 *
@@ -204,35 +204,35 @@ public function ignore_genesis_notice() {
204204 */
205205 public function widget_form_extend ( $ instance , $ widget ) {
206206
207- $ instance = wp_parse_args ( (array ) $ instance ,
208- array (
209- 'column-classes ' => '' ,
210- 'column-classes-first ' => ''
211- )
207+ $ instance = wp_parse_args ( (array ) $ instance ,
208+ array (
209+ 'column-classes ' => '' ,
210+ 'column-classes-first ' => ''
211+ )
212212 );
213-
214-
213+
214+
215215 $ row = '<p style="border: 1px solid #eee; padding: 5px; background: #f5f5f5;"> ' ;
216216 $ row .= '<label for=" ' . $ widget ->get_field_id ( 'column-classes ' ) . '"> ' . __ ('Width ' , 'genesis-widget-column-classes ' ) . ':</label> ' ;
217217 $ row .= '<select name=" ' . $ widget ->get_field_name ( 'column-classes ' ) . '" id=" ' . $ widget ->get_field_id ( 'column-classes ' ) . '"> ' ;
218-
218+
219219 $ row .= '<option value="">- ' . __ ('none ' , 'genesis-widget-column-classes ' ) . ' -</option> ' ;
220-
220+
221221 foreach ( $ this ->column_classes as $ class_name ) {
222222 if ( ! empty ( $ class_name ) ) {
223223 $ class_label = $ class_name ;
224224 $ row .= '<option value=" ' . $ class_name . '" ' . selected ( $ instance ['column-classes ' ], $ class_name , false ) . '> ' . $ class_label . '</option> ' ;
225225 }
226226 }
227-
227+
228228 $ row .= '</select> ' ;
229229 $ row .= ' <label for=" ' . $ widget ->get_field_id ( 'column-classes-first ' ) . '"> ' . __ ('First ' , 'genesis-widget-column-classes ' ) . ':</label> <input type="checkbox" value="1" name=" ' . $ widget ->get_field_name ( 'column-classes-first ' ) . '" id=" ' . $ widget ->get_field_id ( 'column-classes-first ' ) . '" ' . checked ( $ instance ['column-classes-first ' ], 1 , false ) . '> ' ;
230230 $ row .= '</p> ' ;
231-
231+
232232 echo $ row ;
233233 return $ instance ;
234234 }
235-
235+
236236 /**
237237 * Add the new fields to the update instance
238238 *
@@ -254,7 +254,7 @@ public function widget_update( $instance, $new_instance ) {
254254
255255 return $ instance ;
256256 }
257-
257+
258258 /**
259259 * Add classes to the widget
260260 *
@@ -292,11 +292,11 @@ public function sidebar_params( $params ) {
292292
293293 /**
294294 * Compat with plugins that filter the display callback
295- *
295+ *
296296 * @see https://developer.wordpress.org/reference/hooks/widget_display_callback/
297- *
297+ *
298298 * @since 1.1.5
299- *
299+ *
300300 * @param array $instance The current widget instance's settings.
301301 * @param WP_Widget $this The current widget instance.
302302 * @param array $args An array of default widget arguments.
@@ -324,20 +324,20 @@ public function sidebar_params( $params ) {
324324
325325 //$params[0]['before_widget'] = str_replace( 'class="', 'class="'.$classes_extra , $params[0]['before_widget'] );
326326 }
327-
327+
328328 return $ params ;
329329 }
330330
331331 /**
332332 * Find the class attribute and add the classes in a HTML string
333- *
333+ *
334334 * @since 1.1.5
335- *
335+ *
336336 * @param string $str
337337 * @param string $attr The attribute to find
338338 * @param string $content_extra The content that needs to be appended
339339 * @param bool $unique Do we need to filter for unique values?
340- *
340+ *
341341 * @return string
342342 */
343343 public function append_to_attribute ( $ str , $ attr , $ content_extra , $ unique = false ) {
@@ -361,7 +361,7 @@ public function append_to_attribute( $str, $attr, $content_extra, $unique = fals
361361 $ content_extra = trim ( $ content_extra );
362362
363363 if ( $ unique ) {
364-
364+
365365 // Set start pointer to after "
366366 $ start += strlen ( $ attr );
367367 // Find first " after the start pointer
@@ -396,7 +396,7 @@ public function append_to_attribute( $str, $attr, $content_extra, $unique = fals
396396 // Return full HTML string
397397 return $ str ;
398398 }
399-
399+
400400 /**
401401 * Load plugin textdomain.
402402 *
@@ -467,7 +467,7 @@ public function __call( $method = '', $args = array() ) {
467467 unset( $ method , $ args );
468468 return null ;
469469 }
470-
470+
471471}
472472
473473/**
0 commit comments