<?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>Der Blog von Benny Neugebauer &#187; WordPress</title>
	<atom:link href="http://www.bennyn.de/webanwendungen/wordpress/feed" rel="self" type="application/rss+xml" />
	<link>http://www.bennyn.de</link>
	<description>Alles über die Informatik &#38; Co.</description>
	<lastBuildDate>Tue, 22 May 2012 09:22:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>How to use jQuery within a WordPress plugin</title>
		<link>http://www.bennyn.de/webanwendungen/wordpress/how-to-use-jquery-within-a-wordpress-plugin.html</link>
		<comments>http://www.bennyn.de/webanwendungen/wordpress/how-to-use-jquery-within-a-wordpress-plugin.html#comments</comments>
		<pubDate>Sun, 02 Oct 2011 13:57:30 +0000</pubDate>
		<dc:creator>bennyn</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Plugin]]></category>

		<guid isPermaLink="false">http://www.bennyn.de/?p=2800</guid>
		<description><![CDATA[This is just a short sample which shows how you can use jQuery within your own WordPress plugin to make cool JSON requests on PHP pages. &#8230;/wp-content/plugins/your_plugin/your_plugin.php 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ... add_action&#40;'template_redirect', 'ypAddMediaFiles'&#41;; add_shortcode&#40;'your_plugin', 'ypAddShortCode'&#41;; ... function ypAddMediaFiles&#40;&#41; &#123; wp_enqueue_script&#40;'jquery'&#41;; wp_register_script&#40;'your_javascript', plugins_url&#40;'js/your_javascript.js', __FILE__&#41;, [...]]]></description>
			<content:encoded><![CDATA[<p>This is just a short sample which shows how you can use jQuery within your own WordPress plugin to make cool JSON requests on PHP pages.<br />
<span id="more-2800"></span></p>
<h2>&#8230;/wp-content/plugins/your_plugin/your_plugin.php</h2>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">...</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'template_redirect'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ypAddMediaFiles'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_shortcode<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'your_plugin'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ypAddShortCode'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">...</span>
<span style="color: #000000; font-weight: bold;">function</span> ypAddMediaFiles<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  wp_enqueue_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jquery'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  wp_register_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'your_javascript'</span><span style="color: #339933;">,</span> plugins_url<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'js/your_javascript.js'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jquery'</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> ypAddShortCode<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  wp_enqueue_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'your_javascript'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'JavaScript has been loaded.'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h2>&#8230;/wp-content/plugins/your_plugin/js/your_javascript.js</h2>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">your_function<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Benny'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Neugebauer'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> your_function<span style="color: #009900;">&#40;</span>first_name<span style="color: #339933;">,</span> last_name<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  jQuery<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    $.<span style="color: #660066;">post</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;wp-content/plugins/your_plugin/something_that_gives_you_json.php&quot;</span><span style="color: #339933;">,</span> 
    <span style="color: #009900;">&#123;</span>
      param1<span style="color: #339933;">:</span> first_name<span style="color: #339933;">,</span>
      param2<span style="color: #339933;">:</span> last_name
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span> 
    <span style="color: #009900;">&#123;</span>
      <span style="color: #003366; font-weight: bold;">var</span> results <span style="color: #339933;">=</span> jQuery.<span style="color: #660066;">parseJSON</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>results<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.bennyn.de/webanwendungen/wordpress/how-to-use-jquery-within-a-wordpress-plugin.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create thumbnail images with PHP</title>
		<link>http://www.bennyn.de/webanwendungen/wordpress/create-thumbnail-images-with-php.html</link>
		<comments>http://www.bennyn.de/webanwendungen/wordpress/create-thumbnail-images-with-php.html#comments</comments>
		<pubDate>Sat, 01 Oct 2011 16:19:38 +0000</pubDate>
		<dc:creator>bennyn</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Generator]]></category>
		<category><![CDATA[thumbnails]]></category>

		<guid isPermaLink="false">http://www.bennyn.de/?p=2778</guid>
		<description><![CDATA[I developed a function which creates a thumbnail for a given image in a predefined size. Please note that this function was created to be used within a WordPress plugin so it uses paths related to WordPress but these paths can be easily adapted to be used without WordPress. Preamble PHP file: /var/www/wordpress/wp-content/plugins/thumbnail_generator/thumbnail_generator.php Sample image: [...]]]></description>
			<content:encoded><![CDATA[<p>I developed a function which creates a thumbnail for a given image in a predefined size. Please note that this function was created to be used within a WordPress plugin so it uses paths related to WordPress but these paths can be easily adapted to be used without WordPress.<br />
<span id="more-2778"></span><br />
<b>Preamble</b><br />
PHP file:<br />
<code>/var/www/wordpress/wp-content/plugins/thumbnail_generator/thumbnail_generator.php</code><br />
Sample image:<br />
<code>/var/www/wordpress/wp-content/plugins/thumbnail_generator/pictures/album1/picture1.jpeg</code><br />
Sample image size:<br />
1600&#215;1066 pixels</p>
<p>My function will create a thumbnail called <strong>picture1.jpeg.png</strong> with a width of 100px and an appropriate height in a directory called:<br />
<code>/var/www/wordpress/wp-content/plugins/thumbnail_generator/thumbnails/pictures/album1/</code>.</p>
<h2>thumbnail_generator.php</h2>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">createThumbnail<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'pictures/album1/picture1.jpeg'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> createThumbnail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$relativePath</span><span style="color: #339933;">,</span> <span style="color: #000088;">$resizedWidth</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$thumbnailDirectory</span> <span style="color: #339933;">=</span> plugin_dir_path<span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'thumbnails/'</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$imageFile</span> <span style="color: #339933;">=</span> plugin_dir_path<span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$relativePath</span><span style="color: #339933;">;</span>
  <span style="color: #666666; font-style: italic;">// Determine image type</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/[.](jpe?g?|jfif|tiff)$/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$imageFile</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000088;">$image</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecreatefromjpeg</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$imageFile</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/[.](gif)$/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$imageFile</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000088;">$image</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecreatefromgif</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$imageFile</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/[.](png)$/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$imageFile</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000088;">$image</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecreatefrompng</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$imageFile</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #666666; font-style: italic;">// Calculate the thumbnail size (depending on the image aspect ratio)</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;">$image</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$width</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagesx</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$image</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$height</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagesy</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$image</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$resizedHeight</span> <span style="color: #339933;">=</span> <span style="color: #990000;">round</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$height</span> <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$resizedWidth</span> <span style="color: #339933;">/</span> <span style="color: #000088;">$width</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$thumbnail</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecreatetruecolor</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$resizedWidth</span><span style="color: #339933;">,</span> <span style="color: #000088;">$resizedHeight</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">imagecopyresized</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$thumbnail</span><span style="color: #339933;">,</span> <span style="color: #000088;">$image</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$resizedWidth</span><span style="color: #339933;">,</span> <span style="color: #000088;">$resizedHeight</span><span style="color: #339933;">,</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: #666666; font-style: italic;">// Save thumbnail to subdirectory</span>
    <span style="color: #000088;">$slashPosition</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strrpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$relativePath</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$thumbnailName</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$relativePath</span><span style="color: #339933;">,</span> <span style="color: #000088;">$slashPosition</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$thumbnailDirectory</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$thumbnailDirectory</span> <span style="color: #339933;">.</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$relativePath</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$slashPosition</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$thumbnailDirectory</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
      <span style="color: #990000;">mkdir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$thumbnailDirectory</span><span style="color: #339933;">,</span> <span style="color: #208080;">0755</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: #990000;">imagepng</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$thumbnail</span><span style="color: #339933;">,</span> <span style="color: #000088;">$thumbnailDirectory</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$thumbnailName</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'.png'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.bennyn.de/webanwendungen/wordpress/create-thumbnail-images-with-php.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to create a WordPress plugin with a custom database table</title>
		<link>http://www.bennyn.de/webanwendungen/wordpress/how-to-create-a-wordpress-plugin-with-a-custom-database-table.html</link>
		<comments>http://www.bennyn.de/webanwendungen/wordpress/how-to-create-a-wordpress-plugin-with-a-custom-database-table.html#comments</comments>
		<pubDate>Sat, 24 Sep 2011 00:16:50 +0000</pubDate>
		<dc:creator>bennyn</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[table]]></category>

		<guid isPermaLink="false">http://www.bennyn.de/?p=2769</guid>
		<description><![CDATA[You can create a custom table for the data of your WordPress plugin if you hook on the plugin activation. This has the effect that your custom table will be created if you activate the plugin in the WordPress backend. I created a sample code to show you how this works. ../wp/wp-content/plugins/my-plugin/plugin.php 1 2 3 [...]]]></description>
			<content:encoded><![CDATA[<p>You can create a custom table for the data of your WordPress plugin if you hook on the plugin activation. This has the effect that your custom table will be created if you activate the plugin in the WordPress backend. I created a sample code to show you how this works.<br />
<span id="more-2769"></span></p>
<h2>../wp/wp-content/plugins/my-plugin/plugin.php</h2>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*
  Plugin Name: Gallery
  Plugin URI: http://www.angelcode.de/
  Description: My gallery.
  Version: 1.0
  Author: Benny Neugebauer
  Author URI: http://www.bennyn.de/
  License: GPLv2
 */</span>
&nbsp;
register_activation_hook<span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'create_custom_table'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009933; font-style: italic;">/**
 * See: https://codex.wordpress.org/Creating_Tables_with_Plugins
 * @global type $wpdb 
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> create_custom_table<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;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$table_prefix</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;gallery_&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$table_name</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">prefix</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$table_prefix</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;albums&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;CREATE TABLE &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$table_name</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; (
	  id MEDIUMINT(9) NOT NULL AUTO_INCREMENT,	  
	  name VARCHAR(255) NOT NULL,
	  path VARCHAR(255) NOT NULL,	  
	  PRIMARY KEY album_id (id),
    UNIQUE KEY album_path (path)
	) CHARACTER SET utf8 COLLATE utf8_general_ci;&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span>ABSPATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'wp-admin/includes/upgrade.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  dbDelta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</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;">?&gt;</span></pre></td></tr></table></div>

<h2>Note:</h2>
<p>You can also use <code>$GLOBALS["wpdb"]->prefix;</code> instead of:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">prefix</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.bennyn.de/webanwendungen/wordpress/how-to-create-a-wordpress-plugin-with-a-custom-database-table.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress Template erstellen</title>
		<link>http://www.bennyn.de/webanwendungen/wordpress/wordpress-template.html</link>
		<comments>http://www.bennyn.de/webanwendungen/wordpress/wordpress-template.html#comments</comments>
		<pubDate>Wed, 01 Dec 2010 19:08:51 +0000</pubDate>
		<dc:creator>bennyn</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Beispiel]]></category>
		<category><![CDATA[erstellen]]></category>
		<category><![CDATA[Template]]></category>
		<category><![CDATA[Theme]]></category>

		<guid isPermaLink="false">http://www.bennyn.de/?p=2119</guid>
		<description><![CDATA[Für die Erstellung eines WordPress-Templates braucht man nur zwei Dateien. Eine index.php und eine kommentierte style.css sind völlig ausreichend, sofern diese beide Dateien in einem gemeinsamen Unterordner von &#8220;wp-content/themes&#8221; liegen. WordPress stellt für die Gestaltung von Templates unzählige zur Verfügung. Es können auch noch weitaus mehr Dateien als die index.php und style.css verwendet werden. Wer [...]]]></description>
			<content:encoded><![CDATA[<p>Für die Erstellung eines WordPress-Templates braucht man nur zwei Dateien. Eine <strong>index.php</strong> und eine kommentierte <strong>style.css</strong> sind völlig ausreichend, sofern diese beide Dateien in einem gemeinsamen Unterordner von &#8220;wp-content/themes&#8221; liegen. </p>
<p>WordPress stellt für die Gestaltung von Templates unzählige <a href="http://www.bennyn.de/webanwendungen/wordpress/wordpress-variablen-und-template-tags.html" title="WordPress Variablen und Template Tags">Variablen und Template Tags</a> zur Verfügung. Es können auch noch weitaus mehr Dateien als die <b>index.php</b> und <b>style.css</b> verwendet werden. Wer sich dafür interessiert, der sollte sich unbedingt mal die <a href="http://codex.wordpress.org/Template_Hierarchy">WordPress Template Hierarchie</a> anschauen. </p>
<p>Ein sehr gutes Beispiel ist das mit WordPress mitgelieferte Twenty Ten-Design, welches viele Template-Funktionalitäten benutzt. Für Einsteiger ist das Twenty Ten-Template jedoch etwas zu komplex, weshalb ich euch mal eine von mir erstellte Vorlage zeigen möchte.<br />
<span id="more-2119"></span></p>
<h2>Beispiel zum Erstellen eines WordPress Templates</h2>
<p><b>Hinweis:</b><br />
Das Template ist alles andere als schön und keineswegs perfekt. Es soll nur die absolute Basis eines WordPress-Templates darstellen und bei Betrachtung des Codes für mehr Verstandnis beim Anwender sorgen.</p>
<p><b>Template-Speicherort:</b> wp-content/themes/simple_theme</p>
<p><b>style.css</b></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/*
Theme Name: Simple WordPress Template Skeleton
Theme URI: http://www.bennyn.de/
Description: Just a simple example for a WordPress theme.
Author: Benny Neugebauer
Version: 1.0
Tags: Simple, Theme, Template, WordPress
*/</span>
&nbsp;
<span style="color: #00AA00;">*</span>
<span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> Arial<span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
div<span style="color: #cc00cc;">#container</span>
<span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">yellow</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p><b>header.php</b></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.1//EN&quot; &quot;http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; <span style="color: #000000; font-weight: bold;">&lt;?php</span> language_attributes<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>&gt;
	&lt;head&gt;
		&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'charset'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;
		&lt;title&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_title<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'-'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'right'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> <span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/title&gt;
		&lt;link rel=&quot;profile&quot; href=&quot;http://gmpg.org/xfn/11&quot; /&gt;
		&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;all&quot; href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'stylesheet_url'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;
		&lt;link rel=&quot;pingback&quot; href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'pingback_url'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;
		<span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_head<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>
	&lt;/head&gt;
	&lt;body <span style="color: #000000; font-weight: bold;">&lt;?php</span> body_class<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>&gt;
		&lt;div id=&quot;container&quot;&gt;</pre></td></tr></table></div>

<p><b>index.php</b></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> get_header<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>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> get_template_part<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'loop'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'index'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> get_footer<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></td></tr></table></div>

<p><b>loop-index.php</b></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td 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>have_posts<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>
	<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> the_post<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>
		&lt;h1&gt;
			&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_permalink<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; rel=&quot;bookmark&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<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>&lt;/a&gt;
		&lt;/h1&gt;
			<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_content<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;p&gt;...weiterlesen&lt;/p&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
		&lt;p&gt;
			<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Kommentare: &quot;</span><span style="color: #339933;">;</span> comments_number<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'0'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'1'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'%'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;br/&gt;
			<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Datum: &quot;</span><span style="color: #339933;">;</span> the_time<span style="color: #009900;">&#40;</span>get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'date_format'</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>&lt;br/&gt;
			<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Tags: &quot;</span><span style="color: #339933;">;</span> the_category<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">', '</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> the_tags<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">', '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">', '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
		&lt;/p&gt;
	<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">else</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
		&lt;p&gt;
			<span style="color: #000000; font-weight: bold;">&lt;?php</span> _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Sorry, no posts matched your criteria.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
		&lt;/p&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><b>footer.php</b></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">		&lt;/div&gt;
	<span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_footer<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>
	&lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.bennyn.de/webanwendungen/wordpress/wordpress-template.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Relative WordPress Links</title>
		<link>http://www.bennyn.de/webanwendungen/wordpress/relative-wordpress-links.html</link>
		<comments>http://www.bennyn.de/webanwendungen/wordpress/relative-wordpress-links.html#comments</comments>
		<pubDate>Mon, 16 Aug 2010 22:48:31 +0000</pubDate>
		<dc:creator>bennyn</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[absolute]]></category>
		<category><![CDATA[Hyperlinks]]></category>
		<category><![CDATA[Links]]></category>
		<category><![CDATA[Permalinks]]></category>
		<category><![CDATA[relative]]></category>
		<category><![CDATA[Verlinkungen]]></category>

		<guid isPermaLink="false">http://www.bennyn.de/?p=1498</guid>
		<description><![CDATA[Interne Links der eigenen Seite können sich häufig ändern, zum Beispiel wenn man die Domain wechselt oder die Permalink-Struktur von WordPress ändert. Besonders ärgerlich ist das, wenn man in den eigenen Artikeln auf andere Beiträge verlinkt und dann die alten Links nicht mehr gültig sind und man gezwungen ist, alle Verlinkungen manuell anzupassen. Zum Glück [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Interne Links</strong> der eigenen Seite können sich häufig ändern, zum Beispiel wenn man die Domain wechselt oder die <strong>Permalink-Struktur</strong> von WordPress ändert. Besonders ärgerlich ist das, wenn man in den eigenen Artikeln auf andere Beiträge verlinkt und dann die alten Links nicht mehr gültig sind und man gezwungen ist, alle Verlinkungen manuell anzupassen. </p>
<p>Zum Glück gibt es dagegen ein Heilmittel. Den Code dazu findet man im Beitrag &#8220;<a href="http://playground.ebiene.de/2388/wordpress-shortcode-links/">Interne Links in WordPress-Beiträgen zukunftssicher setzen</a>&#8221; von Sergej Müller.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bennyn.de/webanwendungen/wordpress/relative-wordpress-links.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

