Changeset 2080093
- Timestamp:
- 05/03/2019 06:14:25 PM (7 years ago)
- Location:
- widget-display-conditions/tags/0.2.3
- Files:
-
- 1 added
- 1 deleted
- 9 edited
- 1 copied
-
. (copied) (copied from widget-display-conditions/trunk)
-
assets/css/ui.css (modified) (1 diff)
-
assets/css/ui.min.css (modified) (1 diff)
-
includes/conditions-api.php (modified) (2 diffs)
-
includes/fields.php (modified) (9 diffs)
-
includes/ui.php (modified) (12 diffs)
-
includes/update-tasks.php (added)
-
includes/updater-tasks.php (deleted)
-
includes/widgets.php (modified) (4 diffs)
-
languages/widget-display-conditions.pot (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
-
widget-display-conditions.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
widget-display-conditions/tags/0.2.3/assets/css/ui.css
r2078733 r2080093 13 13 bottom: 0; 14 14 left: 0; 15 z-index: 159900;15 z-index: 500100; 16 16 text-align: center; 17 17 white-space: nowrap; -
widget-display-conditions/tags/0.2.3/assets/css/ui.min.css
r2078733 r2080093 1 html.with-featherlight{overflow:hidden}.wdc-modal{display:none;position:fixed;top:0;right:0;bottom:0;left:0;z-index: 159900;text-align:center;white-space:nowrap;background:rgba(0,0,0,.7)}.wdc-modal:before{content:'';display:inline-block;height:100%;vertical-align:middle}.wdc-modal *{-webkit-box-sizing:border-box;box-sizing:border-box}.wdc-modal iframe{border:none}.wdc-modal h1{margin:-15px -15px 15px;padding:0 63px 0 15px;font-size:20px;line-height:50px;border-bottom:1px solid #ddd;background:#fafafa}.wdc-modal p.submit{margin:0;padding:1px 0}.wdc-modal-content{position:relative;text-align:left;vertical-align:middle;display:inline-block;overflow:auto;padding:15px 15px 0;border-bottom:15px solid transparent;margin-left:5%;margin-right:5%;max-height:95%;background:#fff;-webkit-box-shadow:0 5px 15px rgba(0,0,0,.7);box-shadow:0 5px 15px rgba(0,0,0,.7);cursor:auto;white-space:normal;max-width:800px}@media screen and (min-width:961px){.wdc-modal-content{width:800px;max-width:none}}.wdc-modal-iframe .wdc-modal-content{border-bottom:0;padding:0;-webkit-overflow-scrolling:touch}.wdc-modal-inner{display:block}link.wdc-modal-inner,script.wdc-modal-inner,style.wdc-modal-inner{display:none}.wdc-modal-close-icon{position:absolute;z-index:9999;top:0;right:0;line-height:48px;width:48px;text-align:center;padding:0;cursor:pointer;outline:0;border:1px solid transparent;background:0 0;color:#666}.wdc-modal-close-icon::-moz-focus-inner{border:0;padding:0}.wdc-modal-close-icon:before{-webkit-transition:color .1s ease-in-out,background .1s ease-in-out;transition:color .1s ease-in-out,background .1s ease-in-out;position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);content:"\f158";font:normal 20px/1 dashicons;speak:none;vertical-align:middle;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.wdc-modal-close-icon:hover{color:#00a0d2}.wdc-modal-close-icon:focus{color:#00a0d2;border-color:#5b9dd9;-webkit-box-shadow:0 0 3px rgba(0,115,170,.8);box-shadow:0 0 3px rgba(0,115,170,.8);outline:2px solid transparent;outline-offset:-2px}.wdc-modal-image{width:100%}@media print{html.with-featherlight>*>:not(.wdc-modal){display:none}}.wdc-open-ui-wrap{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.wdc-open-ui-wrap .spinner{float:none;margin:0}.wdc-open-ui-wrap .spinner:first-child{margin-right:10px}.wdc-open-ui-wrap .spinner:last-child{margin-left:10px}.wdc-open-ui-wrap .spinner.wdc-is-active{visibility:visible}.wdc-open-ui-wrap .spinner:not(.wdc-is-active){visibility:hidden!important}.wdc-ui.wdc-has-conditions .wdc-hide-if-conditions{display:none}.wdc-ui:not(.wdc-has-conditions) .wdc-show-if-conditions{display:none}.wdc-ui h4{margin:.35em 0;line-height:1}.wdc-ui .notice{margin:1em 0}.wdc-ui .notice .spinner{margin:0 0 0 1em}.wdc-ui .button-link{color:inherit}.wdc-ui .button-link.dashicons-before{text-decoration:none}.wdc-ui p{margin:9px 0}.wdc-ui p.submit{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:end;-ms-flex-pack:end;justify-content:flex-end}.wdc-ui p.submit .spinner{float:none;margin:0}.wdc-ui p.submit .spinner:first-child{margin-right:10px}.wdc-ui p.submit .spinner:last-child{margin-left:10px}table.wdc-conditions{margin:0;padding:0;border:none;border-collapse:collapse;width:100%}tr.wdc-condition>td{text-align:center;vertical-align:middle;padding:4px}tr.wdc-condition>td:first-child{padding-left:0}tr.wdc-condition>td:last-child{padding-right:0}tr.wdc-condition>td:nth-child(1){width:35%}tr.wdc-condition>td:nth-child(2){width:20%}tr.wdc-condition>td:nth-child(4){width:1%}tr.wdc-condition>td:nth-child(5){width:1%}tr.wdc-condition>td select{margin:0;width:100%}1 html.with-featherlight{overflow:hidden}.wdc-modal{display:none;position:fixed;top:0;right:0;bottom:0;left:0;z-index:500100;text-align:center;white-space:nowrap;background:rgba(0,0,0,.7)}.wdc-modal:before{content:'';display:inline-block;height:100%;vertical-align:middle}.wdc-modal *{-webkit-box-sizing:border-box;box-sizing:border-box}.wdc-modal iframe{border:none}.wdc-modal h1{margin:-15px -15px 15px;padding:0 63px 0 15px;font-size:20px;line-height:50px;border-bottom:1px solid #ddd;background:#fafafa}.wdc-modal p.submit{margin:0;padding:1px 0}.wdc-modal-content{position:relative;text-align:left;vertical-align:middle;display:inline-block;overflow:auto;padding:15px 15px 0;border-bottom:15px solid transparent;margin-left:5%;margin-right:5%;max-height:95%;background:#fff;-webkit-box-shadow:0 5px 15px rgba(0,0,0,.7);box-shadow:0 5px 15px rgba(0,0,0,.7);cursor:auto;white-space:normal;max-width:800px}@media screen and (min-width:961px){.wdc-modal-content{width:800px;max-width:none}}.wdc-modal-iframe .wdc-modal-content{border-bottom:0;padding:0;-webkit-overflow-scrolling:touch}.wdc-modal-inner{display:block}link.wdc-modal-inner,script.wdc-modal-inner,style.wdc-modal-inner{display:none}.wdc-modal-close-icon{position:absolute;z-index:9999;top:0;right:0;line-height:48px;width:48px;text-align:center;padding:0;cursor:pointer;outline:0;border:1px solid transparent;background:0 0;color:#666}.wdc-modal-close-icon::-moz-focus-inner{border:0;padding:0}.wdc-modal-close-icon:before{-webkit-transition:color .1s ease-in-out,background .1s ease-in-out;transition:color .1s ease-in-out,background .1s ease-in-out;position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);content:"\f158";font:normal 20px/1 dashicons;speak:none;vertical-align:middle;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.wdc-modal-close-icon:hover{color:#00a0d2}.wdc-modal-close-icon:focus{color:#00a0d2;border-color:#5b9dd9;-webkit-box-shadow:0 0 3px rgba(0,115,170,.8);box-shadow:0 0 3px rgba(0,115,170,.8);outline:2px solid transparent;outline-offset:-2px}.wdc-modal-image{width:100%}@media print{html.with-featherlight>*>:not(.wdc-modal){display:none}}.wdc-open-ui-wrap{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.wdc-open-ui-wrap .spinner{float:none;margin:0}.wdc-open-ui-wrap .spinner:first-child{margin-right:10px}.wdc-open-ui-wrap .spinner:last-child{margin-left:10px}.wdc-open-ui-wrap .spinner.wdc-is-active{visibility:visible}.wdc-open-ui-wrap .spinner:not(.wdc-is-active){visibility:hidden!important}.wdc-ui.wdc-has-conditions .wdc-hide-if-conditions{display:none}.wdc-ui:not(.wdc-has-conditions) .wdc-show-if-conditions{display:none}.wdc-ui h4{margin:.35em 0;line-height:1}.wdc-ui .notice{margin:1em 0}.wdc-ui .notice .spinner{margin:0 0 0 1em}.wdc-ui .button-link{color:inherit}.wdc-ui .button-link.dashicons-before{text-decoration:none}.wdc-ui p{margin:9px 0}.wdc-ui p.submit{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:end;-ms-flex-pack:end;justify-content:flex-end}.wdc-ui p.submit .spinner{float:none;margin:0}.wdc-ui p.submit .spinner:first-child{margin-right:10px}.wdc-ui p.submit .spinner:last-child{margin-left:10px}table.wdc-conditions{margin:0;padding:0;border:none;border-collapse:collapse;width:100%}tr.wdc-condition>td{text-align:center;vertical-align:middle;padding:4px}tr.wdc-condition>td:first-child{padding-left:0}tr.wdc-condition>td:last-child{padding-right:0}tr.wdc-condition>td:nth-child(1){width:35%}tr.wdc-condition>td:nth-child(2){width:20%}tr.wdc-condition>td:nth-child(4){width:1%}tr.wdc-condition>td:nth-child(5){width:1%}tr.wdc-condition>td select{margin:0;width:100%} -
widget-display-conditions/tags/0.2.3/includes/conditions-api.php
r2078733 r2080093 6 6 /** 7 7 * Do conditions 8 * 9 * Returns true/false if conditions are met/unmet. 10 * Returns null when no conditions are applied. 8 11 * 9 12 * @param array $conditions … … 34 37 * 35 38 * @param string $condition 36 * @param string $operator _id39 * @param string $operator 37 40 * @param mixed $value 38 41 * -
widget-display-conditions/tags/0.2.3/includes/fields.php
r2078742 r2080093 55 55 * @param string $condition_id 56 56 * 57 * @return mixed57 * @return array|null 58 58 */ 59 59 function wdc_get_condition_operator_field_items( $condition_id ) 60 60 { 61 // Get condition 62 61 63 $condition = wdc_get_condition( $condition_id ); 62 64 63 65 if ( ! $condition ) return null; 64 66 67 // Get condition operators 68 65 69 $operators = wdc_get_operator_objects( $condition->operators ); 66 70 67 71 uasort( $operators, 'wdc_sort_order' ); 72 73 // Get items 68 74 69 75 $items = array(); … … 81 87 $items = apply_filters( "wdc/condition_operator_field_items" , $items, $condition ); 82 88 89 // Return 90 83 91 return $items; 84 92 } … … 93 101 function wdc_get_condition_value_field_items( $condition_id ) 94 102 { 103 // Get condition 104 95 105 $condition = wdc_get_condition( $condition_id ); 96 106 97 107 if ( ! $condition ) return null; 108 109 // Get items 98 110 99 111 $items = array(); … … 101 113 $items = apply_filters( "wdc/condition_value_field_items" , $items, $condition ); 102 114 115 // Return 116 103 117 return $items; 104 118 } … … 120 134 foreach ( $post_types as $post_type ) 121 135 { 136 // Get post type object 137 122 138 $post_type = get_post_type_object( $post_type ); 123 139 124 140 if ( ! $post_type ) continue; 141 142 // Get posts 125 143 126 144 if ( $post_type->hierarchical ) … … 151 169 if ( ! $posts ) continue; 152 170 171 // Get items 172 153 173 $group = array 154 174 ( … … 206 226 foreach ( $taxonomies as $taxonomy ) 207 227 { 228 // Get taxonomy object 229 208 230 $taxonomy = get_taxonomy( $taxonomy ); 209 231 210 232 if ( ! $taxonomy ) continue; 233 234 // Get terms 211 235 212 236 $terms = get_terms( array … … 221 245 if ( ! $terms ) continue; 222 246 247 // Get items 248 223 249 $group = array 224 250 ( … … 300 326 301 327 /** 302 * Prepare field items json328 * Prepare field items JSON 303 329 * 304 330 * Make sure array keys are nummeric indexes. -
widget-display-conditions/tags/0.2.3/includes/ui.php
r2078733 r2080093 8 8 /** 9 9 * Init 10 *11 * @return mixed12 10 */ 13 11 public static function init() … … 16 14 add_action( 'admin_enqueue_scripts', array( __CLASS__, 'scripts' ) ); 17 15 add_action( 'admin_footer' , array( __CLASS__, 'template_scripts' ) ); 18 19 16 add_action( 'wp_ajax_wdc_ui_get_condition_field_items', array( __CLASS__, 'get_condition_field_items_ajax' ) ); 20 17 add_action( 'wp_ajax_wdc_ui_preload', array( __CLASS__, 'preload' ) ); 21 18 add_action( 'wp_ajax_wdc_ui_update' , array( __CLASS__, 'update' ) ); 19 20 // Customizer 21 add_action( 'customize_preview_init' , array( __CLASS__, 'scripts' ) ); 22 add_action( 'customize_controls_print_scripts', array( __CLASS__, 'template_scripts' ) ); 22 23 } 23 24 … … 31 32 public static function get_condition_field_items( $condition_id ) 32 33 { 34 // Get condition 35 33 36 $condition = wdc_get_condition( $condition_id ); 34 37 35 38 if ( ! $condition ) return null; 39 40 // Get items 36 41 37 42 $items = array … … 41 46 ); 42 47 48 // Sanitize for JSON 43 49 $items['operator'] = wdc_prepare_field_items_json( $items['operator'] ); 44 50 $items['value'] = wdc_prepare_field_items_json( $items['value'] ); 45 51 52 // Return 53 46 54 return $items; 47 55 } … … 54 62 public static function in_widget_form( $widget ) 55 63 { 64 if ( ! self::is_ui_page() ) return; 65 56 66 // Output button to open UI 57 67 $button = sprintf( '<button class="button wdc-open-ui" type="button" data-widget="%s" data-noncename="%s" data-nonce="%s">%s</button>', … … 80 90 if ( ! self::doing_ajax() ) return; 81 91 92 // Get widget conditions 93 82 94 $conditions = wdc_get_widget_conditions( $_POST['widget'] ); 95 96 // Get conditions fields items 83 97 84 98 $fields = array(); … … 92 106 $condition_id = $condition['param']; 93 107 108 // Check if already added 94 109 if ( ! isset( $fields[ $condition_id ] ) ) 95 110 { … … 100 115 } 101 116 117 // Response 118 102 119 wp_send_json( array 103 120 ( … … 114 131 if ( ! self::doing_ajax() ) return; 115 132 133 // Update widget conditions 134 116 135 $conditions = isset( $_POST['conditions'] ) ? $_POST['conditions'] : array(); 117 136 118 137 $result = wdc_set_widget_conditions( $_POST['widget'], $conditions ); 119 138 139 // Reponse 140 120 141 wp_send_json( $result ); 121 142 } … … 126 147 public static function scripts() 127 148 { 128 if ( 'widgets.php' != $GLOBALS['pagenow']) return;149 if ( ! self::is_ui_page() ) return; 129 150 130 151 $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; … … 153 174 public static function template_scripts() 154 175 { 155 if ( 'widgets.php' != $GLOBALS['pagenow']) return;176 if ( ! self::is_ui_page() ) return; 156 177 157 178 ?> … … 241 262 242 263 /** 264 * Is UI page 265 * 266 * @return bool 267 */ 268 public static function is_ui_page() 269 { 270 return in_array( $GLOBALS['pagenow'], array( 'widgets.php', 'customize.php' ) ); 271 } 272 273 /** 243 274 * Doing ajax 244 275 * -
widget-display-conditions/tags/0.2.3/includes/widgets.php
r2078733 r2080093 7 7 * Get widget regex 8 8 * 9 * Regular Expression to get widget base id and number from widget id. 10 * 9 11 * @return string 10 12 */ … … 133 135 /** 134 136 * Has widgets conditions 137 * 138 * Check if there are widgets with conditions. 135 139 * 136 140 * @return bool … … 160 164 /** 161 165 * Delete widgets conditions 166 * 167 * Delete all conditions from all widgets. 162 168 */ 163 169 function wdc_delete_widgets_conditions() … … 199 205 /** 200 206 * Sidebar widgets 207 * 208 * Exclude widgets which display conditions are not met. 201 209 * 202 210 * @param array $sidebars_widgets -
widget-display-conditions/tags/0.2.3/languages/widget-display-conditions.pot
r2078733 r2080093 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Widget Display Conditions 0.2. 1\n"5 "Project-Id-Version: Widget Display Conditions 0.2.3\n" 6 6 "Report-Msgid-Bugs-To: [email protected]\n" 7 "POT-Creation-Date: 2019-05-0 1 18:14:08+00:00\n"7 "POT-Creation-Date: 2019-05-03 17:53:34+00:00\n" 8 8 "MIME-Version: 1.0\n" 9 9 "Content-Type: text/plain; charset=utf-8\n" … … 156 156 msgstr "" 157 157 158 #: includes/ui.php: 58158 #: includes/ui.php:61 159 159 msgid "Display conditions" 160 160 msgstr "" 161 161 162 #: includes/ui.php:1 45162 #: includes/ui.php:159 163 163 msgid "Confirm unsaved changes." 164 164 msgstr "" … … 168 168 msgstr "" 169 169 170 #: includes/ui.php:1 76170 #: includes/ui.php:190 171 171 msgid "Show widget if" 172 172 msgstr "" 173 173 174 #: includes/ui.php:1 81174 #: includes/ui.php:195 175 175 msgid "Add group" 176 176 msgstr "" 177 177 178 #: includes/ui.php: 186178 #: includes/ui.php:200 179 179 msgid "Saved" 180 180 msgstr "" 181 181 182 #: includes/ui.php: 186182 #: includes/ui.php:200 183 183 msgid "Save" 184 184 msgstr "" 185 185 186 #: includes/ui.php:2 01186 #: includes/ui.php:215 187 187 msgid "or" 188 188 msgstr "" 189 189 190 #: includes/ui.php:2 26190 #: includes/ui.php:240 191 191 msgid "and" 192 192 msgstr "" 193 193 194 #: includes/ui.php:2 31194 #: includes/ui.php:245 195 195 msgid "remove" 196 196 msgstr "" -
widget-display-conditions/tags/0.2.3/readme.txt
r2078742 r2080093 4 4 Requires at least: 4.0.0 5 5 Tested up to: 5.1 6 Stable tag: 0.2. 26 Stable tag: 0.2.3 7 7 Requires PHP: 5.6.27 8 8 License: GPLv2 or later … … 51 51 == Changelog == 52 52 53 = 0.2.3 = 54 Release date: May 3th, 2019 55 * Fix - UI: Not showing on 'customize' screen. 56 53 57 = 0.2.2 = 54 58 Release date: May 1st, 2019 55 59 56 * Fix - UI: field selected value was not set correctly.60 * Fix - UI: Field selected value was not set correctly. 57 61 58 62 = 0.2.1 = -
widget-display-conditions/tags/0.2.3/widget-display-conditions.php
r2078742 r2080093 4 4 Plugin URI: https://wordpress.org/plugins/widget-display-conditions/ 5 5 Description: Control on which page you want a particular widget to be displayed. 6 Version: 0.2. 26 Version: 0.2.3 7 7 Author: Maarten Menten 8 8 Author URI: https://profiles.wordpress.org/maartenm/ … … 15 15 defined( 'WDC_PLUGIN_FILE' ) or define( 'WDC_PLUGIN_FILE', __FILE__ ); 16 16 defined( 'WDC_ABSPATH' ) or define( 'WDC_ABSPATH', dirname( WDC_PLUGIN_FILE ) . '/' ); 17 defined( 'WDC_VERSION' ) or define( 'WDC_VERSION', '0.2. 2' );17 defined( 'WDC_VERSION' ) or define( 'WDC_VERSION', '0.2.3' ); 18 18 defined( 'WDC_NONCE_NAME' ) or define( 'WDC_NONCE_NAME', 'wdc_nonce' ); 19 19 defined( 'WDC_MAX_FIELD_ITEMS' ) or define( 'WDC_MAX_FIELD_ITEMS', 9999 ); … … 30 30 { 31 31 include_once WDC_ABSPATH . 'includes/updater.php'; 32 include_once WDC_ABSPATH . 'includes/update r-tasks.php';32 include_once WDC_ABSPATH . 'includes/update-tasks.php'; 33 33 include_once WDC_ABSPATH . 'includes/fields.php'; 34 34 include_once WDC_ABSPATH . 'includes/ui.php';
Note: See TracChangeset
for help on using the changeset viewer.