Open bobbingwide opened 7 years ago
This still doesn’t work on the home page for https://wp-a2z.org/ I added a Blocks section on the home page. There more than 15 blocks so pagination is required. Pagination works on the home page for core.wp-a2z.org but not wp-a2z.org. On the latter the [blocks] shortcode is satisfied by switching blogs using [bw_blog 1] before and [bw_blog] after. Investigate if this could be the reason.
I've reproduced the problem locally in https://blocks.wp.a2z/network-news/ using the following shortcodes.
[bw_blogs 1]
<h3>[bw_option blogname]</h3>
[bw_blogs 1][bw_pages post_type=post format="L/d/" numberposts=5 posts_per_page=5][/bw_blogs]
The admin-ajax request fails with a CORS error. The request is being sent to https://wp.a2z/wp-admin/admin-ajax.php This is a different URL from the original URL that displayed the page.
Pagination works when the request is sent to the original site. ie It works for blog ID 10.
The solution is to change the logic to obtain the AJAX URL.
function oikai_get_ajaxurl() {
//print_r( $GLOBALS['switched']);
//print_r( $GLOBALS['_wp_switched_stack'] );
if ( $GLOBALS['switched'] ) {
$ajaxurl = get_admin_url( $GLOBALS['_wp_switched_stack'][0], "admin-ajax.php" );
} else {
$ajaxurl = admin_url("admin-ajax.php");
}
return $ajaxurl;
}
Note: I'm currently getting Warnings from git due to the Owner of my repo's clones being marked as Administrators rather than SB\herb.
C:\apache\htdocs\wordpress\wp-content\plugins\oik-ajax>git commit -m "Add oikai_get_ajaxurl() for use when blog switched #5
warning: 'C:/apache/htdocs/wordpress/wp-content/plugins/oik-ajax' is owned by:
'S-1-5-32-544'
but the current user is:
'S-1-5-21-349621901-1848259107-2955493301-1001'
warning: 'C:/apache/htdocs/wordpress/wp-content/plugins/oik-ajax' is owned by:
'S-1-5-32-544'
but the current user is:
'S-1-5-21-349621901-1848259107-2955493301-1001'
[master cfbe252] Add oikai_get_ajaxurl() for use when blog switched #5
1 file changed, 22 insertions(+), 2 deletions(-)
There are several repos affected by this. The workaround works. The multiple warnings are because I set the environment variable set GIT_TEST_DEBUG_UNSAFE_DIRECTORIES=true
Ajax pagination doesn't appear to be working on wp-a2z.org.
Workaround
Deactivate plugin.