Use the plugin_dir_path()
and plugin_dir_url()
helper functions:
if( ! defined( 'MY_PLUGIN_PATH' ) )
define( 'MY_PLUGIN_PATH', plugin_dir_path( __file__ ) . 'admin/' );
if( ! defined( 'MY_PLUGIN_DIR' ) )
define( 'MY_PLUGIN_DIR', plugin_dir_url( __file__ ) . 'admin/' );
You should be using more unique constant names – ADMIN_PATH
is far too generic.
Related Posts:
- check if Gutenberg is currently in use
- WordPress Plugin Development – Headers Already Sent Message
- Get page content using slug
- How to include wp-load.php from any location?
- Correct way to enqueue jquery-ui
- How to echo the_excerpt without the P tag wrapper?
- How can I update a wordpress plugin from a Git repository (github)
- Is There a Plugin Life Cycle Documentation?
- What is an alternative method to the WordPress private _doing_it_wrong() function
- How to disable plugin update notification for a specific plugin in Multisite
- Shortcode adding p and br tags
- Building a better media uploader for WordPress
- Problems with localization
- Install and load additional plugins when running unit tests
- Having Problem On Getting WP Post Gallery Images URL
- Calling clean_term_cache() fails when called in the same plugin that creates terms, succeeds when called separately?
- Singular name Plugin localization
- How do I hook a custom discount to change a WC_Order price total on WooCommerce?
- How to get current page id through the plugin
- Properly licensing a plugin that uses Apache 2.0 licensed code
- How to restrict plugin’s sub-menu pages to admin/subscribers?
- Can I dynamically create a link to my plugin settings/options page from my plugin description?
- How to load the plugin only when logged in?
- Saving data from block editor to the database
- Cannot search post by taxonomy
- Hook into theme-switching later than `setup_theme`
- OOP Plugin and Menu – Call to undefined function register_setting()
- Will current_theme_supports return TRUE with a nonstandard add_theme_support?
- WP AJAX is not working, always returns 0
- Act on user meta updated, but only once
- get_pages Drop down list for selection of a page
- Admin auto-refresh is interfering with Firebug — how to prevent it?
- Display content from custom post without modifying the single template
- How do I add custom column to woocommerce cart?
- WordPress mode for emacs?
- Widget translation on my plugin
- Upload to a remote server using wp_remote_post
- Loading WordPress Admin Environment
- how to add custom functionality after woocommerce place order button
- Problems with: manage_${post_type}_posts_columns
- Make WordPress cache permanent for some pages until edited
- Getting timestamp of activation plugin time
- conditionally load javascript & CSS for do_action() calls from plugin
- Rich text editor settings persist throughout all rich text editors
- Function: Add link to / inside div
- How can I rewrite a URL to pass requests to a custom method via AJAX? (I can’t use admin-ajax.php)
- WP Gutenberg Blocks – How to limit first/root blocks
- How do I update a field of a meta box?
- The plugin does not save data
- How do I create plugin or theme using MVC pattern?
- How to Get Current Custom Post Type Associated Taxonomy Term
- tinymce.get() returns error after ajax request
- Access bloginfo, get_option, and plugins_url from a non-core php file
- How to get a list of child ids for a named category?
- Plugin could not be activated because it triggered a fatal error, unexpected ‘[‘
- How to make the first commit on WordPress.org
- Are there any official or unofficial guidelines for the styling of a widget?
- How to get error object returned by wp_create_user
- How best to handle database version dependence (from $wp_db_version)
- Associate multiple email addresses with the same user account, so they can log in with either
- My WordPress Plugin code breaks customize.php viewpoint
- Custom filter not working
- Make wordpress join default user metas with a column from another table while displaying the wp_users table on the users screen
- ajax working when function is on child theme but not in plugin page
- I need to refresh page to display wp_get_current_user() : why?
- What is the way to hook all wordpress email
- Best way to distribute templates and code accross multiple wordpress sites?
- Adding Dynamic Stylesheet
- Foreign wp_users ID in custom plugin DB table?
- Metabox is not displaying
- How to show comments from different Plugins to same post type?
- Proper way to do a page view count on a page?
- Catching a GET parameter from the URL and save it in the user meta when a user registers
- The plugin generated 683 characters of unexpected output during activation
- WP_Query not ordering correctly
- Dont display post with no content
- Custom User Role Preview Function Not Working
- get_the_date() returns english Year & Day when language is Arabic
- Where to save Gutenberg plugin data?
- Error when activating a custom plugin on production server
- Add new header/footer on landing page with plugin
- Publish, Save Draft and Preview buttons do not work after being moved with jQuery
- I can’t write in my DB using $wpdb->insert
- Multi hook deploiement
- woocommerce single product page hook not working
- Endpoint Callback Display for Custom Plugin
- Get Commentor IP When Marking Comment As Spam
- How do I build a settings panel under the plugin
- Multiple Users Logged In Causing Incorrect Account Returned
- Displaying $_FILES data (simlar to $_POST)
- Plugin options page – save two related options as one entry
- I want to display the content of a text field only if it has been entered
- How to remove city field from order in dashboard?
- How do i code exit popup plugin?
- How can I dynamically change title and description in WordPress?
- Need someone to help you want to manage points for members to code interface functions? thank you
- Call API on post save/update and show the result in admin area
- Is there any other ways to replicating changes on live from staging without pushing from git
- Run different permission_callback depending on HTTP method of custom REST API endpoint
- upload image to wordpress media library failed for custom post type