/**
 * Registers options in the Theme Customizer.
 *
 * Adds theme options to the Theme Customizer by looping through
 * each settings section and implementing controls for option types
 * that are allowed to be added to the Customizer.
 */
function upfw_customize_register($wp_customize)
{
    /**
     * Globalize the variable that holds
     * the Settings Page tab definitions
     *
     * @global	array	Settings Page Tab definitions
     */
    global $up_tabs;
    /**
     * Register each tab section in the Theme Customizer
     *
     * Loops through each option tab and creates a customizer section.
     */
    foreach ($up_tabs as $tab) {
        $tabname = $tab['name'];
        $tabsections = $tab['sections'];
        foreach ($tabsections as $section) {
            $sectionname = $section['name'];
            $sectiontitle = $section['title'];
            $sectiondescription = $section['description'];
            $wp_customize->add_section($sectionname, array('title' => $sectiontitle, 'description' => $sectiondescription));
        }
    }
    $upfw_options = upfw_get_options();
    $upfw_option_parameters = upfw_get_option_parameters();
    foreach ($upfw_option_parameters as $option) {
        if ($option['type'] == 'editor' || $option['type'] == 'multicheck') {
            continue;
        }
        $optionname = $option['name'];
        $theme_id = upfw_get_current_theme_id();
        $optiondb = "theme_{$theme_id}_options[{$optionname}]";
        $option_section_name = $option['section'];
        $default = '';
        if (isset($option['default'])) {
            $default = $option['default'];
        }
        $wp_customize->add_setting($optiondb, array('default' => $default, 'type' => 'option', 'capabilities' => 'edit_theme_options'));
        if ($option['type'] == 'text') {
            $wp_customize->add_control($option['name'], array('label' => $option['title'], 'section' => $option_section_name, 'settings' => $optiondb, 'type' => 'text'));
        }
        if ($option['type'] == 'textarea') {
            $wp_customize->add_control(new UpThemes_Customize_Textarea_Control($wp_customize, $option['name'], array('label' => $option['title'], 'section' => $option_section_name, 'settings' => $optiondb)));
        }
        if ($option['type'] == 'color') {
            $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, $option['name'], array('label' => $option['title'], 'section' => $option_section_name, 'settings' => $optiondb)));
        }
        if ($option['type'] == 'upload' || $option['type'] == 'image') {
            $wp_customize->add_control(new UpThemes_Customize_Image_Control($wp_customize, $option['name'], array('label' => $option['title'], 'section' => $option_section_name, 'settings' => $optiondb, 'context' => $option['name'])));
        }
        if ($option['type'] == 'radio_image') {
            $wp_customize->add_control(new UpThemes_Image_Radio_Control($wp_customize, $option['name'], array('label' => $option['title'], 'section' => $option_section_name, 'settings' => $optiondb, 'choices' => upfw_extract_valid_options_radio_image($option['valid_options']))));
        }
        if ($option['type'] == 'radio' || $option['type'] == 'select') {
            $wp_customize->add_control($option['name'], array('label' => $option['title'], 'section' => $option_section_name, 'settings' => $optiondb, 'type' => $option['type'], 'choices' => upfw_extract_valid_options($option['valid_options'])));
        }
    }
}
Esempio n. 2
0
<?php

$up_options = upfw_get_options();
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" <?php 
language_attributes();
?>
>
<head>
  <title><?php 
if (class_exists('All_in_One_SEO_Pack')) {
    wp_title();
} else {
    if (is_front_page()) {
        echo get_bloginfo('name') . " / " . get_bloginfo('description');
    }
    wp_title('', true, 'left');
}
?>
</title>

  <?php 
if (isset($up_options->favicon)) {
    echo '<link rel="shortcut icon" href="' . $up_options->favicon . '">';
}
?>

  <meta http-equiv="Content-Type" content="<?php 
bloginfo('html_type');
?>
/**
 * Callback for get_settings_field()
 */
