Widget CSS Classes - Version 1.2.7

Version Description

  • Changed class and ID fields to full-width
  • Added missing escaping from settings page
  • Enqueue admin scripts on correct hook
  • Fixed undefined notice when option was not found
Download this release

Release Info

Developer elusivelight
Plugin Icon 128x128 Widget CSS Classes
Version 1.2.7
Comparing to
See all releases

Code changes from version 1.2.6 to 1.2.7

README DELETED
@@ -1 +0,0 @@
1
- This file was created by JetBrains PhpStorm 4.0.3 for binding GitHub repository
 
includes/widget-css-classes-library.class.php CHANGED
@@ -42,8 +42,8 @@ class WCSSC_Lib {
42
  */
43
  public static function admin_footer() {
44
  $plugin_data = get_plugin_data( WCSSC_FILE );
45
- echo $plugin_data['Title'].' | '.esc_attr__( 'Version', 'widget-css-classes' ).' '.$plugin_data['Version'].' | '.$plugin_data['Author'].
46
- ' | <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=cindy@cleverness.org">'.esc_attr__( 'Donate', 'widget-css-classes' ).'</a>
47
  <br />';
48
  }
49
 
42
  */
43
  public static function admin_footer() {
44
  $plugin_data = get_plugin_data( WCSSC_FILE );
45
+ echo $plugin_data['Title'].' | '.esc_attr__( 'Version', 'widget-css-classes' ).' '.esc_html( $plugin_data['Version'] ).' | '.$plugin_data['Author'].
46
+ ' | <a href="http://codebrainmedia.com">CodeBrain Media</a> | <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=cindy@cleverness.org">'.esc_attr__( 'Donate', 'widget-css-classes' ).'</a>
47
  <br />';
48
  }
49
 
includes/widget-css-classes-loader.class.php CHANGED
@@ -62,7 +62,7 @@ class WCSSC_Loader {
62
  * @since 1.0
63
  */
64
  private static function call_wp_hooks() {
65
- add_action( 'admin_head', array( __CLASS__, 'enqueue_scripts_styles' ) );
66
  add_action( 'in_widget_form', array( 'WCSSC', 'extend_widget_form' ), 10, 3 );
67
  add_filter( 'widget_update_callback', array( 'WCSSC', 'update_widget' ), 10, 2 );
68
  add_filter( 'plugin_action_links', array( 'WCSSC_Lib', 'add_settings_link' ), 10, 2 );
62
  * @since 1.0
63
  */
64
  private static function call_wp_hooks() {
65
+ add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_scripts_styles' ) );
66
  add_action( 'in_widget_form', array( 'WCSSC', 'extend_widget_form' ), 10, 3 );
67
  add_filter( 'widget_update_callback', array( 'WCSSC', 'update_widget' ), 10, 2 );
68
  add_filter( 'plugin_action_links', array( 'WCSSC_Lib', 'add_settings_link' ), 10, 2 );
includes/widget-css-classes-settings.class.php CHANGED
@@ -50,37 +50,37 @@ class WCSSC_Settings {
50
  }
51
 
52
  function show_number_option() { ?>
53
- <input type="radio" name="<?php echo $this->general_key.'[show_number]'; ?>" value="1" <?php checked( $this->general_settings['show_number'], 1 ); ?> /> <?php esc_attr_e( 'Yes', 'widget-css-classes' ); ?>&nbsp;&nbsp;
54
- <input type="radio" name="<?php echo $this->general_key.'[show_number]'; ?>" value="0" <?php checked( $this->general_settings['show_number'], 0 ); ?> /> <?php esc_attr_e( 'No', 'widget-css-classes' ); ?>
55
  <?php
56
  }
57
 
58
  function show_location_option() {
59
  ?>
60
- <input type="radio" name="<?php echo $this->general_key.'[show_location]'; ?>" value="1" <?php checked( $this->general_settings['show_location'], 1 ); ?> /> <?php esc_attr_e( 'Yes', 'widget-css-classes' ); ?>&nbsp;&nbsp;
61
- <input type="radio" name="<?php echo $this->general_key.'[show_location]'; ?>" value="0" <?php checked( $this->general_settings['show_location'], 0 ); ?> /> <?php esc_attr_e( 'No', 'widget-css-classes' ); ?>
62
  <?php
63
  }
64
 
65
  function show_evenodd_option() {
66
  ?>
67
- <input type="radio" name="<?php echo $this->general_key.'[show_evenodd]'; ?>" value="1" <?php checked( $this->general_settings['show_evenodd'], 1 ); ?> /> <?php esc_attr_e( 'Yes', 'widget-css-classes' ); ?>&nbsp;&nbsp;
68
- <input type="radio" name="<?php echo $this->general_key.'[show_evenodd]'; ?>" value="0" <?php checked( $this->general_settings['show_evenodd'], 0 ); ?> /> <?php esc_attr_e( 'No', 'widget-css-classes' ); ?>
69
  <?php
70
  }
71
 
72
  function show_id_option() {
73
  ?>
74
- <input type="radio" name="<?php echo $this->general_key.'[show_id]'; ?>" value="1" <?php checked( $this->general_settings['show_id'], 1 ); ?> /> <?php esc_attr_e( 'Yes', 'widget-css-classes' ); ?>&nbsp;&nbsp;
75
- <input type="radio" name="<?php echo $this->general_key.'[show_id]'; ?>" value="0" <?php checked( $this->general_settings['show_id'], 0 ); ?> /> <?php esc_attr_e( 'No', 'widget-css-classes' ); ?>
76
  <?php
77
  }
78
 
79
  function type_option() {
80
  ?>
81
- <input type="radio" name="<?php echo $this->general_key.'[type]'; ?>" value="1" <?php checked( $this->general_settings['type'], 1 ); ?> /> <?php esc_attr_e( 'Text', 'widget-css-classes' ); ?>&nbsp;&nbsp;
82
- <input type="radio" name="<?php echo $this->general_key.'[type]'; ?>" value="2" <?php checked( $this->general_settings['type'], 2 ); ?> /> <?php esc_attr_e( 'Dropdown', 'widget-css-classes' ); ?>&nbsp;&nbsp;
83
- <input type="radio" name="<?php echo $this->general_key.'[type]'; ?>" value="3" <?php checked( $this->general_settings['type'], 3 ); ?> /> <?php esc_attr_e( 'Hide', 'widget-css-classes' ); ?>
84
  <?php
85
  }
86
 
@@ -90,23 +90,23 @@ class WCSSC_Settings {
90
  foreach ( $presets as $key => $preset ) {
91
  if ( $preset != '' ) {
92
  ?>
93
- <p><input type="text" name="<?php echo $this->general_key.'[dropdown]['.$key.']'; ?>" value="<?php echo $preset; ?>" />
94
- &nbsp;&nbsp;&nbsp;&nbsp;<a class="wcssc_remove" href="#"><img src="<?php echo WCSSC_PLUGIN_URL; ?>/images/bullet-toggle-minus-icon.png" alt="-" /></a></p>
95
  <?php
96
  }
97
  }
98
  ?>
99
  <p class="wcssc_dropdown">
100
- <input type="text" name="<?php echo $this->general_key.'[dropdown][]'; ?>" value="" />
101
- <a href="#" class="wcssc_copy" rel=".wcssc_dropdown"><img src="<?php echo WCSSC_PLUGIN_URL; ?>/images/bullet-toggle-plus-icon.png" alt="+" /></a>
102
- <a class="wcssc_remove" href="#"><img src="<?php echo WCSSC_PLUGIN_URL; ?>/images/bullet-toggle-minus-icon.png" alt="-" /></a>
103
  </p>
104
  <?php
105
  } else {
106
  ?>
107
- <p class="wcssc_dropdown"><input type="text" name="<?php echo $this->general_key.'[dropdown][]'; ?>" value="<?php echo $this->general_settings['dropdown']; ?>" />
108
- <a href="#" class="wcssc_copy" rel=".wcssc_dropdown"><img src="<?php echo WCSSC_PLUGIN_URL; ?>/images/bullet-toggle-plus-icon.png" alt="+" /></a>
109
- <a class="wcssc_remove" href="#"><img src="<?php echo WCSSC_PLUGIN_URL; ?>/images/bullet-toggle-minus-icon.png" alt="-" /></a></p>
110
  <?php
111
  }
112
  }
@@ -132,7 +132,7 @@ class WCSSC_Settings {
132
  }
133
 
134
  if ( isset( $wcssc_message ) && $wcssc_message != '' ) {
135
- echo '<div class="updated"><p>'.$wcssc_message.'</p></div>';
136
  }
137
 
138
  // export settings
@@ -167,7 +167,7 @@ class WCSSC_Settings {
167
  $wcssc_message = 3;
168
  }
169
 
170
- wp_redirect( admin_url( '/options-general.php?page=widget-css-classes-settings&tab=importexport&wcssc_message='.$wcssc_message ) );
171
  exit;
172
  }
173
  }
@@ -229,11 +229,10 @@ class WCSSC_Settings {
229
  function plugin_options_tabs() {
230
  $current_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : $this->general_key;
231
 
232
- screen_icon( 'options-general' );
233
  echo '<h2 class="nav-tab-wrapper">';
234
  foreach ( $this->plugin_tabs as $tab_key => $tab_caption ) {
235
  $active = $current_tab == $tab_key ? 'nav-tab-active' : '';
236
- echo '<a class="nav-tab '.$active.'" href="?page='.$this->plugin_key.'&amp;tab='.$tab_key.'">'.$tab_caption.'</a>';
237
  }
238
  echo '</h2>';
239
  }
50
  }
51
 
52
  function show_number_option() { ?>
53
+ <input type="radio" name="<?php echo esc_attr( $this->general_key ).'[show_number]'; ?>" value="1" <?php checked( $this->general_settings['show_number'], 1 ); ?> /> <?php esc_attr_e( 'Yes', 'widget-css-classes' ); ?>&nbsp;&nbsp;
54
+ <input type="radio" name="<?php echo esc_attr( $this->general_key ).'[show_number]'; ?>" value="0" <?php checked( $this->general_settings['show_number'], 0 ); ?> /> <?php esc_attr_e( 'No', 'widget-css-classes' ); ?>
55
  <?php
56
  }
57
 
58
  function show_location_option() {
59
  ?>
60
+ <input type="radio" name="<?php echo esc_attr( $this->general_key ).'[show_location]'; ?>" value="1" <?php checked( $this->general_settings['show_location'], 1 ); ?> /> <?php esc_attr_e( 'Yes', 'widget-css-classes' ); ?>&nbsp;&nbsp;
61
+ <input type="radio" name="<?php echo esc_attr( $this->general_key ).'[show_location]'; ?>" value="0" <?php checked( $this->general_settings['show_location'], 0 ); ?> /> <?php esc_attr_e( 'No', 'widget-css-classes' ); ?>
62
  <?php
63
  }
64
 
65
  function show_evenodd_option() {
66
  ?>
67
+ <input type="radio" name="<?php echo esc_attr( $this->general_key ).'[show_evenodd]'; ?>" value="1" <?php checked( $this->general_settings['show_evenodd'], 1 ); ?> /> <?php esc_attr_e( 'Yes', 'widget-css-classes' ); ?>&nbsp;&nbsp;
68
+ <input type="radio" name="<?php echo esc_attr( $this->general_key ).'[show_evenodd]'; ?>" value="0" <?php checked( $this->general_settings['show_evenodd'], 0 ); ?> /> <?php esc_attr_e( 'No', 'widget-css-classes' ); ?>
69
  <?php
70
  }
71
 
72
  function show_id_option() {
73
  ?>
74
+ <input type="radio" name="<?php echo esc_attr( $this->general_key ).'[show_id]'; ?>" value="1" <?php checked( $this->general_settings['show_id'], 1 ); ?> /> <?php esc_attr_e( 'Yes', 'widget-css-classes' ); ?>&nbsp;&nbsp;
75
+ <input type="radio" name="<?php echo esc_attr( $this->general_key ).'[show_id]'; ?>" value="0" <?php checked( $this->general_settings['show_id'], 0 ); ?> /> <?php esc_attr_e( 'No', 'widget-css-classes' ); ?>
76
  <?php
77
  }
78
 
79
  function type_option() {
80
  ?>
81
+ <input type="radio" name="<?php echo esc_attr( $this->general_key ).'[type]'; ?>" value="1" <?php checked( $this->general_settings['type'], 1 ); ?> /> <?php esc_attr_e( 'Text', 'widget-css-classes' ); ?>&nbsp;&nbsp;
82
+ <input type="radio" name="<?php echo esc_attr( $this->general_key ).'[type]'; ?>" value="2" <?php checked( $this->general_settings['type'], 2 ); ?> /> <?php esc_attr_e( 'Dropdown', 'widget-css-classes' ); ?>&nbsp;&nbsp;
83
+ <input type="radio" name="<?php echo esc_attr( $this->general_key ).'[type]'; ?>" value="3" <?php checked( $this->general_settings['type'], 3 ); ?> /> <?php esc_attr_e( 'Hide', 'widget-css-classes' ); ?>
84
  <?php
85
  }
86
 
90
  foreach ( $presets as $key => $preset ) {
91
  if ( $preset != '' ) {
92
  ?>
93
+ <p><input type="text" name="<?php echo esc_attr( $this->general_key ).'[dropdown]['.esc_attr( $key ).']'; ?>" value="<?php echo esc_attr( $preset ); ?>" />
94
+ &nbsp;&nbsp;&nbsp;&nbsp;<a class="wcssc_remove" href="#"><img src="<?php echo esc_attr( WCSSC_PLUGIN_URL ); ?>/images/bullet-toggle-minus-icon.png" alt="-" /></a></p>
95
  <?php
96
  }
97
  }
98
  ?>
99
  <p class="wcssc_dropdown">
100
+ <input type="text" name="<?php echo esc_attr( $this->general_key ).'[dropdown][]'; ?>" value="" />
101
+ <a href="#" class="wcssc_copy" rel=".wcssc_dropdown"><img src="<?php echo esc_attr( WCSSC_PLUGIN_URL ); ?>/images/bullet-toggle-plus-icon.png" alt="+" /></a>
102
+ <a class="wcssc_remove" href="#"><img src="<?php echo esc_attr( WCSSC_PLUGIN_URL ); ?>/images/bullet-toggle-minus-icon.png" alt="-" /></a>
103
  </p>
104
  <?php
105
  } else {
106
  ?>
107
+ <p class="wcssc_dropdown"><input type="text" name="<?php echo esc_attr( $this->general_key ).'[dropdown][]'; ?>" value="<?php echo esc_attr( $this->general_settings['dropdown'] ); ?>" />
108
+ <a href="#" class="wcssc_copy" rel=".wcssc_dropdown"><img src="<?php echo esc_attr( WCSSC_PLUGIN_URL ); ?>/images/bullet-toggle-plus-icon.png" alt="+" /></a>
109
+ <a class="wcssc_remove" href="#"><img src="<?php echo esc_attr( WCSSC_PLUGIN_URL ); ?>/images/bullet-toggle-minus-icon.png" alt="-" /></a></p>
110
  <?php
111
  }
