EduardET

Default: full-width, hide title

Dec 13th, 2017
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.58 KB | None | 0 0
  1. function et_single_settings_meta_box( $post ) {
  2.     $post_id = get_the_ID();
  3.  
  4.     wp_nonce_field( basename( __FILE__ ), 'et_settings_nonce' );
  5.  
  6.     $page_layout = get_post_meta( $post_id, '_et_pb_page_layout', true );
  7.  
  8.     $side_nav = get_post_meta( $post_id, '_et_pb_side_nav', true );
  9.  
  10.     $project_nav = get_post_meta( $post_id, '_et_pb_project_nav', true );
  11.  
  12.     $post_hide_nav = get_post_meta( $post_id, '_et_pb_post_hide_nav', true );
  13.     $post_hide_nav = $post_hide_nav && 'off' === $post_hide_nav ? 'default' : $post_hide_nav;
  14.  
  15.     $show_title = get_post_meta( $post_id, '_et_pb_show_title', true );
  16.  
  17.     if ( is_rtl() ) {
  18.         $page_layouts = array(
  19.             'et_left_sidebar'    => esc_html__( 'Left Sidebar', 'Divi' ),
  20.             'et_right_sidebar'   => esc_html__( 'Right Sidebar', 'Divi' ),
  21.             'et_full_width_page' => esc_html__( 'Fullwidth', 'Divi' ),
  22.         );
  23.     } else {
  24.         $page_layouts = array(
  25.             'et_full_width_page' => esc_html__( 'Fullwidth', 'Divi' ),
  26.             'et_right_sidebar'   => esc_html__( 'Right Sidebar', 'Divi' ),
  27.             'et_left_sidebar'    => esc_html__( 'Left Sidebar', 'Divi' ),
  28.            
  29.         );
  30.     }
  31.  
  32.     $layouts = array(
  33.         'light' => esc_html__( 'Light', 'Divi' ),
  34.         'dark'  => esc_html__( 'Dark', 'Divi' ),
  35.     );
  36.     $post_bg_color  = ( $bg_color = get_post_meta( $post_id, '_et_post_bg_color', true ) ) && '' !== $bg_color
  37.         ? $bg_color
  38.         : '#ffffff';
  39.     $post_use_bg_color = get_post_meta( $post_id, '_et_post_use_bg_color', true )
  40.         ? true
  41.         : false;
  42.     $post_bg_layout = ( $layout = get_post_meta( $post_id, '_et_post_bg_layout', true ) ) && '' !== $layout
  43.         ? $layout
  44.         : 'light'; ?>
  45.  
  46.     <p class="et_pb_page_settings et_pb_page_layout_settings">
  47.         <label for="et_pb_page_layout" style="display: block; font-weight: bold; margin-bottom: 5px;"><?php esc_html_e( 'Page Layout', 'Divi' ); ?>: </label>
  48.  
  49.         <select id="et_pb_page_layout" class="wpc" name="et_pb_page_layout">
  50.         <?php
  51.         foreach ( $page_layouts as $layout_value => $layout_name ) {
  52.             printf( '<option value="%2$s"%3$s>%1$s</option>',
  53.                 esc_html( $layout_name ),
  54.                 esc_attr( $layout_value ),
  55.                 selected( $layout_value, $page_layout, false )
  56.             );
  57.         } ?>
  58.         </select>
  59.     </p>
  60.     <p class="et_pb_page_settings et_pb_side_nav_settings" style="display: none;">
  61.         <label for="et_pb_side_nav" style="display: block; font-weight: bold; margin-bottom: 5px;"><?php esc_html_e( 'Dot Navigation', 'Divi' ); ?>: </label>
  62.  
  63.         <select id="et_pb_side_nav" name="et_pb_side_nav">
  64.             <option value="off" <?php selected( 'off', $side_nav ); ?>><?php esc_html_e( 'Off', 'Divi' ); ?></option>
  65.             <option value="on" <?php selected( 'on', $side_nav ); ?>><?php esc_html_e( 'On', 'Divi' ); ?></option>
  66.         </select>
  67.     </p>
  68.     <p class="et_pb_page_settings">
  69.         <label for="et_pb_post_hide_nav" style="display: block; font-weight: bold; margin-bottom: 5px;"><?php esc_html_e( 'Hide Nav Before Scroll', 'Divi' ); ?>: </label>
  70.  
  71.         <select id="et_pb_post_hide_nav" name="et_pb_post_hide_nav">
  72.             <option value="default" <?php selected( 'default', $post_hide_nav ); ?>><?php esc_html_e( 'Default', 'Divi' ); ?></option>
  73.             <option value="no" <?php selected( 'no', $post_hide_nav ); ?>><?php esc_html_e( 'Off', 'Divi' ); ?></option>
  74.             <option value="on" <?php selected( 'on', $post_hide_nav ); ?>><?php esc_html_e( 'On', 'Divi' ); ?></option>
  75.         </select>
  76.     </p>
  77.  
  78. <?php if ( 'post' === $post->post_type ) : ?>
  79.     <p class="et_pb_page_settings et_pb_single_title" style="display: none;">
  80.         <label for="et_single_title" style="display: block; font-weight: bold; margin-bottom: 5px;"><?php esc_html_e( 'Post Title', 'Divi' ); ?>: </label>
  81.  
  82.         <select id="et_single_title" name="et_single_title">
  83.             <option value="off" <?php selected( 'off', $show_title ); ?>><?php esc_html_e( 'Hide', 'Divi' ); ?></option>
  84.             <option value="on" <?php selected( 'on', $show_title ); ?>><?php esc_html_e( 'Show', 'Divi' ); ?></option>
  85.         </select>
  86.     </p>
  87.  
  88.     <p class="et_divi_quote_settings et_divi_audio_settings et_divi_link_settings et_divi_format_setting et_pb_page_settings">
  89.         <label for="et_post_use_bg_color" style="display: block; font-weight: bold; margin-bottom: 5px;"><?php esc_html_e( 'Use Background Color', 'Divi' ); ?></label>
  90.         <input name="et_post_use_bg_color" type="checkbox" id="et_post_use_bg_color" <?php checked( $post_use_bg_color ); ?> />
  91.     </p>
  92.  
  93.     <p class="et_post_bg_color_setting et_divi_format_setting et_pb_page_settings">
  94.         <input id="et_post_bg_color" name="et_post_bg_color" class="color-picker-hex" type="text" maxlength="7" placeholder="<?php esc_attr_e( 'Hex Value', 'Divi' ); ?>" value="<?php echo esc_attr( $post_bg_color ); ?>" data-default-color="#ffffff" />
  95.     </p>
  96.  
  97.     <p class="et_divi_quote_settings et_divi_audio_settings et_divi_link_settings et_divi_format_setting">
  98.         <label for="et_post_bg_layout" style="font-weight: bold; margin-bottom: 5px;"><?php esc_html_e( 'Text Color', 'Divi' ); ?>: </label>
  99.         <select id="et_post_bg_layout" name="et_post_bg_layout">
  100.     <?php
  101.         foreach ( $layouts as $layout_name => $layout_title )
  102.             printf( '<option value="%s"%s>%s</option>',
  103.                 esc_attr( $layout_name ),
  104.                 selected( $layout_name, $post_bg_layout, false ),
  105.                 esc_html( $layout_title )
  106.             );
  107.     ?>
  108.         </select>
  109.     </p>
  110. <?php endif;
  111.  
  112. if ( 'project' === $post->post_type ) : ?>
  113.     <p class="et_pb_page_settings et_pb_project_nav" style="display: none;">
  114.         <label for="et_project_nav" style="display: block; font-weight: bold; margin-bottom: 5px;"><?php esc_html_e( 'Project Navigation', 'Divi' ); ?>: </label>
  115.  
  116.         <select id="et_project_nav" name="et_project_nav">
  117.             <option value="off" <?php selected( 'off', $project_nav ); ?>><?php esc_html_e( 'Hide', 'Divi' ); ?></option>
  118.             <option value="on" <?php selected( 'on', $project_nav ); ?>><?php esc_html_e( 'Show', 'Divi' ); ?></option>
  119.         </select>
  120.     </p>
  121. <?php endif;
  122. }
Advertisement
Add Comment
Please, Sign In to add comment