WordPress Bhaktapur first formal meeting


Yesterday group of WordPress Bhaktapur had the first formal meeting at FnClick. Even though a small number of people attended the meeting, it was fruitful regarding the decision made. All the attendees shared their ideas regarding the new programs.
Following are the summary of the meeting.
– Formally announced WordPress Bhaktapur formation.
– Formed an organizer team for WordPress Bhaktapur.
– Discussion about short term and long term goal.
– Decided upcoming program which will be announced soon in the group.
– And other discussed other minor topics.
WordPress Bhaktapur group will be conducting programs that will directly benefit the people working on WordPress and also helping NGOs through the WordPress.

SCRIPT_DEBUG constant in WordPress

By default WordPress loads minified version of CSS and JS files so that it would contribute in loading time. As from the user point it is helpful but as for the developer point it might be sometime painful during development. Minified CSS and JS files are very hard to read and understand, so debugging becomes complicated in that case.
In such cases it would be very easy if we could see the unminifed versions of CSS and JS, isn’t it?
Yes, it would be very easy and WordPress have solutions for it.
It is SCRIPT_DEBUG constant.
Just put following line as you define constant WP_DEBUG in wp-config.php file.
define( ‘SCRIPT_DEBUG’, true );
After you put this line in wp-config.php and view page source then you can see the unminified version of the CSS and JS.
That’s a great start, but what about its use in plugin or theme?
Definitely there SCRIPT_DEBUG has its use in plugin or theme. Its better to have minified and unminifed version of CSS and JS in our plugin or theme. We can load our minified version of files using following method.

<?php
function your_plugin_scripts() {
	// if SCRIPT_DEBUG is undefined/ false, use minified libraries
	$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
	// Load script.
	wp_enqueue_script( 'plugin-script-handle', plugin_dir_url( __FILE__ ) . 'assets/plugin-script-file' . $suffix . '.js', array( 'jquery' ) );
	// Load style.
	wp_enqueue_style( 'plugin-style-handle', plugin_dir_url( __FILE__ ) . 'assets/css/plugin-style-file' . $suffix . '.css', array() );
}
add_action( 'wp_enqueue_scripts', 'your_plugin_scripts' );

And this would load minified version of you files if SCRIPT_DEBUG is not defined or false.
Hope this small article would be some how helpful to you. Let me know your feedback.

Add JQuery LightBox in WordPress Gallery

Yūjin kon’nichiwa (友人こんにちは) (Hello Friends in Japanese), Today I am going to talk Little about the WordPress Default Gallery and will show you how to get the JQuery Lightbox effect on the WordPress Gallery.
As we all know WordPress Have it’s default Gallery Feature with shortcode. Its a very simple and useful feature given by WordPress. But while using this feature I felt that it would be great if we could add the JQuery lightbox in the Gallery as default gallery links image to its original image or can a be linked to attachment page. For this idea I searched for a useful plugin and I found Pretty Photo Media, that worked perfectly for me. Download and activate the plugin.
This plugin used “rel” attribute. So I used following hook for adding the attribute. Place it in the functions.php of your current theme.

add_filter( 'wp_get_attachment_link', 'theme_prettyadd', 10, 6);
function theme_prettyadd ($content, $id, $size, $permalink, $icon, $text) {
$content = preg_replace("/<a/"," return $content;
}

Now, Insert your gallery in post or page. While inserting gallery one thing you have to check it you need to change Link To In Gallery Settings Option to “Media File”. If you are done with all things then refresh your gallery page and there you are. The gallery is lightbox enabled.
Comment if you have any question or you can also share your view for this post.