Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Video + Media pop ups not working WordPress

  • SOLVED

http://www.earthsalon.ca/media/#videos

When you click on an item in Videos or Media, the pop-up doesn't work. But it used to.
Same with the Gallery page.

Everything worked fine, I made the website live - and it stopped working.
This problem also appears on mobile devices.

Any help would be great - thank you! I don't even know what code to post because nothing was touched when making the site live:

http://earthsalon.ca/ES2014/ -- where the site is sitting
http://earthsalon.ca -- where the site is viewed.

Answers (2)

2014-06-14

Dbranes answers:

You got this error:

POST http://www.earthsalon.ca/wp-admin/admin-ajax.php 404 (Not Found)

What's the correct path?


Emilia Farrace comments:

that is the file and where it's located.
Below is the contents of that direct file.
Should it be somewhere else?


<?php
/**
* WordPress AJAX Process Execution.
*
* @package WordPress
* @subpackage Administration
*
* @link http://codex.wordpress.org/AJAX_in_Plugins
*/

/**
* Executing AJAX process.
*
* @since 2.1.0
*/
define( 'DOING_AJAX', true );
define( 'WP_ADMIN', true );

/** Load WordPress Bootstrap */
require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );

/** Allow for cross-domain requests (from the frontend). */
send_origin_headers();

// Require an action parameter
if ( empty( $_REQUEST['action'] ) )
die( '0' );

/** Load WordPress Administration APIs */
require_once( ABSPATH . 'wp-admin/includes/admin.php' );

/** Load Ajax Handlers for WordPress Core */
require_once( ABSPATH . 'wp-admin/includes/ajax-actions.php' );

@header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
@header( 'X-Robots-Tag: noindex' );

send_nosniff_header();
nocache_headers();

/** This action is documented in wp-admin/admin.php */
do_action( 'admin_init' );

$core_actions_get = array(
'fetch-list', 'ajax-tag-search', 'wp-compression-test', 'imgedit-preview', 'oembed-cache',
'autocomplete-user', 'dashboard-widgets', 'logged-in',
);

$core_actions_post = array(
'oembed-cache', 'image-editor', 'delete-comment', 'delete-tag', 'delete-link',
'delete-meta', 'delete-post', 'trash-post', 'untrash-post', 'delete-page', 'dim-comment',
'add-link-category', 'add-tag', 'get-tagcloud', 'get-comments', 'replyto-comment',
'edit-comment', 'add-menu-item', 'add-meta', 'add-user', 'closed-postboxes',
'hidden-columns', 'update-welcome-panel', 'menu-get-metabox', 'wp-link-ajax',
'menu-locations-save', 'menu-quick-search', 'meta-box-order', 'get-permalink',
'sample-permalink', 'inline-save', 'inline-save-tax', 'find_posts', 'widgets-order',
'save-widget', 'set-post-thumbnail', 'date_format', 'time_format', 'wp-fullscreen-save-post',
'wp-remove-post-lock', 'dismiss-wp-pointer', 'upload-attachment', 'get-attachment',
'query-attachments', 'save-attachment', 'save-attachment-compat', 'send-link-to-editor',
'send-attachment-to-editor', 'save-attachment-order', 'heartbeat', 'get-revision-diffs',
'save-user-color-scheme', 'update-widget', 'query-themes',
);

// Register core Ajax calls.
if ( ! empty( $_GET['action'] ) && in_array( $_GET['action'], $core_actions_get ) )
add_action( 'wp_ajax_' . $_GET['action'], 'wp_ajax_' . str_replace( '-', '_', $_GET['action'] ), 1 );

if ( ! empty( $_POST['action'] ) && in_array( $_POST['action'], $core_actions_post ) )
add_action( 'wp_ajax_' . $_POST['action'], 'wp_ajax_' . str_replace( '-', '_', $_POST['action'] ), 1 );

add_action( 'wp_ajax_nopriv_heartbeat', 'wp_ajax_nopriv_heartbeat', 1 );

if ( is_user_logged_in() ) {
/**
* Fires authenticated AJAX actions for logged-in users.
*
* The dynamic portion of the hook name, $_REQUEST['action'],
* refers to the name of the AJAX action callback being fired.
*
* @since 2.1.0
*/
do_action( 'wp_ajax_' . $_REQUEST['action'] );
} else {
/**
* Fires non-authenticated AJAX actions for logged-out users.
*
* The dynamic portion of the hook name, $_REQUEST['action'],
* refers to the name of the AJAX action callback being fired.
*
* @since 2.8.0
*/
do_action( 'wp_ajax_nopriv_' . $_REQUEST['action'] );
}
// Default status
die( '0' );



