$_SERVER['DOCUMENT_ROOT'];
is not going to include secondsite
. So all the files, including wp-config.php
with the database details, are coming from the root public directory.
To get the current directory, including subdirectories, use any of these:
getcwd();
dirname(__FILE__);
basename(__DIR__);
But if your file is in a deeper folder, you can’t find the secondsite
directory without specifying it (or scanning directories to find a WordPress installation). So you need to manually specify it like so:
$path = $_SERVER['DOCUMENT_ROOT'] . '/secondsite';
But your problem is that you’re doing AJAX wrong. You shouldn’t be sending AJAX requests directly to a file in your plugin. You should be using the AJAX hooks or adding a custom endpoint to the REST API.
Related Posts:
- How to delete all records from or empty a custom database table?
- dbDelta only creates the last table
- Is their any way to Extend WPDB class and Overwrite the Default Query Function
- Stackoverflow type of badge plugin giving warnings in WordPress 3.5
- Missing argument 2 for wpdb::prepare() Issue
- ob_end_flush error when using wpdb in plugin
- $wpdb->get_results() does not fetch results with unicode ‘WHERE’ clause
- post_content getting cut off on blank space on $wpdb->update
- Why am i getting this error? WordPress database error: [Query was empty]
- Inserting large amounts of data into a custom table during plugin install
- plugin ajax to external php file always return null
- When to call add_filter
- Doubt using $wpbd->get_col for a single column
- Access WordPress database outside of WordPress
- Correct way to perform non-cacheable DB query
- Help With MySQL to WPDB Query Conversion
- Creating mySQL procedure with $wpdb
- Problem with creating tables for Plugin
- Change commission_status paid when withdraw_status vendor is completed
- $wpdb->get_row returns column name instead of column value
- Create a table with wordpress plugin boilerplate
- plugin code is pulling information from database in one instance and not in other. What is wrong?
- Object method calling for global $wpdb in header.php
- Using wpdb without loading all plug-ins via wp-load.php
- after wordpress update to 3.5+ i get many errors in plugin wpdb::prepare()
- How to insert multiple postmeta values with one query?
- Cannot get wpdb data (Error in a simple fuction) [closed]
- WPDB: Update table
- Issue running db create table query from static method
- $wpdb update query in plugin only updating one column
- Mowing site to another domain in simplest way
- Store plugin page content in wp_options?
- Displaying data from another database
- Using $wpdb in a plugin, what sort of data does it return?
- How to access the WordPress DB from a plugin file
- WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version [closed]
- Linked pages from plugin on front can’t see $wpdb
- Need help creating asynchronous data scraper in WordPress
- ob_end_flush(): failed to send buffer of zlib output compression (0) in external php
- How to fetch WordPress database values in JavaScript widget
- $wpdb->delete not working for me
- any word search WordPress
- How to securely controlling data without keeping it in postmeta?
- Using id to show item
- No result after wpdb->insert
- How to fix slow comment query?
- Write mysql credentials in plugin
- Action hook “wp_insert_post” works but not for last imported post
- Proper way to trigger a MySQL query via link in a plugin
- get_var result empty for query of custom table in plugin admin
- Making plugin to use different table prefix cause permission problem
- Is it safe to increase/alter the size of the wp_post.guid column from VARCHAR(255) to VARCHAR(2048)?
- Get all the related data from WordPress DB
- How to dispaly post informations (such as titles) in an admin plugin menu page?
- FATAL ERROR: WP complains about redeclaration [closed]
- How to check record is exist or not in WordPress CRUD Operation with $wpdb
- How to Add WYSIWYG Editor (tinyMCE) to plugin options page compatible with WordPress 3.0 and up?
- What is a Network Activated Plugin Exactly?
- WooCommerce – Call to undefined function is_woocommerce()
- How to distinquish wordpress served links from non-wordpress served links
- do_shortcode() doesn’t work if shortcode contained in variable, works if shortcode passed as string
- Issue with post request to admin-post.php
- Built in audio player?
- How to show my sidebar in specific page only?
- Plugin Development sqlite or WordPress’ database
- WordPress web pages keep getting deleted (moved into the trash) by themselves
- WordPress plugin creation how to execute .sql in order to insert multiple rows at activation of plugin
- How to create a custom shortcode based on the layout?
- Installing plugins and using complex folder structure with child theme in WordPress
- Plugins ignored a line breaks or tag in the WordPress comment functions
- How to get path or root of plugin folder, not file or dir?
- Add key and value to an array in another file
- WordPress plugin boilerplate table create
- How can I globally italicize certain text?
- Create “new pages” within the admin section of plugin
- Creating a plugin that will display text on every page
- Share plugins, themes, and multi post in a multidomain network
- How to Call Specific .PHP file on add_submenu_page selection in Plugin Development?
- WordPress cron job running more than once
- How to display emails as a post?
- How i remove specific script from header?
- Woocommerce redirection if no previous orders
- Update wordpress user roles not working as excepted
- Can’t access 3rd party API, code works on local server but not on wordpress
- Front End Page Not Loading Header Footer
- Add image to post
- get_option return incorrect values
- avi mp4 flv video player [closed]
- get recent 12 days post then random in wordpress
- Many Field in Front End User Registration form insert as post
- private functions in plugins
- Custom Post Type – Permalink Problem
- Can’t edit Contact Us form on front page
- Woocommerce – Product Description heading [closed]
- wp doesn’t recognize my plugin if I don’t login as WP user (or as WP Admin)
- Getting warning of Missing argument 2 for wpdb::prepare()
- wordpress plugin noob situation
- turn off WooCommerce for a site in a multi site environment
- wp_handle_upload – specified file failed upload test
- Split Million WordPress Post’s Into Multiple Database Server