{"id":105,"date":"2004-09-17T16:58:31","date_gmt":"2004-09-17T14:58:31","guid":{"rendered":"http:\/\/frenchfragfactory.net\/ozh\/archives\/2004\/09\/17\/click-counter-plugin-for-wordpress\/"},"modified":"2008-04-11T15:29:57","modified_gmt":"2008-04-11T13:29:57","slug":"click-counter-plugin-for-wordpress","status":"publish","type":"post","link":"https:\/\/planetozh.com\/blog\/2004\/09\/click-counter-plugin-for-wordpress\/","title":{"rendered":"Click Counter Plugin For WordPress"},"content":{"rendered":"<p>You have a blog. You have stats telling you how many people read it. You post links. But do you have something telling you how many people click on your links ?<\/p>\n<p>Here is it : I&#39;m releasing my latest plugin, <strong>Click Counter<\/strong>. Basically, it adds a click counter to links in your posts, as in these examples :<br \/>\nI love <a href=\"http:\/\/wordpress.org\">WordPress<\/a>, <a href=\"http:\/\/wordpress.org\" count=\"inline\">WordPress<\/a> and <a href=\"http:\/\/wordpress.org\" count=\"title inline\">WordPress<\/a>.<br \/>\nClick on one link and reload the page (hit counter displayed on mouseover link title, in plain text, or both)<\/p>\n<p>Less basically, it comes with a real bunch of options you&#39;ll probably never need to tweak, but I wanted to do something as flexible and usable as I could.<br \/>\n<!--more--><\/p>\n<p><strong>Current version<\/strong> : 1.02<\/p>\n<p><strong>Note<\/strong> : you may find sometimes this plugin disabled here on my own server, when I&#39;m tweaking a few things. The plugin is fully functionnal anyway, download it :-)<\/p>\n<p><strong>Note<\/strong>: The plugin is rather well commented, advanced users can probably directly download, edit and run. I&#39;d suggest reading the &quot;How it works&quot; and &quot;Tips &#038; Tricks&quot; sections anyway.<\/p>\n<h2>Set up the MySQL table<\/h2>\n<p>You need a new table in your WordPress database, named <strong>wp_linkclicks<\/strong> (you can modify the name, be sure then to edit the beginning of the plugin properly) Create this table with the following query :<\/p>\n<div id=\"ig-sh-1\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">sql<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"sql\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #993333;font-weight: bold\">CREATE<\/span> <span style=\"color: #993333;font-weight: bold\">TABLE<\/span> <span style=\"color: #ff0000\">`wp_linkclicks`<\/span> <span style=\"color: #66cc66\">&#040;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp;<span style=\"color: #ff0000\">`link_id`<\/span> <span style=\"color: #993333;font-weight: bold\">INT<\/span> <span style=\"color: #993333;font-weight: bold\">NOT<\/span> <span style=\"color: #993333;font-weight: bold\">NULL<\/span> <span style=\"color: #993333;font-weight: bold\">AUTO_INCREMENT<\/span> <span style=\"color: #66cc66\">,<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp;<span style=\"color: #ff0000\">`link_url`<\/span> TEXT <span style=\"color: #993333;font-weight: bold\">NOT<\/span> <span style=\"color: #993333;font-weight: bold\">NULL<\/span> <span style=\"color: #66cc66\">,<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp;<span style=\"color: #ff0000\">`link_clicks`<\/span> <span style=\"color: #993333;font-weight: bold\">INT<\/span> <span style=\"color: #993333;font-weight: bold\">NOT<\/span> <span style=\"color: #993333;font-weight: bold\">NULL<\/span> <span style=\"color: #66cc66\">,<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp;<span style=\"color: #ff0000\">`link_date`<\/span> DATETIME <span style=\"color: #993333;font-weight: bold\">NOT<\/span> <span style=\"color: #993333;font-weight: bold\">NULL<\/span> <span style=\"color: #66cc66\">,<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp;<span style=\"color: #ff0000\">`link_title`<\/span> TEXT <span style=\"color: #993333;font-weight: bold\">NOT<\/span> <span style=\"color: #993333;font-weight: bold\">NULL<\/span> <span style=\"color: #66cc66\">,<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp;<span style=\"color: #993333;font-weight: bold\">UNIQUE<\/span> <span style=\"color: #66cc66\">&#040;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; <span style=\"color: #ff0000\">`link_id`<\/span> <\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp;<span style=\"color: #66cc66\">&#041;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #66cc66\">&#041;<\/span>;<\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n<p><strong>Newbie tips<\/strong> : first, install <a href=\"http:\/\/www.phpmyadmin.net\/\">PHPMyAdmin<\/a> on your website. This is a great interface for anything you can do with MySQL databases. Once it&#39;s done, look for the &quot;SQL&quot; link in the menu : click, and paste in the textbox the above code. It will set up the required table for you.<\/p>\n<h2>Install<\/h2>\n<div class=\"download\">\nDownload the plugin :<br \/>\n<a href=\"http:\/\/downloads.wordpress.org\/plugin\/ozh-click-counter.zip\">ozh-click-counter.zip<\/a><br \/>\nExtract and upload to your blog, preserving directory structure if any.<br \/>\n<small>Note: download counter here and stats on wordpress.org may differ and reflect the number of downloads before this plugin was hosted on the plugin directory<\/small>\n<\/div>\n<p>The archive contains the tracker file, <em>go.php<\/em> : put this file in your blog root. If for some reason you want to modify the tracker file name, be sure to properly edit the beginning of the plugin script as well.<\/p>\n<h2>Use the plugin<\/h2>\n<p>In its default configuration, the plugin needs nothing more. Get back to your blog and post as usual. It will silently add trackers to links in your posts and links in commenters&#39; posts.<\/p>\n<p><strong>A small warning<\/strong> : adding a counter to a link &quot;costs&quot; one SQL query. If you are hosted on a slow server, or if you are <em>teh ultimate linkblogger<\/em> with 200 external links posted in your frontpage <em>\u00e0 la <\/em>Metafilter, you might slightly overload your SQL server :) If this is your case, read by the end of this article the Tips &#038; Tricks, I&#39;ll explain how to add a &quot;silent tracker with no SQL query&quot;.<\/p>\n<p><strong>Another small warning<\/strong> : the plugin works with proper xhtml syntax, that is <strong>href=&quot;url&quot;<\/strong> or <strong>class=&quot;myclass&quot;<\/strong> (quotes), not <strong>href=url  <\/strong>or <strong>class=myclass <\/strong>(no quotes)<\/p>\n<h2>How it works<\/h2>\n<p>Don&#39;t change anything to your posting habits, the plugin is the &quot;install &#038; forget&quot; type.<\/p>\n<p>When your WordPress will print a post with a link, the plugin replaces every link target and title. For example :<\/p>\n<div id=\"ig-sh-2\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">HTML<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"html4strict\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #009900\">&lt;<span style=\"color: #000000;font-weight: bold\">a<\/span> <span style=\"color: #000066\">href<\/span><span style=\"color: #66cc66\">=<\/span><span style=\"color: #ff0000\">&quot;http:\/\/www.link.com\/page.php&quot;<\/span>&gt;<\/span>link<span style=\"color: #009900\">&lt;<span style=\"color: #66cc66\">\/<\/span><span style=\"color: #000000;font-weight: bold\">a<\/span>&gt;<\/span><\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n<p>becomes<\/p>\n<div id=\"ig-sh-3\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">HTML<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"html4strict\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #009900\">&lt;<span style=\"color: #000000;font-weight: bold\">a<\/span> <span style=\"color: #000066\">href<\/span><span style=\"color: #66cc66\">=<\/span><span style=\"color: #ff0000\">&quot;yourblog\/go.php?http:\/\/www.link.com\/page.php&quot;<\/span><\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #009900\"> &nbsp;<span style=\"color: #000066\">title<\/span><span style=\"color: #66cc66\">=<\/span><span style=\"color: #ff0000\">&quot;XX clicks&quot;<\/span>&gt;<\/span>link<span style=\"color: #009900\">&lt;<span style=\"color: #66cc66\">\/<\/span><span style=\"color: #000000;font-weight: bold\">a<\/span>&gt;<\/span><\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n<p>The number of clicks in the title value will be added to an existing title if specified : <em>title=&quot;this is a cool link (XX clicks)&quot;<\/em><\/p>\n<p>When someone clicks on this modified link, it will add or update the following values to the table you&#39;ve created earlier :<\/p>\n<ul>\n<li>link_id: the link id, which is more or less useless<\/li>\n<li>link_url : the url, &quot;<em>http:\/\/www.this-is-a-link.com\/page.php<\/em>&quot; in the above example<\/li>\n<li>link_clicks : how many people clicked on it<\/li>\n<li>link_date : the date of the first click on it (not the date you posted it)<\/li>\n<li>link_title : the title of the remote page, if exists, as defined by its title html tag<\/li>\n<\/ul>\n<p>Unless stated otherwise, only external links will have a counter added, because it&#39;s pointless to track how many people click on your pages. There are stats plugins for this :)<br \/>\nSo, if you want to add a counter to an internal file, put a absolute path in the link html : href=&quot;http:\/\/site\/blog\/file&quot; instead of href=&quot;file&quot;<\/p>\n<h2>Template Tags<\/h2>\n<p>I&#39;ve written two &quot;template tags&quot; you can add to your pages<\/p>\n<ul>\n<li><strong>wp_ozh_click_topclicks($limit, $trim , $pattern)<\/strong> : displays your most clicked links<\/li>\n<li><strong>wp_ozh_click_comment_author_link()<\/strong> : a replacer for <em>comment_author_link() <\/em>in <em>wp-comments.php<\/em>, if you want to add a counter to your commenters&#39; website when specified.<\/li>\n<\/ul>\n<p>As you can see, the first one, <strong>wp_ozh_click_topclicks<\/strong>, has 3 optionnal arguments :<\/p>\n<ul>\n<li>$limit : how many links you want to display. Default value is 5, and can be modified in the plugin.<\/li>\n<li>$trim : maximum length for displayed links title. Setting this for example at 5 will convert &quot;WordPress Home&quot; to &quot;Wordp&#8230;&quot;. Default value is 15, and can be modified in the plugin.<\/li>\n<li>$pattern : html code used to display the list. See right below.<\/li>\n<\/ul>\n<p>The pattern parameter is an html string with template tags. The default value, as defined in the plugin, is :<\/p>\n<div id=\"ig-sh-4\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">code<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"code\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&lt;li&gt;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &lt;a href=&quot;%%link_url%%&quot; title=&quot;%%link_title%%&quot;&gt;%%link_title_trim%%&lt;\/a&gt;: %%link_clicks%%<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&lt;\/li&gt;<\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n<p>Tags are enclosed in between &quot;%%&quot; and can be :<\/p>\n<ul>\n<li><strong>link_id<\/strong>: the link id number in the sql database, I don&#39;t see why you would use this one :)<\/li>\n<li><strong>link_url <\/strong>: the link url, obviously. <\/li>\n<li><strong>link_clicks <\/strong>: the number of clicks the link has received so far<\/li>\n<li><strong>link_date <\/strong>: date of first click (more or less useless too, I admit)<\/li>\n<li><strong>link_title <\/strong>: remote page title<\/li>\n<li><strong>link_title_trim <\/strong>:  shortened value of link_title, trimmed to the value of $trim as defined previously.<\/li>\n<\/ul>\n<p>If the target page has no title, and is html content, the title will be replaced by the url itself. In this case, %%link_title%% will output the url, shortened by its trailing slash and leading <em>http:\/\/www.<\/em> if applicable.<\/p>\n<p>It the page has no title because it&#39;s not an html document (<em>http:\/\/site.com\/somefile.zip <\/em>for example), it will be replaced by the document name (<em>somefile.zip<\/em>)<\/p>\n<h2>Optionnal configuration tweaking<\/h2>\n<p>Now, I&#39;ll go through all the variables and their default values you can modify and edit at the beginning of the script. For the interested only, most users don&#39;t need so much tweaking and are probably bored of reading this page :)<br \/>\n<strong>Note <\/strong>: as usual, I&#39;ve named the plugin file, functions and vars with a beginning &quot;wp_ozh_click&quot; to prevent any nuclear world war.<\/p>\n<p>Core variables :<\/p>\n<p><strong>$wp_ozh_click[&#39;table&#39;] = &#39;wp_linkclicks&#39;<\/strong><br \/>\nName of the table where stats will be stored<\/p>\n<p><strong>$wp_ozh_click[&#39;file&#39;] = get_settings(&#39;siteurl&#39;) . &quot;\/go.php&quot;<\/strong><br \/>\nName and location of the tracker file<\/p>\n<p>Basic features :<\/p>\n<p><strong>$wp_ozh_click[&#39;track_all_links&#39;] = 1<\/strong><br \/>\nValue can be 1 or 0<br \/>\nIf set to 1, every link will have a tracker. Just post as usual.<br \/>\nIf set to 0, you will have to specify when you want to add a tracker, with the following code :<\/p>\n<div id=\"ig-sh-5\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">HTML<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"html4strict\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #009900\">&lt;<span style=\"color: #000000;font-weight: bold\">a<\/span> <span style=\"color: #000066\">href<\/span><span style=\"color: #66cc66\">=<\/span><span style=\"color: #ff0000\">&quot;http:\/\/site.com\/&quot;<\/span> count<span style=\"color: #66cc66\">=<\/span><span style=\"color: #ff0000\">&quot;1&quot;<\/span>&gt;<\/span>link<span style=\"color: #009900\">&lt;<span style=\"color: #66cc66\">\/<\/span><span style=\"color: #000000;font-weight: bold\">a<\/span>&gt;<\/span><\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n<p>The value <em>count<\/em>will be removed at processing time, so output will be valid html.<br \/>\nThe value of count can be : 1, title, inline, or a mix.<\/p>\n<ul>\n<li><strong>count = &quot;1&quot;<\/strong> : number of hits will be added to link according to the default behaviour as defined in the script (see below)<\/li>\n<li><strong>count = &quot;title&quot;<\/strong> : number of hits added in link title : &lt;a href=&quot;http:\/\/site.com\/&quot; title=&quot;69 hits&quot;&gt;link&lt;\/a&gt;<\/li>\n<li><strong>count = &quot;inline&quot;<\/strong> : number of hits added in plain text, after the link : &lt;a href=&quot;http:\/\/site.com\/&quot; &gt;link&lt;\/a&gt; (69 hits)<\/li>\n<li>count=&quot;title inline&quot; : both : &lt;a href=&quot;http:\/\/site.com\/&quot; title=&quot;69 hits&quot;&gt;link&lt;\/a&gt; (69 hits)<\/li>\n<\/ul>\n<p><strong>$wp_ozh_click[&#39;in_title&#39;] = 1<\/strong><br \/>\nValue can be 1 or 0<br \/>\nDefault behaviour for displaying counter (according to $wp_ozh_click[&#39;track_all_links&#39;] or to count value in the link html). If set to one, display hit number in link title.<\/p>\n<p><strong>$wp_ozh_click[&#39;in_plain&#39;] = 0<\/strong><br \/>\nValue can be 1 or 0<br \/>\nDefault behaviour for displaying counter (according to $wp_ozh_click[&#39;track_all_links&#39;] or to count value in the link html). If set to one, display hit number in plain text after the link.<\/p>\n<p><strong>$wp_ozh_click[&#39;0click&#39;] = &#39;No click&#39;<\/strong><br \/>\nDefault text for zero click<\/p>\n<p><strong>$wp_ozh_click[&#39;1click&#39;] = &#39;One hit&#39;<\/strong><br \/>\nDefault text for one click<\/p>\n<p><strong>$wp_ozh_click[&#39;clicks&#39;] = &#39;%% hits&#39;<\/strong><br \/>\nDefault text for several clicks, where %% will be replaced by a number<\/p>\n<p><strong>$wp_ozh_click[&#39;method&#39;] = 2<\/strong><br \/>\nValue can be 1, 2 or 3.<br \/>\nThere are 3 ways to modify the link html to add the tracker. Each has advantages and drawbacks, but all validate any Doctype up to XHTML 1.1. If you want things to remain simple, just skip this setting and leave its default value<br \/>\nDepending on the chosen method, &lt;a href=&quot;http:\/\/site.com&quot;&gt; will become :<\/p>\n<ul>\n<li><strong>Method 1<\/strong>:<br \/>&lt;a href=&quot;http:\/\/site.com&quot; onclick=&quot;window.location=&#039;\/go.php?http:\/\/site.com&#039;; return false&quot;&gt;<br \/>Cool : status bar shows real link without further trick.<br \/>Less cool : doesnt work with &quot;open link in new window&quot;<\/li>\n<li><strong>Method 2<\/strong>:<br \/>&lt;a href=&quot;\/yourblog\/go.php?http:\/\/site.com&quot;&gt;<br \/>Cool : works with &quot;open in new window&quot; and doesn&#39;t require Javascript enabled<br \/>Less cool : shows ugly link &quot;\/blog\/go.php?http:\/\/site.com&quot; in status bar<\/li>\n<li><strong>Method 3<\/strong>:<br \/>like method 2 but also modifies status bar to hide the ugly and sometimes annoying &quot;yoursite.com\/blog\/go.php?&quot; part with onmouseover=&quot;javascript:window.status=&#039;http:\/\/site.com&#039;; return false&quot;<br \/>Cool : status bar shows real link.<br \/>Less cool : adds a few bytes of html<\/li>\n<li>I&#39;d suggest you use preferably method 2, or at least method 3. Method 1 is really less accurate since it doesn&#39;t keep track of links opened in a new window<\/li>\n<\/ul>\n<p><strong>$wp_ozh_click[&#39;do_posts&#39;] = 1<\/strong><br \/>\nValue can be 1 or 0 :<br \/>\nDo you want to add a counter to links in your posts ?<\/p>\n<p><strong>$wp_ozh_click[&#39;do_comments&#39;] = 1<\/strong><br \/>\nValue can be 1 or 0 :<br \/>\nDo you want to add a counter to links in your commenters comments ?<\/p>\n<p>Now onto the link title features :<\/p>\n<p><strong>$wp_ozh_click[&#39;get_title&#39;] = 0<\/strong><br \/>\nValue can be 1 or 0.<br \/>\nGet remote page title the first time a user clicks a link to store it along with hits in the table. This will slow down the first clicker, by 1 or 2 seconds maximum, time for your website to retrieve the distant page and parse it.<br \/>\nNote : mostly untested feature. It uses <a href=\"http:\/\/php.net\/fopen\">fopen()<\/a>, check your host has enabled this (if not, the plugin will work anyway, and title will simply be empty)<\/p>\n<p><strong>$wp_ozh_click[&#39;get_title_forcerefresh&#39;] = 50<\/strong><br \/>\nValue is an integer.<br \/>\nRefresh remote page title every XX clicks. Set to 0 if you don&#39;t want to use this feature. If you chose to use it, the higher traffic &#8211; then clicks &#8211; you get, the higher you should set this. Examples : 50 for Joe&#39;s blog, 3000 for Slashdottish blog.<br \/>\nTo be honest this is really a gadget &#8211; almost totally useless :)<\/p>\n<p><strong>$wp_ozh_click[&#39;extensions&#39;] = array ( <em>lots of extensions <\/em>)<\/strong><br \/>\nMost common non html file extensions. These are files that have no title html tag, so their link title will be the file name (somefile.zip for example)<\/p>\n<p>Then, top link features :<\/p>\n<p><strong>$wp_ozh_click[&#39;top_limit&#39;] = 5<\/strong><br \/>\nDefault number of top links to be displayed by <strong>wp_ozh_click_topclicks()<\/strong> (see above, Template Tags)<\/p>\n<p><strong>$wp_ozh_click[&#039;top_pattern&#039;] = &#039;&lt;li&gt;&lt;a href=&quot;%%link_url%%&quot; title=&quot;%%link_title%%&quot;&gt;%%link_title_trim%%&lt;\/a&gt;: %%link_clicks%%&lt;\/li&gt;&#039;<\/strong><br \/>\nDefault pattern used to display top links (see above, Template Tags)<\/p>\n<p><strong>$wp_ozh_click[&#39;trim&#39;] = 15<\/strong><br \/>\nDefault maximum length of link titles (0 not to trim)<\/p>\n<h2>Tips and Tricks<\/h2>\n<p>Here are listed a few tips or thoughts I&#39;ve had during the development and test of the plugin.<\/p>\n<p><strong>&raquo; As a file download counter<\/strong><br \/>\nYou can use this plugin as a download counter to see how popular are your files :-P<br \/>\nTo do so, you can either specify <em>count=&quot;1&#8243;<\/em> in the download link html tag, or link them with an absolute file (<em>http:\/\/site\/blog\/download\/file.zip<\/em>)<\/p>\n<p><strong>&raquo; Use with Matt&#39;s Asides<\/strong><br \/>\nIf you are using Matt&#39;s asides or something similar, you&#39;ll have to modify a bit your index.php<br \/>\nReplace<\/p>\n<div id=\"ig-sh-6\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">php<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"php\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #b1b100\">echo<\/span> wptexturize<span style=\"color: #009900\">&#040;<\/span><span style=\"color: #000088\">$post<\/span><span style=\"color: #339933\">-&gt;<\/span><span style=\"color: #004000\">post_content<\/span><span style=\"color: #009900\">&#041;<\/span><\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n<p>with<\/p>\n<div id=\"ig-sh-7\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">php<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"php\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #b1b100\">echo<\/span> wp_ozh_click_modifyhrefs<span style=\"color: #009900\">&#040;<\/span>wptexturize<span style=\"color: #009900\">&#040;<\/span><span style=\"color: #000088\">$post<\/span><span style=\"color: #339933\">-&gt;<\/span><span style=\"color: #004000\">post_content<\/span><span style=\"color: #009900\">&#041;<\/span><span style=\"color: #009900\">&#041;<\/span><\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n<p><strong>&raquo; Use with blogrolls<\/strong><br \/>\nSimilarily, if you want to use the feature on a blogroll link list for example, modify the php code to add wp_ozh_click_modifyhrefs().<br \/>\nRemember one thing : each link counter display (in title on in plain text) will cost 1 SQL query. Know what your server can handle before doing such things :)<\/p>\n<p><strong>&raquo; Invisible tracker for weak SQL servers<\/strong><br \/>\nYou can use the plugin to track clicks at no SQL cost : set $wp_ozh_click[&#39;track_all_links&#39;], $wp_ozh_click[&#39;in_title&#39;] and $wp_ozh_click[&#39;in_plain&#39;] to zero. It will still modify your link html tags to add the tracker file to them, but it won&#39;t display hit counters along with links.<br \/>\nNow, check your link clicks from phpmyadmin directly, or using the template tag <strong>wp_ozh_click_topclicks()<\/strong> (1 SQL query)<\/p>\n<h2>History<\/h2>\n<p><strong>1.0<\/strong> : <\/p>\n<ul>\n<li>Initial release<\/li>\n<\/ul>\n<p><strong>1.01<\/strong> : <\/p>\n<ul>\n<li> improved : only one query if same url repeated<\/li>\n<li>fixed : no javascript in links for rss outputs (so the feed validates)<\/li>\n<\/ul>\n<p><strong>1.02<\/strong> : <\/p>\n<ul>\n<li>fixed potential SQL injection<\/li>\n<\/ul>\n<h2>Wow<\/h2>\n<p>It took me almost longer to write this doc than to write the plugin itself :)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A new wordpress plugin : link click counter<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[2,10,85,74,245],"class_list":["post-105","post","type-post","status-publish","format-standard","hentry","category-published","tag-code","tag-php","tag-plugins","tag-stats","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/posts\/105","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/comments?post=105"}],"version-history":[{"count":0,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/posts\/105\/revisions"}],"wp:attachment":[{"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/media?parent=105"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/categories?post=105"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/tags?post=105"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}