bulk-edit.php
7 years ago
col-sidebars.php
7 years ago
import.php
7 years ago
metabox.php
5 years ago
quick-edit.php
9 years ago
widgets-delete.php
8 years ago
widgets-editor.php
8 years ago
widgets-export.php
8 years ago
widgets-location.php
7 years ago
widgets.php
7 years ago
col-sidebars.php
81 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Custom column inside the post-list. |
| 4 | * |
| 5 | * Uses: |
| 6 | * $selected |
| 7 | * $wp_registered_sidebars |
| 8 | * $post_id |
| 9 | */ |
| 10 | |
| 11 | $sidebars = CustomSidebars::get_options( 'modifiable' ); |
| 12 | |
| 13 | $is_front = get_option( 'page_on_front' ) == $post_id; |
| 14 | $is_blog = get_option( 'page_for_posts' ) == $post_id; |
| 15 | /** |
| 16 | * check is WooCommerce shop |
| 17 | */ |
| 18 | $is_woo_shop = intval( $post_id ) === ( function_exists( 'wc_get_page_id' )? intval( wc_get_page_id( 'shop' ) ) : 0 ); |
| 19 | /** |
| 20 | * helper function |
| 21 | */ |
| 22 | if ( ! function_exists( 'custom_sidebars_col_sideber_not_available' ) ) { |
| 23 | /** |
| 24 | * local display helper |
| 25 | * |
| 26 | * @since 3.2.0 |
| 27 | * |
| 28 | * @param string $page_name Page Name to display. |
| 29 | */ |
| 30 | function custom_sidebars_col_sideber_not_available( $page_name ) { |
| 31 | $content = sprintf( |
| 32 | esc_attr__( 'Not available for %s', 'custom-sidebars' ), |
| 33 | $page_name |
| 34 | ); |
| 35 | printf( |
| 36 | '<small>%s</small>', |
| 37 | esc_html( $content ) |
| 38 | ); |
| 39 | } |
| 40 | } |
| 41 | /** |
| 42 | * prepare |
| 43 | */ |
| 44 | if ( $is_front ) { |
| 45 | custom_sidebars_col_sideber_not_available( __( 'Home Page', 'custom-sidebars' ) ); |
| 46 | } elseif ( $is_blog ) { |
| 47 | custom_sidebars_col_sideber_not_available( __( 'Blog Page', 'custom-sidebars' ) ); |
| 48 | } else if ( $is_woo_shop ) { |
| 49 | custom_sidebars_col_sideber_not_available( __( 'WooCommerce Shop', 'custom-sidebars' ) ); |
| 50 | } else { |
| 51 | global $wp_registered_sidebars; |
| 52 | $available = CustomSidebars::sort_sidebars_by_name( $wp_registered_sidebars ); |
| 53 | $content = ''; |
| 54 | foreach ( $sidebars as $s ) { |
| 55 | $sb_name = $available[ $s ]['name']; |
| 56 | $replaced = ! empty( $available[ $selected[ $s ] ] ); |
| 57 | $class = $replaced ? 'cust' : 'def'; |
| 58 | |
| 59 | if ( $replaced ) { |
| 60 | $content .= sprintf( |
| 61 | '<dt data-sidebar="%s" data-replaced="%s" class="cs-key %s">', |
| 62 | esc_attr( $s ), |
| 63 | isset( $selected[ $s ] )? esc_attr( $selected[ $s ] ):'', |
| 64 | esc_attr( $class, 'custom-sidebars' ) |
| 65 | ); |
| 66 | $content .= esc_html( $sb_name ); |
| 67 | $content .= '</dt>'; |
| 68 | $content .= '<dd class="cs-val">'; |
| 69 | $content .= esc_html( $available[ $selected[ $s ] ]['name'] ); |
| 70 | $content .= '</dd>'; |
| 71 | } |
| 72 | } |
| 73 | if ( empty( $content ) ) { |
| 74 | echo '-'; |
| 75 | } else { |
| 76 | echo '<dl>'; |
| 77 | echo $content; |
| 78 | echo '</dl>'; |
| 79 | } |
| 80 | } |
| 81 |