• I tried to contribute to the plugin by pushing pull request, but with SVN it is not possible, as I am not in the list of contributors and it seems you dont have github repository of this plugin.

    I hope this fix will be visible too other people having this problem too:
    in includes/functions.php lines 37-47 should be changed to this:

    add_action('init', function() {

       if ( !function_exists( 'get_plugin_data' ) ) {

          require_once( ABSPATH . 'wp-admin/includes/plugin.php' );

       }

       global $jr_mt_plugin_data;

       $jr_mt_plugin_data = get_plugin_data( JR_MT_FILE );

       $jr_mt_plugin_data['slug'] = basename( dirname( JR_MT_FILE ) );

       global $jr_mt_options_cache;

       $all_options = wp_load_alloptions();

       $jr_mt_options_cache['stylesheet'] = $all_options['stylesheet'];

       $jr_mt_options_cache['template'] = $all_options['template'];

    });
Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter ImageLovro Hrust

    (@lovor)

    To complete fixing problems which WP_DEBUG set to true reports (deprecated function call), in includes/admin.php, line 164 should be changed to this:

          unregister_setting( ‘jr_mt_settings’, ‘jr_mt_settings’ );

    Thread Starter ImageLovro Hrust

    (@lovor)

    Also in includes/functions.php
    lines 153-170 to:

    if ( function_exists( 'mb_strlen' ) ) {

       function jr_mt_strlen( $string ) {

          return mb_strlen( $string ?? '' );

       }

    } else {

       function jr_mt_strlen( $string ) {

          return strlen( $string ?? '' );

       }

    }

    if ( function_exists( 'mb_strtolower' ) ) {

       function jr_mt_strtolower( $string ) {

          return mb_strtolower( $string ?? '');

       }

    } else {

       function jr_mt_strtolower( $string ) {

          return strtolower( $string ?? '' );

       }

    }
    ImageJochenT

    (@jochent)

    Hi Lovro, Thank you very much for your code changes. This stopped the entries in the error log but unfortunately resulted in a crash of the frontend, but motivated me to look deeper into the code. I had to change some more to get it to work again. In includes/functions.php lines 177-180 of the original file, function jr_mt_current_theme() should be changed to:

    function jr_mt_current_theme( $option ) {
    global $jr_mt_options_cache;
    return !empty( $jr_mt_options_cache[$option] ) ? $jr_mt_options_cache[$option] : '';
    }

    In includes/select-theme.php lines 43-44 of the original file, two calls to function add_filter() should be changed to:

    add_filter( 'pre_option_stylesheet', 'jr_mt_stylesheet', 10, 3 );
    add_filter( 'pre_option_template', 'jr_mt_template', 10, 3 );

    In includes/select-theme.php lines 98-104 of the original file, functions jr_mt_stylesheet() and jr_mt_template() should be changed to:

    function jr_mt_stylesheet( $pre_option, $option, $default_value ) {
    $pre_stylesheet = jr_mt_theme( 'stylesheet' );
    return !empty( $pre_stylesheet ) ? $pre_stylesheet : $default_value;
    }

    function jr_mt_template( $pre_option, $option, $default_value ) {
    $pre_template = jr_mt_theme( 'template' );
    return !empty( $pre_template ) ? $pre_template : $default_value;
    }

    This solved my problem. May be the site gets a bit slow, but it does work. For others with other configurations this still may not be enough to solve the problems.

    ImageJochenT

    (@jochent)

    I’ve testet it on the production server now and could not find any slow downs in loading times.

    Thread Starter ImageLovro Hrust

    (@lovor)

    It is not necessarily about slowing loading, but about producing warning message. I didn’t test loading time. Anyway, thanks for your code changes.

    to get this working without ANY error messages in the log, I had to do two more things in my environment:

    1) in /includes/functions.php
    extend the “add_action (‘init’, function() ) {

    to also include the “if ( is_plugin_active_for_network($jr_mt_plugin_basename)

    2)
    and (just before that is_plugin_active_for_network($jr_mt_plugin_basename)
    I had to add the following line to make sure the variable is available:

    if (!isset ($jr_mt_plugin_basename) ) {$jr_mt_plugin_basename = plugin_basename( JR_MT_FILE );}

    this did it for me!

    • This reply was modified 10 months, 3 weeks ago by Imagesitsvienna.
Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Translation loading… too early’ is closed to new replies.