Counterize II カウンタリセット時刻調整

自分用メモ

Counterize IIのカウンターリセットが毎日9時になっていたので、下記に変更し0時にリセットするように変更

修正前

<br />
// Returns amount of hits today.<br />
function counterize_gethitstoday()<br />
{<br />
global $wpdb;<br />
$today = date(&quot;Y-m-d&quot;);<br />
$sql = &quot;SELECT COUNT(1) FROM &quot; . counterize_logTable() . &quot; WHERE timestamp &amp;gt;= '{$today}'&quot;;<br />
return $wpdb-&amp;gt;get_var($sql);<br />
}<br />

修正後

<br />
// Returns amount of hits today.<br />
function counterize_gethitstoday()<br />
{<br />
global $wpdb;<br />
$today = date(&quot;Y-m-d&quot;, current_time('timestamp'));<br />
$sql = &quot;SELECT COUNT(1) FROM &quot; . counterize_logTable() . &quot; WHERE timestamp &amp;gt;= '{$today}'&quot;;<br />
return $wpdb-&amp;gt;get_var($sql);<br />
}<br />

5/31追記 昨日分のカウンターも下記のように修正

修正前

<br />
//Returns amount of hits yesterday<br />
function counterize_gethitsyesterday()<br />
{<br />
    $today = date(&quot;Y-m-d&quot;);<br />
	$yesterday = date(&quot;Y-m-d&quot;, strtotime(&quot;-1 day&quot;));<br />
    $sql = &quot;SELECT COUNT(1) FROM &quot;.counterize_logTable().&quot; WHERE timestamp &gt;= '$yesterday' AND timestamp &lt; '$today' &quot;;    $wpdb =&amp; $GLOBALS['wpdb'];  return $wpdb-&gt;get_var($sql);<br />
}<br />

修正後

<br />
//Returns amount of hits yesterday<br />
function counterize_gethitsyesterday()<br />
{<br />
    $today = date(&quot;Y-m-d&quot;, current_time('timestamp'));<br />
	$yesterday = date(&quot;Y-m-d&quot;, strtotime(&quot;-1 day&quot;));<br />
    $sql = &quot;SELECT COUNT(1) FROM &quot;.counterize_logTable().&quot; WHERE timestamp &gt;= '$yesterday' AND timestamp &lt; '$today' &quot;;    $wpdb =&amp; $GLOBALS['wpdb'];  return $wpdb-&gt;get_var($sql);<br />
}<br />

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です