Example #1
0
/**
 * Hooks pro options into core options
 *
 * Creates and array of options that get added to the relevant sections
 *
 * @key This must match the id of the section you want the options to appear in
 *
 * @title Title on the left hand side of the options
 * @subtitle Displays underneath main title on left hand side
 * @heading Right hand side above input
 * @type The type of input e.g. text, textarea, checkbox
 * @id The options id
 * @description Instructions on what to enter in input
 * @placeholder The placeholder for text and textarea
 * @options array used by select dropdown lists
 * @button Text for button used by uploader
 * @active Text used for plugin that has to be installed
 * @activate Text used for installed plugin
 * @installed Text used for activated plugin
 * @url url param for the plugin download
 * @settings url param for settings page
 * @width option 'full' sets up full width option
 */
function responsive_pro_options($options)
{
    // remove theme elements' options
    unset($options['theme_elements']);
    $options_home_page[] = array('title' => __('Featured Area Layouts', 'responsive'), 'subtitle' => '', 'heading' => '', 'id' => 'featured_area_layout', 'type' => 'select', 'options' => responsive_get_valid_featured_area_layouts());
    $options['home_page'] = array_merge($options['home_page'], $options_home_page);
    $new_options = array('personalize' => array(array('title' => __('Favicon', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'upload', 'id' => 'favicon', 'description' => __('maximum width and height 32px', 'responsive'), 'placeholder' => '', 'button' => __('Upload', 'responsive')), array('title' => __('Apple Touch Icon', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'upload', 'id' => 'apple_touch_icon', 'description' => '', 'placeholder' => '', 'button' => __('Upload', 'responsive')), array('title' => __('Disable breadcrumb list?', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'checkbox', 'id' => 'breadcrumb', 'description' => __('check to disable', 'responsive'), 'placeholder' => ''), array('title' => __('Enable minified css?', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'checkbox', 'id' => 'minified_css', 'description' => __('check to enable', 'responsive'), 'placeholder' => ''), array('title' => __('Disable Call to Action Button?', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'checkbox', 'id' => 'cta_button', 'description' => __('check to disable', 'responsive'), 'placeholder' => ''), array('title' => __('Custom mobile menu title', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'text', 'id' => 'custom_mobile_menu_title', 'description' => __('Enter a custom mobile menu title', 'responsive'), 'placeholder' => '')), 'templates' => array(array('title' => __('Excerpt Text', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'text', 'id' => 'excerpts_text', 'description' => '', 'placeholder' => __('Read More...', 'responsive')), array('title' => __('Excerpt Length', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'text', 'id' => 'excerpts_length', 'description' => '', 'placeholder' => __('50', 'responsive')), array('title' => '<strong>' . __('Page:', 'responsive') . '</strong>', 'subtitle' => '', 'heading' => '', 'type' => 'description', 'id' => '', 'description' => ''), array('title' => __('Default Static Page Layout', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'select', 'id' => 'static_page_layout_default', 'options' => Responsive_Options::valid_layouts()), array('title' => '<strong>' . __('Blog Post Page:', 'responsive') . '</strong>', 'subtitle' => '', 'heading' => '', 'type' => 'description', 'id' => '', 'description' => ''), array('title' => __('Default Blog Posts Index Layout', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'select', 'id' => 'blog_posts_index_layout_default', 'options' => Responsive_Options::valid_layouts()), array('title' => __('Blog Title Toggle', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'checkbox', 'id' => 'blog_post_title_toggle', 'description' => ''), array('title' => __('Title Text', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'text', 'id' => 'blog_post_title_text', 'description' => '', 'placeholder' => __('Blog', 'responsive')), array('title' => __('Post Excerpts', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'checkbox', 'id' => 'blog_post_excerpts', 'description' => ''), array('title' => __('Featured Images', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'checkbox', 'id' => 'blog_featured_images', 'description' => ''), array('title' => __('Post Byline Author', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'checkbox', 'id' => 'blog_byline_author', 'description' => ''), array('title' => __('Post Byline Categories', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'checkbox', 'id' => 'blog_byline_categories', 'description' => ''), array('title' => __('Post Byline Date', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'checkbox', 'id' => 'blog_byline_date', 'description' => ''), array('title' => __('Post Byline Comments', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'checkbox', 'id' => 'blog_byline_comments', 'description' => ''), array('title' => __('Post Byline Tags', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'checkbox', 'id' => 'blog_byline_tags', 'description' => ''), array('title' => '<strong>' . __('Single post page:', 'responsive') . '</strong>', 'subtitle' => '', 'heading' => '', 'type' => 'description', 'id' => '', 'description' => ''), array('title' => __('Default Single Blog Post Layout', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'select', 'id' => 'single_post_layout_default', 'options' => Responsive_Options::valid_layouts()), array('title' => __('Featured Images', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'checkbox', 'id' => 'single_featured_images', 'description' => ''), array('title' => __('Post Byline Author', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'checkbox', 'id' => 'single_byline_author', 'description' => ''), array('title' => __('Post Byline Categories', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'checkbox', 'id' => 'single_byline_categories', 'description' => ''), array('title' => __('Post Byline Date', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'checkbox', 'id' => 'single_byline_date', 'description' => ''), array('title' => __('Post Byline Comments', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'checkbox', 'id' => 'single_byline_comments', 'description' => ''), array('title' => __('Post Byline Tags', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'checkbox', 'id' => 'single_byline_tags', 'description' => ''), array('title' => '<strong>' . __('Archive page:', 'responsive') . '</strong>', 'subtitle' => '', 'heading' => '', 'type' => 'description', 'id' => '', 'description' => ''), array('title' => __('Post Excerpts', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'checkbox', 'id' => 'archive_post_excerpts', 'description' => ''), array('title' => __('Featured Images', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'checkbox', 'id' => 'archive_featured_images', 'description' => ''), array('title' => __('Post Byline Author', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'checkbox', 'id' => 'archive_byline_author', 'description' => ''), array('title' => __('Post Byline Categories', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'checkbox', 'id' => 'archive_byline_categories', 'description' => ''), array('title' => __('Post Byline Date', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'checkbox', 'id' => 'archive_byline_date', 'description' => ''), array('title' => __('Post Byline Comments', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'checkbox', 'id' => 'archive_byline_comments', 'description' => ''), array('title' => __('Post Byline Tags', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'checkbox', 'id' => 'archive_byline_tags', 'description' => ''), array('title' => '<strong>' . __('Search Page:', 'responsive') . '</strong>', 'subtitle' => '', 'heading' => '', 'type' => 'description', 'id' => '', 'description' => ''), array('title' => __('Post Excerpts', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'checkbox', 'id' => 'search_post_excerpts', 'description' => ''), array('title' => '<strong>' . __('404 Page:', 'responsive') . '</strong>', 'subtitle' => '', 'heading' => '', 'type' => 'description', 'id' => '', 'description' => ''), array('title' => __('404 Title', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'text', 'id' => '404_title', 'description' => '', 'placeholder' => __('404 Error', 'responsive')), array('title' => __('404 Content', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'text', 'id' => '404_content', 'description' => '', 'placeholder' => __('Sorry, no content found', 'responsive'))), 'plugins' => array(array('title' => '', 'subtitle' => '', 'active' => __('Events Plugin Settings', 'responsive'), 'activate' => __('Please activate The Events Calendar plugin', 'responsive'), 'install' => __('Install Events Calendar Plugin', 'responsive'), 'type' => 'plugins', 'id' => 'the-events-calendar', 'url' => 'the-events-calendar/the-events-calendar.php', 'settings_page' => 'edit.php?post_type=tribe_events&page=tribe-events-calendar', 'width' => 'full'), array('title' => '', 'subtitle' => '', 'active' => __('WooCommerce Settings', 'responsive'), 'activate' => __('Please activate WooCommerce plugin', 'responsive'), 'install' => __('Install WooCommerce Plugin', 'responsive'), 'type' => 'plugins', 'id' => 'woocommerce', 'url' => 'woocommerce/woocommerce.php', 'settings_page' => 'admin.php?page=wc-settings', 'width' => 'full'), array('title' => '', 'subtitle' => '', 'active' => __('BBPress Settings', 'responsive'), 'activate' => __('Please activate BBPress plugin', 'responsive'), 'install' => __('Install BBPress Plugin', 'responsive'), 'type' => 'plugins', 'id' => 'bbpress', 'url' => 'bbpress/bbpress.php', 'settings_page' => 'options-general.php?page=bbpress', 'width' => 'full'), array('title' => '', 'subtitle' => '', 'active' => __('Digital Downloads Settings', 'responsive'), 'activate' => __('Please activate Easy Digital Downloads plugin', 'responsive'), 'install' => __('Install Easy Digital Downloads Plugin', 'responsive'), 'type' => 'plugins', 'id' => 'easy-digital-downloads', 'url' => 'easy-digital-downloads/easy-digital-downloads.php', 'settings_page' => 'edit.php?post_type=download&page=edd-settings', 'width' => 'full')));
    $new_options = array_merge($new_options, $options);
    return $new_options;
}
 /**
  * Pulls in the arrays for the options and sets up the responsive options
  *
  * @param $options array
  */
 public function __construct($options)
 {
     $this->options = $options;
     $this->options_only = $this->get_options_only($this->options);
     $this->responsive_mobile_options = get_option('responsive_mobile_theme_options');
     $this->default_options = $this->get_options_defaults($this->options_only);
     self::$static_responsive_mobile_options = $this->responsive_mobile_options;
     self::$static_default_options = $this->default_options;
     $this->attributes['onclick'] = 'return confirm("' . __('Do you want to restore the default settings?', 'responsive-mobile') . __('All theme settings will be lost!', 'responsive-mobile') . __('Click OK to restore.', 'responsive-mobile') . '")';
     add_action('admin_print_styles-appearance_page_theme_options', array($this, 'admin_enqueue_scripts'));
     add_action('admin_init', array($this, 'theme_options_init'));
     add_action('admin_menu', array($this, 'theme_page_init'));
 }
Example #3
0
/**
 * Create the options page
 */
function responsive_theme_options_do_page()
{
    if (!isset($_REQUEST['settings-updated'])) {
        $_REQUEST['settings-updated'] = false;
    }
    // Set confirmaton text for restore default option as attributes of submit_button().
    $attributes['onclick'] = 'return confirm("' . __('Do you want to restore? \\nAll theme settings will be lost! \\nClick OK to Restore.', 'responsive') . '")';
    ?>

    <div class="wrap">
    <?php 
    /**
     * < 3.4 Backward Compatibility
     */
    ?>
    <?php 
    $theme_name = function_exists('wp_get_theme') ? wp_get_theme() : get_current_theme();
    ?>
    <?php 
    screen_icon();
    echo "<h2>" . $theme_name . " " . __('Theme Options', 'responsive') . "</h2>";
    ?>


    <?php 
    if (false !== $_REQUEST['settings-updated']) {
        ?>
        <div class="updated fade"><p><strong><?php 
        _e('Options Saved', 'responsive');
        ?>
</strong></p></div>
    <?php 
    }
    ?>

    <?php 
    responsive_theme_options();
    // Theme Options Hook
    ?>

    <?php 
    /**
     * Create array of option sections
     *
     * @Title The display title
     * @id The id that the option array references so the options display in the correct section
     */
    $sections = apply_filters('responsive_option_sections_filter', array(array('title' => __('Theme Elements', 'responsive'), 'id' => 'theme_elements'), array('title' => __('Logo Upload', 'responsive'), 'id' => 'logo_upload'), array('title' => __('Home Page', 'responsive'), 'id' => 'home_page'), array('title' => __('Default Layouts', 'responsive'), 'id' => 'layouts'), array('title' => __('Social Icons', 'responsive'), 'id' => 'social'), array('title' => __('CSS Styles', 'responsive'), 'id' => 'css'), array('title' => __('Scripts', 'responsive'), 'id' => 'scripts')));
    /**
     * Creates and array of options that get added to the relevant sections
     *
     * @key This must match the id of the section you want the options to appear in
     *
     * @title Title on the left hand side of the options
     * @subtitle Displays underneath main title on left hand side
     * @heading Right hand side above input
     * @type The type of input e.g. text, textarea, checkbox
     * @id The options id
     * @description Instructions on what to enter in input
     * @placeholder The placeholder for text and textarea
     * @options array used by select dropdown lists
     */
    $options = apply_filters('responsive_options_filter', array('theme_elements' => array(array('title' => __('Disable breadcrumb list?', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'checkbox', 'id' => 'breadcrumb', 'description' => __('check to disable', 'responsive'), 'placeholder' => ''), array('title' => __('Disable Call to Action Button?', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'checkbox', 'id' => 'cta_button', 'description' => __('check to disable', 'responsive'), 'placeholder' => '')), 'logo_upload' => array(array('title' => __('Custom Header', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'description', 'id' => '', 'description' => __('Need to replace or remove default logo?', 'responsive') . sprintf(__(' <a href="%s">Click here</a>.', 'responsive'), admin_url('themes.php?page=custom-header')), 'placeholder' => '')), 'home_page' => array(array('title' => __('Enable Custom Front Page', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'checkbox', 'id' => 'front_page', 'description' => sprintf(__('Overrides the WordPress %1sfront page option%2s', 'responsive'), '<a href="options-reading.php">', '</a>'), 'placeholder' => ''), array('title' => __('Headline', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'text', 'id' => 'home_headline', 'description' => __('Enter your headline', 'responsive'), 'placeholder' => __('Hello, World!', 'responsive')), array('title' => __('Subheadline', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'text', 'id' => 'home_subheadline', 'description' => __('Enter your subheadline', 'responsive'), 'placeholder' => __('Your H2 subheadline here', 'responsive')), array('title' => __('Content Area', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'textarea', 'id' => 'home_content_area', 'description' => __('Enter your content', 'responsive'), 'placeholder' => __('Your title, subtitle and this very content is editable from Theme Option. Call to Action button and its destination link as well. Image on your right can be an image or even YouTube video if you like.', 'responsive')), array('title' => __('Call to Action (URL)', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'text', 'id' => 'cta_url', 'description' => __('Enter your call to action URL', 'responsive'), 'placeholder' => '#nogo'), array('title' => __('Call to Action (Text)', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'text', 'id' => 'cta_text', 'description' => __('Enter your call to action text', 'responsive'), 'placeholder' => __('Call to Action', 'responsive')), array('title' => __('Featured Content', 'responsive'), 'subtitle' => '<a class="help-links" href="' . esc_url('http://cyberchimps.com/guide/responsive/') . '" title="' . esc_attr__('See Docs', 'responsive') . '" target="_blank">' . __('See Docs', 'responsive') . '</a>', 'heading' => '', 'type' => 'textarea', 'id' => 'featured_content', 'description' => __('Enter your call to action text', 'responsive'), 'placeholder' => "<img class='aligncenter' src='" . get_template_directory_uri() . "'/core/images/featured-image.png' width='440' height='300' alt='' />")), 'layouts' => array(array('title' => __('Default Static Page Layout', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'select', 'id' => 'static_page_layout_default', 'description' => '', 'placeholder' => '', 'options' => Responsive_Options::valid_layouts()), array('title' => __('Default Single Blog Post Layout', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'select', 'id' => 'single_post_layout_default', 'description' => '', 'placeholder' => '', 'options' => Responsive_Options::valid_layouts()), array('title' => __('Default Blog Posts Index Layout', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'select', 'id' => 'blog_posts_index_layout_default', 'description' => '', 'placeholder' => '', 'options' => Responsive_Options::valid_layouts())), 'social' => array(array('title' => __('Twitter', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'text', 'id' => 'twitter_uid', 'description' => __('Enter your Twitter URL', 'responsive'), 'placeholder' => ''), array('title' => __('Facebook', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'text', 'id' => 'facebook_uid', 'description' => __('Enter your Facebook URL', 'responsive'), 'placeholder' => ''), array('title' => __('LinkedIn', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'text', 'id' => 'linkedin_uid', 'description' => __('Enter your LinkedIn URL', 'responsive'), 'placeholder' => ''), array('title' => __('YouTube', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'text', 'id' => 'youtube_uid', 'description' => __('Enter your YouTube URL', 'responsive'), 'placeholder' => ''), array('title' => __('StumbleUpon', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'text', 'id' => 'stumble_uid', 'description' => __('Enter your StumbleUpon URL', 'responsive'), 'placeholder' => ''), array('title' => __('RSS Feed', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'text', 'id' => 'rss_uid', 'description' => __('Enter your RSS Feed URL', 'responsive'), 'placeholder' => ''), array('title' => __('Google+', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'text', 'id' => 'google_plus_uid', 'description' => __('Enter your Google+ URL', 'responsive'), 'placeholder' => ''), array('title' => __('Instagram', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'text', 'id' => 'instagram_uid', 'description' => __('Enter your Instagram URL', 'responsive'), 'placeholder' => ''), array('title' => __('Pinterest', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'text', 'id' => 'pinterest_uid', 'description' => __('Enter your Pinterest URL', 'responsive'), 'placeholder' => ''), array('title' => __('Yelp!', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'text', 'id' => 'yelp_uid', 'description' => __('Enter your Yelp! URL', 'responsive'), 'placeholder' => ''), array('title' => __('Vimeo', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'text', 'id' => 'vimeo_uid', 'description' => __('Enter your Vimeo URL', 'responsive'), 'placeholder' => ''), array('title' => __('foursquare', 'responsive'), 'subtitle' => '', 'heading' => '', 'type' => 'text', 'id' => 'foursquare_uid', 'description' => __('Enter your foursquare URL', 'responsive'), 'placeholder' => '')), 'css' => array(array('title' => __('Custom CSS Styles', 'responsive'), 'subtitle' => '<a class="help-links" href="https://developer.mozilla.org/en/CSS" title="CSS Tutorial" target="_blank">' . __('CSS Tutorial', 'responsive') . '</a>', 'heading' => '', 'type' => 'textarea', 'id' => 'responsive_inline_css', 'description' => __('Enter your custom CSS styles.', 'responsive'), 'placeholder' => '')), 'scripts' => array(array('title' => __('Custom Scripts for Header and Footer', 'responsive'), 'subtitle' => '<a class="help-links" href="http://codex.wordpress.org/Using_Javascript" title="Quick Tutorial" target="_blank">' . __('Quick Tutorial', 'responsive') . '</a>', 'heading' => __('Embeds to header.php &darr;', 'responsive'), 'type' => 'textarea', 'id' => 'responsive_inline_js_head', 'description' => __('Enter your custom header script.', 'responsive'), 'placeholder' => ''), array('title' => '', 'subtitle' => '', 'heading' => __('Embeds to footer.php &darr;', 'responsive'), 'type' => 'textarea', 'id' => 'responsive_inline_js_footer', 'description' => __('Enter your custom footer script.', 'responsive'), 'placeholder' => ''))));
    if (class_exists('Responsive_Pro_Options')) {
        $display = new Responsive_Pro_Options($sections, $options);
    } else {
        $display = new Responsive_Options($sections, $options);
    }
    ?>
    <form method="post" action="options.php">
        <?php 
    settings_fields('responsive_options');
    ?>
        <?php 
    global $responsive_options;
    ?>

        <div id="rwd" class="grid col-940">
            <?php 
    echo $display->render_display();
    ?>
        </div>
        <!-- end of .grid col-940 -->
    </form>
    </div><!-- wrap -->
<?php 
}
function responsive_sanitize_default_layouts($input)
{
    $output = '';
    $option = Responsive_Options::valid_layouts();
    if (array_key_exists($input, $option)) {
        $output = $input;
    }
    return $output;
}