WordPress enqueue js script file in child theme — December 15, 2017

WordPress enqueue js script file in child theme

define( 'template_child_directory', dirname( get_bloginfo('stylesheet_url')));

function hermosa_child_enqueue_js() {
	wp_register_script('custom_js', template_child_directory . '/assets/js/custom.js', array( 'jquery' ),false,true);
	wp_enqueue_script( 'custom_js' );
//send any variable to script
    wp_localize_script( 'custom_js', 'custom', array(
        'ajax_url' => admin_url( 'admin-ajax.php' )
    ));
}
add_action('wp_enqueue_scripts', 'hermosa_child_enqueue_js');

For better explanation use wordpress documentation please.

Advertisements
Ubuntu Schedule a cron Job for Specific Range of Time — December 14, 2017

Ubuntu Schedule a cron Job for Specific Range of Time

Schedule a Job for Specific Range of Time
MIN HOUR DOM MON DOW CMD

eg
30 08 10 06 * /home/ramesh/full-backup

30 – 30th Minute
08 – 08 AM
10 – 10th Day
06 – 6th Month (June)
* – Every day of the week



better explanation
# 1. Entry: Minute when the process will be started [0-60]
# 2. Entry: Hour when the process will be started [0-23]
# 3. Entry: Day of the month when the process will be started [1-28/29/30/31]
# 4. Entry: Month of the year when the process will be started [1-12]
# 5. Entry: Weekday when the process will be started [0-6] [0 is Sunday] correct ubuntu documentation
#
# all x min = */x

So according to this your 5 8 * * 6 would run 8:05 every Saturday.
javascript Get query string parameters — December 11, 2017

javascript Get query string parameters

Now there is super easy way to do this.

// Assuming "?post=1234&action=edit"
    var urlParams = new URLSearchParams(window.location.search);
    console.log(urlParams.has('post')); // true or false
    console.log(urlParams.get('post')); // get the value of key (post)
    //if u have more than one query parameters with same key
    console.log(urlParams.getAll('action')); // ["edit"]
    console.log(urlParams.toString()); // "?post=1234&action=edit"
    urlParams.append('active', '1'); //append new key and value to query string

for more help read this article

javascript get current page Url with or without query string — December 5, 2017
jQuery remove empty element from an array — December 4, 2017
Ubuntu kill process by PID — November 20, 2017
javascript check if variable is an array —