The best way is to not do that. There’s no need for a plugin file to ever include the wp-config.php.
You’re doing it backwards. WordPress loads plugins. Plugins don’t load WordPress.
Related Posts:
- What security concerns should I have when setting FS_METHOD to “direct” in wp-config?
- What could a hacker do with my wp-config.php
- WP Config for FTP credentials
- Bad Request (Invalid Hostname) on working server, database problem
- Some plugins adding full server path after url (with custom wp-content folder)
- register_theme_directory somehow “fails” when folder is outside of WP-Folder
- htaccess and wordpress config files are regularly over written
- plugings request url is the old url
- Can you limit the memory usage of a particular plugin?
- Single Must Use Plugins Directory for local development
- Enable Full SSL for WordPress
- How to change constants in WordPress wp-config.php programmatically?
- Enabling WP_USE_EXT_MYSQL to support old plugin
- DOMAIN_CURRENT_SITE constant being regularly overridden [closed]
- Redirect to another page using contact form 7? [closed]
- Use wp-config.php constants in all files of plugin
- Can WordPress Drop-ins be given their own directory?
- Editing wp-config.php
- Disable globally “Crop thumbnail to exact dimensions (normally thumbnails are proportional)” with Multisite
- What is the purpose of WP_CONTENT_URL?
- WordPress failing to update plugins
- How to request admin-ajax.php correctly when wordpress URL and site URL are different?
- How to get database connection details without longing to cpanel in WordPress?
- WordPress wp get_temp_dir return non exiting folder, thus failing plugin & themes update
- Using wp config to connect to a DB from a plugin
- No plugin updates after moving wp-config.php above root map
- how to create child WordPress plugin
- Deactivate plugins only for mobile devices
- Drag-and-drop “Panels”-style visual layout editor?
- Failed to invoke other hook from the init hook
- Is there an equivalent to Drupal’s Batch API in WordPress?
- Is it possible to remove this action? (as it’s added just before it’s called)
- How to redirect Old Post URL to new Post and keep Old post Comments?
- Plugin shortcode won’t work on a custom template file [closed]
- XML sitemap over product variations
- How to disable lightbox popup for “add a review” only?
- Is there any way to get all the name or slug of template parts used in a page?
- how an array index could be a file path
- How do i login when i cant access wp-login.php?
- First WordPress Plugin – Stat Issues
- Adding an Options Page to a Plugin
- Updating the Drag-To-Share eXtended share URLs?
- install robots.txt to wordpress website admin
- Send Contact form 7 data to remote server using .NET api [closed]
- Sending HTML emails via wp_mail not working properly
- add_action in static class [closed]
- register_settings callback function posing problem
- Privileges problem with add_submenu_page [closed]
- Modify wp_installed_email / wp_new_blog_notification
- Adding inside wp-plugin jQuery script that receives JSON-formatted data, generated by php-function inside this plugin
- iframe not showing in post (with “allow php in posts” plugin activated)
- how can I do something on new user registration?
- How to remove bulk actions from custom post type
- License validate function
- Plugin for an interactive image? [closed]
- wp_enqueue_style on template_redirect level?
- CSS reset for plugin’s front end?
- getting notifications about updates only in the “core” page
- Generate Email Newsletter HTML from Posts published within a Date Range?
- Displaying syntax highlighted code [closed]
- Categories from front-end, checkbox selection doesn’t work
- Share buttons Facebook Twitter, just like wordpress.com without webservice
- Strange Behavior on New Theme Points to Idiocy
- Dynamic URL Rewrite for Custom
- How can I adjust my function so the page editor still loads in the backend?
- Why won’t wp_enqueue_script work within any plugin file?
- how long do restored versions take to go live?
- headless wordpress
- Issue calling my functions on Plugin activate in WordPress
- WPGlobus Multilingual – REST API
- Defining constant in a plugin to use in another plugin
- How Can I display Specific User Pages?
- Any way to self-host plugins and update them like wp-hosted plugins does?
- Custom SportsPress list
- Why is the WordPress update_option not working in this code?
- Display Powerpress media url
- Plugin Post 2 Posts: How to list most connected posts?
- How to prevent intermediate images from being created but keep the sizes available for selection in the media library?
- How to set the default options on an existing plugin in a WP MU new user install
- multiple external urls in wordpress website
- Display static pages instead of category, in code
- How to add a filter conditionally based on page related Conditional Tags
- Additional scrollbar appears inside the browser on every page + lag scroll -Winner theme
- Call to a member function get_page_permastruct() on null
- Quiz plugin where we can import question from Excel file?
- Automatically put a menu on every post
- php include returns 1 as output with other outputs [closed]
- Custom GD Star Ratings Stars [closed]
- How do I transfer my plugin data?
- How to give different user access to different people?
- hide particular category post from front page only [closed]
- which plugin is this? [closed]
- Adding a script & php to functions.php
- Real estate schema markup not showing up on Rich Results test
- qTranslate‑X is not translating all shortcodes
- How do I call an action hook into wp_ajax hook callback function
- Problem with a shortcode generating a error [closed]
- Can’t update plugins in WordPress, system returns -1
- Adjusting Website Display at 100% Zoom
- Custom Elementor controls not appearing in the widget Advanced tab using injection hooks