• Hi I come with an issue + a possible solution.

    As I have seen your plugin moves the forms stylesheet to uploads folder manually. This is not a good practice as you need to use WP functions to upload files to the uploads folder. Think that not everyone uses its own uploads folder but third-party services to store all the files.

    That said, I’ve also seen that when the stylesheet is missing you load the styles using AJAX. This causes issues randomly as the styles are not always loaded so I have a solution for that.

    1. I avoid to load the stylesheet in uploads folder with this hook:

    add_filter( 'get_frm_stylesheet', 'formidable_hooks_get_frm_stylesheet', 500 );
    function formidable_hooks_get_frm_stylesheet( $stylesheet ) {
    	if ( isset( $stylesheet['formidable'] ) ) {
    		$stylesheet['formidable'] = add_query_arg( 'load_frmpro_css', 'true', site_url() );
    	}
    	return $stylesheet;
    }

    2. I avoid using AJAX for the styles:

    add_action( 'plugins_loaded', 'formidable_hooks_load_custom_stylesheet' );
    function formidable_hooks_load_custom_stylesheet() {
    	if ( isset( $_GET['load_frmpro_css'] ) && $_GET['load_frmpro_css'] === 'true' && class_exists( 'FrmProAppController' ) ) {
    		FrmProAppController::load_css();
    	}
    }

    I hope this helps to improve the plguin.

    Thanks.

    https://wordpress.org/plugins/formidable/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Steph Wells

    (@sswells)

    It doesn’t sound like you are running the current version. Do you still have trouble with this in the current version?

    Thread Starter Ignacio Cruz Moreno

    (@igmoweb)

    Hi there.

    I’m very sorry for the delay, I missed this. We came up with a solution for this. The problem is that you generate the file into default uploads folder. We use an external service for our images/files. There are two solutions for this:

    1. Use WP functions to interact with upload API like this: https://codex.wordpress.org/Function_Reference/wp_handle_upload that will upload the file where it should.
    2. Do not generate any file but dinamically generate the CSS. This has been our solution and here’s the code:

    add_filter( 'get_frm_stylesheet', 'formidable_hooks_get_frm_stylesheet', 500 );
    function formidable_hooks_get_frm_stylesheet( $stylesheet ) {
    	if ( isset( $stylesheet['formidable'] ) ) {
    		$stylesheet['formidable'] = add_query_arg( 'load_frmpro_css', 'true', site_url() );
    	}
    	return $stylesheet;
    }
    
    add_action( 'wp_loaded', 'formidable_hooks_load_custom_stylesheet' );
    function formidable_hooks_load_custom_stylesheet() {
    	if ( isset( $_GET['load_frmpro_css'] ) && $_GET['load_frmpro_css'] === 'true' && class_exists( 'FrmProAppController' ) ) {
    		if ( method_exists( 'FrmProAppController', 'load_css' ) ) {
    			FrmProAppController::load_css();
    		}
    		if ( method_exists( 'FrmAppController', 'load_css' ) ) {
    			FrmAppController::load_css();
    		}
    
    	}
    }

    The code loads the CSS trhough the next URL:

    HOME_URL?load_frmpro_css=true

    if $_GET[‘load_frmpro_css’] is detected, FrmProAppController::load_css(); or FrmAppController::load_css(); is triggered (I kept both for backward compatibility). Thos functions will echo the CSS rules.

    I think it would be nice if you pass it to the devs.

    Thanks!

    Plugin Author Steph Wells

    (@sswells)

    Thanks for the example!

    Since 2.0, the WP upload functions have been used. Are you up to date with Formidable?

    Thread Starter Ignacio Cruz Moreno

    (@igmoweb)

    Not for the moment, this is for a big site and need to update carefully but thanks anyway, we’ll take a look

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Stylesheets not loaded’ is closed to new replies.