Exemple #1
0
/**
 * Register our customizer breadcrumb options for the parent class to load.
 *
 * @since  1.0.0
 * @access public
 * @param  object $wp_customize The WordPress customizer API object.
 * @return void
 */
function carelib_register_breadcrumb_settings($wp_customize)
{
    $section = "{$GLOBALS['carelib_prefix']}_breadcrumbs";
    $wp_customize->add_section($section, array('title' => __('Breadcrumbs', 'carelib'), 'description' => __('Choose where you would like breadcrumbs to display.', 'carelib'), 'priority' => 110, 'capability' => 'edit_theme_options'));
    $priority = 10;
    foreach (carelib_get_breadcrumb_options() as $breadcrumb => $setting) {
        $wp_customize->add_setting($breadcrumb, array('default' => $setting['default'], 'sanitize_callback' => 'absint'));
        $wp_customize->add_control($breadcrumb, array('label' => $setting['label'], 'section' => $section, 'type' => 'checkbox', 'priority' => $priority++));
    }
}
Exemple #2
0
/**
 * Display our breadcrumbs based on selections made in the WordPress customizer.
 *
 * @since  1.0.0
 * @access public
 * @return bool true if both our template tag and theme mod return true.
 */
function carelib_display_breadcrumbs()
{
    // Grab our available breadcrumb display options.
    $options = array_keys(carelib_get_breadcrumb_options());
    // Set up an array of template tags to map to our breadcrumb display options.
    $tags = apply_filters("{$GLOBALS['carelib_prefix']}_breadcrumb_tags", array(is_singular() && !is_attachment() && !is_page(), is_page(), is_home() && !is_front_page(), is_archive(), is_404(), is_attachment()));
    // Loop through our theme mods to see if we have a match.
    foreach (array_combine($options, $tags) as $mod => $tag) {
        // Return true if we find an enabled theme mod within the correct section.
        if (1 === absint(get_theme_mod($mod, 0)) && true === $tag) {
            return true;
        }
    }
    return false;
}