Loading scripts with wp_register_script and wp_enqueue_script

There are probably various ways to do this – personally I use the following for loading some small scripts only on the “new” and “edit” pages (datepicker etc.): function load_my_admin_scripts( $hook ) { if (( $hook == ‘post.php’ || $hook == ‘post-new.php’ )) { wp_enqueue_script( ‘my-datepicker’, // name / handle of the script SCRIPTS . ‘script.js’, … Read more

Is It Always a Best Practice to Decouple the Frontend from the Admin Area When Developing a WordPress Application?

Off the top of my head I can’t think of any instance where you would want the WordPress admin to be the main entry point for your website, that there isn’t a more suitable software to use. Do you have a specific application or use in mind? In general I would say say, yes it … Read more

call_user_func_array() expects parameter 1 to be a valid callback, array must have exactly two members

The parameters are fairly wrong here: add_options_page( ‘Theme Options’, ‘Theme Options’, ‘administrator’, __FILE__, array(‘KD_Options’), ‘display_options_page’ ); Because you are within a Class, the callback needs to be array( $this, ‘display_options_page’ ) and not just a function name. You use that array format for WP callbacks within classes so that they are correctly referenced. However, add_options_page … Read more