Execute inline javascript in wordpress after page fully loaded

I think you should in this case use echo: function print_script() { echo ‘<script type=”text/javascript”> window.onload = function () { var loadTime = window.performance.timing.domContentLoadedEventEnd-window.performance.timing.navigationStart; alert(loadTime); console.log(loadTime); } var var1 = <?php echo json_encode(‘var1’); ?>; var var2 = <?php echo json_encode(‘var2’); ?>; var var3 = <?php echo json_encode(‘var3′); ?>; </script>’; } add_action(‘wp_print_scripts’, ‘print_script’);

Multiple image selection custom widget

I’ve found a solution by myself! With two lines of code I’m now able to save all the selected images and then retrive them on the front-end. I have added an array in the JS code part: // media library script (function($){ $(document).ready(function(){ $(document).on(‘click’, ‘.upload_image_button’, function(e){ e.preventDefault(); var button = $(this); var file_frame = wp.media.frames.file_frame … Read more

Creating custom “player-objects”

For players you could create a custom post type, like so function my_player_cpt() { $labels = array( ‘name’ => _x( ‘Players’, ‘Post type general name’, ‘textdomain’ ), ‘singular_name’ => _x( ‘Player’, ‘Post type singular name’, ‘textdomain’ ), ); $args = array( ‘labels’ => $labels, ‘public’ => true, ‘taxonomies’ => array(‘game’) ‘supports’ => array( ‘title’, // … Read more