call wp_enqueue_media on wordpress page - wordpress

I am using a custom theme that when I access http://ec2-54-255-182-157.ap-southeast-1.compute.amazonaws.com/shop/ , it gives the error that
upload-media.js?ver=1:3 Uncaught TypeError: Cannot read property 'editor' of undefined
it happends at the code _orig_send_attachment = wp.media.editor.send.attachment;
some google search (like here https://codestag.com/how-to-use-wordpress-3-5-media-uploader-in-theme-options/
) suggests that "Above code snippet works on post edit page only, to make it work elsewhere you need to use wp_enqueue_media(); in your theme. Thanks to daviedR for correcting me on this."
Any idea how to do call wp_enqueue_media() on this page?

it turns out to be caused by mbstring is not enabled. After run yum install php56-mbstring and restart httpd service, it works good now.

Related

I'm trying to send a form on my wordpress website using ajax, but its an error 500

The form is created using Contact Form 7, but the submit action is made with AJAX and a file php which made a database conection, the error return: 500 (Internal Server Error) on php file and: Uncaught TypeError: $(...).AjaxDebug is not a function on AJAX function.
In the debug file generated by WP there is nothing related with this error.
someone can help me to understand this problem?
I disabled the plugins one by one, hoping for the problem is a conflict, but nothing change.
you clean the cache?! use a plugin like Super Cache good luck

"ErrorUtils caught an error" - Chrome console error with any Wordpress Facebook plugin

I'm trying to use a Facebook likebox plugin on a staging site and I have tried some different plugins. Independently from plugin installed I receive the same error in Chrome console:
ErrorUtils caught an error: "Cannot listen to an undefined element. TAAL[2]". Subsequent errors won't be logged; see https://fburl.com/debugjs.
I think the problem is generated directly from Facebook plugin inclusion. Unfortunately the url https://fburl.com/debugjs isn't working.
This issue doesn't apparently create any problem to the site, but I would like to have a site without any error in console.
Tee site is http://millennium.alecss.it/
Let me know if you can help me, thank you very much.
This is the bug, when upgrade jQuery since 1.8.
Look in your code and replace to on('load')
$(window).load(
function(){
//your code
});
To
$(window).on('load',
function(){
//your code
});

GhostHunter Number of posts found: 0 issue

I'm using Ghost blog system and GhostHunter as searching engine. But when I search anything it returns me Number of posts found: 0.
Who knows, how to fix it?
As mentioned here I was getting the Ghost is not defined error message on the console in F12 dev tools.
I simply had to enable the Public API checkbox on the Labs tab under Settings on the Ghost Admin page.
For reference my script is:
$("#search-field").ghostHunter({
rss: "{{#blog.url}}/rss/",
results: "#results"
});

Wordpress: An error occurred in the upload

After updating to WordPress 3.5, I started getting the following error when uploading files using the Add Media button as a non-admin user:
Error: An error occurred in the upload. Please try again later.
The image seems to finish uploading, but right at the end this error message appears.
This doesn't happen for the administrator, only the other roles. I've even tried giving the other role full admin capabilities, but the error still appears.
Is this a bug? Or am I missing something?
After much trial and error, I finally found a solution that worked for me.
First, I found the following role capabilities to be required to upload files for custom user roles:
$capabilites = array(
'read' => true,
'upload_files' => true,
'edit_published_pages' => true,
'edit_others_pages' => true
);
I'm not sure why these are specifically required, but the error kept occurring without them.
Second, I had to update a function I was using to prevent non-admin users from accessing the Dashboard:
function redirect_nonadmin_fromdash(){
if($_SERVER['PHP_SELF'] == '/wp-admin/async-upload.php'){
/* allow users to upload files */
return true;
} else if(get_user_role() != 'administrator'){
/* custom function get_user_role() checks user role,
requires administrator, else redirects */
wp_safe_redirect(home_url());
exit;
}
}
add_action( 'login_form_login', 'redirect_nonadmin_fromdash' );
add_action( 'admin_init', 'redirect_nonadmin_fromdash', 1 );
Previously, I was checking for the media-upload.php, but the new media uploader uses async-upload.php.
So, essentially, this allows non-admin users to use the new media uploader from the front-end without allowing them access to the Dashboard.
It also restricts their access to the Media Library, which was also important to me.
This could be caused by a couple of different factors, what this usually suggests is:
File is to large
Refeer to this thread on how to up the maximum allowed filesize.
Not enough diskspace
Check if your servers harddrive is full.
Insufficient write permissions
Make sure that PHP and your webserver has write permissions to the wp-uploads folder.
I just had this error after updating PHP to 5.3. The problem on me was short_open_tag.
It was off by default. I enabled it and all is OK now.
I resolve my problem with,
sudo apt-get update
sudo apt-get install php5-gd
this message i get in firebug inspect in moment of upload.
GD Library Error: imagecreatetruecolor does not exist - please contact your webhost and ask them to install the GD libraryGD Library Error: imagecreatetruecolor does not exist - please contact your webhost and ask them to install the GD library{"success":true,"data":{"id":17,"title":"yoshi","filename":"yoshi1.jpg"
so i get this in firebug in moment of upload.
Please see this link for more details - it helped me https://sebastian.expert/fix-wordpress-an-error-occurred-in-the-upload-please-try-again-later/
Basically what it says is to use Developer tools in Chrome or Firefox to see the response from async_upload.php file after uploading files (when error message appears). It returns error details in JSON format. Having details it will be easier and a lot faster to resolve the problem.

Bug on Chrome while implementing gconnect module in drupal 7

i'm using this module to connect from Gmail to my site, it's working greate on firefox but on chrome the button (Sign in Using Google) is not appearing..
if i go to console, i found a javascript error on the file:
(http://localhost/mysite/sites/all/modules/gconnect/git-for-drupal.js?o) on the line 6:
Uncaught TypeError: Cannot read property 'config' of undefined
Also i am getting an error in Importer.js on line 2035: uncaught syntaxerror unexpected identifier
Please help in solving this issue, http://drupal.org/node/1807348
It happens in my drupal and i installed a Jquery update module link below, and change my jquery version it works great. I think default drupal jquery version is 1.4.
https://www.drupal.org/project/jquery_update
Also if you need use jquery's Browser function you have to add extra js to your file.
jQuery.browser() removed
The jQuery.browser() method has been deprecated since jQuery 1.3 and is removed in 1.9. If you still need this function, you can get one js file from: https://github.com/gabceb/jquery-browser-plugin and link the js to your file.

Resources