Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Updating a CSS File Dynamically in Redux framework
- / show style.css || file.php
- // Help link: https://docs.reduxframework.com/core/advanced/updating-a-css-file-dynamically/
- add_filter('redux/options/' . $opt_name . '/compiler', 'compiler_action', 10, 3);
- function compiler_action($options, $css, $changed_values) {
- $css_dir = get_template_directory() . '/css/style.css';
- ob_start();
- require_once( get_template_directory().'/css/file.php' );
- $css = ob_get_clean();
- /** Write to options.css file **/
- global $wp_filesystem;
- WP_Filesystem();
- if ($wp_filesystem->put_contents( $css_dir, $css, FS_CHMOD_FILE ) ) {
- return true;
- }
- }
- /*
- array(
- 'id'=>'body_color_bg',
- 'type'=>'color',
- 'compiler'=>array('body_color_bg'), OR 'body_color_bg'
- 'title'=>'Body Background Color',
- 'default'=>'#FFFFFF'
- ),
- */
- // Redux Dynamic css
- function reDux_dynamic_CSS() {
- /* ------------------------------------------------------------------------ */
- /* Register Stylesheets */
- /* ------------------------------------------------------------------------ */
- wp_register_style('redux-style', get_template_directory_uri() . '/css/style.css', 'style');
- /* ------------------------------------------------------------------------ */
- /* Enqueue Styles */
- /* ------------------------------------------------------------------------ */
- wp_enqueue_style( 'redux-style');
- }
- add_action( 'wp_enqueue_scripts', 'reDux_dynamic_CSS', 1 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement