English 中文(简体)
• 如何在我的言语中把心乐施会和 j列入吗?
原标题:How To Include CSS and jQuery in my WordPress plugin?

• 如何在我的言语中把心乐施会和 j列入吗?

最佳回答

风格wp_register_ Format(名称space. http://siteofcs.com/mycss.cs );

然后使用:wp_enqueue_ Format ( namespace );, 不论你想要装上 c。

文本如上所示,但装满舱的更快途径是使用装在你想要装上以下一页的墨水:wp_enqueue_script(jquery );

不管怎样,你都希望利用山洞库进行 j。

您也可以有条件地把贵方的书本取决于:

wp_enqueue_script ( namespaceformyscript, http://placeofscript.com/myscript.js , range(jquery ));

www.un.org/Depts/DGACM/index_french.htm

此前我曾作过这一回答。 我应澄清,在<代码>wp_enqueue_scripts上封顶的最好位置。 例如:

add_action( wp_enqueue_scripts ,  callback_for_setting_up_scripts );
function callback_for_setting_up_scripts() {
    wp_register_style(  namespace ,  http://locationofcss.com/mycss.css  );
    wp_enqueue_style(  namespace  );
    wp_enqueue_script(  namespaceformyscript ,  http://locationofscript.com/myscript.js , array(  jquery  ) );
}

<代码>wp_enqueue_scripts action will set what for the “frontend”. 您可使用<代码>admin_enqueue_scripts(任何地点在wp-admin)和login_enqueue_scripts,对标识页采取行动。

问题回答

在<代码>init()中为您的原始功能。

function your_namespace() {
    wp_register_style( your_namespace , plugins_url( style.css ,__FILE__ ));
    wp_enqueue_style( your_namespace );
    wp_register_script(  your_namespace , plugins_url( your_script.js ,__FILE__ ));
    wp_enqueue_script( your_namespace );
}

add_action(  admin_init , your_namespace );

在我找到了(对我来说)最优的解决办法之前,我还是花了一段时间了。

卡车

方便地将社会保障和住房纳入到贵处,努力做到:

// register jquery and style on initialization
add_action( init ,  register_script );
function register_script() {
    wp_register_script(  custom_jquery , plugins_url( /js/custom-jquery.js , __FILE__), array( jquery ),  2.5.1  );

    wp_register_style(  new_style , plugins_url( /css/new-style.css , __FILE__), false,  1.0.0 ,  all );
}

// use the registered jquery and style above
add_action( wp_enqueue_scripts ,  enqueue_style );

function enqueue_style(){
   wp_enqueue_script( custom_jquery );

   wp_enqueue_style(  new_style  );
}

我发现这一伟大的幻觉来自网站。 • 如何将酒类和心脏病列入语言压力——语言压力

希望会有所帮助。

接受的答复不完整。 您应使用右 h:wp_enqueue_scripts

例:

    function add_my_css_and_my_js_files(){
        wp_enqueue_script( your-script-name , $this->urlpath  .  /your-script-filename.js , array( jquery ),  1.2.3 , true);
        wp_enqueue_style(  your-stylesheet-name , plugins_url( /css/new-style.css , __FILE__), false,  1.0.0 ,  all );
    }
    add_action( wp_enqueue_scripts , "add_my_css_and_my_js_files");

只读到@pixeline的答案(补充简单评论,但网站说,我需要50名声誉)。

如果你写上你在行政科的金字句,你应使用:

add_action( admin_enqueue_scripts , "add_my_css_and_my_js_files");

The admin_enqueueu_scripts is the right hook for the admin section, use wp_enqueue_scripts for the front end.

简单:

在<>Front End上添加联合材料/共同支助事务:

function enqueue_related_pages_scripts_and_styles(){
        wp_enqueue_style( related-styles , plugins_url( /css/bootstrap.min.css , __FILE__));
        wp_enqueue_script( releated-script , plugins_url(  /js/custom.js  , __FILE__ ), array( jquery , jquery-ui-droppable , jquery-ui-draggable ,  jquery-ui-sortable ));
    }
add_action( wp_enqueue_scripts , enqueue_related_pages_scripts_and_styles );

在工作方案中添加联合材料/共同支助事务:

function enqueue_related_pages_scripts_and_styles(){
        wp_enqueue_style( related-pages-admin-styles ,  get_stylesheet_directory_uri() .  /admin-related-pages-styles.css );
        wp_enqueue_script( releated-pages-admin-script , plugins_url(  /js/custom.js  , __FILE__ ), array( jquery , jquery-ui-droppable , jquery-ui-draggable ,  jquery-ui-sortable ));
    }
add_action( admin_enqueue_scripts , enqueue_related_pages_scripts_and_styles );

你们可以利用以下职能,从gin子中排出文字或风格。

function my_enqueued_assets() {
    wp_enqueue_script( my-js-file , plugin_dir_url(__FILE__) .  /js/script.js ,   , time());
    wp_enqueue_style( my-css-file , plugin_dir_url(__FILE__) .  /css/style.css ,   , time());
}
add_action( wp_enqueue_scripts ,  my_enqueued_assets );

You can add scripts and css in back end and front end with this following code: This is simple class and the functions are called in object oriented way.

class AtiBlogTest {
function register(){
    //for backend
    add_action(  admin_enqueue_scripts , array($this, backendEnqueue ));
    //for frontend
    add_action(  wp_enqueue_scripts , array($this, frontendEnqueue ));
}
function backendEnqueue(){
    wp_enqueue_style(  AtiBlogTestStyle , plugins_url(  /assets/css/admin_mystyle.css , __FILE__ ));
    wp_enqueue_script(  AtiBlogTestScript , plugins_url(  /assets/js/admin_myscript.js , __FILE__ ));
}
function frontendEnqueue(){
    wp_enqueue_style(  AtiBlogTestStyle , plugins_url(  /assets/css/front_mystyle.css , __FILE__ ));
    wp_enqueue_script(  AtiBlogTestScript , plugins_url(  /assets/js/front_myscript.js , __FILE__ ));
}
}

if(class_exists( AtiBlogTest )){
$atiblogtest=new AtiBlogTest();
$atiblogtest->register();
}

c)

wp_register_style( style-css ,plugin_dir_url(__FILE__). css/style.css );

b 包括:

 wp_register_script( script-js , plugin_dir_url(__FILE__). js/script.js ,array(),  1.0.0 , true);

您可以在任何一页左右使用 c。

wp_enqueue_style( style-css );

您可以在任何一页左右使用 j。

wp_enqueue_script( script-js );

你们是否指的是 j和 c或 code? 如果你用的文字或打字很少,那么你就能够直线使用。 但是,它建议使用word plugin功能,如果你想要包括档案。

wp_register_script() wp_enqueue_style()

希望会有所助益。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签