• Resolved fabx77

    (@fabx77)


    Hello,
    WP: 6.9.1
    Theme: Graphene
    PHP: 8.3

    I added a code snippet, but as soon as I run it, it displays the following message in the Debug.log file:


    The _load_textdomain_just_in_time function was called incorrectly. Loading the translation for the graphene domain was triggered too early. This usually indicates that code in the plugin or theme is executing too early. Translations should be loaded at the time of the init action or later. (This message was added in version 6.7.0.)

    My other plugins are up to date, and I’ve deactivated most of them to keep only the essentials.

    P.S.: For debugging, I added error_log("Hello") at the very beginning of my code. I can see them in the debug.log file, but I don’t see the error_log statements within my functions. Does this mean it’s not interpreting my functions correctly?

    Otherwise, your plugin is great!

    Could you help me because I’m completely stuck? Thank you so much! :-))

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support markomiljanovic

    (@markomiljanovic)

    Hi @fabx77

    The message you’re seeing is a WordPress 6.7+ notice that appears when a theme or plugin loads its translations too early, before the init hook.

    The part: “Loading the translation for the graphene domain was triggered too early.” Indicates that somewhere in your snippet you’re loading translations for the graphene text domain. To resolve it, make sure that code runs on or after inithook.

    You can share your snippet, and we can review it and suggest the fix.

    As for your error_log() calls: seeing the one at the top, but not the ones inside your functions, is expected. The top-level error_log( "Hello" ); runs as soon as the snippet loads, but the logs inside your functions only run when the hooks they’re attached to actually fire. If you’re not seeing those entries, it likely means the action or event they’re hooked to isn’t triggered on the page you’re testing.

    Thanks,

    Thread Starter fabx77

    (@fabx77)

    Good evening,

    Thank you so much for your reply!!!

    Indeed, I’m not very comfortable with hooks…

    Here’s a very early version of my code:

    // // Create a cron job to run the day after an event happens or ends
    function set_expiry_date( $post_id ) {
    error_log( 'start of function' );

    // See if an event_end_date or event_date has been entered and if not then end the function
    if( get_post_meta( $post_id, $key = 'event_end_date', $single = true ) ) {

    // Get the end date of the event in unix grenwich mean time
    $acf_end_date = get_post_meta( $post_id, $key = 'event_end_date', $single = true );

    } elseif ( get_post_meta( $post_id, $key = 'event_date', $single = true ) ) {

    // Get the start date of the event in unix grenwich mean time
    $acf_end_date = get_post_meta( $post_id, $key = 'event_date', $single = true );

    } else {

    // No start or end date. Lets delete any CRON jobs related to this post and end the function.
    wp_clear_scheduled_hook( 'make_past_event', array( $post_id ) );
    return;

    }
    }
    // ....
    .....
    .....


    // Hook into the save_post_{post-type} function to create/update the cron job everytime an event is saved.
    add_action( 'acf/save_post', 'set_expiry_date', 20 );

    The error_log “Start of function” within the function never appears in the debug.log file, so I deduce that the function is never called…

    Thank you so much again for your help!!! :-))

    • This reply was modified 1 month, 2 weeks ago by fabx77.
Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.