Emilia Farrace comments:

that is the file and where it's located.
Below is the contents of that direct file.
Should it be somewhere else?


<?php
/**
* WordPress AJAX Process Execution.
*
* @package WordPress
* @subpackage Administration
*
* @link http://codex.wordpress.org/AJAX_in_Plugins
*/

/**
* Executing AJAX process.
*
* @since 2.1.0
*/
define( 'DOING_AJAX', true );
define( 'WP_ADMIN', true );

/** Load WordPress Bootstrap */
require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );

/** Allow for cross-domain requests (from the frontend). */
send_origin_headers();

// Require an action parameter
if ( empty( $_REQUEST['action'] ) )
die( '0' );

/** Load WordPress Administration APIs */
require_once( ABSPATH . 'wp-admin/includes/admin.php' );

/** Load Ajax Handlers for WordPress Core */
require_once( ABSPATH . 'wp-admin/includes/ajax-actions.php' );

@header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
@header( 'X-Robots-Tag: noindex' );

send_nosniff_header();
nocache_headers();

/** This action is documented in wp-admin/admin.php */
do_action( 'admin_init' );

$core_actions_get = array(
'fetch-list', 'ajax-tag-search', 'wp-compression-test', 'imgedit-preview', 'oembed-cache',
'autocomplete-user', 'dashboard-widgets', 'logged-in',
);

$core_actions_post = array(
'oembed-cache', 'image-editor', 'delete-comment', 'delete-tag', 'delete-link',
'delete-meta', 'delete-post', 'trash-post', 'untrash-post', 'delete-page', 'dim-comment',
'add-link-category', 'add-tag', 'get-tagcloud', 'get-comments', 'replyto-comment',
'edit-comment', 'add-menu-item', 'add-meta', 'add-user', 'closed-postboxes',
'hidden-columns', 'update-welcome-panel', 'menu-get-metabox', 'wp-link-ajax',
'menu-locations-save', 'menu-quick-search', 'meta-box-order', 'get-permalink',
'sample-permalink', 'inline-save', 'inline-save-tax', 'find_posts', 'widgets-order',
'save-widget', 'set-post-thumbnail', 'date_format', 'time_format', 'wp-fullscreen-save-post',
'wp-remove-post-lock', 'dismiss-wp-pointer', 'upload-attachment', 'get-attachment',
'query-attachments', 'save-attachment', 'save-attachment-compat', 'send-link-to-editor',
'send-attachment-to-editor', 'save-attachment-order', 'heartbeat', 'get-revision-diffs',
'save-user-color-scheme', 'update-widget', 'query-themes',
);

// Register core Ajax calls.
if ( ! empty( $_GET['action'] ) && in_array( $_GET['action'], $core_actions_get ) )
add_action( 'wp_ajax_' . $_GET['action'], 'wp_ajax_' . str_replace( '-', '_', $_GET['action'] ), 1 );

if ( ! empty( $_POST['action'] ) && in_array( $_POST['action'], $core_actions_post ) )
add_action( 'wp_ajax_' . $_POST['action'], 'wp_ajax_' . str_replace( '-', '_', $_POST['action'] ), 1 );

add_action( 'wp_ajax_nopriv_heartbeat', 'wp_ajax_nopriv_heartbeat', 1 );

if ( is_user_logged_in() ) {
/**
* Fires authenticated AJAX actions for logged-in users.
*
* The dynamic portion of the hook name, $_REQUEST['action'],
* refers to the name of the AJAX action callback being fired.
*
* @since 2.1.0
*/
do_action( 'wp_ajax_' . $_REQUEST['action'] );
} else {
/**
* Fires non-authenticated AJAX actions for logged-out users.
*
* The dynamic portion of the hook name, $_REQUEST['action'],
* refers to the name of the AJAX action callback being fired.
*
* @since 2.8.0
*/
do_action( 'wp_ajax_nopriv_' . $_REQUEST['action'] );
}
// Default status
die( '0' );



Emilia Farrace comments:

Sorry!! Upon closer inspection -- THIS IS THE CORRECT PATH

http://earthsalon.ca/ES2014/wp-admin/admin-ajax.php 404 (Not Found)


Dbranes comments:

shouldn't it be:

