col-sidebars.php
9 years ago
import.php
9 years ago
metabox.php
9 years ago
quick-edit.php
9 years ago
widgets-delete.php
10 years ago
widgets-editor.php
10 years ago
widgets-export.php
10 years ago
widgets-location.php
9 years ago
widgets.php
10 years ago
widgets-location.php
193 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 | function _show_replaceable( $sidebar, $prefix, $cat_name, $class = '' ) { |
| 21 | $base_id = 'cs-' . $prefix; |
| 22 | $inp_id = $base_id . '-' . $sidebar['id']; |
| 23 | $inp_name = '___cs___' . $prefix . '___' . $sidebar['id']; |
| 24 | $sb_id = $sidebar['id']; |
| 25 | $class = (empty( $class ) ? '' : ' ' . $class); |
| 26 | |
| 27 | ?> |
| 28 | <div |
| 29 | class="cs-replaceable <?php echo esc_attr( $sb_id . $class ); ?>" |
| 30 | data-lbl-used="<?php _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 | $sidebar['name'], |
| 40 | $cat_name |
| 41 | ); ?> |
| 42 | </label> |
| 43 | <div class="details"> |
| 44 | <select |
| 45 | class="cs-datalist <?php echo esc_attr( $base_id ); ?>" |
| 46 | name="<?php echo esc_attr( $inp_name ); ?>[]" |
| 47 | multiple="multiple" |
| 48 | placeholder="<?php echo esc_attr( |
| 49 | sprintf( |
| 50 | __( 'Click here to pick available %1$s', 'custom-sidebars' ), |
| 51 | $cat_name |
| 52 | ) |
| 53 | ); ?>" |
| 54 | > |
| 55 | </select> |
| 56 | </div> |
| 57 | </div> |
| 58 | <?php |
| 59 | } |
| 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 _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 _e( 'Click to toggle' ); /* This is a Wordpress default language */ ?>"><br></a> |
| 99 | <span><?php _e( 'For all Single Entries matching selected criteria', 'custom-sidebars' ); ?></span> |
| 100 | </h3> |
| 101 | <div class="inside"> |
| 102 | <p><?php _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 | |
| 128 | </div> |
| 129 | </div> |
| 130 | |
| 131 | <?php |
| 132 | /** |
| 133 | * ========================================================================= |
| 134 | * Box 2: ARCHIVE pages |
| 135 | */ |
| 136 | ?> |
| 137 | <div class="wpmui-box closed"> |
| 138 | <h3> |
| 139 | <a href="#" class="toggle" title="<?php _e( 'Click to toggle' ); /* This is a Wordpress default language */ ?>"><br></a> |
| 140 | <span><?php _e( 'For Archives', 'custom-sidebars' ); ?></span> |
| 141 | </h3> |
| 142 | <div class="inside"> |
| 143 | <p><?php _e( 'These replacements will be applied to Archive Type posts and pages.', 'custom-sidebars' ); ?> |
| 144 | |
| 145 | <h3 class="wpmui-tabs"> |
| 146 | <a href="#tab-arch" class="tab active"><?php _e( 'Archive Types', 'custom-sidebars' ); ?></a> |
| 147 | <a href="#tab-catg" class="tab"><?php _e( 'Category Archives', 'custom-sidebars' ); ?></a> |
| 148 | <a href="#tab-aut" class="tab"><?php _e( 'Authors', 'custom-sidebars' ); ?></a> |
| 149 | </h3> |
| 150 | <div class="wpmui-tab-contents"> |
| 151 | <div id="tab-arch" class="tab active"> |
| 152 | <?php |
| 153 | /** |
| 154 | * ========== ARCHIVE -- Special ========== * |
| 155 | */ |
| 156 | foreach ( $sidebars as $sb_id => $details ) { |
| 157 | $cat_name = __( 'Archive Types', 'custom-sidebars' ); |
| 158 | _show_replaceable( $details, 'arc', $cat_name ); |
| 159 | } |
| 160 | ?> |
| 161 | </div> |
| 162 | <div id="tab-catg" class="tab"> |
| 163 | <?php |
| 164 | /** |
| 165 | * ========== ARCHIVE -- Category ========== * |
| 166 | */ |
| 167 | foreach ( $sidebars as $sb_id => $details ) { |
| 168 | $cat_name = __( 'Category Archives', 'custom-sidebars' ); |
| 169 | _show_replaceable( $details, 'arc-cat', $cat_name ); |
| 170 | } |
| 171 | ?> |
| 172 | </div> |
| 173 | <div id="tab-aut" class="tab"> |
| 174 | <?php |
| 175 | /** |
| 176 | * ========== ARCHIVE -- Author ========== * |
| 177 | */ |
| 178 | foreach ( $sidebars as $sb_id => $details ) { |
| 179 | $cat_name = __( 'Author Archives', 'custom-sidebars' ); |
| 180 | _show_replaceable( $details, 'arc-aut', $cat_name ); |
| 181 | } |
| 182 | ?> |
| 183 | </div> |
| 184 | </div> |
| 185 | </div> |
| 186 | </div> |
| 187 | |
| 188 | <div class="buttons"> |
| 189 | <button type="button" class="button-link btn-cancel"><?php _e( 'Cancel', 'custom-sidebars' ); ?></button> |
| 190 | <button type="button" class="button-primary btn-save"><?php _e( 'Save Changes', 'custom-sidebars' ); ?></button> |
| 191 | </div> |
| 192 | </form> |
| 193 |