<?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>PHP &#8211; Johnny Morano&#039;s Tech Articles</title>
	<atom:link href="https://jmorano.moretrix.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>https://jmorano.moretrix.com</link>
	<description>Ramblings of an old-fashioned space cowboy</description>
	<lastBuildDate>Wed, 01 Sep 2010 12:09:44 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.6.2</generator>

<image>
	<url>https://jmorano.moretrix.com/wp-content/uploads/2022/04/cropped-jmorano_emblem-32x32.png</url>
	<title>PHP &#8211; Johnny Morano&#039;s Tech Articles</title>
	<link>https://jmorano.moretrix.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Hacking the easy-fancybox WordPress plugin</title>
		<link>https://jmorano.moretrix.com/2010/09/hacking-the-easy-fancybox-wordpress-plugin/</link>
		
		<dc:creator><![CDATA[insaniac]]></dc:creator>
		<pubDate>Wed, 01 Sep 2010 12:09:44 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>
		<guid isPermaLink="false">http://jmorano.moretrix.com/?p=303</guid>

					<description><![CDATA[Intro The easy-fancybox WordPress is actually a rather simple but cool plugin to use, if it would work&#8230;]]></description>
										<content:encoded><![CDATA[<h3>Intro</h3>
<p>The easy-fancybox WordPress is actually a rather simple but cool plugin to use, if it would work out-of-the-box in WordPress 3.x (on Debian unstable).</p>
<p>First of all, a bit of background information:</p>
<ul>
<li>I&#8217;ve installed WordPress using <code>apt-get install wordpress</code> on a Debian Unstable server</li>
<li>I&#8217;ve created three WordPress sites, all three use the same DocumentRoot (<code>/usr/share/wordpress</code>), but they do have separate <code>wp-content/</code> locations (each in their own home directory)</li>
<li>plugins are installed in one of the blogs</li>
<li>Symlinks are creating from the blog that installed plugin to <code>/usr/share/wordpress/wp-content/plugins/</code></li>
</ul>
<p>Now, I have never written a WordPress plugin before, nor have I been developing in PHP for years! But since I really liked this plugin so much, I decided to give it a go (PHP, how hard can it be &#8230; kids play with it!).<br />
<span id="more-303"></span></p>
<h3>The Hack</h3>
<p>After analyzing other WordPress plugins (copy-paste development, don&#8217;t we just all do it!), the hack to make it work was pretty straightforward:<br />
&nbsp;<br />
The original code:</p>
<pre class="brush:php">
// ENQUEUE
wp_enqueue_script('jquery.fancybox', plugins_url($efb, __FILE__).'/jquery.fancybox.pack.js', array('jquery'), '1.3.1');
wp_enqueue_script('jquery.easing', plugins_url($efb, __FILE__).'/jquery.easing.pack.js', array('jquery'), '1.3');
wp_enqueue_script('jquery.mousewheel', plugins_url($efb, __FILE__).'/jquery.mousewheel.pack.js', array('jquery'), '3.0.2');
wp_enqueue_style('jquery.fancybox', plugins_url($efb, __FILE__).'/jquery.fancybox.css.php', false, '1.3.1');
add_action('wp_head', 'easy_fancybox');
}
</pre>
<p>My hack:</p>
<pre class="brush:php">
// ENQUEUE
wp_enqueue_script('jquery.fancybox', plugins_url($efb, basename(dirname(__FILE__))).'/easy-fancybox/jquery.fancybox.pack.js', array('jquery'), '1.3.1');
wp_enqueue_script('jquery.easing', plugins_url($efb, basename(dirname(__FILE__))).'/easy-fancybox/jquery.easing.pack.js', array('jquery'), '1.3');
wp_enqueue_script('jquery.mousewheel', plugins_url($efb, basename(dirname(__FILE__))).'/easy-fancybox/jquery.mousewheel.pack.js', array('jquery'), '3.0.2');
wp_enqueue_style('jquery.fancybox', plugins_url($efb, basename(dirname(__FILE__))).'/easy-fancybox/jquery.fancybox.css.php', false, '1.3.1');
add_action('wp_head', 'easy_fancybox');
}
</pre>
<p>And now the plugins works on my website and on all the other WordPress sites I run on my server (I&#8217;ve installed WordPress 3.x on my Debian server using the apt-get command.)</p>
<p>I&#8217;ve mailed the author my changes <img src="https://s.w.org/images/core/emoji/15.0.3/72x72/1f609.png" alt="😉" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<h3>UPDATE: for 1.3.1.2</h3>
<p>After talking back and forwards with the author of this great plugin, the final result of the hacking is the following:</p>
<pre class="brush:php">
// ENQUEUE
wp_enqueue_script('jquery.fancybox', plugins_url($efb, basename(dirname(__FILE__))."/fancybox.php").'/jquery.fancybox.pack.js', array('jquery'), '1.3.1');
wp_enqueue_script('jquery.easing', plugins_url($efb, basename(dirname(__FILE__)).'/fancybox.php').'/jquery.easing.pack.js', array('jquery'), '1.3.1');
wp_enqueue_script('jquery.mousewheel', plugins_url($efb, basename(dirname(__FILE__)).'/fancybox.php').'/jquery.mousewheel.pack.js', array('jquery'), '3.0.2');
wp_enqueue_style('jquery.fancybox', plugins_url($efb, basename(dirname(__FILE__)).'/fancybox.php').'/jquery.fancybox.css.php', false, '1.3.1');
add_action('wp_head', 'easy_fancybox');
}
</pre>
<h3>UPDATE: 07/10/2010</h3>
<p>This works for version 1.3.1.3. I&#8217;ve only changed the <code class="brush:perl">wp_enqueue_script()</code> statements.</p>
<pre class="brush:perl">
function easy_fancybox_enqueue() {
	// check if fancy.php is moved one dir up like in WPMU's /mu-plugins/
	// NOTE: don't use WP_PLUGIN_URL to avoid problems when installed in /mu-plugins/
	$efb_subdir = (file_exists(dirname(__FILE__).'/easy-fancybox')) ? 'easy-fancybox' : '';

	// ENQUEUE
	// register main fancybox script
	wp_enqueue_script('jquery.fancybox', plugins_url($efb, basename(dirname(__FILE__))."/fancybox.php").'/jquery.fancybox.pack.js', array('jquery'), '1.3.1');

	
	if( "none" != get_option("fancybox_transitionIn") || "none" != get_option("fancybox_transitionOut") ) {
		// first get rid of previously registered variants of jquery.easing (by other plugins)
		wp_deregister_script('jquery.easing');
		wp_deregister_script('jqueryeasing');
		wp_deregister_script('jquery-easing');
		wp_deregister_script('easing');
		// then register our version
		wp_enqueue_script('jquery.easing', plugins_url($efb, basename(dirname(__FILE__)).'/fancybox.php').'/jquery.easing.pack.js', array('jquery'), '1.3.1');

	}
	
	// first get rid of previously registered variants of jquery.mousewheel (by other plugins)
	wp_deregister_script('jquery.mousewheel');
	wp_deregister_script('jquerymousewheel');
	wp_deregister_script('jquery-mousewheel');
	wp_deregister_script('mousewheel');
	// then register our version
	wp_enqueue_script('jquery.mousewheel', plugins_url($efb, basename(dirname(__FILE__)).'/fancybox.php').'/jquery.mousewheel.pack.js', array('jquery'), '3.0.2');
	
	// register style
	wp_enqueue_style('jquery.fancybox', plugins_url($efb, basename(dirname(__FILE__)).'/fancybox.php').'/jquery.fancybox.css.php', false, '1.3.1');

}
</pre>
<h3>UPDATE: 03/11/2010</h3>
<p>This works for version 1.3.2. I&#8217;ve only changed the <code class="brush:perl">wp_enqueue_script()</code> statements.</p>
<pre class="brush:php">
function easy_fancybox_enqueue() {
    // check if fancy.php is moved one dir up like in WPMU's /mu-plugins/
    // NOTE: don't use WP_PLUGIN_URL to avoid problems when installed in /mu-plugins/
    $efb_subdir = (file_exists(dirname(__FILE__).'/easy-fancybox')) ? 'easy-fancybox' : '';

    // ENQUEUE
    // register main fancybox script
    wp_enqueue_script('jquery.fancybox', plugins_url($efb, basename(dirname(__FILE__))."/fancybox.php").'/fancybox/jquery.fancybox-1.3.2.pack.js', array('jquery'), '1.3.2');

    if( "none" != get_option("fancybox_transitionIn") || "none" != get_option("fancybox_transitionOut") ) {
        // first get rid of previously registered variants of jquery.easing (by other plugins)
        wp_deregister_script('jquery.easing');
        wp_deregister_script('jqueryeasing');
        wp_deregister_script('jquery-easing');
        wp_deregister_script('easing');
        // then register our version
        wp_enqueue_script('jquery.easing', plugins_url($efb, basename(dirname(__FILE__)).'/fancybox.php').'/fancybox/jquery.easing-1.3.pack.js', array('jquery'), '1.3');

    }

    // first get rid of previously registered variants of jquery.mousewheel (by other plugins)
    wp_deregister_script('jquery.mousewheel');
    wp_deregister_script('jquerymousewheel');
    wp_deregister_script('jquery-mousewheel');
    wp_deregister_script('mousewheel');
    // then register our version
    wp_enqueue_script('jquery.mousewheel', plugins_url($efb, basename(dirname(__FILE__)).'/fancybox.php').'/fancybox/jquery.mousewheel-3.0.4.pack.js', array('jquery'), '3.0.4');

    // register style
    wp_enqueue_style('jquery.fancybox', plugins_url($efb, basename(dirname(__FILE__)).'/fancybox.php').'/fancybox/jquery.fancybox.css.php', false, '1.3.2');

}
</pre>
<h3>UPDATE: 23/11/2010</h3>
<p>This works for version 1.3.3:</p>
<pre class="brush:php">
function easy_fancybox_enqueue() {
    // check if fancy.php is moved one dir up like in WPMU's /mu-plugins/
    // NOTE: don't use WP_PLUGIN_URL to avoid problems when installed in /mu-plugins/
    $efb_subdir = (file_exists(dirname(__FILE__).'/easy-fancybox')) ? 'easy-fancybox' : '';

    // ENQUEUE
    // register main fancybox script
    wp_enqueue_script('jquery.fancybox', plugins_url($efb, basename(dirname(__FILE__))."/fancybox.php").'/fancybox/jquery.fancybox-1.3.3.pack.js', array('jquery'), '1.3.3');

    if( "none" != get_option("fancybox_transitionIn") || "none" != get_option("fancybox_transitionOut") ) {
        // first get rid of previously registered variants of jquery.easing (by other plugins)
        wp_deregister_script('jquery.easing');
        wp_deregister_script('jqueryeasing');
        wp_deregister_script('jquery-easing');
        wp_deregister_script('easing');
        // then register our version
        wp_enqueue_script('jquery.easing', plugins_url($efb, basename(dirname(__FILE__)).'/fancybox.php').'/fancybox/jquery.easing-1.3.pack.js', array('jquery'), '1.3');

    }

    // first get rid of previously registered variants of jquery.mousewheel (by other plugins)
    wp_deregister_script('jquery.mousewheel');
    wp_deregister_script('jquerymousewheel');
    wp_deregister_script('jquery-mousewheel');
    wp_deregister_script('mousewheel');
    // then register our version
    wp_enqueue_script('jquery.mousewheel', plugins_url($efb, basename(dirname(__FILE__)).'/fancybox.php').'/fancybox/jquery.mousewheel-3.0.4.pack.js', array('jquery'), '3.0.4');

    // register style
    wp_enqueue_style('jquery.fancybox', plugins_url($efb, basename(dirname(__FILE__)).'/fancybox.php').'/fancybox/jquery.fancybox.css.php', false, '1.3.3');

}
</pre>
<h3>UPDATE: 08/03/2011</h3>
<p>Patch for version 1.3.4.8</p>
<pre class="brush:diff">
--- easy-fancybox.php_old       2011-03-08 10:38:07.000000000 +0100
+++ easy-fancybox.php   2011-03-08 10:41:35.000000000 +0100
@@ -226,7 +226,7 @@
 ';
 
 if ('1' == $overlaySpotlight)
-       echo '<style type="text/css">#fancybox-overlay{background-image:url("'. plugins_url(FANCYBOX_SUBDIR.'/light-mask.png', __FILE__) . '");background-position:50% -3%;background-repeat:no-repeat;-o-background-size:100%;-webkit-background-size:100%;-moz-background-size:100%;-khtml-background-size:100%;background-size:100%;position:fixed}</style>
+       echo '<style type="text/css">#fancybox-overlay{background-image:url("'. plugins_url('/easy-fancybox/light-mask.png', basename(__FILE__)) . '");background-position:50% -3%;background-repeat:no-repeat;-o-background-size:100%;-webkit-background-size:100%;-moz-background-size:100%;-khtml-background-size:100%;background-size:100%;position:fixed}</style>
 ';
 
 }
@@ -325,7 +325,7 @@
        $do_fancybox = false;
        $easing = false;
        foreach ($easy_fancybox_array as $value) {
-               // anything enabled?
+            // anything enabled?
                if ( '1' == get_option($value['options']['enable']['id'],$value['options']['enable']['default']) )
                        $do_fancybox = true;
                // easing anyone?
@@ -337,7 +337,7 @@
 
        // ENQUEUE
        // register main fancybox script
-       wp_enqueue_script('jquery.fancybox', plugins_url(FANCYBOX_SUBDIR.'/fancybox/jquery.fancybox-'.FANCYBOX_VERSION.'.pack.js', __FILE__), array('jquery'), FANCYBOX_VERSION);
+       wp_enqueue_script('jquery.fancybox', plugins_url('/easy-fancybox/fancybox/jquery.fancybox-'.FANCYBOX_VERSION.'.pack.js', basename(__FILE__)), array('jquery'), FANCYBOX_VERSION);
 
        foreach ($easy_fancybox_array as $value) {
                if( ( 'elastic' == get_option($value['options']['transitionIn']['id'],$value['options']['transitionIn']['default']) || 'elastic' == get_option($value['options']['transitionOut']['id'],$value['options']['transitionOut']['default']) ) && ( '' != get_option($value['options']['easingIn']['id'],$value['options']['easingIn']['default']) || '' != get_option($value['options']['easingOut']['id'],$value['options']['easingOut']['default']) ) ) {
@@ -352,7 +352,7 @@
                wp_deregister_script('jquery-easing');
                wp_deregister_script('easing');
                // then register our version
-               wp_enqueue_script('jquery.easing', plugins_url(FANCYBOX_SUBDIR.'/fancybox/jquery.easing-'.EASING_VERSION.'.pack.js', __FILE__), array('jquery'), EASING_VERSION);
+               wp_enqueue_script('jquery.easing', plugins_url('/easy-fancybox/fancybox/jquery.easing-'.EASING_VERSION.'.pack.js', basename(__FILE__)), array('jquery'), EASING_VERSION);
        }
 
        // first get rid of previously registered variants of jquery.mousewheel (by other plugins)
@@ -361,10 +361,10 @@
        wp_deregister_script('jquery-mousewheel');
        wp_deregister_script('mousewheel');
        // then register our version
-       wp_enqueue_script('jquery.mousewheel', plugins_url(FANCYBOX_SUBDIR.'/fancybox/jquery.mousewheel-'.MOUSEWHEEL_VERSION.'.pack.js', __FILE__), array('jquery'), MOUSEWHEEL_VERSION);
+       wp_enqueue_script('jquery.mousewheel', plugins_url('/easy-fancybox/fancybox/jquery.mousewheel-'.MOUSEWHEEL_VERSION.'.pack.js', basename(__FILE__)), array('jquery'), MOUSEWHEEL_VERSION);
 
        // register style
-       wp_enqueue_style('easy-fancybox.css', plugins_url(FANCYBOX_SUBDIR.'/easy-fancybox.css.php', __FILE__), false, FANCYBOX_VERSION, 'screen');
+       wp_enqueue_style('easy-fancybox.css', plugins_url('/easy-fancybox/easy-fancybox.css.php', basename(__FILE__)), false, FANCYBOX_VERSION, 'screen');
 
 }
</pre>
<p>In your WordPress plugins directory you will have to make the following symlinks:</p>
<pre class="brush:bash">
$ cd _WORDPRESS_DIR_/wp-content/plugins/easy-fancybox/fancybox/
$ ln -s ../jquery.fancybox.css.php
$ ln -s ../easy-fancybox-nl.mo
$ ln -s ../easy-fancybox-nl_NL.mo
$ ln -s ../easy-fancybox.php
$ ln -s ../easy-fancybox.pota
$ ln -s .. fancybox
</pre>
<p>The plugin and the discussion can be found on <a href="http://4visions.nl/wordpress-plugins/easy-fancybox/">http://4visions.nl/wordpress-plugins/easy-fancybox/</a></p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
