33 * @author Jory Hogeveen <[email protected] > 44 * @package Genesis_Widget_Column_Classes
55 * @since 0.1.0
6- * @version 1.3.0
6+ * @version 1.3.1
77 * @licence GPL-2.0+
88 * @link https://github.com/JoryHogeveen/genesis-widget-column-classes
99 *
1010 * @wordpress-plugin
1111 * Plugin Name: Genesis Widget Column Classes
1212 * Plugin URI: https://wordpress.org/plugins/genesis-widget-column-classes/
1313 * Description: Add Genesis (old Bootstrap) column classes to widgets
14- * Version: 1.3
14+ * Version: 1.3.1
1515 * Author: Jory Hogeveen
1616 * Author URI: http://www.keraweb.nl
1717 * Text Domain: genesis-widget-column-classes
5050 * @author Jory Hogeveen <[email protected] > 5151 * @package Genesis_Widget_Column_Classes
5252 * @since 0.1.0
53- * @version 1.3.0
53+ * @version 1.3.1
5454 */
5555final class WCC_Genesis_Widget_Column_Classes
5656{
@@ -84,7 +84,7 @@ final class WCC_Genesis_Widget_Column_Classes
8484 * @since 1.1.0
8585 * @var string
8686 */
87- private $ version = '1.3.0 ' ;
87+ private $ version = '1.3.1 ' ;
8888
8989 /**
9090 * User ignore nag key.
@@ -218,6 +218,9 @@ public function init() {
218218 add_filter ( 'widget_form_callback ' , array ( $ this , 'filter_widget_form_extend ' ), 1 , 2 );
219219 add_filter ( 'widget_update_callback ' , array ( $ this , 'filter_widget_update_callback ' ), 10 , 2 );
220220 add_filter ( 'dynamic_sidebar_params ' , array ( $ this , 'filter_dynamic_sidebar_params ' ), 99999 ); // Make sure to be the last one.
221+
222+ add_action ( 'admin_head ' , array ( $ this , 'print_inline_styles ' ) );
223+ add_action ( 'customize_controls_print_styles ' , array ( $ this , 'print_inline_styles ' ) );
221224 }
222225
223226 /**
@@ -262,6 +265,7 @@ public function action_ignore_genesis_notice() {
262265 * @since 0.1.0
263266 * @since 1.3.0 Multi select support.
264267 * @access public
268+ *
265269 * @param array $instance
266270 * @param \WP_Widget $widget
267271 * @return array $instance
@@ -287,18 +291,7 @@ public function filter_widget_form_extend( $instance, $widget ) {
287291 $ field_name = $ widget ->get_field_name ( 'column-classes ' );
288292 $ field_id = $ widget ->get_field_id ( 'column-classes ' );
289293
290- $ background = '#f5f5f5 ' ;
291- $ border = '#eee ' ;
292- $ background_select = '#fff ' ;
293- $ border_select = '#ccc ' ;
294- if ( $ this ->is_using_dark_mode () ) {
295- $ background = '#191f25 ' ;
296- $ border = '#000 ' ;
297- $ background_select = '#000 ' ;
298- $ border_select = '#32373c ' ;
299- }
300-
301- $ row = '<p style="border: 1px solid ' . $ border . '; padding: 5px 10px; background-color: ' . $ background . ';"> ' ;
294+ $ row = '<p class="genesis-widget-column-classes"> ' ;
302295 $ row .= '<label for=" ' . $ widget ->get_field_id ( 'column-classes ' ) . '"> ' . __ ( 'Width ' , self ::$ _domain ) . ': </label> ' ;
303296
304297 $ row_column = '' ;
@@ -329,43 +322,6 @@ public function filter_widget_form_extend( $instance, $widget ) {
329322 $ row .= '<span id=" ' . $ field_id . '" class="multiselect"><span> ' ;
330323 $ row .= $ row_column ;
331324 $ row .= '</span></span> ' ;
332- ?>
333- <style>
334- #<?php echo $ field_id ; ?> .multiselect {
335- position: relative;
336- height: 26px;
337- width: 130px;
338- display: inline-block;
339- vertical-align: middle;
340- overflow: visible;
341- }
342- #<?php echo $ field_id ; ?> .multiselect label {
343- display: block;
344- line-height: 22px;
345- padding-right: 1em;
346- white-space: nowrap;
347- }
348- #<?php echo $ field_id ; ?> .multiselect span {
349- position: absolute;
350- border: 1px solid <?php echo $ border_select ; ?> ;
351- background: <?php echo $ background_select ; ?> ;
352- height: 22px;
353- max-height: 22px;
354- overflow: hidden;
355- overflow-y: scroll;
356- padding: 1px 3px;
357- width: 120px;
358- display: inline-block;
359- transition: max-height .2s;
360- }
361- #<?php echo $ field_id ; ?> .multiselect:hover span {
362- height: auto;
363- max-height: 200px;
364- width: auto;
365- box-shadow: 0 1px 3px rgba(0,0,0,0.1);
366- }
367- </style>
368- <?php
369325 } else {
370326 $ row .= '<select name=" ' . $ field_name . '" id=" ' . $ field_id . '"> ' ;
371327 $ row .= '<option value="">- ' . __ ( 'none ' , self ::$ _domain ) . ' -</option> ' ;
@@ -388,6 +344,7 @@ public function filter_widget_form_extend( $instance, $widget ) {
388344 * @since 1.2.2 Do not save empty data.
389345 * @since 1.3.0 Multi select support.
390346 * @access public
347+ *
391348 * @param array $instance
392349 * @param array $new_instance
393350 * @return array $instance
@@ -418,6 +375,7 @@ public function filter_widget_update_callback( $instance, $new_instance ) {
418375 *
419376 * @since 0.1.0
420377 * @access public
378+ *
421379 * @param array $params
422380 * @return array $params
423381 */
@@ -478,6 +436,8 @@ public function filter_dynamic_sidebar_params( $params ) {
478436 *
479437 * @since 1.2.2
480438 * @since 1.2.3 Refactor: Remove first $widget_instance parameter.
439+ * @access public
440+ *
481441 * @param array $params The widget (sidebar) params.
482442 * @param array $classes (optional) Append to existing classes.
483443 * @return array
@@ -513,13 +473,13 @@ public function add_widget_classes( $params, $classes = array() ) {
513473 * Find an attribute and add the data as a HTML string.
514474 *
515475 * @since 1.2.0
476+ * @access public
516477 *
517478 * @param string $str The HTML string.
518479 * @param string $attr The attribute to find.
519480 * @param string $content_extra The content that needs to be appended.
520481 * @param bool $unique Do we need to filter for unique values?
521- *
522- * @return string
482+ * @return string
523483 */
524484 public function append_to_attribute ( $ str , $ attr , $ content_extra , $ unique = false ) {
525485
@@ -589,6 +549,8 @@ public function append_to_attribute( $str, $attr, $content_extra, $unique = fals
589549 * Get the classes from a widget instance.
590550 *
591551 * @since 1.2.3
552+ * @access public
553+ *
592554 * @param array $widget_instance The widget instance.
593555 * @param array $classes (optional) Extra classes.
594556 * @return array
@@ -609,6 +571,7 @@ public function get_widget_classes( $widget_instance, $classes = array() ) {
609571 * Get the available column classes.
610572 *
611573 * @since 1.2.2
574+ * @access public
612575 * @return array
613576 */
614577 public function get_column_classes () {
@@ -631,11 +594,84 @@ public function get_column_classes() {
631594 return $ this ->column_classes ;
632595 }
633596
597+ /**
598+ * Add elements to the <head> of admin pages.
599+ *
600+ * @since 1.3.1
601+ * @access public
602+ * @return void
603+ */
604+ public function print_inline_styles () {
605+
606+ if ( doing_action ( 'admin_head ' ) ) {
607+ $ screen = get_current_screen ();
608+ if ( ! $ screen || 'widgets ' !== $ screen ->base ) {
609+ return ;
610+ }
611+ }
612+
613+ $ background = '#f5f5f5 ' ;
614+ $ border = '#eee ' ;
615+ $ background_select = '#fff ' ;
616+ $ border_select = '#ccc ' ;
617+ if ( $ this ->is_using_dark_mode () ) {
618+ $ background = '#191f25 ' ;
619+ $ border = '#000 ' ;
620+ $ background_select = '#000 ' ;
621+ $ border_select = '#32373c ' ;
622+ }
623+
624+ ?>
625+ <style type="text/css" id="genesis-widget-column-classes-css">
626+ .widget .genesis-widget-column-classes {
627+ border: 1px solid <?php echo $ border ; ?> ;
628+ padding: 5px 10px;
629+ background-color: <?php echo $ background ; ?> ;
630+ }
631+ .widget .genesis-widget-column-classes .multiselect {
632+ position: relative;
633+ height: 26px;
634+ width: 130px;
635+ display: inline-block;
636+ vertical-align: middle;
637+ overflow: visible;
638+ }
639+ .widget .genesis-widget-column-classes .multiselect label {
640+ display: block;
641+ line-height: 22px;
642+ padding-right: 1em;
643+ white-space: nowrap;
644+ }
645+ .widget .genesis-widget-column-classes .multiselect span {
646+ position: absolute;
647+ border: 1px solid <?php echo $ border_select ; ?> ;
648+ background: <?php echo $ background_select ; ?> ;
649+ height: 22px;
650+ max-height: 22px;
651+ overflow: hidden;
652+ overflow-y: scroll;
653+ padding: 1px 3px;
654+ width: 120px;
655+ display: inline-block;
656+ transition: max-height .2s;
657+ }
658+ .widget .genesis-widget-column-classes .multiselect:hover span {
659+ height: auto;
660+ max-height: 200px;
661+ width: auto;
662+ box-shadow: 0 1px 3px rgba(0,0,0,0.1);
663+ }
664+ </style>
665+ <?php
666+ }
667+
634668 /**
635669 * Show row meta on the plugin screen.
636670 *
637671 * @since 1.2.4
638672 * @see \WP_Plugins_List_Table::single_row()
673+ * @access public
674+ *
639675 * @param array[] $links The existing links.
640676 * @param string $file The plugin file.
641677 * @return array
@@ -656,6 +692,7 @@ public function action_plugin_row_meta( $links, $file ) {
656692 * Plugin links.
657693 *
658694 * @since 1.2.4
695+ * @access public
659696 * @return array[]
660697 */
661698 public function get_links () {
0 commit comments