Hi Frank, love the plugin thanks! Here’s my two cents on it…
Problem Example: In the plugin file player_sizes.inc.php, at the top of the file (around line 11), the plugin calls:
__('Mini 16:9 player…', 'wp-youtube-lyte');
But WordPress hasn’t fully initialized yet (specifically, translations haven’t been fully prepared), so any __() or _e() call happening too early will now trigger a notice in WordPress 6.7+.
Potential Solution: We can’t defer loading the whole player_sizes.inc.php file until after WordPress is ready (preferably after init), because there are so many other things that early depend on those arrays that get defined in there. But if you remove all the translations aspect from that file…
Eg. delete these lines:
$plugin_dir = basename( dirname( __FILE__ ) ) . '/languages';
load_plugin_textdomain( 'wp-youtube-lyte', false, $plugin_dir );
and also replace each of these below ones...:
$pSize[8]['t'] = __( 'Mini 16:9 player', 'wp-youtube-lyte' );
$pSize[0]['t'] = __( 'Smaller 4:3 player', 'wp-youtube-lyte' );
$pSize[1]['t'] = __( 'Smaller 16:9 player', 'wp-youtube-lyte' );
$pSize[2]['t'] = __( 'Standard value, YouTube default for 4:3-ratio video', 'wp-youtube-lyte' );
$pSize[3]['t'] = __( 'YouTube default for 16:9-ratio video', 'wp-youtube-lyte' );
$pSize[4]['t'] = __( 'Larger 4:3 player', 'wp-youtube-lyte' );
$pSize[5]['t'] = __( 'Larger 16:9 player', 'wp-youtube-lyte' );
$pSize[6]['t'] = __( 'Maxi 4:3 player', 'wp-youtube-lyte' );
$pSize[7]['t'] = __( 'Maxi 16:9 player', 'wp-youtube-lyte' );
...replace them with just the raw strings like this:
$pSize[8]['t'] = 'Mini 16:9 player';
$pSize[0]['t'] = 'Smaller 4:3 player';
$pSize[1]['t'] = 'Smaller 16:9 player';
$pSize[2]['t'] = 'Standard value, YouTube default for 4:3-ratio video';
$pSize[3]['t'] = 'YouTube default for 16:9-ratio video';
$pSize[4]['t'] = 'Larger 4:3 player';
$pSize[5]['t'] = 'Larger 16:9 player';
$pSize[6]['t'] = 'Maxi 4:3 player';
$pSize[7]['t'] = 'Maxi 16:9 player';
And then inside your main plugin file, wp-youtube-lyte.php you can wrap the translation aspects only, so they happen safely after WordPress init. For example…
Cut out lines 65 and 66:
$plugin_dir = basename( dirname( __FILE__ ) ) . '/languages';
load_plugin_textdomain( 'wp-youtube-lyte', false, $plugin_dir );
and add them back at line 68 with a whole little snippet like this to try handle the title translation after init has safely happened:
/** translate size descriptions after init */
add_action( 'init', function() {
$plugin_dir = basename( dirname( __FILE__ ) ) . '/languages';
load_plugin_textdomain( 'wp-youtube-lyte', false, $plugin_dir );
global $pSize;
if ( ! empty( $pSize ) ) {
foreach ( $pSize as $key => $size ) {
if ( isset( $size['t'] ) && is_string( $size['t'] ) ) {
$pSize[$key]['t'] = __( $size['t'], 'wp-youtube-lyte' );
}
}
}
});
Now I’m not sure how to actually test that this still works with the translation of those titles, but the error notices are gone, and everything else seems to still be working as it should, so hopefully this helps you in some way as a potential workaround?