<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>WP Engineer &#187; JavaScript</title> <atom:link href="http://wpengineer.com/tag/javascript/feed/" rel="self" type="application/rss+xml" /><link>http://wpengineer.com</link> <description>WordPress News, Hacks, Tipps, Tutorials, Plugins and Themes</description> <lastBuildDate>Wed, 28 Jul 2010 13:37:05 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=7845</generator> <xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" /> <item><title>WordPress 	Implements Jcrop</title><link>http://wpengineer.com/wordpress-implements-jcrop/</link> <comments>http://wpengineer.com/wordpress-implements-jcrop/#comments</comments> <pubDate>Fri, 10 Apr 2009 11:00:05 +0000</pubDate> <dc:creator>Frank</dc:creator> <category><![CDATA[WordPress News]]></category> <category><![CDATA[JavaScript]]></category> <category><![CDATA[Jcrop]]></category> <category><![CDATA[WordPress]]></category> <category><![CDATA[wp2.8]]></category><guid
isPermaLink="false">http://wpengineer.com/?p=1020</guid> <description><![CDATA[With the upcoming version 2.8 of WordPress, the extension to the JavaScript library jQuery Jcrop is implemented. Jcrop allows directly into a web application to crop images. A first peak shows the site about Jcrop and I'm curious how it will be included in WordPress, currently is no live demo available. Related posts: Cleanup WordPress [...]]]></description> <content:encoded><![CDATA[<p>With the upcoming <a
href="http://wpengineer.com/wordpress-28-small-insights/" class="liinternal">version 2.8 of WordPress</a>, the extension to the JavaScript library <a
href="http://jquery.com/" class="liexternal">jQuery</a> <a
href="http://deepliquid.com/content/Jcrop.html" class="liexternal">Jcrop</a> is implemented. Jcrop allows directly into a web application to crop images.</p><p><img
src="http://wpengineer.com/blog/wp-content/uploads/jcrop.png" alt="jcrop" title="jcrop" width="453" height="89" class="aligncenter size-full wp-image-1021" /></p><p>A first peak shows the site about <a
href="http://deepliquid.com/content/Jcrop.html" class="liexternal">Jcrop</a> and I'm curious how it will be included in WordPress, currently is no live demo available.<br
/><hr
/><h3>Related posts:</h3><ul><li><a
href="http://wpengineer.com/wordpress-header/" rel="bookmark" title="Permanent Link: Cleanup WordPress Header" class="liinternal">Cleanup WordPress Header</a></li><li><a
href="http://wpengineer.com/use-metaboxes-in-your-theme-or-plugin/" rel="bookmark" title="Permanent Link: Use Metaboxes In Your Theme Or Plugin" class="liinternal">Use Metaboxes In Your Theme Or Plugin</a></li></ul><hr
/><p><img
style="float:left;" src="http://wpengineer.com/favicon.ico" alt="WP Engineer Favicon"/> Thanks for subscribing our feed! <a
href="http://buysellads.com/buy/detail/3646/" class="liexternal">Sponsor the WP Engineer Blog</a> and get your brand in front of several hundred users per day!<br
/> &copy; <a
href="http://wpengineer.com/" class="liinternal">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p> ]]></content:encoded> <wfw:commentRss>http://wpengineer.com/wordpress-implements-jcrop/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>Use JavaScript Libraries In And Of WordPress</title><link>http://wpengineer.com/use-javascript-libraries-in-and-of-wordpress/</link> <comments>http://wpengineer.com/use-javascript-libraries-in-and-of-wordpress/#comments</comments> <pubDate>Tue, 25 Nov 2008 16:16:08 +0000</pubDate> <dc:creator>Frank</dc:creator> <category><![CDATA[WordPress Tutorials]]></category> <category><![CDATA[JavaScript]]></category> <category><![CDATA[Lightbox]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Thickbox]]></category> <category><![CDATA[WordPress]]></category> <category><![CDATA[WordPress Hacks]]></category><guid
isPermaLink="false">http://wpengineer.com/?p=415</guid> <description><![CDATA[If you develop in and for WordPress, it's advisable to use a library of the core and a Plugin for the the library with the desired effect. Same for theme and Plugin authors. If you use a function of WordPress to implement JavaScript, you will have less complications and the compatibility between Plugins is much [...]]]></description> <content:encoded><![CDATA[<p>If you develop in and for WordPress, it's advisable to use a library of the core and a Plugin for the the library with the desired effect.</p><p>Same for theme and Plugin authors. If you use a function of WordPress to implement JavaScript, you will have less complications and the compatibility between Plugins is much higher.<br
/> I will show you an example with Thickbox how to use JavaScript from the core.</p><p>There are many possibilities to implement the „Lightbox“ effect on your website. Let's take a close look on a way to use it without a Plugin.<br
/> WordPress has <a
href="http://jquery.com/demo/thickbox/" class="liexternal">Thickbox</a> in their standard installation, so it's not very complicated to use it.<br
/> <span
id="more-415"></span></p><h3><code>wp_enqueue_script()</code></h3><p>Since version 2.1 of WordPress, there is the function <code>wp_enqueue_script()</code> included, which makes the implementation of JavaScript libraries very easy and also checks it. There is no need to use additional JavaScripts, the integration is easy and clean.</p><h3><code>wp_enqueue_style()</code></h3><p>Additionally pay attention to <code>wp_enqueue_style()</code> . With this function you can integrate CSS files.<br
/> Both functions understand many parameters. For the example we need Thickbox, which exists as Plugin for jQuery. That's why you have to load both files, right?</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;">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_enqueue_script<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'thickbox'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><p>WordPress manages the dependencies , so it would be enough if you present the extension and WordPress will detect that jQuery is necessary. It's enough to use <code>wp_enqueue_script( 'thickbox' );</code>. Therefor jQuery will be load and be placed into the right spot of the code. The same happens if other calls are needing jQuery. WordPress pays attention and only allows one call of the library or extension to prevent that they get loaded several times.</p><p>So we integrate in our example the necessary JavaScript files. Additionally we need a style to get the effect of the Thickbox.<br
/> It's enough to include the standard design of WordPress by calling the key <em>Thickbox</em> for the CSS call <code>wp_enqueue_style( 'thickbox' )</code>.</p><p>You can adjust the design for your own preferences.<br
/> Here a small example to add the close icon into your core.</p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#TB_window</span> a<span style="color: #3333ff;">:link </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">transparent</span> !important<span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'http:/examble.com/wp-includes/js/thickbox/tb-close.png'</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">4px</span> !important<span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#TB_window</span> a<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">red</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div><p>If you don't want to look after it, which is only possible in your WordPress backend (otherwise the icons are not available, since they are defined in JS), you can just use the call <code>add_thickbox()</code>. With this everything will be included in Thickbox.</p><p>To connect links with this effect, you have to add to the link the class <em>thickbox</em> .<br
/> In the most simple case it would look like this:</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://examble.com/image.png&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;thickbox&quot;</span><span style="color: #339933;">&gt;</span>
	<span style="color: #339933;">&lt;</span>img src<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://examble.com/image-thumb.png&quot;</span> alt<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Image&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span></pre></div></div><h3>Set class automatically</h3><p>Alternatively you can set the class automatically. The following function in <code>functions.php</code> of the theme does that, but it's not guaranteed that it works in all cases.</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/*
 * Thickbox scan, add class for a
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> fb_add_thickbox<span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/&lt;a(.*?)href=&quot;(.*?).(jpg|jpeg|png|gif|bmp|ico)&quot;(.*?)&gt;&lt;img/U'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;a$1href=&quot;$2.$3&quot; $4 class=&quot;thickbox&quot;&gt;&lt;img'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'the_content'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'fb_add_thickbox'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><h3>Other JavaScripts</h3><p>WordPress offers the developers a range of other libraries and extensions to use them. The implementation of the displayed example above shows that there are no or just few difficulties and the different libraries don't disturb each other. Also it's not necessary to load some libraries several times, which happens because of some Plugins.</p><p>You can find quite a lot of keys in <code>/wp-includes/script-loader.php</code>. It's worth it to check them out. Here is just a selection of keys:</p><ul><li><code>prototype</code></li><li><code>scriptaculous-root</code></li><li><code>scriptaculous-builder</code></li><li><code>scriptaculous-dragdrop</code></li><li><code>scriptaculous-effects</code></li><li><code>scriptaculous-slider</code></li><li><code>scriptaculous-sound</code></li><li><code>scriptaculous-controls</code></li><li><code>jquery</code></li><li><code>jquery-form</code></li><li><code>jquery-color</code></li><li><code>interface</code></li><li><code>suggest</code></li><li><code>schedule</code></li><li><code>jquery-hotkeys</code></li><li><code>thickbox</code></li><li><code>swfupload</code></li><li><code>swfupload-degrade</code></li><li><code>swfupload-swfobject</code></li><li><code>jquery-ui-core</code></li><li><code>jquery-ui-tabs</code></li><li><code>jquery-ui-sortable</code></li><li><code>jquery-ui-draggable</code></li><li><code>jquery-ui-resizable</code></li><li><code>jquery-ui-dialog</code></li><li><code>wp-gears</code></li><li><code>farbtastic</code></li></ul><p>If you deliver a key, you can also deliver it in an array, which extension is necessary.</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;">wp_enqueue_script<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'scriptaculous'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'scriptaculous-dragdrop'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'scriptaculous-slider'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'scriptaculous-controls'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'1.8.0'</span><span style="color: #009900;">&#41;</span></pre></div></div><h3>Own scripts</h3><p>Alternatively you can include your own scripts with the help of the function. Here an example:</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;">wp_enqueue_script<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'my_script'</span><span style="color: #339933;">,</span>  plugins_url<span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'my_plugin_folder/js/my_script.js'</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></pre></div></div><p>It is not necessary to use just js-files, you can also work with PHP, if you like to use some variables of PHP</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;">wp_enqueue_script<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'my_script'</span><span style="color: #339933;">,</span>  plugins_url<span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'my_plugin_folder/js/my_script.php'</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></pre></div></div><p>Do you assume a specific version of the library, you can also deliver the version.</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;">wp_enqueue_script<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'my_script'</span><span style="color: #339933;">,</span>  plugins_url<span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'my_plugin_folder/js/my_script.php'</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: #339933;">,</span> <span style="color: #0000ff;">'1.2.1.3'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><p>This post should show you how to avoid complications with other libraries by using Plugins. The usage of this function is not only for Plugins, you can use it in your WordPress theme too.<br
/><hr
/><h3>Related posts:</h3><ul><li><a
href="http://wpengineer.com/small-tips-using-wordpress-and-jquery/" rel="bookmark" title="Permanent Link: Small Tips Using WordPress and jQuery" class="liinternal">Small Tips Using WordPress and jQuery</a></li><li><a
href="http://wpengineer.com/wordpress-plugin-path/" rel="bookmark" title="Permanent Link: WordPress Plugin-Path" class="liinternal">WordPress Plugin-Path</a></li><li><a
href="http://wpengineer.com/wordpress-searchform-template-tag-or-template/" rel="bookmark" title="Permanent Link: WordPress Searchform, Template Tag or Template" class="liinternal">WordPress Searchform, Template Tag or Template</a></li><li><a
href="http://wpengineer.com/wordpress-28-small-insights/" rel="bookmark" title="Permanent Link: WordPress 2.8 &#8211; Small Insights" class="liinternal">WordPress 2.8 &#8211; Small Insights</a></li><li><a
href="http://wpengineer.com/load-a-stylesheet-only-if-use-gallery/" rel="bookmark" title="Permanent Link: Load A Stylesheet Only If Use Gallery" class="liinternal">Load A Stylesheet Only If Use Gallery</a></li></ul><hr
/><p><img
style="float:left;" src="http://wpengineer.com/favicon.ico" alt="WP Engineer Favicon"/> Thanks for subscribing our feed! <a
href="http://buysellads.com/buy/detail/3646/" class="liexternal">Sponsor the WP Engineer Blog</a> and get your brand in front of several hundred users per day!<br
/> &copy; <a
href="http://wpengineer.com/" class="liinternal">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p> ]]></content:encoded> <wfw:commentRss>http://wpengineer.com/use-javascript-libraries-in-and-of-wordpress/feed/</wfw:commentRss> <slash:comments>6</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Database Caching 30/42 queries in 0.090 seconds using disk
Object Caching 676/755 objects using disk

Served from: wpengineer.com @ 2010-07-29 13:37:11 -->