function cleanyetibasic_row_width() { global $cleanyetibasic_options; $cleanyetibasic_options = cleanyetibasic_get_options(); $px_width = $cleanyetibasic_options['max_width']; if (isset($px_width)) { $rem_width = $px_width / 16; } else { $rem_width = 65; } $output = '<style type="text/css">.row{ max-width: ' . $rem_width . 'rem; }</style>'; echo apply_filters('cleanyetibasic_row_width', $output); }
/** * Opening & closing element for sidebar * * Width may be changed by editing large-4 to large-* * If changed, filter for cleanyetibasic_container must be applied * Filters: cleanyetibasic_sidebar_open, cleanyetibasic_sidebar_close */ function cleanyetibasic_sidebar_open() { global $cleanyetibasic_options; $cleanyetibasic_options = cleanyetibasic_get_options(); $sbpos = $cleanyetibasic_options['sidebar_position']; $sbwidth = $cleanyetibasic_options['sidebar_width']; $pullwidth = 12 - $sbwidth; if ('left' == $sbpos) { $open = '<div class="medium-' . $sbwidth . ' medium-pull-' . $pullwidth . ' columns">'; } else { $open = '<div class="medium-' . $sbwidth . ' columns">'; } echo apply_filters('cleanyetibasic_sidebar_open', $open); }
/** * Opening element for container * * Width may be changed by editing large-8 to large-* * If changed, filter for cleanyetibasic_sidebar_open must be applied * Filter: cleanyetibasic_container */ function cleanyetibasic_container() { global $wp_customize, $cleanyetibasic_options; $cleanyetibasic_options = cleanyetibasic_get_options(); $sbpos = $cleanyetibasic_options['sidebar_position']; $sbwidth = $cleanyetibasic_options['sidebar_width']; $contentwidth = 12 - $sbwidth; if (is_page_template('template-page-fullwidth.php')) { $open = '<div id="container" class="medium-12 columns">'; } elseif (is_active_sidebar('primary-aside') || is_active_sidebar('secondary-aside') || method_exists($wp_customize, 'is_preview') && $wp_customize->is_preview()) { if ('left' == $sbpos) { $open = '<div id="container" class="medium-' . $contentwidth . ' medium-push-' . $sbwidth . ' columns">'; } else { $open = '<div id="container" class="medium-' . $contentwidth . ' columns">'; } } else { $open = '<div id="container" class="medium-12 columns">'; } echo apply_filters('cleanyetibasic_container', $open); }
/** * Clean Yeti Basic Theme Settings Theme Customizer Implementation * * Implement the Theme Customizer for the * Clean Yeti Basic Theme Settings. * * @param object $wp_customize Object that holds the customizer data * * @link http://ottopress.com/2012/how-to-leverage-the-theme-customizer-in-your-own-themes/ Otto */ function cleanyetibasic_register_theme_customizer($wp_customize) { // Failsafe is safe if (!isset($wp_customize)) { return; } global $cleanyetibasic_options; $cleanyetibasic_options = cleanyetibasic_get_options(); // Get the array of option parameters $option_parameters = cleanyetibasic_get_option_parameters(); // Get list of tabs $tabs = cleanyetibasic_get_settings_page_tabs(); // Add Sections foreach ($tabs as $tab) { // Add $tab section $wp_customize->add_section('cleanyetibasic_' . $tab['name'], array('title' => $tab['title'])); } // Add Settings foreach ($option_parameters as $option_parameter) { // sanitize callback based on type if ('text' == $option_parameter['type']) { $sanitize = 'cleanyetibasic_sanitize_text'; } else { if ('checkbox' == $option_parameter['type']) { $sanitize = 'cleanyetibasic_sanitize_checkbox'; } else { if ('radio' == $option_parameter['type'] || 'select' == $option_parameter['type']) { $sanitize = 'cleanyetibasic_sanitize_choices'; } else { if ('color-picker' == $option_parameter['type']) { $sanitize = 'sanitize_hex_color'; } } } } // Add $option_parameter setting $wp_customize->add_setting('theme_cleanyetibasic_options[' . $option_parameter['name'] . ']', array('default' => $option_parameter['default'], 'type' => 'option', 'sanitize_callback' => $sanitize)); // Add $option_parameter control if ('text' == $option_parameter['type']) { $wp_customize->add_control('cleanyetibasic_' . $option_parameter['name'], array('label' => $option_parameter['title'], 'section' => 'cleanyetibasic_' . $option_parameter['tab'], 'settings' => 'theme_cleanyetibasic_options[' . $option_parameter['name'] . ']', 'type' => 'text')); } else { if ('checkbox' == $option_parameter['type']) { $wp_customize->add_control('cleanyetibasic_' . $option_parameter['name'], array('label' => $option_parameter['title'], 'section' => 'cleanyetibasic_' . $option_parameter['tab'], 'settings' => 'theme_cleanyetibasic_options[' . $option_parameter['name'] . ']', 'type' => 'checkbox')); } else { if ('radio' == $option_parameter['type']) { $valid_options = array(); foreach ($option_parameter['valid_options'] as $valid_option) { $valid_options[$valid_option['name']] = $valid_option['title']; } $wp_customize->add_control('cleanyetibasic_' . $option_parameter['name'], array('label' => $option_parameter['title'], 'section' => 'cleanyetibasic_' . $option_parameter['tab'], 'settings' => 'theme_cleanyetibasic_options[' . $option_parameter['name'] . ']', 'type' => 'radio', 'choices' => $valid_options)); } else { if ('select' == $option_parameter['type']) { $valid_options = array(); foreach ($option_parameter['valid_options'] as $valid_option) { $valid_options[$valid_option['name']] = $valid_option['title']; } $wp_customize->add_control('cleanyetibasic_' . $option_parameter['name'], array('label' => $option_parameter['title'], 'section' => 'cleanyetibasic_' . $option_parameter['tab'], 'settings' => 'theme_cleanyetibasic_options[' . $option_parameter['name'] . ']', 'type' => 'select', 'choices' => $valid_options)); } else { if ('color-picker' == $option_parameter['type']) { $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'cleanyetibasic_' . $option_parameter['name'], array('label' => $option_parameter['title'], 'section' => 'cleanyetibasic_' . $option_parameter['tab'], 'settings' => 'theme_cleanyetibasic_options[' . $option_parameter['name'] . ']'))); } else { if ('custom' == $option_parameter['type']) { $valid_options = array(); foreach ($option_parameter['valid_options'] as $valid_option) { $valid_options[$valid_option['name']] = $valid_option['title']; } $wp_customize->add_control('cleanyetibasic_' . $option_parameter['name'], array('label' => $option_parameter['title'], 'section' => 'cleanyetibasic_' . $option_parameter['tab'], 'settings' => 'theme_cleanyetibasic_options[' . $option_parameter['name'] . ']', 'type' => 'select', 'choices' => $valid_options)); } } } } } } } }
/** * Callback for get_settings_field() */ function cleanyetibasic_setting_callback($option) { $cleanyetibasic_options = cleanyetibasic_get_options(); $option_parameters = cleanyetibasic_get_option_parameters(); $optionname = $option['name']; $optiontitle = $option['title']; $optiondescription = $option['description']; $fieldtype = $option['type']; $fieldname = 'theme_cleanyetibasic_options[' . $optionname . ']'; // Output checkbox form field markup if ('checkbox' == $fieldtype) { ?> <input type="checkbox" name="<?php echo $fieldname; ?> " <?php checked($cleanyetibasic_options[$optionname]); ?> /> <?php } else { if ('radio' == $fieldtype) { $valid_options = array(); $valid_options = $option['valid_options']; foreach ($valid_options as $valid_option) { ?> <input type="radio" name="<?php echo $fieldname; ?> " <?php checked($valid_option['name'] == $cleanyetibasic_options[$optionname]); ?> value="<?php echo $valid_option['name']; ?> " /> <span> <?php echo $valid_option['title']; ?> <?php if ($valid_option['description']) { ?> <span style="padding-left:5px;"><em><?php echo $valid_option['description']; ?> </em></span> <?php } ?> </span> <br /> <?php } } else { if ('select' == $fieldtype) { $valid_options = array(); $valid_options = $option['valid_options']; ?> <select name="<?php echo $fieldname; ?> "> <?php foreach ($valid_options as $valid_option) { ?> <option <?php selected($valid_option['name'] == $cleanyetibasic_options[$optionname]); ?> value="<?php echo $valid_option['name']; ?> "><?php echo $valid_option['title']; ?> </option> <?php } ?> </select> <?php } else { if ('text' == $fieldtype) { ?> <input type="text" name="<?php echo $fieldname; ?> " value="<?php echo wp_filter_nohtml_kses($cleanyetibasic_options[$optionname]); ?> " /> <?php } else { if ('color-picker' == $fieldtype) { ?> <input type="text" class="cyb-color-field" name="<?php echo $fieldname; ?> " value="<?php echo wp_filter_nohtml_kses($cleanyetibasic_options[$optionname]); ?> " data-default-color="<?php echo $option['default']; ?> "/> <?php } } } } } // Output the setting description ?> <span class="description"><?php echo $optiondescription; ?> </span> <?php }
/** * Display the #access div * * Override: childtheme_override_access */ function cleanyetibasic_access() { global $cleanyetibasic_options; $cleanyetibasic_options = cleanyetibasic_get_options(); $sticky = 'sticky' == $cleanyetibasic_options['header_top_bar_position'] ? ' class="found-sticky"' : ''; $menuclass = $cleanyetibasic_options['header_top_bar_menu_position']; ?> <div id="access"<?php echo $sticky; ?> > <nav class="top-bar" data-topbar> <ul class="title-area"> <!-- Title Area --> <li class="name"> <?php if ('true' == $cleanyetibasic_options['display_top_bar_title']) { ?> <h1><a href="<?php echo esc_url(home_url()); ?> /" title="<?php bloginfo('name'); ?> " rel="home"><?php bloginfo('name'); ?> </a></h1><?php } ?> </li> <!-- Remove the class "menu-icon" to get rid of menu icon. Take out "Menu" to just have icon alone --> <li class="toggle-topbar menu-icon"><a href="#"><?php _e('Menu', 'cleanyetibasic'); ?> </a></li> </ul> <section class="top-bar-section"> <?php if (function_exists("has_nav_menu") && has_nav_menu(apply_filters('cleanyetibasic_primary_menu_id', 'primary-menu'))) { echo wp_nav_menu(cleanyetibasic_nav_menu_args()); } else { echo "<ul class=\"{$menuclass}\">\n"; echo "<li><a href=\"#\">" . __('Primary', 'cleanyetibasic') . "</a></li>\n"; echo "<li><a href=\"#\">" . __('Menu', 'cleanyetibasic') . "</a></li>\n"; echo "<li><a href=\"#\">" . __('Location', 'cleanyetibasic') . "</a></li>\n"; echo "<li><a href=\""; echo home_url() . '/wp-admin/nav-menus.php'; echo "\">" . __('Customize Here...', 'cleanyetibasic') . "</a></li>\n"; echo "</ul>\n"; } ?> </section> </nav> </div><!-- #access --> <?php }
function cleanyetibasic_old_options_update() { $old_options = array(); $old_cpopt = get_option('cleanyetibasic_copyright_option', 'notset'); $old_cptext = get_option('cleanyetibasic_copyright_text', 'notset'); $old_credit = get_option('cleanyetibasic_credit', 'notset'); if ('notset' !== $old_cpopt) { delete_option('cleanyetibasic_copyright_option'); if (1 == $old_cpopt) { $old_options['display_custom_copyright'] = 'true'; } } if ('notset' !== $old_cptext) { $old_options['copyright_text'] = $old_cptext; delete_option('cleanyetibasic_copyright_text'); } if ('notset' !== $old_credit) { delete_option('cleanyetibasic_credit'); if (1 == $old_credit) { $old_options['display_footer_credit'] = 'true'; } } if (!empty($old_options)) { update_option('theme_cleanyetibasic_options', array_merge(cleanyetibasic_get_options(), $old_options)); } }