how to get plugin directory path 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/
how to get plugin directory path 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/
how to get plugin directory path in wordpress
if ( is_admin() ) {
include_once( plugin_dir_path( __FILE__ ) . 'includes/admin-functions.php' );
} else {
include_once( plugin_dir_path( __FILE__ ) . 'includes/front-end-functions.php' );
}
how to get plugin directory path in wordpress
define( 'MY_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
include( MY_PLUGIN_PATH . 'includes/admin-page.php');
include( MY_PLUGIN_PATH . 'includes/classes.php');
// etc.
how to get plugin directory path in wordpress
foreach ( glob( plugin_dir_path( __FILE__ ) . "subfolder/*.php" ) as $file ) {
include_once $file;
}
how to get plugin directory path in wordpress
$dir = plugin_dir_path( __FILE__ );
// Example: /home/user/var/www/wordpress/wp-content/plugins/my-plugin/
how to get plugin directory path in wordpress
/**
* 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' );
Answer
http://example.com/wp-content/plugins/my-plugin/assets/foo-styles.css
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us