plugin_dir_url()

 

File: wp-includes/plugin.php

function plugin_dir_url( $file ) {
	return trailingslashit( plugins_url( '', $file ) );
}

参数:plugin_dir_url( string $file )

The filename of the plugin (__FILE__).

(字符串)包含插件的目录的URL路径。

$file

(string)
(Required)
The filename of the plugin (__FILE__).

{acontent3}

  1. Basic Example

    /**
     * Include CSS file for MyPlugin.
     */
    function myplugin_scripts() {
        wp_register_style( 'foo-styles',  plugin_dir_url( __FILE__ ) . 'assets/foo-styles.css' );
        wp_enqueue_style( 'foo-styles' );
    }
    add_action( 'wp_enqueue_scripts', 'myplugin_scripts' );
    

    Would echo:

    http://example.com/wp-content/plugins/my-plugin/assets/foo-styles.css
    

You must log in before being able to contribute a note or feedback.

20.00% (2) 次Baidu访问
10.00% (1) 次Google访问
70.00% (7) 次Sogou访问
  • 蜘蛛:Baidu,2次,更新时间:2019-04-28 17:14:23
  • 蜘蛛:Google,1次,更新时间:2019-05-12 13:11:16
  • 蜘蛛:Sogou,7次,更新时间:2019-05-18 14:08:53

参与评论