Jesin's Blog

Welcome to the Portal of Technology

  • Facebook
  • GitHub
  • RSS
  • Twitter
  • Home
  • Categories
    • Domains
    • Linux
    • Networking
    • PHP
    • Virtualization
    • Web Design
    • Web Servers
    • Windows
  • WordPress Plugins
    • Custom Error Pages
    • HTTP Digest Authentication
    • Mailgun Email Validator
  • Toolbox
    • DNS Lookup Tool
    • htdigest Generator Tool Online
    • htpasswd Generator Tool Online
    • HTTP Headers Lookup Tool
    • MD5 Encryption Tool
    • Open Port Check Tool
    • SHA-1 Encryption Tool
    • URL Encoding/Decoding Tool
  • About Me
  • Contact Me
  • Sitemap
Home ›
wordpress

WP CLI fix “Warning: Some code is trying to do a URL redirect.” error

July 22, 2018 Web Design Jesin A Leave a Comment

The WordPress command-line interface is incredibly useful when changing the domain URL of a website. When working on a client’s website I encountered the following warning when I ran the wp search-replace command.

Warning: Some code is trying to do a URL redirect. Backtrace:
#0  WP_CLI\Utils\wp_redirect_handler(http://example.com/) called at [/srv/users/serverpilot/apps/APPNAME/public/wp-includes/class-wp-hook.php:288]
#1  WP_Hook->apply_filters(http://example.com/, Array ([0] => http://example.com/,[1] => 301)) called at [/srv/users/serverpilot/apps/APPNAME/public/wp-includes/plugin.php:203]
#2  apply_filters(wp_redirect, http://example.com/, 301) called at [/srv/users/serverpilot/apps/APPNAME/public/wp-includes/pluggable.php:1199]
#3  wp_redirect(http://example.com/, 301) called at [/srv/users/serverpilot/apps/APPNAME/public/wp-content/plugins/quick-pagepost-redirect-plugin/page_post_redirect_plugin.php:2151]
#4  quick_page_post_reds->redirect() called at [/srv/users/serverpilot/apps/APPNAME/public/wp-includes/class-wp-hook.php:286]
#5  WP_Hook->apply_filters(, Array ([0] => )) called at [/srv/users/serverpilot/apps/APPNAME/public/wp-includes/class-wp-hook.php:310]
#6  WP_Hook->do_action(Array ([0] => )) called at [/srv/users/serverpilot/apps/APPNAME/public/wp-includes/plugin.php:453]
#7  do_action(init) called at [/srv/users/serverpilot/apps/APPNAME/public/wp-settings.php:450]
#8  require(/srv/users/serverpilot/apps/APPNAME/public/wp-settings.php) called at [phar:///opt/sp/bin/wp-cli.phar/php/WP_CLI/Runner.php:1174]
#9  WP_CLI\Runner->load_wordpress() called at [phar:///opt/sp/bin/wp-cli.phar/php/WP_CLI/Runner.php:1100]
#10 WP_CLI\Runner->start() called at [phar:///opt/sp/bin/wp-cli.phar/php/WP_CLI/Bootstrap/LaunchRunner.php:23]
#11 WP_CLI\Bootstrap\LaunchRunner->process(WP_CLI\Bootstrap\BootstrapState Object ([WP_CLI\Bootstrap\BootstrapStatestate] => Array ())) called at [phar:///opt/sp/bin/wp-cli.phar/php/bootstrap.php:75]
#12 WP_CLI\bootstrap() called at [phar:///opt/sp/bin/wp-cli.phar/php/wp-cli.php:23]
#13 include(phar:///opt/sp/bin/wp-cli.phar/php/wp-cli.php) called at [phar:///opt/sp/bin/wp-cli.phar/php/boot-phar.php:8]
#14 include(phar:///opt/sp/bin/wp-cli.phar/php/boot-phar.php) called at [/opt/sp/bin/wp-cli.phar:4]

Googling this warning message brought up several links to GitHub which all recommended using the --user=someadmin parameter. I tried that too but got the same warning. Looking at the backtrace log it is clear that the quick-pagepost-redirect-plugin is causing this redirect, so I used the --skip-plugins= parameter to skip loading this plugin.

wp search-replace --skip-plugins=quick-pagepost-redirect-plugin 'http://example.com' 'https://example.com' --skip-columns=guid

And I had no issues running the search and replace operation.

