Who does your site talk to? (Remote Requests)

Does your site talk to anyone?

This is a question I recently had when I was dealing with a really slow dashboard. I knew WordPress tried to load news from WordPress.org and even planet.WordPress.org. I knew there could be other situations where it loads data from somewhere else after all it shows new themes and plugins.

I was trying to figure how I could find all the URLs so I could get them white-listed for this particular site. Then I realised that I could not find it in the code itself because many of the URLs would likely be dynamic. I was trying to figure out what my next step would be. Then I had a thought, I would just build a plugin and hook into pre_http_request to find all the URLs it attempted to communicate with.

This was a really simple plugin and after running it for a few days the findings were very interested, especially with a few common plugins installed.

You can download Remote Requests here.

Thickbox in WordPress

I was recently working on a plugin and needed to load a url in the admin using thickbox. As I was building the the page that Thickbox would show up on I included add_thickbox(); and then the page content. On that page I have a link that will trigger my thickbox with the remote url. This was really easy the link ended up looking something like this

$link = "http://www.website.com?TB_iframe=true&width=1200&height=800";
<a href="<?php echo $link; ?>" class="thickbox">Details</a>

So you can see you have to include the class of thickbox on the anchor tag and then add the required paramaters to the url. Notice that you must set a width and height, this was somewhat problematic for me because I need it to be as large as possible and you never know what resolution the user may be using.

I needed to find a work around to solve my problem. This is what I came up with.


<script type=”text/javascript”>
jQuery( ‘.thickbox’ ).each( function( index, value ) {
var w = window.innerWidth * .85;
var h = window.innerHeight * .85;
var href = jQuery( this ).attr(‘href’);
var find = ‘width=1200&height=800’;
var replace = ‘width=’+w+’&height=’+h;
href = href.replace( find, replace )
jQuery( this ).attr( ‘href’, href );
} );


During my search I came across trac ticket #17249. It seems to have a need for a non-fixed size.

Hide Old Shortcodes – WordPress Plugin

Hide Old Shortcodes WordPress PluginRecently I was asked to build a new WordPress theme for a project. As I was looking through some of the old content I kept noticing different shortcodes that must have existed in the previous theme or plugins. I wanted to clean these up by removing them but this site had 1000s of posts and it would be time consuming to find all of the post with shortcodes and then remove them.

I looked for an existing plugin and found a few, but you needed to enter the shortcodes into a field for them to be ignored. In this case I did not know what the shortcode was without finding it first.

I knew there had to be a better way to go about this. So I started by looking into the core code in WP for shortcodes to see if there was a filter to use to catch shortcodes that no longer existed. However when I first found the regex for shorcodes I noticed it only looked for shortcodes that were registered in WP. Kinda a dead end on that. I then decided it must be possible to use the same regex(it is a complicated one) with a few changes and find anything that looked like a shortcode. This continued to a plugin that logged all of the non-existing shortcodes.

As I monitored the log I started to notice a few false positives, that is things that were being hidden and should not have been. I knew at this point my plugin would need to account for this and be able to handle it. I then added some actions you can take on the found shortcode. You can Allow the shortcode to show, remove it from the post or edit the post in case it was a typo or something. I found this plugin pretty helpful for myself during this project so I put it up on github.

Let me know if you questions or comments about the plugin. I will be submitting it to the wp.org repo soon. I want to test it a bit more before I put it up there.

You can download Hide Old Shortcodes here.