WP Media Library Grid View not displaying - wordpress

Found this question: Wordpress: media library grid mode infinite loading
And, more recently:
"Currently I am using Enfold child theme but media grid view is not working. Even if I try to get to the grid from any of other places like selecting the featured image its not working."
From: Wordpress grid media is not working
I am having the exact same problem in WordPress (and also using Enfold). I have renamed my plugins folder to plugins.hold, disabling all plugins. I also set the theme to TwentySixteen. Neither of those things worked. The media library list view works -- only the grid view does not. (But, this is vital, since several elements pull the grid view by default with no chance to switch to the list view. This essentially renders those elements useless, as it is impossible to add an image.)
I realize this is more a WP question than a programming question, but I am hoping someone else has seen this and has a suggestion as to how it can be resolved.

I faced same issue on my wordpress site. After the lot of debugging i fixed my problem step by step.
First add given below code your db-config.php
define('SCRIPT_DEBUG', TRUE);
define('WP_DEBUG', TRUE);
define( 'WP_DEBUG_LOG', true );
Then goto /wp-includes/js/wp-util.js files and find the code $.ajax(
options ) on line number 100(depand your wordpress version) insert given below code into your file
deferred.jqXHR = $.ajax( options ).done( function( response ) {
try {
response = JSON.parse(response);
} catch (Exception) {
response = response;
}
Please check your may be resolved.
if you Removed constant from db-config.php
define('SCRIPT_DEBUG', TRUE);
define('WP_DEBUG', TRUE);
define( 'WP_DEBUG_LOG', true );
Then compress your /wp-includes/js/wp-util.js file code and put your compressed code into /wp-includes/js/wp-util.min.js
*change your own risk if your update your wordpress version changed may be lost.

Solution: Check the admin-ajax.php response, if there are non-json return or invalid json return you should investigate where the extra ajax response come from.
I had similar issue recently, after inspecting admin page the admin-ajax.php response contain non json response. It is because my client adding extra code in function.php that somehow append inline to the admin-ajax.php response

I had this issue recently and after trying all suggestion following worked for me.
Add following function in wp-config.php at top most line. If needed after that
than update permalink once.
ob_start();

For me, this happened after moving my site from an NGINX host to Apache. An old .htaccess file was lurking in the /uploads folder, which blocked access to any file in the uploads folder with a referrer that was not was my site (but, the http version, not the current https version). Because NGINX doesn't read .htaccess, this was now suddenly preventing images from being shown in the media grid.
Strangely, the images were showing in the list view. Also, directly requesting images was fine, presumably because that is done without a referrer.

Check the log error file in the wp-admin directory. If the repeating error is something like this
PHP Warning: ini_set () has been disabled for security reasons in
So, disable the ini_set function in your Cpanel (php selector> options> disable functions)
If the php selector option does not appear in your Cpanel, contact your hosting provider to fix this problem

Adding following code to functions.php of theme folder worked for me
add_action('admin_head', 'my_custom_style');
function my_custom_style()
{
echo '<style>
.media-frame.mode-grid .media-toolbar {
height: 60px !important;
}
</style>';
}

Related

.htaccess remove double https:// http:// in the link

I'm working on one of a client site, some weird reason, a lot of their link show like this: https://http://yourdomain.com/xxxx
It's fine to click the link when I use the console to see the source and will redirect to https://yourdomain.com but when it's front page(without console open), click the button(link), will open https//yourdomain.com, will be missing ":" or "//"
I tried to find where those content come from, but no luck, I can't not use DB to remove that old "HTTP", because everytime they create new resource will still have https://http://
So I wonder can I use a .htaccess file to detect all those "https://http://" links to direct "https://" only.
Thanks for the help!
I don't think it is practical in .htaccess. However, as a temporary solution until you solve the cause of the problem, you should be able to add code to replace bad links at the point WordPress finally "outputs" the page.
I was going to pen a solution but found I only had to modify code for "final output" already here on stackexchange (itself based on this article )
Try adding the following to your theme's functions.php, or for permanence to your own custom site specific plugin.
function my_linkfix_callback($buffer) {
$buffer = str_replace( 'https://http://' , 'https://' ,$buffer);
return $buffer;
}
function my_linkfix_buffer_start() { ob_start("my_linkfix_callback"); }
function my_linkfix_buffer_end() { ob_end_flush(); }
add_action('after_setup_theme', 'my_linkfix_buffer_start');
add_action('shutdown', 'my_linkfix_buffer_end');
Obviously this is just a temporary solution until you solve the cause of the problem

Using external file with WP_USE_THEMES set to false causing 404

I know there's a dedicated WordPress StackExchange, however, I'm getting no traction over there.
I have a file in my WordPress template I want to use for a Twitter authentication callback named oauth.php that I'd like to be accessible through htp://mydomain.com/oauth.php:
<?php
define('WP_USE_THEMES', false);
echo "test";
However the file is throwing up a 404??
This actually a issue I'd like a solution for away from just this instance.
EDIT
Using the full file path works as intended, so:
http://example.com/wp-content/themes/mytheme/oauth.php
Is this bad practise?
You could try something like this in your oauth.php:
<?php
//Instead of setting to false, try comment it out
//define('WP_USE_THEMES', true);
/** Load the WordPress Environment */
require('./wp-blog-header.php');
// Fake a 200 OK status header
status_header(200);
//The rest of your code here
?>
This should allow you to access this file at http://example.com/oauth.php and run the code inside leveraging Wordpress functionality but without your template.
NOTE: This may depend on your wordpress version.
Hope it helps!

My plugin can't include wp-config.php

I've got a very weird problem. I've got a plugin that works practically everywhere and on all the servers/wordpress installs I can test. However, I've got a user that can't use the plugin.
I'm using Thickbox with iframe to load my shortcode picker window in the editor, so I need to include wp-config.php. Here's the code I use to grab wp-config:
while(!is_file('wp-config.php')){
if(is_dir('../')){ chdir('../'); }
else die('Could not find WordPress.');
}
include('wp-config.php');
The thing is, it FINDS wp-config, but it can't include it. The page literally hangs at the include statement. No errors, nothing. I've added "echo" to each step in finding and including the file, but it just stops at the include directive.
The plugin works everywhere else, but not with the pop up iFrame and Thickbox. Any ideas? If I can't include wp-config, then I can't even set WP_DEBUG and see what the problem is.
require_once( ABSPATH . 'wp-config.php' );

Custom Plugin for wordpress with hierarchy of SEF pages

Here's my issue. My company needs a vendor database added to our wordpress website. None of the existing plugins will even come close to what we need, and we already have a mysql database with all of our information, so we need to create a plugin or something to do what we need.
These urls need to be direct-accessible and have SEF urls. So, for example:
mysite.com/vendors/
mysite.com/vendors/pipe-manufacturers/
mysite.com/vendor/bobs-pipes/
And, the custom content needs to appear inside the wordpress template.
There are really 2 options:
1) Find a way to write our application outside of wordpress, but find a way to bootstrap wordpress to show the header, footer, and sidebar.
2) Run the app from inside wordpress.
So I went for option #2. I created a new template file named "vendor.php", and began working. I added this code to my functions.php of my theme:
add_filter( 'template_include', 'xyz_template_check' );
function xyz_template_check() {
global $template;
$rqst = $_SERVER['REQUEST_URI'];
$ra = split("/", $rqst);
if ($ra[1] == "vendors") {
$template_file = get_stylesheet_directory() . '/vendors.php';
return $template_file;
}
return $template;
}
So what the above code does, if it sees the word "vendors" as the first part of the url after the site name, it sends you to vendor.php. This works PERFECTLY....
except...
Wordpress believes that the page is not found. It returns a 404 header, and NOT FOUND into the page title and breadcrumb.
Adding a PAGE called "Vendor Database" with the permalink "/vendors/" fixes the main page. But there will be literally hundreds of vendors and different categories. I cant be creating a custom page for each one. This needs to be dynamic.
So, how do I make wordpress give a 200, and supply an acceptable page title, breadcrumb, etc.
Don't even get me started on the danged wp_title filter. This did NOT work as documented. Although, it just occurred to me that this might be an issue with Wordpress SEO (the wp_title filter issue).
Anyone got an idea on this?
Ok got this. The solution was to use the rewrite api, as mentioned above, to look for the pattern /vendors/, letting it know that it was a valid URL. Coupled with my existing template override, this is what I needed.

