Search
 
SCRIPT & CODE EXAMPLE
 

PHP

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/
Comment

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' );
}
Comment

how to get plugin directory path 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');
Comment

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
Comment

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.
Comment

how to get plugin directory path in wordpress

$dir = plugin_dir_path( __FILE__ );
// Example: /home/user/var/www/wordpress/wp-content/plugins/my-plugin/
Comment

how to get plugin directory path in wordpress

foreach ( glob( plugin_dir_path( __FILE__ ) . "subfolder/*.php" ) as $file ) {
    include_once $file;
}
Comment

how to get plugin directory path in wordpress

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

plugin directory wordpress get

// Get the public url path to your wordpress plugin were you are working on
echo plugin_dir_url( __DIR__ );
// returns: https://yourdomain.com/wp-content/plugins/my-plugin/icon.png
Comment

wordpress get plugin root directory

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

PREVIOUS NEXT
Code Example
Php :: php check for null 
Php :: laravel make auth 
Php :: php How do you remove an array element in a foreach loop? 
Php :: define in php 
Php :: how to remove duplicate values from an array in php 
Php :: range in php 
Php :: timezone php 
Php :: php replace first occurrence in string 
Php :: PHP Forms - Required Fields 
Php :: how to get product id by sku in woocommerce 
Php :: Remove public from the url in the codeigniter 
Php :: check if elquent retrun empty array laravel 
Php :: php function comment 
Php :: create storage link laravel without terminal server 
Php :: php get src content from image tag 
Php :: contact form 7 remove p 
Php :: php date function get previous month 
Php :: textarea laravel migration 
Php :: add access-control-allow-origin header laravel 
Php :: full month name php 
Php :: boot add schema in laravel 
Php :: get page thumbnail id wordpress 
Php :: filename php 
Php :: woocommerce cart length button shortcode 
Php :: laravel validate datetime with datetime-local 
Php :: download data from s3 and save to local disk laravel 
Php :: how to get correct file or content mime type using/in php 
Php :: preg_replace 
Php :: remove string after comma in php 
Php :: get next month first day php 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =