Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * A unique identifier is defined to store the options in the database and reference them from the theme.
- * By default it uses the theme name, in lowercase and without spaces, but this can be changed if needed.
- * If the identifier changes, it'll appear as if the options have been reset.
- *
- */
- function optionsframework_option_name() {
- // This gets the theme name from the stylesheet (lowercase and without spaces)
- $themename = get_option( 'stylesheet' );
- $themename = preg_replace("/\W/", "_", strtolower($themename) );
- $optionsframework_settings = get_option('optionsframework');
- $optionsframework_settings['id'] = $themename;
- update_option('optionsframework', $optionsframework_settings);
- // echo $themename;
- }
- /**
- * Defines an array of options that will be used to generate the settings page and be saved in the database.
- * When creating the 'id' fields, make sure to use all lowercase and no spaces.
- *
- */
- function optionsframework_options() {
- // Typography Options
- $typography_options = array(
- 'sizes' => array( '6','12','14','16','20' ),
- 'faces' => array( 'Helvetica Neue' => 'Helvetica Neue','Arial' => 'Arial' ),
- 'styles' => array( 'normal' => 'Normal','bold' => 'Bold' ),
- 'color' => false
- );
- // Pull all the categories into an array
- $options_categories = array();
- $options_categories_obj = get_categories();
- foreach ($options_categories_obj as $category) {
- $options_categories[$category->cat_ID] = $category->cat_name;
- }
- // Pull all tags into an array
- $options_tags = array();
- $options_tags_obj = get_tags();
- foreach ( $options_tags_obj as $tag ) {
- $options_tags[$tag->term_id] = $tag->name;
- }
- // Pull all the pages into an array
- $options_pages = array();
- $options_pages_obj = get_pages('sort_column=post_parent,menu_order');
- $options_pages[''] = 'Select a page:';
- foreach ($options_pages_obj as $page) {
- $options_pages[$page->ID] = $page->post_title;
- }
- // If using image radio buttons, define a directory path
- $imagepath = get_template_directory_uri() . '/images/';
- $options = array();
- /**
- * Returns an array of system fonts
- * Feel free to edit this, update the font fallbacks, etc.
- */
- function options_typography_get_os_fonts() {
- // OS Font Defaults
- $os_faces = array(
- 'Arial, sans-serif' => 'Arial',
- '"Avant Garde", sans-serif' => 'Avant Garde',
- 'Cambria, Georgia, serif' => 'Cambria',
- 'Copse, sans-serif' => 'Copse',
- 'Garamond, "Hoefler Text", Times New Roman, Times, serif' => 'Garamond',
- 'Georgia, serif' => 'Georgia',
- '"Helvetica Neue", Helvetica, sans-serif' => 'Helvetica Neue',
- 'Tahoma, Geneva, sans-serif' => 'Tahoma'
- );
- return $os_faces;
- }
- /**
- * Returns a select list of Google fonts
- * Feel free to edit this, update the fallbacks, etc.
- */
- function options_typography_get_google_fonts() {
- // Google Font Defaults
- $google_faces = array(
- 'Arvo, serif' => 'Arvo',
- 'Copse, sans-serif' => 'Copse',
- 'Droid Sans, sans-serif' => 'Droid Sans',
- 'Droid Serif, serif' => 'Droid Serif',
- 'Lobster, cursive' => 'Lobster',
- 'Nobile, sans-serif' => 'Nobile',
- 'Open Sans, sans-serif' => 'Open Sans',
- 'Oswald, sans-serif' => 'Oswald',
- 'Pacifico, cursive' => 'Pacifico',
- 'Rokkitt, serif' => 'Rokkit',
- 'PT Sans, sans-serif' => 'PT Sans',
- 'Quattrocento, serif' => 'Quattrocento',
- 'Raleway, cursive' => 'Raleway',
- 'Ubuntu, sans-serif' => 'Ubuntu',
- 'Yanone Kaffeesatz, sans-serif' => 'Yanone Kaffeesatz'
- );
- return $google_faces;
- }
- $typography_mixed_fonts = array_merge( options_typography_get_os_fonts() , options_typography_get_google_fonts() );
- asort($typography_mixed_fonts);
- /**
- * Checks font options to see if a Google font is selected.
- * If so, options_typography_enqueue_google_font is called to enqueue the font.
- * Ensures that each Google font is only enqueued once.
- */
- if ( !function_exists( 'options_typography_google_fonts' ) ) {
- function options_typography_google_fonts() {
- $all_google_fonts = array_keys( options_typography_get_google_fonts() );
- // Define all the options that possibly have a unique Google font
- $google_font = of_get_option('google_font', 'Rokkitt, serif');
- $google_mixed = of_get_option('google_mixed', false);
- $google_mixed_2 = of_get_option('google_mixed_2', 'Arvo, serif');
- // Get the font face for each option and put it in an array
- $selected_fonts = array(
- $google_font['face'],
- $google_mixed['face'],
- $google_mixed_2['face'] );
- // Remove any duplicates in the list
- $selected_fonts = array_unique($selected_fonts);
- // Check each of the unique fonts against the defined Google fonts
- // If it is a Google font, go ahead and call the function to enqueue it
- foreach ( $selected_fonts as $font ) {
- if ( in_array( $font, $all_google_fonts ) ) {
- options_typography_enqueue_google_font($font);
- }
- }
- }
- }
- add_action( 'wp_enqueue_scripts', 'options_typography_google_fonts' );
- /**
- * Enqueues the Google $font that is passed
- */
- function options_typography_enqueue_google_font($font) {
- $font = explode(',', $font);
- $font = $font[0];
- // Certain Google fonts need slight tweaks in order to load properly
- // Like our friend "Raleway"
- if ( $font == 'Raleway' )
- $font = 'Raleway:100';
- $font = str_replace(" ", "+", $font);
- wp_enqueue_style( "options_typography_$font", "http://fonts.googleapis.com/css?family=$font", false, null, 'all' );
- }
- /*
- * Outputs the selected option panel styles inline into the <head>
- */
- function options_typography_styles() {
- $output = '';
- $input = '';
- if ( of_get_option( 'google_font' ) ) {
- $input = of_get_option( 'google_font' );
- $output .= options_typography_font_styles( of_get_option( 'google_font' ) , '.google-font');
- }
- if ( $output != '' ) {
- $output = "\n<style>\n" . $output . "</style>\n";
- echo $output;
- }
- }
- add_action('wp_head', 'options_typography_styles');
- /*
- * Returns a typography option in a format that can be outputted as inline CSS
- */
- function options_typography_font_styles($option, $selectors) {
- $output = $selectors . ' {';
- $output .= ' color:' . $option['color'] .'; ';
- $output .= 'font-family:' . $option['face'] . '; ';
- $output .= 'font-weight:' . $option['style'] . '; ';
- $output .= 'font-size:' . $option['size'] . '; ';
- $output .= '}';
- $output .= "\n";
- return $output;
- }
- // Settings Tab 1
- $options[] = array(
- 'name' => __('Branding Settings', 'options_check'),
- 'type' => 'heading');
- //image uploader
- $options[] = array(
- 'name' => __('Upload Your Logo', 'options_check'),
- 'desc' => __('Upload your company logo here .', 'options_check'),
- 'id' => 'logo_uploader',
- 'type' => 'upload');
- //image uploader
- $options[] = array(
- 'name' => __('Upload Your Favicon', 'options_check'),
- 'desc' => __('Upload your facicon here .', 'options_check'),
- 'id' => 'favicon_uploader',
- 'type' => 'upload');
- //colour picker
- $options[] = array(
- 'name' => __('Primary Colour', 'options_check'),
- 'desc' => __('Choose primary colour', 'options_check'),
- 'id' => 'primary_colorpicker',
- 'std' => '',
- 'type' => 'color' );
- //colour picker
- $options[] = array(
- 'name' => __('Secondary Colour', 'options_check'),
- 'desc' => __('Choose secondary colour', 'options_check'),
- 'id' => 'secondary_colorpicker',
- 'std' => '',
- 'type' => 'color' );
- /* ******** Fonts ************ */
- /** set text settings tab ***/
- $options[] = array(
- 'name' => __('Text Settings', 'options_check'),
- 'type' => 'heading');
- //Headings
- $options[] = array( 'name' => 'Headings Text',
- 'desc' => 'Choose options for all your sites headings.',
- 'id' => 'heading_text',
- 'std' => array( 'size' => '32px', 'face' => 'Tahoma, Geneva, sans-serif', 'color' => '#999999'),
- 'type' => 'typography',
- 'options' => array(
- 'faces' => $typography_mixed_fonts,
- 'styles' => array( 'normal' => 'Normal', 'bold' => 'Bold', 'bolder' => 'Bolder', 'lighter' => 'Lighter',)
- )
- );
- //Body text
- $options[] = array( 'name' => 'Main Text',
- 'desc' => 'Choose options for your sites body text.',
- 'id' => 'main_text',
- 'std' => array( 'size' => '16px', 'face' => 'Tahoma, Geneva, sans-serif', 'color' => '#000000'),
- 'type' => 'typography',
- 'options' => array(
- 'faces' => $typography_mixed_fonts,
- 'styles' => false )
- );
- //Links
- $options[] = array( 'name' => 'Link Colour',
- 'desc' => 'Choose options for all your sites links.',
- 'id' => 'link_typography',
- 'std' => array( 'size' => '16px', 'face' => 'Tahoma, Geneva, sans-serif', 'color' => '#999999'),
- 'type' => 'typography',
- 'options' => array(
- 'faces' => $typography_mixed_fonts,
- 'styles' => array( 'normal' => 'Normal', 'bold' => 'Bold', 'bolder' => 'Bolder', 'lighter' => 'Lighter',)
- )
- );
- // Menu Text colour
- $options[] = array( 'name' => 'Menu Text colour',
- 'desc' => 'Choose menu link text options',
- 'id' => 'menu_links',
- 'std' => array( 'size' => '16px', 'face' => 'Tahoma, Geneva, sans-serif', 'color' => '#ffffff'),
- 'type' => 'typography',
- 'options' => array(
- 'faces' => $typography_mixed_fonts,
- 'styles' => array( 'normal' => 'Normal', 'bold' => 'Bold', 'bolder' => 'Bolder', 'lighter' => 'Lighter',)
- )
- );
- return $options;
- }
- /******** END OF FONTS ***************/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement