<?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>Mike Payne &#187; PHP</title>
	<atom:link href="http://mikepayne.co/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://mikepayne.co</link>
	<description>Utah WordPress Developer</description>
	<lastBuildDate>Fri, 26 Apr 2013 15:47:42 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Getting Facebook Comment Count Within WordPress</title>
		<link>http://mikepayne.co/2011/getting-facebook-comment-count/</link>
		<comments>http://mikepayne.co/2011/getting-facebook-comment-count/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 23:27:10 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[Snippet]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WP Dev]]></category>

		<guid isPermaLink="false">http://mikepayne.co/?p=379</guid>
		<description><![CDATA[I&#8217;ve been working with the Facebook Comment integration into WordPress lately. Mostly because it can help cut down on spam, but also because of the grammer checker and social media benefit. I couldn&#8217;t really find a good solution online for pulling the number of comments on any given post, so here is what I ended up with. I included this [...]]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve been working with the Facebook Comment integration into WordPress lately. Mostly because it can help cut down on spam, but also because of the grammer checker and social media benefit. I couldn&#8217;t really find a good solution online for pulling the number of comments on any given post, so here is what I ended up with. I included this in my functions.php file, and just put this: <code>&lt;?php get_fb_comment_count(); ?&gt;</code> in my single.php file where I want the comment number to be displayed.</p>
<pre>function get_fb_comment_count() {
     global $post;
     $url = get_permalink($post-&gt;ID);
     $filecontent = file_get_contents('https://graph.facebook.com/?ids=' . $url);
     $json = json_decode($filecontent);
     $count = $json-&gt;$url-&gt;comments;
     if ($count == 0 || !isset($count)) {
          $count = 'No Comments';
     } elseif ( $count == 1 ) {
          $count = '1 Comment';
     } else {
          $count .= ' Comments';
     }
     echo $count;
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://mikepayne.co/2011/getting-facebook-comment-count/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Don&#8217;t Track Analytics for Admin</title>
		<link>http://mikepayne.co/2011/dont-track-analytics-for-admin/</link>
		<comments>http://mikepayne.co/2011/dont-track-analytics-for-admin/#comments</comments>
		<pubDate>Mon, 10 Oct 2011 17:04:49 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[Snippet]]></category>
		<category><![CDATA[analytics]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WP Dev]]></category>

		<guid isPermaLink="false">http://mikepayne.co/?p=365</guid>
		<description><![CDATA[I often run into situations where I am editing a site, or checking my pages, but do not want to count the time i spend on my own site to count towards my Analytics Tracking.]]></description>
				<content:encoded><![CDATA[<p>I often run into situations where I am editing a site, or checking my pages, but do not want to count the time i spend on my own site to count towards my Analytics Tracking. To fix this, I only display my analytics code when the user is not logged in, or is logged in as someone other than the administrator.</p>
<pre>&lt;?php   
global $user_ID;   
if( $user_ID ){    
 if( !current_user_can('level_10') ){
  //logged in as someone other than admin
  //place analytics
 }
} else {
 //not logged in
 //place analytics
}
?&gt;</pre>
<p>This code checks for a user ID, if it cant find one it displays the tracking code. If there is an ID, then the user is logged in. If the user level is at 10, then it is an administrator and should not show the code. We use the exclamation point (the NOT logical operator) to verify that the user is NOT an admin. As a general rule of thumb, you should not have more than one administrator account on a site.</p>
]]></content:encoded>
			<wfw:commentRss>http://mikepayne.co/2011/dont-track-analytics-for-admin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shortcode to Hide Content from Users that Aren&#8217;t Logged In</title>
		<link>http://mikepayne.co/2011/shortcode-to-hide-content-from-users-that-arent-logged-in/</link>
		<comments>http://mikepayne.co/2011/shortcode-to-hide-content-from-users-that-arent-logged-in/#comments</comments>
		<pubDate>Thu, 29 Sep 2011 15:33:02 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[Snippet]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[publish]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[user roles]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WP Dev]]></category>

		<guid isPermaLink="false">http://mikepayne.co/?p=343</guid>
		<description><![CDATA[A common issue many beginner WordPress users run into is blocking certain content from users that aren't registered or logged in. Here is a short, simple solution in the form of a shortcode.]]></description>
				<content:encoded><![CDATA[<p>A common issue many beginner WordPress users run into is blocking certain content from users that aren&#8217;t registered or logged in. Here is a short, simple solution in the form of a shortcode. Any content between the code block will only be output if the user has registered and logged in to their account.</p>
<p>You can paste this code into your functions.php to gain access to the WordPress shortcode.</p>
<pre>add_shortcode( 'premium', 'mcp_premium_content' );

function mcp_premium_content( $atts, $content = null ) {
 if ( is_user_logged_in() &amp;&amp; !is_null( $content ) &amp;&amp; !is_feed() ){
  return $content;
 } else {
  return '';
 }
}</pre>
<p>And now the following can be put into any post, page, or widgetized area to filter who sees your content.</p>
<pre>[premium]**Any Content Here Can Only Be Viewed
By Registering and Logging In Users**[/premium]</pre>
<p>This can be further refined by filtering by user types, but in this basic example I only checked if they had an account and were logged in.</p>
]]></content:encoded>
			<wfw:commentRss>http://mikepayne.co/2011/shortcode-to-hide-content-from-users-that-arent-logged-in/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Updating WordPress Posts and Pages with Ctrl+S</title>
		<link>http://mikepayne.co/2011/updating-wordpress-posts-and-pages-with-ctrls/</link>
		<comments>http://mikepayne.co/2011/updating-wordpress-posts-and-pages-with-ctrls/#comments</comments>
		<pubDate>Wed, 17 Aug 2011 00:04:17 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[WP Dev]]></category>
		<category><![CDATA[cmd+s]]></category>
		<category><![CDATA[ctrl+s]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[page]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[publish]]></category>
		<category><![CDATA[shortkey]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://mikepayne.co/?p=307</guid>
		<description><![CDATA[I spend a lot of time coding. a lot. So much so, that when I write posts and pages on my WordPress sites and go to save it, I hit Cmd+S.]]></description>
				<content:encoded><![CDATA[<p>I spend a lot of time coding. a lot. So much so, that when I write posts and pages on my WordPress sites and go to save it, I hit Ctrl+S (Cmd+S on Mac), which is the short-key to save in pretty much any program ever made. It can get frustrating to save and have to stop, exit out of the popup window trying to save the website locally, and then hit the Update button. So, this snippet covers how to detect when a page is loaded, output scripts, see when a user presses multiple buttons across operating systems, stop the default reaction from the browser, and finally activate a button.</p>
<p>&nbsp;</p>
<pre>&lt;?php
/*
Plugin Name: Publish WP Post on Cmd/Ctrl + S
Plugin URI: http://www.mikepayne.co/updating-wordpress-posts-with-ctrls
Version: v0.1
Author: &lt;a href="http://www.mikepayne.co/"&gt;Mike Payne&lt;/a&gt;
Description: Publishes posts and pages when Ctrl+S is pressed
*/

function mp_postOnSave(){
  ?&amp;gt;
    &lt;script type="text/javascript"&gt;
      jQuery(window).keypress(function(event) {
        if (!(event.which == 115 &amp;&amp; event.ctrlKey) &amp;&amp; !(event.which == 19)){
          return true;
        }
        jQuery('#publish').click();
        event.preventDefault();
        return false;
      );
    &lt;/script&gt;
  &lt;?php
}
add_action('admin_footer-post.php','mp_postOnSave');
add_action('admin_footer-post-new.php','mp_postOnSave');

?&gt;</pre>
<p>&nbsp;</p>
<p>The function I&#8217;ve put here pretty much just spits out a jQuery function in the footer of the admin panel, but only on &lt;code&gt;post.php&lt;/code&gt; or &lt;code&gt;post-new.php&lt;/code&gt;. This will allow us to access the pages used to either publish or update the page or post. This jQuery function detects when the user presses the Ctrl key along with S(key 115). On a Mac OS, the browser returns cmd+s as key 19, so we can make it cross os by including that as well. If neither of those statements is true, we can return true and allow the key to be presses in it&#8217;s default action. If it&#8217;s false, that means either Ctrl+s or Cmd+s was pressed sp we should click the button with the id of Publish. This will submit the page to be updated or published for the first time.</p>
<p>This isn&#8217;t quite enough though, because the browser will still try to save the webpage. To stop the browsers default action on a JavaScript command, we use the &lt;code&gt;event.preventDefault()&lt;/code&gt; method, and return false.</p>
]]></content:encoded>
			<wfw:commentRss>http://mikepayne.co/2011/updating-wordpress-posts-and-pages-with-ctrls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Preventing Spam: Blocking Comments from No-Referrers</title>
		<link>http://mikepayne.co/2011/blocking-comments-from-no-referrers/</link>
		<comments>http://mikepayne.co/2011/blocking-comments-from-no-referrers/#comments</comments>
		<pubDate>Fri, 29 Jul 2011 20:13:26 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[WP Dev]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[spam]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://mikepayne.co/?p=260</guid>
		<description><![CDATA[Web browsers store a lot of information about how you navigate the internet, and one of those metrics is called a referrer. A referrer is the page that you were on before the page you are currently on. By checking this browser option we can eliminate quite a few of our spammy comments from bots that crawl the internet and post [...]]]></description>
				<content:encoded><![CDATA[<p>Web browsers store a lot of information about how you navigate the internet, and one of those metrics is called a referrer. A referrer is the page that you were on before the page you are currently on. By checking this browser option we can eliminate quite a few of our spammy comments from bots that crawl the internet and post links to certain &#8216;medical solutions&#8217;.  Bellow is another WordPress PHP Snippet that you can post into your functions.php and will check whether a referrer exists or not.<span id="more-260"></span></p>
<p><code><br />
&lt;?php<br />
/*<br />
Plugin Name: Block No-Referrer Comments<br />
Plugin URI: http://www.MikePayne.co/blocking-comments-from-no-referrers<br />
Version: v0.1<br />
Author: <a href="http://www.mikepayne.co/">Mike Payne</a><br />
Description: Block comments from spambots with no referring metric.<br />
*/<br />
function block_no_referrer() {<br />
if (!isset($_SERVER['HTTP_REFERER']) || $_SERVER['HTTP_REFERER'] == “”) :<br />
wp_die( __('To maintain a high quality on this blog, and to actively stop internet spamming, this feature has been removed on your browser. You may turn this feature on by enabling referrers on your browser.') );<br />
endif;<br />
}<br />
add_action(‘check_comment_flood’, ‘block_no_referrer’);<br />
?&gt;<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://mikepayne.co/2011/blocking-comments-from-no-referrers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding Social Media Contact Info to WordPress User Profiles</title>
		<link>http://mikepayne.co/2011/adding-social-media-contact-info-to-wordpress-user-profiles/</link>
		<comments>http://mikepayne.co/2011/adding-social-media-contact-info-to-wordpress-user-profiles/#comments</comments>
		<pubDate>Tue, 19 Jul 2011 19:44:38 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[WP Dev]]></category>
		<category><![CDATA[Contact Info]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[User Profiles]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://mikepayne.co/?p=200</guid>
		<description><![CDATA[Wordpress has been around for a few years now, and a lot can change in just a few years. Especially when the internet is involved. The User Profiles functionality was developed in it's early days, and the contact info fields were relevant ways to contact users..then. Yahoo IM, AIM, and Jabber..? No one uses those!]]></description>
				<content:encoded><![CDATA[<p>WordPress has been around for a few years now, and a lot can change in just a few years. Especially when the internet is involved. The User Profiles functionality was developed in it&#8217;s early days, and the contact info fields were relevant ways to contact users..then. Yahoo IM, AIM, and Jabber..? No one uses those! In this snippet I&#8217;ll show you how you can replace those outdated contact links with more recent Social Media connections like Facebook links, Twitter urls, and Google+ profile pages.</p>
<p>This snippet consists of a function and a filter, which can be put into the functions.php file. However, I&#8217;ve written it as a plugin that you can install and activate as well.</p>
<p><code><br />
<!--?php <br ?--> &lt;?php<br />
/*<br />
Plugin Name: User Profile Social Media Links<br />
Plugin URI: http://mikepayne.co/adding-social-media-contact-info-to-wordpress-user-profiles<br />
Description: This snippet allows you to replace the WordPress User Profile contact info links with your own, current, social media profile links.<br />
Version: 0.1<br />
Author: Mike Payne<br />
Author URI: http://mikepayne.co<br />
*/<br />
function replace_profile_contact_info($contactmethods) {<br />
unset($contactmethods['aim']);<br />
unset($contactmethods['yim']);<br />
unset($contactmethods['jabber']);<br />
$contactmethods['twitter'] = 'Twitter';<br />
$contactmethods['facebook'] = 'Facebook';<br />
$contactmethods['linkedin'] = 'LinkedIn';<br />
$contactmethods['gplus'] = 'Google+';<br />
}<br />
add_filter('user_contactmethods', 'replace_profile_contact_info');<br />
?&gt;<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://mikepayne.co/2011/adding-social-media-contact-info-to-wordpress-user-profiles/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Whitelable WordPress Login Logo</title>
		<link>http://mikepayne.co/2011/whitelable-logo/</link>
		<comments>http://mikepayne.co/2011/whitelable-logo/#comments</comments>
		<pubDate>Mon, 18 Jul 2011 22:58:12 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[WP Dev]]></category>
		<category><![CDATA[branding]]></category>
		<category><![CDATA[Developer]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[whitelable]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://mikepayne.co/?p=175</guid>
		<description><![CDATA[This php snippet will allow you to replace the default Wordpress logo with your own, and increases the brand strength on the site. ]]></description>
				<content:encoded><![CDATA[<p>This php snippet will allow you to replace the default WordPress logo with your own, and increases the brand strength on the site. I&#8217;ve written it as a plugin that can be activated and deactivated, but you could also move the function and action into your functions.php file to achieve the same thing. Make sure you replace the image location with that of your own image.</p>
<p><code><br />
<!--?php <br ?--> &lt;?php<br />
/*<br />
Plugin Name: Whitelabel Logo<br />
Plugin URI: http://mikepayne.co/whitelable-logo<br />
Description: This snippet allows you to replace the WordPress Admin login logo with your own. Just replace the location with your own.<br />
Version: 0.1<br />
Author: Mike Payne<br />
Author URI: http://mikepayne.co<br />
*/<br />
function whitelable_logo() {<br />
echo '&lt;style type="text/css"&gt;<br />
h1 a { background-image:url("'.get_bloginfo('template_directory').'/assets/images/logo.png") !important; }<br />
&lt;/style&gt;';<br />
}<br />
add_action('login_head', 'whitelable_logo');<br />
?&gt;</code></p>
]]></content:encoded>
			<wfw:commentRss>http://mikepayne.co/2011/whitelable-logo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Remove Unwanted Header Elements in WordPress</title>
		<link>http://mikepayne.co/2011/remove-unwanted-wordpress-header-elements/</link>
		<comments>http://mikepayne.co/2011/remove-unwanted-wordpress-header-elements/#comments</comments>
		<pubDate>Sat, 16 Jul 2011 06:12:21 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[WP Dev]]></category>
		<category><![CDATA[Header Elements]]></category>
		<category><![CDATA[Non-Destructive]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://mikepayne.co/?p=138</guid>
		<description><![CDATA[I've been working with some freelance clients lately who get very picky with source code. They didn't want some of Wordpress's default tags to be displayed in the header of every file. I'm sure I'm not alone, and there are people out there looking for a good solution to this without having to hack into Wordpress's core files and risk losing any edits with every update. Below is the code to remove some basic tags that Wordpress automatically generates.]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve been working with some freelance clients lately who get very picky with source code. They didn&#8217;t want some of WordPress&#8217;s default tags to be displayed in the header of every file. I&#8217;m sure I&#8217;m not alone, and there are people out there looking for a good solution to this without having to hack into WordPress&#8217;s core files and risk losing any edits with every update. Below is the code to remove some basic tags that WordPress automatically generates.</p>
<p><code>//Wordpress Generator Tag<br />
//Removing to maintain security, will no longer show that wordpress is used, or version numberremove_action('wp_head', 'wp_generator');<br />
</code></p>
<p><code>//Really Simple Discovery<br />
//Not used by most people, takes out the EditURI meta tag in header<br />
remove_action('wp_head', 'rsd_link');</code></p>
<p><code><br />
//Windows Live Writer<br />
//Only used for remote Publishing with Microsoft Products<br />
remove_action('wp_head', 'wlwmanifest_link');<br />
</code></p>
<p><code><br />
//Post Relational Links<br />
//removing this helps keep some private posts from being crawled by search engines<br />
remove_action('wp_head', 'start_post_rel_link', 10, 0 );<br />
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);</code></p>
<p>Let me know if I missed any,or if you need any other snippets</p>
]]></content:encoded>
			<wfw:commentRss>http://mikepayne.co/2011/remove-unwanted-wordpress-header-elements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
