bulk-edit.php
3 years ago
col-sidebars.php
3 years ago
import.php
3 years ago
metabox.php
3 years ago
quick-edit.php
9 years ago
widgets-delete.php
3 years ago
widgets-editor.php
3 years ago
widgets-export.php
3 years ago
widgets-location.php
3 years ago
widgets.php
3 years ago
widgets-location.php
289 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Contents of the Location popup in the widgets screen. |
| 4 | * User can define default locations where the custom sidebar will be used. |
| 5 | * |
| 6 | * This file is included in widgets.php. |
| 7 | */ |
| 8 | |
| 9 | $sidebars = CustomSidebars::get_sidebars( 'theme' ); |
| 10 | |
| 11 | /** |
| 12 | * Output the input fields to configure replacements for a single sidebar. |
| 13 | * |
| 14 | * @since 2.0 |
| 15 | * @param array $sidebar Details provided by CustomSidebars::get_sidebar(). |
| 16 | * @param string $prefix Category specific prefix used for input field ID/Name. |
| 17 | * @param string $cat_name Used in label: "Replace sidebar for <cat_name>". |
| 18 | * @param string $class Optinal classname added to the wrapper element. |
| 19 | */ |
| 20 | if ( ! function_exists( '_show_replaceable' ) ) { |
| 21 | function _show_replaceable( $sidebar, $prefix, $cat_name, $class = '' ) { |
| 22 | $base_id = 'cs-' . $prefix; |
| 23 | $inp_id = $base_id . '-' . $sidebar['id']; |
| 24 | $inp_name = '___cs___' . $prefix . '___' . $sidebar['id']; |
| 25 | $sb_id = $sidebar['id']; |
| 26 | $class = (empty( $class ) ? '' : ' ' . $class); |
| 27 | ?> |
| 28 | <div |
| 29 | class="cs-replaceable <?php echo esc_attr( $sb_id . $class ); ?>" |
| 30 | data-lbl-used="<?php esc_html_e( 'Replaced by another sidebar:', 'custom-sidebars' ); ?>" |
| 31 | > |
| 32 | <label for="<?php echo esc_attr( $inp_id ); ?>"> |
| 33 | <input type="checkbox" |
| 34 | id="<?php echo esc_attr( $inp_id ); ?>" |
| 35 | class="detail-toggle" |
| 36 | /> |
| 37 | <?php printf( |
| 38 | __( 'As <strong>%1$s</strong> for selected %2$s', 'custom-sidebars' ), |
| 39 | esc_attr($sidebar['name']), |
| 40 | esc_attr($cat_name) |
| 41 | ); ?> |
| 42 | </label> |
| 43 | <div class="details"> |
| 44 | <select |
| 45 | data-id="<?php echo esc_attr( $prefix ); ?>" |
| 46 | class="cs-datalist <?php echo esc_attr( $base_id ); ?>" |
| 47 | name="<?php echo esc_attr( $inp_name ); ?>[]" |
| 48 | multiple="multiple" |
| 49 | placeholder="<?php echo esc_attr( |
| 50 | sprintf( |
| 51 | __( 'Click here to pick available %1$s', 'custom-sidebars' ), |
| 52 | $cat_name |
| 53 | ) |
| 54 | ); ?>" |
| 55 | > |
| 56 | </select> |
| 57 | </div> |
| 58 | </div> |
| 59 | <?php |
| 60 | } |
| 61 | } |
| 62 | ?> |
| 63 | <form class="frm-location wpmui-form"> |
| 64 | <input type="hidden" name="do" value="set-location" /> |
| 65 | <input type="hidden" name="sb" class="sb-id" value="" /> |
| 66 | |
| 67 | <div class="cs-title"> |
| 68 | <h3 class="no-pad-top"> |
| 69 | <span class="sb-name">...</span> |
| 70 | </h3> |
| 71 | </div> |
| 72 | <p class="message unique-post"> |
| 73 | <i class="dashicons dashicons-info light"></i> |
| 74 | <?php |
| 75 | printf( |
| 76 | __( |
| 77 | 'To attach this sidebar to a unique Post or Page please visit ' . |
| 78 | 'that <a href="%1$s">Post</a> or <a href="%2$s">Page</a> & set it ' . |
| 79 | 'up via the sidebars metabox.', 'custom-sidebars' |
| 80 | ), |
| 81 | admin_url( 'edit.php' ), |
| 82 | admin_url( 'edit.php?post_type=page' ) |
| 83 | ); |
| 84 | ?> |
| 85 | </p> |
| 86 | |
| 87 | <div class="hidden"> |
| 88 | <p class="message no-sidebars"><?php esc_html_e( 'There are no replaceable sidebars. Please allow at least one as replaceable.', 'custom-sidebars' ); ?></p> |
| 89 | </div> |
| 90 | <?php |
| 91 | /** |
| 92 | * ========================================================================= |
| 93 | * Box 1: SINGLE entries (single pages, categories) |
| 94 | */ |
| 95 | ?> |
| 96 | <div class="wpmui-box"> |
| 97 | <h3> |
| 98 | <a href="#" class="toggle" title="<?php esc_html_e( 'Click to toggle', 'custom-sidebars' ); ?>"><br></a> |
| 99 | <span><?php esc_html_e( 'For all Single Entries matching selected criteria', 'custom-sidebars' ); ?></span> |
| 100 | </h3> |
| 101 | <div class="inside"> |
| 102 | <p><?php esc_html_e( 'These replacements will be applied to every single post that matches a certain post type or category.', 'custom-sidebars' ); ?> |
| 103 | |
| 104 | <div class="cs-half"> |
| 105 | <?php |
| 106 | /** |
| 107 | * ========== SINGLE -- Categories ========== * |
| 108 | */ |
| 109 | foreach ( $sidebars as $sb_id => $details ) { |
| 110 | $cat_name = __( 'categories', 'custom-sidebars' ); |
| 111 | _show_replaceable( $details, 'cat', $cat_name ); |
| 112 | } |
| 113 | ?> |
| 114 | </div> |
| 115 | |
| 116 | <div class="cs-half"> |
| 117 | <?php |
| 118 | /** |
| 119 | * ========== SINGLE -- Post-Type ========== * |
| 120 | */ |
| 121 | foreach ( $sidebars as $sb_id => $details ) { |
| 122 | $cat_name = __( 'Post Types', 'custom-sidebars' ); |
| 123 | _show_replaceable( $details, 'pt', $cat_name ); |
| 124 | } |
| 125 | ?> |
| 126 | </div> |
| 127 | <?php |
| 128 | /** |
| 129 | * Custom Taxonomies |
| 130 | */ |
| 131 | $taxonomies = CustomSidebarsEditor::get_custom_taxonomies( 'allowed' ); |
| 132 | foreach ( $taxonomies as $taxonomy_slug => $taxonomy ) { |
| 133 | echo '<div class="cs-half cf-custom-taxonomies">'; |
| 134 | foreach ( $sidebars as $sb_id => $details ) { |
| 135 | _show_replaceable( $details, $taxonomy_slug, $taxonomy->label ); |
| 136 | } |
| 137 | echo '</div>'; |
| 138 | } |
| 139 | ?> |
| 140 | </div> |
| 141 | </div> |
| 142 | <?php |
| 143 | /** |
| 144 | * ========================================================================= |
| 145 | * Box 2: ARCHIVE pages |
| 146 | */ |
| 147 | ?> |
| 148 | <div class="wpmui-box closed"> |
| 149 | <h3> |
| 150 | <a href="#" class="toggle" title="<?php esc_html_e( 'Click to toggle', 'custom-sidebars' );?>"><br></a> |
| 151 | <span><?php esc_html_e( 'For Archives', 'custom-sidebars' ); ?></span> |
| 152 | </h3> |
| 153 | <div class="inside"> |
| 154 | <p><?php esc_html_e( 'These replacements will be applied to Archive Type posts and pages.', 'custom-sidebars' ); ?> |
| 155 | <h3 class="wpmui-tabs"> |
| 156 | <a href="#tab-arch" class="tab active"><?php esc_html_e( 'Archive Types', 'custom-sidebars' ); ?></a> |
| 157 | <a href="#tab-catg" class="tab"><?php esc_html_e( 'Category Archives', 'custom-sidebars' ); ?></a> |
| 158 | <a href="#tab-aut" class="tab"><?php esc_html_e( 'Authors', 'custom-sidebars' ); ?></a> |
| 159 | </h3> |
| 160 | <div class="wpmui-tab-contents"> |
| 161 | <div id="tab-arch" class="tab active"> |
| 162 | <?php |
| 163 | /** |
| 164 | * ========== ARCHIVE -- Special ========== * |
| 165 | */ |
| 166 | foreach ( $sidebars as $sb_id => $details ) { |
| 167 | $cat_name = __( 'Archive Types', 'custom-sidebars' ); |
| 168 | _show_replaceable( $details, 'arc', $cat_name ); |
| 169 | } |
| 170 | ?> |
| 171 | </div> |
| 172 | <div id="tab-catg" class="tab"> |
| 173 | <?php |
| 174 | /** |
| 175 | * ========== ARCHIVE -- Category ========== * |
| 176 | */ |
| 177 | foreach ( $sidebars as $sb_id => $details ) { |
| 178 | $cat_name = __( 'Category Archives', 'custom-sidebars' ); |
| 179 | _show_replaceable( $details, 'arc-cat', $cat_name ); |
| 180 | } |
| 181 | ?> |
| 182 | </div> |
| 183 | <div id="tab-aut" class="tab"> |
| 184 | <?php |
| 185 | /** |
| 186 | * ========== ARCHIVE -- Author ========== * |
| 187 | */ |
| 188 | foreach ( $sidebars as $sb_id => $details ) { |
| 189 | $cat_name = __( 'Author Archives', 'custom-sidebars' ); |
| 190 | _show_replaceable( $details, 'arc-aut', $cat_name ); |
| 191 | } |
| 192 | ?> |
| 193 | </div> |
| 194 | </div> |
| 195 | </div> |
| 196 | </div> |
| 197 | |
| 198 | <?php |
| 199 | /** |
| 200 | * ========================================================================= |
| 201 | * Box 3: SCREEN size |
| 202 | */ |
| 203 | ?> |
| 204 | <div class="wpmui-box closed csb-media-screen-width"> |
| 205 | <h3> |
| 206 | <a href="#" class="toggle" title="<?php esc_html_e( 'Click to toggle', 'custom-sidebars' ); ?>"><br></a> |
| 207 | <span><?php esc_html_e( 'For Screen Sizes', 'custom-sidebars' ); ?></span> |
| 208 | </h3> |
| 209 | <div class="inside"> |
| 210 | <p class="description"><?php esc_html_e( 'Those settings do not load unload sidebars, it only hide or show widgets, NOT SIDEBARS, depend on media screen width.', 'custom-sidebars' ); ?></p> |
| 211 | <table class="form-table"> |
| 212 | <thead> |
| 213 | <tr> |
| 214 | <th><?php echo esc_attr_x( 'Screen', 'media screen width table', 'custom-sidebars' ); ?></th> |
| 215 | <th><?php echo esc_attr_x( 'Show', 'media screen width table', 'custom-sidebars' ); ?></th> |
| 216 | <th><?php echo esc_attr_x( 'Screen width', 'media screen width table', 'custom-sidebars' ); ?></th> |
| 217 | <th class="num"><span class="dashicons dashicons-trash"></span></th> |
| 218 | </tr> |
| 219 | </thead> |
| 220 | <tbody> |
| 221 | </tbody> |
| 222 | <tfoot> |
| 223 | <tr><td colspan="3"><div class="notice notice-info inline"><p><?php esc_html_e( 'There is no defined rules.', 'custom-sidebars' ); ?></p></div></td></tr> |
| 224 | </tfoot> |
| 225 | </table> |
| 226 | <button class="button btn-add-rule"><?php esc_html_e( 'Add new rule', 'custom-sidebars' ); ?></button> |
| 227 | </div> |
| 228 | </div> |
| 229 | |
| 230 | <?php |
| 231 | /** |
| 232 | * ========================================================================= |
| 233 | * Box 4: Plugin integration |
| 234 | */ |
| 235 | $integrations = apply_filters( 'custom_sidebars_integrations', array() ); |
| 236 | if ( ! empty( $integrations ) ) { |
| 237 | ?> |
| 238 | <div class="wpmui-box closed cs-3rd-part"> |
| 239 | <h3> |
| 240 | <a href="#" class="toggle" title="<?php esc_html_e( 'Click to toggle', 'custom-sidebars' ); ?>"><br></a> |
| 241 | <span><?php esc_html_e( '3rd party plugins', 'custom-sidebars' ); ?></span> |
| 242 | </h3> |
| 243 | <div class="inside"> |
| 244 | <p><?php esc_html_e( 'These replacements will be applied to 3rd party plugins.', 'custom-sidebars' ); ?> |
| 245 | |
| 246 | <h3 class="wpmui-tabs"> |
| 247 | <?php |
| 248 | $classes = array( 'tab', 'active' ); |
| 249 | foreach ( $integrations as $id => $one ) { |
| 250 | printf( |
| 251 | '<a href="#tab-%s" class="%s">%s</a>', |
| 252 | esc_attr( $id ), |
| 253 | esc_attr( implode( ' ', $classes ) ), |
| 254 | esc_html( $one['title'] ) |
| 255 | ); |
| 256 | $classes = array( 'tab' ); |
| 257 | } |
| 258 | ?> |
| 259 | </h3> |
| 260 | <div class="wpmui-tab-contents"> |
| 261 | <?php |
| 262 | $classes = array( 'tab', 'active' ); |
| 263 | foreach ( $integrations as $id => $one ) { |
| 264 | printf( |
| 265 | '<div id="tab-%s" class="%s">', |
| 266 | esc_attr( $id ), |
| 267 | esc_attr( implode( ' ', $classes ) ) |
| 268 | ); |
| 269 | foreach ( $sidebars as $sb_id => $details ) { |
| 270 | _show_replaceable( $details, $id, $one['cat_name'] ); |
| 271 | } |
| 272 | echo '</div>'; |
| 273 | $classes = array( 'tab' ); |
| 274 | } |
| 275 | ?> |
| 276 | </div> |
| 277 | </div> |
| 278 | </div> |
| 279 | <?php |
| 280 | } |
| 281 | ?> |
| 282 | |
| 283 | <div class="buttons"> |
| 284 | <button type="button" class="button-link btn-cancel"><?php esc_html_e( 'Cancel', 'custom-sidebars' ); ?></button> |
| 285 | <button type="button" class="button-primary btn-save"><?php esc_html_e( 'Save Changes', 'custom-sidebars' ); ?></button> |
| 286 | </div> |
| 287 | <?php wp_nonce_field( 'custom-sidebars-set-location' ); ?> |
| 288 | </form> |
| 289 |