• After uploading the Customizr’s example child theme (empty one) to my RTL WP site, my site broke. Apparently the reason is that the ltr blue.css file is processed instead of the one in “inc/css/rtl” one.

    My conclusion is that the following code, found in “inc/class-fire-init.php“, is flawed:

    /**
        * Returns the active path+skin.css
        *
        * @package Customizr
        * @since Customizr 3.0.15
        */
        function tc_active_skin() {
          $skin           = esc_attr( tc__f( '__get_option' , 'tc_skin' ) );
    
          //Finds the good path : are we in a child theme and is there a skin to override?
          $remote_path    = false;
          $remote_path    = ( TC___::$instance -> tc_is_child() && file_exists(TC_BASE_CHILD .'inc/css/' . $skin) ) ? TC_BASE_URL_CHILD .'inc/css/' : $remote_path ;
          $remote_path    = ( !$remote_path && file_exists(TC_BASE .'inc/css/' . $skin) ) ? TC_BASE_URL .'inc/css/' : $remote_path ;
          //Checks if there is a rtl version of the selected skin if needed
          if ('ar' == WPLANG || 'he_IL' == WPLANG) {
            $remote_path   = ( TC___::$instance -> tc_is_child() && file_exists(TC_BASE_CHILD .'inc/css/rtl/' . $skin) ) ? TC_BASE_URL_CHILD .'inc/css/rtl/' : $remote_path ;
            $remote_path   = ( !TC___::$instance -> tc_is_child() && file_exists(TC_BASE .'inc/css/rtl/' . $skin) ) ? TC_BASE_URL .'inc/css/rtl/' : $remote_path ;
          } 
    
          //Defines the active skin and fallback to blue.css if needed
          $tc_active_skin  = $remote_path ? $remote_path.$skin : TC_BASE_URL.'inc/css/blue.css';
          return apply_filters ( 'tc_active_skin' , $tc_active_skin );
        }

    The code above will try and find the RTL skin .css file in the child theme, instead of the original customizr.

    My current solution is a hacky one – I simply created a “inc/css/rtl” folder in the child theme, and imported all css files, including fonts and font folders.

    This obvious problem with this solution is that after a Customizr upgrade, those copied css files won’t be updated.

    I’m open to suggestions… thanks:)

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter The Merovingian

    (@the-merovingian)

    Update:

    I’ve been using an import code (example below) in the css files of my child theme’s “inc/css/rtl” folder, which eliminates the problem I mentioned, and automatically imports the new css files after an update in the main theme.

    I still need a better way to do this, I was unsuccessful in using the functions.php of my child theme to override the buggy “tc_active_skin” function.

    here is what I currently for the “customizr-child/inc/css/rtl/blue.css” file:
    @import url("../../../../customizr/inc/css/rtl/blue.css");

    Thanks for this. Which language/country code are you using?

    Thread Starter The Merovingian

    (@the-merovingian)

    Using ‘he_IL’ (Hebrew).

    I should add that currently I’m using a permanent fix to this problem –

    I simply replaced the original “TC_init->tc_active_skin()” function in “parts/class-fire-init.php”, like such:

    1) I’ve created a “tc_active_skin_FIXED()” function in my child-theme’s functions.php file. this function is based on the original “tc_active_skin()” with a few changes fixing the bug in this discussion.

    2) I’ve then created a “editor_style_child()” function to re-register editor styles using the corrected active skin function mentioned above.

    3) I’ve created a “wp_enqueue_scripts_child()” to re-register & re-enqueue the ‘customizr-skin’ using the same corrected active skin function.

    4) I’ve used “add_action()” to hook “wp_enqueue_scripts_child()” to “wp_enqueue_scripts” (priority=100), and to hook “editor_style_child()” to “after_setup_theme” (MUST use priority=20).

    Here is a draft of the 2 new functions mentions in section 2,3 :

    /**
     * re-register editor-styles and add the fixed tc_active_skin_FIXED()
     */
    function editor_style_child() {
    	$success = remove_editor_styles();
    	if ($success) {
    		add_editor_style( array( TC_BASE_URL.'inc/admin/css/editor-style.css',
    						$this -> tc_active_skin_FIXED() ,
    						get_stylesheet_uri() ,
    						TC_BASE_URL_CHILD.'editor-style-child.css'
    		) );
    	}
    }
    
    function wp_enqueue_scripts_child() {
    	// ------------------------------------------------------------------------------------------------------------------
    	// replace tc_active_skin() invoked in "parts/class-fire-resources.php: TC_resources->tc_enqueue_customizr_styles()"
    	// ------------------------------------------------------------------------------------------------------------------
    
    	// remove css + un-register so we can re-register under same handle name 'customizr-skin'.
    
    	if ( wp_style_is( 'customizr-skin' , $list = 'enqueued' ) )
    		wp_dequeue_style( 'customizr-skin' );
    
    	if ( wp_style_is( 'customizr-skin' , $list = 'registered' ) )
    			wp_deregister_style( 'customizr-skin' );
    
    	// re-register & re-queue new function
    
    	wp_register_style( 'customizr-skin' , $this -> tc_active_skin_FIXED(), array(), CUSTOMIZR_VER, $media = 'all' );
    	wp_enqueue_style( 'customizr-skin' );
    }

    I won’t share the full code since it might seem a bit too convoluted and confusing. But if someone insists, i’ll post it.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Bug: child theme on RTL-based WP’ is closed to new replies.