function upfw_setting_callback($option)
{
    global $upfw_custom_callbacks;
    $upfw_options = (array) upfw_get_options();
    $option_parameters = upfw_get_option_parameters();
    $optionname = $option['name'];
    $optiontitle = $option['title'];
    $optiondescription = $option['description'];
    $fieldtype = $option['type'];
    $fieldname = "theme_" . upfw_get_current_theme_id() . "_options[{$optionname}]";
    $attr = $option_parameters[$option['name']];
    $value = $upfw_options[$optionname];
    //Determine the type of input field
    switch ($fieldtype) {
        //Render Text Input
        case 'text':
            upfw_text($value, $attr);
            break;
            //Render textarea options
        //Render textarea options
        case 'textarea':
            upfw_textarea($value, $attr);
            break;
            //Render wordpress editor options
        //Render wordpress editor options
        case 'editor':
            upfw_editor($value, $attr);
            break;
            //Render select dropdowns
        //Render select dropdowns
        case 'select':
            upfw_select($value, $attr);
            break;
            //Render radio image dropdowns
        //Render radio image dropdowns
        case 'radio':
            upfw_radio($value, $attr);
            break;
            //Render radio image dropdowns
        //Render radio image dropdowns
        case 'radio_image':
            upfw_radio_image($value, $attr);
            break;
            //Render checkboxes
        //Render checkboxes
        case 'multicheck':
            upfw_multicheck($value, $attr);
            break;
            //Render color picker
        //Render color picker
        case 'color':
            upfw_color($value, $attr);
            break;
            //Render upload image
        //Render upload image
        case 'image':
            upfw_upload($value, $attr);
            break;
            //Render upload
        //Render upload
        case 'upload':
            upfw_upload($value, $attr);
            break;
        default:
            break;
    }
    // Check if there is a callback to envoke for custom fields
    if (isset($upfw_custom_callbacks[$fieldtype])) {
        $custom_field_name = 'theme_' . upfw_get_current_theme_id() . '_options[' . $attr['name'] . ']';
        call_user_func($upfw_custom_callbacks[$fieldtype], $value, $attr, $custom_field_name);
    }
}
 /**
  * compat_upthemes_handler
  *
  * Wrapper to get values from the UpThemes framework
  *
  * @since 1.10
  */
 function compat_upthemes_handler($name)
 {
     $return = '';
     if (function_exists('upfw_init') && function_exists('upfw_get_options')) {
         $wpv_up_options = upfw_get_options();
         $wpv_up_options_array = (array) $wpv_up_options;
         if (isset($wpv_up_options_array[$name])) {
             $return = $wpv_up_options_array[$name];
         }
     }
     return $return;
 }
function agency_home_slide_builder()
{
    global $post;
    $the_slides = agency_get_home_slides();
    $up_options = upfw_get_options();
    if ($the_slides) {
        if (function_exists('wp_nav_menu')) {
            $args = array('container' => false, 'menu_id' => 'home-slides-nav', 'theme_location' => 'home_slides_menu', 'fallback_cb' => 'agency_nav_callout', 'link_before' => '', 'link_after' => '', 'echo' => false, 'depth' => 1, 'walker' => new Agency_Walker_Nav_Menu());
            $slides_nav = wp_nav_menu($args);
        } else {
            $slides_nav = agency_nav_callout();
        }
        ?>

<section class="rotator">
  <div class="wrap">
    <div class="flexslider">
      <ul class="slides">
  <?php 
        foreach ($the_slides as $the_slide) {
            echo "\n";
            echo '          <li class="slide">' . "\n\n";
            echo '            <div class="slide-content-wrapper _1-3 clearfix">' . "\n";
            if ($up_options->enable_carousel_text != 'false') {
                echo '              <div class="slide-content">' . "\n";
                echo '                <h1>' . $the_slide['title'] . "</h1>\n";
                echo '                <div class="teaser">' . $the_slide['blurb'] . "\n";
                if ($the_slide['link']) {
                    echo '                <p><a href="' . $the_slide['link'] . '" title="' . $the_slide['title'] . '">' . __("Read More &rarr;", "agency") . '</a></p>' . "\n";
                }
                echo '                </div>' . "\n";
                echo '                ' . $slides_nav . "\n";
                echo '              </div>' . "\n";
            }
            echo '            </div>' . "\n";
            echo '          ' . $the_slide['image'] . "\n\n";
            echo '        </li>' . "\n";
        }
        ?>

      </ul>
    </div>
  </div><!--/.wrap-->
</section><!--/.rotator-->

<?php 
    }
}
Esempio n. 6
0
function agency_styles()
{
    $up_options = upfw_get_options();
    wp_enqueue_style('style', get_template_directory_uri() . "/style.css", false, THEME_VERSION, 'all');
}
/**
 * Validate and sanitize options on save
 *
 * This function iterates through our options, sanitizes them, and
 * saves them to the database.
 *
 * @uses has_filter()
 * @uses apply_filters()
 *
 */
