Advertisement
salmancreation

Redux Main Option php file for create option

Nov 13th, 2015
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 13.87 KB | None | 0 0
  1. <?php
  2.     /**
  3.      * ReduxFramework Sample Config File
  4.      * For full documentation, please visit: http://docs.reduxframework.com/
  5.      */
  6.  
  7.     if ( ! class_exists( 'Redux' ) ) {
  8.         return;
  9.     }
  10.  
  11.  
  12.     // This is your option name where all the Redux data is stored.
  13.     $opt_name = "salmancreation";
  14.  
  15.     // This line is only for altering the demo. Can be easily removed.
  16.     $opt_name = apply_filters( 'redux_demo/opt_name', $opt_name );
  17.  
  18.     /*
  19.      *
  20.      * --> Used within different fields. Simply examples. Search for ACTUAL DECLARATION for field examples
  21.      *
  22.      */
  23.  
  24.     $sampleHTML = '';
  25.     if ( file_exists( dirname( __FILE__ ) . '/info-html.html' ) ) {
  26.         Redux_Functions::initWpFilesystem();
  27.  
  28.         global $wp_filesystem;
  29.  
  30.         $sampleHTML = $wp_filesystem->get_contents( dirname( __FILE__ ) . '/info-html.html' );
  31.     }
  32.  
  33.     // Background Patterns Reader
  34.     $sample_patterns_path = ReduxFramework::$_dir . '../sample/patterns/';
  35.     $sample_patterns_url  = ReduxFramework::$_url . '../sample/patterns/';
  36.     $sample_patterns      = array();
  37.  
  38.     if ( is_dir( $sample_patterns_path ) ) {
  39.  
  40.         if ( $sample_patterns_dir = opendir( $sample_patterns_path ) ) {
  41.             $sample_patterns = array();
  42.  
  43.             while ( ( $sample_patterns_file = readdir( $sample_patterns_dir ) ) !== false ) {
  44.  
  45.                 if ( stristr( $sample_patterns_file, '.png' ) !== false || stristr( $sample_patterns_file, '.jpg' ) !== false ) {
  46.                     $name              = explode( '.', $sample_patterns_file );
  47.                     $name              = str_replace( '.' . end( $name ), '', $sample_patterns_file );
  48.                     $sample_patterns[] = array(
  49.                         'alt' => $name,
  50.                         'img' => $sample_patterns_url . $sample_patterns_file
  51.                     );
  52.                 }
  53.             }
  54.         }
  55.     }
  56.  
  57.     /**
  58.      * ---> SET ARGUMENTS
  59.      * All the possible arguments for Redux.
  60.      * For full documentation on arguments, please refer to: https://github.com/ReduxFramework/ReduxFramework/wiki/Arguments
  61.      * */
  62.  
  63.     $theme = wp_get_theme(); // For use with some settings. Not necessary.
  64.  
  65.     $args = array(
  66.         // TYPICAL -> Change these values as you need/desire
  67.         'opt_name'             => $opt_name,
  68.         // This is where your data is stored in the database and also becomes your global variable name.
  69.         'display_name'         => $theme->get( 'Name' ),
  70.         // Name that appears at the top of your panel
  71.         'display_version'      => $theme->get( 'Version' ),
  72.         // Version that appears at the top of your panel
  73.         'menu_type'            => 'menu',
  74.         //Specify if the admin menu should appear or not. Options: menu or submenu (Under appearance only)
  75.         'allow_sub_menu'       => true,
  76.         // Show the sections below the admin menu item or not
  77.         'menu_title'           => __( 'Multi Theme Options', 'redux-framework-demo' ),
  78.         'page_title'           => __( 'Theme Options', 'redux-framework-demo' ),
  79.         // You will need to generate a Google API key to use this feature.
  80.         // Please visit: https://developers.google.com/fonts/docs/developer_api#Auth
  81.         'google_api_key'       => '',
  82.         // Set it you want google fonts to update weekly. A google_api_key value is required.
  83.         'google_update_weekly' => false,
  84.         // Must be defined to add google fonts to the typography module
  85.         'async_typography'     => true,
  86.         // Use a asynchronous font on the front end or font string
  87.         //'disable_google_fonts_link' => true,                    // Disable this in case you want to create your own google fonts loader
  88.         'admin_bar'            => true,
  89.         // Show the panel pages on the admin bar
  90.         'admin_bar_icon'       => 'dashicons-portfolio',
  91.         // Choose an icon for the admin bar menu
  92.         'admin_bar_priority'   => 50,
  93.         // Choose an priority for the admin bar menu
  94.         'global_variable'      => '',
  95.         // Set a different name for your global variable other than the opt_name
  96.         'dev_mode'             => false,
  97.         // Show the time the page took to load, etc
  98.         'update_notice'        => false,
  99.         // If dev_mode is enabled, will notify developer of updated versions available in the GitHub Repo
  100.         'customizer'           => true,
  101.         // Enable basic customizer support
  102.         //'open_expanded'     => true,                    // Allow you to start the panel in an expanded way initially.
  103.         //'disable_save_warn' => true,                    // Disable the save warning when a user changes a field
  104.  
  105.         // OPTIONAL -> Give you extra features
  106.         'page_priority'        => 50,
  107.         // Order where the menu appears in the admin area. If there is any conflict, something will not show. Warning.
  108.         'page_parent'          => 'themes.php',
  109.         // For a full list of options, visit: http://codex.wordpress.org/Function_Reference/add_submenu_page#Parameters
  110.         'page_permissions'     => 'manage_options',
  111.         // Permissions needed to access the options panel.
  112.         'menu_icon'            => 'dashicons-dashboard',
  113.         // Specify a custom URL to an icon
  114.         'last_tab'             => '',
  115.         // Force your panel to always open to a specific tab (by id)
  116.         'page_icon'            => 'icon-themes',
  117.         // Icon displayed in the admin panel next to your menu_title
  118.         'page_slug'            => '',
  119.         // Page slug used to denote the panel, will be based off page title then menu title then opt_name if not provided
  120.         'save_defaults'        => true,
  121.         // On load save the defaults to DB before user clicks save or not
  122.         'default_show'         => false,
  123.         // If true, shows the default value next to each field that is not the default value.
  124.         'default_mark'         => '',
  125.         // What to print by the field's title if the value shown is default. Suggested: *
  126.         'show_import_export'   => true,
  127.         // Shows the Import/Export panel when not used as a field.
  128.  
  129.         // CAREFUL -> These options are for advanced use only
  130.         'transient_time'       => 60 * MINUTE_IN_SECONDS,
  131.         'output'               => true,
  132.         // Global shut-off for dynamic CSS output by the framework. Will also disable google fonts output
  133.         'output_tag'           => true,
  134.         // Allows dynamic CSS to be generated for customizer and google fonts, but stops the dynamic CSS from going to the head
  135.         // 'footer_credit'     => '',                   // Disable the footer credit of Redux. Please leave if you can help it.
  136.  
  137.         // FUTURE -> Not in use yet, but reserved or partially implemented. Use at your own risk.
  138.         'database'             => '',
  139.         // possible: options, theme_mods, theme_mods_expanded, transient. Not fully functional, warning!
  140.         'use_cdn'              => true,
  141.         // If you prefer not to use the CDN for Select2, Ace Editor, and others, you may download the Redux Vendor Support plugin yourself and run locally or embed it in your code.
  142.  
  143.         // HINTS
  144.         'hints'                => array(
  145.             'icon'          => 'el el-question-sign',
  146.             'icon_position' => 'right',
  147.             'icon_color'    => 'lightgray',
  148.             'icon_size'     => 'normal',
  149.             'tip_style'     => array(
  150.                 'color'   => 'red',
  151.                 'shadow'  => true,
  152.                 'rounded' => false,
  153.                 'style'   => '',
  154.             ),
  155.             'tip_position'  => array(
  156.                 'my' => 'top left',
  157.                 'at' => 'bottom right',
  158.             ),
  159.             'tip_effect'    => array(
  160.                 'show' => array(
  161.                     'effect'   => 'slide',
  162.                     'duration' => '500',
  163.                     'event'    => 'mouseover',
  164.                 ),
  165.                 'hide' => array(
  166.                     'effect'   => 'slide',
  167.                     'duration' => '500',
  168.                     'event'    => 'click mouseleave',
  169.                 ),
  170.             ),
  171.         )
  172.     );
  173.  
  174.  
  175.     // SOCIAL ICONS -> Setup custom links in the footer for quick links in your panel footer icons.
  176.     $args['share_icons'][] = array(
  177.         'url'   => 'https://github.com/ReduxFramework/ReduxFramework',
  178.         'title' => 'Visit us on GitHub',
  179.         'icon'  => 'el el-github'
  180.         //'img'   => '', // You can use icon OR img. IMG needs to be a full URL.
  181.     );
  182.     $args['share_icons'][] = array(
  183.         'url'   => 'https://www.facebook.com/pages/Redux-Framework/243141545850368',
  184.         'title' => 'Like us on Facebook',
  185.         'icon'  => 'el el-facebook'
  186.     );
  187.  
  188.  
  189.     // Add content after the form.
  190.     $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-framework-demo' );
  191.  
  192.     Redux::setArgs( $opt_name, $args );
  193.  
  194.     /*
  195.      * ---> END ARGUMENTS
  196.      */
  197.  
  198.     // -> START Basic Fields
  199.    
  200.     Redux::setSection($opt_name, array(
  201.         'title' => __('Multi Theme Setting','multi'),
  202.         'desc' => __('Theme Custmiztion Options','multi'),
  203.         'icon' => 'el el-screen',
  204.         'fields' => array(
  205.             array(
  206.                 'title' => __('Logo Uplaod','multi'),
  207.                 'desc' => __('Uplaod Your Logo ','multi'),
  208.                 'id' => 'logo',
  209.                 'type' => 'media',
  210.                 'default' => get_template_directory_uri().'/images/logo.png',
  211.             ),
  212.         )
  213.    
  214.     ) );
  215.    
  216.    
  217.    
  218.  
  219.     if ( ! function_exists( 'compiler_action' ) ) {
  220.         function compiler_action( $options, $css, $changed_values ) {
  221.             echo '<h1>The compiler hook has run!</h1>';
  222.             echo "<pre>";
  223.             print_r( $changed_values ); // Values that have changed since the last save
  224.             echo "</pre>";
  225.             //print_r($options); //Option values
  226.             //print_r($css); // Compiler selector CSS values  compiler => array( CSS SELECTORS )
  227.         }
  228.     }
  229.  
  230.     /**
  231.      * Custom function for the callback validation referenced above
  232.      * */
  233.     if ( ! function_exists( 'redux_validate_callback_function' ) ) {
  234.         function redux_validate_callback_function( $field, $value, $existing_value ) {
  235.             $error   = false;
  236.             $warning = false;
  237.  
  238.             //do your validation
  239.             if ( $value == 1 ) {
  240.                 $error = true;
  241.                 $value = $existing_value;
  242.             } elseif ( $value == 2 ) {
  243.                 $warning = true;
  244.                 $value   = $existing_value;
  245.             }
  246.  
  247.             $return['value'] = $value;
  248.  
  249.             if ( $error == true ) {
  250.                 $return['error'] = $field;
  251.                 $field['msg']    = 'your custom error message';
  252.             }
  253.  
  254.             if ( $warning == true ) {
  255.                 $return['warning'] = $field;
  256.                 $field['msg']      = 'your custom warning message';
  257.             }
  258.  
  259.             return $return;
  260.         }
  261.     }
  262.  
  263.     /**
  264.      * Custom function for the callback referenced above
  265.      */
  266.     if ( ! function_exists( 'redux_my_custom_field' ) ) {
  267.         function redux_my_custom_field( $field, $value ) {
  268.             print_r( $field );
  269.             echo '<br/>';
  270.             print_r( $value );
  271.         }
  272.     }
  273.  
  274.     /**
  275.      * Custom function for filtering the sections array. Good for child themes to override or add to the sections.
  276.      * Simply include this function in the child themes functions.php file.
  277.      * NOTE: the defined constants for URLs, and directories will NOT be available at this point in a child theme,
  278.      * so you must use get_template_directory_uri() if you want to use any of the built in icons
  279.      * */
  280.     if ( ! function_exists( 'dynamic_section' ) ) {
  281.         function dynamic_section( $sections ) {
  282.             //$sections = array();
  283.             $sections[] = array(
  284.                 'title'  => __( 'Section via hook', 'redux-framework-demo' ),
  285.                 '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-framework-demo' ),
  286.                 'icon'   => 'el el-paper-clip',
  287.                 // Leave this as a blank section, no options just some intro text set above.
  288.                 'fields' => array()
  289.             );
  290.  
  291.             return $sections;
  292.         }
  293.     }
  294.  
  295.     /**
  296.      * Filter hook for filtering the args. Good for child themes to override or add to the args array. Can also be used in other functions.
  297.      * */
  298.     if ( ! function_exists( 'change_arguments' ) ) {
  299.         function change_arguments( $args ) {
  300.             //$args['dev_mode'] = true;
  301.  
  302.             return $args;
  303.         }
  304.     }
  305.  
  306.     /**
  307.      * Filter hook for filtering the default value of any given field. Very useful in development mode.
  308.      * */
  309.     if ( ! function_exists( 'change_defaults' ) ) {
  310.         function change_defaults( $defaults ) {
  311.             $defaults['str_replace'] = 'Testing filter hook!';
  312.  
  313.             return $defaults;
  314.         }
  315.     }
  316.  
  317.     /**
  318.      * Removes the demo link and the notice of integrated demo from the redux-framework plugin
  319.      */
  320.     if ( ! function_exists( 'remove_demo' ) ) {
  321.         function remove_demo() {
  322.             // Used to hide the demo mode link from the plugin page. Only used when Redux is a plugin.
  323.             if ( class_exists( 'ReduxFrameworkPlugin' ) ) {
  324.                 remove_filter( 'plugin_row_meta', array(
  325.                     ReduxFrameworkPlugin::instance(),
  326.                     'plugin_metalinks'
  327.                 ), null, 2 );
  328.  
  329.                 // Used to hide the activation notice informing users of the demo panel. Only used when Redux is a plugin.
  330.                 remove_action( 'admin_notices', array( ReduxFrameworkPlugin::instance(), 'admin_notices' ) );
  331.             }
  332.         }
  333.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement