<?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, Tipps, Tutorials, Plugins and Themes</description> <lastBuildDate>Wed, 28 Jul 2010 13:37:05 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=1682</generator> <xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" /> <item><title>Feed Cache in WordPress</title><link>http://wpengineer.com/feed-cache-in-wordpress/</link> <comments>http://wpengineer.com/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/" class="liexternal">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><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span>ABSPATH <span style="color: #339933;">.</span> WPINC <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/feed.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$rss</span> <span style="color: #339933;">=</span> fetch_feed<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://bueltge.de/feed/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$rss_items</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$rss</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_items</span><span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$rss</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_item_quantity</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #000088;">$rss_items</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'no items'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$rss_items</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$item</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;p&gt;&lt;a href=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_permalink</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_title</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/a&gt;&lt;/p&gt;'</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div><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><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;">add_filter<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wp_feed_cache_transient_lifetime'</span><span style="color: #339933;">,</span> <span style="color: #990000;">create_function</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'$a'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'return 1800;'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><p>In this example, I set the cache to 30 minutes. With the help of <a
href="http://codex.wordpress.org/Conditional_Tags" class="liwp">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" class="liwp">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><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> do_not_cache_feeds<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #000088;">$feed</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$feed</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">enable_cache</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WP_DEBUG'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> WP_DEBUG <span style="color: #009900;">&#41;</span>
	add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wp_feed_options'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'do_not_cache_feeds'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><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><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span>ABSPATH <span style="color: #339933;">.</span> WPINC <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/rss.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$rss</span> <span style="color: #339933;">=</span> fetch_rss<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://bueltge.de/feed/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$rss_items</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_slice</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rss</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">items</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rss_items</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'no items'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$rss_items</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$item</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;p&gt;&lt;a href=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'link'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/a&gt;&lt;/p&gt;'</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div><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><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'MAGPIE_CACHE_ON'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// deactivate cache</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'MAGPIE_CACHE_AGE'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// Cache 1 hour in seconds</span></pre></div></div><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
/><h3>Related posts:</h3><ul><li><a
href="http://wpengineer.com/use-wordpress-cache/" rel="bookmark" title="Permanent Link: Use WordPress Cache" class="liinternal">Use WordPress Cache</a></li><li><a
href="http://wpengineer.com/customize-your-wordpress-feeds/" rel="bookmark" title="Permanent Link: Customize Your WordPress-Feeds" class="liinternal">Customize Your WordPress-Feeds</a></li><li><a
href="http://wpengineer.com/recents-drafts-all-authors/" rel="bookmark" title="Permanent Link: Recents Drafts All Authors" class="liinternal">Recents Drafts All Authors</a></li><li><a
href="http://wpengineer.com/disable-wordpress-feed/" rel="bookmark" title="Permanent Link: Disable WordPress Feed" class="liinternal">Disable WordPress Feed</a></li><li><a
href="http://wpengineer.com/publish-the-feed-later/" rel="bookmark" title="Permanent Link: Publish The Feed Later" class="liinternal">Publish The Feed Later</a></li></ul><hr
/><p><img
style="float:left;" src="http://wpengineer.com/favicon.ico" alt="WP Engineer Favicon"/> Thanks for subscribing our feed! <a
href="http://buysellads.com/buy/detail/3646/" class="liexternal">Sponsor the WP Engineer Blog</a> and get your brand in front of several hundred users per day!<br
/> &copy; <a
href="http://wpengineer.com/" class="liinternal">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p> ]]></content:encoded> <wfw:commentRss>http://wpengineer.com/feed-cache-in-wordpress/feed/</wfw:commentRss> <slash:comments>12</slash:comments> </item> <item><title>WordPress Database Repair Script In 2.9</title><link>http://wpengineer.com/wordpress-database-repair-script-in-2-9/</link> <comments>http://wpengineer.com/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/blog/wp-content/uploads/wprdb11.png" class="liimagelink"><img
src="http://wpengineer.com/blog/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><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WP_ALLOW_REPAIR'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><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" class="liexternal"><code>ANALYZE TABLE</code></a>, <a
href="http://dev.mysql.com/doc/refman/5.1/en/repair-table.html" class="liexternal"><code>REPAIR TABLE</code></a> and <a
href="http://dev.mysql.com/doc/refman/5.1/en/optimize-table.html" class="liexternal"><code>OPTIMIZE TABLE</code></a>.</p><p><a
href="http://wpengineer.com/blog/wp-content/uploads/wprdb.png" class="liimagelink"><img
src="http://wpengineer.com/blog/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
/><h3>Related posts:</h3><ul><li><a
href="http://wpengineer.com/joomla-to-wordpress-content-converter/" rel="bookmark" title="Permanent Link: Joomla to WordPress &#8211; Content Converter!" class="liinternal">Joomla to WordPress &#8211; Content Converter!</a></li><li><a
href="http://wpengineer.com/joomla-fireboard-wordpress-wp-forum-converter/" rel="bookmark" title="Permanent Link: Joomla Fireboard to WordPress WP-FORUM Converter" class="liinternal">Joomla Fireboard to WordPress WP-FORUM Converter</a></li><li><a
href="http://wpengineer.com/use-constants-integrate-wordpress/" rel="bookmark" title="Permanent Link: Use Constants To Integrate WordPress In Other CMS" class="liinternal">Use Constants To Integrate WordPress In Other CMS</a></li><li><a
href="http://wpengineer.com/wordpress-database-functions/" rel="bookmark" title="Permanent Link: WordPress Database Functions" class="liinternal">WordPress Database Functions</a></li><li><a
href="http://wpengineer.com/wordpress-working-with-options/" rel="bookmark" title="Permanent Link: WordPress: Working With Options" class="liinternal">WordPress: Working With Options</a></li></ul><hr
/><p><img
style="float:left;" src="http://wpengineer.com/favicon.ico" alt="WP Engineer Favicon"/> Thanks for subscribing our feed! <a
href="http://buysellads.com/buy/detail/3646/" class="liexternal">Sponsor the WP Engineer Blog</a> and get your brand in front of several hundred users per day!<br
/> &copy; <a
href="http://wpengineer.com/" class="liinternal">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p> ]]></content:encoded> <wfw:commentRss>http://wpengineer.com/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/wordpress-trash-is-coming/</link> <comments>http://wpengineer.com/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/blog/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/blog/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/blog/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/" class="liwp">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/" class="liinternal"> the option of "Canonical Plugins" </a>.<br
/><hr
/><h3>Related posts:</h3><ul><li><a
href="http://wpengineer.com/configure-wordpress-trash/" rel="bookmark" title="Permanent Link: Configure WordPress Trash" class="liinternal">Configure WordPress Trash</a></li><li><a
href="http://wpengineer.com/new-feature-for-wordpress-2-9-wordpress-image-editor/" rel="bookmark" title="Permanent Link: New Feature for WordPress 2.9 &#8211; WordPress Image Editor" class="liinternal">New Feature for WordPress 2.9 &#8211; WordPress Image Editor</a></li><li><a
href="http://wpengineer.com/help-to-raise-money-for-haiti/" rel="bookmark" title="Permanent Link: Help To Raise Money For Haiti!" class="liinternal">Help To Raise Money For Haiti!</a></li><li><a
href="http://wpengineer.com/wp-worldmap-get-to-know-your-wordpress-neighbour/" rel="bookmark" title="Permanent Link: WP Worldmap &#8211; Get to Know Your WordPress Neighbour!" class="liinternal">WP Worldmap &#8211; Get to Know Your WordPress Neighbour!</a></li><li><a
href="http://wpengineer.com/wordpress-outlook-2009/" rel="bookmark" title="Permanent Link: WordPress &#8211; An Outlook For 2009" class="liinternal">WordPress &#8211; An Outlook For 2009</a></li></ul><hr
/><p><img
style="float:left;" src="http://wpengineer.com/favicon.ico" alt="WP Engineer Favicon"/> Thanks for subscribing our feed! <a
href="http://buysellads.com/buy/detail/3646/" class="liexternal">Sponsor the WP Engineer Blog</a> and get your brand in front of several hundred users per day!<br
/> &copy; <a
href="http://wpengineer.com/" class="liinternal">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p> ]]></content:encoded> <wfw:commentRss>http://wpengineer.com/wordpress-trash-is-coming/feed/</wfw:commentRss> <slash:comments>9</slash:comments> </item> <item><title>WordPress Proxysupport</title><link>http://wpengineer.com/wordpress-proxysupport/</link> <comments>http://wpengineer.com/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><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$host</span>       <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;www.php.net&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// host name we are connecting to</span>
<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$port</span>       <span style="color: #339933;">=</span> <span style="color: #cc66cc;">8080</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// port we are connecting to</span>
<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$proxy_host</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// proxy host to use</span>
<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$proxy_port</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// proxy port to use</span>
<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$proxy_user</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// proxy user to use</span>
<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$proxy_pass</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// proxy password to use</span>
<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$_isproxy</span>   <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// set if using a proxy server</span></pre></div></div><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><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WP_PROXY_HOST'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'192.168.84.101'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WP_PROXY_PORT'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'8080'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WP_PROXY_USERNAME'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'my_user_name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WP_PROXY_PASSWORD'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'my_password'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WP_PROXY_BYPASS_HOSTS'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'localhost, www.example.com'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><p>Various references are also in<a
href="http://core.trac.wordpress.org/ticket/4011" class="liwp">Ticket 4011</a>.<br
/><hr
/><p><img
style="float:left;" src="http://wpengineer.com/favicon.ico" alt="WP Engineer Favicon"/> Thanks for subscribing our feed! <a
href="http://buysellads.com/buy/detail/3646/" class="liexternal">Sponsor the WP Engineer Blog</a> and get your brand in front of several hundred users per day!<br
/> &copy; <a
href="http://wpengineer.com/" class="liinternal">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p> ]]></content:encoded> <wfw:commentRss>http://wpengineer.com/wordpress-proxysupport/feed/</wfw:commentRss> <slash:comments>9</slash:comments> </item> <item><title>Use Constants To Integrate WordPress In Other CMS</title><link>http://wpengineer.com/use-constants-integrate-wordpress/</link> <comments>http://wpengineer.com/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><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DIR_ROOT'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'http://example.com'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DIR_STYLESHEETS'</span><span style="color: #339933;">,</span> DIR_ROOT <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/css'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DIR_IMAGES'</span><span style="color: #339933;">,</span> DIR_ROOT <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/images'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DIR_JAVASCRIPT'</span><span style="color: #339933;">,</span> DIR_ROOT <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div><p>In your theme you use the constants like this:</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;">&lt;script src=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> DIR_JAVASCRIPT<span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>/myeffects.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;img src=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> DIR_IMAGES<span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>/myimage.jpg&quot; alt=&quot;foo&quot; /&gt;</pre></div></div><p>Easy, right? Mostly a little stylesheet is enough for special WordPress adjustments, which you load after the stylesheets of the CMS.<br
/><hr
/><h3>Related posts:</h3><ul><li><a
href="http://wpengineer.com/determine-path-to-plugin-and-content-directories/" rel="bookmark" title="Permanent Link: Determine Path To Plugin and Content Directories" class="liinternal">Determine Path To Plugin and Content Directories</a></li><li><a
href="http://wpengineer.com/wordpress-developer-hint/" rel="bookmark" title="Permanent Link: WordPress Developer Hint" class="liinternal">WordPress Developer Hint</a></li><li><a
href="http://wpengineer.com/wordpress-ftp-data-with-constant/" rel="bookmark" title="Permanent Link: WordPress FTP Data With Constant" class="liinternal">WordPress FTP Data With Constant</a></li><li><a
href="http://wpengineer.com/add-wordpress-dashboard-widgets/" rel="bookmark" title="Permanent Link: Add WordPress Dashboard Widgets" class="liinternal">Add WordPress Dashboard Widgets</a></li><li><a
href="http://wpengineer.com/feed-cache-in-wordpress/" rel="bookmark" title="Permanent Link: Feed Cache in WordPress" class="liinternal">Feed Cache in WordPress</a></li></ul><hr
/><p><img
style="float:left;" src="http://wpengineer.com/favicon.ico" alt="WP Engineer Favicon"/> Thanks for subscribing our feed! <a
href="http://buysellads.com/buy/detail/3646/" class="liexternal">Sponsor the WP Engineer Blog</a> and get your brand in front of several hundred users per day!<br
/> &copy; <a
href="http://wpengineer.com/" class="liinternal">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p> ]]></content:encoded> <wfw:commentRss>http://wpengineer.com/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/determine-path-to-plugin-and-content-directories/</link> <comments>http://wpengineer.com/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><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Pre-2.6 compatibility</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'WP_CONTENT_URL'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
	<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'WP_CONTENT_URL'</span><span style="color: #339933;">,</span> get_option<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'siteurl'</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/wp-content'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'WP_CONTENT_DIR'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
	<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'WP_CONTENT_DIR'</span><span style="color: #339933;">,</span> ABSPATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'wp-content'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'WP_PLUGIN_URL'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
	<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'WP_PLUGIN_URL'</span><span style="color: #339933;">,</span> WP_CONTENT_URL<span style="color: #339933;">.</span> <span style="color: #0000ff;">'/plugins'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'WP_PLUGIN_DIR'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
	<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'WP_PLUGIN_DIR'</span><span style="color: #339933;">,</span> WP_CONTENT_DIR <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/plugins'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'WP_LANG_DIR'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
	<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'WP_LANG_DIR'</span><span style="color: #339933;">,</span> WP_CONTENT_DIR <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/languages'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><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" class="liwp">Determining Plugin and Content Directories</a>&#8220;.<br
/><hr
/><h3>Related posts:</h3><ul><li><a
href="http://wpengineer.com/wordpress-return-url/" rel="bookmark" title="Permanent Link: WordPress &#8211; Return URL" class="liinternal">WordPress &#8211; Return URL</a></li><li><a
href="http://wpengineer.com/wordpress-plugin-path/" rel="bookmark" title="Permanent Link: WordPress Plugin-Path" class="liinternal">WordPress Plugin-Path</a></li><li><a
href="http://wpengineer.com/my-hacksphp/" rel="bookmark" title="Permanent Link: Bye Bye my-hacks.php?" class="liinternal">Bye Bye my-hacks.php?</a></li><li><a
href="http://wpengineer.com/embed-wordpress-functions-outside-wordpress/" rel="bookmark" title="Permanent Link: Embed WordPress Functions Outside WordPress" class="liinternal">Embed WordPress Functions Outside WordPress</a></li><li><a
href="http://wpengineer.com/top-level-menu-in-wordpress-27/" rel="bookmark" title="Permanent Link: Top Level Menu In WordPress 2.7" class="liinternal">Top Level Menu In WordPress 2.7</a></li></ul><hr
/><p><img
style="float:left;" src="http://wpengineer.com/favicon.ico" alt="WP Engineer Favicon"/> Thanks for subscribing our feed! <a
href="http://buysellads.com/buy/detail/3646/" class="liexternal">Sponsor the WP Engineer Blog</a> and get your brand in front of several hundred users per day!<br
/> &copy; <a
href="http://wpengineer.com/" class="liinternal">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p> ]]></content:encoded> <wfw:commentRss>http://wpengineer.com/determine-path-to-plugin-and-content-directories/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Database Caching 30/83 queries in 0.561 seconds using disk
Object Caching 1723/1876 objects using disk

Served from: wpengineer.com @ 2010-07-29 12:59:45 -->