我试图在插件中加载我的样式表,但它们没有被调用,但是javascript文件正在加载。
<?php
/**
Plugin Name:
Plugin URI:
Description:
Version:
Author:
Author URI:
**/
define("MPF_PATH", ABSPATH . \'wp-content/plugins/\' . basename(dirname(__FILE__)).\'/\' );
define("MPF_URL", trailingslashit(get_option(\'siteurl\')) . \'wp-content/plugins/\' . basename(dirname(__FILE__)) . \'/\' );
class mpf_plugin{
function crf_user_registration(){
add_action(\'plugins_loaded\', array(&$this, "load_my_scripts"));
add_action(\'admin_menu\', array(&$this,\'add_crf_menu_items\'));
if(!is_admin()){
add_shortcode(\'crf_registration\', array(&$this, "do_shortcode"));
} else {
//do something else here
}
}
function load_my_scripts(){
if(is_admin()){
wp_register_script(\'crf_script\', MPF_URL . \'includes/js/crf_script.js\');
wp_register_style(\'crf_style\', MPF_URL . \'includes/css/crf_style.css\');
wp_enqueue_style(\'crf-style\');
wp_enqueue_script(\'jquery\');
wp_enqueue_script(\'crf_script\');
wp_localize_script( \'crf_script\', \'MyAjax\', array( \'MPF_PATH\' => MPF_PATH, \'MPF_URL\' => MPF_URL,\'ajaxurl\' => MPF_URL . \'includes/save-layout.php\', \'loadPageLayoutURL\' => MPF_URL . \'includes/get-layout.php\', \'optionsPageURL\' => MPF_URL . \'includes/options.php\' ));
}
}
function do_shortcode(){
include(\'crf_form.php\');
}
function options_page() {
// HTML code goes here, left out for brevity
}
function custom_dropdown_page(){
// HTML code goes here, left out for brevity
}
function add_crf_menu_items() {
add_menu_page(
\'My Plugin Form\',
\'MPF\',
\'manage_options\',
\'mpf-options\',
array(&$this,\'options_page\')
);
add_submenu_page(
\'mpf-options\',
\'MPF Options\',
\'MPF Options\',
\'manage_options\',
\'custom-mpf-options\',
array(&$this,\'custom_dropdown_page\')
);
}
}
new mpf_plugin();
路径都是正确的。有什么想法吗?