script_debug wordpress code example
Example 1: debug wordpress
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
Example 2: wp_localize_script
<?php
function pw_load_scripts() {
wp_enqueue_script('pw-script', plugin_dir_url( __FILE__ ) . 'js/pw-script.js');
wp_localize_script('pw-script', 'pw_script_vars', array(
'alert' => __('Hey! You have clicked the button!', 'pippin')
)
);
}
add_action('wp_enqueue_scripts', 'pw_load_scripts');