112
  }
132
  }
133
 
134
  if ( isset( $wcssc_message ) && $wcssc_message != '' ) {
135
+ echo '<div class="updated"><p>'.esc_html( $wcssc_message ).'</p></div>';
136
  }
137
 
138
  // export settings
167
  $wcssc_message = 3;
168
  }
169
 
170
+ wp_redirect( admin_url( '/options-general.php?page=widget-css-classes-settings&tab=importexport&wcssc_message='.esc_attr( $wcssc_message ) ) );
171
  exit;
172
  }
173
  }
229
  function plugin_options_tabs() {
230
  $current_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : $this->general_key;
231
 
 
232
  echo '<h2 class="nav-tab-wrapper">';
233
  foreach ( $this->plugin_tabs as $tab_key => $tab_caption ) {
234
  $active = $current_tab == $tab_key ? 'nav-tab-active' : '';
235
+ echo '<a class="nav-tab '.esc_attr( $active ).'" href="?page='.esc_attr( $this->plugin_key ).'&amp;tab='.esc_attr( $tab_key ).'">'.esc_html( $tab_caption ).'</a>';
236
  }
237
  echo '</h2>';
238
  }
includes/widget-css-classes.class.php CHANGED
@@ -25,27 +25,28 @@ class WCSSC {
25
  */
26
  public static function extend_widget_form( $widget, $return, $instance ) {
27
  if ( !isset( $instance['classes'] ) ) $instance['classes'] = null;
28
-
29
- $fields = "<p>\n";
30
 
31
  // show id field
32
  if ( WCSSC_Loader::$settings['show_id'] == 1 ) {
33
  if ( !isset( $instance['ids'] ) ) $instance['ids'] = null;
34
- $fields .= "\t<label for='widget-{$widget->id_base}-{$widget->number}-ids'>".apply_filters( 'widget_css_classes_id', esc_html__( 'CSS ID', 'widget-css-classes' ) ).":</label>
35
- <input type='text' name='widget-{$widget->id_base}[{$widget->number}][ids]' id='widget-{$widget->id_base}-{$widget->number}-ids' value='{$instance['ids']}'/><br />\n";
36
  }
37
 
 
 
38
  // show text field
39
  if ( WCSSC_Loader::$settings['type'] == 1 ) {
40
  $fields .= "\t<label for='widget-{$widget->id_base}-{$widget->number}-classes'>".apply_filters( 'widget_css_classes_class', esc_html__( 'CSS Class', 'widget-css-classes' ) ).":</label>
41
- <input type='text' name='widget-{$widget->id_base}[{$widget->number}][classes]' id='widget-{$widget->id_base}-{$widget->number}-classes' value='{$instance['classes']}'/>\n";
42
  }
43
 
44
  // show dropdown
45
  if ( WCSSC_Loader::$settings['type'] == 2 ) {
46
  $preset_values = explode( ';', WCSSC_Loader::$settings['dropdown'] );
47
  $fields .= "\t<label for='widget-{$widget->id_base}-{$widget->number}-classes'>".apply_filters( 'widget_css_classes_class', esc_html__( 'CSS Class', 'widget-css-classes' ) ).":</label>\n";
48
- $fields .= "\t<select name='widget-{$widget->id_base}[{$widget->number}][classes]' id='widget-{$widget->id_base}-{$widget->number}-classes'>\n";
49
  $fields .= "\t<option value=''>".esc_attr__( 'Select', 'widget-css-classes' )."</option>\n";
50
  foreach ( $preset_values as $preset ) {
51
  if ( $preset != '' ) {
@@ -126,8 +127,7 @@ class WCSSC {
126
  }
127
  if ( isset( $custom_sidebarcheck[0] ) && ( $custom_sidebarcheck[0] == 'yes' ) ) {
128
  $widget_opt = get_option( 'widget_'.$id.'_'.substr($widget_obj['callback'][0]->option_name, 7) );
129
- }
130
- else {
131
  $widget_opt = get_option( $widget_obj['callback'][0]->option_name );
132
  }
133
  }
25
  */
26
  public static function extend_widget_form( $widget, $return, $instance ) {
27
  if ( !isset( $instance['classes'] ) ) $instance['classes'] = null;
28
+ $fields = '';
 
29
 
30
  // show id field
31
  if ( WCSSC_Loader::$settings['show_id'] == 1 ) {
32
  if ( !isset( $instance['ids'] ) ) $instance['ids'] = null;
33
+ $fields .= "\t<p><label for='widget-{$widget->id_base}-{$widget->number}-ids'>".apply_filters( 'widget_css_classes_id', esc_html__( 'CSS ID', 'widget-css-classes' ) ).":</label>
34
+ <input type='text' name='widget-{$widget->id_base}[{$widget->number}][ids]' id='widget-{$widget->id_base}-{$widget->number}-ids' value='{$instance['ids']}' class='widefat' /></p>\n";
35
  }
36
 
37
+ $fields .= "<p>\n";
38
+
39
  // show text field
40
  if ( WCSSC_Loader::$settings['type'] == 1 ) {
41
  $fields .= "\t<label for='widget-{$widget->id_base}-{$widget->number}-classes'>".apply_filters( 'widget_css_classes_class', esc_html__( 'CSS Class', 'widget-css-classes' ) ).":</label>
42
+ <input type='text' name='widget-{$widget->id_base}[{$widget->number}][classes]' id='widget-{$widget->id_base}-{$widget->number}-classes' value='{$instance['classes']}' class='widefat' />\n";
43
  }
44
 
45
  // show dropdown
46
  if ( WCSSC_Loader::$settings['type'] == 2 ) {
47
  $preset_values = explode( ';', WCSSC_Loader::$settings['dropdown'] );
48
  $fields .= "\t<label for='widget-{$widget->id_base}-{$widget->number}-classes'>".apply_filters( 'widget_css_classes_class', esc_html__( 'CSS Class', 'widget-css-classes' ) ).":</label>\n";
49
+ $fields .= "\t<select name='widget-{$widget->id_base}[{$widget->number}][classes]' id='widget-{$widget->id_base}-{$widget->number}-classes' class='widefat'>\n";
50
  $fields .= "\t<option value=''>".esc_attr__( 'Select', 'widget-css-classes' )."</option>\n";
51
  foreach ( $preset_values as $preset ) {
52
  if ( $preset != '' ) {
127
  }
128
  if ( isset( $custom_sidebarcheck[0] ) && ( $custom_sidebarcheck[0] == 'yes' ) ) {
129
  $widget_opt = get_option( 'widget_'.$id.'_'.substr($widget_obj['callback'][0]->option_name, 7) );
130
+ } elseif ( isset( $widget_obj['callback'][0]->option_name ) ) {
 
131
  $widget_opt = get_option( $widget_obj['callback'][0]->option_name );
132
  }
133
  }
readme.txt CHANGED
@@ -7,8 +7,8 @@ Tags: widgets, classes, css, widget classes, widget css
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
  Requires at least: 3.3
10
- Tested up to: 3.9
11
- Stable tag: 1.2.6
12
 
13
  Add custom classes and ids plus first, last, even, odd, and numbered classes to your widgets.
14
 
@@ -94,6 +94,12 @@ Visit [the plugin website](http://cleverness.org/plugins/widget-css-classes/) an
94
 
95
  == Changelog ==
96
 
 
 
 
 
 
 
97
  = 1.2.6 =
98
  * Fixed error notice
99
 
@@ -133,6 +139,9 @@ Visit [the plugin website](http://cleverness.org/plugins/widget-css-classes/) an
133
 
134
  == Upgrade Notice ==
135
 
 
 
 
136
  = 1.2.6 =
137
  Bug fix
138
 
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
  Requires at least: 3.3
10
+ Tested up to: 4.3
11
+ Stable tag: 1.2.7
12
 
13
  Add custom classes and ids plus first, last, even, odd, and numbered classes to your widgets.
14
 
94
 
95
  == Changelog ==
96
 
97
+ = 1.2.7 =
98
+ * Changed class and ID fields to full-width
99
+ * Added missing escaping from settings page
100
+ * Enqueue admin scripts on correct hook
101
+ * Fixed undefined notice when option was not found
102
+
103
  = 1.2.6 =
104
  * Fixed error notice
105
 
139
 
140
  == Upgrade Notice ==
141
 
142
+ = 1.2.7 =
143
+ Bug fix
144
+
145
  = 1.2.6 =
146
  Bug fix
147
 
screenshot-1.jpg DELETED
Binary file
screenshot-2.jpg DELETED
Binary file
screenshot-3.png DELETED
Binary file
screenshot-4.png DELETED
Binary file
widget-css-classes.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Widget CSS Classes
4
- Version: 1.2.6
5
  Description: Add custom, first, last, even, odd, and numbered classes to your widgets.
6
  Author: C.M. Kendrick
7
  Author URI: http://cleverness.org
1
  <?php
2
  /*
3
  Plugin Name: Widget CSS Classes
4
+ Version: 1.2.7
5
  Description: Add custom, first, last, even, odd, and numbered classes to your widgets.
6
  Author: C.M. Kendrick
7
  Author URI: http://cleverness.org