Example #1
0
 /**
  * Sets up theme defaults and registers support for various WordPress features.
  *
  * Note that this function is hooked into the after_setup_theme hook, which
  * runs before the init hook. The init hook is too late for some features, such
  * as indicating support for post thumbnails.
  */
 function photo_perfect_setup()
 {
     /*
      * Make theme available for translation.
      * Translations can be filed in the /languages/ directory.
      * If you're building a theme based on Photo Perfect, use a find and replace
      * to change 'photo-perfect' to the name of your theme in all the template files.
      */
     load_theme_textdomain('photo-perfect', get_template_directory() . '/languages');
     // Add default posts and comments RSS feed links to head.
     add_theme_support('automatic-feed-links');
     /*
      * Let WordPress manage the document title.
      * By adding theme support, we declare that this theme does not use a
      * hard-coded <title> tag in the document head, and expect WordPress to
      * provide it for us.
      */
     add_theme_support('title-tag');
     /*
      * Enable support for Post Thumbnails on posts and pages.
      *
      * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
      */
     add_theme_support('post-thumbnails');
     // This theme uses wp_nav_menu() in four location.
     register_nav_menus(array('primary' => esc_html__('Primary Menu', 'photo-perfect'), 'footer' => esc_html__('Footer Menu', 'photo-perfect'), 'social' => esc_html__('Social Menu', 'photo-perfect'), 'notfound' => esc_html__('404 Menu', 'photo-perfect')));
     /*
      * Switch default core markup for search form, comment form, and comments
      * to output valid HTML5.
      */
     add_theme_support('html5', array('search-form', 'comment-form', 'comment-list', 'gallery', 'caption'));
     /*
      * This theme styles the visual editor to resemble the theme style,
      * specifically font, colors, icons, and column width.
      */
     add_editor_style(array('css/editor-style.css'));
     // Set up the WordPress core custom background feature.
     add_theme_support('custom-background', apply_filters('photo_perfect_custom_background_args', array('default-color' => 'ffffff', 'default-image' => '')));
     /**
      * Enable support for footer widgets
      */
     add_theme_support('footer-widgets', 4);
     /**
      * Load Supports.
      */
     require get_template_directory() . '/inc/support.php';
     global $photo_perfect_default_options;
     $photo_perfect_default_options = photo_perfect_get_default_theme_options();
     global $photo_perfect_post_count;
     $photo_perfect_post_count = 1;
 }
Example #2
0
<?php

$default = photo_perfect_get_default_theme_options();
// Add Panel
$wp_customize->add_panel('theme_option_panel', array('title' => __('Theme Options', 'photo-perfect'), 'priority' => 100, 'capability' => 'edit_theme_options'));
// Header Section
$wp_customize->add_section('section_header', array('title' => __('Header Options', 'photo-perfect'), 'priority' => 100, 'capability' => 'edit_theme_options', 'panel' => 'theme_option_panel'));
// site_logo
$wp_customize->add_setting('theme_options[site_logo]', array('default' => $default['site_logo'], 'capability' => 'edit_theme_options', 'sanitize_callback' => 'photo_perfect_sanitize_image'));
$wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'theme_options[site_logo]', array('label' => __('Logo', 'photo-perfect'), 'description' => sprintf(__('Recommended size: %dpx x %dpx ', 'photo-perfect'), 145, 100), 'section' => 'section_header', 'settings' => 'theme_options[site_logo]')));
// Search Section
$wp_customize->add_section('section_search', array('title' => __('Search Options', 'photo-perfect'), 'priority' => 100, 'capability' => 'edit_theme_options', 'panel' => 'theme_option_panel'));
// show_title
$wp_customize->add_setting('theme_options[show_title]', array('default' => $default['show_title'], 'capability' => 'edit_theme_options', 'sanitize_callback' => 'photo_perfect_sanitize_checkbox'));
$wp_customize->add_control('theme_options[show_title]', array('label' => __('Show Site Title', 'photo-perfect'), 'section' => 'section_header', 'type' => 'checkbox', 'priority' => 100));
// show_tagline
$wp_customize->add_setting('theme_options[show_tagline]', array('default' => $default['show_tagline'], 'capability' => 'edit_theme_options', 'sanitize_callback' => 'photo_perfect_sanitize_checkbox'));
$wp_customize->add_control('theme_options[show_tagline]', array('label' => __('Show Tagline', 'photo-perfect'), 'section' => 'section_header', 'type' => 'checkbox', 'priority' => 100));
// show_category_dropdown
$wp_customize->add_setting('theme_options[show_category_dropdown]', array('default' => $default['show_category_dropdown'], 'capability' => 'edit_theme_options', 'sanitize_callback' => 'photo_perfect_sanitize_checkbox'));
$wp_customize->add_control('theme_options[show_category_dropdown]', array('label' => __('Show Category Dropdown', 'photo-perfect'), 'section' => 'section_header', 'type' => 'checkbox', 'priority' => 100));
// search_placeholder
$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'));