Version Description
- Feature: Sort Pre-defined classes (thanks Jory Hogeveen)
- Security: Prevent unauthenticated import of settings
- Fix: Notice message when classes is empty (thanks Jory Hogeveen)
Download this release
Release Info
| Developer | elusivelight |
| Plugin | |
| Version | 1.4.0 |
| Comparing to | |
| See all releases | |
Code changes from version 1.3.0 to 1.4.0
- README.md +8 -0
- css/widget-css-classes.css +15 -3
- includes/widget-css-classes-settings.class.php +98 -73
- includes/widget-css-classes.class.php +10 -4
- js/widget-css-classes.js +8 -0
- readme.txt +10 -2
- widget-css-classes.php +1 -1
README.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Widget CSS Classes
|
| 2 |
+
|
| 3 |
+
**Version:** see [widget-css-classes.php](/widget-css-classes.php)
|
| 4 |
+
**Description:** Add custom, first, last, even, odd, and numbered classes to your widgets.
|
| 5 |
+
**Author:** C.M. Kendrick
|
| 6 |
+
**Author URI:** http://cleverness.org
|
| 7 |
+
**Plugin URI:** http://cleverness.org/plugins/widget-css-classes
|
| 8 |
+
**Text Domain:** widget-css-classes
|
css/widget-css-classes.css
CHANGED
|
@@ -1,8 +1,20 @@
|
|
| 1 |
-
.wcssc_copy span, .wcssc_remove span {
|
| 2 |
-
vertical-align:
|
| 3 |
margin: 0;
|
| 4 |
padding: 0;
|
| 5 |
}
|
| 6 |
-
.wcssc_copy, .wcssc_remove {
|
| 7 |
text-decoration: none;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
}
|
| 1 |
+
.wcssc_copy span, .wcssc_remove span, .wcssc_sort span {
|
| 2 |
+
vertical-align: text-bottom;
|
| 3 |
margin: 0;
|
| 4 |
padding: 0;
|
| 5 |
}
|
| 6 |
+
.wcssc_copy, .wcssc_remove, .wcssc_sort {
|
| 7 |
text-decoration: none;
|
| 8 |
+
}
|
| 9 |
+
.wcssc_sort {
|
| 10 |
+
display: none;
|
| 11 |
+
cursor: move;
|
| 12 |
+
}
|
| 13 |
+
.wcssc_sort_fixed .wcssc_sort {
|
| 14 |
+
visibility: hidden;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
.wcssc_sortable .wcssc_drop_placeholder {
|
| 18 |
+
background: #e5e5e5;
|
| 19 |
+
height: 30px;
|
| 20 |
}
|
includes/widget-css-classes-settings.class.php
CHANGED
|
@@ -21,21 +21,21 @@ class WCSSC_Settings {
|
|
| 21 |
private $plugin_tabs = array();
|
| 22 |
private $general_settings = array();
|
| 23 |
|
| 24 |
-
function __construct() {
|
| 25 |
add_action( 'admin_init', array( $this, 'load_settings' ) );
|
| 26 |
add_action( 'admin_init', array( $this, 'register_general_settings' ) );
|
| 27 |
add_action( 'admin_init', array( $this, 'register_importexport_settings' ) );
|
| 28 |
add_action( 'admin_menu', array( $this, 'add_admin_menus' ) );
|
| 29 |
}
|
| 30 |
|
| 31 |
-
function load_settings() {
|
| 32 |
$this->general_settings = get_option( $this->general_key );
|
| 33 |
}
|
| 34 |
|
| 35 |
-
function section_general_desc() {
|
| 36 |
}
|
| 37 |
|
| 38 |
-
function register_general_settings() {
|
| 39 |
$this->plugin_tabs[$this->general_key] = esc_attr__( 'Widget CSS Classes Settings', 'widget-css-classes' );
|
| 40 |
|
| 41 |
register_setting( $this->general_key, $this->general_key, array( $this, 'validate_input' ) );
|
|
@@ -49,34 +49,34 @@ class WCSSC_Settings {
|
|
| 49 |
do_action( 'widget_css_classes_settings' );
|
| 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' ); ?>
|
| 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' ); ?>
|
| 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' ); ?>
|
| 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' ); ?>
|
| 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' ); ?>
|
| 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( 'Predefined', 'widget-css-classes' ); ?>
|
|
@@ -85,19 +85,27 @@ class WCSSC_Settings {
|
|
| 85 |
<?php
|
| 86 |
}
|
| 87 |
|
| 88 |
-
function defined_classes_option() {
|
|
|
|
| 89 |
$presets = explode( ';', $this->general_settings['defined_classes'] );
|
|
|
|
|
|
|
|
|
|
| 90 |
if ( count( $presets ) > 1 ) {
|
| 91 |
foreach ( $presets as $key => $preset ) {
|
| 92 |
if ( $preset != '' ) {
|
| 93 |
?>
|
| 94 |
-
<p
|
| 95 |
-
|
|
|
|
|
|
|
|
|
|
| 96 |
<?php
|
| 97 |
}
|
| 98 |
}
|
| 99 |
?>
|
| 100 |
-
<p class="wcssc_defined_classes">
|
|
|
|
| 101 |
<input type="text" name="<?php echo esc_attr( $this->general_key ).'[defined_classes][]'; ?>" value="" />
|
| 102 |
<a href="#" class="wcssc_copy" rel=".wcssc_defined_classes"><span class="dashicons dashicons-plus-alt"></span></a>
|
| 103 |
<a class="wcssc_remove" href="#"><span class="dashicons dashicons-dismiss"></span></a>
|
|
@@ -105,79 +113,96 @@ class WCSSC_Settings {
|
|
| 105 |
<?php
|
| 106 |
} else {
|
| 107 |
?>
|
| 108 |
-
<p class="wcssc_defined_classes
|
| 109 |
-
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
| 111 |
<?php
|
| 112 |
}
|
|
|
|
|
|
|
|
|
|
| 113 |
}
|
| 114 |
|
| 115 |
-
function register_importexport_settings() {
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
}
|
| 133 |
-
}
|
| 134 |
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
|
|
|
| 151 |
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
|
|
|
|
|
|
| 164 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
}
|
| 166 |
-
update_option( 'WCSSC_options', $options );
|
| 167 |
-
$wcssc_message = 1;
|
| 168 |
} else {
|
| 169 |
-
$wcssc_message =
|
| 170 |
}
|
| 171 |
-
|
| 172 |
-
$wcssc_message
|
|
|
|
| 173 |
}
|
| 174 |
|
| 175 |
-
wp_redirect( admin_url( '/options-general.php?page=widget-css-classes-settings&tab=importexport&wcssc_message='.esc_attr( $wcssc_message ) ) );
|
| 176 |
-
exit;
|
| 177 |
}
|
| 178 |
}
|
| 179 |
|
| 180 |
-
function validate_input( $input ) {
|
| 181 |
$output = array();
|
| 182 |
|
| 183 |
foreach ( $input as $key => $value ) {
|
|
@@ -198,7 +223,7 @@ class WCSSC_Settings {
|
|
| 198 |
return $output;
|
| 199 |
}
|
| 200 |
|
| 201 |
-
function add_admin_menus() {
|
| 202 |
add_options_page( esc_attr__( 'Widget CSS Classes', 'widget-css-classes' ), esc_attr__( 'Widget CSS Classes', 'widget-css-classes' ), 'manage_options', 'widget-css-classes-settings', array( $this, 'plugin_options_page' ) );
|
| 203 |
}
|
| 204 |
|
|
@@ -208,7 +233,7 @@ class WCSSC_Settings {
|
|
| 208 |
* settings key. Uses the plugin_options_tabs method
|
| 209 |
* to render the tabs.
|
| 210 |
*/
|
| 211 |
-
function plugin_options_page() {
|
| 212 |
$tab = isset( $_GET['tab'] ) ? $_GET['tab'] : $this->general_key;
|
| 213 |
?>
|
| 214 |
<div class="wrap">
|
|
@@ -231,7 +256,7 @@ class WCSSC_Settings {
|
|
| 231 |
* them one by one. Provides the heading for the
|
| 232 |
* plugin_options_page method.
|
| 233 |
*/
|
| 234 |
-
function plugin_options_tabs() {
|
| 235 |
$current_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : $this->general_key;
|
| 236 |
|
| 237 |
echo '<h1 class="nav-tab-wrapper">';
|
|
@@ -242,7 +267,7 @@ class WCSSC_Settings {
|
|
| 242 |
echo '</h1>';
|
| 243 |
}
|
| 244 |
|
| 245 |
-
function importexport_fields() {
|
| 246 |
?>
|
| 247 |
<h3><?php esc_html_e( 'Import/Export Settings', 'widget-css-classes' ); ?></h3>
|
| 248 |
|
| 21 |
private $plugin_tabs = array();
|
| 22 |
private $general_settings = array();
|
| 23 |
|
| 24 |
+
public function __construct() {
|
| 25 |
add_action( 'admin_init', array( $this, 'load_settings' ) );
|
| 26 |
add_action( 'admin_init', array( $this, 'register_general_settings' ) );
|
| 27 |
add_action( 'admin_init', array( $this, 'register_importexport_settings' ) );
|
| 28 |
add_action( 'admin_menu', array( $this, 'add_admin_menus' ) );
|
| 29 |
}
|
| 30 |
|
| 31 |
+
public function load_settings() {
|
| 32 |
$this->general_settings = get_option( $this->general_key );
|
| 33 |
}
|
| 34 |
|
| 35 |
+
public function section_general_desc() {
|
| 36 |
}
|
| 37 |
|
| 38 |
+
public function register_general_settings() {
|
| 39 |
$this->plugin_tabs[$this->general_key] = esc_attr__( 'Widget CSS Classes Settings', 'widget-css-classes' );
|
| 40 |
|
| 41 |
register_setting( $this->general_key, $this->general_key, array( $this, 'validate_input' ) );
|
| 49 |
do_action( 'widget_css_classes_settings' );
|
| 50 |
}
|
| 51 |
|
| 52 |
+
public 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' ); ?>
|
| 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 |
+
public 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' ); ?>
|
| 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 |
+
public 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' ); ?>
|
| 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 |
+
public 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' ); ?>
|
| 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 |
+
public 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' ); ?>
|
| 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( 'Predefined', 'widget-css-classes' ); ?>
|
| 85 |
<?php
|
| 86 |
}
|
| 87 |
|
| 88 |
+
public function defined_classes_option() {
|
| 89 |
+
wp_enqueue_script( 'jquery-ui-sortable' );
|
| 90 |
$presets = explode( ';', $this->general_settings['defined_classes'] );
|
| 91 |
+
?>
|
| 92 |
+
<div class="wcssc_sortable">
|
| 93 |
+
<?php
|
| 94 |
if ( count( $presets ) > 1 ) {
|
| 95 |
foreach ( $presets as $key => $preset ) {
|
| 96 |
if ( $preset != '' ) {
|
| 97 |
?>
|
| 98 |
+
<p class="wcssc_defined_classes">
|
| 99 |
+
<a class="wcssc_sort" href="#"><span class="dashicons dashicons-sort"></span></a>
|
| 100 |
+
<input type="text" name="<?php echo esc_attr( $this->general_key ).'[defined_classes]['.esc_attr( $key ).']'; ?>" value="<?php echo esc_attr( $preset ); ?>" />
|
| 101 |
+
<a class="wcssc_remove" href="#"><span class="dashicons dashicons-dismiss"></span></a>
|
| 102 |
+
</p>
|
| 103 |
<?php
|
| 104 |
}
|
| 105 |
}
|
| 106 |
?>
|
| 107 |
+
<p class="wcssc_defined_classes wcssc_sort_fixed">
|
| 108 |
+
<a class="wcssc_sort" href="#"><span class="dashicons dashicons-sort"></span></a>
|
| 109 |
<input type="text" name="<?php echo esc_attr( $this->general_key ).'[defined_classes][]'; ?>" value="" />
|
| 110 |
<a href="#" class="wcssc_copy" rel=".wcssc_defined_classes"><span class="dashicons dashicons-plus-alt"></span></a>
|
| 111 |
<a class="wcssc_remove" href="#"><span class="dashicons dashicons-dismiss"></span></a>
|
| 113 |
<?php
|
| 114 |
} else {
|
| 115 |
?>
|
| 116 |
+
<p class="wcssc_defined_classes wcssc_sort_fixed">
|
| 117 |
+
<a class="wcssc_sort" href="#"><span class="dashicons dashicons-sort"></span></a>
|
| 118 |
+
<input type="text" name="<?php echo esc_attr( $this->general_key ).'[defined_classes][]'; ?>" value="<?php echo esc_attr( $this->general_settings['defined_classes'] ); ?>" />
|
| 119 |
+
<a href="#" class="wcssc_copy" rel=".wcssc_defined_classes"><span class="dashicons dashicons-plus-alt"></span></a>
|
| 120 |
+
<a class="wcssc_remove" href="#"><span class="dashicons dashicons-dismiss"></span></a>
|
| 121 |
+
</p>
|
| 122 |
<?php
|
| 123 |
}
|
| 124 |
+
?>
|
| 125 |
+
</div>
|
| 126 |
+
<?php
|
| 127 |
}
|
| 128 |
|
| 129 |
+
public function register_importexport_settings() {
|
| 130 |
+
|
| 131 |
+
if ( current_user_can('manage_options' ) ) {
|
| 132 |
+
|
| 133 |
+
$this->plugin_tabs['importexport'] = esc_attr__( 'Import/Export', 'widget-css-classes' );
|
| 134 |
+
|
| 135 |
+
if ( isset( $_GET['wcssc_message'] ) ) {
|
| 136 |
+
switch ( $_GET['wcssc_message'] ) {
|
| 137 |
+
case 1:
|
| 138 |
+
$wcssc_message_class = 'updated';
|
| 139 |
+
$wcssc_message = esc_attr__( 'Settings Imported', 'widget-css-classes' );
|
| 140 |
+
break;
|
| 141 |
+
case 2:
|
| 142 |
+
$wcssc_message_class = 'error';
|
| 143 |
+
$wcssc_message = esc_attr__( 'Invalid Settings File', 'widget-css-classes' );
|
| 144 |
+
break;
|
| 145 |
+
case 3:
|
| 146 |
+
$wcssc_message_class = 'error';
|
| 147 |
+
$wcssc_message = esc_attr__( 'No Settings File Selected', 'widget-css-classes' );
|
| 148 |
+
break;
|
| 149 |
+
default:
|
| 150 |
+
$wcssc_message_class = '';
|
| 151 |
+
$wcssc_message = '';
|
| 152 |
+
break;
|
| 153 |
+
}
|
| 154 |
}
|
|
|
|
| 155 |
|
| 156 |
+
if ( isset( $wcssc_message ) && $wcssc_message != '' ) {
|
| 157 |
+
echo '<div class=" ' . $wcssc_message_class . ' "><p>' . esc_html( $wcssc_message ) . '</p></div>';
|
| 158 |
+
}
|
| 159 |
|
| 160 |
+
// export settings
|
| 161 |
+
if ( isset( $_GET['widget-css-classes-settings-export'] ) ) {
|
| 162 |
+
header( "Content-Disposition: attachment; filename=widget-css-classes-settings.txt" );
|
| 163 |
+
header( 'Content-Type: text/plain; charset=utf-8' );
|
| 164 |
+
$general = get_option( 'WCSSC_options' );
|
| 165 |
+
|
| 166 |
+
echo "[START=WCSSC SETTINGS]\n";
|
| 167 |
+
foreach ( $general as $id => $text ) {
|
| 168 |
+
echo "$id\t" . json_encode( $text ) . "\n";
|
| 169 |
+
}
|
| 170 |
+
echo "[STOP=WCSSC SETTINGS]";
|
| 171 |
+
exit;
|
| 172 |
+
}
|
| 173 |
|
| 174 |
+
// import settings
|
| 175 |
+
if ( isset( $_POST['widget-css-classes-settings-import'] ) ) {
|
| 176 |
+
$wcssc_message = '';
|
| 177 |
+
if ( $_FILES['widget-css-classes-settings-import-file']['tmp_name'] ) {
|
| 178 |
+
$import = explode( "\n",
|
| 179 |
+
file_get_contents( $_FILES['widget-css-classes-settings-import-file']['tmp_name'] ) );
|
| 180 |
+
if ( array_shift( $import ) == "[START=WCSSC SETTINGS]" && array_pop( $import ) == "[STOP=WCSSC SETTINGS]" ) {
|
| 181 |
+
foreach ( $import as $import_option ) {
|
| 182 |
+
list( $key, $value ) = explode( "\t", $import_option );
|
| 183 |
+
$options[ $key ] = json_decode( sanitize_text_field( $value ) );
|
| 184 |
+
if ( $options['dropdown'] ) { // Update for 1.3.0
|
| 185 |
+
$options['defined_classes'] = $options['dropdown'];
|
| 186 |
+
unset( $options['dropdown'] );
|
| 187 |
+
}
|
| 188 |
}
|
| 189 |
+
update_option( 'WCSSC_options', $options );
|
| 190 |
+
$wcssc_message = 1;
|
| 191 |
+
} else {
|
| 192 |
+
$wcssc_message = 2;
|
| 193 |
}
|
|
|
|
|
|
|
| 194 |
} else {
|
| 195 |
+
$wcssc_message = 3;
|
| 196 |
}
|
| 197 |
+
|
| 198 |
+
wp_redirect( admin_url( '/options-general.php?page=widget-css-classes-settings&tab=importexport&wcssc_message=' . esc_attr( $wcssc_message ) ) );
|
| 199 |
+
exit;
|
| 200 |
}
|
| 201 |
|
|
|
|
|
|
|
| 202 |
}
|
| 203 |
}
|
| 204 |
|
| 205 |
+
public function validate_input( $input ) {
|
| 206 |
$output = array();
|
| 207 |
|
| 208 |
foreach ( $input as $key => $value ) {
|
| 223 |
return $output;
|
| 224 |
}
|
| 225 |
|
| 226 |
+
public function add_admin_menus() {
|
| 227 |
add_options_page( esc_attr__( 'Widget CSS Classes', 'widget-css-classes' ), esc_attr__( 'Widget CSS Classes', 'widget-css-classes' ), 'manage_options', 'widget-css-classes-settings', array( $this, 'plugin_options_page' ) );
|
| 228 |
}
|
| 229 |
|
| 233 |
* settings key. Uses the plugin_options_tabs method
|
| 234 |
* to render the tabs.
|
| 235 |
*/
|
| 236 |
+
public function plugin_options_page() {
|
| 237 |
$tab = isset( $_GET['tab'] ) ? $_GET['tab'] : $this->general_key;
|
| 238 |
?>
|
| 239 |
<div class="wrap">
|
| 256 |
* them one by one. Provides the heading for the
|
| 257 |
* plugin_options_page method.
|
| 258 |
*/
|
| 259 |
+
public function plugin_options_tabs() {
|
| 260 |
$current_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : $this->general_key;
|
| 261 |
|
| 262 |
echo '<h1 class="nav-tab-wrapper">';
|
| 267 |
echo '</h1>';
|
| 268 |
}
|
| 269 |
|
| 270 |
+
public function importexport_fields() {
|
| 271 |
?>
|
| 272 |
<h3><?php esc_html_e( 'Import/Export Settings', 'widget-css-classes' ); ?></h3>
|
| 273 |
|
includes/widget-css-classes.class.php
CHANGED
|
@@ -31,7 +31,7 @@ class WCSSC {
|
|
| 31 |
|
| 32 |
if ( WCSSC_Loader::$settings['show_id'] == 1 || WCSSC_Loader::$settings['type'] > 0 ) {
|
| 33 |
//$fields .= "<div class='wcssc' style='border: 1px solid #ddd; padding: 5px; background: #fafafa; margin: 1em 0; line-height: 1.5;'>\n";
|
| 34 |
-
|
| 35 |
|
| 36 |
// show id field
|
| 37 |
if ( WCSSC_Loader::$settings['show_id'] == 1 ) {
|
|
@@ -83,7 +83,7 @@ class WCSSC {
|
|
| 83 |
$fields .= "\t</ul></p>\n";
|
| 84 |
}
|
| 85 |
|
| 86 |
-
|
| 87 |
}
|
| 88 |
|
| 89 |
do_action( 'widget_css_classes_form', $fields, $instance );
|
|
@@ -101,12 +101,14 @@ class WCSSC {
|
|
| 101 |
* @since 1.0
|
| 102 |
*/
|
| 103 |
public static function update_widget( $instance, $new_instance ) {
|
|
|
|
|
|
|
| 104 |
$instance['classes'] = $new_instance['classes'];
|
| 105 |
$instance['classes-defined'] = $new_instance['classes-defined'];
|
| 106 |
if (WCSSC_Loader::$settings['show_id'] == 1) {
|
| 107 |
$instance['ids'] = $new_instance['ids'];
|
| 108 |
}
|
| 109 |
-
if ( is_array( $instance['classes-defined'] ) ) {
|
| 110 |
// Merge predefined classes with input classes
|
| 111 |
$text_classes = explode( ' ', $instance['classes'] );
|
| 112 |
foreach ( $instance['classes-defined'] as $key => $value ) {
|
|
@@ -133,7 +135,11 @@ class WCSSC {
|
|
| 133 |
public static function add_widget_classes( $params ) {
|
| 134 |
|
| 135 |
global $wp_registered_widgets, $widget_number;
|
| 136 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
$arr_registered_widgets = wp_get_sidebars_widgets(); // Get an array of ALL registered widgets
|
| 138 |
$this_id = $params[0]['id']; // Get the id for the current sidebar we're processing
|
| 139 |
$widget_id = $params[0]['widget_id'];
|
| 31 |
|
| 32 |
if ( WCSSC_Loader::$settings['show_id'] == 1 || WCSSC_Loader::$settings['type'] > 0 ) {
|
| 33 |
//$fields .= "<div class='wcssc' style='border: 1px solid #ddd; padding: 5px; background: #fafafa; margin: 1em 0; line-height: 1.5;'>\n";
|
| 34 |
+
$fields .= "<div class='wcssc'>\n";
|
| 35 |
|
| 36 |
// show id field
|
| 37 |
if ( WCSSC_Loader::$settings['show_id'] == 1 ) {
|
| 83 |
$fields .= "\t</ul></p>\n";
|
| 84 |
}
|
| 85 |
|
| 86 |
+
$fields .= "</div>\n";
|
| 87 |
}
|
| 88 |
|
| 89 |
do_action( 'widget_css_classes_form', $fields, $instance );
|
| 101 |
* @since 1.0
|
| 102 |
*/
|
| 103 |
public static function update_widget( $instance, $new_instance ) {
|
| 104 |
+
if ( !isset( $new_instance['classes'] ) ) $new_instance['classes'] = null;
|
| 105 |
+
if ( !isset( $new_instance['classes-defined'] ) ) $new_instance['classes-defined'] = array();
|
| 106 |
$instance['classes'] = $new_instance['classes'];
|
| 107 |
$instance['classes-defined'] = $new_instance['classes-defined'];
|
| 108 |
if (WCSSC_Loader::$settings['show_id'] == 1) {
|
| 109 |
$instance['ids'] = $new_instance['ids'];
|
| 110 |
}
|
| 111 |
+
if ( ! empty( $instance['classes-defined'] ) && is_array( $instance['classes-defined'] ) ) {
|
| 112 |
// Merge predefined classes with input classes
|
| 113 |
$text_classes = explode( ' ', $instance['classes'] );
|
| 114 |
foreach ( $instance['classes-defined'] as $key => $value ) {
|
| 135 |
public static function add_widget_classes( $params ) {
|
| 136 |
|
| 137 |
global $wp_registered_widgets, $widget_number;
|
| 138 |
+
|
| 139 |
+
if ( ! isset( $params[0] ) ) {
|
| 140 |
+
return $params;
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
$arr_registered_widgets = wp_get_sidebars_widgets(); // Get an array of ALL registered widgets
|
| 144 |
$this_id = $params[0]['id']; // Get the id for the current sidebar we're processing
|
| 145 |
$widget_id = $params[0]['widget_id'];
|
js/widget-css-classes.js
CHANGED
|
@@ -9,4 +9,12 @@ jQuery( document ).ready( function ( $ ) {
|
|
| 9 |
} );
|
| 10 |
} );
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
} );
|
| 9 |
} );
|
| 10 |
} );
|
| 11 |
|
| 12 |
+
if ( $.isFunction( $.fn.sortable ) ) {
|
| 13 |
+
$('.wcssc_sortable .wcssc_sort').show();
|
| 14 |
+
$('.wcssc_sortable').sortable({
|
| 15 |
+
items: 'p:not(.wcssc_sort_fixed)',
|
| 16 |
+
placeholder: 'wcssc_drop_placeholder'
|
| 17 |
+
}).disableSelection();
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
} );
|
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: 4.
|
| 11 |
-
Stable tag: 1.
|
| 12 |
|
| 13 |
Add custom classes and ids plus first, last, even, odd, and numbered classes to your widgets.
|
| 14 |
|
|
@@ -94,6 +94,11 @@ Visit [the plugin website](http://cleverness.org/plugins/widget-css-classes/) an
|
|
| 94 |
|
| 95 |
== Changelog ==
|
| 96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
= 1.3.0 =
|
| 98 |
* Feature: Change dropdown to checkboxes for multiple class selection
|
| 99 |
* Feature: Option to use both predefined and text input classes
|
|
@@ -158,6 +163,9 @@ Visit [the plugin website](http://cleverness.org/plugins/widget-css-classes/) an
|
|
| 158 |
|
| 159 |
== Upgrade Notice ==
|
| 160 |
|
|
|
|
|
|
|
|
|
|
| 161 |
= 1.2.7 =
|
| 162 |
Bug fix
|
| 163 |
|
| 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.8
|
| 11 |
+
Stable tag: 1.4.0
|
| 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.4.0 =
|
| 98 |
+
* Feature: Sort Pre-defined classes (thanks Jory Hogeveen)
|
| 99 |
+
* Security: Prevent unauthenticated import of settings
|
| 100 |
+
* Fix: Notice message when classes is empty (thanks Jory Hogeveen)
|
| 101 |
+
|
| 102 |
= 1.3.0 =
|
| 103 |
* Feature: Change dropdown to checkboxes for multiple class selection
|
| 104 |
* Feature: Option to use both predefined and text input classes
|
| 163 |
|
| 164 |
== Upgrade Notice ==
|
| 165 |
|
| 166 |
+
= 1.4 =
|
| 167 |
+
New feature, bug fix, security fix
|
| 168 |
+
|
| 169 |
= 1.2.7 =
|
| 170 |
Bug fix
|
| 171 |
|
widget-css-classes.php
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?php
|
| 2 |
/*
|
| 3 |
Plugin Name: Widget CSS Classes
|
| 4 |
-
Version: 1.
|
| 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.4.0
|
| 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
|
