<?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>The unexpected is what changes our lives. &#187; Plugin Extension</title>
	<atom:link href="http://tobias.baethge.com/info/plugin-extension/feed/" rel="self" type="application/rss+xml" />
	<link>http://tobias.baethge.com</link>
	<description>Website of Tobias Bäthge.</description>
	<lastBuildDate>Thu, 02 Feb 2012 21:25:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Extension 7: Textfield widths on the “Edit” page</title>
		<link>http://tobias.baethge.com/2010/03/extension-7-textfield-widths-on-the-edit-page/</link>
		<comments>http://tobias.baethge.com/2010/03/extension-7-textfield-widths-on-the-edit-page/#comments</comments>
		<pubDate>Fri, 26 Mar 2010 20:26:48 +0000</pubDate>
		<dc:creator>Tobias</dc:creator>
				<category><![CDATA[Plugin Extension]]></category>
		<category><![CDATA[WP Plugins]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://tobias.baethge.com/?p=844</guid>
		<description><![CDATA[A few weeks ago, I was approached with a question on whether it is possible to make the textfields on the &#8220;Edit&#8221; screen of a table wider, to allow for an easier editing of long text. As this might also interest other people, I decided to publish the solution as a WP-Table Reloaded Extension. My [...]]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago, I was approached with a question on whether it is possible to make the textfields on the &#8220;Edit&#8221; screen of a table wider, to allow for an easier editing of long text. As this might also interest other people, I decided to publish the solution as a WP-Table Reloaded Extension.<br />
<span id="more-844"></span></p>
<p>My thanks for making this possible go out to the folks at <a href="http://ningbohotelreview.com">ningboHOTELreview.com</a>. Thanks!</p>
<p>To get started with WP-Table Reloaded Extensions, you should <a href="http://tobias.baethge.com/2009/12/introducing-wp-table-reloaded-extensions/">read the introduction</a> and follow the included instructions. You will also find links to the other presented Extensions there.</p>
<p>Now lets come to the actual code of the Extension:</p>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">/**
 * Change default textfield width on the &quot;Edit&quot; screen
 */
if ( is_admin() ) {
    function wp_table_reloaded_textarea_width_css() {
        ?&gt;
&lt;style type=&quot;text/css&quot; media=&quot;screen&quot;&gt;
            /* Change all columns */
            #table_contents textarea {
                min-width: 400px;
            }
&nbsp;
            /* Change only textareas in column A */
            #table_contents .edit_col_1 textarea {
                min-width: 780px;
            }
        &lt;/style&gt;
&nbsp;
        <span style="color: #000000; font-weight: bold;">&lt;?php</span>
    <span style="color: #009900;">&#125;</span>
    add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;admin_print_styles-<span style="color: #006699; font-weight: bold;">{$WP_Table_Reloaded_Admin-&gt;hook}</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp_table_reloaded_textarea_width_css'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>



<p><strong>Important:</strong> The code from above is not yet ready to use! (Well, it would work, but is not really useful.) Before it will be useful to you, you need to adjust the included CSS code, so that it changes the width to what you want. You can see two sections of CSS code, marked by a comment line above them. The first one is responsible for setting the textfield width on all columns of the &#8220;Edit&#8221; screen. The second example only changes those of the first column. You can copy that section as often as needed (don&#8217;t forget to change the &#8220;.col_1&#8243; to whatever you need). For both sections you can then set the width to any pixel value you like, by simply changing the number after the &#8220;min-width:&#8221; attribute.</p>
<p>Then, the code just needs to be copied into the file &#8220;wp-table-reloaded-extensions.php&#8221;, created according to <a href="http://tobias.baethge.com/wordpress-plugins/wp-table-reloaded-english/extensions/">these instructions</a> (after the Plugin Header comment, but before the closing PHP bracket <code>?&gt;</code>). Then, just activate the new plugin &#8220;WP-Table Reloaded Extensions&#8221;, if you haven&#8217;t. That&#8217;s it! :-)</p>
<p>If you like this series of Extensions, I&#8217;m happy about any feedback, and especially about further suggestions!</p>
<p>Previous posts in this series that might interest you:</p>
<ul>
<li><a href="http://tobias.baethge.com/2009/12/introducing-wp-table-reloaded-extensions/">Announcement and Foundation on Extensions</a></li>
<li><a href="http://tobias.baethge.com/2009/12/extension-1-url-to-link-conversion/">Extension 1: Automatic URL to Links conversion</a></li>
<li><a href="http://tobias.baethge.com/2010/01/extension-2-custom-name-in-the-menu/">Extension 2: Custom Name in the Admin Menu</a></li>
<li><a href="http://tobias.baethge.com/2010/01/extension-3-changing-the-table-shortcode/">Extension 3: Changing the Table Shortcode</a></li>
<li><a href="http://tobias.baethge.com/2010/02/extension-4-changing-datatables-strings/">Extension 4: Changing DataTables strings</a></li>
<li><a href="http://tobias.baethge.com/2010/02/extension-5-how-to-use-php-in-table-cells/">Extension 5: How to use PHP in table cells</a></li>
<li><a href="http://tobias.baethge.com/2010/02/extension-6-showing-only-rows-that-match-a-filter/">Extension 6: Showing only rows that match a filter</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://tobias.baethge.com/2010/03/extension-7-textfield-widths-on-the-edit-page/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>Extension 6: Showing only rows that match a filter</title>
		<link>http://tobias.baethge.com/2010/03/extension-6-showing-only-rows-that-match-a-filter/</link>
		<comments>http://tobias.baethge.com/2010/03/extension-6-showing-only-rows-that-match-a-filter/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 09:24:48 +0000</pubDate>
		<dc:creator>Tobias</dc:creator>
				<category><![CDATA[Plugin Extension]]></category>
		<category><![CDATA[WP Plugins]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[feature]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://tobias.baethge.com/?p=842</guid>
		<description><![CDATA[Some people have approached me with an idea like this one: They have a rather large table which they maintain as a list for some sort of items (e.g. products). On certain pages however, they do not want to show the entire table, but e.g. only items with a certain keyword in a column. That&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>Some people have approached me with an idea like this one: They have a rather large table which they maintain as a list for some sort of items (e.g. products). On certain pages however, they do not want to show the entire table, but e.g. only items with a certain keyword in a column.</p>
<p>That&#8217;s the use case for which the following filtering extension can be used. It adds another parameter <code>filter</code> to the Shortcode that gets passed one or more search terms (connected with a logical operator):</p>


<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[table id=1 filter=&quot;word1&amp;&amp;word2&quot; /]</pre></div></div>



<p>Then, only those rows of the table are shown, that have columns that exactly match the search term(s). In the example, only rows where one column has the exact value &#8220;word1&#8243; and one column has the exact value &#8220;word2&#8243;, will be shown.<br />
<span id="more-842"></span></p>
<p><span style="color:#ff0000;font-weight:bold;">UPDATE</span> for WP-Table Reloaded 1.9: Please see the note below the code, regarding the deactivation of the <span style="color:#ff0000;font-weight:bold;">&#8220;Cache Table Output&#8221;</span> feature!</p>
<p>Let me start with some thanks first: This extension has been made possible by the kind donations or support of Peter Miller, Paulo Correia, PJ Scheufele, Wei-Ni Chong, and Sjoerd Jongerius. Thanks to all of them!</p>
<p>To get started with WP-Table Reloaded Extensions, you should <a href="http://tobias.baethge.com/2009/12/introducing-wp-table-reloaded-extensions/">read the introduction</a> and follow the included instructions. You will also find links to the other presented Extensions there.</p>
<p>Now lets come to the actual code of the Extension:</p>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Show only rows that match the &quot;filter&quot; parameter value/contained logical expression
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> wp_table_reloaded_filter_rows<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$output_options</span><span style="color: #339933;">,</span> <span style="color: #000088;">$table_id</span><span style="color: #339933;">,</span> <span style="color: #000088;">$table</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// early exit if no &quot;filter&quot; parameter given</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;">$output_options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'filter'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$output_options</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$filter</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$output_options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'filter'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// from the Shortcode parameter &quot;filter&quot;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// &amp;#038;&amp;#038; is the passed value for &amp;&amp;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900; font-weight: bold;">false</span> <span style="color: #339933;">!==</span> <span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$filter</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&amp;#038;&amp;#038;'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$compare</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'and'</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$filter</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'&amp;#038;&amp;#038;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$filter</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900; font-weight: bold;">false</span> <span style="color: #339933;">!==</span> <span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$filter</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'||'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$compare</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'or'</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$filter</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'||'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$filter</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;">$compare</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'none'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// single filter word</span>
        <span style="color: #000088;">$filter</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$filter</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$filter</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$string</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// remove HTML entities and turn them into characters, escape/slash other characters</span>
        <span style="color: #000088;">$filter</span><span style="color: #009900;">&#91;</span> <span style="color: #000088;">$key</span> <span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">addslashes</span><span style="color: #009900;">&#40;</span> wp_specialchars_decode<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$string</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">ENT_QUOTES</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;">true</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: #000088;">$row_match</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$table</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'data'</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$row_idx</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$row</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;">0</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$row_idx</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$output_options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'first_row_th'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span>
            <span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$found</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</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;">$filter</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$string</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$found</span><span style="color: #009900;">&#91;</span> <span style="color: #000088;">$key</span> <span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$string</span><span style="color: #339933;">,</span> <span style="color: #000088;">$row</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$compare</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'none'</span><span style="color: #339933;">:</span>
            <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'or'</span><span style="color: #339933;">:</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #000088;">$found</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// at least one word was found / only filter word was found</span>
                    <span style="color: #000088;">$row_match</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">else</span>
                    <span style="color: #000088;">$output_options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'hide_rows'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>string<span style="color: #009900;">&#41;</span><span style="color: #000088;">$row_idx</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'and'</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;">in_array</span><span style="color: #009900;">&#40;</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #000088;">$found</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// if not (at least one word was *not* found) == all words were found</span>
                    <span style="color: #000088;">$row_match</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">else</span>
                    <span style="color: #000088;">$output_options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'hide_rows'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>string<span style="color: #009900;">&#41;</span><span style="color: #000088;">$row_idx</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// if search term(s) was/were not found in any of the rows, all rows need to be hidden</span>
    <span style="color: #666666; font-style: italic;">// but only if first row is used as table head</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #000088;">$row_match</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$output_options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'first_row_th'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$row_idx</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$output_options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'hide_rows'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>string<span style="color: #009900;">&#41;</span><span style="color: #000088;">$row_idx</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$output_options</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Add &quot;filter&quot; as a valid parameter to the [table] Shortcode
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> wp_table_reloaded_shortcode_parameter_filter<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$default_atts</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$default_atts</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'filter'</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: #b1b100;">return</span> <span style="color: #000088;">$default_atts</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Register necessary Plugin Filters
 */</span>
add_filter<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wp_table_reloaded_frontend_output_options'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp_table_reloaded_filter_rows'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_filter<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wp_table_reloaded_shortcode_table_default_atts'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp_table_reloaded_shortcode_parameter_filter'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>



<p>The code form above just needs to be copied into the file &#8220;wp-table-reloaded-extensions.php&#8221;, created according to <a href="http://tobias.baethge.com/wordpress-plugins/wp-table-reloaded-english/extensions/">these instructions</a> (after the Plugin Header comment, but before the closing PHP bracket <code>?&gt;</code>).</p>
<p><span style="color:#ff0000;font-weight:bold;">ATTENTION:</span> One additional change is required (since WP-Table Reloaded 1.9): You must turn off the &#8220;Cache Table Output&#8221; feature in the &#8220;Table Styling Options&#8221; section on the &#8220;Edit&#8221; screen of the table! Otherwise you will get the same filtering result on all pages where the table is shown.</p>
<p>Then, just activate the new plugin &#8220;WP-Table Reloaded Extensions&#8221;, if you haven&#8217;t. That&#8217;s it! :-)</p>
<p>I commented the code so that it should be easy to understand, but here&#8217;s short walkthrough: The Extension hooks into the WP-Table Reloaded code to register a new Shortcode parameter <code>filter</code>. That is necessary so that the actual value passed with that argument is available to the actual filter algorithm. That algorithm starts with determining, what kind of filtering is wanted (&#8220;and&#8221;, &#8220;or&#8221;, or just one word). It then extracts the search term(s) and searches the row for them. Then the actual condition is checked, and if it is not fulfilled, the row will be marked as hidden from the output. There are some minor sanity checks around that (i.e. the first row needs to be treated differently or there needs to be a fallback, if all rows would be hidden), but basically that&#8217;s how the code works.</p>
<p>Here are a few examples that show the three possibilities for using it (remember that in all cases, exact matches to the cell content are required, i.e. if you search for &#8220;test&#8221;, but the cell content is &#8220;testing&#8221;, that will not match!):</p>
<p>Search for a single word in a row:</p>


<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[table id=1 filter=&quot;word1&quot; /]</pre></div></div>



<p>(All rows that do not have &#8220;word1&#8243; as the content of at least one cell will be hidden.)</p>
<p>Search for at least one word:</p>


<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[table id=1 filter=&quot;word1||word2&quot; /]</pre></div></div>



<p>(All rows that do not have either &#8220;word1&#8243; or &#8220;word2&#8243; as the content of cells will be hidden.)<br />
You can combine as many search terms with || as needed.</p>
<p>Search for all words:</p>


<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[table id=1 filter=&quot;word1&amp;&amp;word2&amp;&amp;word3&quot; /]</pre></div></div>



<p>(All rows that do not have &#8220;word1&#8243; and &#8220;word2&#8243; and &#8220;word3&#8243; as the content of cells will be hidden.)<br />
You can combine as many search terms with &#038;&#038; as needed.</p>
<p>Important: Mixing the logical operators is not possible though, i.e.</p>


<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[table id=1 filter=&quot;word1||word2&amp;&amp;word3&quot; /]</pre></div></div>



<p>will not work!</p>
<p>So, you are now able to only show the necessary parts of a large table :-)</p>
<p>If you like this series of Extensions, I&#8217;m happy about any feedback, and especially about further suggestions!</p>
<p>Previous posts in this series that might interest you:</p>
<ul>
<li><a href="http://tobias.baethge.com/2009/12/introducing-wp-table-reloaded-extensions/">Announcement and Foundation on Extensions</a></li>
<li><a href="http://tobias.baethge.com/2009/12/extension-1-url-to-link-conversion/">Extension 1: Automatic URL to Links conversion</a></li>
<li><a href="http://tobias.baethge.com/2010/01/extension-2-custom-name-in-the-menu/">Extension 2: Custom Name in the Admin Menu</a></li>
<li><a href="http://tobias.baethge.com/2010/01/extension-3-changing-the-table-shortcode/">Extension 3: Changing the Table Shortcode</a></li>
<li><a href="http://tobias.baethge.com/2010/02/extension-4-changing-datatables-strings/">Extension 4: Changing DataTables strings</a></li>
<li><a href="http://tobias.baethge.com/2010/02/extension-5-how-to-use-php-in-table-cells/">Extension 5: How to use PHP in table cells</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://tobias.baethge.com/2010/03/extension-6-showing-only-rows-that-match-a-filter/feed/</wfw:commentRss>
		<slash:comments>57</slash:comments>
		</item>
		<item>
		<title>Extension 5: How to use PHP in table cells</title>
		<link>http://tobias.baethge.com/2010/02/extension-5-how-to-use-php-in-table-cells/</link>
		<comments>http://tobias.baethge.com/2010/02/extension-5-how-to-use-php-in-table-cells/#comments</comments>
		<pubDate>Sun, 14 Feb 2010 18:23:11 +0000</pubDate>
		<dc:creator>Tobias</dc:creator>
				<category><![CDATA[Plugin Extension]]></category>
		<category><![CDATA[WP Plugins]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[feature]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://tobias.baethge.com/?p=829</guid>
		<description><![CDATA[This post in my WP-Table Reloaded Extension series should be very useful to a lot of people, taking into consideration the questions I receive on this. Using the code from below, you will extend WP-Table Reloaded so that PHP code in table cells will be parsed and executed. This is useful for dynamic content generation [...]]]></description>
			<content:encoded><![CDATA[<p>This post in my WP-Table Reloaded Extension series should be very useful to a lot of people, taking into consideration the questions I receive on this. Using the code from below, you will extend WP-Table Reloaded so that <a href="http://www.php.net/">PHP</a> code in table cells will be parsed and executed. This is useful for dynamic content generation or integration of other plugins&#8217; features.</p>
<p>To get started with WP-Table Reloaded Extensions, you should <a href="http://tobias.baethge.com/2009/12/introducing-wp-table-reloaded-extensions/">read the introduction</a> and follow the included instructions. You will also find links to the other presented Extensions there.<br />
<span id="more-829"></span></p>
<h4>Security Warning</h4>
<p>Before I start, let me explain, why you should only use this Extension, if you are really sure that you need it and if you really know what you are doing: PHP code is very mighty. Due to the structure of PHP and the HTTP request handling, code that is run from within the table lives in the same &#8220;area&#8221; as the WordPress (or plugin) PHP code and thus has the same rights and possibilities. However, it is not solely controlled by the admin as the plugin or WP core files usually are.<br />
This is especially critical if you have multiple users registered in your WordPress site: Anyone who can edit tables of WP-Table Reloaded will be able to insert (and with that cause execution of) PHP code. And with that, he can do a lot of bad things, if he wanted! What this means: If you want to use this Extension, make sure that only people who you trust can edit tables in WP-Table Reloaded (using the corresponding setting in the &#8220;Plugin Options&#8221;). Preferably this should be only admins of your site. Again: Treat this step seriously! Neither WP-Table Reloaded nor the Extension do any checks on whether a user has the right to insert PHP code! Again: If a user can edit tables, he will be able to enter any PHP code he wants! (Obviously, all of this is no problem, if you are the only registered person in your WordPress site.)</p>
<p><strong>I will not take any responsibility if this feature is misused!</strong></p>
<p>If you can, you should avoid using this Extension, i.e. by developing your own Shortcode (remember: Those also work in tables!) as you&#8217;ll have control of the underlaying PHP code and not the user who edits a table.</p>
<p>For the PHP developers: The Extension uses PHP&#8217;s <a href="http://www.php.net/eval">eval() function</a>. That function takes a string (in our case the cell content) and executes it as PHP. Due to the internal structure of WordPress Shortcodes, we need some output buffering around that function, so that any outputs will not be sent to the browser directly, but together with the output of the [table id=N /] Shortcode. (Take this into consideration before using the Extension, as output buffering on a large number of cells might slighty increase the time needed to render a table and the load on your webspace or <a href="http://www.webhostingsearch.com/dedicated-server.php">cheap dedicated server</a>*.)<br />
Additionally, on certain hosts, the <code>eval()</code> function might be disabled due to security reasons.</p>
<p>Now lets come to the actual code of the Extension:</p>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Executes PHP code in table cells
 * @author Tobias Baethge
 * @see http://tobias.baethge.com/2010/02/extension-5-how-to-use-php-in-table-cells/
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> wp_table_reloaded_execute_php_in_cells<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$cell_content</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">ob_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">eval</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'?&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$cell_content</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ob_get_clean</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$output</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_filter<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wp_table_reloaded_cell_content'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp_table_reloaded_execute_php_in_cells'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>



<p>The code form above just needs to be copied into the file &#8220;wp-table-reloaded-extensions.php&#8221;, created according to <a href="http://tobias.baethge.com/wordpress-plugins/wp-table-reloaded-english/extensions/">these instructions</a> (after the Plugin Header comment, but before the closing PHP bracket <code>?&gt;</code>). Then, just activate the new plugin &#8220;WP-Table Reloaded Extensions&#8221;, if you haven&#8217;t. That&#8217;s it! :-)</p>
<p>To use PHP in a table, you can now enter commands into your table cells. They have to be valid PHP syntax, including the opening and closing brackets (<code>&lt;?php</code> and <code>?&gt;</code>). In those commands, you can use the regular <code>echo</code> function to output text. Any text that is not within the brackets will be printed as-is.</p>
<p>If you like this series of Extensions, I&#8217;m happy about any feedback, and especially about further suggestions!</p>
<p>Previous posts in this series that might interest you:</p>
<ul>
<li><a href="http://tobias.baethge.com/2009/12/introducing-wp-table-reloaded-extensions/">Announcement and Foundation on Extensions</a></li>
<li><a href="http://tobias.baethge.com/2009/12/extension-1-url-to-link-conversion/">Extension 1: Automatic URL to Links conversion</a></li>
<li><a href="http://tobias.baethge.com/2010/01/extension-2-custom-name-in-the-menu/">Extension 2: Custom Name in the Admin Menu</a></li>
<li><a href="http://tobias.baethge.com/2010/01/extension-3-changing-the-table-shortcode/">Extension 3: Changing the Table Shortcode</a></li>
<li><a href="http://tobias.baethge.com/2010/02/extension-4-changing-datatables-strings/">Extension 4: Changing DataTables strings</a></li>
</ul>
<p><small>* Words from our friends at Webhostingsearch</small></p>
]]></content:encoded>
			<wfw:commentRss>http://tobias.baethge.com/2010/02/extension-5-how-to-use-php-in-table-cells/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Extension 4: Changing DataTables strings</title>
		<link>http://tobias.baethge.com/2010/02/extension-4-changing-datatables-strings/</link>
		<comments>http://tobias.baethge.com/2010/02/extension-4-changing-datatables-strings/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 19:24:03 +0000</pubDate>
		<dc:creator>Tobias</dc:creator>
				<category><![CDATA[Plugin Extension]]></category>
		<category><![CDATA[WP Plugins]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://tobias.baethge.com/?p=822</guid>
		<description><![CDATA[In this post of the WP-Table Reloaded Extensions series, I&#8217;ll show you a way to easily change the strings that the DataTables JavaScript library outputs around a table. This includes things like the &#8220;Search:&#8221;, &#8220;Showing i to j of n entries&#8221; and the other text strings. To get started with WP-Table Reloaded Extensions, you should [...]]]></description>
			<content:encoded><![CDATA[<p>In this post of the WP-Table Reloaded Extensions series, I&#8217;ll show you a way to easily change the strings that the DataTables JavaScript library outputs around a table. This includes things like the &#8220;Search:&#8221;, &#8220;Showing i to j of n entries&#8221; and the other text strings.</p>
<p>To get started with WP-Table Reloaded Extensions, you should <a href="http://tobias.baethge.com/2009/12/introducing-wp-table-reloaded-extensions/">read the introduction</a> and follow the included instructions. You will also find links to the other presented Extensions there.<br />
<span id="more-822"></span></p>
<p>Several people have approached me, asking how to change the &#8220;Search:&#8221; to &#8220;Filter:&#8221;, &#8220;Live Search:&#8221;, or other similar texts.<br />
Those strings are all stored in a file that at the same time serves as the localization method for those strings, i.e. English and the other languages&#8217; texts are simply stored in different files and only the needed one is loaded, depending on the locale that is used for WordPress. The files are all located in the &#8220;datatables&#8221; subfolder of the &#8220;languages&#8221; folder in the WP-Table Reloaded plugin folder.</p>
<p>Thus, changing strings is very similar to translating them to a new language: Find the file for your language in the mentioned folder and copy it to your theme&#8217;s folder (or another publicly available location on your webspace or <a href="http://www.webhostingsearch.com/virtual-private-server.php">virtual private server</a>*). This step will ensure that your changes will still be there after an update of the plugin. If you just change strings in the mentioned file, those changes will be gone after an update!</p>
<p>The file looks similar to this (this is the English file):</p>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span>
	<span style="color: #3366CC;">&quot;sProcessing&quot;</span><span style="color: #339933;">:</span>   <span style="color: #3366CC;">&quot;Processing...&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #3366CC;">&quot;sLengthMenu&quot;</span><span style="color: #339933;">:</span>   <span style="color: #3366CC;">&quot;Show _MENU_ entries&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #3366CC;">&quot;sZeroRecords&quot;</span><span style="color: #339933;">:</span>  <span style="color: #3366CC;">&quot;No matching records found&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #3366CC;">&quot;sInfo&quot;</span><span style="color: #339933;">:</span>         <span style="color: #3366CC;">&quot;Showing _START_ to _END_ of _TOTAL_ entries&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #3366CC;">&quot;sInfoEmpty&quot;</span><span style="color: #339933;">:</span>    <span style="color: #3366CC;">&quot;Showing 0 to 0 of 0 entries&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #3366CC;">&quot;sInfoFiltered&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;(filtered from _MAX_ total entries)&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #3366CC;">&quot;sInfoPostFix&quot;</span><span style="color: #339933;">:</span>  <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #3366CC;">&quot;sSearch&quot;</span><span style="color: #339933;">:</span>       <span style="color: #3366CC;">&quot;Search:&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #3366CC;">&quot;sUrl&quot;</span><span style="color: #339933;">:</span>          <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #3366CC;">&quot;oPaginate&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #3366CC;">&quot;sFirst&quot;</span><span style="color: #339933;">:</span>    <span style="color: #3366CC;">&quot;First&quot;</span><span style="color: #339933;">,</span>
		<span style="color: #3366CC;">&quot;sPrevious&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Previous&quot;</span><span style="color: #339933;">,</span>
		<span style="color: #3366CC;">&quot;sNext&quot;</span><span style="color: #339933;">:</span>     <span style="color: #3366CC;">&quot;Next&quot;</span><span style="color: #339933;">,</span>
		<span style="color: #3366CC;">&quot;sLast&quot;</span><span style="color: #339933;">:</span>     <span style="color: #3366CC;">&quot;Last&quot;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>



<p>You can change any string that is on the right side of a colon (:). Make sure to not remove any of the quotation marks. Also, you can not use quotation marks in your changed strings! The words that are surrounded by an underscore (_) are placeholders for the numbers or input fields that are automatically added by the DataTables script. You must not alter those (you can however put them in a new place within the string).</p>
<p>This is an example of a file with changed string:</p>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span>
	<span style="color: #3366CC;">&quot;sProcessing&quot;</span><span style="color: #339933;">:</span>   <span style="color: #3366CC;">&quot;Please wait...&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #3366CC;">&quot;sLengthMenu&quot;</span><span style="color: #339933;">:</span>   <span style="color: #3366CC;">&quot;Show _MENU_ rows&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #3366CC;">&quot;sZeroRecords&quot;</span><span style="color: #339933;">:</span>  <span style="color: #3366CC;">&quot;No matching rows found in the table&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #3366CC;">&quot;sInfo&quot;</span><span style="color: #339933;">:</span>         <span style="color: #3366CC;">&quot;Showing _START_ to _END_ of _TOTAL_ rows&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #3366CC;">&quot;sInfoEmpty&quot;</span><span style="color: #339933;">:</span>    <span style="color: #3366CC;">&quot;Showing 0 to 0 of 0 rows&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #3366CC;">&quot;sInfoFiltered&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;(found from _MAX_ total entries)&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #3366CC;">&quot;sInfoPostFix&quot;</span><span style="color: #339933;">:</span>  <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #3366CC;">&quot;sSearch&quot;</span><span style="color: #339933;">:</span>       <span style="color: #3366CC;">&quot;Live Filter:&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #3366CC;">&quot;sUrl&quot;</span><span style="color: #339933;">:</span>          <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #3366CC;">&quot;oPaginate&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #3366CC;">&quot;sFirst&quot;</span><span style="color: #339933;">:</span>    <span style="color: #3366CC;">&quot;First&quot;</span><span style="color: #339933;">,</span>
		<span style="color: #3366CC;">&quot;sPrevious&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Previous&quot;</span><span style="color: #339933;">,</span>
		<span style="color: #3366CC;">&quot;sNext&quot;</span><span style="color: #339933;">:</span>     <span style="color: #3366CC;">&quot;Next&quot;</span><span style="color: #339933;">,</span>
		<span style="color: #3366CC;">&quot;sLast&quot;</span><span style="color: #339933;">:</span>     <span style="color: #3366CC;">&quot;Last&quot;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>



<p>After making your changes, again make sure to have the file stored in your theme&#8217;s folder. You might want to use a more recognizable filename, like &#8220;datatables.txt&#8221; which I will use here.</p>
<p>It will then have a URL like <code>http://www.example.com/wp-content/your-theme/datatables.txt</code>. (You will need this URL, adjusted to your site, in the next step.)</p>
<p>After creating the file with the changed strings, we need to tell WP-Table Reloaded (i.e. the DataTables library) to use the file for obtaining the strings:</p>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Changes the file used for the DataTables strings to a different file (i.e. with changed strings)
 * @author Tobias Baethge
 * @see http://tobias.baethge.com/2010/02/extension-4-changing-datatables-strings/
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> wp_table_reloaded_change_datatables_language_file_url<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$language_file_url</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'http://www.example.com/wp-content/your-theme/datatables.txt'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// change this to the corresponding URL on your server</span>
<span style="color: #009900;">&#125;</span>
add_filter<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wp_table_reloaded_url_datatables_language_file'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp_table_reloaded_change_datatables_language_file_url'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>



<p>Just replace the URL in this function with the URL to your file and the strings of the DataTables library will be taken from the file.</p>
<p>The code form above just needs to be copied into the file &#8220;wp-table-reloaded-extensions.php&#8221;, created according to <a href="http://tobias.baethge.com/wordpress-plugins/wp-table-reloaded-english/extensions/">these instructions</a> (after the Plugin Header comment, but before the closing PHP bracket <code>?&gt;</code>). Then, just activate the new plugin &#8220;WP-Table Reloaded Extensions&#8221;, if you haven&#8217;t. That&#8217;s it! :-)</p>
<p>If you like this series of Extensions, I&#8217;m happy about any feedback, and especially about further suggestions!</p>
<p>Previous posts in this series that might interest you:</p>
<ul>
<li><a href="http://tobias.baethge.com/2009/12/introducing-wp-table-reloaded-extensions/">Announcement and Foundation on Extensions</a></li>
<li><a href="http://tobias.baethge.com/2009/12/extension-1-url-to-link-conversion/">Extension 1: Automatic URL to Links conversion</a></li>
<li><a href="http://tobias.baethge.com/2010/01/extension-2-custom-name-in-the-menu/">Extension 2: Custom Name in the Admin Menu</a></li>
<li><a href="http://tobias.baethge.com/2010/01/extension-3-changing-the-table-shortcode/">Extension 3: Changing the Table Shortcode</a></li>
</ul>
<p><small>* Words from our friends at Webhostingsearch</small></p>
]]></content:encoded>
			<wfw:commentRss>http://tobias.baethge.com/2010/02/extension-4-changing-datatables-strings/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Extension 3: Changing the Table Shortcode</title>
		<link>http://tobias.baethge.com/2010/01/extension-3-changing-the-table-shortcode/</link>
		<comments>http://tobias.baethge.com/2010/01/extension-3-changing-the-table-shortcode/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 17:06:29 +0000</pubDate>
		<dc:creator>Tobias</dc:creator>
				<category><![CDATA[Plugin Extension]]></category>
		<category><![CDATA[WP Plugins]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[feature]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://tobias.baethge.com/?p=793</guid>
		<description><![CDATA[My second Extension to WP-Table Reloaded was actually pretty short and simple, so I decided to present another short one to make up for that :-) So, here you will see how you can change the used Shortcode from Demo Table Thisisademotable! AndIamthefooter :-) Youcanpresentdatahere. Likenumbers:123 Orevenhtml:Strongemphasized a linkoranimage: Demo Table Description (You could tell [...]]]></description>
			<content:encoded><![CDATA[<p>My <a href="http://tobias.baethge.com/2010/01/extension-2-custom-name-in-the-menu/">second Extension</a> to WP-Table Reloaded was actually pretty short and simple, so I decided to present another short one to make up for that :-) So, here you will see how you can change the used Shortcode from <code>[table id=1 /]</code> to e.g. <code>[data id=1 /]</code> or <code>[ranking id=1 /]</code>.</p>
<p>To get started with WP-Table Reloaded Extensions, you should <a href="http://tobias.baethge.com/2009/12/introducing-wp-table-reloaded-extensions/">read the introduction</a> and follow the included instructions. You will also find links to the other presented Extensions there.<br />
<span id="more-793"></span></p>
<p>Changing the name of the used Shortcode could be useful for several use cases:</p>
<ul>
<li>You want it to be in your native language (i.e. for German: <code>Tabelle</code> instead of <code>table</code>).</li>
<li>You are already (or want to) use the <code>table</code> for something else.</li>
<li>Your generated tables resemble something specific, i.e. a set of <code>data</code>, or a <code>ranking</code>.</li>
<li>&#8230;</li>
</ul>
<p>And it really is simple! All you need is this code:</p>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Changes Shortcode for WP-Table Reloaded from [table id=N /] to [[ranking id=N /]]
 * @author Tobias Baethge
 * @see http://tobias.baethge.com/2010/01/extension-3-changing-the-table-shortcode/
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> wp_table_reloaded_change_table_shortcode<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$shortcode</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'ranking'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_filter<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wp_table_reloaded_shortcode_table'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp_table_reloaded_change_table_shortcode'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>



<p>The code will change the Shortcode from [table id=1 /] to [[ranking id=1 /]]. Of course you can change &#8216;ranking&#8217; to anything you like in the code above!</p>
<p>This code just needs to be copied into the file &#8220;wp-table-reloaded-extensions.php&#8221;, created according to <a href="http://tobias.baethge.com/wordpress-plugins/wp-table-reloaded-english/extensions/">these instructions</a> (after the Plugin Header comment, but before the closing PHP bracket <code>?&gt;</code>). Then, just activate the new plugin &#8220;WP-Table Reloaded Extensions&#8221;, if you haven&#8217;t. That&#8217;s it! :-)</p>
<p>If you like this series of Extensions, I&#8217;m happy about any feedback, and especially about further suggestions!</p>
<p>Previous posts in this series that might interest you:</p>
<ul>
<li><a href="http://tobias.baethge.com/2009/12/introducing-wp-table-reloaded-extensions/">Announcement and Foundation on Extensions</a></li>
<li><a href="http://tobias.baethge.com/2009/12/extension-1-url-to-link-conversion/">Extension 1: Automatic URL to Links conversion</a></li>
<li><a href="http://tobias.baethge.com/2010/01/extension-2-custom-name-in-the-menu/">Extension 2: Custom Name in the Admin Menu</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://tobias.baethge.com/2010/01/extension-3-changing-the-table-shortcode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extension 2: Custom Name in the Admin Menu</title>
		<link>http://tobias.baethge.com/2010/01/extension-2-custom-name-in-the-menu/</link>
		<comments>http://tobias.baethge.com/2010/01/extension-2-custom-name-in-the-menu/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 10:35:27 +0000</pubDate>
		<dc:creator>Tobias</dc:creator>
				<category><![CDATA[Plugin Extension]]></category>
		<category><![CDATA[WP Plugins]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[feature]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://tobias.baethge.com/?p=647</guid>
		<description><![CDATA[In my second post of the series on WP-Table Reloaded Extensions, I will show you a way to change the name of the plugin in the WP Admin Menu. Remember, Extensions are small code snippets that customize or extend the functionality of WP-Table Reloaded, by using the many &#8220;Plugin Hooks&#8221;. To get started, you should [...]]]></description>
			<content:encoded><![CDATA[<p>In my second post of the series on WP-Table Reloaded Extensions, I will show you a way to change the name of the plugin in the WP Admin Menu.</p>
<p>Remember, Extensions are small code snippets that customize or extend the functionality of WP-Table Reloaded, by using the many &#8220;Plugin Hooks&#8221;. To get started, you should <a href="http://tobias.baethge.com/2009/12/introducing-wp-table-reloaded-extensions/">read the introduction</a> on WP-Table Reloaded Extensions and follow the included instructions to set up the foundation. I also recommend reading the first post of this series, where I add an <a href="http://tobias.baethge.com/2009/12/extension-1-url-to-link-conversion/">Automatic Converter for URLs to Links</a>. You don&#8217;t need the code from there, but it might be helpful to better understand the concept.<br />
<span id="more-647"></span></p>
<p>In this post, I will show you how to change the name of the plugin in the WP Admin Menu. The default value is &#8220;WP-Table Reloaded&#8221; which might not be easy to recognize by clients or people using WordPress as a CMS. To better show, what I&#8217;m talking about: Here are two screenshots, one before activating the Extension and one after activating it.</p>
<p><img src="http://tobias.baethge.com/wp-content/uploads/2010/01/admin-menu.png" alt="Screenshot of the old and new entries in the WP Admin Menu" title="Screenshot of the old and new entries in the WP Admin Menu" width="337" height="130" class="alignnone size-full wp-image-759" /></p>
<p>The menu entry was changed from &#8220;WP-Table Reloaded&#8221; to &#8220;Tables&#8221;. (Remember that you can also move that entry to another parent entry with the corresponding admin option in the &#8220;Plugin Options&#8221; of WP-Table Reloaded.)</p>
<p>And here is the code:</p>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Changes the WP Admin Menu entry from &quot;WP-Table Reloaded&quot; to &quot;Tables&quot;
 * @author Tobias Baethge
 * @see http://tobias.baethge.com/2010/01/extension-2-custom-name-in-the-menu/
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> wp_table_reloaded_admin_menu_entry<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$name</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'Tables'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_filter<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wp_table_reloaded_plugin_display_name'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp_table_reloaded_admin_menu_entry'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>



<p>This code just needs to be copied into the file &#8220;wp-table-reloaded-extensions.php&#8221;, which needs to be created according to <a href="http://tobias.baethge.com/wordpress-plugins/wp-table-reloaded-english/extensions/">these instructions</a> (after the Plugin Header comment, but before the closing PHP bracket <code>?&gt;</code>). Then, just activate the new plugin &#8220;WP-Table Reloaded Extensions&#8221;. That&#8217;s it! :-)</p>
<p>If you like this series of Extensions, I&#8217;m happy about any feedback, and especially about further suggestions!</p>
<p>Previous posts in this series that might interest you:</p>
<ul>
<li><a href="http://tobias.baethge.com/2009/12/introducing-wp-table-reloaded-extensions/">Announcement and Foundation on Extensions</a></li>
<li><a href="http://tobias.baethge.com/2009/12/extension-1-url-to-link-conversion/">Extension 1: Automatic URL to Links conversion</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://tobias.baethge.com/2010/01/extension-2-custom-name-in-the-menu/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Extension 1: URL to Link Conversion</title>
		<link>http://tobias.baethge.com/2009/12/extension-1-url-to-link-conversion/</link>
		<comments>http://tobias.baethge.com/2009/12/extension-1-url-to-link-conversion/#comments</comments>
		<pubDate>Thu, 31 Dec 2009 08:53:43 +0000</pubDate>
		<dc:creator>Tobias</dc:creator>
				<category><![CDATA[Plugin Extension]]></category>
		<category><![CDATA[WP Plugins]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[feature]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://tobias.baethge.com/?p=646</guid>
		<description><![CDATA[Just recently I introduced WP-Table Reloaded Extensions, small code snippets that add further functions to the plugin by using the provided &#8220;Plugin Actions&#8221; and &#8220;Plugin Filters&#8221;. The first such Extension that I&#8217;m going to present here, is an Automatic Converter for URLs to Links. In general, you&#8217;ll need to manually enter the HTML for a [...]]]></description>
			<content:encoded><![CDATA[<p>Just recently I <a href="http://tobias.baethge.com/2009/12/introducing-wp-table-reloaded-extensions/">introduced WP-Table Reloaded Extensions</a>, small code snippets that add further functions to the plugin by using the provided &#8220;Plugin Actions&#8221; and &#8220;Plugin Filters&#8221;.</p>
<p>The first such Extension that I&#8217;m going to present here, is an <strong>Automatic Converter for URLs to Links</strong>. <span id="more-646"></span></p>
<p>In general, you&#8217;ll need to manually enter the HTML for a link (something like <code>&lt;a href="http://www.example.com"&gt;My Link&lt;/a&gt;</code>) into a cell or use the included Wizard that will ask you for the URL and the link text and then generates the HTML for you. This is my recommended way and for most needs it works fine. It also allows for the most flexibility, because you have all freedom to alter or extend that HTML code as you like, e.g. by adding further attributes or a different link text.<br />
Unfortunately it an be a real hassle and a lot of work, if all you want to achieve is, to make URLs you enter &#8220;clickable&#8221;, i.e. to make them valid HTML links. That can for example be the case when you import a table from a file, because in most cases URLs are not exported as HTML links by a program but simply as the plain URL in text form.</p>
<p>And this is were this Extension kicks in. When a table is shown in a post or page (by using the corresponding Shortcode in it), the extension will basically loop through all cells of that table and check if there&#8217;s an URL (for www, ftp or an email address) somewhere. And if it finds one, it will replace the URL with a complete HTML link to that URL that can be clicked by the visitor. The good thing: If there already was a complete HTML link it will be left intact.</p>
<p>Example:<br />
A cell with the content &#8220;http://www.example.com&#8221; will automatically be converted to a clickable link: &#8220;<a href="http://www.example.com">http://www.example.com</a>&#8220;.</p>
<p>And here is the code:</p>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Converts URLs (www, ftp, and email) in table cells to full HTML links
 * @author Tobias Baethge
 * @see http://tobias.baethge.com/2009/12/extension-1-url-to-link-conversion/
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> wp_table_reloaded_url_link_converter<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$cell_content</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> make_clickable<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$cell_content</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_filter<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wp_table_reloaded_cell_content'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp_table_reloaded_url_link_converter'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>



<p>This code just needs to be copied into the file &#8220;wp-table-reloaded-extensions.php&#8221;, which needs to be created according to <a href="http://tobias.baethge.com/wordpress-plugins/wp-table-reloaded-english/extensions/">these instructions</a> (after the Plugin Header comment, but before the closing PHP bracket <code>?&gt;</code>). That&#8217;s it! :-)</p>
<p>If you like this series of Extensions, I&#8217;m happy about any feedback, and especially about further suggestions!</p>
]]></content:encoded>
			<wfw:commentRss>http://tobias.baethge.com/2009/12/extension-1-url-to-link-conversion/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>Introducing WP-Table Reloaded Extensions</title>
		<link>http://tobias.baethge.com/2009/12/introducing-wp-table-reloaded-extensions/</link>
		<comments>http://tobias.baethge.com/2009/12/introducing-wp-table-reloaded-extensions/#comments</comments>
		<pubDate>Mon, 28 Dec 2009 08:47:57 +0000</pubDate>
		<dc:creator>Tobias</dc:creator>
				<category><![CDATA[Plugin Extension]]></category>
		<category><![CDATA[WP Plugins]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[feature]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://tobias.baethge.com/?p=626</guid>
		<description><![CDATA[One of the main additions to version 1.5 of WP-Table Reloaded were so-called &#8220;Plugin Actions&#8221; and &#8220;Plugin Filters&#8221;. Both are part of the &#8220;Plugin Hooks&#8221;, a widely used concept within WordPress. This explanation from the WordPress Codex sums it up. The way Plugin hooks work is that at various times while WordPress is running, WordPress [...]]]></description>
			<content:encoded><![CDATA[<p>One of the main additions to version 1.5 of WP-Table Reloaded were so-called &#8220;Plugin Actions&#8221; and &#8220;Plugin Filters&#8221;. Both are part of the &#8220;Plugin Hooks&#8221;, a widely used concept within WordPress. This explanation from the WordPress <a href="http://codex.wordpress.org/Writing_a_Plugin">Codex</a> sums it up.</p>
<blockquote><p>The way Plugin hooks work is that at various times while WordPress is running, WordPress checks to see if any Plugins have registered functions to run at that time, and if so, the functions are run. These functions modify the default behavior of WordPress.</p></blockquote>
<p>Well known hooks are for example &#8220;wp_head&#8221; and &#8220;wp_footer&#8221;, which allow adding functions to the head and footer of a page that was generated by WordPress.</p>
<p>Actions and Filters can not only be used by the WordPress Core, but also by plugins and it is possible to add new ones. And this is what I did in WP-Table Reloaded 1.5. Many of these hooks were added to the plugin which now allow other plugins to add or change functions in WP-Table Reloaded.</p>
<p>These new functions may be as short as one line or as long as a complete new plugin. For WP-Table Reloaded, I will &#8211; over the course of the next weeks and months, but with no fixed time frame or frequency &#8211; present such pieces of code on this website, as a series of blog posts. As these code snippets are not complete WordPress plugins, I will call them <strong>WP-Table Reloaded Extensions</strong>, as that describes what they are a little bit better.<span id="more-626"></span></p>
<p>Before adding any Extensions, we need to establish a foundation for them. There are two possible ways: As they (mostly) are pretty short (only one or two PHP functions and only few lines of code), they can simply be added to the file &#8220;functions.php&#8221; of the currently used theme. While that is possible, I don&#8217;t really recommend it, because it mixes theme and plugin code. And it requires special attention, if e.g. the theme is switched.<br />
The other (and recommended) way is to create a new plugin file that will hold all of the extensions. That file (which should be called &#8220;wp-table-reloaded-extensions.php&#8221;) simply needs to be put into the WordPress &#8220;plugins&#8221; folder (a sub-directory of &#8220;wp-content&#8221;). It *MUST NOT* be placed in the WP-Table Reloaded plugin directory (&#8220;wp-table-reloaded&#8221;), because it will be deleted from there by WordPress, once WP-Table Reloaded is updated.</p>
<p>This file is nothing else than a regular WordPress Plugin, with all the advantages, like separation of theme and plugin code, i.e. no problems when switching the theme. It must be activated like any other plugin, which obviously creates the advantage it can be deactivated any time, if its functionality is no longer needed.</p>
<p>The contents of that file (&#8220;wp-table-reloaded-extensions.php&#8221; in the folder &#8220;plugins&#8221;) are (for now):</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: #666666; font-style: italic;">/*
Plugin Name: WP-Table Reloaded Extensions
Plugin URI: http://tobias.baethge.com/wordpress-plugins/wp-table-reloaded-english/extensions/
Description: Custom Extensions for WP-Table Reloaded
Version: 1.0
Author: YOU, Tobias Baethge
*/</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// this is where the actual code goes</span></pre></div></div>



<p>As you will certainly see, the file does not yet contain any real PHP code, but just comments. These comments are the so-called "Plugin Header", that every WordPress Plugin must contain to be recognized as such.</p>
<p>All new code now has to be added to this file (after these comments and *before* the closing PHP bracket (<code>?&gt;</code>).</p>
<p>So, a quick summary to get started with WP-Table Reloaded Extensions:</p>
<ul>
<li>Copy the code from above into a new text file.</li>
<li>Save that file as "wp-table-reloaded-extensions.php".</li>
<li>Move it to the directory "/wp-contents/plugins/" of your WordPress installation on your server (but NOT into the "wp-table-reloaded" folder!)</li>
<li>Activate the newly available plugin "WP-Table Reloaded Extensions" from the WordPress Plugins screen.</li>
<li>Any code for an Extension (that will be presented throughout the announced series of sporadic blog posts) has to be added to that file (below the existing code and above the <code>?&gt;</code> in the last line of code).</li>
<li>Of course you can add more than one Extension to that file (I recommend to separate them by a comment line that describes what each part does.)</li>
</ul>
<p>To start off the series in the next days, I will show you a way to automatically convert URLs in a table into complete HTML links - without the need of having to use the Link Wizard on the "Edit table" screen.</p>
<p>If you have any questions or feedback, just let me know. I'm also open to ideas or solutions that involve Actions and Filters. So, if you have any input on this, just contact me or leave a comment!</p>
<p>I hope that we'll have a lot of fun with WP-Table Reloaded Extensions and that they provide valuable functions and maybe even a plugin develepment learning experience to you.</p>
]]></content:encoded>
			<wfw:commentRss>http://tobias.baethge.com/2009/12/introducing-wp-table-reloaded-extensions/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

