Social media is often used to help publicise blog posts. Here’s a little WordPress plugin which adds links to the bottom of a post to share it by Email, StumbleUpon, Digg, Facebook and twitter.
jw-share-this.zip
This plugin uses the techniques I’ve outlined in these articles:
If you find the icons included (which are 48×48 pixels) are too large then here are some 32×32 pixels smaller designs.
Filed under: Wordpress
39 comments »
It’s quite difficult to get the entire page content in a WordPress plugin. I eventually got this code to work. It requires two action handlers, one for the “send_headers” action just after the HTTP headers are sent and the HTML is just about to begin. The other handler is in the “shutdown” action, when the page is sent. By setting the priority to high on our action handler we can get in, grab the page and change it before it is returned. This gives the whole page from <HTML> to </HTML>.
function jw_callback($buffer) {
// Change contents of buffer here
// Just treat it like a string
return $buffer;
}
function jw_buffer_start() {
ob_start(“jw_callback”);
}
function jw_buffer_end() {
ob_end_flush();
}
add_action(‘send_headers’, ‘jw_buffer_start’);
add_action(‘shutdown’, ‘jw_buffer_end’, 1);
Filed under: Wordpress
No comments »
I knocked up a quick plugin to display all the categories and display all the posts in each of them. Currently it displays posts multiple times in each of the categories it belongs to. I had to jump through hoops a bit to get the categories ordered alphabetically.
See it in action here.
Available from the WordPress.org plugins repository.
Update: version 1.2 just out adds the ability to set the ordering of the posts.
The idea originated with my friend Linda at herselfswebtools.com.
Filed under: Wordpress
60 comments »
I’ve found the WordPress stats plugins a bit annoying at times. So, I wrote my own web server log analyser. It runs on the command line. Most web stats plugins seem to rely on javascript in the pages delivered. Since users might have javascript turned off this might not count their page requests. However, if you have access to the web server logs then you have an amazing source of information.
(more…)
Filed under: PHP, Wordpress
No comments »
Available for download is my WordPress HTML output filter (the HOF), a plugin for WordPress 2.9 (it might work with previous versions, it might require tweaking). WordPress installations on large-scale shared hosts have come under assault recently, as noted in the WordPress Development blog, not through any flaw in WordPress but flaws in the web hosts’ servers. Those of us who use such services can never be sure of how secure the server is.
(more…)
Filed under: Security, Wordpress
No comments »
2 files are needed for WordPress to recognise a theme:
- a CCS stylesheet “style.css” (containing information to appear in the theme selection page in a CSS comment block)
- a PHP file to deal with displaying posts “index.php”
With these 2 files in place the theme will appear on the theme page (under Appearance on the left bar of the admin pages, select Theme) and can be activated.
(more…)
Filed under: Wordpress
No comments »
I’ve been discussing security issues with timestocome and had a go at writing a little hack alarm script. It is designed to pick up when someone has put comments or posts containing malicious code directly into your database (bypassing WordPress security) or uploaded executable files to your web server file system. This is not a very complete test but it might be useful when combined with other security checks. It does nothing to actually protect your system. My main aim is to prevent users being affected by malicious code and google blacklisting the site.
It gives you the following features:
- a filter which checks post (including page) and comment content. If it finds anything (there’s an array of strings it checks for – it’s pretty agressive, by default it flags up “javascript” with a colon on the end [I can't type it here cos I'm running the script!]) then it displays a message above the page/post and completely HTML encodes the content (so a malicious “<iframe>” would become “<iframe>” thus disarming it)
- a dashboard widget which scans all files from ../.. (which on a standard install is ‘public_html’ since the script runs in ‘wp-admin’) and alerts you to any files with execute permission (which is a bad sign).
- the dashboard widget lists any posts/comments which trigger the above checks
Here’s the zip file.
Filed under: Wordpress
No comments »
This is an introduction to writing plugins for WordPress. For this tutorial you will require: a test WordPress installation (don’t try stuff like this on your live server!) with access to the ‘wordpress/wp-content/plugins’ directory and some knowledge of PHP or programming in general.
WordPress plugins are created using a language called PHP. There are plenty of tutorials out there about PHP. I’m not going to cover that in this tutorial.
Create a directory called ‘a-simple-plugin’ in the ‘plugins’ directory of your WordPress install (the usual directory structure is ‘wordpress/wp-content/plugins’). In this directory create a file called ‘a-simple-plugin.php’ and paste in this code:
(more…)
Filed under: Wordpress
No comments »
This tips applies to coding a WordPress theme design. You won’t be able to copy and paste the code straight into your posts. You will need full access to editing themes on your server (yes, I can host WordPress sites if you contact me).
Should produce valid HTML and work nicely, mostly the work of Jamie Huskisson and Herself’s Webtools. I added a quick change to produce completely valid HTML (I’m very fussy about that sort of thing).
<a href=”http://twitter.com/home?status=I+like+<?php echo urlencode(get_permalink(get_the_ID())); ?>&title=<?php echo urlencode(get_the_title(get_the_ID())); ?>”> Share this on Twitter </a>
UPDATE: Twitter has changed it’s url format. This is the new format:
http://twitter.com/intent/tweet?text=I+like+http%3A%2F%2Fwww.jameswilkesdesign.co.uk%2Fwordpress-plugin-to-share-posts%2F&title=WordPress+plugin+to+share+posts+via+facebook%2C+twitter+etc
Filed under: Wordpress
No comments »