June 17, 2015

Wordpress define your javascript right way

Sometime you see in Wordpress line of code like: wp_enqueue_script( 'swfobject' );

This is the way to call javascript already in Wordpress but how to define it? I will help you to use it.

Have many ways to insert external javascript file into Wordpress theme. But you should use way below to register new javascript file and add it to your template when needed.

Here is code:

Firstly, use "wp_register_script" function to define your file:

wp_register_script( 'qtobject', plugins_url('/path/to/your/file.js'), array(), '1.0.0' );

"qtobject" is script name handle

Then enqueues script anywhere in template:

wp_enqueue_script( 'qtobject' );

January 28, 2015

[Linux] CHMOD – how to change file permission

chmod 777 config.php
Available permission type: (below is not command)
First number is for the owner, second for the group, and third for everyone.
7 = Read + Write + Execute
6 = Read + Write
5 = Read + Execute
4 = Read
3 = Write + Execute
2 = Write
1 = Execute
0 = All access denied

jQuery check exists element call function

Function:
jQuery.exists = function(selector) {return ($(selector).length > 0);}
Usage:
if($.exists(".datetimepicker")){ $(".datetimepicker").datetimepicker({ pickTime: false }); }

January 27, 2015

There was an error in this gadget