“WordPress Get Plugin Root Directory” Code-Antworten

So erhalten Sie Plugin -Verzeichnispfad in WordPress

//current path: /home/user/var/www/wordpress/wp-content/plugins/my-plugin/
$dir = plugin_dir_path( __DIR__ );
//$dir is set to /home/user/var/www/wordpress/wp-content/plugins/
Dev

So erhalten Sie Plugin -Verzeichnispfad in WordPress

function enqueue_scripts() {
    wp_enqueue_script( 'custom-js', plugin_dir_url( __FILE__ ) . 'js/custom.js', array( 'jquery' ), '', true );
    wp_enqueue_style( 'style-css', plugin_dir_url( __FILE__ ) . 'css/style.css' );
}
add_action( 'wp_enqueue_scripts', 'enqueue_scripts');
 
function admin_enqueue_scripts() {
    wp_enqueue_script( 'custom-js', plugin_dir_url( __FILE__ ) . 'js/custom.js', array( 'jquery' ), '', true );
    wp_enqueue_style( 'style-css', plugin_dir_url( __FILE__ ) . 'css/style.css' );
}
add_action( 'admin_enqueue_scripts', 'admin_enqueue_scripts');
Dev

So erhalten Sie Plugin -Verzeichnispfad in WordPress

function plugin_dir_path( $file ) {
    return trailingslashit( dirname( $file ) );
}
Dev

WordPress Get Plugin Root Directory

// Use a file of a plugin
include WP_PLUGIN_DIR . '/plugin-name/plugin-file.php';
gtamborero

Ähnliche Antworten wie “WordPress Get Plugin Root Directory”

Fragen ähnlich wie “WordPress Get Plugin Root Directory”

Weitere verwandte Antworten zu “WordPress Get Plugin Root Directory” auf PHP

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen