Twitter Image Host 2 Twitter Image Host 2
  • Home
  • Posts
  • Home
  • Posts

WordPress

Twitter Image Host 2

Please email for details about Twitter Image Host 2

Read More

Personalising AddThis’s Tweet Button

AddThis is a quite useful WordPress plugin for adding a host of sharing options to your blog posts.

By default, the “Tweet” button that AddThis provides will append “via @AddThis” to the end of tweets, which seems to me a little uncool, given that it’s your content.

So, here’s a little plugin that lets you specify your own Twitter account name instead of @AddThis.

The principle is simple: AddThis were kind enough to define their own filter for the plugin’s output. The plugin plugs itself into this filter, and makes an adjustment to the Tweet button.

To use it, put addthis-modifier.php into your wp-content/plugins folder, open it up and set your twitter name where indicated. Activate it, and you should be good to go.

Download the plugin: AddThis Modifier Plugin

For extra marks: Here’s some code you can use to replace line 14 (the $twittername = … line) to provide a different Twitter account for each post author. Is that not awesome?:

    $accounts = array('Michael'   => 'MichaelTyson',
                      'Katherine' => 'NellieWindmill');
    $twittername = $accounts[get_the_author()];

$accounts = array('Michael' => 'MichaelTyson', 'Katherine' => 'NellieWindmill'); $twittername = $accounts[get_the_author()];

Read More

Supporting WordPress shortcodes and captions in MarsEdit preview

I noticed that WordPress these days uses a shortcode to define image captions, of the form:

[caption id="" align="aligncenter" width="630" caption="Image title goes here"]<img src="http://domain.com/imgpath/../image.jpg" width="630" height="420" />[/caption]

I’ve recently redone our blog template at Technomadics, and while setting up the new preview template in MarsEdit, thought I’d take a stab at implementing support for captions, too, via some javascript in the template.

I was successful! Here’s how I did it:

Added the following to the “head” section:

 
var prior_content;
function watch_for_changes() {
  var check = function() {
    var elt = document.getElementById('content');
    if ( elt.innerHTML != prior_content ) {
       elt.innerHTML = apply_filters(elt.innerHTML);
       prior_content = elt.innerHTML;
    }
    setTimeout(check, 100);
  };
  setTimeout(check, 100);
}
 
function apply_shortcode(source, name, callback) {
   return source.replace(new RegExp('\[' + name + '\s*([^\]]*)\]((.|[sn])*?)\[/' + name + '\]', 'g'),
                         function(match, paramString, content) {
                           params = new Object();
                           reg = /([a-z]+)="((:?="[^"]+"|[^"])*)"/gi;
                           while ( (match = reg.exec(paramString)) != null ) {
                             params[match[1]] = match[2];
                           }
                           return callback(params, content);
                         });
}
 
function apply_filters(html) {
  html = apply_shortcode(html, "caption", function(args, content) {
     return '<div>' + content +
             '<p class="wp-caption-text">' + args.caption + '</p></div>';
  });
 
  return html;
}

var prior_content; function watch_for_changes() { var check = function() { var elt = document.getElementById('content'); if ( elt.innerHTML != prior_content ) { elt.innerHTML = apply_filters(elt.innerHTML); prior_content = elt.innerHTML; } setTimeout(check, 100); }; setTimeout(check, 100); } function apply_shortcode(source, name, callback) { return source.replace(new RegExp('\[' + name + '\s*([^\]]*)\]((.|[sn])*?)\[/' + name + '\]', 'g'), function(match, paramString, content) { params = new Object(); reg = /([a-z]+)="((:?="[^"]+"|[^"])*)"/gi; while ( (match = reg.exec(paramString)) != null ) { params[match[1]] = match[2]; } return callback(params, content); }); } function apply_filters(html) { html = apply_shortcode(html, "caption", function(args, content) { return '<div>' + content + '<p class="wp-caption-text">' + args.caption + '</p></div>'; }); return html; }

…changed to ‘body’ tag to…

 

…And wrapped a div around the main “#body#, #extended#” content with an id of content:

<div id="content">
#body#
#extended#
</div>

<div id="content"> #body# #extended# </div>

Basically, it polls the content area for changes, and when triggered, runs it though a filter. The above is extensible, and by adding additional “apply_shortcode” calls from “apply_filters“, more shortcodes can be simulated.

Read More

Keeping content active with popular posts widget and regular rotation

Vlad Bailescu’s WordPress Stats Helper plugin is useful for showing a list of top blog posts in one’s sidebar, but it can have the tendency to artificially elevate posts in a feedback cycle of awesomeness.

What you want is to rotate the posts around to give other popular posts some exposure. I’ve made some minor adjustments to Vlad’s plugin to add the option for random rotation.

Grab the modified version here: wordpresscom-stats-helper-random.zip

You’ll want to unzip this in your wp-plugins folder, disable the old plugin, then activate this one. See the new settings in the widgets section of your WordPress admin — I recommend a random pool size that’s twice the number of posts to display, but you can tweak the settings to your liking.

Read More

Galleria for WordPress

This plugin is based upon the Galleria javascript gallery, and displays your Flickr photos in a slideshow-like gallery.

It also displays your groups and photosets in a clickable list, to display photosets in the gallery.

This is a plugin I wrote for my own use (see it in action here), but I have received several requests to make it available.

Read More

Keeping blog visitors by showing meaningful search results in WordPress

I recently became disgruntled with the way my blogs displayed search results. By default, WordPress blogs will show searched posts exactly as they might appear on an index or archives page: Typically as an extract, or perhaps even as the full entry.

This doesn’t help at all if you’re looking for something in particular – It’s a much better idea to show the post within the context of the search query, as real search engines do.

See it in practice here.

This is a fairly easy thing to actually get working in WordPress. It’ll take just a couple of minutes, and will make a big difference to blog visitors. Here’s how I did it.

Read More

Flickrpress 1.0

Flickrpress sampleI’ve just finished a new release of my Flickr plugin for WordPress, Flickrpress.

The new version features AJAX-based navigation between pages of images, and improved support for insertion within pages and posts as a shortcode.

Flickrpress 1.0 can be downloaded from the WordPress plugin repository

See it an action over on my personal blog.

Read More

Upload Janitor WordPress Plugin

This plugin allows you to reclaim disk space and clean up your uploads folder by deleting old uploads you are no longer linking to.

It will identify unused files within your uploads folder, and give you the option of archiving then deleting some or all of these files.

Before any action is taken, Upload Janitor will automatically make a ‘tar’ archive of all files to be erased, including their original paths, so you can restore if necessary.

Read More

Hi! I'm Michael Tyson, and I run A Tasty Pixel from our home in the hills of Melbourne, Australia. I occasionally write on a variety of technology and software development topics. I've also spent 3.5-years travelling around Europe in a motorhome.

I make Loopy, the live-looper for iOS, Audiobus, the app-to-app audio platform, and Samplebot, a sampler and sequencer app for iOS.

Follow me on Twitter.

Posts pagination

1 2 … 4 »
© 2021 A Tasty Pixel.