• Resolved Jonas Lundman

    (@jonas-lundman)


    Hi
    Im working with diffrent translate methods and using plain mo/po switch in the WP settings does not rescan the php template-1 file.

    If Im correct(?) the localization of the template-1.php is made (translated) into the database only ONCE and only to the locale at the very moment the plugin is activated for the first time.

    It is the “EMail sent” and “…any requ, please contact” in the footer that get stucked in the current lang.

    I wanna use the default new wordpress lang switcher in my base projects without using WPML – that handle this problem.

    Is it possible to “flush” and do that on the hook of Locale changes in general settings for WordPress?

    Thanks

    https://wordpress.org/plugins/wp-better-emails/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Nicolas Lemoine

    (@nlemoine)

    Hi Jonas,

    The problem with this approach is that I would have to reload and save the whole default template, and that it would overwrite the changes made by the user. Unfortunatley, I can’t do that because it won’t match most use cases.

    But you can implement the hook on your functions.php file. Try the code below (untested).

    add_action('update_option_WPLANG', function( $old_value, $value ) {
    
    	if( $old_value === $value )
    		return false;
    
    	global $wp_better_emails;
    	delete_option('wpbe_options');
    	$wp_better_emails->set_options();
    
    });

    Note that all options are deleted on each language change.

    Thread Starter Jonas Lundman

    (@jonas-lundman)

    Hi
    Thanks for your answer & time for support. Im gonna try to hook in as suggested. The template should maybe be saved in a separate option, and frwite into a theme template file in user folder theme. A simple checkbox on the setting to allow re-read the user template on language change.

    Ill will do some invetigation on your default opt array…

    THanks, marking this as solved.

    Plugin Author Nicolas Lemoine

    (@nlemoine)

    The template should maybe be saved in a separate option, and frwite into a theme template file in user folder theme. A simple checkbox on the setting to allow re-read the user template on language change.

    Writing files in the user folder is a bad practice for many reasons.

    The main problem is that there is only one template and once activated and saved, I have to consider that I can’t modify it anymore (because the user could have made changes that It would not be correct to overwrite).

    To be honest, I’d like to update the plugin to add some new features (multiple templates, responsive templates, smtp, etc.). It’s still doing the job but could be improved. But I’m unfortunately lacking spare time to achieve this. I’ll try to release a new version by spring time.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Reload the template-1 php file’ is closed to new replies.