function upfw_options_validate($input)
{
    global $up_tabs;
    // This is the "whitelist": current settings
    $valid_input = (array) upfw_get_options();
    // Get the array of Theme settings, by Settings Page tab
    $settingsbytab = upfw_get_settings_by_tab();
    // Get the array of option parameters
    $option_parameters = upfw_get_option_parameters();
    // Get the array of option defaults
    $option_defaults = upfw_get_option_defaults();
    // Get list of tabs
    // Determine what type of submit was input
    $submittype = 'submit';
    foreach ($up_tabs as $tab) {
        $resetname = 'reset-' . $tab['name'];
        if (!empty($input[$resetname])) {
            $submittype = 'reset';
        }
    }
    // Determine what tab was input
    $submittab = '';
    foreach ($up_tabs as $tab) {
        $submitname = 'submit-' . $tab['name'];
        $resetname = 'reset-' . $tab['name'];
        if (!empty($input[$submitname]) || !empty($input[$resetname])) {
            $submittab = $tab['name'];
        }
    }
    global $wp_customize;
    // Get settings by tab
    $tabsettings = isset($wp_customize) ? $settingsbytab['all'] : $settingsbytab[$submittab];
    // Loop through each tab setting
    foreach ($tabsettings as $setting) {
        // If no option is selected, set the default
        $valid_input[$setting] = !isset($input[$setting]) ? $option_defaults[$setting] : $input[$setting];
        // If submit, validate/sanitize $input
        if ('submit' == $submittype) {
            // Get the setting details from the defaults array
            $option = $option_parameters[$setting];
            // Get the array of valid options, if applicable
            $valid_options = isset($option['valid_options']) ? $option['valid_options'] : false;
            if (!isset($option['name'])) {
                continue;
            }
            if (!isset($option['type'])) {
                continue;
            }
            $setting = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($option['name']));
            // Set checkbox to false if it wasn't sent in the $_POST
            if ('checkbox' == $option['type'] && !isset($input[$setting])) {
                $input[$setting] = false;
            }
            // Set each item in the multicheck to false if it wasn't sent in the $_POST
            if ('multicheck' == $option['type'] && !isset($input[$setting])) {
                foreach ($option['valid_options'] as $key => $value) {
                    $input[$setting][$key] = false;
                }
            }
            // For a value to be submitted to database it must pass through a sanitization filter
            if (has_filter('upfw_sanitize_' . $option['type'])) {
                $clean[$setting] = apply_filters('upfw_sanitize_' . $option['type'], $input[$setting], $option);
            }
        } elseif ('reset' == $submittype) {
            // Set $setting to the default value
            $clean[$setting] = $option_defaults[$setting];
        }
    }
    // Hook to run after validation
    do_action('upfw_after_validate', $clean);
    return $clean;
}
function register_global_up_options_variable()
{
    upfw_get_options();
    global $up_options;
}
/**
 * Callback for get_settings_field()
 */
function upfw_setting_callback($option)
{
    $upfw_options = upfw_get_options();
    //print_r($upfw_options);
    $option_parameters = upfw_get_option_parameters();
    $optionname = $option['name'];
    $optiontitle = $option['title'];
    $optiondescription = $option['description'];
    $fieldtype = $option['type'];
    $fieldname = "theme_" . get_current_theme_id() . "_options[{$optionname}]";
    $attr = $option_parameters[$option['name']];
    $value = $upfw_options[$optionname];
    //Determine the type of input field
    switch ($fieldtype) {
        //Render Text Input
        case 'text':
            upfw_text_field($value, $attr);
            break;
            //Render Custom User Text Inputs
        //Render Custom User Text Inputs
        case 'text_list':
            upfw_text_list($value, $attr);
            break;
            //Render textarea options
        //Render textarea options
        case 'textarea':
            upfw_textarea($value, $attr);
            break;
            //Render select dropdowns
        //Render select dropdowns
        case 'select':
            upfw_select($value, $attr);
            break;
            //Render multple selects
        //Render multple selects
        case 'multiple':
            upfw_multiple($value, $attr);
            break;
            //Render checkboxes
        //Render checkboxes
        case 'checkbox':
            upfw_checkbox($value, $attr);
            break;
            //Render color picker
        //Render color picker
        case 'color':
            upfw_color($value, $attr);
            break;
            //Render upload image
        //Render upload image
        case 'image':
            upfw_image($value, $attr);
            break;
            //Render category dropdown
        //Render category dropdown
        case 'category':
            upfw_category($value, $attr);
            break;
            //Render categories multiple select
        //Render categories multiple select
        case 'categories':
            upfw_categories($value, $attr);
            break;
            //Render page dropdown
        //Render page dropdown
        case 'page':
            upfw_page($value, $attr);
            break;
            //Render pages muliple select
        //Render pages muliple select
        case 'pages':
            upfw_pages($value, $attr);
            break;
            //Render Form Button
        //Render Form Button
        case 'submit':
            upfw_submit($value, $attr);
            break;
            //Render taxonomy multiple select
        //Render taxonomy multiple select
        case 'taxonomy':
            upfw_taxonomy($value, $attr);
            break;
            //Render Typography Selector
        //Render Typography Selector
        case 'typography':
            upfw_typography($value, $attr);
            break;
            //Render Style Selector
        //Render Style Selector
        case 'styles':
            upfw_style($value, $attr);
            break;
            //Render Form Button
        //Render Form Button
        case 'button':
            upfw_button($value, $attr);
            break;
            //Render Text Input
        //Render Text Input
        case 'divider':
            upfw_divider($value, $attr);
            break;
            //Render Layouts
        //Render Layouts
        case 'layouts':
            upfw_layouts($value, $attr);
            break;
        default:
            break;
    }
}