make script inclusion work more safely

This commit is contained in:
John Bintz 2010-02-06 10:07:36 -05:00
parent aa1f0d86bd
commit 6804b32916

View File

@ -9,6 +9,7 @@ class ComicPressAdmin {
function init() {
$this->comicpress = &ComicPress::get_instance();
if (is_admin()) {
add_action('admin_menu', array(&$this, 'admin_menu'));
add_filter('attachment_fields_to_edit', array(&$this, 'setup_comic_metadata_buttons'), 10, 2);
@ -29,7 +30,6 @@ class ComicPressAdmin {
'archive' => __('Archive', 'comicpress')
);
if (is_admin()) {
add_action('admin_notices', array(&$this, 'display_messages'));
} else {
add_action('wp_head', array(&$this, 'display_messages'));
@ -83,12 +83,7 @@ class ComicPressAdmin {
add_theme_page(__("ComicPress", 'comicpress'), __('ComicPress', 'comicpress'), 'edit_themes', 'comicpress/render_admin', array(&$this, 'render_admin'));
add_theme_page(__("ComicPress Documentation", 'comicpress'), __('ComicPress Docs', 'comicpress'), 'edit_themes', 'comicpress/comicpress_docs', array(&$this, 'render_documentation'));
if (strpos($pagenow, "post") === 0) {
add_meta_box("comic-image-ordering", __("Comic Image Ordering", 'comicpress'), array(&$this, 'render_comic_image_ordering'), "post", "normal", "low");
wp_enqueue_script('cp-ordering', plugin_dir_url(dirname(__FILE__)) . '/js/ComicImageOrdering.js', array('scriptaculous', 'scriptaculous-slider'));
wp_enqueue_style('cp-admin', plugin_dir_url(dirname(__FILE__)) . '/css/cp-admin.css');
add_action('admin_footer', array(&$this, 'admin_footer'));
}
add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts'));
if ($plugin_page == 'comicpress/render_admin') {
wp_enqueue_style('cp-admin', plugin_dir_url(dirname(__FILE__)) . '/css/cp-admin.css');
@ -102,10 +97,20 @@ class ComicPressAdmin {
wp_enqueue_style('prettify', plugin_dir_url(dirname(__FILE__)) . '/js/prettify/prettify.css');
wp_enqueue_script('scriptaculous-effects');
}
}
if (strpos($pagenow, "-upload") !== false) {
function admin_enqueue_scripts($hook_suffix) {
switch ($hook_suffix) {
case 'post.php':
add_meta_box("comic-image-ordering", __("Comic Image Ordering", 'comicpress'), array(&$this, 'render_comic_image_ordering'), "post", "normal", "low");
wp_enqueue_script('cp-ordering', plugin_dir_url(dirname(__FILE__)) . '/js/ComicImageOrdering.js', array('scriptaculous', 'scriptaculous-slider'));
wp_enqueue_style('cp-admin', plugin_dir_url(dirname(__FILE__)) . '/css/cp-admin.css');
add_action('admin_footer', array(&$this, 'admin_footer'));
break;
case 'media-upload-popup':
wp_enqueue_style('cp-admin', plugin_dir_url(dirname(__FILE__)) . '/css/cp-admin.css');
wp_enqueue_script('cp-media', plugin_dir_url(dirname(__FILE__)) . '/js/MediaUpload.js', array('prototype'));
break;
}
}