views:

34

answers:

1

Many times, while developing Wordpress plug-ins, themes or widgets, we use unnecessary lines of code and logic.

As the time goes we find and get better solutions for same logic which is tidy, simple and good in performance.

Here I would like to know such Tips & Tricks, that makes our wordpress development life simple and enjoyable.

(I will also add some of my Tips & Tricks here.)

+1  A: 
  1. Including javascript :

To include javascript in wordpress plugin,normally we use

wp_enqueue_script('PATH_TO_JAVASCRIPT');

But this include javascript in both front side and admin side of site, if that plugin is active.

If you want to activate it on only admin side use

if(is_admin()){ wp_enqueue_script('PATH_TO_JAVASCRIPT'); }

2 . Using wordpress classes, objects, functions outside wordpress:

To use wordpress classes, objects, functions outside wordpress, simple include wp-load.php file in your script

<?php include_once 'wp-load.php';?>

santosh