http://www.earthsalon.ca/ES2014/wp-admin/admin-ajax.php


Emilia Farrace comments:

How to I fix where it's pulling the address from?


Dbranes comments:

aha, you just posted the same path before me ;-)


Dbranes comments:

You got this setup on your page:

<script type='text/javascript'>
/* <![CDATA[ */
var SiteVars = {"siteUrl":"http:\/\/www.earthsalon.ca","templateUrl":"http:\/\/www.earthsalon.ca\/ES2014\/wp-content\/themes\/earth","ajaxUrl":"http:\/\/www.earthsalon.ca\/wp-admin\/admin-ajax.php"};
/* ]]> */
</script>



Dbranes comments:

Can you locate the:

wp_localize_script


for your custom theme?


Emilia Farrace comments:

I'm trying - is that for sure what it will be called?
in where:

wp-admin
wp-content
wp-includes


Dbranes comments:

Check in your current theme directory (most likely functions.php), it could also be in a plugin.


Dbranes comments:

your current theme directory is:

/wp-content/themes/earth/


Emilia Farrace comments:

found this:


function wp_localize_script( $handle, $object_name, $l10n ) {
global $wp_scripts;
if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
if ( ! did_action( 'init' ) )
_doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
'<code>wp_enqueue_scripts
', 'admin_enqueue_scripts', 'login_enqueue_scripts' ), '3.3' );

return false;
}

return $wp_scripts->localize( $handle, $object_name, $l10n );
}


</code>


Dbranes comments:

yes, but this is the core function.

so you need to find where it's called in your theme (or a plugin), not where it's defined in the WordPress core.


Dbranes comments:

So if you check out

http://www.earthsalon.ca/ES2014/wp-content/themes/earth/js/functions.js?ver=1.0


then you can see where the wrong <em>ajaxUrl </em>it's used:


/*** Modal Photo Media ***/

$(function() {
$('.photo-gallery .media-row figure a').click(function(e) {
e.preventDefault();
var galleryid = $(this).closest('.media-row').data('gallery-id');
var imageIndex = $(this).closest('li').index();
if (!$('#gallery-' + galleryid).length) {
$.ajax({
url: SiteVars.ajaxUrl,
type: "POST",
data: {action: "load_gallery", id: galleryid},

... cut ...


Emilia Farrace comments:

this is where i found it in functions, under my theme:



function localize_scripts() {
$params = array(
"siteUrl" => get_bloginfo('url'),
"templateUrl" => get_bloginfo('template_directory'),
"ajaxUrl" => get_bloginfo('url’).’/wp-admin/admin-ajax.php'
);
wp_localize_script('functions', 'SiteVars', $params);
}


Dbranes comments:

Yes, there is the problem.

Please try:

"ajaxUrl" => admin_url( 'admin-ajax.php' )

instead of:

"ajaxUrl" => get_bloginfo('url’).’/wp-admin/admin-ajax.php'


Emilia Farrace comments:

It worked, it worked, thank you so much!


Dbranes comments:

ok, great.

ps: instead of <em>get_bloginfo('template_directory')</em> you should use <em>get_template_directory_uri()</em> or <em>get_stylesheet_directory_uri()</em> if you're using a child theme.


Emilia Farrace comments:

I'm not using a child theme, it was customized from scratch. is leaving what you suggested okay knowing that?
There will be no changes to this theme.

2014-06-14

Remy answers:

It's because your view url and sitting url are different, the working url for admin-ajax.php is http://www.earthsalon.ca//ES2014/wp-admin/admin-ajax.php

I guess your site url and home url are different in the admin, are you using a premium theme, or a custom made one ? how is the call to wp-admin/admin-ajax.php is made ? with home_url() ?


Emilia Farrace comments:

Hi Remy,

This is a custom made theme, made by developers we've never had problems with when making the site live ...

When making the site live - there was a site error that was produced by the company we host on: Netfirms.ca - they subsequently fixed it ...

I don't know how to find out the answer to the question you posed ... where in the code would I look for that?


Emilia Farrace comments:

Hi Remy,

This is a custom made theme, made by developers we've never had problems with when making the site live ...

When making the site live - there was a site error that was produced by the company we host on: Netfirms.ca - they subsequently fixed it ...

I don't know how to find out the answer to the question you posed ... where in the code would I look for that?


Remy comments:

I think it can be in functions.php, or in footer.php, you should look for admin-ajax in those 2 files