On a sidenote if you are looking for a shared web host with WP CLI support choose SiteGround (affiliate link). They also have other WordPress specific features like automated migration and caching.

Tags: wordpress, wp-cli

How to prevent WordPress comment Spam using JavaScript

March 7, 2015 PHP Jesin A Leave a Comment

Akismet does a great job in catching comment spam but it is still inserted into the database causing it to bloat over time. So I developed a small WordPress plugin that stops 99% of the comment spam (atleast for me). It uses JavaScript to dynamically add a “hidden” input field to the comments form. A visitor making a comment will also “POST” this value which will be verified before the comment is inserted into the database. No more pesky captchas or asking users to solve dumb calculations.Continue Reading…

Tags: javascript, wordpress

Please fix your WP.org Plugin screenshots

January 1, 2015 Web Design Jesin A 2 Comments

This is a mistake committed even by people I consider the Gods of WordPress (as you’ll see in the screenshot below) and plugins with a million downloads. Even the plugin’s created by the plugin reviewers weren’t spared. Rather than a mistake I would say they all overlooked this minor setting that can ruin a plugin hunter’s experience.

The WordPress.org plugin repository has (or rather had) an annoying feature, when you click on a plugin screenshot on the hopes of viewing it larger the browser pops up the download box like this:
Continue Reading…

Tags: svn, wordpress

How to customize the BuddyPress activation email

April 24, 2014 PHP Jesin A 30 Comments

BuddyPress the social networking plugin for WordPress sends an activation email when a new user registers. This email is very plain so why not add some spice to it by having your custom email. There are many forum threads out there for this topic but 99% of them don’t mention if their method is for single site or multi site. So I spent a lot of time trying customize this activation mailer without any success. Finally I sank into the code of BuddyPress and found the right set of hooks for the each environment – single or multi site.Continue Reading…

Tags: php, wordpress

WordPress Hooks (Actions and Filters) Search Tool

December 20, 2013 PHP Jesin A 5 Comments

wordpress hooks search tool thumbnail

This started out as a PHP regex experiment. I wanted to find the WordPress “action” hooks in a particular theme so that I can add my own action function to it.

So instead of searching through the whole lot of files for do_actions I sat down writing a regular expression to do this. I was very satisfied with the results which made me think about creating a tool to do this.

So here you go a standalone PHP script which seeps through the PHP code of the WordPress core, plugins, themes or anything you specify and gets you a list of actions and filters.

I use the word “standalone” because this isn’t a WordPress plugin or anything which requires WordPress functions. This is a script which uses a regex in preg_match_all() to find all “tag” names in the do_action() and apply_filters() function. This does not even require WordPress, if you want to find the hooks in a plugin just download the plugin, unzip it to a directory readable by this tool.

Download WordPress Hooks Search Tool | GitHubContinue Reading…

Tags: ajax, php scripts, wordpress

Custom 403 and 401 error pages in WordPress

September 18, 2013 PHP Jesin A 5 Comments

wordpress custom 403 error page

Earlier I had written an article on custom error pages for Apache but doing the same with WordPress is not that straightforward. WordPress has the ability to handle 404s internally but doing the same for other 4xx errors requires modifying the code.

I’ve been searching how to do this for months without luck. Recently after I created my own theme for this blog I got some knowledge of WordPress internals.

I put that to use and after several hours of experimenting built the 403 and 401 custom error pages for my WordPress blog.Continue Reading…

Tags: custom error pages, php, wordpress

  • 1
  • 2
  • Next Page »

Get a wealth of information delivered to your inbox. Subscribe and never miss a single article.

  • Tutorials and howtos
  • Code, scripts and commands
  • Online Tools

* No spam, unsubscribe anytime

Hire Me

  • SSL installation and hardening (A+ on Qualys SSL test)
  • Apache & Nginx configuration
  • Email deliverability improvement (10/10 on Mail Tester & MailGenius)
  • WordPress customization, optimization and migration
  • and much more…

    Tools

    • DNS Lookup Tool
    • htdigest Generator Tool Online
    • htpasswd Generator Tool Online
    • HTTP Headers Lookup Tool
    • MD5 Encryption Tool
    • Open Port Check Tool
    • SHA-1 Encryption Tool
    • URL Encoding/Decoding Tool

    Nav

    • Home
    • About Me
    • Contact Me
    • Privacy Policy
    • Sitemap
    Vultr SSD VPS

    Creative Commons License
    Jesin's Blog by Jesin A is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
    Based on a work at websistent.com.