Skip to content

Commit

Permalink
Sample-config fixes to avoid conflicts, and better organizing.
Browse files Browse the repository at this point in the history
  • Loading branch information
dovy committed Jul 2, 2015
1 parent 8c1554c commit ea7e3ae
Showing 1 changed file with 105 additions and 87 deletions.
192 changes: 105 additions & 87 deletions sample/sample-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,29 +54,6 @@
}
}

/*
*
* --> Action hook examples
*
*/

// If Redux is running as a plugin, this will remove the demo notice and links
//add_action( 'redux/loaded', 'remove_demo' );

// Function to test the compiler hook and demo CSS output.
// Above 10 is a priority, but 2 in necessary to include the dynamically generated CSS to be sent to the function.
//add_filter('redux/options/' . $opt_name . '/compiler', 'compiler_action', 10, 3);

// Change the arguments after they've been declared, but before the panel is created
//add_filter('redux/options/' . $opt_name . '/args', 'change_arguments' );

// Change the default value of a field after it's been set, but before it's been useds
//add_filter('redux/options/' . $opt_name . '/defaults', 'change_defaults' );

// Dynamically add a section. Can be also used to modify sections/fields
//add_filter('redux/options/' . $opt_name . '/sections', 'dynamic_section');


/**
* ---> SET ARGUMENTS
* All the possible arguments for Redux.
Expand Down Expand Up @@ -299,20 +276,20 @@

// -> START Basic Fields
Redux::setSection( $opt_name, array(
'title' => __( 'Basic Fields', 'redux-framework-demo' ),
'id' => 'basic',
'desc' => __( '', 'redux-framework-demo' ),
'title' => __( 'Basic Fields', 'redux-framework-demo' ),
'id' => 'basic',
'desc' => __( '', 'redux-framework-demo' ),
'customizer_width' => '400px',
'icon' => 'el el-home'
'icon' => 'el el-home'
) );

Redux::setSection( $opt_name, array(
'title' => __( 'Checkbox', 'redux-framework-demo' ),
'id' => 'basic-checkbox',
'subsection' => true,
'title' => __( 'Checkbox', 'redux-framework-demo' ),
'id' => 'basic-checkbox',
'subsection' => true,
'customizer_width' => '450px',
'desc' => __( 'For full documentation on this field, visit: ', 'redux-framework-demo' ) . '<a href="http://docs.reduxframework.com/core/fields/checkbox/" target="_blank">http://docs.reduxframework.com/core/fields/checkbox/</a>',
'fields' => array(
'desc' => __( 'For full documentation on this field, visit: ', 'redux-framework-demo' ) . '<a href="http://docs.reduxframework.com/core/fields/checkbox/" target="_blank">http://docs.reduxframework.com/core/fields/checkbox/</a>',
'fields' => array(
array(
'id' => 'opt-checkbox',
'type' => 'checkbox',
Expand Down Expand Up @@ -359,12 +336,12 @@
)
) );
Redux::setSection( $opt_name, array(
'title' => __( 'Radio', 'redux-framework-demo' ),
'id' => 'basic-Radio',
'subsection' => true,
'title' => __( 'Radio', 'redux-framework-demo' ),
'id' => 'basic-Radio',
'subsection' => true,
'customizer_width' => '500px',
'desc' => __( 'For full documentation on this field, visit: ', 'redux-framework-demo' ) . '<a href="http://docs.reduxframework.com/core/fields/radio/" target="_blank">http://docs.reduxframework.com/core/fields/radio/</a>',
'fields' => array(
'desc' => __( 'For full documentation on this field, visit: ', 'redux-framework-demo' ) . '<a href="http://docs.reduxframework.com/core/fields/radio/" target="_blank">http://docs.reduxframework.com/core/fields/radio/</a>',
'fields' => array(
array(
'id' => 'opt-radio',
'type' => 'radio',
Expand Down Expand Up @@ -403,8 +380,8 @@
'desc' => __( 'This is the description field, again good for additional info.', 'redux-framework-demo' ),
'label' => true,
'options' => array(
'Text One' => 'Item 1',
'Text Two' => 'Item 2',
'Text One' => 'Item 1',
'Text Two' => 'Item 2',
'Text Three' => 'Item 3',
)
),
Expand All @@ -431,12 +408,12 @@


Redux::setSection( $opt_name, array(
'title' => __( 'Text', 'redux-framework-demo' ),
'desc' => __( 'For full documentation on this field, visit: ', 'redux-framework-demo' ) . '<a href="http://docs.reduxframework.com/core/fields/text/" target="_blank">http://docs.reduxframework.com/core/fields/text/</a>',
'id' => 'basic-Text',
'subsection' => true,
'title' => __( 'Text', 'redux-framework-demo' ),
'desc' => __( 'For full documentation on this field, visit: ', 'redux-framework-demo' ) . '<a href="http://docs.reduxframework.com/core/fields/text/" target="_blank">http://docs.reduxframework.com/core/fields/text/</a>',
'id' => 'basic-Text',
'subsection' => true,
'customizer_width' => '700px',
'fields' => array(
'fields' => array(
array(
'id' => 'text-example',
'type' => 'text',
Expand Down Expand Up @@ -522,10 +499,10 @@

// -> START Editors
Redux::setSection( $opt_name, array(
'title' => __( 'Editors', 'redux-framework-demo' ),
'id' => 'editor',
'title' => __( 'Editors', 'redux-framework-demo' ),
'id' => 'editor',
'customizer_width' => '500px',
'icon' => 'el el-edit',
'icon' => 'el el-edit',
) );

Redux::setSection( $opt_name, array(
Expand Down Expand Up @@ -721,9 +698,9 @@
'title' => __( 'Palette Color Option', 'redux-framework-demo' ),
'subtitle' => __( 'Only color validation can be done on this field type', 'redux-framework-demo' ),
'desc' => __( 'This is the description field, again good for additional info.', 'redux-framework-demo' ),
'default' => 'red',
'palettes' => array(
'red' => array(
'default' => 'red',
'palettes' => array(
'red' => array(
'#ef9a9a',
'#f44336',
'#ff1744',
Expand All @@ -746,7 +723,7 @@
),
)
) );


// -> START Design Fields
Redux::setSection( $opt_name, array(
Expand Down Expand Up @@ -2254,17 +2231,48 @@
* <--- END SECTIONS
*/


