Advertisement
Guest User

options file spacechimp

a guest
Jul 25th, 2013
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.26 KB | None | 0 0
  1. <?php
  2. /**
  3.  * A unique identifier is defined to store the options in the database and reference them from the theme.
  4.  * By default it uses the theme name, in lowercase and without spaces, but this can be changed if needed.
  5.  * If the identifier changes, it'll appear as if the options have been reset.
  6.  *
  7.  */
  8.  
  9. function optionsframework_option_name() {
  10.  
  11.     // This gets the theme name from the stylesheet (lowercase and without spaces)
  12.     $themename = get_option( 'stylesheet' );
  13.     $themename = preg_replace("/\W/", "_", strtolower($themename) );
  14.  
  15.     $optionsframework_settings = get_option('optionsframework');
  16.     $optionsframework_settings['id'] = $themename;
  17.     update_option('optionsframework', $optionsframework_settings);
  18.  
  19.     // echo $themename;
  20. }
  21.  
  22. /**
  23.  * Defines an array of options that will be used to generate the settings page and be saved in the database.
  24.  * When creating the 'id' fields, make sure to use all lowercase and no spaces.
  25.  *
  26.  */
  27.  
  28. function optionsframework_options() {
  29.    
  30.     // Typography Options
  31.     $typography_options = array(
  32.         'sizes' => array( '6','12','14','16','20' ),
  33.         'faces' => array( 'Helvetica Neue' => 'Helvetica Neue','Arial' => 'Arial' ),
  34.         'styles' => array( 'normal' => 'Normal','bold' => 'Bold' ),
  35.         'color' => false
  36.     );
  37.  
  38.     // Pull all the categories into an array
  39.     $options_categories = array();
  40.     $options_categories_obj = get_categories();
  41.     foreach ($options_categories_obj as $category) {
  42.         $options_categories[$category->cat_ID] = $category->cat_name;
  43.     }
  44.    
  45.     // Pull all tags into an array
  46.     $options_tags = array();
  47.     $options_tags_obj = get_tags();
  48.     foreach ( $options_tags_obj as $tag ) {
  49.         $options_tags[$tag->term_id] = $tag->name;
  50.     }
  51.  
  52.     // Pull all the pages into an array
  53.     $options_pages = array();
  54.     $options_pages_obj = get_pages('sort_column=post_parent,menu_order');
  55.     $options_pages[''] = 'Select a page:';
  56.     foreach ($options_pages_obj as $page) {
  57.         $options_pages[$page->ID] = $page->post_title;
  58.     }
  59.  
  60.     // If using image radio buttons, define a directory path
  61.     $imagepath =  get_template_directory_uri() . '/images/';
  62.  
  63.     $options = array();
  64.  
  65. /**
  66.  * Returns an array of system fonts
  67.  * Feel free to edit this, update the font fallbacks, etc.
  68.  */
  69.  
  70. function options_typography_get_os_fonts() {
  71.     // OS Font Defaults
  72.     $os_faces = array(
  73.         'Arial, sans-serif' => 'Arial',
  74.         '"Avant Garde", sans-serif' => 'Avant Garde',
  75.         'Cambria, Georgia, serif' => 'Cambria',
  76.         'Copse, sans-serif' => 'Copse',
  77.         'Garamond, "Hoefler Text", Times New Roman, Times, serif' => 'Garamond',
  78.         'Georgia, serif' => 'Georgia',
  79.         '"Helvetica Neue", Helvetica, sans-serif' => 'Helvetica Neue',
  80.         'Tahoma, Geneva, sans-serif' => 'Tahoma'
  81.     );
  82.     return $os_faces;
  83. }
  84. /**
  85.  * Returns a select list of Google fonts
  86.  * Feel free to edit this, update the fallbacks, etc.
  87.  */
  88.  
  89. function options_typography_get_google_fonts() {
  90.     // Google Font Defaults
  91.     $google_faces = array(
  92.         'Arvo, serif' => 'Arvo',
  93.         'Copse, sans-serif' => 'Copse',
  94.         'Droid Sans, sans-serif' => 'Droid Sans',
  95.         'Droid Serif, serif' => 'Droid Serif',
  96.         'Lobster, cursive' => 'Lobster',
  97.         'Nobile, sans-serif' => 'Nobile',
  98.         'Open Sans, sans-serif' => 'Open Sans',
  99.         'Oswald, sans-serif' => 'Oswald',
  100.         'Pacifico, cursive' => 'Pacifico',
  101.         'Rokkitt, serif' => 'Rokkit',
  102.         'PT Sans, sans-serif' => 'PT Sans',
  103.         'Quattrocento, serif' => 'Quattrocento',
  104.         'Raleway, cursive' => 'Raleway',
  105.         'Ubuntu, sans-serif' => 'Ubuntu',
  106.         'Yanone Kaffeesatz, sans-serif' => 'Yanone Kaffeesatz'
  107.     );
  108.     return $google_faces;
  109. }
  110. $typography_mixed_fonts = array_merge( options_typography_get_os_fonts() , options_typography_get_google_fonts() );
  111. asort($typography_mixed_fonts);
  112.  
  113. /**
  114.  * Checks font options to see if a Google font is selected.
  115.  * If so, options_typography_enqueue_google_font is called to enqueue the font.
  116.  * Ensures that each Google font is only enqueued once.
  117.  */
  118.  
  119. if ( !function_exists( 'options_typography_google_fonts' ) ) {
  120.     function options_typography_google_fonts() {
  121.         $all_google_fonts = array_keys( options_typography_get_google_fonts() );
  122.         // Define all the options that possibly have a unique Google font
  123.         $google_font = of_get_option('google_font', 'Rokkitt, serif');
  124.         $google_mixed = of_get_option('google_mixed', false);
  125.         $google_mixed_2 = of_get_option('google_mixed_2', 'Arvo, serif');
  126.         // Get the font face for each option and put it in an array
  127.         $selected_fonts = array(
  128.             $google_font['face'],
  129.             $google_mixed['face'],
  130.             $google_mixed_2['face'] );
  131.         // Remove any duplicates in the list
  132.         $selected_fonts = array_unique($selected_fonts);
  133.         // Check each of the unique fonts against the defined Google fonts
  134.         // If it is a Google font, go ahead and call the function to enqueue it
  135.         foreach ( $selected_fonts as $font ) {
  136.             if ( in_array( $font, $all_google_fonts ) ) {
  137.                 options_typography_enqueue_google_font($font);
  138.             }
  139.         }
  140.     }
  141. }
  142.  
  143. add_action( 'wp_enqueue_scripts', 'options_typography_google_fonts' );
  144.  
  145.  
  146. /**
  147.  * Enqueues the Google $font that is passed
  148.  */
  149.  
  150. function options_typography_enqueue_google_font($font) {
  151.     $font = explode(',', $font);
  152.     $font = $font[0];
  153.     // Certain Google fonts need slight tweaks in order to load properly
  154.     // Like our friend "Raleway"
  155.     if ( $font == 'Raleway' )
  156.         $font = 'Raleway:100';
  157.     $font = str_replace(" ", "+", $font);
  158.     wp_enqueue_style( "options_typography_$font", "http://fonts.googleapis.com/css?family=$font", false, null, 'all' );
  159. }
  160. /*
  161.  * Outputs the selected option panel styles inline into the <head>
  162.  */
  163.  
  164. function options_typography_styles() {
  165.      $output = '';
  166.      $input = '';
  167.  
  168.      if ( of_get_option( 'google_font' ) ) {
  169.           $input = of_get_option( 'google_font' );
  170.       $output .= options_typography_font_styles( of_get_option( 'google_font' ) , '.google-font');
  171.      }
  172.  
  173.      if ( $output != '' ) {
  174.     $output = "\n<style>\n" . $output . "</style>\n";
  175.     echo $output;
  176.      }
  177. }
  178. add_action('wp_head', 'options_typography_styles');
  179. /*
  180.  * Returns a typography option in a format that can be outputted as inline CSS
  181.  */
  182.  
  183. function options_typography_font_styles($option, $selectors) {
  184.         $output = $selectors . ' {';
  185.         $output .= ' color:' . $option['color'] .'; ';
  186.         $output .= 'font-family:' . $option['face'] . '; ';
  187.         $output .= 'font-weight:' . $option['style'] . '; ';
  188.         $output .= 'font-size:' . $option['size'] . '; ';
  189.         $output .= '}';
  190.         $output .= "\n";
  191.         return $output;
  192. }
  193.  
  194.  
  195. // Settings Tab 1
  196.     $options[] = array(
  197.         'name' => __('Branding Settings', 'options_check'),
  198.         'type' => 'heading');
  199.        
  200. //image uploader
  201.     $options[] = array(
  202.         'name' => __('Upload Your Logo', 'options_check'),
  203.         'desc' => __('Upload your company logo here .', 'options_check'),
  204.         'id' => 'logo_uploader',
  205.         'type' => 'upload');
  206.        
  207. //image uploader
  208.     $options[] = array(
  209.         'name' => __('Upload Your Favicon', 'options_check'),
  210.         'desc' => __('Upload your facicon here .', 'options_check'),
  211.         'id' => 'favicon_uploader',
  212.         'type' => 'upload');
  213.  
  214.  
  215. //colour picker
  216.     $options[] = array(
  217.         'name' => __('Primary Colour', 'options_check'),
  218.         'desc' => __('Choose primary colour', 'options_check'),
  219.         'id' => 'primary_colorpicker',
  220.         'std' => '',
  221.         'type' => 'color' );
  222.  
  223. //colour picker
  224.     $options[] = array(
  225.         'name' => __('Secondary Colour', 'options_check'),
  226.         'desc' => __('Choose secondary colour', 'options_check'),
  227.         'id' => 'secondary_colorpicker',
  228.         'std' => '',
  229.         'type' => 'color' );
  230.  
  231.  
  232. /* ******** Fonts ************ */
  233.  
  234. /** set text settings tab ***/
  235. $options[] = array(
  236.         'name' => __('Text Settings', 'options_check'),
  237.         'type' => 'heading');
  238.  
  239. //Headings 
  240. $options[] = array( 'name' => 'Headings Text',
  241.     'desc' => 'Choose options for all your sites headings.',
  242.     'id' => 'heading_text',
  243.     'std' => array( 'size' => '32px', 'face' => 'Tahoma, Geneva, sans-serif', 'color' => '#999999'),
  244.     'type' => 'typography',
  245.     'options' => array(
  246.         'faces' => $typography_mixed_fonts,
  247.         'styles' => array( 'normal' => 'Normal', 'bold' => 'Bold', 'bolder' => 'Bolder', 'lighter' => 'Lighter',)
  248.         )
  249.     );
  250.  
  251. //Body text
  252. $options[] = array( 'name' => 'Main Text',
  253.     'desc' => 'Choose options for your sites body text.',
  254.     'id' => 'main_text',
  255.     'std' => array( 'size' => '16px', 'face' => 'Tahoma, Geneva, sans-serif', 'color' => '#000000'),
  256.     'type' => 'typography',
  257.     'options' => array(
  258.         'faces' => $typography_mixed_fonts,
  259.         'styles' => false )
  260.     );
  261.  
  262. //Links
  263. $options[] = array( 'name' => 'Link Colour',
  264.     'desc' => 'Choose options for all your sites links.',
  265.     'id' => 'link_typography',
  266.     'std' => array( 'size' => '16px', 'face' => 'Tahoma, Geneva, sans-serif', 'color' => '#999999'),
  267.     'type' => 'typography',
  268.     'options' => array(
  269.         'faces' => $typography_mixed_fonts,
  270.         'styles' => array( 'normal' => 'Normal', 'bold' => 'Bold', 'bolder' => 'Bolder', 'lighter' => 'Lighter',)
  271.     )
  272.     );
  273.    
  274. // Menu Text colour
  275. $options[] = array( 'name' => 'Menu Text colour',
  276.     'desc' => 'Choose menu link text options',
  277.     'id' => 'menu_links',
  278.     'std' => array( 'size' => '16px', 'face' => 'Tahoma, Geneva, sans-serif', 'color' => '#ffffff'),
  279.     'type' => 'typography',
  280.     'options' => array(
  281.         'faces' => $typography_mixed_fonts,
  282.         'styles' => array( 'normal' => 'Normal', 'bold' => 'Bold', 'bolder' => 'Bolder', 'lighter' => 'Lighter',)
  283.     )
  284.     );
  285.  
  286.     return $options;
  287. }
  288.  
  289.  
  290.  
  291.  
  292. /******** END OF FONTS ***************/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement