Counting pageviews on high-traffic cached sites

It really depends what you need to view counts for – if it’s just for seeing traffic stats, then use Google Analytics or any number of javascript tracker based analytics tools. If you need integration of page view counts and the ability to do things like order post by views, then you can either spend … Read more

Custom routing for plugins

The WordPress Way of doing it is using query_vars so first you add you vars to the array: //add to query vars function add_query_vars($vars) { $new_vars = array(‘custom_method’,’cm_parameter’); $vars = $new_vars + $vars; return $vars; } add_filter(‘query_vars’, ‘add_query_vars’); then you can check in your plugin for the vars: global $wp; if (array_key_exists(‘custom_method’, $wp->query_vars) && isset($wp->query_vars[‘custom_method’])){ … Read more

Workflow and best practice for documentation [closed]

Great question. There is no generic and comprehensive documentation workflow in WordPress circles. However there are some nice tools and options to make use of. readme.txt Markdown-based machine-readable file. It’s main purpose is to be parsed and presented by official plugin repository, but it’s not too convenient outside of that. It is great and fitting … Read more

Star rating for custom post types [closed]

For any rating functionality I always turn to GD Star Rating by Milan Petrovic. This plugin can do SO many things, including thumb rating, rating of comments, multiple ratings, etc. It can also handle Rich Snippets (for getting your star ratings shown in Google SERPs), caching mechanisms, etc.. In short, it can do a lot, … Read more

Theme and Plugins sharing common libraries

Can a theme or plugin go and fetch another plugin and install it? For themes, it’s rather straighforward. See https://github.com/thomasgriffin/TGM-Plugin-Activation For plugins, it’s trickier, since you can’t bundle the same boilerplate code in more than one plugin. See http://wordpress.org/extend/plugins/plugin-dependencies/

How can I make the “Preview Post” button save and preview in the same window?

Here’s a way to do it without modifying the core: add_action(‘admin_footer’,’preview_same_window’); function preview_same_window(){ ?> <script type=”text/javascript”> jQuery(function($){ jQuery(‘.preview.button’).unbind().removeAttr(‘target’); setTimeout(function(){ jQuery(‘.preview.button’).unbind().removeAttr(‘target’); },250); }); </script> <?php }