<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
> <channel><title>Gary Pendergast &#187; WordPress</title> <atom:link href="http://pento.net/category/wordpress/feed/" rel="self" type="application/rss+xml" /><link>http://pento.net</link> <description>I&#039;m on the Internet</description> <lastBuildDate>Sat, 03 Dec 2011 09:27:46 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <cloud
domain='pento.net' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' /> <item><title>Preventing Users From Accessing wp-admin</title><link>http://pento.net/2011/06/19/preventing-users-from-accessing-wp-admin/</link> <comments>http://pento.net/2011/06/19/preventing-users-from-accessing-wp-admin/#comments</comments> <pubDate>Sun, 19 Jun 2011 05:58:45 +0000</pubDate> <dc:creator>Gary</dc:creator> <category><![CDATA[WordPress]]></category> <category><![CDATA[hack]]></category> <guid
isPermaLink="false">http://pento.net/?p=592</guid> <description><![CDATA[If you have a WordPress site that you allow people to sign up for, you often don&#8217;t want them to be able to access wp-admin. It&#8217;s not that there are any security issues, you just want to ensure that your users are accessing your site in a predictable manner. To block non-admin users from getting [...]]]></description> <content:encoded><![CDATA[<p>If you have a WordPress site that you allow people to sign up for, you often don&#8217;t want them to be able to access wp-admin. It&#8217;s not that there are any security issues, you just want to ensure that your users are accessing your site in a predictable manner.</p><p>To block non-admin users from getting into wp-admin, you just need to add the following code to your <tt>functions.php</tt>, or somewhere similar:</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;">add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'blockusers_init'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> blockusers_init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> is_admin<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span> current_user_can<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'administrator'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		wp_redirect<span style="color: #009900;">&#40;</span> home_url<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">exit</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div><p>Ta-da! Now, only administrator users can access wp-admin, everyone else will be re-directed to the homepage.</p> ]]></content:encoded> <wfw:commentRss>http://pento.net/2011/06/19/preventing-users-from-accessing-wp-admin/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Partitioning the WordPress Comments Table</title><link>http://pento.net/2011/04/28/partitioning-the-wordpress-comments-table/</link> <comments>http://pento.net/2011/04/28/partitioning-the-wordpress-comments-table/#comments</comments> <pubDate>Thu, 28 Apr 2011 07:19:41 +0000</pubDate> <dc:creator>Gary</dc:creator> <category><![CDATA[MySQL]]></category> <category><![CDATA[WordPress]]></category> <category><![CDATA[Partitioning]]></category> <guid
isPermaLink="false">http://pento.net/?p=579</guid> <description><![CDATA[WordPress sites can get big. Really big. When you&#8217;re looking at a site of Cheezburger, Engadget or Techcrunch proportions, you get hundreds of comments per post, on dozens of posts per day, which adds up to millions of comments per year. In order to keep your site running in top condition, you don&#8217;t want to [...]]]></description> <content:encoded><![CDATA[<p>WordPress sites can get big. Really big. When you&#8217;re looking at a site of Cheezburger, Engadget or Techcrunch proportions, you get hundreds of comments per post, on dozens of posts per day, which adds up to millions of comments per year.</p><p>In order to keep your site running in top condition, you don&#8217;t want to be running queries against tables with lots of rarely accessed rows, which is what happens with most comments &#8211; after the post drops off the front page, readership drops, so the comments are viewed much less frequently. So, what we want to do is remove these old comments from the primary comment table, but keep them handy, for when people read the archives.</p><p>Enter partitioning.</p><p>The idea of MySQL partitioning is that it splits tables up into multiple logical tablespaces, based on your criteria. Running a query on a single partition of a large table is much faster than running it across the entire table, even with appropriate indexes.</p><p>In the case of the WordPress comments table, splitting it up by the `comment_post_ID` seems to be the most appropriate . This should keep the partitions to a reasonable size, and ensure that there&#8217;s minimal cross-over between partitions.</p><p>First off, we need to add the `comment_post_ID` column to the Primary Key. This can be a slow process if you already have a massive `wp_comments` table, so you may need to schedule some downtime to handle this. Alternatively, there many methods for making schema changes with no downtime, such as judicious use of Replication, Facebook&#8217;s <a
href="https://www.facebook.com/notes/mysql-at-facebook/online-schema-change-for-mysql/430801045932">Online Schema Change Tool</a>, or the currently-in-development <a
href="http://code.google.com/p/maatkit/issues/detail?id=1268">mk-online-schema-change</a>, for Maatkit.</p><div
class="wp_syntax"><div
class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">ALTER</span> <span style="color: #990099; font-weight: bold;">TABLE</span> wp_comments <span style="color: #990099; font-weight: bold;">DROP</span> <span style="color: #990099; font-weight: bold;">PRIMARY KEY</span><span style="color: #000033;">,</span> <span style="color: #990099; font-weight: bold;">ADD</span> <span style="color: #990099; font-weight: bold;">PRIMARY KEY</span> <span style="color: #FF00FF;">&#40;</span>comment_ID<span style="color: #000033;">,</span> comment_post_ID<span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span></pre></div></div><p>Now that we&#8217;ve altered this index, we can define the partitions. For this example, we&#8217;ll say we want the comments for 1000 posts per partition. This query can take a long time to run, if you already have many comments in your system.</p><div
class="wp_syntax"><div
class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">ALTER</span> <span style="color: #990099; font-weight: bold;">TABLE</span> wp_comments PARTITION BY RANGE<span style="color: #FF00FF;">&#40;</span>comment_post_ID<span style="color: #FF00FF;">&#41;</span> <span style="color: #FF00FF;">&#40;</span>
    PARTITION p0 <span style="color: #990099; font-weight: bold;">VALUES</span> LESS THAN <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">1000</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span>
    PARTITION p1 <span style="color: #990099; font-weight: bold;">VALUES</span> LESS THAN <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">2000</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span>
    PARTITION p2 <span style="color: #990099; font-weight: bold;">VALUES</span> LESS THAN <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">3000</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span>
    PARTITION p3 <span style="color: #990099; font-weight: bold;">VALUES</span> LESS THAN <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">4000</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span>
    PARTITION p4 <span style="color: #990099; font-weight: bold;">VALUES</span> LESS THAN <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">5000</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span>
    PARTITION p5 <span style="color: #990099; font-weight: bold;">VALUES</span> LESS THAN <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">6000</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span>
    PARTITION p6 <span style="color: #990099; font-weight: bold;">VALUES</span> LESS THAN MAXVALUE
<span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span></pre></div></div><p>When you&#8217;re approaching the next partition divider value, adding a new partition is simple. For example, you&#8217;d run this query around post 6000.</p><div
class="wp_syntax"><div
class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">ALTER</span> <span style="color: #990099; font-weight: bold;">TABLE</span> wp_comments REORGANIZE PARTITION p6 <span style="color: #990099; font-weight: bold;">INTO</span> <span style="color: #FF00FF;">&#40;</span>
    PARTITION p6 <span style="color: #990099; font-weight: bold;">VALUES</span> LESS THAN <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">7000</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span>
    PARTITION p7 <span style="color: #990099; font-weight: bold;">VALUES</span> LESS THAN MAXVALUE
<span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span></pre></div></div><p>Naturally, this process is most useful for very large WordPress sites. If you&#8217;re starting a new site with big plans, however, you may just want to factor this into your architecture.</p><p><strong>UPDATE:</strong> Changed the partition definition to better reflect how WordPress uses the wp_comments table, per Giuseppe&#8217;s comments.</p> ]]></content:encoded> <wfw:commentRss>http://pento.net/2011/04/28/partitioning-the-wordpress-comments-table/feed/</wfw:commentRss> <slash:comments>6</slash:comments> </item> <item><title>Stats for WordPress plugins and themes hosted on wordpress.org</title><link>http://pento.net/2010/03/03/stats-for-wordpress-plugins-and-themes-hosted-on-wordpress-org/</link> <comments>http://pento.net/2010/03/03/stats-for-wordpress-plugins-and-themes-hosted-on-wordpress-org/#comments</comments> <pubDate>Wed, 03 Mar 2010 15:40:56 +0000</pubDate> <dc:creator>Gary</dc:creator> <category><![CDATA[WordPress]]></category> <category><![CDATA[wordpress.org]]></category> <guid
isPermaLink="false">http://pento.net/?p=381</guid> <description><![CDATA[I am a stats addict. For all of the sites I work on, there&#8217;s a link in my Google Analytics account to show me the statistics for that site. Unfortunately, there&#8217;s one site missing from the chain: wordpress.org. Job Manager is hosted there, but I cannot see the visitor statistics. Google Code allows you to [...]]]></description> <content:encoded><![CDATA[<p>I am a stats addict. For all of the sites I work on, there&#8217;s a link in my Google Analytics account to show me the statistics for that site.</p><p>Unfortunately, there&#8217;s one site missing from the chain: wordpress.org. <a
href="http://pento.net/projects/wordpress-job-manager-plugin/">Job Manager</a> is hosted there, but I cannot see the visitor statistics. Google Code allows you to track statistics for your project hosted there, so I think wordpress.org hosting should be able to do the same, for plugins and themes hosted there.</p><p>To that end, I have submitted a <a
href="http://wordpress.org/extend/ideas/topic/google-analytics-for-hosted-pluginsthemes">shiny new feature request</a>. If you like this idea, go, comment, and vote for it!</p> ]]></content:encoded> <wfw:commentRss>http://pento.net/2010/03/03/stats-for-wordpress-plugins-and-themes-hosted-on-wordpress-org/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> </channel> </rss>