Warning: Cannot modify header information when using require or require_once

I'm WordPress newbie.
I'm creating a plugin that redirect to custom login page each unregistered user access a website, let say the custom login page : custom_login.php.
I am able to create a code to redirect it but it seems no wordpress functions work in custom_login.php. So, I think I have to load something through the file. I guess wp-load.php.
Then I add some codes below at the top of the page :
<?php
require( 'd:\xampp\htdocs\wordpress\wp-load.php' );
?>
But then I got this error :
Warning: Cannot modify header information.....
I changed to require_once but still get similar error.
Some solutions of this forum threads advice to delete any whitespace. Frankly, I don't know what does it mean but I tried to delete all whitespace anyway so that the code become :
<?php require('d:\xampp\htdocs\wordpress\wp-load.php');?>
But it does not solve anything. The error is still exist.
Please help me, the expert ones.
Thanks in advance
Try inserting a system path relative to localhost, like this:
require( '/wp-load.php' ); // or just
require( 'wp-load.php' ); //
All depends on the location you are trying to include wp-load.php from.
On the other hand, you don't have to include wp-load.php if you place the file custom_login.php. in the stylesheet directory as a template or as a custom page. The way to do it is:
.1 Rename the file to page-custom-login.php
.2 Move the file to the stylesheet directory (The theme directory)
.3 Go to admin and create a new page with the title "custom login"
That's all. Now WP will treat that file as a single custom page.
They are correct - you have a space before the opening php tag in one of your files. It can be a bit tricky to find, but look hard.
If you can't find it, try looking for ob_clean() php function to help.

Resources