{"id":1364,"date":"2010-12-26T17:54:50","date_gmt":"2010-12-26T23:54:50","guid":{"rendered":"http:\/\/bililite.nfshost.com\/blog\/?p=1364"},"modified":"2010-12-27T00:01:23","modified_gmt":"2010-12-27T06:01:23","slug":"simple-sitemeter-widget","status":"publish","type":"post","link":"https:\/\/bililite.com\/blog\/2010\/12\/26\/simple-sitemeter-widget\/","title":{"rendered":"Simple Sitemeter Widget"},"content":{"rendered":"<p>I just started using <a href=\"http:\/\/sitemeter.com\">Sitemeter<\/a> for tracking page visits (everyone seems to use Google Analytics, but I've used Sitemeter before and am satisfied with what I've got). Sort of depressing seeing a \"1\" for the visit count, but it's new as of today. Creating a widget to put in the sidebar was straightforward, since I've already <a href=\"\/blog\/2010\/12\/26\/hacking-my-way-to-an-amazon-wishlist-widget\/\">created one widget<\/a>:<\/p>\r\n<pre><code class=\"language-php\">\/*\r\nPlugin Name: Sitemeter Widget\r\nPlugin URI: http:\/\/bililite.nfshost.com\/blog\/2010\/12\/26\/simple-sitemeter-widget\/\r\nDescription: Display the sitemeter.com badge in the sidebar\r\nAuthor: Daniel Wachsstock\r\nVersion: 1.0\r\nAuthor URI: http:\/\/bililite.nfshost.com\/blog\r\n*\/ \r\n\r\n\/\/ WordPress 2.8 Widget code based on http:\/\/jessealtman.com\/2009\/06\/08\/tutorial-wordpress-28-widget-api\/\r\n\/\/ and http:\/\/justcoded.com\/article\/wordpress-28-multi-widgets\/\r\n\r\nclass Sitemeter_Widget extends WP_Widget{\r\n  function Sitemeter_Widget(){\r\n    $this-&gt;WP_Widget ('sitemeter', __('Sitemeter'), array(\r\n     'description' =&gt; 'Display the Sitemeter Badge'\r\n    ));\r\n  } \/\/ constructor\r\n  function widget ($args, $instance){\r\n    extract ($args, EXTR_SKIP);\r\n    extract ($instance, EXTR_SKIP);\r\n    echo $before_widget.$before_title.$title.$after_title;\r\n\t\techo &quot;&lt;!-- Site Meter --&gt;\r\n&lt;script type=\\&quot;text\/javascript\\&quot; src=\\&quot;http:\/\/$server.sitemeter.com\/js\/counter.js?site=$account\\&quot;&gt;\r\n&lt;\/script&gt;\r\n&lt;noscript&gt;\r\n&lt;a href=\\&quot;http:\/\/$server.sitemeter.com\/stats.asp?site=$account\\&quot; target=\\&quot;_top\\&quot;&gt;\r\n&lt;img src=\\&quot;http:\/\/$server.sitemeter.com\/meter.asp?site=$account\\&quot; alt=\\&quot;Site Meter\\&quot; border=\\&quot;0\\&quot;\/&gt;&lt;\/a&gt;\r\n&lt;\/noscript&gt;\r\n&lt;!-- Copyright (c)2009 Site Meter --&gt;&quot;;\r\n    echo $after_widget;\r\n  } \/\/ widget display code\r\n  function update ($new, $old){\r\n    return array_merge ($old, $new);\r\n  } \/\/ options update\r\n  function form ($instance){\r\n    extract ($instance, EXTR_SKIP);\r\n    $this-&gt;textElement ('title', 'Title', $title);\r\n    $this-&gt;textElement ('server', 'Server', $server);\r\n    $this-&gt;textElement ('account', 'Account', $account);\r\n  } \/\/ control form\r\n  function textElement ($index, $text, $value){\r\n    $id = $this-&gt;get_field_id($index);\r\n    $name = $this-&gt;get_field_name ($index);\r\n    $text = __($text); \/\/ localize\r\n    echo &quot;&lt;p&gt;&lt;label for=\\&quot;$id\\&quot;&gt;$text &lt;input name=\\&quot;$name\\&quot; class=\\&quot;widefat\\&quot; value=\\&quot;$value\\&quot; id=\\&quot;$id\\&quot; \/&gt;&lt;\/label&gt;&lt;\/p&gt;&quot;;\r\n  } \/\/ textElement\r\n} \/\/ class Sitemeter_Widget\r\n\r\nadd_action ('widgets_init', create_function('', 'return register_widget(&quot;Sitemeter_Widget&quot;);'));<\/code><\/pre>\r\n<p>Short and sweet<\/p>","protected":false},"excerpt":{"rendered":"I just started using Sitemeter for tracking page visits (everyone seems to use Google Analytics, but I've used Sitemeter before and am satisfied with what I've got). Sort of depressing seeing a \"1\" for the visit count, but it's new as of today. Creating a widget to put in the sidebar was straightforward, since I've [&hellip;]","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,20],"tags":[],"_links":{"self":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts\/1364"}],"collection":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/comments?post=1364"}],"version-history":[{"count":15,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts\/1364\/revisions"}],"predecessor-version":[{"id":1396,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts\/1364\/revisions\/1396"}],"wp:attachment":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/media?parent=1364"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/categories?post=1364"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/tags?post=1364"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}