Implementing a URL Shortener

Step 1: Create a new template file in your themes folder named: shorturl.php <?php /* Template Name: Short URLS Template Post Type: post, page */ while ( have_posts() ) : the_post(); $content=get_the_content(); header(‘Location: ‘.str_replace(“&amp;”,”&”,$content)); exit(); endwhile; Step 2: Create a new php file in your wp-content/plugins/ folder and name it: public-url-shortener.php <?php /* Plugin Name: … Read more

Strange behavior: random HTTP error 500 fixed by visiting Permalinks settings page (htaccess issue with language code)

Looks like it might be your WPML. See here: https://wpml.org/forums/topic/wpml-add-rewritebase-en-in-htaccess/ For posterity, the summary of this page is as follows: Problem: Some wrong settings caused an issue with “Use directory for default language”. A 500 error was showing. Solution: The client reports here that pressing the ‘Reset Settings’ button in WPML -> Languages probably solved … Read more

why is $_REQUESt[‘redirect_to’] empty?

The redirect_to variable works fine, even as a GET variable, however wp-login.php also uses wp_safe_redirect() for doing the actual redirection, which means that the URL must be on the same website. You can’t redirect to anywhere in the web, just to the same site as the login is located on. This is to prevent some … Read more

How to make my site use HTTPS for images or how to insert images as relative paths?

Main Issue As long as you are accessing the WordPress dashboard via HTTPS, new media items should be inserted into content using HTTPS in the associated media item URL. There is a bit more detail around that feature in this WordPress ticket: wp_get_attachment_url returns https when it should not. That ticket describes how wp_get_attachment_url returns … Read more

Several times request to load plugins when sending one request

That might well be, but that’s alright. There might be redirects happening, and those will result in multiple requests. The WordPress-Cron System relies on AJAX-requests, those will also show up in the log. If you load any resources (images, scripts, stylesheets) that do not exist, WordPress will be loaded and handle the 404, resulting in … Read more

How to get value of custom http header?

I checked amazon.com website for retrive X-Amz-Cf-Id header which I belive is not a standard header and for me it is working fine: function wpse_288865_featch_header() { $response = wp_remote_get(‘https://www.amazon.com/’); $custom_header = wp_remote_retrieve_header($response, ‘X-Amz-Cf-Id’); var_dump($custom_header); exit; } add_action(‘init’, ‘wpse_288865_featch_header’); Sometimes amazon.com is not returning this header so please refresh your WordPress site couple of times. I … Read more