Dynamically switch file in get_template_directory_uri() | Function

Question

I need to switch scheme color of my WordPress theme trough Redux option panel.

My plan is switch the CSS file trough get_template_directory_uri() | Function.

The scenario is:

  1. Create 2 scheme color: dark and light with dark.css and libght.css.

  2. Control from redux panel with this code:

    <?php
    Redux::setSection( $opt_name, array(
     'title'  => __( 'Color Scheme', 'javapaper' ),
     'id'     => 'test_scheme',
     'icon'   => 'el el-list',
     'fields' => array(
         array(
             'id'       => 'color_scheme',
             'type'     => 'image_select',
             'title'    => __( 'SELECT Color Scheme', 'javapaper' ),
             'subtitle' => __( '2 scheme Available', 'javapaper' ),              
             'options'  => array(
                 'dark' => array(
                     'title' => 'dark',
                     'alt' => 'dark',
                     'img' => get_stylesheet_directory_uri() . '/images/header-styledefault.png'
                 ),              
                 'light' => array(
                     'title' => 'light',                 
                     'alt' => 'light',
                     'img' => get_stylesheet_directory_uri() . '/images/header-style2.png'
                 )                   
             ),
    
             'default'  => 'dark'
         ),          
    
          )
      ) );
    ?>   
    
  3. Call the code from Redux panel into get_template_directory_uri() | Function like this:

     wp_enqueue_style( 'javapaper-lightbox-style', get_template_directory_uri() . '/css/$redux_demo["color_scheme"]' );  
    

But Unfortunately It did not work. I am newbie on php. Please help.

0
Chl Lila 4 months 2022-04-17T16:48:32-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse