<?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; WP</title> <atom:link href="http://wpengineer.com/tag/wp/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=6273</generator> <xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" /> <item><title>Custom Post Type and Permalink</title><link>http://wpengineer.com/custom-post-type-and-permalink/</link> <comments>http://wpengineer.com/custom-post-type-and-permalink/#comments</comments> <pubDate>Wed, 28 Jul 2010 13:37:05 +0000</pubDate> <dc:creator>Frank</dc:creator> <category><![CDATA[WordPress News]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Plugin]]></category> <category><![CDATA[WordPress]]></category> <category><![CDATA[WP]]></category> <category><![CDATA[WP3.0]]></category><guid
isPermaLink="false">http://wpengineer.com/?p=2044</guid> <description><![CDATA[Since WordPress 3.0 you can use Custom Post Types and you can define your own types of content - it's more like pages than posts! Thereby you can use automatically the Permalink structure of your WordPress installation. That means, if you create a new post type, you can use Permalinks. But the Permalinks only work [...]]]></description> <content:encoded><![CDATA[<p>Since WordPress 3.0 you can use <a
href="http://wpengineer.com/impressions-of-custom-post-type/" class="liinternal">Custom Post Types</a> and you can define your own types of content - it's more like pages than posts! Thereby you can use automatically the Permalink structure of your WordPress installation. That means, if you create a new post type, you can use Permalinks.</p><p>But the Permalinks only work if you recreate the Rewrite Rules of WordPress - that's why many users initially have problems with it. If you create a new post type you probably get a 404 if you open this page because WordPress doesn't know the URL-structure in your Permalinks since you didn't create the Rewrite Rules again.</p><p>The easiest way is to safe the Permalink structure in your settings again. Alternatively you can include in your Plugin or Theme the function <code>flush_rewrite_rules()</code>. This enables to create the Rewrite Rules again.<br
/><hr
/><h3>Related posts:</h3><ul><li><a
href="http://wpengineer.com/impressions-of-custom-post-type/" rel="bookmark" title="Permanent Link: First Impressions of Custom Post Type" class="liinternal">First Impressions of Custom Post Type</a></li><li><a
href="http://wpengineer.com/custom-fields-in-your-feed/" rel="bookmark" title="Permanent Link: Custom Fields in your Feed" class="liinternal">Custom Fields in your Feed</a></li><li><a
href="http://wpengineer.com/wordpress-3-0-custom-background-support/" rel="bookmark" title="Permanent Link: WordPress 3.0 Custom Background Support" class="liinternal">WordPress 3.0 Custom Background Support</a></li><li><a
href="http://wpengineer.com/sort-posts-custom-fields/" rel="bookmark" title="Permanent Link: Sort Posts With The Help Of Custom Fields" class="liinternal">Sort Posts With The Help Of Custom Fields</a></li><li><a
href="http://wpengineer.com/create-your-own-wordpress-login-design/" rel="bookmark" title="Permanent Link: Create Your Own WordPress Login Design" class="liinternal">Create Your Own WordPress Login Design</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/custom-post-type-and-permalink/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>Individual Design for any Page</title><link>http://wpengineer.com/individual-design-for-any-page/</link> <comments>http://wpengineer.com/individual-design-for-any-page/#comments</comments> <pubDate>Tue, 20 Jul 2010 13:55:52 +0000</pubDate> <dc:creator>Frank</dc:creator> <category><![CDATA[WordPress Tutorials]]></category> <category><![CDATA[Code]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[template_tag]]></category> <category><![CDATA[Theme]]></category> <category><![CDATA[WordPress]]></category> <category><![CDATA[WP]]></category><guid
isPermaLink="false">http://wpengineer.com/?p=2043</guid> <description><![CDATA[The blog has a Theme and for every page an extra style sheet. This current trend of individuality for each content is very common today. Even with WordPress, you can do so; there are several possibilities. One possibility is to create, based on the title, the individual stylesheet. By default, the class assignment of function [...]]]></description> <content:encoded><![CDATA[<p>The blog has a Theme and for every page an extra style sheet. This current trend of individuality for each content is very common today. Even with WordPress, you can do so; there are several possibilities. One possibility is to create, based on the title, the individual stylesheet.<br
/> By default, the class assignment of function <a
href="http://codex.wordpress.org/Template_Tags/body_class" title="more informations in the Codex of WordPress" class="liwp"><code>body_class()</code></a> has already a lot of possibilities. More individuality can be reached with the title or ID.<br
/> It is certainly not worth for a traditional blog environment but for a site with little content it works pretty well. As I have implemented in this case.<br
/> <span
id="more-2043"></span><br
/> If a page is loaded, then you can pass the title. If you use this one in the body tag as ID or class and then create for each <code>ID</code> or <code>class</code> a style, the right design will be loaded.</p><p>Alternatively, you can work with the ID of the page or article, function the_ID() passes it. Please note, IDs and classes may not start with a number and therefore you must add a string before, for example:</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;">&lt;div id=&quot;page-<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_ID<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;</pre></div></div><p>As a final alternative, I would like to mention that you can expand the function <code>body_class()</code> via Hook with own classes. So you can have the title of a page/post via hook in this function.</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> fb_title_body_class<span style="color: #009900;">&#40;</span><span style="color: #000088;">$classes</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$post</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$classes</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> sanitize_title_with_dashes<span style="color: #009900;">&#40;</span> get_the_title<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$classes</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_filter<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'body_class'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'fb_title_body_class'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><p>In the following I'm showing you the simplest case via title, so that you output only this class and and <code>body_class()</code> is not used.</p><h4>With the help of the Title</h4><p>Put the stylesheet in the header of your Theme:</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;">&lt;link rel=&quot;stylesheet&quot; href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'template_url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>/custom.css&quot; type=&quot;text/css&quot; media=&quot;screen&quot; /&gt;</pre></div></div><p>Alternatively, this is integrated via Hook <code>wp_head</code> if the specific page is loaded, so you load the explicit style sheet only if it is needed. Everything happens in the <code> functions.php</code> of your Theme.</p><p>in your body tag of <code>page.php</code> is the title of the page:</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;">&lt;body class=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> sanitize_title_with_dashes<span style="color: #009900;">&#40;</span> get_the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;</pre></div></div><p>Therefore the page "My Home" has the body tag:</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>body <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;my-home&quot;</span><span style="color: #339933;">&gt;</span>
and so on<span style="color: #339933;">...</span></pre></div></div><p>in your <code>custom.css</code> you define all style for class home: for example</p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.my-home</span> a <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#090</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.my-home</span> a<span style="color: #3333ff;">:visited </span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#999</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.my-home</span> a<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#f60</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div><p>in the original Theme it looks like this:</p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;">a <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#009</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">underline</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
a<span style="color: #3333ff;">:visited </span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#999</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">underline</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
a<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#c00</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">underline</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div><p>I think it's an approach with a lot potential and so I leave it to your creativity. So if you would like to have for each page a different style sheet, this is an easy solution.</p><p>Alternativ a small plugin to add the title of the post to the template tag <code>body_class()</code> as example.</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: #009933; font-style: italic;">/**
 * Plugin Name: Title 2 body_class
 * Plugin URI: http://bueltge.de/wordpress-theme-in-abhaengigkeit-des-titel/397/
 * Text Domain: title2bodyclass
 * Domain Path: /languages
 * Description: Add the title of the post to the boy_class-function
 * Author: Frank B&amp;uuml;ltge
 * Version: 0.1
 * Author URI: http://bueltge.de/
 * Donate URI: http://bueltge.de/wunschliste/
 * License: GPL
 * Last change: 26.07.2010 10:37:23
 */</span> 
&nbsp;
<span style="color: #009933; font-style: italic;">/**
License:
==============================================================================
Copyright 2010 Frank Bueltge  (email : frank@bueltge.de)
&nbsp;
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
&nbsp;
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
&nbsp;
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
&nbsp;
Requirements:
==============================================================================
This plugin requires WordPress &gt;= 2.8 and tested with PHP Interpreter &gt;= 5.2.9
*/</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #990000;">class_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'title2body_class'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wp_version</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;">function_exists</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'add_action'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #990000;">version_compare</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$wp_version</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;2.8alpha&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&lt;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">function_exists</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'add_action'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #000088;">$exit_msg</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'The plugin requires WordPress 2.8 or newer. &lt;a href=&quot;http://codex.wordpress.org/Upgrading_WordPress&quot;&gt;Please update WordPress&lt;/a&gt; or delete the plugin.'</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">else</span>
            <span style="color: #000088;">$exit_msg</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
        <span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Status: 403 Forbidden'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HTTP/1.1 403 Forbidden'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #990000;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$exit_msg</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">class</span> title2body_class<span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'FB_T2BC_BASEDIR'</span><span style="color: #339933;">,</span> <span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span> plugin_basename<span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</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;">'FB_T2BC_TEXTDOMAIN'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'title2bodyclass'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
            add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'body_class'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'title_body_class'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">function</span> title_body_class<span style="color: #009900;">&#40;</span><span style="color: #000088;">$classes</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$post</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #000088;">$classes</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> sanitize_title_with_dashes<span style="color: #009900;">&#40;</span> get_the_title<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #b1b100;">return</span> <span style="color: #000088;">$classes</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">function</span> title2body_class_start<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">new</span> title2body_class<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'plugins_loaded'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'title2body_class_start'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div><hr
/><h3>Related posts:</h3><ul><li><a
href="http://wpengineer.com/change-your-wordpress-theme-on/" rel="bookmark" title="Permanent Link: Change your WordPress Theme on Dependency" class="liinternal">Change your WordPress Theme on Dependency</a></li><li><a
href="http://wpengineer.com/use-metaboxes-in-your-theme-or-plugin/" rel="bookmark" title="Permanent Link: Use Metaboxes In Your Theme Or Plugin" class="liinternal">Use Metaboxes In Your Theme Or Plugin</a></li><li><a
href="http://wpengineer.com/join-to-design-a-graphic-for-the-new-maintenance-mode-plugin/" rel="bookmark" title="Permanent Link: Join To Design A Graphic For The New Maintenance Mode Plugin" class="liinternal">Join To Design A Graphic For The New Maintenance Mode Plugin</a></li><li><a
href="http://wpengineer.com/new-navi-design-in-wordpress-27/" rel="bookmark" title="Permanent Link: New Navi-Design in WordPress 2.7" class="liinternal">New Navi-Design in WordPress 2.7</a></li><li><a
href="http://wpengineer.com/removing-wordpress-login-design/" rel="bookmark" title="Permanent Link: Removing WordPress Login Design" class="liinternal">Removing WordPress Login Design</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/individual-design-for-any-page/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>WordPress Import Not Include In WP Core</title><link>http://wpengineer.com/wordpress-import-not-include-in-wp-core/</link> <comments>http://wpengineer.com/wordpress-import-not-include-in-wp-core/#comments</comments> <pubDate>Wed, 30 Jun 2010 09:30:34 +0000</pubDate> <dc:creator>Frank</dc:creator> <category><![CDATA[WordPress News]]></category> <category><![CDATA[Code]]></category> <category><![CDATA[development]]></category> <category><![CDATA[Plugin]]></category> <category><![CDATA[WordPress]]></category> <category><![CDATA[WordPress Plugins]]></category> <category><![CDATA[WP]]></category> <category><![CDATA[WP3.0]]></category><guid
isPermaLink="false">http://wpengineer.com/?p=2026</guid> <description><![CDATA[WordPress came with several new or changed features - one feature which changed is the functionality to import content from other systems. WordPress offers under "Tools" to import data of other applications or a XML-file of another WordPress installation. But since WordPress 3.0 you need a Plugin because it is no longer in WordPress core. [...]]]></description> <content:encoded><![CDATA[<p>WordPress came with several new or changed features - one feature which changed is the functionality to import content from other systems.<br
/> <span
id="more-2026"></span><br
/> WordPress offers under "Tools" to import data of other applications or a XML-file of another WordPress installation. But since WordPress 3.0 you need a Plugin because it is no longer in WordPress core. The installation of the Plugin is easy and has the usual steps to activate a Plugin.</p><p><a
href="http://wpengineer.com/blog/wp-content/uploads/wp-importer.png" class="liimagelink"><img
src="http://wpengineer.com/blog/wp-content/uploads/wp-importer-300x112.png" alt="" title="wp-importer" width="300" height="112" class="aligncenter size-medium wp-image-2027" /></a></p><p>This is the first time, that WordPress is going into the direction of using <a
href="http://wpengineer.com/core-plugins/" class="liinternal">Core-Plugins</a>. There are many formats available if you check out the <a
href="http://wordpress.org/extend/plugins/profile/wordpressdotorg" class="liwp">profile of WordPress</a>, and maybe someone can create additional importers for other formats.<br
/><hr
/><h3>Related posts:</h3><ul><li><a
href="http://wpengineer.com/wordpress-27-update-core/" rel="bookmark" title="Permanent Link: WordPress 2.7 Update Core" class="liinternal">WordPress 2.7 Update Core</a></li><li><a
href="http://wpengineer.com/use-wordpress-voting/" rel="bookmark" title="Permanent Link: Use WordPress Voting" class="liinternal">Use WordPress Voting</a></li><li><a
href="http://wpengineer.com/wordpress-28-small-insights/" rel="bookmark" title="Permanent Link: WordPress 2.8 &#8211; Small Insights" class="liinternal">WordPress 2.8 &#8211; Small Insights</a></li><li><a
href="http://wpengineer.com/use-javascript-libraries-in-and-of-wordpress/" rel="bookmark" title="Permanent Link: Use JavaScript Libraries In And Of WordPress">Use JavaScript Libraries In And Of WordPress</a></li><li><a
href="http://wpengineer.com/improve-seo-in-wordpress-with-the-wpseo-wordpress-plugin/" rel="bookmark" title="Permanent Link: Improve SEO In WordPress With The wpSEO WordPress Plugin" class="liinternal">Improve SEO In WordPress With The wpSEO WordPress Plugin</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-import-not-include-in-wp-core/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>List All Subcategories</title><link>http://wpengineer.com/list-all-subcategories/</link> <comments>http://wpengineer.com/list-all-subcategories/#comments</comments> <pubDate>Tue, 15 Jun 2010 09:42:30 +0000</pubDate> <dc:creator>Frank</dc:creator> <category><![CDATA[WordPress Hacks]]></category> <category><![CDATA[categories]]></category> <category><![CDATA[list]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[subcategories]]></category> <category><![CDATA[template tag]]></category> <category><![CDATA[Theme]]></category> <category><![CDATA[WordPress]]></category> <category><![CDATA[WP]]></category><guid
isPermaLink="false">http://wpengineer.com/?p=2025</guid> <description><![CDATA[Sometimes you just need a list of all child categories only and nothing else. The requirements of projects can be very diverse, as the solution can, and in my case it is a small code snippet that takes care of the output of Subcategories. Something for you to play, improve and expand. Enjoy! $echo = [...]]]></description> <content:encoded><![CDATA[<p>Sometimes you just need a list of all child categories only and nothing else. The requirements of projects can be very diverse, as the solution can, and in my case it is a small code snippet that takes care of the output of Subcategories. Something for you to play, improve and expand. Enjoy!<br
/> <span
id="more-2025"></span></p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$echo</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;ul&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$childcats</span> <span style="color: #339933;">=</span> get_categories<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'child_of='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$cat</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&amp;hide_empty=1'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$childcats</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$childcat</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$childcat</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">category_parent</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$echo</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;li&gt;&lt;a href=&quot;'</span> <span style="color: #339933;">.</span> get_category_link<span style="color: #009900;">&#40;</span><span style="color: #000088;">$childcat</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cat_ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; title=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$childcat</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">category_description</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;&gt;'</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$echo</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$childcat</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cat_name</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/a&gt;'</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$echo</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;/li&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$echo</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;/ul&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$echo</span><span style="color: #339933;">;</span></pre></div></div><hr
/><h3>Related posts:</h3><ul><li><a
href="http://wpengineer.com/exclude-subcategories-in-a-loop/" rel="bookmark" title="Permanent Link: Exclude Subcategories in a Loop" class="liinternal">Exclude Subcategories in a Loop</a></li><li><a
href="http://wpengineer.com/we-made-it-on-the-list-of-the-coolest-blog-powered-by-wordpress/" rel="bookmark" title="Permanent Link: We Made It On The List Of The Coolest Blog Powered By WordPress" class="liinternal">We Made It On The List Of The Coolest Blog Powered By WordPress</a></li><li><a
href="http://wpengineer.com/related-posts-on-category/" rel="bookmark" title="Permanent Link: Related Posts on Category" class="liinternal">Related Posts on Category</a></li><li><a
href="http://wpengineer.com/wordpress-plugin-compatibility-checker/" rel="bookmark" title="Permanent Link: WordPress Plugin Compatibility Checker" class="liinternal">WordPress Plugin Compatibility Checker</a></li><li><a
href="http://wpengineer.com/set-options-on-activation-themes/" rel="bookmark" title="Permanent Link: Set options on activation Themes" class="liinternal">Set options on activation Themes</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/list-all-subcategories/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>Flattr Button for WordPress without a Plugin</title><link>http://wpengineer.com/flattr-button-4-wordpress-without-a-plugin/</link> <comments>http://wpengineer.com/flattr-button-4-wordpress-without-a-plugin/#comments</comments> <pubDate>Thu, 10 Jun 2010 08:15:45 +0000</pubDate> <dc:creator>Frank</dc:creator> <category><![CDATA[WordPress Tutorials]]></category> <category><![CDATA[Code]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Plugin]]></category> <category><![CDATA[Theme]]></category> <category><![CDATA[WordPress]]></category> <category><![CDATA[WordPress Themes]]></category> <category><![CDATA[WP]]></category><guid
isPermaLink="false">http://wpengineer.com/?p=2022</guid> <description><![CDATA[There is a lot talking about Flattr and the idea certainly is worth a try. That's why I wanted to test and integrate Flattr in our blog. However, I don't really like the Plugin and that's why I created a small little function, which integrates the button as you can see right under the tweets [...]]]></description> <content:encoded><![CDATA[<p><img
src="http://wpengineer.com/blog/wp-content/uploads/flattr-logo-beta.png" alt="" title="flattr-logo-beta" width="218" height="43" class="alignright size-full wp-image-2023" /><br
/> There is a lot talking about <a
href="http://flattr.com/" class="liexternal">Flattr</a> and the idea certainly is worth a try. That's why I wanted to test and integrate Flattr in our blog. However, I don't really like the Plugin and that's why I created a small little function, which integrates the button as you can see right under the tweets of each post.<br
/> <span
id="more-2022"></span></p><h4>The function</h4><p>The following small function goes in the <code>functions.php</code> of the themes or outsourced in a Plugin. It depends what is your opinion - for me it is theme-specific and thus a function of the theme and therefore in the <code>functions.php</code> of the theme.</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Flattr Button in WordPress Templates
 *
 * @author Frank Bültge
 * @link   Flattr API https://flattr.com/support/api
 * @param  integer  $uid   personal user ID
 * @param  string   $cat   Flattr category: text, images, video, audio, software or rest.
 * @param  string   $btn   Type of Flattr button: '' or 'compact'
 * @param  integer  $hide  Use this to hide the thing from listings on flattr.com. The value 1 will hide the thing.
 *
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> fb_flattr_link<span style="color: #009900;">&#40;</span><span style="color: #000088;">$uid</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$cat</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'text'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$btn</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'compact'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$hide</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000088;">$uid</span>  <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span> <span style="color: #000088;">$uid</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$cat</span>  <span style="color: #339933;">=</span> <span style="color: #990000;">htmlspecialchars</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cat</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$btn</span>  <span style="color: #339933;">=</span> <span style="color: #990000;">htmlspecialchars</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$btn</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$hide</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span> <span style="color: #000088;">$hide</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$noflattr</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$noflattr</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span> get_post_meta<span style="color: #009900;">&#40;</span> get_the_ID<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'noflattr'</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>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #000088;">$uid</span> <span style="color: #009900;">&#41;</span>
		<span style="color: #000088;">$uid</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span> get_post_meta<span style="color: #009900;">&#40;</span> get_the_ID<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'flattrid'</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>
&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;">'WPLANG'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
		<span style="color: #000088;">$locale</span> <span style="color: #339933;">=</span> WPLANG<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;">$locale</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
		<span style="color: #000088;">$locale</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'en_US'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$ftag</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$tags</span> <span style="color: #339933;">=</span> get_the_tags<span style="color: #009900;">&#40;</span> get_the_ID<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$tags</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$tags</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$tag</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$ftag</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$tag</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">', '</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000088;">$ftag</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$ftag</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">2</span> <span style="color: #009900;">&#41;</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: #000088;">$tag</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000088;">$dsc</span> <span style="color: #339933;">=</span> <span style="color: #990000;">htmlspecialchars</span><span style="color: #009900;">&#40;</span> <span style="color: #990000;">strip_tags</span><span style="color: #009900;">&#40;</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span> get_the_excerpt<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$dsc</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;'&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dsc</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$dsc</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dsc</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// maybe \r\n</span>
&nbsp;
	<span style="color: #000088;">$tle</span> <span style="color: #339933;">=</span> <span style="color: #990000;">htmlspecialchars</span><span style="color: #009900;">&#40;</span> <span style="color: #990000;">strip_tags</span><span style="color: #009900;">&#40;</span> get_the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$tle</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;'&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$tle</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$flattr</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'
	&lt;span class=&quot;flattr&quot;&gt;
		&lt;script type=&quot;text/javascript&quot;&gt;
			var flattr_uid  = \''</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$uid</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'\';
			var flattr_url  = \''</span> <span style="color: #339933;">.</span> get_permalink<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'\';
			var flattr_tle  = \''</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$tle</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'\';
			var flattr_dsc  = \''</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$dsc</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'\';
			var flattr_cat  = \''</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$cat</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'\';
			var flattr_lng  = \''</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$locale</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'\';
			var flattr_tag  = \''</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$ftag</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'\';
			var flattr_btn  = \''</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$btn</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'\';
			var flattr_hide = '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$hide</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">';
		&lt;/script&gt;
		&lt;script src=&quot;http://api.flattr.com/button/load.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
	&lt;/span&gt;
	'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #000088;">$noflattr</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">0</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$uid</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$flattr</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div><h4>Usage</h4><p>Within the template for your posts the above function will be called, the call would normally be appropriate in the <code>single.php</code> of the theme.</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;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'fb_flattr_link'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> fb_flattr_link<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$uid</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'YOUR_UID'</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>There is a query in this code, which checks a custom field with the name flattrid. There you can put an ID, so you can use the button in dependency of different authors. You can use the above function without the use of the parameter $uid , like this:</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;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'fb_flattr_link'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> fb_flattr_link<span style="color: #009900;">&#40;</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>The button will only show if the custom field contains a flattrid and if the following field noflattr is not 1.</p><p>I also added a custom field - if you use this just type <code>noflattr</code> and as the value <code>1</code>, then the button won't display. I think there are posts that do not need a flattr button, for example because it is a guest post.</p><p><a
href="http://wpengineer.com/blog/wp-content/uploads/noflattr.png" class="liimagelink"><img
src="http://wpengineer.com/blog/wp-content/uploads/noflattr-300x104.png" alt="" title="noflattr" width="300" height="104" class="aligncenter size-medium wp-image-2024" /></a></p><p>The button will be displayed within the span-element with the class <code>flattr</code> and can be addressed via CSS, here a small example:</p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.flattr</span> <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div><p>The function can be expanded in many ways, for example a profile field on authors profile page for the ID can help, better as an custom field.</p><p>You can also outsource everything in Metaboxes, thus making it more user-friendly and automatically showing it before the content or in your feed. Since Flattr provides its own Plugin, I didn't wanted to build a Plugin and who may use the function can extend it accordingly, if the current functionality is not enough.<br
/><hr
/><h3>Related posts:</h3><ul><li><a
href="http://wpengineer.com/theme-uninstaller/" rel="bookmark" title="Permanent Link: 5th Post Of Our Advent Calendar: Theme Uninstaller" class="liinternal">5th Post Of Our Advent Calendar: Theme Uninstaller</a></li><li><a
href="http://wpengineer.com/use-wordpress-login/" rel="bookmark" title="Permanent Link: Use WordPress Login" class="liinternal">Use WordPress Login</a></li><li><a
href="http://wpengineer.com/show-amount-of-posts-pages-categories-tags-comments-for-wordpress-themes/" rel="bookmark" title="Permanent Link: Show Amount Of Posts, Pages, Categories, Tags, Comments For WordPress Themes" class="liinternal">Show Amount Of Posts, Pages, Categories, Tags, Comments For WordPress Themes</a></li><li><a
href="http://wpengineer.com/tweet-this-with-wordpress/" rel="bookmark" title="Permanent Link: Tweet This with WordPress" class="liinternal">Tweet This with WordPress</a></li><li><a
href="http://wpengineer.com/warning-message-for-self-customized-plugins/" rel="bookmark" title="Permanent Link: Warning Message For Self Customized Plugins" class="liinternal">Warning Message For Self Customized Plugins</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/flattr-button-4-wordpress-without-a-plugin/feed/</wfw:commentRss> <slash:comments>7</slash:comments> </item> <item><title>Our WordPress Developer Toolbox</title><link>http://wpengineer.com/our-wordpress-developer-toolbox/</link> <comments>http://wpengineer.com/our-wordpress-developer-toolbox/#comments</comments> <pubDate>Fri, 21 May 2010 05:52:47 +0000</pubDate> <dc:creator>Frank</dc:creator> <category><![CDATA[WordPress Tutorials]]></category> <category><![CDATA[development]]></category> <category><![CDATA[Plugin]]></category> <category><![CDATA[WordPress]]></category> <category><![CDATA[WP]]></category><guid
isPermaLink="false">http://wpengineer.com/?p=2011</guid> <description><![CDATA[Again and again the question comes in: What do you use as an environment to develop with WordPress. Some suggestions I would like to give, these are just my preferences, but I would be happy if you tell me your preferences of tools. Maybe there is one or the other useful tool included, I never [...]]]></description> <content:encoded><![CDATA[<p>Again and again the question comes in: What do you use as an environment to develop with WordPress. Some suggestions I would like to give, these are just my preferences, but I would be happy if you tell me your preferences of tools. Maybe there is one or the other useful tool included, I never heard of.<br
/> <span
id="more-2011"></span></p><h4>Platform</h4><p>Currently I am working on Windows and Linux, so that should be a priority, that I can use my tools on both platforms. This is important to me because I consider a heterogeneous environment for conducive.</p><h4>Browser</h4><p>In my everyday environment of web development, I work primarily in the browser and the editor, therefore, these two tools for me are also the center of my work.</p><p>My favorite browser is <a
href="http://www.mozilla-europe.org/de/firefox/" class="liexternal">Firefox</a>, especially because of the great Add-ons. Therefore I have to mention the awesome Add-on <a
href="http://getfirebug.com/" class="liexternal">FireBug</a> , I cannot imagine to work without it. For this Add-on there are even <a
href="http://getfirebug.com/downloads#extensions" class="liexternal">more Add-ons</a>, which I also use and recommend, especially <a
href="http://developer.yahoo.com/yslow/" class="liexternal">YSlow</a>, <a
href="http://www.firephp.org/" class="liexternal">FirePHP</a> and <a
href="http://code.google.com/intl/de-DE/speed/page-speed/" class="liexternal">Page Speed</a>.</p><p>Also I like to use the Add-on <a
href="http://chrispederick.com/work/web-developer/features/" class="liexternal">Web Developer</a> to get access to certain content of the website, like Cookies or JavaScript. The possibilities of Web Developer are tremendous and therefore a wonderful tool. Some functionalities are included in Firebug and Web Developer, you have to decide which functions you like more in each Add-on.</p><h4>Editor</h4><p>Another important tool is the editor, and my favorite is <a
href="http://www.ultraedit.com/" class="liexternal">UltraEdit</a>. An editor, which is not Open Source, but I love to use since several years. Here I guess mainly the speed of the editor and the wonderful extensibility with your own tools is the part I really like. That's why I parse PHP and validate HTML and CSS directly in the editor. For the parsing of CSS I also use <a
href="http://csstidy.sourceforge.net/" class="liexternal">CSSTidy</a>, also available online. I parse PHP via web server that is integrated in the editor and also integrated via <a
href="http://www.icosaedro.it/phplint/" class="liexternal"> PHPLint</a>, also in the additional tools of the editor.</p><p>Under Linux I can not quite decide whether I should use <a
href="http://www.geany.org/" class="liexternal"> Geany</a> or <a
href="http://netbeans.org/" class="liexternal">NetBeans</a>, where NetBeans is already too slow and I really miss one or the other feature in Geany. UE is currently still in the testing and beta phase and we'll see, maybe I can not yet get away off this editor.</p><h4>Webserver &#038; Tools</h4><p>There are two other important tools to use in the context of web development. I work on the local environment under Windows with <a
href="http://www.apachefriends.org/de/xampp.html" class="liexternal">XAMPP</a> and in Linux is the local web environment installed via package manager. So I have on each client an environment to work with PHP and mySQL.</p><p>Important in the development with PHP is error and warning output and debugging. In PHP, there are several different approaches and I use the module <a
href="http://xdebug.org/" class="liexternal">xdebug</a>.<br
/> Furthermore, I write in the context the ErrorLog and evaluate them. The last tool I would like to point out is <a
href="http://code.google.com/p/webgrind/" class="liexternal">Webgrind</a>, which is used as a web application. Alternatively, there are desktop tools that perform this work, for example <a
href="http://sourceforge.net/projects/wincachegrind/" class="liexternal">WinCacheGrind</a> under Windows. This evaluates perfectly the profiling and optimizes your code.</p><h4>FTP</h4><p>To get the development on the server, it usually requires a tool, which dominates the FTP protocol and provides a possible interface for managing the accounts. Here I use under Windows <a
href="http://www.ghisler.com" class="liexternal">Total Commander</a>, which can be perfectly adapted to your needs and I love it that I can open multiple connections in several tabs. On Linux I use the Add-on for Firefox <a
href="http://fireftp.mozdev.org/" class="liexternal">FireFTP</a>. There are several more tools, but I've never found the time to look at various other options.</p><h4>WordPress</h4><p>As I develop primarily in and for WordPress, I have a few small Plugins in the test environment active, which ease my view on certain data, and which specifically save errors or issues in WordPress. A small list with short explanation of Plugins, even if I don't use all of them, but there might be one or two in this list you like.</p><ul><li><a
href="http://wordpress.org/extend/plugins/wp-developer-assistant/" class="liwp">WP Developer Assistant</a> - because it has some reports and feature, which are very handy</li><li><a
href="http://www.code-styling.de/english/development/wordpress-plugin-codestyling-localization-en" class="liexternal">CodeStyling Localization</a> - because you can create a Plugin multilingual, it's easy to create new language files</li><li><a
href="http://striderweb.com/nerdaphernalia/features/wp-log-deprecated-calls/" class="liexternal">Log Deprecated Calls</a> - not always in use, but can be useful</li><li><a
href="http://www.mittineague.com/dev/er.php" class="liexternal">Error Reporting</a></li><li><a
href="http://bueltge.de/wordpress-performance-analysieren-plugin/558/" class="liexternal">Debug Queries</a> - Analysis of queries</li><li><a
href="http://bueltge.de/debug-objects-wordpress-plugin/966/" class="liexternal">Debug Objects</a> - Evaluates many values</li><li><a
href="http://www.adminer.org/en/" class="liexternal">Adminer</a> - for the fast access to your webspace or as <a
href="http://bueltge.de/adminer-fuer-wordpress/1014/" class="liexternal">Plugin</a> directly in your WordPress</li><li><a
href="http://www.firephp.org/" class="liexternal">FirePHP</a> - as <a
href="http://bueltge.de/firephp-und-wordpress/944/" class="liexternal">Plugin</a> for WordPress to access specific content without crawling through your source code</li><li><a
href="http://jeffsayre.com/2010/04/29/introducing-wordpress-hook-sniffer-a-developer-plugin/" class="liexternal">WordPress Hook Sniffer</a> - interest idea; bad is the replacing of the core-file plugin.php</li></ul><p>That should be enough, even there are many more for sure. The decisive factor, in my view are not the Plugins, but the environment with xDebug and the settings that WordPress offers as standard in this context. Therefore, I can only recommend to have the following lines in the <code>wp-config.php</code> of the environment.</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/** Debugging WP */</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WP_DEBUG'</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> <span style="color: #666666; font-style: italic;">//enable the reporting of notices during development - E_ALL</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WP_DEBUG_DISPLAY'</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> <span style="color: #666666; font-style: italic;">//use the globally configured setting for display_errors and not force errors to be displayed</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WP_DEBUG_LOG'</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> <span style="color: #666666; font-style: italic;">//error logging to wp-content/debug.log</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'SCRIPT_DEBUG'</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> <span style="color: #666666; font-style: italic;">//loads the development (non-minified) versions of all scripts and CSS and disables compression and concatenation,</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'E_DEPRECATED'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//E_ALL &amp;amp; ~E_DEPRECATED &amp;amp; ~E_STRICT</span>
&nbsp;
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'AUTOSAVE_INTERVAL'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'300'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>    <span style="color: #666666; font-style: italic;">// Autosave interval</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'SAVEQUERIES'</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>    <span style="color: #666666; font-style: italic;">// Analyse queries</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WP_POST_REVISIONS'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><p>These definitions make the work easily with WordPress and there are many indications of WP to have a clean code and current functions. I change the autosave interval only to small values, if I work in this segment, so if I need the script as soon as possible.</p><h4>Web Applications</h4><p>On the web there are a variety of tools that are useful - I'd like to briefly introduce some them I use often and also to say my thanks to the people who make these services available.</p><ul><li><a
href="http://de2.php.net/" class="liexternal">php.net</a> - because you never get information fast enough, therefore I have in the Firefox Add-on an additional extension for the internal search field, which searches directly in the functions of php.net (<a
href="http://bueltge.de/test/searchplugins/phpnet.php" class="liexternal">You can use it if you like to</a>)</li><li><a
href="http://bueltge.de/test/searchplugins/phpnet.php" class="liexternal">wpseek.com</a> - the search for WordPress, also a search extension for Firefox is available</li><li><a
href="http://xref.yoast.com/" class="liexternal">PHP Cross Reference of WordPress Source</a> - sometimes I'm faster with it than via editor</li></ul><h4>Conclusion</h4><p>A small overview of my latest tools and perhaps you find one of them useful or you have suggestions as well for me.<br
/><hr
/><h3>Related posts:</h3><ul><li><a
href="http://wpengineer.com/3rd-door-today-the-advice-dont-steal-premium-wordpress-themes/" rel="bookmark" title="Permanent Link: 3rd Door &#8211; Today The Advice: Don&#8217;t Steal Premium WordPress Themes" class="liinternal">3rd Door &#8211; Today The Advice: Don&#8217;t Steal Premium WordPress Themes</a></li><li><a
href="http://wpengineer.com/yaml-31-released/" rel="bookmark" title="Permanent Link: YAML 3.1 Released" class="liinternal">YAML 3.1 Released</a></li><li><a
href="http://wpengineer.com/quick-view-on-wordpress-settings/" rel="bookmark" title="Permanent Link: Quick View on WordPress Settings" class="liinternal">Quick View on WordPress Settings</a></li><li><a
href="http://wpengineer.com/wp_page_menu-in-wordpress-27/" rel="bookmark" title="Permanent Link: wp_page_menu in WordPress 2.7" class="liinternal">wp_page_menu in WordPress 2.7</a></li><li><a
href="http://wpengineer.com/a-chance-wordpress-plugin-competition/" rel="bookmark" title="Permanent Link: A Chance: WordPress Plugin Competition" class="liinternal">A Chance: WordPress Plugin Competition</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/our-wordpress-developer-toolbox/feed/</wfw:commentRss> <slash:comments>18</slash:comments> </item> <item><title>Better Plugin List in WordPress 3.0</title><link>http://wpengineer.com/better-plugin-list-in-wordpress-3-0/</link> <comments>http://wpengineer.com/better-plugin-list-in-wordpress-3-0/#comments</comments> <pubDate>Thu, 15 Apr 2010 17:29:48 +0000</pubDate> <dc:creator>Frank</dc:creator> <category><![CDATA[WordPress News]]></category> <category><![CDATA[backend]]></category> <category><![CDATA[Plugin]]></category> <category><![CDATA[WordPress]]></category> <category><![CDATA[WP]]></category> <category><![CDATA[WP3.0]]></category><guid
isPermaLink="false">http://wpengineer.com/?p=1996</guid> <description><![CDATA[One of the main reason why WordPress is so popular is the amount of available Plugins. Most users using Plugins via the most popular way - in the folder plugins under wp-content, and activate them in the backend of WordPress. For other possibilities of plugin integration WordPress 3.0 try to provide a more user friendly [...]]]></description> <content:encoded><![CDATA[<p>One of the main reason why WordPress is so popular is the amount of available Plugins. Most users using Plugins via the most popular way - in the folder <code>plugins</code> under <code>wp-content</code>, and activate them in the backend of WordPress. For other possibilities of plugin integration WordPress 3.0 try to provide a more user friendly way.<br
/> <span
id="more-1996"></span><br
/> WordPress offers many possibilities to hook into the system, sometime they are better and faster.</p><p>For this reason the admin can find a new tab on the Plugin page "Drop-ins", see screenshot below of the current beta 1.</p><p><a
href="http://wpengineer.com/blog/wp-content/uploads/drop-ins-plugins.png" class="liimagelink"><img
src="http://wpengineer.com/blog/wp-content/uploads/drop-ins-plugins-600x207.png" alt="drop-ins-plugins" title="drop-ins-plugins" width="600" height="207" class="aligncenter size-large wp-image-1997" /></a></p><p>In comparison a screenshot of WordPress 2.9.<br
/> <a
href="http://wpengineer.com/blog/wp-content/uploads/drop-ins-plugins2.png" class="liimagelink"><img
src="http://wpengineer.com/blog/wp-content/uploads/drop-ins-plugins2.png" alt="drop-ins-plugins2" title="drop-ins-plugins2" width="270" height="148" class="size-full wp-image-1998" /></a></p><p>There is also a tab for must-use plugins. Plugins can be stored in a "WordPress MU"-plugins folder.<br
/> <a
href="http://wpengineer.com/blog/wp-content/uploads/drop-ins-plugins3.png" class="liimagelink"><img
src="http://wpengineer.com/blog/wp-content/uploads/drop-ins-plugins3.png" alt="must-use-plugins" title="must-use-plugins" width="584" height="176" class="aligncenter size-full wp-image-2000" /></a></p><hr
/><h3>Related posts:</h3><ul><li><a
href="http://wpengineer.com/wordpress-plugin-compatibility-checker/" rel="bookmark" title="Permanent Link: WordPress Plugin Compatibility Checker" class="liinternal">WordPress Plugin Compatibility Checker</a></li><li><a
href="http://wpengineer.com/we-made-it-on-the-list-of-the-coolest-blog-powered-by-wordpress/" rel="bookmark" title="Permanent Link: We Made It On The List Of The Coolest Blog Powered By WordPress" class="liinternal">We Made It On The List Of The Coolest Blog Powered By WordPress</a></li><li><a
href="http://wpengineer.com/list-all-subcategories/" rel="bookmark" title="Permanent Link: List All Subcategories" class="liinternal">List All Subcategories</a></li><li><a
href="http://wpengineer.com/plugin-review-codestyling-localization/" rel="bookmark" title="Permanent Link: Plugin Review: Codestyling Localization" class="liinternal">Plugin Review: Codestyling Localization</a></li><li><a
href="http://wpengineer.com/set-options-on-activation-themes/" rel="bookmark" title="Permanent Link: Set options on activation Themes" class="liinternal">Set options on activation Themes</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/better-plugin-list-in-wordpress-3-0/feed/</wfw:commentRss> <slash:comments>10</slash:comments> </item> <item><title>Customize WordPress WYSIWYG Editor</title><link>http://wpengineer.com/customize-wordpress-wysiwyg-editor/</link> <comments>http://wpengineer.com/customize-wordpress-wysiwyg-editor/#comments</comments> <pubDate>Thu, 18 Feb 2010 14:01:45 +0000</pubDate> <dc:creator>Frank</dc:creator> <category><![CDATA[WordPress Tutorials]]></category> <category><![CDATA[HTML Editor]]></category> <category><![CDATA[TinyMCE]]></category> <category><![CDATA[WordPress]]></category> <category><![CDATA[WP]]></category> <category><![CDATA[WYSIWYG Editor]]></category><guid
isPermaLink="false">http://wpengineer.com/?p=1963</guid> <description><![CDATA[Adjustments to the editor TinyMCE via hook, so regardless of the core files of WordPress is also possible and must be used in a number of requirements. So in this article are some examples that can be adapted to its needs and should give an introduction of customizing the TinyMCE editor in WordPress. You put [...]]]></description> <content:encoded><![CDATA[<p>Adjustments to the editor TinyMCE via hook, so regardless of the core files of WordPress is also possible and must be used in a number of requirements. So in this article are some examples that can be adapted to its needs and should give an introduction of customizing the TinyMCE editor in WordPress.<br
/> <span
id="more-1963"></span><br
/> You put the following code snippet in the <code>functions.php</code> of the theme or stores it into a Plugin. There are a whole range of possibilities and I would like to show only a small range of them. Adjusting the buttons is quite comfortable to do via the Plugin <a
href="http://wordpress.org/extend/plugins/tinymce-advanced/" class="liwp">TinyMCE Advanced</a>.</p><h4>Adjust HTML-Filter</h4><p>The default editor is set to always generate xHTML 1.0 and thus not all tags are allowed; a classic example are iframes, which you use for Google Map for example. Sure there are other approaches via short code, etc., but this is not the today topic. Merely as an example, allowing the tag <code>iframe</code>, with various attributes, and the Tags must be added to the variable <code>$ext</code>.</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> fb_change_mce_options<span style="color: #009900;">&#40;</span><span style="color: #000088;">$initArray</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// Comma separated string od extendes tags</span>
	<span style="color: #666666; font-style: italic;">// Command separated string of extended elements</span>
	<span style="color: #000088;">$ext</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'pre[id|name|class|style],iframe[align|longdesc|name|width|height|frameborder|scrolling|marginheight|marginwidth|src]'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$initArray</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'extended_valid_elements'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$initArray</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'extended_valid_elements'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">','</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$ext</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: #000088;">$initArray</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'extended_valid_elements'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$ext</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #666666; font-style: italic;">// maybe; set tiny paramter verify_html</span>
	<span style="color: #666666; font-style: italic;">//$initArray['verify_html'] = false;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$initArray</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'tiny_mce_before_init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'fb_change_mce_options'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><h4>Customizing the function of the buttons in your Editor</h4><p>A way to expand the block formats (<code>theme_advanced_blockformats</code>) or modify and disable a few buttons in your editor (<code>theme_advanced_disable</code>).</p><p><img
src="http://wpengineer.com/blog/wp-content/uploads/mytinymce-en.png" alt="" title="mytinymce-en" width="468" height="240" class="aligncenter size-full wp-image-1962" /></p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> fb_change_mce_buttons<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$initArray</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">//@see http://wiki.moxiecode.com/index.php/TinyMCE:Control_reference</span>
	<span style="color: #000088;">$initArray</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'theme_advanced_blockformats'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'p,address,pre,code,h3,h4,h5,h6'</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$initArray</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'theme_advanced_disable'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'forecolor'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$initArray</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'tiny_mce_before_init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'fb_change_mce_buttons'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><h4>Change language of spelling</h4><p>In our third case, we adapt the language of the spelling checker, in our example we will now allow German and English only.</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> fb_mce_external_languages<span style="color: #009900;">&#40;</span><span style="color: #000088;">$initArray</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$initArray</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'spellchecker_languages'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'+German=de, English=en'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$initArray</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'tiny_mce_before_init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'fb_mce_external_languages'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><h4>The default values of WordPress</h4><p>Following the values that are used in the standard of wordpress which gives an insight into the possibilities for the transfer of the array.</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #0000ff;">'mode'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'specific_textareas'</span>
<span style="color: #0000ff;">'editor_selector'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'theEditor'</span>
<span style="color: #0000ff;">'width'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'100%'</span>
<span style="color: #0000ff;">'theme'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'advanced'</span>
<span style="color: #0000ff;">'skin'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'wp_theme'</span>
<span style="color: #0000ff;">'theme_advanced_buttons1'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'bold,italic,strikethrough,|,bullist,numlist,blockquote,|,justifyleft,justifycenter,justifyright,|,link,unlink,wp_more,|,spellchecker,fullscreen,wp_adv'</span>
<span style="color: #0000ff;">'theme_advanced_buttons2'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'formatselect,underline,justifyfull,forecolor,|,pastetext,pasteword,removeformat,|,media,charmap,|,outdent,indent,|,undo,redo,wp_help'</span>
<span style="color: #0000ff;">'theme_advanced_buttons3'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span>
<span style="color: #0000ff;">'theme_advanced_buttons4'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span>
<span style="color: #0000ff;">'language'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'de'</span>
<span style="color: #0000ff;">'spellchecker_languages'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,+German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv'</span>
<span style="color: #0000ff;">'theme_advanced_toolbar_location'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'top'</span>
<span style="color: #0000ff;">'theme_advanced_toolbar_align'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'left'</span>
<span style="color: #0000ff;">'theme_advanced_statusbar_location'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'bottom'</span>
<span style="color: #0000ff;">'theme_advanced_resizing'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span>
<span style="color: #0000ff;">'theme_advanced_resize_horizontal'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span>
<span style="color: #0000ff;">'dialog_type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'modal'</span>
<span style="color: #0000ff;">'relative_urls'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span>
<span style="color: #0000ff;">'remove_script_host'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span>
<span style="color: #0000ff;">'convert_urls'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span>
<span style="color: #0000ff;">'apply_source_formatting'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span>
<span style="color: #0000ff;">'remove_linebreaks'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span>
<span style="color: #0000ff;">'gecko_spellcheck'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span>
<span style="color: #0000ff;">'entities'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'38,amp,60,lt,62,gt'</span>
<span style="color: #0000ff;">'accessibility_focus'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span>
<span style="color: #0000ff;">'tabfocus_elements'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'major-publishing-actions'</span>
<span style="color: #0000ff;">'media_strict'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span>
<span style="color: #0000ff;">'paste_remove_styles'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span>
<span style="color: #0000ff;">'paste_remove_spans'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span>
<span style="color: #0000ff;">'paste_strip_class_attributes'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'all'</span>
<span style="color: #0000ff;">'wpeditimage_disable_captions'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span>
<span style="color: #0000ff;">'plugins'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'safari,inlinepopups,spellchecker,paste,wordpress,media,fullscreen,wpeditimage,wpgallery,tabfocus'</span></pre></div></div><hr
/><h3>Related posts:</h3><ul><li><a
href="http://wpengineer.com/disable-html-editor-wordpress/" rel="bookmark" title="Permanent Link: Disable HTML Editor In WordPress" class="liinternal">Disable HTML Editor In WordPress</a></li><li><a
href="http://wpengineer.com/create-your-own-wordpress-login-design/" rel="bookmark" title="Permanent Link: Create Your Own WordPress Login Design" class="liinternal">Create Your Own WordPress Login Design</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/list-all-users-in-wordpress/" rel="bookmark" title="Permanent Link: List All Users in WordPress" class="liinternal">List All Users in WordPress</a></li><li><a
href="http://wpengineer.com/use-metaboxes-in-your-theme-or-plugin/" rel="bookmark" title="Permanent Link: Use Metaboxes In Your Theme Or Plugin" class="liinternal">Use Metaboxes In Your Theme Or Plugin</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/customize-wordpress-wysiwyg-editor/feed/</wfw:commentRss> <slash:comments>16</slash:comments> </item> <item><title>Display Post Thumbnail Also In Edit Post and Page Overview</title><link>http://wpengineer.com/display-post-thumbnail-post-page-overview/</link> <comments>http://wpengineer.com/display-post-thumbnail-post-page-overview/#comments</comments> <pubDate>Tue, 16 Feb 2010 10:51:49 +0000</pubDate> <dc:creator>Frank</dc:creator> <category><![CDATA[WordPress Hacks]]></category> <category><![CDATA[Post Thumbnail]]></category> <category><![CDATA[Theme]]></category> <category><![CDATA[WordPress]]></category> <category><![CDATA[WP]]></category> <category><![CDATA[wp2.9]]></category><guid
isPermaLink="false">http://wpengineer.com/?p=1960</guid> <description><![CDATA[WordPress version 2.9 introduced the function of Post Thumbnail. We wrote about this feature in this post and here and also in many other blogs. I find it an advantage, if the overview of articles and pages also provides the associated thumbnail. Therefore, I would like to introduce a small code snippet that makes just [...]]]></description> <content:encoded><![CDATA[<p>WordPress version 2.9 introduced the function of Post Thumbnail. We wrote about this feature <a
href="http://wpengineer.com/about-wordpress-post-thumbnail/" class="liinternal">in this post</a> and <a
href="http://wpengineer.com/wordpress-2-9-add_theme_support-and-has_post_image/" class="liinternal">here</a> and also in many other blogs. I find it an advantage, if the overview of articles and pages also provides the associated thumbnail. Therefore, I would like to introduce a small code snippet that makes just that.<br
/> <span
id="more-1960"></span></p><p><img
src="http://wpengineer.com/blog/wp-content/uploads/post-thumbnail-edit.png" alt="" title="post-thumbnail-edit" width="450" height="360" class="aligncenter size-full wp-image-1961" /></p><p>The above screenshot should illustrate what the little extension does. The following code must be put in a Plugin or be copied into the <code>functions.php</code> of the theme.</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'fb_AddThumbColumn'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'add_theme_support'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// for post and page</span>
	add_theme_support<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post-thumbnails'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'page'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> fb_AddThumbColumn<span style="color: #009900;">&#40;</span><span style="color: #000088;">$cols</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #000088;">$cols</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'thumbnail'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Thumbnail'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$cols</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> fb_AddThumbValue<span style="color: #009900;">&#40;</span><span style="color: #000088;">$column_name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$post_id</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
			<span style="color: #000088;">$width</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span> <span style="color: #cc66cc;">35</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$height</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span> <span style="color: #cc66cc;">35</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'thumbnail'</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$column_name</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #666666; font-style: italic;">// thumbnail of WP 2.9</span>
				<span style="color: #000088;">$thumbnail_id</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post_id</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'_thumbnail_id'</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>
				<span style="color: #666666; font-style: italic;">// image from gallery</span>
				<span style="color: #000088;">$attachments</span> <span style="color: #339933;">=</span> get_children<span style="color: #009900;">&#40;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post_parent'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$post_id</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post_type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'attachment'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post_mime_type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'image'</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: #000088;">$thumbnail_id</span><span style="color: #009900;">&#41;</span>
					<span style="color: #000088;">$thumb</span> <span style="color: #339933;">=</span> wp_get_attachment_image<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$thumbnail_id</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$width</span><span style="color: #339933;">,</span> <span style="color: #000088;">$height</span><span style="color: #009900;">&#41;</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>
				<span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$attachments</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$attachments</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$attachment_id</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$attachment</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						<span style="color: #000088;">$thumb</span> <span style="color: #339933;">=</span> wp_get_attachment_image<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$attachment_id</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$width</span><span style="color: #339933;">,</span> <span style="color: #000088;">$height</span><span style="color: #009900;">&#41;</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>
					<span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span>
					<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$thumb</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$thumb</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$thumb</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;">echo</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'None'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// for posts</span>
	add_filter<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'manage_posts_columns'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'fb_AddThumbColumn'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'manage_posts_custom_column'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'fb_AddThumbValue'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// for pages</span>
	add_filter<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'manage_pages_columns'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'fb_AddThumbColumn'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'manage_pages_custom_column'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'fb_AddThumbValue'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div><hr
/><h3>Related posts:</h3><ul><li><a
href="http://wpengineer.com/new-feature-in-wordpress-2-9-the_post_image/" rel="bookmark" title="Permanent Link: New feature in WordPress 2.9 &#8211; the_post_image()" class="liinternal">New feature in WordPress 2.9 &#8211; the_post_image()</a></li><li><a
href="http://wpengineer.com/about-wordpress-post-thumbnail/" rel="bookmark" title="Permanent Link: About WordPress Post Thumbnail" class="liinternal">About WordPress Post Thumbnail</a></li><li><a
href="http://wpengineer.com/the-ultimative-guide-for-the_post_thumbnail-in-wordpress-2-9/" rel="bookmark" title="Permanent Link: The Ultimative Guide For the_post_thumbnail In WordPress 2.9" class="liinternal">The Ultimative Guide For the_post_thumbnail In WordPress 2.9</a></li><li><a
href="http://wpengineer.com/wordpress-2-9-add_theme_support-and-has_post_image/" rel="bookmark" title="Permanent Link: WordPress 2.9 add_theme_support and has_post_image" class="liinternal">WordPress 2.9 add_theme_support and has_post_image</a></li><li><a
href="http://wpengineer.com/display-always-subpages-in-sidebar/" rel="bookmark" title="Permanent Link: Display Always All Subpages in Sidebar" class="liinternal">Display Always All Subpages in Sidebar</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/display-post-thumbnail-post-page-overview/feed/</wfw:commentRss> <slash:comments>19</slash:comments> </item> <item><title>Load A Stylesheet Only If Use Gallery</title><link>http://wpengineer.com/load-a-stylesheet-only-if-use-gallery/</link> <comments>http://wpengineer.com/load-a-stylesheet-only-if-use-gallery/#comments</comments> <pubDate>Tue, 26 Jan 2010 13:43:34 +0000</pubDate> <dc:creator>Frank</dc:creator> <category><![CDATA[WordPress Hacks]]></category> <category><![CDATA[gallery]]></category> <category><![CDATA[hack]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Theme]]></category> <category><![CDATA[WordPress]]></category> <category><![CDATA[WordPress Themes]]></category> <category><![CDATA[WordPress Tutorials]]></category> <category><![CDATA[WP]]></category><guid
isPermaLink="false">http://wpengineer.com/?p=1949</guid> <description><![CDATA[In relation to the better Gallery it is actually not necessary to load the stylesheet if there is no gallery, so it is worth it to check in advance whether the gallery will be used in the post or not. For this you have to parse the post which can be done in two ways. [...]]]></description> <content:encoded><![CDATA[<p>In relation to the <a
href="http://wpengineer.com/a-solution-for-the-wordpress-gallery/" better class="liinternal">better Gallery </a> it is actually not necessary to load the stylesheet if there is no gallery, so it is worth it to check in advance whether the gallery will be used in the post or not. For this you have to parse the post which can be done in two ways.<br
/> <span
id="more-1949"></span><br
/> The classic solution is to parse the content and seek the short code, classic PHP <a
href="http://php.net/manual/en/function.strstr.php" class="liexternal"><code>strstr</code></a>. Depending on the result it loads the stylesheet.<br
/> <code>if ( strstr($post->post_content, '[gallery') )</code>.<br
/> This obviously takes time and performance, what you really like to avoid. Thus, it is better if you can parse the post in advance. In this context, there is a <a
href="http://wordpress.org/support/topic/350167#post-1344676" class="liwp">tread in the forum of WordPress</a>, which contains a very nice solution by <a
href="http://w-shadow.com/" class="liexternal">WhiteShadow</a> which you can use to load the stylesheet.</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// onyl css, when post has a gallery</span>
<span style="color: #000000; font-weight: bold;">function</span> gallery_stylesheet<span style="color: #009900;">&#40;</span><span style="color: #000088;">$posts</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$posts</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$posts</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$found</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$posts</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">stripos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_content</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'[gallery'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
			<span style="color: #000088;">$found</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">break</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: #000088;">$found</span><span style="color: #009900;">&#41;</span>
		wp_enqueue_style<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'gallery-stylesheet'</span><span style="color: #339933;">,</span> get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'stylesheet_directory'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/gallery.css'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'screen'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$posts</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'the_posts'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'gallery_stylesheet'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><p>You can also use this to load scripts,</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// onyl js, when post has a gallery</span>
<span style="color: #000000; font-weight: bold;">function</span> my_script<span style="color: #009900;">&#40;</span><span style="color: #000088;">$posts</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$posts</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$posts</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$found</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$posts</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">stripos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_content</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'[my-script) )
			$found = true;
			break;
		}
&nbsp;
	if ($found)
		wp_enqueue_script( '</span>my<span style="color: #339933;">-</span>script<span style="color: #0000ff;">', get_bloginfo('</span>template_directory<span style="color: #0000ff;">') . '</span><span style="color: #339933;">/</span>js<span style="color: #339933;">/</span>my_script<span style="color: #339933;">.</span>js<span style="color: #0000ff;">', false, false, true );
&nbsp;
	return $posts;
}
add_action('</span>the_posts<span style="color: #0000ff;">', '</span>my_script<span style="color: #0000ff;">');</span></pre></div></div><p>For more information, to include JavaScript and CSS files, there is <a
href="http://wpengineer.com/use-javascript-libraries-in-and-of-wordpress/">another post</a> about this topic.<br
/><hr
/><h3>Related posts:</h3><ul><li><a
href="http://wpengineer.com/removing-wordpress-login-design/" rel="bookmark" title="Permanent Link: Removing WordPress Login Design" class="liinternal">Removing WordPress Login Design</a></li><li><a
href="http://wpengineer.com/a-solution-for-the-wordpress-gallery/" rel="bookmark" title="Permanent Link: A Solution For The WordPress Gallery" class="liinternal">A Solution For The WordPress Gallery</a></li><li><a
href="http://wpengineer.com/create-your-own-wordpress-login-design/" rel="bookmark" title="Permanent Link: Create Your Own WordPress Login Design" class="liinternal">Create Your Own WordPress Login Design</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/pages-subpages-is-parent/" rel="bookmark" title="Permanent Link: Pages &#038; Subpages &#8211; Is Parent?" class="liinternal">Pages &#038; Subpages &#8211; Is Parent?</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/load-a-stylesheet-only-if-use-gallery/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 78/125 queries in 1.183 seconds using disk
Object Caching 2932/3154 objects using disk

Served from: wpengineer.com @ 2010-07-29 13:05:43 -->