I have a plugin that will allow administrators to perform certain actions when adding or editing a post. I use a stylesheet and a javascript for this plugin that I want to include only when a post is being added or edited. Am I right to use the following action hooks?
add_action('load-post.php', 'call_my_function');
add_action('load-post-new.php', 'call_my_function');
Inside of the function call_my_function I have:
function call_my_function() {
$plugin_directory = "/wp-content/plugins/".dirname(plugin_basename(__FILE__));
$jssrc = $plugin_directory.'/js/my_plugin.js';
wp_enqueue_script("my_plugin_js", $jssrc);
$csssrc = $plugin_directory.'/css/my_plugin.css';
wp_enqueue_style("my_plugin_css", $csssrc);
}
The code above successfully loads the CSS and Javascript files when not called from the add_action hook. It does not work successfully when called from these hooks.