/** * Render theme settings meta box. * * @since Photo Perfect 1.0 */ function photo_perfect_render_theme_settings_metabox() { global $post; $post_id = $post->ID; // Meta box nonce for verification. wp_nonce_field(basename(__FILE__), 'photo_perfect_theme_settings_meta_box_nonce'); // Fetch Options list. $global_layout_options = photo_perfect_get_global_layout_options(); $image_size_options = photo_perfect_get_image_options(true, array('disable', 'large')); $image_alignment_options = photo_perfect_get_image_alignment_options(); // Fetch values of current post meta. $values = get_post_meta($post_id, 'theme_settings', true); $theme_settings_post_layout = isset($values['post_layout']) ? esc_attr($values['post_layout']) : ''; $theme_settings_single_image = isset($values['single_image']) ? esc_attr($values['single_image']) : ''; $theme_settings_single_image_alignment = isset($values['single_image_alignment']) ? esc_attr($values['single_image_alignment']) : ''; ?> <!-- Layout option --> <p><strong><?php echo esc_html__('Choose Layout', 'photo-perfect'); ?> </strong></p> <select name="theme_settings[post_layout]" id="theme_settings_post_layout"> <option value=""><?php echo esc_html__('Default', 'photo-perfect'); ?> </option> <?php if (!empty($global_layout_options)) { ?> <?php foreach ($global_layout_options as $key => $val) { ?> <option value="<?php echo esc_attr($key); ?> " <?php selected($theme_settings_post_layout, $key); ?> ><?php echo esc_html($val); ?> </option> <?php } ?> <?php } ?> </select> <!-- Image in single post/page --> <p><strong><?php echo esc_html__('Choose Image Size in Single Post/Page', 'photo-perfect'); ?> </strong></p> <select name="theme_settings[single_image]" id="theme_settings_single_image"> <option value=""><?php echo esc_html__('Default', 'photo-perfect'); ?> </option> <?php if (!empty($image_size_options)) { ?> <?php foreach ($image_size_options as $key => $val) { ?> <option value="<?php echo esc_attr($key); ?> " <?php selected($theme_settings_single_image, $key); ?> ><?php echo esc_html($val); ?> </option> <?php } ?> <?php } ?> </select> <!-- Image Alignment in single post/page --> <p><strong><?php echo esc_html__('Alignment of Image in Single Post/Page', 'photo-perfect'); ?> </strong></p> <select name="theme_settings[single_image_alignment]" id="theme_settings_single_image_alignment"> <option value=""><?php echo esc_html__('Default', 'photo-perfect'); ?> </option> <?php if (!empty($image_alignment_options)) { ?> <?php foreach ($image_alignment_options as $key => $val) { ?> <option value="<?php echo esc_attr($key); ?> " <?php selected($theme_settings_single_image_alignment, $key); ?> ><?php echo esc_html($val); ?> </option> <?php } ?> <?php } ?> </select> <?php }
$wp_customize->add_setting('theme_options[search_placeholder]', array('default' => $default['search_placeholder'], 'capability' => 'edit_theme_options', 'sanitize_callback' => 'wp_filter_nohtml_kses')); $wp_customize->add_control('theme_options[search_placeholder]', array('label' => __('Search Placeholder', 'photo-perfect'), 'section' => 'section_search', 'type' => 'text', 'priority' => 100)); // Layout Section $wp_customize->add_section('section_layout', array('title' => __('Layout Options', 'photo-perfect'), 'priority' => 100, 'capability' => 'edit_theme_options', 'panel' => 'theme_option_panel')); // global_layout $wp_customize->add_setting('theme_options[global_layout]', array('default' => $default['global_layout'], 'capability' => 'edit_theme_options', 'sanitize_callback' => 'photo_perfect_sanitize_select')); $wp_customize->add_control('theme_options[global_layout]', array('label' => __('Global Layout', 'photo-perfect'), 'section' => 'section_layout', 'type' => 'select', 'choices' => photo_perfect_get_global_layout_options(), 'priority' => 100)); // archive_layout $wp_customize->add_setting('theme_options[archive_layout]', array('default' => $default['archive_layout'], 'capability' => 'edit_theme_options', 'sanitize_callback' => 'photo_perfect_sanitize_select')); $wp_customize->add_control('theme_options[archive_layout]', array('label' => __('Archive Layout', 'photo-perfect'), 'section' => 'section_layout', 'type' => 'select', 'choices' => photo_perfect_get_archive_layout_options(), 'priority' => 100)); // single_image $wp_customize->add_setting('theme_options[single_image]', array('default' => $default['single_image'], 'capability' => 'edit_theme_options', 'sanitize_callback' => 'photo_perfect_sanitize_select')); $wp_customize->add_control('theme_options[single_image]', array('label' => __('Image in Single Post/Page', 'photo-perfect'), 'section' => 'section_layout', 'type' => 'select', 'choices' => photo_perfect_get_image_options(true, array('disable', 'large')), 'priority' => 100)); // single_image_alignment $wp_customize->add_setting('theme_options[single_image_alignment]', array('default' => $default['single_image_alignment'], 'capability' => 'edit_theme_options', 'sanitize_callback' => 'photo_perfect_sanitize_select')); $wp_customize->add_control('theme_options[single_image_alignment]', array('label' => __('Image Alignment in Single Post/Page', 'photo-perfect'), 'section' => 'section_layout', 'type' => 'select', 'choices' => photo_perfect_get_image_alignment_options(), 'priority' => 100)); // Pagination Section $wp_customize->add_section('section_pagination', array('title' => __('Pagination Options', 'photo-perfect'), 'priority' => 100, 'capability' => 'edit_theme_options', 'panel' => 'theme_option_panel')); // pagination_type $wp_customize->add_setting('theme_options[pagination_type]', array('default' => $default['pagination_type'], 'capability' => 'edit_theme_options', 'sanitize_callback' => 'photo_perfect_sanitize_select')); $wp_customize->add_control('theme_options[pagination_type]', array('label' => __('Pagination Type', 'photo-perfect'), 'description' => sprintf(__('Numeric: Requires %sWP-PageNavi%s plugin', 'photo-perfect'), '<a href="https://wordpress.org/plugins/wp-pagenavi/" target="_blank">', '</a>'), 'section' => 'section_pagination', 'type' => 'select', 'choices' => photo_perfect_get_pagination_type_options(), 'priority' => 100)); // Footer Section $wp_customize->add_section('section_footer', array('title' => __('Footer Options', 'photo-perfect'), 'priority' => 100, 'capability' => 'edit_theme_options', 'panel' => 'theme_option_panel')); // copyright_text $wp_customize->add_setting('theme_options[copyright_text]', array('default' => $default['copyright_text'], 'capability' => 'edit_theme_options', 'sanitize_callback' => 'wp_filter_nohtml_kses')); $wp_customize->add_control('theme_options[copyright_text]', array('label' => __('Copyright Text', 'photo-perfect'), 'section' => 'section_footer', 'type' => 'text', 'priority' => 100)); // go_to_top $wp_customize->add_setting('theme_options[go_to_top]', array('default' => $default['go_to_top'], 'capability' => 'edit_theme_options', 'sanitize_callback' => 'photo_perfect_sanitize_checkbox')); $wp_customize->add_control('theme_options[go_to_top]', array('label' => __('Show Go To Top', 'photo-perfect'), 'section' => 'section_footer', 'type' => 'checkbox', 'priority' => 100)); // Blog Section $wp_customize->add_section('section_blog', array('title' => __('Blog Options', 'photo-perfect'), 'priority' => 100, 'capability' => 'edit_theme_options', 'panel' => 'theme_option_panel'));