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
metabox.php
81 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Metabox inside posts/pages where user can define custom sidebars for an |
| 4 | * individual post. |
| 5 | * |
| 6 | * Uses: |
| 7 | * $selected |
| 8 | * $wp_registered_sidebars |
| 9 | * $post_id |
| 10 | */ |
| 11 | |
| 12 | $sidebars = CustomSidebars::get_options( 'modifiable' ); |
| 13 | |
| 14 | $is_front = get_option( 'page_on_front' ) == $post_id; |
| 15 | $is_blog = get_option( 'page_for_posts' ) == $post_id; |
| 16 | |
| 17 | if ( $is_front || $is_blog ) : ?> |
| 18 | <p> |
| 19 | <?php printf( |
| 20 | __( |
| 21 | '<strong>To change the sidebar for static Front-Page or ' . |
| 22 | 'Posts-Page</strong>:<ul>' . |
| 23 | '<li>Go to the <a href="%1$s">Widgets page</a></li>' . |
| 24 | '<li>Click on "Sidebar Location"</li>' . |
| 25 | '<li>Open the "Archive-Types" tab</li>' . |
| 26 | '<li>Choose "Front-Page" or "Post-Index"</li></ul>', |
| 27 | 'custom-sidebars' |
| 28 | ), |
| 29 | admin_url( 'widgets.php' ) |
| 30 | ); ?> |
| 31 | </p> |
| 32 | |
| 33 | <img src="<?php echo esc_url( CSB_IMG_URL . 'frontpage-info.png' ); ?>" style="width:274px;margin:0 0 -14px -10px;" /> |
| 34 | |
| 35 | <?php foreach ( $sidebars as $s ) { ?> |
| 36 | <input type="hidden" |
| 37 | name="cs_replacement_<?php echo esc_attr( $s ); ?>" |
| 38 | value="<?php echo esc_attr( $selected[ $s ] ); ?>" /> |
| 39 | <?php } ?> |
| 40 | |
| 41 | <?php else : ?> |
| 42 | |
| 43 | <p> |
| 44 | <?php _e( |
| 45 | 'Here you can replace the default sidebars. Simply select what ' . |
| 46 | 'sidebar you want to show for this post!', 'custom-sidebars' |
| 47 | ); ?> |
| 48 | </p> |
| 49 | <?php |
| 50 | if ( ! empty( $sidebars ) ) : |
| 51 | global $wp_registered_sidebars; |
| 52 | $available = CustomSidebars::sort_sidebars_by_name( $wp_registered_sidebars ); |
| 53 | foreach ( $sidebars as $s ) : ?> |
| 54 | <?php $sb_name = $available[ $s ]['name']; ?> |
| 55 | <p> |
| 56 | <label for="cs_replacement_<?php echo esc_attr( $s ); ?>"> |
| 57 | <b><?php echo esc_html( $sb_name ); ?></b>: |
| 58 | </label> |
| 59 | <select name="cs_replacement_<?php echo esc_attr( $s ); ?>" |
| 60 | id="cs_replacement_<?php echo esc_attr( $s ); ?>" |
| 61 | class="cs-replacement-field <?php echo esc_attr( $s ); ?>"> |
| 62 | <option value=""></option> |
| 63 | <?php foreach ( $available as $a ) : ?> |
| 64 | <option value="<?php echo esc_attr( $a['id'] ); ?>" <?php selected( $selected[ $s ], $a['id'] ); ?>> |
| 65 | <?php echo esc_html( $a['name'] ); ?> |
| 66 | </option> |
| 67 | <?php endforeach; ?> |
| 68 | </select> |
| 69 | </p> |
| 70 | <?php endforeach; ?> |
| 71 | <?php else : ?> |
| 72 | <p id="message" class="updated"> |
| 73 | <?php _e( |
| 74 | 'All sidebars have been locked, you cannot replace them. ' . |
| 75 | 'Go to <a href="widgets.php">the widgets page</a> to unlock a ' . |
| 76 | 'sidebar', 'custom-sidebars' |
| 77 | ); ?> |
| 78 | </p> |
| 79 | <?php endif; |
| 80 | endif; |
| 81 |