<?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>WP Engineer &#187; Constants</title>
	<atom:link href="http://wpengineer.com/tag/constants/feed/" rel="self" type="application/rss+xml" />
	<link>http://wpengineer.com</link>
	<description>WordPress News, Hacks, Tips, Tutorials, Plugins and Themes</description>
	<lastBuildDate>Mon, 21 May 2012 22:48:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Know The Constants Of An WordPress Installation</title>
		<link>http://wpengineer.com/2052/know-the-constants-of-an-wordpress-installation/</link>
		<comments>http://wpengineer.com/2052/know-the-constants-of-an-wordpress-installation/#comments</comments>
		<pubDate>Wed, 08 Dec 2010 10:50:13 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress Tutorials]]></category>
		<category><![CDATA[advent]]></category>
		<category><![CDATA[Advent Calendar]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Constants]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WP]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=2052</guid>
		<description><![CDATA[Today I will show you how to display the constants you use in your WordPress installation. Here is a small code snippet to list the defined constants. Please note: The output shows all defined constants, including the database and FTP password. Therefore please don't put it up online for everybody, let only admins access this [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://wpengineer.com/wp-content/uploads/WordPress-Christmas-2010-08-300x200.jpg" alt="" title="WordPress-Christmas-2010-08" width="300" height="200" class="alignleft size-medium wp-image-2093" />Today I will show you how to display the constants you use in your WordPress installation. Here is a small code snippet to list the defined constants.<br />
<span id="more-2052"></span><br />
<strong>Please note:</strong> The output shows all defined constants, including the database and FTP password. Therefore please don't put it up online for everybody, let only admins access this page. For the output of constants PHP has a <a href="http://php.net/manual/function.get-defined-constants.php">function</a>, which we will use and add a little bit code to create a readable list. You put the code in your Theme to have an output of all constants. Alternatively you can also create a Plugin to view a list of the constants.</p>
<pre>
print(&#039;&lt;pre&gt;&#039;);
print_r( @get_defined_constants() );
print(&#039;&lt;/pre&gt;&#039;);
</pre>
<p>To be sure, that only <a href="http://wpengineer.com/1906/display-private-posts-to-logged-in-users/">logged in user</a> can see the list, I will add an additional query to check if the user is logged in.</p>
<pre>
if ( is_user_logged_in() ) {
	print(&#039;&lt;pre&gt;&#039;);
	print_r( @get_defined_constants() );
	print(&#039;&lt;/pre&gt;&#039;);
}
</pre>
<p>The output can also be checked by <a href="http://codex.wordpress.org/Roles_and_Capabilities">user rights</a> with <code> if ( current_user_can('manage_options') ) {</code>. You can read more about it in a <a href="http://wpengineer.com/516/update-informations-only-for-admins/">previous article</a> or an <a href="http://wpengineer.com/2046/control-the-wordpress-content-via-userrights-or-time/">article with examples</a> for use the rights.</p>
<p>As an alternativ, the Plugins <a href="http://wordpress.org/extend/plugins/wp-system-health/">WP System Health</a> and <a href="http://wordpress.org/extend/plugins/debug-objects/">Debug Objects</a> can be very helpful, which lists all constants.<br />
Have fun!<br />
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/2052/know-the-constants-of-an-wordpress-installation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Feed Cache in WordPress</title>
		<link>http://wpengineer.com/1820/feed-cache-in-wordpress/</link>
		<comments>http://wpengineer.com/1820/feed-cache-in-wordpress/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 10:11:53 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress Tutorials]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[Constants]]></category>
		<category><![CDATA[Feed]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[RSS]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[WP]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=1820</guid>
		<description><![CDATA[WordPress already offers the possibility of own functions to read feeds and use it in your blog. Since version 2.8 of WordPress, a new feature is in use for that. So there are two ways to work with feeds in WordPress, and in both functions, the data is cached. But this is not always wanted, [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress already offers the possibility of own functions to read feeds and use it in your blog. Since version 2.8 of WordPress, a new feature is in use for that. So there are two ways to work with feeds in WordPress, and in both functions, the data is cached. But this is not always wanted, so I show how to take influence on caching of the two functions.<br />
<span id="more-1820"></span></p>
<h3>fetch_feed() <em>Since WordPress 2.8</em></h3>
<p>With version 2.8 of WordPress, they add the class <strong>SimplePie</strong> into the core. SimplePie has always distinguished by a very rapid development and a stable user-friendly class. Before <strong>MagpieRSS</strong> has been used, which in many cases was not available and the development is rather slow. For some time SimplePie is no longer be maintained by the developer, which worried the developer community. But developers from the WordPress team took care of it and keep the class alive. More information can be find on the blog <a href="http://wpdevel.wordpress.com/2009/09/24/suggest-agenda-items-for-oct-1st-dev-cha/">WP Dev Updates</a></p>
<p>Now the class is in the core of WordPress and is capable of generating RSS and ATOM feeds. It uses the cache of WordPress and can be controlled via a hook.</p>
<p>But first a small sample to read a feed with the class in WordPress.</p>
<pre lang="php">
&lt;?php
include_once(ABSPATH . WPINC . &#039;/feed.php&#039;);
$rss = fetch_feed(&#039;http://bueltge.de/feed/&#039;);
$rss_items = $rss-&gt;get_items( 0, $rss-&gt;get_item_quantity(5) );
if ( !$rss_items ) {
    echo &#039;no items&#039;;
} else {
    foreach ( $rss_items as $item ) {
        echo &#039;&lt;p&gt;&lt;a href=&quot;&#039; . $item-&gt;get_permalink() . &#039;&quot;&gt;&#039; . $item-&gt;get_title() . &#039;&lt;/a&gt;&lt;/p&gt;&#039;;
    }
}
?&gt;
</pre>
<p>The small sample reads my feed and returns the last 5 entries.</p>
<p>Essential is the function <code>fetch_feed()</code>. This function has a hook which can make influence on caching - <code>wp_feed_cache_transient_lifetime</code>.<br />
The standard of the cache is set to 12 hours (<code> 43,200 </code>), which is not always the favorite setting for users. The value is operated on the method <code>WP_Feed_Cache_Transient()</code>, parameter <code>$lifetime</code>. Therefore, it is advisable to use the following little query, be it in the Plugin or in the <code>functions.php</code> of the theme.</p>
<pre lang="php">
add_filter( &#039;wp_feed_cache_transient_lifetime&#039;, create_function( &#039;$a&#039;, &#039;return 1800;&#039; ) );
</pre>
<p>In this example, I set the cache to 30 minutes. With the help of <a href="http://codex.wordpress.org/Conditional_Tags">Conditional Tags</a> you can control the whole of it so that the cache-hook is only activated when you click on a page (<code>is_page()</code>) or for example you are in the front end (<code>!is_admin()</code>) of the blog. Here you must simply use the opportunities and adapt to your own needs.</p>
<p>A small possibility I would like to point out more, <strong>available as of WordPress 2.9</strong> (<a href="http://core.trac.wordpress.org/ticket/11117">ticket 11117</a>), to simplify debugging for developers. Thus, the cache is disabled in the environment, if the constant <code>WP_DEBUG</code> is set, which can be important now and then. Setting the constant is usually done in the <code>wp-config.php</code> of the installation, or as alternative in the Plugin.</p>
<pre lang="php">
function do_not_cache_feeds(&amp;$feed) {
	$feed-&gt;enable_cache(false);
}

if ( defined(&#039;WP_DEBUG&#039;) &amp;&amp; WP_DEBUG )
	add_action( &#039;wp_feed_options&#039;, &#039;do_not_cache_feeds&#039; );
</pre>
<h3>fetch_rss()</h3>
<p>Another function is <code>fetch_rss()</code>, which was set with WordPress 2.8 on the suspense list. As an alternative, the above function is active. Current is <code>fetch_rss()</code> still available and is also supported. Therefore, for completeness, also the possibility to influence the cache.</p>
<p>Here an example to read feed and output the last 5 entries of the feed</p>
<pre lang="php">
&lt;?php
include_once(ABSPATH . WPINC . &#039;/rss.php&#039;);
$rss = fetch_rss(&#039;http://bueltge.de/feed/&#039;);
$rss_items = array_slice($rss-&gt;items, 0, 5);
if ( empty($rss_items) ) {
    echo &#039;no items&#039;;
} else {
    foreach ( $rss_items as $item ) {
        echo &#039;&lt;p&gt;&lt;a href=&quot;&#039; . $item&#091;&#039;link&#039;&#093; . &#039;&quot;&gt;&#039; . $item&#091;&#039;title&#039;&#093; . &#039;&lt;/a&gt;&lt;/p&gt;&#039;;
    }
}
?&gt;
</pre>
<p>Here, the function <code>fetch_rss()</code> is used for reading and the cache can be changed via the constants. This must defined either directly in <code>wp-config.php</code> where they will apply globally to all applications, or you need to integrate them into its own functions.</p>
<pre lang="php">
define(&#039;MAGPIE_CACHE_ON&#039;, 0); // deactivate cache
define(&#039;MAGPIE_CACHE_AGE&#039;, 60*60) // Cache 1 hour in seconds
</pre>
<h3>Conclusion</h3>
<p>Since WordPress decided not to support MagpieRSS any longer in the future, you should only deal with SimplePie and not with the second possibility.<br />
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/1820/feed-cache-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>WordPress Database Repair Script In 2.9</title>
		<link>http://wpengineer.com/1836/wordpress-database-repair-script-in-2-9/</link>
		<comments>http://wpengineer.com/1836/wordpress-database-repair-script-in-2-9/#comments</comments>
		<pubDate>Fri, 13 Nov 2009 17:21:35 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress News]]></category>
		<category><![CDATA[Constants]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[wp2.9]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=1836</guid>
		<description><![CDATA[A little tip for all users of the existing beta of WordPress 2.9 and for all who wish to update soon to the new version. With version 2.9 WordPress conducts its own routine to optimize the database. Previously it was done by either Plugins or via SQL access. From the next version this function is [...]]]></description>
			<content:encoded><![CDATA[<p>A little tip for all users of the existing beta of WordPress 2.9 and for all who wish to update soon to the new version. With version 2.9 WordPress conducts its own routine to optimize the database. Previously it was done by either Plugins or via SQL access. From the next version this function is implemented in the core ...<br />
<span id="more-1836"></span><br />
<a href="http://wpengineer.com/wp-content/uploads/wprdb11.png"><img src="http://wpengineer.com/wp-content/uploads/wprdb11-300x78.png" alt="wprdb1" title="wprdb1" width="300" height="78" class="aligncenter size-medium wp-image-1838" /></a></p>
<p>... which you can activate with the help of a constant; stored in <code>wp-config.php</code>, you have access to the script.</p>
<pre lang="php">
define(&#039;WP_ALLOW_REPAIR&#039;, true);
</pre>
<p>Call the script from the outside at the following address ...<br />
<code>http://example.com/wp-admin/maint/repair.php</code></p>
<p>... where you either repair the database or run the optimization. Technically, there is no magic behind this work, but the familiar SQL statements <a href="http://dev.mysql.com/doc/refman/5.1/en/analyze-table.html"><code>ANALYZE TABLE</code></a>, <a href="http://dev.mysql.com/doc/refman/5.1/en/repair-table.html"><code>REPAIR TABLE</code></a> and <a href="http://dev.mysql.com/doc/refman/5.1/en/optimize-table.html"><code>OPTIMIZE TABLE</code></a>.</p>
<p><a href="http://wpengineer.com/wp-content/uploads/wprdb.png"><img src="http://wpengineer.com/wp-content/uploads/wprdb-300x127.png" alt="wprdb" title="wprdb" width="300" height="127" class="aligncenter size-medium wp-image-1841" /></a></p>
<p>I guess that will start a debate, why with the constant and why from the outside, etc. - leave your comment here. Alternatively, anyone can contribute to WordPress and discuss directly with the developers or enter changes directly to the code.<br />
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/1836/wordpress-database-repair-script-in-2-9/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>WordPress Trash Is Coming</title>
		<link>http://wpengineer.com/1580/wordpress-trash-is-coming/</link>
		<comments>http://wpengineer.com/1580/wordpress-trash-is-coming/#comments</comments>
		<pubDate>Mon, 17 Aug 2009 10:19:12 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress News]]></category>
		<category><![CDATA[Constants]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[wp2.9]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=1580</guid>
		<description><![CDATA[I would like to show you briefly what the new function trash is all about. Users of Gmail are aware of the possibility in a web application: you move content into the trash and the content will be deleted after a certain time. Alternatively, you can also restore the content, always depending on a defined [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://wpengineer.com/wp-content/uploads/post-trash.png" alt="post-trash" title="post-trash" width="292" height="207" class="alignright size-full wp-image-1578" /><br />
I would like to show you briefly what the new function trash is all about.</p>
<p>Users of Gmail are aware of the possibility in a web application: you move content into the trash and the content will be deleted after a certain time. Alternatively, you can also restore the content, always depending on a defined time frame.</p>
<p>WordPress integrates this function also in WordPress 2.9 for articles and comments. Some screenshots showing the function in articles and comments.</p>
<p><span id="more-1580"></span><br />
<img src="http://wpengineer.com/wp-content/uploads/trash-comment.png" alt="trash-comment" title="trash-comment" width="436" height="182" class="aligncenter size-full wp-image-1581" /><br />
<img src="http://wpengineer.com/wp-content/uploads/edit-posts.png" alt="edit-posts" title="edit-posts" width="351" height="145" class="aligncenter size-full wp-image-1579" /></p>
<p>The time period is via constant defined, default are 30 days. If you want to change this value, it must be defined in <code>wp-config.php</code>.<br />
<code>define( 'EMPTY_TRASH_DAYS', 30 );</code></p>
<p>For developers, there are two hooks - for articles and comments, where you can intervene.<br />
<code><br />
 * @uses do_action() on 'untrash_post' before undeletion<br />
 * @uses do_action() on 'untrashed_post' after undeletion<br />
</code><br />
<code><br />
 * @uses do_action() on 'untrash_comment' before undeletion<br />
 * @uses do_action() on 'untrashed_comment' after undeletion<br />
</code></p>
<p>Otherwise, version 2.9 gets some more advanced features for media, as the users in <a href="http://wordpress.org/development/2009/07/2-9-vote-results/">the last survey</a> decided. These will also be available in the core and thus the system continues to inflate. A pity, in my view that the user does not use<a href="http://wpengineer.com/core-plugins/"> the option of "Canonical Plugins" </a>.<br />
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/1580/wordpress-trash-is-coming/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>WordPress Proxysupport</title>
		<link>http://wpengineer.com/1227/wordpress-proxysupport/</link>
		<comments>http://wpengineer.com/1227/wordpress-proxysupport/#comments</comments>
		<pubDate>Fri, 15 May 2009 10:58:13 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[Constants]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress 2.8]]></category>
		<category><![CDATA[WordPress Tutorials]]></category>
		<category><![CDATA[WP]]></category>
		<category><![CDATA[wp2.8]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=1227</guid>
		<description><![CDATA[Who is using WordPress in an intranet environment, will quickly realize, that despite internet connection, no feed content gets loaded in the backend. In general, it's because of the proxy of the company. So far WordPress wasn't particularly flexible in this case. As of WordPress 2.8 that will change and new constants make ensure that [...]]]></description>
			<content:encoded><![CDATA[<p>Who is using WordPress in an intranet environment, will quickly realize, that despite internet connection, no feed content gets loaded in the backend. In general, it's because of the proxy of the company. So far WordPress wasn't particularly flexible in this case. As of WordPress 2.8 that will change and new constants make ensure that you now can enter the proxy directly to <code>wp-config.php</code>.<br />
<span id="more-1227"></span></p>
<h3>Until WordPress 2.7</h3>
<p>Up to this version of WordPress it works only with an adjustment in the core, in <code>wp-includes/class-snoopy.php</code>. Here you have to change the settings of <code>$proxy_host</code>, <code>$proxy_port</code> and <code>$_isproxy</code>. The value of var <code>$_isproxy = false;</code> will of course have <code>TRUE</code> as value.</p>
<pre lang="php">
var $host       = &quot;www.php.net&quot;; // host name we are connecting to
var $port       = 8080; // port we are connecting to
var $proxy_host = &quot;&quot;; // proxy host to use
var $proxy_port = &quot;&quot;; // proxy port to use
var $proxy_user = &quot;&quot;; // proxy user to use
var $proxy_pass = &quot;&quot;; // proxy password to use
var $_isproxy   = true; // set if using a proxy server
</pre>
<h3>WordPress 2.8</h3>
<p>With the new version it is much easier, because no more intrusion into the core files is necessary and the possibility to define the values in the configuration file <code>wp-config.php</code>.</p>
<pre lang="php">
define(&#039;WP_PROXY_HOST&#039;, &#039;192.168.84.101&#039;);
define(&#039;WP_PROXY_PORT&#039;, &#039;8080&#039;);
define(&#039;WP_PROXY_USERNAME&#039;, &#039;my_user_name&#039;);
define(&#039;WP_PROXY_PASSWORD&#039;, &#039;my_password&#039;);
define(&#039;WP_PROXY_BYPASS_HOSTS&#039;, &#039;localhost, www.example.com&#039;);
</pre>
<p>Various references are also in<a href="http://core.trac.wordpress.org/ticket/4011">Ticket 4011</a>.<br />
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/1227/wordpress-proxysupport/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Use Constants To Integrate WordPress In Other CMS</title>
		<link>http://wpengineer.com/647/use-constants-integrate-wordpress/</link>
		<comments>http://wpengineer.com/647/use-constants-integrate-wordpress/#comments</comments>
		<pubDate>Fri, 23 Jan 2009 13:03:18 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[Constants]]></category>
		<category><![CDATA[Integration]]></category>
		<category><![CDATA[Theme]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=647</guid>
		<description><![CDATA[Sometimes you need to integrate WordPress into another CMS, like Typo3, Drupal or whatever is out there. The blog should have the same design, use same images and Javascript or implement existing links. Mostly you run the WordPress blog on a subdomain like blog.example.com and the data lies on example.com/css/ and so on. The easiest [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes you need to integrate WordPress into another CMS, like Typo3, Drupal or whatever is out there. The blog should have the same design, use same images  and Javascript or implement existing links. Mostly you run the WordPress blog on a subdomain like blog.example.com and the data lies on example.com/css/ and so on.<br />
<span id="more-647"></span><br />
The easiest solution in such cases is to use constants, to access the existing files. We define them in functions.php of the theme folder:</p>
<pre lang="php">
&lt;?php
define(&#039;DIR_ROOT&#039;, &#039;http://example.com&#039;);
define(&#039;DIR_STYLESHEETS&#039;, DIR_ROOT . &#039;/css&#039;);
define(&#039;DIR_IMAGES&#039;, DIR_ROOT . &#039;/images&#039;);
define(&#039;DIR_JAVASCRIPT&#039;, DIR_ROOT . &#039;/js&#039;);
?&gt;
</pre>
<p>In your theme you use the constants like this:</p>
<pre lang="php">
&lt;script src=&quot;&lt;?php echo DIR_JAVASCRIPT; ?&gt;/myeffects.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;img src=&quot;&lt;?php echo DIR_IMAGES; ?&gt;/myimage.jpg&quot; alt=&quot;foo&quot; /&gt;
</pre>
<p>Easy, right? Mostly a little stylesheet is enough for special WordPress adjustments, which you load after the stylesheets of the CMS.<br />
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/647/use-constants-integrate-wordpress/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Determine Path To Plugin and Content Directories</title>
		<link>http://wpengineer.com/63/determine-path-to-plugin-and-content-directories/</link>
		<comments>http://wpengineer.com/63/determine-path-to-plugin-and-content-directories/#comments</comments>
		<pubDate>Fri, 26 Sep 2008 18:02:14 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Constants]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Plugins]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=63</guid>
		<description><![CDATA[If you like to write a Plugin and you want to keep it downward compatible, then check beforehand the constants, because since WordPress version 2.6 you can rename the folder wp-content and this will also change the path to the Plugin folder. Just a few lines of code are enough and you can work with [...]]]></description>
			<content:encoded><![CDATA[<p>If you like to write a Plugin and you want to keep it downward compatible, then check beforehand the constants, because since WordPress version 2.6 you can rename the folder <code>wp-content</code> and this will also change the path to the Plugin folder.</p>
<p>Just a few lines of code are enough and you can work with the &#8222;new&#8220; constants.<br />
<span id="more-63"></span></p>
<pre lang="php">
// Pre-2.6 compatibility
if ( !defined( &#039;WP_CONTENT_URL&#039; ) )
	define( &#039;WP_CONTENT_URL&#039;, get_option( &#039;siteurl&#039; ) . &#039;/wp-content&#039; );
if ( !defined( &#039;WP_CONTENT_DIR&#039; ) )
	define( &#039;WP_CONTENT_DIR&#039;, ABSPATH . &#039;wp-content&#039; );
if ( !defined( &#039;WP_PLUGIN_URL&#039; ) )
	define( &#039;WP_PLUGIN_URL&#039;, WP_CONTENT_URL. &#039;/plugins&#039; );
if ( !defined( &#039;WP_PLUGIN_DIR&#039; ) )
	define( &#039;WP_PLUGIN_DIR&#039;, WP_CONTENT_DIR . &#039;/plugins&#039; );
if ( !defined( &#039;WP_LANG_DIR&#039;) )
	define( &#039;WP_LANG_DIR&#039;, WP_CONTENT_DIR . &#039;/languages&#039; );
</pre>
<p>I use this solution quite a long time. You can find the solution in the WordPress Codex now - &#8222;<a href="http://codex.wordpress.org/Determining_Plugin_and_Content_Directories">Determining Plugin and Content Directories</a>&#8220;.<br />
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/63/determine-path-to-plugin-and-content-directories/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