/*
*
* YOU MUST PREFIX THE FUNCTIONS BELOW AND ACTION FUNCTION CALLS OR ANY OTHER CONFIG MAY OVERRIDE YOUR CODE.
*
*/

/*
*
* --> Action hook examples
*
*/

// If Redux is running as a plugin, this will remove the demo notice and links
//add_action( 'redux/loaded', 'remove_demo' );

// Function to test the compiler hook and demo CSS output.
// Above 10 is a priority, but 2 in necessary to include the dynamically generated CSS to be sent to the function.
//add_filter('redux/options/' . $opt_name . '/compiler', 'compiler_action', 10, 3);

// Change the arguments after they've been declared, but before the panel is created
//add_filter('redux/options/' . $opt_name . '/args', 'change_arguments' );

// Change the default value of a field after it's been set, but before it's been useds
//add_filter('redux/options/' . $opt_name . '/defaults', 'change_defaults' );

// Dynamically add a section. Can be also used to modify sections/fields
//add_filter('redux/options/' . $opt_name . '/sections', 'dynamic_section');

/**
* This is a test function that will let you see when the compiler hook occurs.
* It only runs if a field set with compiler=>true is changed.
* */
function compiler_action( $options, $css, $changed_values ) {
echo '<h1>The compiler hook has run!</h1>';
echo "<pre>";
print_r( $changed_values ); // Values that have changed since the last save
echo "</pre>";
//print_r($options); //Option values
//print_r($css); // Compiler selector CSS values compiler => array( CSS SELECTORS )
if ( ! function_exists( 'compiler_action' ) ) {
function compiler_action( $options, $css, $changed_values ) {
echo '<h1>The compiler hook has run!</h1>';
echo "<pre>";
print_r( $changed_values ); // Values that have changed since the last save
echo "</pre>";
//print_r($options); //Option values
//print_r($css); // Compiler selector CSS values compiler => array( CSS SELECTORS )
}
}

/**
Expand Down Expand Up @@ -2317,48 +2325,58 @@ function redux_my_custom_field( $field, $value ) {
* NOTE: the defined constants for URLs, and directories will NOT be available at this point in a child theme,
* so you must use get_template_directory_uri() if you want to use any of the built in icons
* */
function dynamic_section( $sections ) {
//$sections = array();
$sections[] = array(
'title' => __( 'Section via hook', 'redux-framework-demo' ),
'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' ),
'icon' => 'el el-paper-clip',
// Leave this as a blank section, no options just some intro text set above.
'fields' => array()
);

return $sections;
if ( ! function_exists( 'dynamic_section' ) ) {
function dynamic_section( $sections ) {
//$sections = array();
$sections[] = array(
'title' => __( 'Section via hook', 'redux-framework-demo' ),
'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' ),
'icon' => 'el el-paper-clip',
// Leave this as a blank section, no options just some intro text set above.
'fields' => array()
);

return $sections;
}
}

/**
* 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.
* */
function change_arguments( $args ) {
//$args['dev_mode'] = true;
if ( ! function_exists( 'change_arguments' ) ) {
function change_arguments( $args ) {
//$args['dev_mode'] = true;

return $args;
return $args;
}
}

/**
* Filter hook for filtering the default value of any given field. Very useful in development mode.
* */
function change_defaults( $defaults ) {
$defaults['str_replace'] = 'Testing filter hook!';
if ( ! function_exists( 'change_defaults' ) ) {
function change_defaults( $defaults ) {
$defaults['str_replace'] = 'Testing filter hook!';

return $defaults;
return $defaults;
}
}

// Remove the demo link and the notice of integrated demo from the redux-framework plugin
function remove_demo() {

// Used to hide the demo mode link from the plugin page. Only used when Redux is a plugin.
if ( class_exists( 'ReduxFrameworkPlugin' ) ) {
remove_filter( 'plugin_row_meta', array(
ReduxFrameworkPlugin::instance(),
'plugin_metalinks'
), null, 2 );

// Used to hide the activation notice informing users of the demo panel. Only used when Redux is a plugin.
remove_action( 'admin_notices', array( ReduxFrameworkPlugin::instance(), 'admin_notices' ) );
/**
* Removes the demo link and the notice of integrated demo from the redux-framework plugin
*/
if ( ! function_exists( 'remove_demo' ) ) {
function remove_demo() {
// Used to hide the demo mode link from the plugin page. Only used when Redux is a plugin.
if ( class_exists( 'ReduxFrameworkPlugin' ) ) {
remove_filter( 'plugin_row_meta', array(
ReduxFrameworkPlugin::instance(),
'plugin_metalinks'
), null, 2 );

// Used to hide the activation notice informing users of the demo panel. Only used when Redux is a plugin.
remove_action( 'admin_notices', array( ReduxFrameworkPlugin::instance(), 'admin_notices' ) );
}
}
}

0 comments on commit ea7e3ae

Please sign in to comment.