<?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>HTMLCenter Web Development Blog &#187; PHP Tutorials</title>
	<atom:link href="http://www.htmlcenter.com/blog/category/php-tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.htmlcenter.com</link>
	<description>Web Development Help and Tutorials</description>
	<lastBuildDate>Sat, 04 Feb 2012 02:56:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Zeus and WordPress Part 3: SSL Issues</title>
		<link>http://www.htmlcenter.com/blog/zeus-and-wordpress-part-3/</link>
		<comments>http://www.htmlcenter.com/blog/zeus-and-wordpress-part-3/#comments</comments>
		<pubDate>Sat, 04 Feb 2012 02:56:03 +0000</pubDate>
		<dc:creator>Curtiss</dc:creator>
				<category><![CDATA[PHP Tutorials]]></category>

		<guid isPermaLink="false">http://www.htmlcenter.com/?p=2283</guid>
		<description><![CDATA[While working to get WordPress functioning properly on a Zeus Web server, one of the issues I came across was the fact that I couldn&#8217;t seem to get any SSL functions working properly. I tried 2 or 3 different plugins, and all of them started causing infinite redirect loops as soon as they were activated. [...]
Related posts:<ol>
<li><a href='http://www.htmlcenter.com/blog/zeus-and-wordpress-part-2/' rel='bookmark' title='Zeus and WordPress Part 2: Fixing Query Strings'>Zeus and WordPress Part 2: Fixing Query Strings</a></li>
<li><a href='http://www.htmlcenter.com/blog/wordpress-and-zeus-part-1-getting-permalinks-working/' rel='bookmark' title='WordPress and Zeus Part 1: Getting Permalinks Working'>WordPress and Zeus Part 1: Getting Permalinks Working</a></li>
<li><a href='http://www.htmlcenter.com/blog/php-framework-mvc/' rel='bookmark' title='Programming your own PHP framework Part 2 &#8211; MVC'>Programming your own PHP framework Part 2 &#8211; MVC</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>While working to get WordPress functioning properly on a Zeus Web server, one of the issues I came across was the fact that I couldn&#8217;t seem to get any SSL functions working properly. I tried 2 or 3 different plugins, and all of them started causing infinite redirect loops as soon as they were activated.</p>
<p>Eventually, after quite a bit of investigating and testing, I found the cause of the issue: that particular server (and, presumably, all Zeus servers) doesn&#8217;t use any of the same indicators that SSL is being used that apache does. On apache servers, PHP usually has a handful of indicators that SSL is currently being used to serve the page. For instance, there&#8217;s a server global variable called &#8220;HTTPS&#8221; that gets set to &#8220;on&#8221; for many PHP configurations; SSL is generally served over port 443 instead of port 80; etc.<span id="more-2283"></span></p>
<p>The WordPress HTTPS plugin runs four different checks to see if SSL is running, but all of them fail on Zeus. Following is the check that WordPress HTTPS runs:</p>
<pre style="width: 96%; margin: 1%; padding: 1%; overflow-x: auto;">public function is_ssl() {
    $https_url = parse_url($this-&gt;https_url);
    // Some extra checks for proxies and Shared SSL
    if ( is_ssl() &amp;&amp; strpos($_SERVER['HTTP_HOST'], $https_url['host']) === false &amp;&amp; $_SERVER['SERVER_ADDR'] != $_SERVER['HTTP_HOST'] ) {
        return false;
    } else if ( isset($_SERVER['HTTP_X_FORWARDED_PROTO']) &amp;&amp; strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https' ) {
        return true;
    } else if ( $this-&gt;diff_host &amp;&amp; !is_ssl() &amp;&amp; isset($_SERVER['HTTP_X_FORWARDED_SERVER']) &amp;&amp; strpos($this-&gt;https_url, 'https://' . $_SERVER['HTTP_X_FORWARDED_SERVER']) !== false ) {
        return true;
    } else if ( $this-&gt;diff_host &amp;&amp; !is_ssl() &amp;&amp; strpos($_SERVER['HTTP_HOST'], $https_url['host']) !== false &amp;&amp; (!$this-&gt;ssl_port || $_SERVER['SERVER_PORT'] == $this-&gt;ssl_port) &amp;&amp; (isset($https_url['path']) &amp;&amp; !$https_url['path'] || strpos($_SERVER['REQUEST_URI'], $https_url['path']) !== false) ) {
        return true;
    }
    return is_ssl();
}</pre>
<p>Like I said, at least on the Zeus server I was dealing with, all four of those checks failed, so it kept reporting that the page wasn&#8217;t running over SSL, so it caused an infinite redirect loop.</p>
<p>After a while, I did find a variable (actually, 3 of them) that, while it doesn&#8217;t seem to have any consistent value, always seems to be set when running SSL, and never seems to exist when running without SSL. That variable is the $_SERVER['HTTP_SSLCLIENTCERTSTATUS'] variable. Checking for the existence of that variable seems to consistently report whether or not SSL is running for the page.</p>
<p>For my purposes, I ended up editing a plugin called WPSSL (simply because it was simpler than making sure I&#8217;d edited all of the correct places within WordPress HTTPS) to check the existence of that variable.</p>
<p>Have you come across this same issue on a Zeus server? Is this common, or is this an issue unique to the particular host that&#8217;s being used for this project?</p>
<p>Related posts:<ol>
<li><a href='http://www.htmlcenter.com/blog/zeus-and-wordpress-part-2/' rel='bookmark' title='Zeus and WordPress Part 2: Fixing Query Strings'>Zeus and WordPress Part 2: Fixing Query Strings</a></li>
<li><a href='http://www.htmlcenter.com/blog/wordpress-and-zeus-part-1-getting-permalinks-working/' rel='bookmark' title='WordPress and Zeus Part 1: Getting Permalinks Working'>WordPress and Zeus Part 1: Getting Permalinks Working</a></li>
<li><a href='http://www.htmlcenter.com/blog/php-framework-mvc/' rel='bookmark' title='Programming your own PHP framework Part 2 &#8211; MVC'>Programming your own PHP framework Part 2 &#8211; MVC</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.htmlcenter.com/blog/zeus-and-wordpress-part-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zeus and WordPress Part 2: Fixing Query Strings</title>
		<link>http://www.htmlcenter.com/blog/zeus-and-wordpress-part-2/</link>
		<comments>http://www.htmlcenter.com/blog/zeus-and-wordpress-part-2/#comments</comments>
		<pubDate>Sat, 28 Jan 2012 02:44:51 +0000</pubDate>
		<dc:creator>Curtiss</dc:creator>
				<category><![CDATA[PHP Tutorials]]></category>

		<guid isPermaLink="false">http://www.htmlcenter.com/?p=2279</guid>
		<description><![CDATA[If you&#8217;re trying to get WordPress working on a Zeus Web server, and you&#8217;ve gotten as far as using a good rewrite script to make permalinks work properly, you might have noticed that query strings don&#8217;t work at the ends of your permalinks. At first, it seemed like this wouldn&#8217;t be too big of an [...]
Related posts:<ol>
<li><a href='http://www.htmlcenter.com/blog/wordpress-and-zeus-part-1-getting-permalinks-working/' rel='bookmark' title='WordPress and Zeus Part 1: Getting Permalinks Working'>WordPress and Zeus Part 1: Getting Permalinks Working</a></li>
<li><a href='http://www.htmlcenter.com/blog/wordpress-multi-site-get-a-featured-image-from-another-blog/' rel='bookmark' title='WordPress Multi-Site: Get Featured Image from Another Blog'>WordPress Multi-Site: Get Featured Image from Another Blog</a></li>
<li><a href='http://www.htmlcenter.com/blog/order-wordpress-pages-by-multiple-fields/' rel='bookmark' title='Order WordPress Pages By Multiple Fields'>Order WordPress Pages By Multiple Fields</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re trying to get WordPress working on a Zeus Web server, and you&#8217;ve gotten as far as using a good rewrite script to make permalinks work properly, you might have noticed that query strings don&#8217;t work at the ends of your permalinks. At first, it seemed like this wouldn&#8217;t be too big of an issue; it just meant that users wouldn&#8217;t be able to preview posts/pages, and there would be one or two other issues they&#8217;d have to live with. However, after using the site that way for a little while, we started coming across more and more issues that this caused, and it finally reached a tipping point.</p>
<p>To solve the issue, I wrote a simple function that runs any time a 404 error occurs on the site. Essentially, it parses the path of the requested page, cuts off the query string temporarily, and then searches the database for a post or page that has the slug at the end of the path.</p>
<p>You may be wondering why I didn&#8217;t just parse the request/get variables sent with the page. The problem is, those were empty in each of the cases I tested.<span id="more-2279"></span></p>
<p>Anyway, following is the function I ended up writing.</p>
<pre style="width: 96%; margin: 1%; padding: 1%; overflow-x: auto;">function zeus_reply_fix() {
	if ( ! isset( $_SERVER['PATH_INFO'] ) ) {
		return;
	}
	if ( ! is_404() ) {
		return;
	}

	$path = $_SERVER['PATH_INFO'];
	$parts = explode( '/', $path );
	$qs = array_pop( $parts );
	$parsed = array();
	if ( strstr( $qs, '&amp;' ) || strstr( $qs, '?' ) ) {
		parse_str( $qs, $parsed );
	} else {
		return;
	}
	if ( is_array( $parsed ) ) {
		global $wpdb, $post, $wp_query;
		$post_ID = $wpdb-&gt;get_var( $wpdb-&gt;prepare( "SELECT ID FROM {$wpdb-&gt;posts} WHERE post_name=%s", array_pop( $parts ) ) );

		if ( empty( $post_ID ) ) {
			return;
		}

		$wp_query = new WP_Query( array( 'page_id' =&gt; $post_ID ) );
		$wp_query-&gt;is_404 = false;
		foreach ( $parsed as $k=&gt;$v ) {
			if ( ! empty( $k ) &amp;&amp; ! empty( $v ) )
				set_query_var( $k, $v );
		}

		$_GET = $_GET + $parsed;

		$use_template = 'index.php';
		$post = $wp_query-&gt;get_queried_object();

		load_template( trailingslashit( get_template_directory() ) . $use_template );
		die();
	}
}
add_action( 'wp', 'zeus_reply_fix', 99 );</pre>
<p>Have you found a better way of dealing with this issue? Do you see anything that could be done better? I&#8217;d love to see other solutions to this particular problem with Zeus &amp; WordPress.</p>
<p>Related posts:<ol>
<li><a href='http://www.htmlcenter.com/blog/wordpress-and-zeus-part-1-getting-permalinks-working/' rel='bookmark' title='WordPress and Zeus Part 1: Getting Permalinks Working'>WordPress and Zeus Part 1: Getting Permalinks Working</a></li>
<li><a href='http://www.htmlcenter.com/blog/wordpress-multi-site-get-a-featured-image-from-another-blog/' rel='bookmark' title='WordPress Multi-Site: Get Featured Image from Another Blog'>WordPress Multi-Site: Get Featured Image from Another Blog</a></li>
<li><a href='http://www.htmlcenter.com/blog/order-wordpress-pages-by-multiple-fields/' rel='bookmark' title='Order WordPress Pages By Multiple Fields'>Order WordPress Pages By Multiple Fields</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.htmlcenter.com/blog/zeus-and-wordpress-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress and Zeus Part 1: Getting Permalinks Working</title>
		<link>http://www.htmlcenter.com/blog/wordpress-and-zeus-part-1-getting-permalinks-working/</link>
		<comments>http://www.htmlcenter.com/blog/wordpress-and-zeus-part-1-getting-permalinks-working/#comments</comments>
		<pubDate>Sat, 21 Jan 2012 02:31:00 +0000</pubDate>
		<dc:creator>Curtiss</dc:creator>
				<category><![CDATA[PHP Tutorials]]></category>

		<guid isPermaLink="false">http://www.htmlcenter.com/?p=2275</guid>
		<description><![CDATA[For those of you that might not know (and I was one of you about a month ago), Zeus is a Web server package that&#8217;s used instead of apache by some Web hosts. If you&#8217;re planning to use WordPress, and you have a choice between apache and Zeus, I would definitely recommend choosing apache. However, [...]
Related posts:<ol>
<li><a href='http://www.htmlcenter.com/blog/wordpress-creating-custom-permalinks-for-plug-ins/' rel='bookmark' title='WordPress: Creating Custom Permalinks for Plug-Ins'>WordPress: Creating Custom Permalinks for Plug-Ins</a></li>
<li><a href='http://www.htmlcenter.com/blog/installing-wordpress-through-ssh/' rel='bookmark' title='Installing WordPress Through SSH'>Installing WordPress Through SSH</a></li>
<li><a href='http://www.htmlcenter.com/blog/my-first-official-wordpress-plugin/' rel='bookmark' title='My First Official WordPress Plugin'>My First Official WordPress Plugin</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>For those of you that might not know (and I was one of you about a month ago), <a href="http://en.wikipedia.org/wiki/Zeus_Web_Server">Zeus is a Web server package</a> that&#8217;s used instead of apache by some Web hosts. If you&#8217;re planning to use WordPress, and you have a choice between apache and Zeus, I would definitely recommend choosing apache. However, sometimes you don&#8217;t have a choice in the matter; and you have to do what you can to make things work.</p>
<p>WordPress will work out of the box with Zeus, but a lot of things won&#8217;t behave the way you might expect. One of those things is the permalink structure.</p>
<p>Instead of getting nice, clean URLs like &#8220;http://example.com/blog/2012/01/my-first-blog-post/&#8221;, you get &#8220;index.php&#8221; shoved in there (like &#8220;http://example.com/index.php/blog/2012/01/my-first-blog-post/&#8221;). You can correct this issue, but it&#8217;s not quite as simple as updating an .htaccess file (in fact, without some jiggery-pokery by your Web host, Zeus doesn&#8217;t support .htaccess at all). Instead, you have to apply a rewrite script to your server configuration.</p>
<p>After quite a bit of searching and trial &amp; error, I finally found a working rewrite script configuration for WordPress. A hosting company called <a href="http://support.ziphosting.com.au/index.php?_m=knowledgebase&amp;_a=viewarticle&amp;kbarticleid=205">ZipHosting posted the scripts below in their knowledgebase</a>. The first script is set up for you to use if WordPress is hosted in a subdirectory, and the second is for use with WordPress in the root directory.<span id="more-2275"></span></p>
<h2>WordPress in a Subdirectory</h2>
<pre style="width: 96%; margin: 1%; padding: 1%; overflow-x: auto;">RULE_0_START:
    # Get the document root path and put value into the SCRATCH array.
    # This is the server path not the web URL.
    # i.e. /clientdata/clients/p/h/php.testing.au.com/www/

map path into SCRATCH:DOCROOT from /

    # Get the URL without the domain.
    # e.g. /test&amp;colour=red
    # e.g. /an-example-post/?color=red

 set SCRATCH:ORIG_URL = %{URL}
 set SCRATCH:REQUEST_URI = %{URL}

    # See if there are any queries in our URL.

 match URL into $ with ^(.*)\?(.*)$

    # If there are...

 if matched then
    # Set a var to path without the domain part.
    # e.g. /an-example-post

     set SCRATCH:REQUEST_URI = $1

    # Set a var to the passed queries.
    # e.g. colour=red

     set SCRATCH:QUERY_STRING = $2
 endif
 RULE_0_END:

RULE_1_START:
    # This is setting a var to the server path and sub folders.
    # e.g. /clientdata/clients/p/h/php.testing.au.com/www/wordpress/an-example-post/

 set SCRATCH:REQUEST_FILENAME = %{SCRATCH:DOCROOT}
 set SCRATCH:REQUEST_FILENAME . %{SCRATCH:REQUEST_URI}

    # Check to see if the file exists.

 look for file at %{SCRATCH:REQUEST_FILENAME}
 if not exists then

    # The file wasn't found so is it a folder?

     look for dir at %{SCRATCH:REQUEST_FILENAME}
     if not exists then

    # No folder either. So now check the URL for special hosting folders.

         match SCRATCH:ORIG_URL into % with ^/stats|^/logs
         if matched then

    # If a special folder was requested end the script.

             goto END
         else

    # There were no files, folders or special folders so set the new URL.
    # -- Sub directory -------------------------------------------------------------
    # If the blog is in a sub directory...replace the words in bold  with your directory name.
    # e.g. /wordpress/index.php/an-example-post

             match SCRATCH:REQUEST_URI into $ with ^/wordpress(.*)
             if matched then
                 set URL = /wordpress/index.php$1
             endif

    # -- Sub directory ends --------------------------------------------------------
    # or...
    # -- Top level -----------------------------------------------------------------
    # If the blog is in the top level of the site...
    # e.g. /index.php/an-example-post
    # set URL = /index.php%{SCRATCH:REQUEST_URI}
    # -- Top level ends ------------------------------------------------------------
    # Go to the next rule.

             goto RULE_2_START
         endif
     endif
 endif

    # If files or folders were found end the rewrite script.

 goto END
 RULE_1_END:

RULE_2_START:

    # Check for queries in the requested URL.

 match SCRATCH:ORIG_URL into % with \?(.*)$
 if matched then

    # If queries were found add them to the new URL.
    # e.g. /index.php/an-example-post/&amp;colour=red

     set URL = %{URL}&amp;%{SCRATCH:QUERY_STRING}

 endif

    # -- Sub directory -------------------------------------------------------------
    # If you only want to rewrite the sub directory uncomment this bit.
      match SCRATCH:ORIG_URL into % with ^/wordpress
 if matched then
    # -- Sub directory ends --------------------------------------------------------

    # End the script.

     goto END

    # -- Sub directory -------------------------------------------------------------
 endif
    # -- Sub directory ends --------------------------------------------------------
 RULE_2_END:</pre>
<h2>WordPress Installed in the Root Directory</h2>
<pre style="width: 96%; margin: 1%; padding: 1%; overflow-x: auto;">RULE_0_START:
    # Get the document root path and put value into the SCRATCH array.
    # This is the server path not the web URL.
    # i.e. /clientdata/clients/p/h/php.testing.au.com/www/

map path into SCRATCH:DOCROOT from /

    # Get the URL without the domain.
    # e.g. /test&amp;colour=red
    # e.g. /an-example-post/?color=red

 set SCRATCH:ORIG_URL = %{URL}
 set SCRATCH:REQUEST_URI = %{URL}

    # See if there are any queries in our URL.

 match URL into $ with ^(.*)\?(.*)$

    # If there are...

 if matched then
    # Set a var to path without the domain part.
    # e.g. /an-example-post

     set SCRATCH:REQUEST_URI = $1

    # Set a var to the passed queries.
    # e.g. colour=red

     set SCRATCH:QUERY_STRING = $2
 endif
 RULE_0_END:

RULE_1_START:
    # This is setting a var to the server path and sub folders.
    # e.g. /clientdata/clients/p/h/php.testing.au.com/www/wordpress/an-example-post/

 set SCRATCH:REQUEST_FILENAME = %{SCRATCH:DOCROOT}
 set SCRATCH:REQUEST_FILENAME . %{SCRATCH:REQUEST_URI}

    # Check to see if the file exists.

 look for file at %{SCRATCH:REQUEST_FILENAME}
 if not exists then

    # The file wasn't found so is it a folder?

     look for dir at %{SCRATCH:REQUEST_FILENAME}
     if not exists then

    # No folder either. So now check the URL for special hosting folders.

         match SCRATCH:ORIG_URL into % with ^/stats|^/logs
         if matched then

    # If a special folder was requested end the script.

             goto END
         else

    # There were no files, folders or special folders so set the new URL.
    # -- Sub directory -------------------------------------------------------------
    # If the blog is in a sub directory...replace the words in bold  with your directory name.
    # e.g. /wordpress/index.php/an-example-post

    # match SCRATCH:REQUEST_URI into $ with ^/wordpress(.*)
    # if matched then
    #     set URL = /wordpress/index.php$1
    # endif

    # -- Sub directory ends --------------------------------------------------------
    # or...
    # -- Top level -----------------------------------------------------------------
    # If the blog is in the top level of the site...
    # e.g. /index.php/an-example-post
     set URL = /index.php%{SCRATCH:REQUEST_URI}
    # -- Top level ends ------------------------------------------------------------
    # Go to the next rule.

             goto RULE_2_START
         endif
     endif
 endif

    # If files or folders were found end the rewrite script.

 goto END
 RULE_1_END:

RULE_2_START:

    # Check for queries in the requested URL.

 match SCRATCH:ORIG_URL into % with \?(.*)$
 if matched then

    # If queries were found add them to the new URL.
    # e.g. /index.php/an-example-post/&amp;colour=red

     set URL = %{URL}&amp;%{SCRATCH:QUERY_STRING}

 endif

    # -- Sub directory -------------------------------------------------------------
     # If you only want to rewrite the sub directory uncomment this bit.
    # match SCRATCH:ORIG_URL into % with ^/wordpress
 if matched then
    # -- Sub directory ends --------------------------------------------------------

    # End the script.

     goto END

    # -- Sub directory -------------------------------------------------------------
 endif
    # -- Sub directory ends --------------------------------------------------------
 RULE_2_END:</pre>
<p>Unfortunately, that won&#8217;t solve all of your permalink issues, but it will get you started. One serious issue you might encounter is the fact that query strings aren&#8217;t recognized at the end of your permalinks; instead, WordPress shows a 404 error page whenever a query string is attached. In my next article, I&#8217;ll explain how I fixed that issue.</p>
<p>Related posts:<ol>
<li><a href='http://www.htmlcenter.com/blog/wordpress-creating-custom-permalinks-for-plug-ins/' rel='bookmark' title='WordPress: Creating Custom Permalinks for Plug-Ins'>WordPress: Creating Custom Permalinks for Plug-Ins</a></li>
<li><a href='http://www.htmlcenter.com/blog/installing-wordpress-through-ssh/' rel='bookmark' title='Installing WordPress Through SSH'>Installing WordPress Through SSH</a></li>
<li><a href='http://www.htmlcenter.com/blog/my-first-official-wordpress-plugin/' rel='bookmark' title='My First Official WordPress Plugin'>My First Official WordPress Plugin</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.htmlcenter.com/blog/wordpress-and-zeus-part-1-getting-permalinks-working/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upcoming Panel on The Future of PHP</title>
		<link>http://www.htmlcenter.com/blog/upcoming-panel-on-the-future-of-php/</link>
		<comments>http://www.htmlcenter.com/blog/upcoming-panel-on-the-future-of-php/#comments</comments>
		<pubDate>Thu, 10 Nov 2011 00:32:34 +0000</pubDate>
		<dc:creator>Allen</dc:creator>
				<category><![CDATA[PHP Tutorials]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.htmlcenter.com/?p=2256</guid>
		<description><![CDATA[On November 17, Engine Yard will host a discussion around the future of PHP. Engine Yard describes the event, &#8220;If you are a PHP developer using PEAR and Pyrus, we invite you to join us this week as we explore the future of PEAR and Pyrus. We&#8217;ll be discussing issues such as where PEAR/Pyrus will [...]
Related posts:<ol>
<li><a href='http://www.htmlcenter.com/blog/calculating-future-dates-with-php/' rel='bookmark' title='Calculating Future Dates with PHP'>Calculating Future Dates with PHP</a></li>
<li><a href='http://www.htmlcenter.com/blog/search-engine-marketing-strategies-panel-recap/' rel='bookmark' title='Search Engine Marketing Strategies &#8211; Panel Recap'>Search Engine Marketing Strategies &#8211; Panel Recap</a></li>
<li><a href='http://www.htmlcenter.com/blog/customizing-html_quickform/' rel='bookmark' title='Customizing HTML_QuickForm'>Customizing HTML_QuickForm</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>On November 17, Engine Yard will <a href="http://pages.engineyard.com/FutureofPHPPEARPyrus.html">host a discussion</a> around the future of PHP. Engine Yard describes the event, &#8220;If you are a PHP developer using PEAR and Pyrus, we invite you to join us this week as we explore the future of PEAR and Pyrus. We&#8217;ll be discussing issues such as where PEAR/Pyrus will be going in the next few years, what obstacles may be on the horizon, and how they&#8217;re going to get where they&#8217;re going.&#8221;</p>
<p>One of the panelists is Till Klampäckel who many of you know as one of the people who worked with HTMLCenter for many years. Till also just published a book (in German) about the database service CouchDB which you can <a href="http://www.amazon.de/CouchDB-Praxisbuch-Entwickler-Administratoren-Computing/dp/3836216701">purchase on Amazon.de</a>.</p>
<p>The panel is free, will be streamed live and the panel will take questions via Twitter. If you are interested, you can <a href="http://pages.engineyard.com/FutureofPHPPEARPyrus.html">register for the event here</a>.</p>
<p>Related posts:<ol>
<li><a href='http://www.htmlcenter.com/blog/calculating-future-dates-with-php/' rel='bookmark' title='Calculating Future Dates with PHP'>Calculating Future Dates with PHP</a></li>
<li><a href='http://www.htmlcenter.com/blog/search-engine-marketing-strategies-panel-recap/' rel='bookmark' title='Search Engine Marketing Strategies &#8211; Panel Recap'>Search Engine Marketing Strategies &#8211; Panel Recap</a></li>
<li><a href='http://www.htmlcenter.com/blog/customizing-html_quickform/' rel='bookmark' title='Customizing HTML_QuickForm'>Customizing HTML_QuickForm</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.htmlcenter.com/blog/upcoming-panel-on-the-future-of-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress: A Tip About WP Super Cache</title>
		<link>http://www.htmlcenter.com/blog/wordpress-a-tip-about-wp-super-cache/</link>
		<comments>http://www.htmlcenter.com/blog/wordpress-a-tip-about-wp-super-cache/#comments</comments>
		<pubDate>Wed, 12 Oct 2011 19:11:30 +0000</pubDate>
		<dc:creator>Curtiss</dc:creator>
				<category><![CDATA[PHP Tutorials]]></category>
		<category><![CDATA[get]]></category>
		<category><![CDATA[google search]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wp super cache]]></category>

		<guid isPermaLink="false">http://www.htmlcenter.com/?p=2240</guid>
		<description><![CDATA[First of all, let me apologize for having been so absent over the last few weeks. As you may or may not have heard already, we just launched the new website at University of Mary Washington, and things have been hectic trying to put the final pieces into place. One of those final pieces was [...]
Related posts:<ol>
<li><a href='http://www.htmlcenter.com/blog/writing-dependent-wordpress-plug-ins/' rel='bookmark' title='Writing Dependent WordPress Plug-Ins'>Writing Dependent WordPress Plug-Ins</a></li>
<li><a href='http://www.htmlcenter.com/blog/whats-new-with-wordpress-3-1/' rel='bookmark' title='What&#8217;s New With WordPress 3.1?'>What&#8217;s New With WordPress 3.1?</a></li>
<li><a href='http://www.htmlcenter.com/blog/wordpress-storing-temporary-information/' rel='bookmark' title='WordPress: Storing Temporary Information'>WordPress: Storing Temporary Information</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>First of all, let me apologize for having been so absent over the last few weeks. As you may or may not have heard already, we just <a href="http://ten-321.com/blog/portfolio/university-of-mary-washington/">launched the new website at University of Mary Washington</a>, and things have been hectic trying to put the final pieces into place.</p>
<p>One of those final pieces was to get <a href="http://wordpress.org/extend/plugins/wp-super-cache/">WP Super Cache</a> up and running on the site, in order to keep our server from overloading. When we first launched, I didn&#8217;t realize that we didn&#8217;t have the plugin configured properly, and our various plugins and theme functions really started to drag things to a crawl.</p>
<p>After doing a lot of digging and debugging, I found that WP Super Cache was ignoring cached files throughout our server because they all included GET variables.<span id="more-2240"></span></p>
<p>The next step was to find out what GET variable(s) was/were causing the problem, so I headed on over to our development server and threw in some debug code to output the contents of $_GET in the footer of every page. It turned out that the code I&#8217;d created to implement the Google Custom Search Engine on our site was setting a default choice for which search engine to use, and was setting that default choice as a GET var. I fixed that minor issue and WP Super Cache started working like a champ.</p>
<p>Within Google&#8217;s Webmaster Tools, I ran a test on the production server to see how long it took Google to retrieve our home page before and after I made this tiny little change. Before (when pages were not being cached properly), it took approximately 4,400 milliseconds (that&#8217;s over 4 seconds) for Google to retrieve the home page. After the change (with pages being cached properly now), it took 97 milliseconds to retrieve the page (that&#8217;s less than one-tenth of a second). That&#8217;s a ~98% reduction in the amount of time it takes to serve the pages.</p>
<h2>Conclusion</h2>
<p>So, if you&#8217;re using WP Super Cache on your WordPress site, you should do the following things:</p>
<ol>
<li>Use the Cache Tester that&#8217;s built into the &#8220;Simple&#8221; tab on the WP Super Cache options page to make sure your page is being cached properly.</li>
<li>If you find that it&#8217;s not, enable the Debug option (in the &#8220;Debug&#8221; tab on the WP Super Cache options page) to see if you can find out why it&#8217;s not being cached.</li>
<li>If you see anything about WP Super Cache exiting because of a GET variable, use a script to dump your $_GET array into your pages somewhere (I hooked into the wp_print_footer_scripts action, since that way I could make sure I&#8217;d already run through just about everything there was to run through), and see what turns up. Hopefully you&#8217;ll recognize the GET var that&#8217;s being set, and be able to figure out where to change it.</li>
</ol>
<div>Also, since we&#8217;re using Analytics to track cross-domain requests, I made some changes to the way those requests are tracked; but I will post about that in another post.</div>
<p>Related posts:<ol>
<li><a href='http://www.htmlcenter.com/blog/writing-dependent-wordpress-plug-ins/' rel='bookmark' title='Writing Dependent WordPress Plug-Ins'>Writing Dependent WordPress Plug-Ins</a></li>
<li><a href='http://www.htmlcenter.com/blog/whats-new-with-wordpress-3-1/' rel='bookmark' title='What&#8217;s New With WordPress 3.1?'>What&#8217;s New With WordPress 3.1?</a></li>
<li><a href='http://www.htmlcenter.com/blog/wordpress-storing-temporary-information/' rel='bookmark' title='WordPress: Storing Temporary Information'>WordPress: Storing Temporary Information</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.htmlcenter.com/blog/wordpress-a-tip-about-wp-super-cache/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up WordPress MU Domain Mapping on GoDaddy</title>
		<link>http://www.htmlcenter.com/blog/setting-up-wordpress-mu-domain-mapping-on-godaddy/</link>
		<comments>http://www.htmlcenter.com/blog/setting-up-wordpress-mu-domain-mapping-on-godaddy/#comments</comments>
		<pubDate>Tue, 20 Sep 2011 18:37:51 +0000</pubDate>
		<dc:creator>Curtiss</dc:creator>
				<category><![CDATA[PHP Tutorials]]></category>

		<guid isPermaLink="false">http://www.htmlcenter.com/?p=2227</guid>
		<description><![CDATA[I recently worked with a client to help move a GoDaddy &#8220;WebsiteTonight&#8221; website into WordPress. In the process, I recommended that she turn her existing WordPress website into a multisite installation, set up her second site as another site in that install, and then set up domain mapping to give each of the websites a [...]
Related posts:<ol>
<li><a href='http://www.htmlcenter.com/blog/setting-up-google-apps-gmail-for-your-domain/' rel='bookmark' title='Setting Up Google Apps (Gmail) For Your Domain'>Setting Up Google Apps (Gmail) For Your Domain</a></li>
<li><a href='http://www.htmlcenter.com/blog/make-sure-your-domain-works-without-the-www/' rel='bookmark' title='Make Sure Your Domain Works Without the &#8220;WWW&#8221;'>Make Sure Your Domain Works Without the &#8220;WWW&#8221;</a></li>
<li><a href='http://www.htmlcenter.com/blog/domain-prices-going-up-in-july/' rel='bookmark' title='Domain Prices Going Up in July'>Domain Prices Going Up in July</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I recently worked with a client to help move a GoDaddy &#8220;WebsiteTonight&#8221; website into WordPress. In the process, I recommended that she turn her existing WordPress website into a multisite installation, set up her second site as another site in that install, and then set up domain mapping to give each of the websites a separate domain name.</p>
<p>This setup allows her to login a single time, and be able to switch back and forth between the sites to perform edits. It also makes it simpler to manage plugins, update WordPress and keep the theme consistent between the two sites.<span id="more-2227"></span></p>
<p>The problem was, the website is hosted on GoDaddy. After searching Bing for a while to see what the potential problems might be, and to see what solutions other people had found, I started to get a little worried. A lot of articles indicated that they&#8217;d had to purchase a dedicated IP from GoDaddy, some even said they&#8217;d completely failed to get it set up properly.</p>
<p>As it turned out, though, I was worried for nothing, really. It was a frustrating process, simply because of how unfriendly GoDaddy&#8217;s account control panel is; but it was basically straight-forward.</p>
<p>To get WordPress MU Domain Mapping set up, I first went through the <a href="http://codex.wordpress.org/Create_A_Network">steps to convert the original installation into multisite</a>. Then, I followed these steps (filtered a bit to leave out the steps that were unsuccessful or had no impact):</p>
<ol>
<li>Set up the new site in WordPress.</li>
<li>Imported all of the content for the new site.</li>
<li>Made sure that everything was working fine on the new site.</li>
<li>Installed the <a href="http://wordpress.org/extend/plugins/wordpress-mu-domain-mapping/">WordPress MU Domain Mapping plugin</a> using the plugin installer built into WordPress.</li>
<li>Copied sunrise.php from the plugin&#8217;s folder into my wp-content directory.</li>
<li>Went to Settings -&gt; Domain Mapping in the Network admin area for WordPress; entered the IP address of the host server (I found out that this setting doesn&#8217;t really do anything, so don&#8217;t be afraid to fill it out &#8211; you can even put random numbers there if you want &#8211; the setting is strictly used to show site administrators what the IP address should be when they use their hosting control panel to map the domain). I also chose the options &#8220;User domain mapping page&#8221; and &#8220;Redirect administration pages to site&#8217;s original domain (remote login disabled if this redirect is disabled)&#8221; and unchecked all of the others.</li>
<li>Went to Tools -&gt; Domain Mapping in the Admin area for the new WordPress site and added the domain name that I wanted to map. I did not set it as Primary, yet, as I wanted to make sure the old address worked until I actually had the domain mapped properly. Setting up the domain before I mapped it, though, helped to make sure it did map properly once the DNS settings propagated.</li>
<li>Went into the GoDaddy account control panel (My Account -&gt; My Products).</li>
<li>Followed the <a href="http://help.godaddy.com/article/4385">steps to associate a different domain name with the Website Tonight website</a> (in this client&#8217;s case, they owned 5 domain names that were all similar, 4 of which were not being used for anything, so I was able to assign one of those to the WT site). I needed to perform this step, because GoDaddy wouldn&#8217;t let me complete step 12 until this was done.</li>
<li>After waiting a few hours for all of GoDaddy&#8217;s servers to catch on to the fact that I had disassociated the desired domain with WT, I went back to My Products -&gt; Web Hosting in the GD control panel and clicked &#8220;Launch&#8221; for the account that hosts WordPress.</li>
<li>On that page, opened the Settings tab and clicked on Domain Management.</li>
<li>I clicked the &#8220;Add Domain&#8221; button in the top right of the domain management screen and entered the domain name that I wanted to map to WordPress. After about 2 or 3 hours of waiting (and, oddly, of the domain name pointing to 3 different places in the process), it finally started pointing to WordPress.</li>
<li>Went back into Tools -&gt; Domain Mapping in the WordPress admin area for the new site and updated the domain so that it would act as the Primary (causing any other domains mapped to that site to redirect to it).</li>
</ol>
<p>While the first three steps aren&#8217;t necessarily part of the setup process for WordPress MU Domain Mapping, you really should make sure they&#8217;ve been done before you try to setup the plugin. Otherwise, any issues you encounter will be much harder to diagnose (because you won&#8217;t know if the issue is related to WordPress or the plugin).</p>
<p>I am fairly certain that this process used to be a lot more complicated (in the early days, I think it might have even required edits to core WPMU files); but it is extremely simple, now. Since the instructions have changed so drastically over the years, be careful which articles and tutorials you read on the subject.</p>
<p>The plugin does not require any sort of wildcard subdomains to be set up (even when using WordPress Multisite in subdomain-mode, it doesn&#8217;t actually require wildcard subdomains; you just need to create each subdomain manually in your host&#8217;s DNS settings), nor does it require a dedicated IP address. It really only requires that your host knows where to point each domain name once it&#8217;s sent to the DNS.</p>
<p>Related posts:<ol>
<li><a href='http://www.htmlcenter.com/blog/setting-up-google-apps-gmail-for-your-domain/' rel='bookmark' title='Setting Up Google Apps (Gmail) For Your Domain'>Setting Up Google Apps (Gmail) For Your Domain</a></li>
<li><a href='http://www.htmlcenter.com/blog/make-sure-your-domain-works-without-the-www/' rel='bookmark' title='Make Sure Your Domain Works Without the &#8220;WWW&#8221;'>Make Sure Your Domain Works Without the &#8220;WWW&#8221;</a></li>
<li><a href='http://www.htmlcenter.com/blog/domain-prices-going-up-in-july/' rel='bookmark' title='Domain Prices Going Up in July'>Domain Prices Going Up in July</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.htmlcenter.com/blog/setting-up-wordpress-mu-domain-mapping-on-godaddy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Some WordPress Gallery Features You Might Not Know About</title>
		<link>http://www.htmlcenter.com/blog/some-wordpress-gallery-features-you-might-not-know-about/</link>
		<comments>http://www.htmlcenter.com/blog/some-wordpress-gallery-features-you-might-not-know-about/#comments</comments>
		<pubDate>Fri, 16 Sep 2011 21:56:17 +0000</pubDate>
		<dc:creator>Curtiss</dc:creator>
				<category><![CDATA[PHP Tutorials]]></category>
		<category><![CDATA[features]]></category>
		<category><![CDATA[gallery]]></category>
		<category><![CDATA[options]]></category>
		<category><![CDATA[shortcode]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.htmlcenter.com/?p=2216</guid>
		<description><![CDATA[The other day, I was playing around with the WordPress [ ] shortcode, and came across the need to exclude an image that was attached to the page. The image I needed to exclude was kind of like a featured image, and I didn&#8217;t want it to appear again in the gallery itself. So, I [...]
Related posts:<ol>
<li><a href='http://www.htmlcenter.com/blog/new-version-of-gallery/' rel='bookmark' title='New Version of Gallery'>New Version of Gallery</a></li>
<li><a href='http://www.htmlcenter.com/blog/my-first-official-wordpress-plugin/' rel='bookmark' title='My First Official WordPress Plugin'>My First Official WordPress Plugin</a></li>
<li><a href='http://www.htmlcenter.com/blog/css-table-gallery/' rel='bookmark' title='CSS Table Gallery'>CSS Table Gallery</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>The other day, I was playing around with the WordPress [</p>
<p>] shortcode, and came across the need to exclude an image that was attached to the page. The image I needed to exclude was kind of like a featured image, and I didn&#8217;t want it to appear again in the gallery itself. So, I searched for information about excluding images from the WordPress [</p>
<p>] shortcode, and came across <a href="http://codex.wordpress.org/Gallery_Shortcode">the related WordPress Codex article</a>.</p>
<p>While reading that article, I noticed a handful of features I&#8217;d never known about in that particular shortcode. After all, I always basically assumed that the options WordPress gives you when inserting a gallery were probably the only options that were available.<span id="more-2216"></span></p>
<p>Turns out I was wrong. In addition to the &#8220;Order By&#8221;, &#8220;Columns&#8221; and &#8220;Links&#8221; options that the WordPress interface offers, the [</p>
<p>] shortcode accepts the following extra options:</p>
<ul>
<li>id &#8211; In case you want to show the gallery from a page other than the one you&#8217;re currently editing. By default, WordPress simply shows the images that are attached to the current page, but you can override that by providing another page&#8217;s ID.</li>
<li>size &#8211; Choose from any of the defined (named) image sizes in WordPress. By default, WordPress displays the &#8220;thumb&#8221; size (which might not be ideal, since that is usually a cropped image).</li>
<li>itemtag &#8211; The HTML element that&#8217;s used to wrap each item (which includes the image and the caption together) in the gallery. By default, WordPress uses a &lt;dl&gt; tag, making each gallery item a separate definition list.</li>
<li>icontag &#8211; The HTML element that&#8217;s used to wrap each image inside of the gallery. By default, WordPress makes each image a &lt;dt&gt;</li>
<li>captiontag &#8211; The HTML element used to wrap each caption in the gallery. By default, WordPress uses &lt;dd&gt;</li>
<li>include/exclude &#8211; You can provide a comma-separated list of attachment IDs that WordPress should either include explicitly (leaving all others out) or exclude (causing WordPress to use all other items that are attached to the page) in the gallery.</li>
</ul>
<p>Related posts:<ol>
<li><a href='http://www.htmlcenter.com/blog/new-version-of-gallery/' rel='bookmark' title='New Version of Gallery'>New Version of Gallery</a></li>
<li><a href='http://www.htmlcenter.com/blog/my-first-official-wordpress-plugin/' rel='bookmark' title='My First Official WordPress Plugin'>My First Official WordPress Plugin</a></li>
<li><a href='http://www.htmlcenter.com/blog/css-table-gallery/' rel='bookmark' title='CSS Table Gallery'>CSS Table Gallery</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.htmlcenter.com/blog/some-wordpress-gallery-features-you-might-not-know-about/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Please Stop Using cURL in WordPress Plugins</title>
		<link>http://www.htmlcenter.com/blog/please-stop-using-curl-in-wordpress-plugins/</link>
		<comments>http://www.htmlcenter.com/blog/please-stop-using-curl-in-wordpress-plugins/#comments</comments>
		<pubDate>Sat, 10 Sep 2011 03:23:07 +0000</pubDate>
		<dc:creator>Curtiss</dc:creator>
				<category><![CDATA[PHP Tutorials]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[file request]]></category>
		<category><![CDATA[get]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[wp_http]]></category>

		<guid isPermaLink="false">http://www.htmlcenter.com/?p=2214</guid>
		<description><![CDATA[Unfortunately, I keep finding WordPress plugins that try to call cURL functions directly. Unfortunately, not only do these plugins fail to work if cURL isn&#8217;t installed, it throws a fatal PHP error in the process. The problem with using cURL in WordPress plugins is that WordPress solved that problem more than 2 years ago by [...]
Related posts:<ol>
<li><a href='http://www.htmlcenter.com/blog/using-jquery-in-your-wordpress-plugins/' rel='bookmark' title='Using jQuery in your WordPress plugins'>Using jQuery in your WordPress plugins</a></li>
<li><a href='http://www.htmlcenter.com/blog/my-first-official-wordpress-plugin/' rel='bookmark' title='My First Official WordPress Plugin'>My First Official WordPress Plugin</a></li>
<li><a href='http://www.htmlcenter.com/blog/my-first-contribution-to-wordpress/' rel='bookmark' title='My First Contribution to WordPress'>My First Contribution to WordPress</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Unfortunately, I keep finding WordPress plugins that try to call cURL functions directly. Unfortunately, not only do these plugins fail to work if cURL isn&#8217;t installed, it throws a fatal PHP error in the process.</p>
<p>The problem with using cURL in WordPress plugins is that WordPress solved that problem more than 2 years ago by implementing <a href="http://codex.wordpress.org/HTTP_API">the WP_Http class</a>. WP_Http is a class included in the WordPress core that has multiple options. One of those options is cURL, but it gracefully reverts to other PHP functions if cURL isn&#8217;t available.</p>
<p>Basically, anything you can do with cURL can be done with the WP_Http class, and it will allow your plugin to be much more versatile and compatible with more server setups.<span id="more-2214"></span></p>
<p>Unfortunately, though, it seems that a lot of plugin developers are completely unaware of the class. Each time I find a plugin that requires cURL (one of my servers does not have cURL compiled into PHP), I point them to <a href="http://planetozh.com/blog/2009/08/how-to-make-http-requests-with-wordpress/">a great article on the WP_Http class</a> that Ozh wrote back in August 2009, and each one tells me they&#8217;ve never heard of WP_Http before.</p>
<p>So, if you are even tangentially connected to a WordPress plugin (or theme) developer, please help shout this from the rooftops. If you are performing any sort of file request in your plugin, please use WP_Http instead of relying entirely on cURL.</p>
<p>Related posts:<ol>
<li><a href='http://www.htmlcenter.com/blog/using-jquery-in-your-wordpress-plugins/' rel='bookmark' title='Using jQuery in your WordPress plugins'>Using jQuery in your WordPress plugins</a></li>
<li><a href='http://www.htmlcenter.com/blog/my-first-official-wordpress-plugin/' rel='bookmark' title='My First Official WordPress Plugin'>My First Official WordPress Plugin</a></li>
<li><a href='http://www.htmlcenter.com/blog/my-first-contribution-to-wordpress/' rel='bookmark' title='My First Contribution to WordPress'>My First Contribution to WordPress</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.htmlcenter.com/blog/please-stop-using-curl-in-wordpress-plugins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress: Adding &#8220;Get Shortlink&#8221; to Custom Post Types</title>
		<link>http://www.htmlcenter.com/blog/wordpress-adding-get-shortlink-to-custom-post-types/</link>
		<comments>http://www.htmlcenter.com/blog/wordpress-adding-get-shortlink-to-custom-post-types/#comments</comments>
		<pubDate>Fri, 12 Aug 2011 22:29:24 +0000</pubDate>
		<dc:creator>Curtiss</dc:creator>
				<category><![CDATA[PHP Tutorials]]></category>
		<category><![CDATA[custom post types]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[get shortlink]]></category>
		<category><![CDATA[get_shortlink]]></category>
		<category><![CDATA[pages]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.htmlcenter.com/?p=2178</guid>
		<description><![CDATA[For some reason, by default, WordPress only includes the &#8220;Get Shortlink&#8221; button when editing posts; not when editing any kind of custom post type or when editing pages. Honestly, I&#8217;m not sure why, since pages and custom post types all use the same basic short URL as standard posts (example.com/?p=[post_id]). The solution is simple, though. [...]
Related posts:<ol>
<li><a href='http://www.htmlcenter.com/blog/wordpress-adding-page-links-to-to-custom-post-types/' rel='bookmark' title='WordPress: Adding &#8220;Page Links To&#8221; to Custom Post Types'>WordPress: Adding &#8220;Page Links To&#8221; to Custom Post Types</a></li>
<li><a href='http://www.htmlcenter.com/blog/adding-custom-menus-to-your-wordpress-3-theme/' rel='bookmark' title='Adding Custom Menus to Your WordPress 3 Theme'>Adding Custom Menus to Your WordPress 3 Theme</a></li>
<li><a href='http://www.htmlcenter.com/blog/importing-posts-from-custom-sources-into-wordpress/' rel='bookmark' title='Importing Posts From Custom Sources Into WordPress'>Importing Posts From Custom Sources Into WordPress</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>For some reason, by default, WordPress only includes the &#8220;Get Shortlink&#8221; button when editing posts; not when editing any kind of custom post type or when editing pages. Honestly, I&#8217;m not sure why, since pages and custom post types all use the same basic short URL as standard posts (example.com/?p=[post_id]).</p>
<p>The solution is simple, though. You just need to hook into the get_shortlink filter. Following is a simple function that will help you add the button to all &#8220;publicly_queryable&#8221; post types in your theme.<span id="more-2178"></span></p>
<pre style="width: 96%; padding: 1%; margin: 1%; overflow-x: auto;">if( !function_exists( 'my_theme_cpt_shortlinks' ) ) {
	/**
	 * Allow shortlinks to be retrieved for pages and custom post types
	 */
	function my_theme_cpt_shortlinks( $shortlink, $id, $context, $allow_slugs=true ) {
		/**
		 * If query is the context, we probably shouldn't do anything
		 */
		if( 'query' == $context )
			return $shortlink;

		$post = get_post( $id );
		$post_id = $post-&gt;ID;

		/**
		 * If this is a standard post, return the shortlink that was already built
		 */
		if( 'post' == $post-&gt;post_type )
			return $shortlink;

		/**
		 * Retrieve the array of publicly_queryable, non-built-in post types
		 */
		$post_types = get_post_types( array( '_builtin' =&gt; false, 'publicly_queryable' =&gt; true ) );
		if( in_array( $post-&gt;post_type, $post_types ) || 'page' == $post-&gt;post_type )
			$shortlink = home_url('?p=' . $post-&gt;ID);

		return $shortlink;
	}
}
add_filter( 'get_shortlink', 'edui2011_cpt_shortlinks', 10, 4 );</pre>
<p>Related posts:<ol>
<li><a href='http://www.htmlcenter.com/blog/wordpress-adding-page-links-to-to-custom-post-types/' rel='bookmark' title='WordPress: Adding &#8220;Page Links To&#8221; to Custom Post Types'>WordPress: Adding &#8220;Page Links To&#8221; to Custom Post Types</a></li>
<li><a href='http://www.htmlcenter.com/blog/adding-custom-menus-to-your-wordpress-3-theme/' rel='bookmark' title='Adding Custom Menus to Your WordPress 3 Theme'>Adding Custom Menus to Your WordPress 3 Theme</a></li>
<li><a href='http://www.htmlcenter.com/blog/importing-posts-from-custom-sources-into-wordpress/' rel='bookmark' title='Importing Posts From Custom Sources Into WordPress'>Importing Posts From Custom Sources Into WordPress</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.htmlcenter.com/blog/wordpress-adding-get-shortlink-to-custom-post-types/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress: Adding &#8220;Page Links To&#8221; to Custom Post Types</title>
		<link>http://www.htmlcenter.com/blog/wordpress-adding-page-links-to-to-custom-post-types/</link>
		<comments>http://www.htmlcenter.com/blog/wordpress-adding-page-links-to-to-custom-post-types/#comments</comments>
		<pubDate>Wed, 10 Aug 2011 05:04:11 +0000</pubDate>
		<dc:creator>Curtiss</dc:creator>
				<category><![CDATA[PHP Tutorials]]></category>
		<category><![CDATA[mark jaquith]]></category>
		<category><![CDATA[page links to]]></category>
		<category><![CDATA[redirect]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.htmlcenter.com/?p=2174</guid>
		<description><![CDATA[If you use WordPress (especially as a content management system) and you haven&#8217;t heard of Mark Jaquith&#8217;s &#8220;Page Links To&#8221; plugin, you should definitely check it out. Basically, the plugin allows you to set up a WordPress page or post to redirect to a different URL. It can be very handy for setting up redirects, [...]
Related posts:<ol>
<li><a href='http://www.htmlcenter.com/blog/wordpress-adding-get-shortlink-to-custom-post-types/' rel='bookmark' title='WordPress: Adding &#8220;Get Shortlink&#8221; to Custom Post Types'>WordPress: Adding &#8220;Get Shortlink&#8221; to Custom Post Types</a></li>
<li><a href='http://www.htmlcenter.com/blog/custom-wordpress-page-templates/' rel='bookmark' title='Custom WordPress Page Templates'>Custom WordPress Page Templates</a></li>
<li><a href='http://www.htmlcenter.com/blog/adding-custom-menus-to-your-wordpress-3-theme/' rel='bookmark' title='Adding Custom Menus to Your WordPress 3 Theme'>Adding Custom Menus to Your WordPress 3 Theme</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>If you use WordPress (especially as a content management system) and you haven&#8217;t heard of <a href="http://wordpress.org/extend/plugins/page-links-to/">Mark Jaquith&#8217;s &#8220;Page Links To&#8221; plugin</a>, you should definitely check it out. Basically, the plugin allows you to set up a WordPress page or post to redirect to a different URL. It can be very handy for setting up redirects, adding menu items for pages that wouldn&#8217;t normally appear in those menus, etc.</p>
<p>One issue with the plugin, however, is that it does not (as of version 2.4.1) support custom post types. It only supports WordPress posts and pages. If you want to set a custom post type to redirect to a URL other than its permalink, you can&#8217;t do so with this plugin.</p>
<p>However, there is a pretty simple way to add support for custom post types to this plugin; and the changes do not require you to edit the plugin itself. Instead, you can make all of the necessary changes in your theme&#8217;s functions.php file.<span id="more-2174"></span></p>
<p>To begin with, you will need to write your own copy of the plugin&#8217;s <code>add_meta_box()</code> function and hook it into the <code>do_meta_boxes</code> action. The current version of Page Links To includes the following <code>do_meta_boxes()</code> function:</p>
<pre style="width: 96%; padding: 1%; margin: 1%; overflow-x: auto;">	/**
	 * Adds the meta box to the post or page edit screen
	 * @param string $page the name of the current page
	 * @param string $context the current context
	 */
	function do_meta_boxes( $page, $context ) {
		if ( ( 'page' === $page || 'post' === $page ) &amp;&amp; 'advanced' === $context )
			add_meta_box( 'page-links-to', 'Page Links To', array( &amp;$this, 'meta_box' ), $page, 'advanced', 'low' );
	}</pre>
<p>You need to make your own copy of that function, giving it a unique function name (for instance, something like <code>my_theme_add_plt_mb</code>) and add your custom post types in place of &#8220;page&#8221; and &#8220;post&#8221; in the new function. That would look something like:</p>
<pre style="width: 96%; padding: 1%; margin: 1%; overflow-x: auto;">/**
 * Adds the meta box to the post or page edit screen
 * @param string $page the name of the current page
 * @param string $context the current context
 */
function my_theme_add_plt_mb( $page, $context ) {
	if ( ( 'custom_post_type_1' === $page || 'custom_post_type_2' === $page || 'custom_post_type_3' === $page ) &amp;&amp; 'advanced' === $context )
		add_meta_box( 'page-links-to', 'Page Links To', array( 'CWS_PageLinksTo', 'meta_box' ), $page, 'advanced', 'low' );
}
if( class_exists( 'CWS_PageLinksTo' ) )
	add_action( 'do_meta_boxes', 'mspan_add_plt_meta_box', 10, 2 );</pre>
<p>Next, you will need to tell WordPress to replace the standard permalink for the custom post type with the link specified by Page Links To. To do that, you need to hook into the post_type_link filter. Because Page Links To doesn&#8217;t actually instantiate a variable when creating a new CWS_PageLinksTo object, you&#8217;ll need to do so before filtering the permalink (otherwise, you&#8217;ll get a PHP reference error, because the link method in the CWS_PageLinksTo class calls another method in the same class). Therefore, you should add something like the following to your functions.php file:</p>
<pre style="width: 96%; padding: 1%; margin: 1%; overflow-x: auto;">if( class_exists( 'CWS_PageLinksTo' ) )
	add_filter( 'post_type_link', 'my_theme_init_plt_obj', 20, 2 );
function my_theme_init_plt_obj( $link, $post ) {
	$tmp = new CWS_PageLinksTo;
	return $tmp-&gt;link( $link, $post );
}</pre>
<p>The code above hooks the my_theme_init_plt_obj() function into the post_type_link filter. Then, the <code>my_theme_init_plt_obj()</code> function declares a variable and assigns a new <code>CWS_PageLinksTo</code> object to that variable; and finally calls and returns the <code>CWS_PageLinksTo::link()</code> function.</p>
<p>Because the <code>CWS_PageLinksTo::__construct()</code> function adds a handful of hooks, etc.; you should not instantiate the variable any earlier than you need to use it (otherwise, you might end up with 2 Page Links To meta boxes on your post edit screen, or the links might get filtered twice, etc.).</p>
<p>Related posts:<ol>
<li><a href='http://www.htmlcenter.com/blog/wordpress-adding-get-shortlink-to-custom-post-types/' rel='bookmark' title='WordPress: Adding &#8220;Get Shortlink&#8221; to Custom Post Types'>WordPress: Adding &#8220;Get Shortlink&#8221; to Custom Post Types</a></li>
<li><a href='http://www.htmlcenter.com/blog/custom-wordpress-page-templates/' rel='bookmark' title='Custom WordPress Page Templates'>Custom WordPress Page Templates</a></li>
<li><a href='http://www.htmlcenter.com/blog/adding-custom-menus-to-your-wordpress-3-theme/' rel='bookmark' title='Adding Custom Menus to Your WordPress 3 Theme'>Adding Custom Menus to Your WordPress 3 Theme</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.htmlcenter.com/blog/wordpress-adding-page-links-to-to-custom-post-types/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

