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
Related
I found a similar topic but it didn´t solve my problem. I installed a WordPress Multisite. I changed all the values manually that are described in endless forums and tutorials.
My Website > Network > Website > Edit > Info
--> Here the site url stays with http (See pic)
My Website > Network > Website > Edit > Settings
--> Here the site url and home have been changed to https (See pic)
Why?
I checked my changes endless times. The changes should be all correct and done where they should. Still the main site url stays at http what I don´t understand. I have done the changes regarding to this tutorial and others:
https://wpengine.com/support/how-to-change-a-multi-site-primary-domain/
Also I put in the values
define( 'WP_HOME', 'http://somedomain.com' );
define( 'WP_SITEURL', 'http://somedomain.com' );
just to be sure! It didn´t do anything so I deleted this last part again.
Can u please help me. This is so frustrating.
Picture of the problem
Someone from the German wordpress.org site helped me out with a link form Stack Exchange. So in case someone had the same issue, here is a possible solution that helped me out. That´s his words regarding to this link: https://wordpress.stackexchange.com/a/355888/129212
"Workaround:
1.) Make a backup of the database. No backup, no pity.
2.) In wp-config.php, comment out the code block for multisite with the prefix // in front of each line (do not delete).
Analogous:
// define ('WP_ALLOW_MULTISITE', true);
// define ('MULTISITE', true);
// define ('SUBDOMAIN_INSTALL', true);
// $ base = '/';
// define ('DOMAIN_CURRENT_SITE', 'example.com');
// define ('PATH_CURRENT_SITE', '/');
// define ('SITE_ID_CURRENT_SITE', 1);
// define ('BLOG_ID_CURRENT_SITE', 1);
3.) Login again and change the URL to https://example.com (with your domain) under Settings > General
4.) In the wp-config.php delete in the code block the comment characters // for multisite.
Analogous:
define ('WP_ALLOW_MULTISITE', true);
define ('MULTISITE', true);
define ('SUBDOMAIN_INSTALL', true);
$ base = '/';
define ('DOMAIN_CURRENT_SITE', 'example.com');
define ('PATH_CURRENT_SITE', '/');
define ('SITE_ID_CURRENT_SITE', 1);
define ('BLOG_ID_CURRENT_SITE', 1);
5.) Carry on as if nothing had happened."
He said that it seems that WordPress didn´t consider that the main page / parent page would change in any way. So it is the easiest way to return with the previous steps to a "normal site", change the urls and then "activate" Multisite again.
Hope it helps! See ya!
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>';
}
Probably should be something simple, but I looked at many sites a solution to my problem.
I'm trying to remove the url ?author=N of a page of my site.
I want to change www.mydomain.com/?author=13 to www.mydomain.com/profile/username So far I removed author url, however the id is still there.
My current code is:
}
public static function get_profile_url($user_id = 0) {
if ($user_id > 0) {
$profile_url.="profile/" . $user_id;
}
Not sure, but I think my target is $user_id I've used other alternatives such as $user_nicename but it still fails, any tips? thank you in advance for attention.
You need to activate friendly url in Options -> Permalinks. Do you have activated?
If yes, your url will be domain.com/author/user_name
So here's the problem: We don't like the fact that WordPress doesn't allow duplicate slugs, even for sub categories meaning we cannot have urls like:
product-1/guides
product-1/articles
product-2/guides
product-2/articles
That's very annoying! One solution we are considering is setting up our slugs like this:
product-1/product-1-guides
product-1/product-1-articles
product-2/product-2-guides
product-2/product-2-articles
But in our htaccess - can we use it to pick up such urls and rewrite them as prettier urls which have the product name removed from the sub folder? We don't mind hard coding these as we'll only ever have 5-10 products on the site.
This would keep the WordPress install happy with unique slugs, but the SEO tick in the box with better looking urls.
I just need a hand with the syntax please?
EDIT 1:
After looking at the WordPress Rewrite API, I'm failing to get anywhere with what I think is a really simple test. I have the following code in my functions.php which is running as I tested an echo, but no rewriting is taking place?
add_action( 'init', 'productRewrites' );
function productRewrites() {
add_rewrite_rule('^wordpress/james?','index.php?author_name=jwilson','top');
}
Nothing happens when I hit:
mysite.com/wordpress/james
Edit 2:
Cool I realise I now have to click save each time. The problem I now have is the following does not work not when I use $matches[1] - it only works if I hard code the author_name value (to jwilson for example):
function productRewrites() {
add_rewrite_rule(
"writer/([^/]+)/?",
"index.php?author_name=$matches[1]",
"top");
}
When I use $matches[1] it just returns everything! So clearly isn't using ([^/]+) in the url?!
you have to reset permalink structure
in order to do that, move to Settings -> Permalinks and press Save changes button
I am trying to pass an email address to a wordpress page like so:
http://www.website.com/?email=fakeemail#yeahwho.com
However, Wordpress turns it into this:
http://www.website.com/?email=fakeemailyeahwho.com
I even try URL encoding it like so:
http://www.website.com/?email=fakeemail%40yeahwho.com
But Wordpress is too smart and still removes the %40.
I understand that # is a reserved character, but I should be able to still use the URL encoded version. Alas, Wordpress does not want it to be so.
How can I force Wordpress to respect the # sign? I'm guessing I'll either have to hack the internals, or do some mod_rewrite magic.
from http://www.webopius.com/content/137/using-custom-url-parameters-in-wordpress
First, add this to your theme's functions.php file (or make a custom plugin to do it):
add_filter('query_vars', 'parameter_queryvars' );
function parameter_queryvars( $qvars )
{
$qvars[] = 'email';
return $qvars;
}
Next, try passing ?email=fakeemail-AT-yeahwho.com in the URL and then converting it back with something like this:
global $wp_query;
if (isset($wp_query->query_vars['email']))
{
$getemail = str_replace( '-AT-', '#', $wp_query->query_vars['email']);
}
// now use $getemail
This would only not work in the very rare occurrence of an email that actually has "-at-" in it. You could replace for an even more obscure string like '-AT6574892654738-' if you are concerned about this.
Whatever your final solution, don't hack the core to get it to work. :)
I was having a similar problem and I was able to isolate the issue to an SEO plugin. I'm sure the plugin added a filter to the functions.php but as the plugin wasn't being used uninstalling the plugin also resolved the issue.
I also had this problem, but it wasn't caused by a plugin. It was a result of the 301 redirect that WordPress does with regard to your Site URL having, or not having, a www. in it.
If my Site URL was defined as http://www.mydomain.com, then this would work as expected: http://www.mydomain.com/?email=user#domain.com
If the user came to the site as: http://mydomain.com/?email=user#domain.com (NOTE: no www), then WordPress would redirect to this: http://www.mydomain.com/?email=userdomain.com (NOTE: the stripped # symbol)
My solution was to hard code the www redirect in the htaccess file, so WordPress would never have the opportunity to mess with my URL. This page gives example htaccess lines to redirect non www to www and vice versa: http://dense13.com/blog/2008/02/27/redirecting-non-www-to-www-with-htaccess/
I was having a similar problem today when trying to pass Mailchimp data through to a Gravity Form in Wordpress. I found a solution. The original question stated that Wordpress was also stripping %40, but it didn't for me in this instance.
1) In Mailchimp create a new Merge tag. I called mine 'Email Param' and * |EMAIL2| *
2) Export your list of subscribers
3) Copy the normal 'email' column content into the new 'Email Param' column.
4) Do a Find and Replace for all # symbols to %40
5) Import your list and tick the box that Auto-updates that list
6) Update your URL to include the new parameter
* |EMAIL2| *
That worked for me.