Changeset 1550765
- Timestamp:
- 12/09/2016 04:29:20 PM (9 years ago)
- Location:
- widget-css-classes
- Files:
-
- 34 added
- 6 edited
-
tags/1.4.0 (added)
-
tags/1.4.0/README.md (added)
-
tags/1.4.0/css (added)
-
tags/1.4.0/css/widget-css-classes.css (added)
-
tags/1.4.0/includes (added)
-
tags/1.4.0/includes/widget-css-classes-library.class.php (added)
-
tags/1.4.0/includes/widget-css-classes-loader.class.php (added)
-
tags/1.4.0/includes/widget-css-classes-settings.class.php (added)
-
tags/1.4.0/includes/widget-css-classes.class.php (added)
-
tags/1.4.0/js (added)
-
tags/1.4.0/js/relCopy.min.js (added)
-
tags/1.4.0/js/widget-css-classes.js (added)
-
tags/1.4.0/languages (added)
-
tags/1.4.0/languages/widget-css-classes-es_ES.mo (added)
-
tags/1.4.0/languages/widget-css-classes-es_ES.po (added)
-
tags/1.4.0/languages/widget-css-classes-nl_NL.mo (added)
-
tags/1.4.0/languages/widget-css-classes-nl_NL.po (added)
-
tags/1.4.0/languages/widget-css-classes-pl_PL.mo (added)
-
tags/1.4.0/languages/widget-css-classes-pl_PL.po (added)
-
tags/1.4.0/languages/widget-css-classes-ru_RU.mo (added)
-
tags/1.4.0/languages/widget-css-classes-ru_RU.po (added)
-
tags/1.4.0/languages/widget-css-classes-sk_SK.mo (added)
-
tags/1.4.0/languages/widget-css-classes-sk_SK.po (added)
-
tags/1.4.0/languages/widget-css-classes-sr_RS.mo (added)
-
tags/1.4.0/languages/widget-css-classes-sr_RS.po (added)
-
tags/1.4.0/languages/widget-css-classes-sv_SE.mo (added)
-
tags/1.4.0/languages/widget-css-classes-sv_SE.po (added)
-
tags/1.4.0/languages/widget-css-classes.mo (added)
-
tags/1.4.0/languages/widget-css-classes.pot (added)
-
tags/1.4.0/license.txt (added)
-
tags/1.4.0/readme.txt (added)
-
tags/1.4.0/uninstall.php (added)
-
tags/1.4.0/widget-css-classes.php (added)
-
trunk/README.md (added)
-
trunk/css/widget-css-classes.css (modified) (1 diff)
-
trunk/includes/widget-css-classes-settings.class.php (modified) (13 diffs)
-
trunk/includes/widget-css-classes.class.php (modified) (5 diffs)
-
trunk/js/widget-css-classes.js (modified) (1 diff)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/widget-css-classes.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
widget-css-classes/trunk/css/widget-css-classes.css
r1332286 r1550765 1 .wcssc_copy span, .wcssc_remove span {2 vertical-align: middle;1 .wcssc_copy span, .wcssc_remove span, .wcssc_sort span { 2 vertical-align: text-bottom; 3 3 margin: 0; 4 4 padding: 0; 5 5 } 6 .wcssc_copy, .wcssc_remove {6 .wcssc_copy, .wcssc_remove, .wcssc_sort { 7 7 text-decoration: none; 8 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 } -
widget-css-classes/trunk/includes/widget-css-classes-settings.class.php
r1332286 r1550765 22 22 private $general_settings = array(); 23 23 24 function __construct() {24 public function __construct() { 25 25 add_action( 'admin_init', array( $this, 'load_settings' ) ); 26 26 add_action( 'admin_init', array( $this, 'register_general_settings' ) ); … … 29 29 } 30 30 31 function load_settings() {31 public function load_settings() { 32 32 $this->general_settings = get_option( $this->general_key ); 33 33 } 34 34 35 function section_general_desc() {36 } 37 38 function register_general_settings() {35 public function section_general_desc() { 36 } 37 38 public function register_general_settings() { 39 39 $this->plugin_tabs[$this->general_key] = esc_attr__( 'Widget CSS Classes Settings', 'widget-css-classes' ); 40 40 … … 50 50 } 51 51 52 function show_number_option() { ?>52 public function show_number_option() { ?> 53 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 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' ); ?> … … 56 56 } 57 57 58 function show_location_option() {58 public function show_location_option() { 59 59 ?> 60 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' ); ?> … … 63 63 } 64 64 65 function show_evenodd_option() {65 public function show_evenodd_option() { 66 66 ?> 67 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' ); ?> … … 70 70 } 71 71 72 function show_id_option() {72 public function show_id_option() { 73 73 ?> 74 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' ); ?> … … 77 77 } 78 78 79 function type_option() {79 public function type_option() { 80 80 ?> 81 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' ); ?> … … 86 86 } 87 87 88 function defined_classes_option() { 88 public function defined_classes_option() { 89 wp_enqueue_script( 'jquery-ui-sortable' ); 89 90 $presets = explode( ';', $this->general_settings['defined_classes'] ); 91 ?> 92 <div class="wcssc_sortable"> 93 <?php 90 94 if ( count( $presets ) > 1 ) { 91 95 foreach ( $presets as $key => $preset ) { 92 96 if ( $preset != '' ) { 93 97 ?> 94 <p><input type="text" name="<?php echo esc_attr( $this->general_key ).'[defined_classes]['.esc_attr( $key ).']'; ?>" value="<?php echo esc_attr( $preset ); ?>" /> 95 <a class="wcssc_remove" href="#"><span class="dashicons dashicons-dismiss"></span></a></p> 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> 96 103 <?php 97 104 } 98 105 } 99 106 ?> 100 <p class="wcssc_defined_classes"> 107 <p class="wcssc_defined_classes wcssc_sort_fixed"> 108 <a class="wcssc_sort" href="#"><span class="dashicons dashicons-sort"></span></a> 101 109 <input type="text" name="<?php echo esc_attr( $this->general_key ).'[defined_classes][]'; ?>" value="" /> 102 110 <a href="#" class="wcssc_copy" rel=".wcssc_defined_classes"><span class="dashicons dashicons-plus-alt"></span></a> … … 106 114 } else { 107 115 ?> 108 <p class="wcssc_defined_classes"><input type="text" name="<?php echo esc_attr( $this->general_key ).'[defined_classes][]'; ?>" value="<?php echo esc_attr( $this->general_settings['defined_classes'] ); ?>" /> 109 <a href="#" class="wcssc_copy" rel=".wcssc_defined_classes"><span class="dashicons dashicons-plus-alt"></span></a> 110 <a class="wcssc_remove" href="#"><span class="dashicons dashicons-dismiss"></span></a></p> 111 <?php 112 } 113 } 114 115 function register_importexport_settings() { 116 $this->plugin_tabs['importexport'] = esc_attr__( 'Import/Export', 'widget-css-classes' ); 117 118 if ( isset( $_GET['wcssc_message'] ) ) { 119 switch ( $_GET['wcssc_message'] ) { 120 case 1: 121 $wcssc_message = esc_attr__( 'Settings Imported', 'widget-css-classes' ); 122 break; 123 case 2: 124 $wcssc_message = esc_attr__( 'Invalid Settings File', 'widget-css-classes' ); 125 break; 126 case 3: 127 $wcssc_message = esc_attr__( 'No Settings File Selected', 'widget-css-classes' ); 128 break; 129 default: 130 $wcssc_message = ''; 131 break; 132 } 133 } 134 135 if ( isset( $wcssc_message ) && $wcssc_message != '' ) { 136 echo '<div class="updated"><p>'.esc_html( $wcssc_message ).'</p></div>'; 137 } 138 139 // export settings 140 if ( isset( $_GET['widget-css-classes-settings-export'] ) ) { 141 header( "Content-Disposition: attachment; filename=widget-css-classes-settings.txt" ); 142 header( 'Content-Type: text/plain; charset=utf-8' ); 143 $general = get_option( 'WCSSC_options' ); 144 145 echo "[START=WCSSC SETTINGS]\n"; 146 foreach ( $general as $id => $text ) 147 echo "$id\t".json_encode( $text )."\n"; 148 echo "[STOP=WCSSC SETTINGS]"; 149 exit; 150 } 151 152 // import settings 153 if ( isset( $_POST['widget-css-classes-settings-import'] ) ) { 154 $wcssc_message = ''; 155 if ( $_FILES['widget-css-classes-settings-import-file']['tmp_name'] ) { 156 $import = explode( "\n", file_get_contents( $_FILES['widget-css-classes-settings-import-file']['tmp_name'] ) ); 157 if ( array_shift( $import ) == "[START=WCSSC SETTINGS]" && array_pop( $import ) == "[STOP=WCSSC SETTINGS]" ) { 158 foreach ( $import as $import_option ) { 159 list( $key, $value ) = explode( "\t", $import_option ); 160 $options[$key] = json_decode( sanitize_text_field( $value ) ); 161 if ( $options['dropdown'] ) { // Update for 1.3.0 162 $options['defined_classes'] = $options['dropdown']; 163 unset( $options['dropdown'] ); 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 } 164 188 } 189 update_option( 'WCSSC_options', $options ); 190 $wcssc_message = 1; 191 } else { 192 $wcssc_message = 2; 165 193 } 166 update_option( 'WCSSC_options', $options );167 $wcssc_message = 1;168 194 } else { 169 $wcssc_message = 2; 170 } 171 } else { 172 $wcssc_message = 3; 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 ) { 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 ) { 181 206 $output = array(); 182 207 … … 199 224 } 200 225 201 function add_admin_menus() {226 public function add_admin_menus() { 202 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' ) ); 203 228 } … … 209 234 * to render the tabs. 210 235 */ 211 function plugin_options_page() {236 public function plugin_options_page() { 212 237 $tab = isset( $_GET['tab'] ) ? $_GET['tab'] : $this->general_key; 213 238 ?> … … 232 257 * plugin_options_page method. 233 258 */ 234 function plugin_options_tabs() {259 public function plugin_options_tabs() { 235 260 $current_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : $this->general_key; 236 261 … … 243 268 } 244 269 245 function importexport_fields() {270 public function importexport_fields() { 246 271 ?> 247 272 <h3><?php esc_html_e( 'Import/Export Settings', 'widget-css-classes' ); ?></h3> -
widget-css-classes/trunk/includes/widget-css-classes.class.php
r1332286 r1550765 32 32 if ( WCSSC_Loader::$settings['show_id'] == 1 || WCSSC_Loader::$settings['type'] > 0 ) { 33 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";34 $fields .= "<div class='wcssc'>\n"; 35 35 36 36 // show id field … … 84 84 } 85 85 86 //$fields .= "</div>\n";86 $fields .= "</div>\n"; 87 87 } 88 88 … … 102 102 */ 103 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(); 104 106 $instance['classes'] = $new_instance['classes']; 105 107 $instance['classes-defined'] = $new_instance['classes-defined']; … … 107 109 $instance['ids'] = $new_instance['ids']; 108 110 } 109 if ( is_array( $instance['classes-defined'] ) ) {111 if ( ! empty( $instance['classes-defined'] ) && is_array( $instance['classes-defined'] ) ) { 110 112 // Merge predefined classes with input classes 111 113 $text_classes = explode( ' ', $instance['classes'] ); … … 134 136 135 137 global $wp_registered_widgets, $widget_number; 136 138 139 if ( ! isset( $params[0] ) ) { 140 return $params; 141 } 142 137 143 $arr_registered_widgets = wp_get_sidebars_widgets(); // Get an array of ALL registered widgets 138 144 $this_id = $params[0]['id']; // Get the id for the current sidebar we're processing -
widget-css-classes/trunk/js/widget-css-classes.js
r1332286 r1550765 10 10 } ); 11 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 12 20 } ); -
widget-css-classes/trunk/readme.txt
r1535315 r1550765 9 9 Requires at least: 3.3 10 10 Tested up to: 4.7 11 Stable tag: 1. 3.011 Stable tag: 1.4.0 12 12 13 13 Add custom classes and ids plus first, last, even, odd, and numbered classes to your widgets. … … 95 95 == Changelog == 96 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 97 102 = 1.3.0 = 98 103 * Feature: Change dropdown to checkboxes for multiple class selection … … 159 164 == Upgrade Notice == 160 165 166 = 1.4 = 167 New feature, bug fix, security fix 168 161 169 = 1.2.7 = 162 170 Bug fix -
widget-css-classes/trunk/widget-css-classes.php
r1332280 r1550765 2 2 /* 3 3 Plugin Name: Widget CSS Classes 4 Version: 1. 3.04 Version: 1.4.0 5 5 Description: Add custom, first, last, even, odd, and numbered classes to your widgets. 6 6 Author: C.M. Kendrick
Note: See TracChangeset
for help on using the changeset viewer.