PHP   19

options sample php

Guest on 10th June 2022 01:28:43 AM

  1. <?php
  2. /*
  3.  *
  4.  * Set the text domain for the theme or plugin.
  5.  *
  6.  */
  7. define('Redux_TEXT_DOMAIN', 'redux-opts');
  8.  
  9. /*
  10.  *
  11.  * Require the framework class before doing anything else, so we can use the defined URLs and directories.
  12.  * If you are running on Windows you may have URL problems which can be fixed by defining the framework url first.
  13.  *
  14.  */
  15. //define('Redux_OPTIONS_URL', site_url('path the options folder'));
  16. if(!class_exists('Redux_Options')){
  17.     require_once(dirname(__FILE__) . '/options/defaults.php');
  18. }
  19.  
  20. /*
  21.  *
  22.  * Custom function for filtering the sections array. Good for child themes to override or add to the sections.
  23.  * Simply include this function in the child themes functions.php file.
  24.  *
  25.  * NOTE: the defined constansts for URLs, and directories will NOT be available at this point in a child theme,
  26.  * so you must use get_template_directory_uri() if you want to use any of the built in icons
  27.  *
  28.  */
  29. function add_another_section($sections){
  30.     //$sections = array();
  31.     $sections[] = array(
  32.         'title' => __('A Section added by hook', Redux_TEXT_DOMAIN),
  33.         'desc' => __('<p class="description">This is a section created by adding a filter to the sections array. Can be used by child themes to add/remove sections from the options.</p>', Redux_TEXT_DOMAIN),
  34.                 'icon' => 'paper-clip',
  35.                 'icon_class' => 'icon-large',
  36.         // Leave this as a blank section, no options just some intro text set above.
  37.         'fields' => array()
  38.     );
  39.  
  40.     return $sections;
  41. }
  42. //add_filter('redux-opts-sections-twenty_eleven', 'add_another_section');
  43.  
  44.  
  45. /*
  46.  *
  47.  * Custom function for filtering the args array given by a theme, good for child themes to override or add to the args array.
  48.  *
  49.  */
  50. function change_framework_args($args){
  51.     //$args['dev_mode'] = false;
  52.    
  53.     return $args;
  54. }
  55. //add_filter('redux-opts-args-twenty_eleven', 'change_framework_args');
  56.  
  57.  
  58. /*
  59.  *
  60.  * Most of your editing will be done in this section.
  61.  *
  62.  * Here you can override default values, uncomment args and change their values.
  63.  * No $args are required, but they can be over ridden if needed.
  64.  *
  65.  */
  66. function setup_framework_options(){
  67.     $args = array();
  68.  
  69.     // Setting dev mode to true allows you to view the class settings/info in the panel.
  70.     // Default: true
  71.     //$args['dev_mode'] = true;
  72.  
  73.         // Set the icon for the dev mode tab.
  74.         // If $args['icon_type'] = 'image', this should be the path to the icon.
  75.         // If $args['icon_type'] = 'iconfont', this should be the icon name.
  76.         // Default: info-sign
  77.         //$args['dev_mode_icon'] = 'info-sign';
  78.  
  79.         // Set the class for the dev mode tab icon.
  80.         // This is ignored unless $args['icon_type'] = 'iconfont'
  81.         // Default: null
  82.         $args['dev_mode_icon_class'] = 'icon-large';
  83.  
  84.     // If you want to use Google Webfonts, you MUST define the api key.
  85.     //$args['google_api_key'] = 'xxxx';
  86.  
  87.     // Define the starting tab for the option panel.
  88.     // Default: '0';
  89.     //$args['last_tab'] = '0';
  90.  
  91.     // Define the option panel stylesheet. Options are 'standard', 'custom', and 'none'
  92.     // If only minor tweaks are needed, set to 'custom' and override the necessary styles through the included custom.css stylesheet.
  93.     // If replacing the stylesheet, set to 'none' and don't forget to enqueue another stylesheet!
  94.     // Default: 'standard'
  95.     //$args['admin_stylesheet'] = 'standard';
  96.  
  97.     // Add HTML before the form.
  98.     $args['intro_text'] = __('<p>This text is displayed above the options panel. It isn\'t required, but more info is always better! The intro_text field accepts all HTML.</p>', Redux_TEXT_DOMAIN);
  99.  
  100.     // Add content after the form.
  101.     $args['footer_text'] = __('<p>This text is displayed below the options panel. It isn\'t required, but more info is always better! The footer_text field accepts all HTML.</p>', Redux_TEXT_DOMAIN);
  102.  
  103.     // Set footer/credit line.
  104.     //$args['footer_credit'] = __('<p>This text is displayed in the options panel footer across from the WordPress version (where it normally says \'Thank you for creating with WordPress\'). This field accepts all HTML.</p>', Redux_TEXT_DOMAIN);
  105.  
  106.     // Setup custom links in the footer for share icons
  107.     $args['share_icons']['twitter'] = array(
  108.         'link' => 'http://twitter.com/ghost1227',
  109.         'title' => 'Follow me on Twitter',
  110.         'img' => Redux_OPTIONS_URL . 'img/social/Twitter.png'
  111.     );
  112.     $args['share_icons']['linked_in'] = array(
  113.         'link' => 'http://www.linkedin.com/profile/view?id=52559281',
  114.         'title' => 'Find me on LinkedIn',
  115.         'img' => Redux_OPTIONS_URL . 'img/social/LinkedIn.png'
  116.     );
  117.  
  118.     // Enable the import/export feature.
  119.     // Default: true
  120.     //$args['show_import_export'] = false;
  121.  
  122.         // Set the icon for the import/export tab.
  123.         // If $args['icon_type'] = 'image', this should be the path to the icon.
  124.         // If $args['icon_type'] = 'iconfont', this should be the icon name.
  125.         // Default: refresh
  126.         //$args['import_icon'] = 'refresh';
  127.  
  128.         // Set the class for the import/export tab icon.
  129.         // This is ignored unless $args['icon_type'] = 'iconfont'
  130.         // Default: null
  131.         $args['import_icon_class'] = 'icon-large';
  132.  
  133.     // Set a custom option name. Don't forget to replace spaces with underscores!
  134.     $args['opt_name'] = 'twenty_eleven2';
  135.  
  136.     // Set a custom menu icon.
  137.     //$args['menu_icon'] = '';
  138.  
  139.     // Set a custom title for the options page.
  140.     // Default: Options
  141.     $args['menu_title'] = __('Options', Redux_TEXT_DOMAIN);
  142.  
  143.     // Set a custom page title for the options page.
  144.     // Default: Options
  145.     $args['page_title'] = __('Options', Redux_TEXT_DOMAIN);
  146.  
  147.     // Set a custom page slug for options page (wp-admin/themes.php?page=***).
  148.     // Default: redux_options
  149.     $args['page_slug'] = 'redux_options';
  150.  
  151.     // Set a custom page capability.
  152.     // Default: manage_options
  153.     //$args['page_cap'] = 'manage_options';
  154.  
  155.     // Set the menu type. Set to "menu" for a top level menu, or "submenu" to add below an existing item.
  156.     // Default: menu
  157.     //$args['page_type'] = 'submenu';
  158.  
  159.     // Set the parent menu.
  160.     // Default: themes.php
  161.     // A list of available parent menus is available at http://codex.wordpress.org/Function_Reference/add_submenu_page#Parameters
  162.     //$args['page_parent'] = 'options_general.php';
  163.  
  164.     // Set a custom page location. This allows you to place your menu where you want in the menu order.
  165.     // Must be unique or it will override other items!
  166.     // Default: null
  167.     //$args['page_position'] = null;
  168.  
  169.     // Set a custom page icon class (used to override the page icon next to heading)
  170.     //$args['page_icon'] = 'icon-themes';
  171.  
  172.         // Set the icon type. Set to "iconfont" for Font Awesome, or "image" for traditional.
  173.         // Redux no longer ships with standard icons!
  174.         // Default: iconfont
  175.         //$args['icon_type'] = 'image';
  176.  
  177.     // Disable the panel sections showing as submenu items.
  178.     // Default: true
  179.     //$args['allow_sub_menu'] = false;
  180.        
  181.     // Set ANY custom page help tabs, displayed using the new help tab API. Tabs are shown in order of definition.
  182.     $args['help_tabs'][] = array(
  183.         'id' => 'redux-opts-1',
  184.         'title' => __('Theme Information 1', Redux_TEXT_DOMAIN),
  185.         'content' => __('<p>This is the tab content, HTML is allowed.</p>', Redux_TEXT_DOMAIN)
  186.     );
  187.     $args['help_tabs'][] = array(
  188.         'id' => 'redux-opts-2',
  189.         'title' => __('Theme Information 2', Redux_TEXT_DOMAIN),
  190.         'content' => __('<p>This is the tab content, HTML is allowed.</p>', Redux_TEXT_DOMAIN)
  191.     );
  192.  
  193.     // Set the help sidebar for the options page.                                        
  194.     $args['help_sidebar'] = __('<p>This is the sidebar content, HTML is allowed.</p>', Redux_TEXT_DOMAIN);
  195.  
  196.     $sections = array();
  197.  
  198.     $sections[] = array(
  199.                 // Redux uses the Font Awesome iconfont to supply its default icons.
  200.                 // If $args['icon_type'] = 'iconfont', this should be the icon name minus 'icon-'.
  201.                 // If $args['icon_type'] = 'image', this should be the path to the icon.
  202.                 'icon' => 'paper-clip',
  203.                 // Set the class for this icon.
  204.                 // This field is ignored unless $args['icon_type'] = 'iconfont'
  205.                 'icon_class' => 'icon-large',
  206.         'title' => __('Getting Started', Redux_TEXT_DOMAIN),
  207.                 'desc' => __('<p class="description">This is the description field for this section. HTML is allowed</p>', Redux_TEXT_DOMAIN),
  208.         // Lets leave this as a blank section, no options just some intro text set above.
  209.         //'fields' => array()
  210.     );
  211.  
  212.     $sections[] = array(
  213.                 'icon' => 'edit',
  214.                 'icon_class' => 'icon-large',
  215.         'title' => __('Text Fields', Redux_TEXT_DOMAIN),
  216.         'desc' => __('<p class="description">This is the description field for this section. Again HTML is allowed2</p>', Redux_TEXT_DOMAIN),
  217.         'fields' => array(
  218.             array(
  219.                 'id' => '1', // The item ID must be unique
  220.                 'type' => 'text', // Built-in field types include:
  221.                 // text, textarea, editor, checkbox, multi_checkbox, radio, radio_img, button_set,
  222.                 // select, multi_select, color, date, divide, info, upload
  223.                 'title' => __('Text Option', Redux_TEXT_DOMAIN),
  224.                 'sub_desc' => __('This is a little space under the field title which can be used for additonal info.', Redux_TEXT_DOMAIN),
  225.                 'desc' => __('This is the description field, again good for additional info.', Redux_TEXT_DOMAIN),
  226.                 //'validate' => '', // Built-in validation includes:
  227.                 //  email, html, html_custom, no_html, js, numeric, comma_numeric, url, str_replace, preg_replace
  228.                 //'msg' => 'custom error message', // Override the default validation error message for specific fields
  229.                 //'std' => '', // This is the default value and is used to set an option on theme activation.
  230.                 //'class' => '' // Set custom classes for elements if you want to do something a little different
  231.                 //'rows' => '6' // Set the number of rows shown for the textarea. Default: 6
  232.                         ),
  233.             array(
  234.                 'id' => '2',
  235.                 'type' => 'text',
  236.                 'title' => __('Text Option - Email Validated', Redux_TEXT_DOMAIN),
  237.                 'sub_desc' => __('This is a little space under the field title which can be used for additonal info.', Redux_TEXT_DOMAIN),
  238.                 'desc' => __('This is the description field, again good for additional info.', Redux_TEXT_DOMAIN),
  239.                 'validate' => 'email',
  240.                 'msg' => 'custom error message',
  241.                 'std' => 'test@test.com'
  242.             ),
  243.             array(
  244.                 'id' => 'password',
  245.                 'type' => 'password',
  246.                 'title' => __('Password Option', Redux_TEXT_DOMAIN),
  247.                 'sub_desc' => __('This is a little space under the field title which can be used for additonal info.', Redux_TEXT_DOMAIN),
  248.                 'desc' => __('This is the description field, again good for additional info.', Redux_TEXT_DOMAIN)
  249.             ),
  250.             array(
  251.                 'id' => 'multi_text',
  252.                 'type' => 'multi_text',
  253.                 'title' => __('Multi Text Option', Redux_TEXT_DOMAIN),
  254.                 'sub_desc' => __('This is a little space under the field title which can be used for additonal info.', Redux_TEXT_DOMAIN),
  255.                 'desc' => __('This is the description field, again good for additional info.', Redux_TEXT_DOMAIN),
  256.             ),
  257.             array(
  258.                 'id' => '3',
  259.                 'type' => 'text',
  260.                 'title' => __('Text Option - URL Validated', Redux_TEXT_DOMAIN),
  261.                 'sub_desc' => __('This must be a URL.', Redux_TEXT_DOMAIN),
  262.                 'desc' => __('This is the description field, again good for additional info.', Redux_TEXT_DOMAIN),
  263.                 'validate' => 'url',
  264.                 'std' => 'http://reduxframework.com'
  265.             ),
  266.             array(
  267.                 'id' => '4',
  268.                 'type' => 'text',
  269.                 'title' => __('Text Option - Numeric Validated', Redux_TEXT_DOMAIN),
  270.                 'sub_desc' => __('This must be numeric.', Redux_TEXT_DOMAIN),
  271.                 'desc' => __('This is the description field, again good for additional info.', Redux_TEXT_DOMAIN),
  272.                 'validate' => 'numeric',
  273.                 'std' => '0',
  274.                 'class' => 'small-text'
  275.             ),
  276.             array(
  277.                 'id' => 'comma_numeric',
  278.                 'type' => 'text',
  279.                 'title' => __('Text Option - Comma Numeric Validated', Redux_TEXT_DOMAIN),
  280.                 'sub_desc' => __('This must be a comma seperated string of numerical values.', Redux_TEXT_DOMAIN),
  281.                 'desc' => __('This is the description field, again good for additional info.', Redux_TEXT_DOMAIN),
  282.                 'validate' => 'comma_numeric',
  283.                 'std' => '0',
  284.                 'class' => 'small-text'
  285.             ),
  286.             array(
  287.                 'id' => 'no_special_chars',
  288.                 'type' => 'text',
  289.                 'title' => __('Text Option - No Special Chars Validated', Redux_TEXT_DOMAIN),
  290.                 'sub_desc' => __('This must be a alpha numeric only.', Redux_TEXT_DOMAIN),
  291.                 'desc' => __('This is the description field, again good for additional info.', Redux_TEXT_DOMAIN),
  292.                 'validate' => 'no_special_chars',
  293.                 'std' => '0'
  294.             ),
  295.             array(
  296.                 'id' => 'str_replace',
  297.                 'type' => 'text',
  298.                 'title' => __('Text Option - Str Replace Validated', Redux_TEXT_DOMAIN),
  299.                 'sub_desc' => __('You decide.', Redux_TEXT_DOMAIN),
  300.                 'desc' => __('This is the description field, again good for additional info.', Redux_TEXT_DOMAIN),
  301.                 'validate' => 'str_replace',
  302.                 'str' => array('search' => ' ', 'replacement' => 'thisisaspace'),
  303.                 'std' => '0'
  304.             ),
  305.             array(
  306.                 'id' => 'preg_replace',
  307.                 'type' => 'text',
  308.                 'title' => __('Text Option - Preg Replace Validated', Redux_TEXT_DOMAIN),
  309.                 'sub_desc' => __('You decide.', Redux_TEXT_DOMAIN),
  310.                 'desc' => __('This is the description field, again good for additional info.', Redux_TEXT_DOMAIN),
  311.                 'validate' => 'preg_replace',
  312.                 'preg' => array('pattern' => '/[^a-zA-Z_ -]/s', 'replacement' => 'no numbers'),
  313.                 'std' => '0'
  314.             ),
  315.             array(
  316.                 'id' => 'custom_validate',
  317.                 'type' => 'text',
  318.                 'title' => __('Text Option - Custom Callback Validated', Redux_TEXT_DOMAIN),
  319.                 'sub_desc' => __('You decide.', Redux_TEXT_DOMAIN),
  320.                 'desc' => __('This is the description field, again good for additional info.', Redux_TEXT_DOMAIN),
  321.                 'validate_callback' => 'validate_callback_function',
  322.                 'std' => '0'
  323.             ),
  324.             array(
  325.                 'id' => '5',
  326.                 'type' => 'textarea',
  327.                 'title' => __('Textarea Option - No HTML Validated', Redux_TEXT_DOMAIN),
  328.                 'sub_desc' => __('All HTML will be stripped', Redux_TEXT_DOMAIN),
  329.                 'desc' => __('This is the description field, again good for additional info.', Redux_TEXT_DOMAIN),
  330.                 'validate' => 'no_html',
  331.                 'std' => 'No HTML is allowed in here.'
  332.             ),
  333.             array(
  334.                 'id' => '6',
  335.                 'type' => 'textarea',
  336.                 'title' => __('Textarea Option - HTML Validated', Redux_TEXT_DOMAIN),
  337.                 'sub_desc' => __('HTML Allowed', Redux_TEXT_DOMAIN),
  338.                 'desc' => __('This is the description field, again good for additional info.', Redux_TEXT_DOMAIN),
  339.                 'validate' => 'html', // See http://codex.wordpress.org/Function_Reference/wp_kses_post
  340.                 'std' => 'HTML is allowed in here.'
  341.             ),
  342.             array(
  343.                 'id' => '7',
  344.                 'type' => 'textarea',
  345.                 'title' => __('Textarea Option - HTML Validated Custom', Redux_TEXT_DOMAIN),
  346.                 'sub_desc' => __('Custom HTML Allowed', Redux_TEXT_DOMAIN),
  347.                 'desc' => __('This is the description field, again good for additional info.', Redux_TEXT_DOMAIN),
  348.                 'validate' => 'html_custom',
  349.                 'std' => 'Some HTML is allowed in here.',
  350.                 'allowed_html' => array('') // See http://codex.wordpress.org/Function_Reference/wp_kses
  351.             ),
  352.             array(
  353.                 'id' => '8',
  354.                 'type' => 'textarea',
  355.                 'title' => __('Textarea Option - JS Validated', Redux_TEXT_DOMAIN),
  356.                 'sub_desc' => __('JS will be escaped', Redux_TEXT_DOMAIN),
  357.                 'desc' => __('This is the description field, again good for additional info.', Redux_TEXT_DOMAIN),
  358.                 'validate' => 'js'
  359.             ),
  360.             array(
  361.                 'id' => '9',
  362.                 'type' => 'editor',
  363.                 'title' => __('Editor Option', Redux_TEXT_DOMAIN),
  364.                 'sub_desc' => __('Can also use the validation methods if required', Redux_TEXT_DOMAIN),
  365.                 'desc' => __('This is the description field, again good for additional info.', Redux_TEXT_DOMAIN),
  366.                 'std' => 'OOOOOOhhhh, rich editing.',
  367.             ),
  368.             array(
  369.                 'id' => 'editor2',
  370.                 'type' => 'editor',
  371.                 'title' => __('Editor Option 2', Redux_TEXT_DOMAIN),
  372.                 'sub_desc' => __('Can also use the validation methods if required', Redux_TEXT_DOMAIN),
  373.                 'desc' => __('This is the description field, again good for additional info.', Redux_TEXT_DOMAIN),
  374.                 'std' => 'OOOOOOhhhh, rich editing with auto paragraphs disabled.',
  375.                 'autop' => false
  376.             )
  377.         )
  378.     );
  379.    
  380.     $sections[] = array(
  381.                 'icon' => 'check',
  382.                 'icon_class' => 'icon-large',
  383.         'title' => __('Radio/Checkbox Fields', Redux_TEXT_DOMAIN),
  384.         'desc' => __('<p class="description">This is the Description. Again HTML is allowed</p>', Redux_TEXT_DOMAIN),
  385.         'fields' => array(
  386.             array(
  387.                 'id' => 'switch',
  388.                 'type' => 'checkbox',
  389.                 'title' => __('Switch Option', Redux_TEXT_DOMAIN),
  390.                 'sub_desc' => __('No validation can be done on this field type', Redux_TEXT_DOMAIN),
  391.                 'desc' => __('This is the description field, again good for additional info.', Redux_TEXT_DOMAIN),
  392.                 'switch' => true,
  393.                 'std' => '1' // 1 = checked | 0 = unchecked
  394.             ),
  395.             array(
  396.                 'id' => '10',
  397.                 'type' => 'checkbox',
  398.                 'title' => __('Checkbox Option', Redux_TEXT_DOMAIN),
  399.                 'sub_desc' => __('No validation can be done on this field type', Redux_TEXT_DOMAIN),
  400.                 'desc' => __('This is the description field, again good for additional info.', Redux_TEXT_DOMAIN),
  401.                 'switch' => false,
  402.                 'std' => '1' // 1 = checked | 0 = unchecked
  403.             ),
  404.             array(
  405.                 'id' => '11',
  406.                 'type' => 'multi_checkbox',
  407.                 'title' => __('Multi Checkbox Option', Redux_TEXT_DOMAIN),
  408.                 'sub_desc' => __('No validation can be done on this field type', Redux_TEXT_DOMAIN),
  409.                 'desc' => __('This is the description field, again good for additional info.', Redux_TEXT_DOMAIN),
  410.                 'options' => array('1' => 'Opt 1', '2' => 'Opt 2', '3' => 'Opt 3'), // Must provide key => value pairs for multi checkbox options
  411.                 'std' => array('1' => '1', '2' => '0', '3' => '0') // See how std has changed? You also dont need to specify opts that are 0.
  412.             ),
  413.             array(
  414.                 'id' => '12',
  415.                 'type' => 'radio',
  416.                 'title' => __('Radio Option', Redux_TEXT_DOMAIN),
  417.                 'sub_desc' => __('No validation can be done on this field type', Redux_TEXT_DOMAIN),
  418.                 'desc' => __('This is the description field, again good for additional info.', Redux_TEXT_DOMAIN),
  419.                 'options' => array('1' => 'Opt 1', '2' => 'Opt 2', '3' => 'Opt 3'), // Must provide key => value pairs for radio options
  420.                 'std' => '2'
  421.             ),
  422.             array(
  423.                 'id' => '13',
  424.                 'type' => 'radio_img',
  425.                 'title' => __('Radio Image Option', Redux_TEXT_DOMAIN),
  426.                 'sub_desc' => __('No validation can be done on this field type', Redux_TEXT_DOMAIN),
  427.                 'desc' => __('This is the description field, again good for additional info.', Redux_TEXT_DOMAIN),
  428.                 'options' => array(
  429.                     '1' => array('title' => 'Opt 1', 'img' => 'images/align-none.png'),
  430.                     '2' => array('title' => 'Opt 2', 'img' => 'images/align-left.png'),
  431.                     '3' => array('title' => 'Opt 3', 'img' => 'images/align-center.png'),
  432.                     '4' => array('title' => 'Opt 4', 'img' => 'images/align-right.png')
  433.                 ), // Must provide key => value(array:title|img) pairs for radio options
  434.                 'std' => '2'
  435.             ),
  436.             array(
  437.                 'id' => 'radio_img',
  438.                 'type' => 'radio_img',
  439.                 'title' => __('Radio Image Option For Layout', Redux_TEXT_DOMAIN),
  440.                 'sub_desc' => __('No validation can be done on this field type', Redux_TEXT_DOMAIN),
  441.                 'desc' => __('This uses some of the built in images, you can use them for layout options.', Redux_TEXT_DOMAIN),
  442.                 'options' => array(
  443.                     '1' => array('title' => '1 Column', 'img' => Redux_OPTIONS_URL . 'img/1col.png'),
  444.                     '2' => array('title' => '2 Column Left', 'img' => Redux_OPTIONS_URL . 'img/2cl.png'),
  445.                     '3' => array('title' => '2 Column Right', 'img' => Redux_OPTIONS_URL . 'img/2cr.png')
  446.                 ), // Must provide key => value(array:title|img) pairs for radio options
  447.                 'std' => '2'
  448.             )                                                                        
  449.         )
  450.     );
  451.    
  452.     $sections[] = array(
  453.                 'icon' => 'list-alt',
  454.                 'icon_class' => 'icon-large',
  455.         'title' => __('Select Fields', Redux_TEXT_DOMAIN),
  456.         'desc' => __('<p class="description">This is the Description. Again HTML is allowed</p>', Redux_TEXT_DOMAIN),
  457.         'fields' => array(
  458.             array(
  459.                 'id' => '14',
  460.                 'type' => 'select',
  461.                 'title' => __('Select Option', Redux_TEXT_DOMAIN),
  462.                 'sub_desc' => __('No validation can be done on this field type', Redux_TEXT_DOMAIN),
  463.                 'desc' => __('This is the description field, again good for additional info.', Redux_TEXT_DOMAIN),
  464.                 'options' => array('1' => 'Opt 1', '2' => 'Opt 2', '3' => 'Opt 3'), // Must provide key => value pairs for select options
  465.                 'std' => '2'
  466.             ),
  467.             array(
  468.                 'id' => '15',
  469.                 'type' => 'multi_select',
  470.                 'title' => __('Multi Select Option', Redux_TEXT_DOMAIN),
  471.                 'sub_desc' => __('No validation can be done on this field type', Redux_TEXT_DOMAIN),
  472.                 'desc' => __('This is the description field, again good for additional info.', Redux_TEXT_DOMAIN),
  473.                 'options' => array('1' => 'Opt 1', '2' => 'Opt 2', '3' => 'Opt 3'), // Must provide key => value pairs for radio options
  474.                 'std' => array('2', '3')
  475.             )                                    
  476.         )
  477.     );
  478.    
  479.     $sections[] = array(
  480.                 'icon' => 'cogs',
  481.                 'icon_class' => 'icon-large',
  482.         'title' => __('Custom Fields', Redux_TEXT_DOMAIN),
  483.         'desc' => __('<p class="description">This is the Description. Again HTML is allowed</p>', Redux_TEXT_DOMAIN),
  484.         'fields' => array(
  485.             array(
  486.                 'id' => '16',
  487.                 'type' => 'color',
  488.                 'title' => __('Color Option', Redux_TEXT_DOMAIN),
  489.                 'sub_desc' => __('Only color validation can be done on this field type', Redux_TEXT_DOMAIN),
  490.                 'desc' => __('This is the description field, again good for additional info.', Redux_TEXT_DOMAIN),
  491.                 'std' => '#FFFFFF'
  492.             ),
  493.             array(
  494.                 'id' => 'color_gradient',
  495.                 'type' => 'color_gradient',
  496.                 'title' => __('Color Gradient Option', Redux_TEXT_DOMAIN),
  497.                 'sub_desc' => __('Only color validation can be done on this field type', Redux_TEXT_DOMAIN),
  498.                 'desc' => __('This is the description field, again good for additional info.', Redux_TEXT_DOMAIN),
  499.                 'std' => array('from' => '#000000', 'to' => '#FFFFFF')
  500.             ),
  501.             array(
  502.                 'id' => '17',
  503.                 'type' => 'date',
  504.                 'title' => __('Date Option', Redux_TEXT_DOMAIN),
  505.                 'sub_desc' => __('No validation can be done on this field type', Redux_TEXT_DOMAIN),
  506.                 'desc' => __('This is the description field, again good for additional info.', Redux_TEXT_DOMAIN)
  507.             ),
  508.             array(
  509.                 'id' => '18',
  510.                 'type' => 'button_set',
  511.                 'title' => __('Button Set Option', Redux_TEXT_DOMAIN),
  512.                 'sub_desc' => __('No validation can be done on this field type', Redux_TEXT_DOMAIN),
  513.                 'desc' => __('This is the description field, again good for additional info.', Redux_TEXT_DOMAIN),
  514.                 'options' => array('1' => 'Opt 1', '2' => 'Opt 2', '3' => 'Opt 3'), // Must provide key => value pairs for radio options
  515.                 'std' => '2'
  516.                         ),
  517.             array(
  518.                 'id' => '19',
  519.                 'type' => 'upload',
  520.                 'title' => __('Upload Option', Redux_TEXT_DOMAIN),
  521.                 'sub_desc' => __('No validation can be done on this field type', Redux_TEXT_DOMAIN),
  522.                 'desc' => __('This is the description field, again good for additional info.', Redux_TEXT_DOMAIN)
  523.             ),
  524.             array(
  525.                 'id' => 'pages_select',
  526.                 'type' => 'pages_select',
  527.                 'title' => __('Pages Select Option', Redux_TEXT_DOMAIN),
  528.                 'sub_desc' => __('No validation can be done on this field type', Redux_TEXT_DOMAIN),
  529.                 'desc' => __('This field creates a drop down menu of all the sites pages.', Redux_TEXT_DOMAIN),
  530.                 'args' => array() // Uses get_pages()
  531.             ),
  532.             array(
  533.                 'id' => 'pages_multi_select',
  534.                 'type' => 'pages_multi_select',
  535.                 'title' => __('Pages Multiple Select Option', Redux_TEXT_DOMAIN),
  536.                 'sub_desc' => __('No validation can be done on this field type', Redux_TEXT_DOMAIN),
  537.                 'desc' => __('This field creates a multi select menu of all the sites pages.', Redux_TEXT_DOMAIN),
  538.                 'args' => array('number' => '5') // Uses get_pages()
  539.             ),
  540.             array(
  541.                 'id' => 'posts_select',
  542.                 'type' => 'posts_select',
  543.                 'title' => __('Posts Select Option', Redux_TEXT_DOMAIN),
  544.                 'sub_desc' => __('No validation can be done on this field type', Redux_TEXT_DOMAIN),
  545.                 'desc' => __('This field creates a drop down menu of all the sites posts.', Redux_TEXT_DOMAIN),
  546.                 'args' => array('numberposts' => '10') // Uses get_posts()
  547.             ),
  548.             array(
  549.                 'id' => 'posts_multi_select',
  550.                 'type' => 'posts_multi_select',
  551.                 'title' => __('Posts Multiple Select Option', Redux_TEXT_DOMAIN),
  552.                 'sub_desc' => __('No validation can be done on this field type', Redux_TEXT_DOMAIN),
  553.                 'desc' => __('This field creates a multi select menu of all the sites posts.', Redux_TEXT_DOMAIN),
  554.                 'args' => array('numberposts' => '10') // Uses get_posts()
  555.             ),
  556.             array(
  557.                 'id' => 'tags_select',
  558.                 'type' => 'tags_select',
  559.                 'title' => __('Tags Select Option', Redux_TEXT_DOMAIN),
  560.                 'sub_desc' => __('No validation can be done on this field type', Redux_TEXT_DOMAIN),
  561.                 'desc' => __('This field creates a drop down menu of all the sites tags.', Redux_TEXT_DOMAIN),
  562.                 'args' => array('number' => '10') // Uses get_tags()
  563.             ),
  564.             array(
  565.                 'id' => 'tags_multi_select',
  566.                 'type' => 'tags_multi_select',
  567.                 'title' => __('Tags Multiple Select Option', Redux_TEXT_DOMAIN),
  568.                 'sub_desc' => __('No validation can be done on this field type', Redux_TEXT_DOMAIN),
  569.                 'desc' => __('This field creates a multi select menu of all the sites tags.', Redux_TEXT_DOMAIN),
  570.                 'args' => array('number' => '10') // Uses get_tags()
  571.             ),
  572.             array(
  573.                 'id' => 'cats_select',
  574.                 'type' => 'cats_select',
  575.                 'title' => __('Cats Select Option', Redux_TEXT_DOMAIN),
  576.                 'sub_desc' => __('No validation can be done on this field type', Redux_TEXT_DOMAIN),
  577.                 'desc' => __('This field creates a drop down menu of all the sites cats.', Redux_TEXT_DOMAIN),
  578.                 'args' => array('number' => '10') // Uses get_categories()
  579.             ),
  580.             array(
  581.                 'id' => 'cats_multi_select',
  582.                 'type' => 'cats_multi_select',
  583.                 'title' => __('Cats Multiple Select Option', Redux_TEXT_DOMAIN),
  584.                 'sub_desc' => __('No validation can be done on this field type', Redux_TEXT_DOMAIN),
  585.                 'desc' => __('This field creates a multi select menu of all the sites cats.', Redux_TEXT_DOMAIN),
  586.                 'args' => array('number' => '10') // Uses get_categories()
  587.             ),
  588.             array(
  589.                 'id' => 'menu_select',
  590.                 'type' => 'menu_select',
  591.                 'title' => __('Menu Select Option', Redux_TEXT_DOMAIN),
  592.                 'sub_desc' => __('No validation can be done on this field type', Redux_TEXT_DOMAIN),
  593.                 'desc' => __('This field creates a drop down menu of all the sites menus.', Redux_TEXT_DOMAIN),
  594.                 //'args' => array() // Uses wp_get_nav_menus()
  595.             ),
  596.             array(
  597.                 'id' => 'select_hide_below',
  598.                 'type' => 'select_hide_below',
  599.                 'title' => __('Select Hide Below Option', Redux_TEXT_DOMAIN),
  600.                 'sub_desc' => __('No validation can be done on this field type', Redux_TEXT_DOMAIN),
  601.                 'desc' => __('This field requires certain options to be checked before the below field will be shown.', Redux_TEXT_DOMAIN),
  602.                 'options' => array(
  603.                     '1' => array('name' => 'Opt 1 field below allowed', 'allow' => 'true'),
  604.                     '2' => array('name' => 'Opt 2 field below hidden', 'allow' => 'false'),
  605.                     '3' => array('name' => 'Opt 3 field below allowed', 'allow' => 'true')
  606.                 ), // Must provide key => value(array) pairs for select options
  607.                 'std' => '2'
  608.             ),
  609.             array(
  610.                 'id' => 'menu_location_select',
  611.                 'type' => 'menu_location_select',
  612.                 'title' => __('Menu Location Select Option', Redux_TEXT_DOMAIN),
  613.                 'sub_desc' => __('No validation can be done on this field type', Redux_TEXT_DOMAIN),
  614.                 'desc' => __('This field creates a drop down menu of all the themes menu locations.', Redux_TEXT_DOMAIN)
  615.             ),
  616.             array(
  617.                 'id' => 'checkbox_hide_below',
  618.                 'type' => 'checkbox_hide_below',
  619.                 'title' => __('Checkbox to hide below', Redux_TEXT_DOMAIN),
  620.                 'sub_desc' => __('No validation can be done on this field type', Redux_TEXT_DOMAIN),
  621.                 'desc' => __('This field creates a checkbox which will allow the user to use the next setting.', Redux_TEXT_DOMAIN),
  622.             ),
  623.             array(
  624.                 'id' => 'post_type_select',
  625.                 'type' => 'post_type_select',
  626.                 'title' => __('Post Type Select Option', Redux_TEXT_DOMAIN),
  627.                 'sub_desc' => __('No validation can be done on this field type', Redux_TEXT_DOMAIN),
  628.                 'desc' => __('This field creates a drop down menu of all registered post types.', Redux_TEXT_DOMAIN),
  629.                 //'args' => array() // Uses get_post_types()
  630.             ),
  631.             array(
  632.                 'id' => 'custom_callback',
  633.                 //'type' => 'nothing', // Doesn't need to be called for callback fields
  634.                 'title' => __('Custom Field Callback', Redux_TEXT_DOMAIN),
  635.                 'sub_desc' => __('This is a completely unique field type', Redux_TEXT_DOMAIN),
  636.                 'desc' => __('This is created with a callback function, so anything goes in this field. Make sure to define the function though.', Redux_TEXT_DOMAIN),
  637.                 'callback' => 'my_custom_field'
  638.             ),
  639.             array(
  640.                 'id' => 'google_webfonts',
  641.                 'type' => 'google_webfonts',
  642.                 'title' => __('Google Webfonts', Redux_TEXT_DOMAIN),
  643.                 'sub_desc' => __('This is a completely unique field type', Redux_TEXT_DOMAIN),
  644.                 'desc' => __('This is a simple implementation of the developer API for Google Webfonts. Don\'t forget to set your API key!', Redux_TEXT_DOMAIN)
  645.             )                            
  646.         )
  647.     );
  648.  
  649.     $sections[] = array(
  650.                 'icon' => 'eye-open',
  651.                 'icon_class' => 'icon-large',
  652.         'title' => __('Non Value Fields', Redux_TEXT_DOMAIN),
  653.         'desc' => __('<p class="description">This is the Description. Again HTML is allowed</p>', Redux_TEXT_DOMAIN),
  654.         'fields' => array(
  655.             array(
  656.                 'id' => '20',
  657.                 'type' => 'text',
  658.                 'title' => __('Text Field', Redux_TEXT_DOMAIN),
  659.                 'sub_desc' => __('Additional Info', Redux_TEXT_DOMAIN),
  660.                 'desc' => __('This is the description field, again good for additional info.', Redux_TEXT_DOMAIN)
  661.             ),
  662.             array(
  663.                 'id' => '21',
  664.                 'type' => 'divide'
  665.             ),
  666.             array(
  667.                 'id' => '22',
  668.                 'type' => 'text',
  669.                 'title' => __('Text Field', Redux_TEXT_DOMAIN),
  670.                 'sub_desc' => __('Additional Info', Redux_TEXT_DOMAIN),
  671.                 'desc' => __('This is the description field, again good for additional info.', Redux_TEXT_DOMAIN)
  672.             ),
  673.             array(
  674.                 'id' => '23',
  675.                 'type' => 'info',
  676.                 'desc' => __('<p class="description">This is the info field, if you want to break sections up.</p>', Redux_TEXT_DOMAIN)
  677.             ),
  678.             array(
  679.                 'id' => '24',
  680.                 'type' => 'text',
  681.                 'title' => __('Text Field', Redux_TEXT_DOMAIN),
  682.                 'sub_desc' => __('Additional Info', Redux_TEXT_DOMAIN),
  683.                 'desc' => __('This is the description field, again good for additional info.', Redux_TEXT_DOMAIN)
  684.             )                
  685.         )
  686.     );
  687.                
  688.     $tabs = array();
  689.  
  690.     if (function_exists('wp_get_theme')){
  691.         $theme_data = wp_get_theme();
  692.         $item_uri = $theme_data->get('ThemeURI');
  693.         $description = $theme_data->get('Description');
  694.         $author = $theme_data->get('Author');
  695.         $author_uri = $theme_data->get('AuthorURI');
  696.         $version = $theme_data->get('Version');
  697.         $tags = $theme_data->get('Tags');
  698.     }else{
  699.         $theme_data = get_theme_data(trailingslashit(get_stylesheet_directory()) . 'style.css');
  700.         $item_uri = $theme_data['URI'];
  701.         $description = $theme_data['Description'];
  702.         $author = $theme_data['Author'];
  703.         $author_uri = $theme_data['AuthorURI'];
  704.         $version = $theme_data['Version'];
  705.         $tags = $theme_data['Tags'];
  706.      }
  707.    
  708.     $item_info = '<div class="redux-opts-section-desc">';
  709.     $item_info .= '<p class="redux-opts-item-data description item-uri">' . __('<strong>Theme URL:</strong> ', Redux_TEXT_DOMAIN) . '<a href="' . $item_uri . '" target="_blank">' . $item_uri . '</a></p>';
  710.     $item_info .= '<p class="redux-opts-item-data description item-author">' . __('<strong>Author:</strong> ', Redux_TEXT_DOMAIN) . ($author_uri ? '<a href="' . $author_uri . '" target="_blank">' . $author . '</a>' : $author) . '</p>';
  711.     $item_info .= '<p class="redux-opts-item-data description item-version">' . __('<strong>Version:</strong> ', Redux_TEXT_DOMAIN) . $version . '</p>';
  712.     $item_info .= '<p class="redux-opts-item-data description item-description">' . $description . '</p>';
  713.     $item_info .= '<p class="redux-opts-item-data description item-tags">' . __('<strong>Tags:</strong> ', Redux_TEXT_DOMAIN) . implode(', ', $tags) . '</p>';
  714.     $item_info .= '</div>';
  715.  
  716.     $tabs['item_info'] = array(
  717.                 'icon' => 'info-sign',
  718.                 'icon_class' => 'icon-large',
  719.         'title' => __('Theme Information', Redux_TEXT_DOMAIN),
  720.         'content' => $item_info
  721.     );
  722.    
  723.     if(file_exists(trailingslashit(dirname(__FILE__)) . 'README.html')) {
  724.         $tabs['docs'] = array(
  725.                         'icon' => 'book',
  726.                         'icon_class' => 'icon-large',
  727.             'title' => __('Documentation', Redux_TEXT_DOMAIN),
  728.             'content' => nl2br(file_get_contents(trailingslashit(dirname(__FILE__)) . 'README.html'))
  729.         );
  730.     }
  731.  
  732.     global $Redux_Options;
  733.     $Redux_Options = new Redux_Options($sections, $args, $tabs);
  734.  
  735. }
  736. add_action('init', 'setup_framework_options', 0);
  737.  
  738. /*
  739.  *
  740.  * Custom function for the callback referenced above
  741.  *
  742.  */
  743. function my_custom_field($field, $value) {
  744.     print_r($field);
  745.     print_r($value);
  746. }
  747.  
  748. /*
  749.  *
  750.  * Custom function for the callback validation referenced above
  751.  *
  752.  */
  753. function validate_callback_function($field, $value, $existing_value) {
  754.     $error = false;
  755.     $value =  'just testing';
  756.     /*
  757.     do your validation
  758.    
  759.     if(something) {
  760.         $value = $value;
  761.     } elseif(somthing else) {
  762.         $error = true;
  763.         $value = $existing_value;
  764.         $field['msg'] = 'your custom error message';
  765.     }
  766.     */
  767.    
  768.     $return['value'] = $value;
  769.     if($error == true) {
  770.         $return['error'] = $field;
  771.     }
  772.     return $return;
  773. }

Raw Paste


Login or Register to edit or fork this paste. It's free.