PluginProbe
Gallery by BestWebSoft – Customizable Image and Photo Galleries for WordPress / 3.05
Gallery by BestWebSoft – Customizable Image and Photo Galleries for WordPress v3.05
4.8.1 4.8.0 4.7.9 trunk 2.01 2.02 2.03 2.04 2.05 2.06 2.07 2.08 2.09 2.10 2.11 2.12 2011.1.01 2011.1.02 3.01 3.02 3.03 3.04 3.05 3.06 3.1 All 131 releases
gallery-plugin / gallery-plugin.php

gallery-plugin.php in Gallery by BestWebSoft – Customizable Image and Photo Galleries for WordPress 3.05, at gallery-plugin.php

922 lines 42.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: Gallery Plugin
4 Plugin URI: http://bestwebsoft.com/plugin/
5 Description: This plugin allows you to implement gallery page into web site.
6 Author: BestWebSoft
7 Version: 3.05
8 Author URI: http://bestwebsoft.com/
9 License: GPLv2 or later
10 */
11
12 /* © Copyright 2011 BestWebSoft ( admin@bestwebsoft.com )
13
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License, version 2, as
16 published by the Free Software Foundation.
17
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 */
27 $gllr_boxes = array (
28 'Upload-File' => array (
29 array( '_gllr_uploadedFile', '', '', '', '' ),
30 )
31 );
32
33 if( ! function_exists( 'gllr_plugin_install' ) ) {
34 function gllr_plugin_install() {
35 if ( ! file_exists( get_stylesheet_directory() .'/gallery-template.php' ) ) {
36 @copy( WP_PLUGIN_DIR .'/gallery-plugin/template/gallery-template.php', get_stylesheet_directory() .'/gallery-template.php' );
37 }
38 else {
39 @copy( get_stylesheet_directory() .'/gallery-template.php', get_stylesheet_directory() .'/gallery-template.php.bak' );
40 @copy( WP_PLUGIN_DIR .'/gallery-plugin/template/gallery-template.php', get_stylesheet_directory() .'/gallery-template.php' );
41 }
42 if ( ! file_exists( get_stylesheet_directory() .'/gallery-single-template.php' ) ) {
43 @copy( WP_PLUGIN_DIR .'/gallery-plugin/template/gallery-single-template.php', get_stylesheet_directory() .'/gallery-single-template.php' );
44 }
45 else {
46 @copy( get_stylesheet_directory() .'/gallery-single-template.php', get_stylesheet_directory() .'/gallery-single-template.php.bak' );
47 @copy( WP_PLUGIN_DIR .'/gallery-plugin/template/gallery-single-template.php', get_stylesheet_directory() .'/gallery-single-template.php' );
48 }
49 }
50 }
51
52 if( ! function_exists( 'gllr_admin_error' ) ) {
53 function gllr_admin_error() {
54 $post = isset( $_REQUEST['post'] ) ? $_REQUEST['post'] : "" ;
55 $post_type = isset( $_REQUEST['post_type'] ) ? $_REQUEST['post_type'] : "" ;
56 if ( ( 'gallery' == get_post_type( $post ) || 'gallery' == $post_type ) && ( ! file_exists( get_stylesheet_directory() .'/gallery-template.php' ) || ! file_exists( get_stylesheet_directory() .'/gallery-single-template.php' ) ) ) {
57 echo '<div class="error"><p><strong>'.__( 'The following files "gallery-template.php" and "gallery-single-template.php" were not found in the directory of your theme. Please copy them from the directory `/wp-content/plugins/gallery-plugin/template/` to the directory of your theme for the correct work of the Gallery plugin', 'gallery' ).'</strong></p></div>';
58 }
59 }
60 }
61
62 if( ! function_exists( 'gllr_plugin_uninstall' ) ) {
63 function gllr_plugin_uninstall() {
64 if ( file_exists( get_stylesheet_directory() .'/gallery-template.php' ) && ! unlink( get_stylesheet_directory() .'/gallery-template.php' ) ) {
65 add_action( 'admin_notices', create_function( '', ' return "Error delete template file";' ) );
66 }
67 if ( file_exists( get_stylesheet_directory() .'/gallery-single-template.php' ) && ! unlink( get_stylesheet_directory() .'/gallery-single-template.php' ) ) {
68 add_action( 'admin_notices', create_function( '', ' return "Error delete template file";' ) );
69 }
70 if( get_option( 'gllr_options' ) ) {
71 delete_option( 'gllr_options' );
72 }
73 }
74 }
75
76 // Create post type for Gallery
77 if( ! function_exists( 'post_type_images' ) ) {
78 function post_type_images() {
79 register_post_type('gallery', array(
80 'labels' => array(
81 'name' => __( 'Galleries', 'gallery' ),
82 'singular_name' => __( 'Gallery', 'gallery' ),
83 'add_new' => __( 'Add New', 'gallery' ),
84 'add_new_item' => __( 'Add New Gallery', 'gallery' ),
85 'edit_item' => __( 'Edit Gallery', 'gallery' ),
86 'new_item' => __( 'New Gallery', 'gallery' ),
87 'view_item' => __( 'View Gallery', 'gallery' ),
88 'search_items' => __( 'Search Galleries', 'gallery' ),
89 'not_found' => __( 'No Galleries found', 'gallery' ),
90 'parent_item_colon' => '',
91 'menu_name' => __( 'Galleries', 'gallery' )
92 ),
93 'public' => true,
94 'publicly_queryable' => true,
95 'query_var' => true,
96 'rewrite' => true,
97 'capability_type' => 'post',
98 'has_archive' => false,
99 'hierarchical' => true,
100 'supports' => array('title', 'editor', 'thumbnail', 'author', 'page-attributes' ),
101 'register_meta_box_cb' => 'init_metaboxes_gallery'
102 ));
103 }
104 }
105
106 if( ! function_exists( 'addImageAncestorToMenu' ) ) {
107 function addImageAncestorToMenu( $classes ) {
108 if ( is_singular( 'gallery' ) ) {
109 global $wpdb, $post;
110
111 if ( empty( $post->ancestors ) ) {
112 $parent_id = $wpdb->get_var( "SELECT $wpdb->posts.ID FROM $wpdb->posts, $wpdb->postmeta WHERE meta_key = '_wp_page_template' AND meta_value = 'gallery-template.php' AND post_status = 'publish' AND $wpdb->posts.ID = $wpdb->postmeta.post_id" );
113 while ( $parent_id ) {
114 $page = get_page( $parent_id );
115 if( $page->post_parent > 0 )
116 $parent_id = $page->post_parent;
117 else
118 break;
119 }
120 wp_reset_query();
121 if( empty( $parent_id ) )
122 return $classes;
123 $post_ancestors = array( $parent_id );
124 }
125 else {
126 $post_ancestors = $post->ancestors;
127 }
128
129 $menuQuery = "SELECT DISTINCT post_id FROM $wpdb->postmeta WHERE meta_key = '_menu_item_object_id' AND meta_value IN (" . implode(',', $post_ancestors) . ")";
130 $menuItems = $wpdb->get_col( $menuQuery );
131
132 if ( is_array( $menuItems ) ) {
133 foreach ( $menuItems as $menuItem ) {
134 if ( in_array( 'menu-item-' . $menuItem, $classes ) ) {
135 $classes[] = 'current-page-ancestor';
136 }
137 }
138 }
139 }
140
141 return $classes;
142 }
143 }
144
145 function init_metaboxes_gallery() {
146 add_meta_box( 'Upload-File', __( 'Upload File', 'gallery' ), 'gllr_post_custom_box', 'gallery', 'normal', 'high' );
147 }
148
149 // Create custom meta box for portfolio post type
150 if ( ! function_exists( 'gllr_post_custom_box' ) ) {
151 function gllr_post_custom_box( $obj = '', $box = '' ) {
152 global $post;
153 $gllr_options = get_option( 'gllr_options' );
154 $key = "gllr_image_text";
155 $error = "";
156 $uploader = true;
157
158 $post_types = get_post_types( array( '_builtin' => false ) );
159 if( ! is_writable ( ABSPATH ."wp-content/plugins/gallery-plugin/upload/files/" ) )
160 @chmod( ABSPATH ."wp-content/plugins/gallery-plugin/upload/files/", 0777 );
161 if( ! is_writable ( ABSPATH ."wp-content/plugins/gallery-plugin/upload/files/" ) ) {
162 $error = __( "The gallery temp directory (gallery-plugin/upload/files) not writeable by your webserver. Please use the standard WP functional to upload the images (media library)", 'gallery' );
163 $uploader = false;
164 }
165 ?>
166 <div style="padding-top:10px;"><label for="uploadscreen"><?php echo __( 'Choose an image to upload:', 'gallery' ); ?></label>
167 <input name="MAX_FILE_SIZE" value="1048576" type="hidden" />
168 <div id="file-uploader-demo1" style="padding-top:10px;">
169 <?php echo $error; ?>
170 <noscript>
171 <p><?php echo __( 'Please enable JavaScript to use the file uploader.', 'gallery' ); ?></p>
172 </noscript>
173 </div>
174 <ul id="files" ></ul>
175 <div id="hidden"></div>
176 <div style="clear:both;"></div></div>
177 <script type="text/javascript">
178 <?php if ($uploader === true) { ?>
179 jQuery(document).ready(function()
180 {
181 var uploader = new qq.FileUploader({
182 element: document.getElementById('file-uploader-demo1'),
183 action: '<?php echo plugins_url( "upload/php.php" , __FILE__ ); ?>',
184 debug: false,
185 onComplete: function(id, fileName, result) {
186 if(result.error) {
187 //
188 }
189 else {
190 jQuery('<li></li>').appendTo('#files').html('<img src="<?php echo plugins_url( "upload/files/" , __FILE__ ); ?>'+fileName+'" alt="" /><div style="width:200px">'+fileName+'<br />' +result.width+'x'+result.height+'</div>').addClass('success');
191 jQuery('<input type="hidden" name="undefined[]" id="undefined" value="'+fileName+'" />').appendTo('#hidden');
192 }
193 }
194 });
195 jQuery('#images_albumdiv').remove();
196
197 });
198 <?php } ?>
199 function img_delete(id) {
200 jQuery('#'+id).hide();
201 jQuery('#delete_images').append('<input type="hidden" name="delete_images[]" value="'+id+'" />');
202 }
203 </script>
204 <?php
205
206 $posts = get_posts(array(
207 "showposts" => -1,
208 "what_to_show" => "posts",
209 "post_status" => "inherit",
210 "post_type" => "attachment",
211 "orderby" => $gllr_options['order_by'],
212 "order" => $gllr_options['order'],
213 "post_mime_type"=> "image/jpeg,image/gif,image/jpg,image/png",
214 "post_parent" => $post->ID)); ?>
215 <ul class="gallery clearfix">
216 <?php foreach ( $posts as $page ):
217 $image_text = get_post_meta( $page->ID, $key, FALSE );
218 echo '<li id="'.$page->ID.'" class="gllr_image_block">';
219 $image_attributes = wp_get_attachment_image_src( $page->ID, 'thumbnail' );
220 echo '<img src="'.$image_attributes[0].'" alt="'.$page->post_title.'" title="'.$page->post_title.'" height="'.get_option( 'thumbnail_size_h' ).'" width="'.get_option( 'thumbnail_size_w' ).'" />';
221 echo '<input type="text" name="gllr_image_text['.$page->ID.']" value="'.get_post_meta( $page->ID, $key, TRUE ).'" class="gllr_image_text" />';
222 echo '<div class="delete"><a href="javascript:void(0);" onclick="img_delete('.$page->ID.');">Delete</a><div/>';
223 echo '</li>';
224 endforeach; ?>
225 </ul><div style="clear:both;"></div>
226 <div id="delete_images"></div>
227 <?php }
228 }
229
230 // Use nonce for verification ...
231 if( ! function_exists ( 'echo_gllr_nonce' ) ) {
232 function echo_gllr_nonce () {
233 echo sprintf(
234 '<input type="hidden" name="%1$s" id="%1$s" value="%2$s" />',
235 'gllr_nonce_name',
236 wp_create_nonce( plugin_basename(__FILE__) )
237 );
238 }
239 }
240
241 if ( ! function_exists ( 'gllr_save_postdata' ) ) {
242 function gllr_save_postdata( $post_id, $post ) {
243 global $post, $wpdb;
244 $key = "gllr_image_text";
245
246 if( isset( $_REQUEST['undefined'] ) && ! empty( $_REQUEST['undefined'] ) ) {
247 $array_file_name = $_REQUEST['undefined'];
248 $uploadFile = array();
249 $newthumb = array();
250 $time = current_time('mysql');
251
252 $uploadDir = wp_upload_dir( $time );
253
254 while( list( $key, $val ) = each( $array_file_name ) ) {
255 $imagename = $val;
256 $uploadFile[] = $uploadDir["path"] ."/" . $imagename;
257 }
258 reset( $array_file_name );
259 require_once( ABSPATH . 'wp-admin/includes/image.php' );
260 while( list( $key, $val ) = each( $array_file_name ) ) {
261 $file_name = $val;
262 if( file_exists( $uploadFile[$key] ) ){
263 $uploadFile[$key] = $uploadDir["path"] ."/" . pathinfo($uploadFile[$key], PATHINFO_FILENAME ).uniqid().".".pathinfo($uploadFile[$key], PATHINFO_EXTENSION );
264 }
265
266 if ( copy ( ABSPATH ."wp-content/plugins/gallery-plugin/upload/files/".$file_name, $uploadFile[$key] ) ) {
267 unlink( ABSPATH ."wp-content/plugins/gallery-plugin/upload/files/".$file_name );
268 $overrides = array('test_form' => false );
269
270 $file = $uploadFile[$key];
271 $filename = basename( $file );
272
273 $wp_filetype = wp_check_filetype( $filename, null );
274 $attachment = array(
275 'post_mime_type' => $wp_filetype['type'],
276 'post_title' => $filename,
277 'post_content' => '',
278 'post_status' => 'inherit'
279 );
280 $attach_id = wp_insert_attachment( $attachment, $file );
281 $attach_data = wp_generate_attachment_metadata( $attach_id, $file );
282 wp_update_attachment_metadata( $attach_id, $attach_data );
283 $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_parent = %d WHERE ID = %d", $post->ID, $attach_id ) );
284 }
285 }
286 }
287 if( isset( $_REQUEST['delete_images'] ) ) {
288 foreach( $_REQUEST['delete_images'] as $delete_id ) {
289 delete_post_meta( $delete_id, $key );
290 wp_delete_attachment( $delete_id );
291 }
292 }
293 if( isset( $_REQUEST['gllr_image_text'] ) ) {
294 $posts = get_posts(array(
295 "showposts" => -1,
296 "what_to_show" => "posts",
297 "post_status" => "inherit",
298 "post_type" => "attachment",
299 "orderby" => "menu_order",
300 "order" => "ASC",
301 "post_mime_type"=> "image/jpeg,image/gif,image/jpg,image/png",
302 "post_parent" => $post->ID));
303 foreach ( $posts as $page ) {
304 if( isset( $_REQUEST['gllr_image_text'][$page->ID] ) ) {
305 $value = $_REQUEST['gllr_image_text'][$page->ID];
306 if( get_post_meta( $page->ID, $key, FALSE ) && $value ) {
307 // Custom field has a value and this custom field exists in database
308 update_post_meta( $page->ID, $key, $value );
309 }
310 elseif($value) {
311 // Custom field has a value, but this custom field does not exist in database
312 add_post_meta( $page->ID, $key, $value );
313 }
314 }
315 }
316 }
317 }
318 }
319
320 if ( ! function_exists ( 'gllr_plugin_init' ) ) {
321 function gllr_plugin_init() {
322 // Internationalization, first(!)
323 load_plugin_textdomain( 'gallery', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
324 }
325 }
326
327 if( ! function_exists( 'gllr_custom_permalinks' ) ) {
328 function gllr_custom_permalinks() {
329 global $wp_rewrite;
330 global $wpdb;
331 $parent = $wpdb->get_var("SELECT $wpdb->posts.post_name FROM $wpdb->posts, $wpdb->postmeta WHERE meta_key = '_wp_page_template' AND meta_value = 'gallery-template.php' AND (post_status = 'publish' OR post_status = 'private') AND $wpdb->posts.ID = $wpdb->postmeta.post_id");
332 if( ! empty( $parent ) ) {
333 $wp_rewrite->add_rule( '(.+)/'.$parent.'/([^/]+)/?$', 'index.php?post_type=gallery&title=$matches[2]&posts_per_page=-1', 'top' );
334 $wp_rewrite->add_rule( ''.$parent.'/([^/]+)/?$', 'index.php?post_type=gallery&title=$matches[1]&posts_per_page=-1', 'top' );
335 $wp_rewrite->add_rule( ''.$parent.'/page/([^/]+)/?$', 'index.php?pagename='.$parent.'&paged=$matches[1]', 'top' );
336 $wp_rewrite->add_rule( ''.$parent.'/page/([^/]+)?$', 'index.php?pagename='.$parent.'&paged=$matches[1]', 'top' );
337 }
338 else {
339 $wp_rewrite->add_rule( '(.+)/gallery/([^/]+)/?$', 'index.php?post_type=gallery&title=$matches[2]&posts_per_page=-1', 'top' );
340 $wp_rewrite->add_rule( 'gallery/([^/]+)/?$', 'index.php?post_type=gallery&title=$matches[1]&posts_per_page=-1', 'top' );
341 $wp_rewrite->add_rule( 'gallery/page/([^/]+)/?$', 'index.php?pagename=gallery&paged=$matches[1]', 'top' );
342 $wp_rewrite->add_rule( 'gallery/page/([^/]+)?$', 'index.php?pagename=gallery&paged=$matches[1]', 'top' );
343 }
344
345
346 $wp_rewrite->flush_rules();
347 }
348 }
349
350 if ( ! function_exists( 'gllr_template_redirect' ) ) {
351 function gllr_template_redirect() {
352 global $wp_query, $post, $posts;
353 if( 'gallery' == get_post_type() && "" == $wp_query->query_vars["s"] ) {
354 include( STYLESHEETPATH . '/gallery-single-template.php' );
355 exit();
356 }
357 }
358 }
359
360
361 // Change the columns for the edit CPT screen
362 if ( ! function_exists( 'gllr_change_columns' ) ) {
363 function gllr_change_columns( $cols ) {
364 $cols = array(
365 'cb' => '<input type="checkbox" />',
366 'title' => __( 'Title', 'gallery' ),
367 'autor' => __( 'Author', 'gallery' ),
368 'gallery' => __( 'Photo\'s', 'gallery' ),
369 'status' => __( 'Public', 'gallery' ),
370 'dates' => __( 'Date', 'gallery' )
371 );
372 return $cols;
373 }
374 }
375
376 if ( ! function_exists( 'gllr_custom_columns' ) ) {
377 function gllr_custom_columns( $column, $post_id ) {
378 global $wpdb;
379 $post = get_post( $post_id );
380 $row = $wpdb->get_results( "SELECT *
381 FROM $wpdb->posts
382 WHERE $wpdb->posts.post_parent = $post_id
383 AND $wpdb->posts.post_type = 'attachment'
384 AND (
385 $wpdb->posts.post_status = 'inherit'
386 )
387 ORDER BY $wpdb->posts.post_title ASC" );
388 switch ( $column ) {
389 //case "category":
390 case "autor":
391 $author_id=$post->post_author;
392 echo '<a href="edit.php?post_type=post&amp;author='.$author_id.'">'.get_the_author_meta( 'user_nicename' , $author_id ).'</a>';
393 break;
394 case "gallery":
395 echo count($row);
396 break;
397 case "status":
398 if( $post->post_status == 'publish' )
399 echo '<a href="javascript:void(0)">Yes</a>';
400 else
401 echo '<a href="javascript:void(0)">No</a>';
402 break;
403 case "dates":
404 echo strtolower( __( date( "F", strtotime( $post->post_date ) ), 'kerksite' ) )." ".date( "j Y", strtotime( $post->post_date ) );
405 break;
406 }
407 }
408 }
409
410 if ( ! function_exists( 'get_ID_by_slug' ) ) {
411 function get_ID_by_slug($page_slug) {
412 $page = get_page_by_path($page_slug);
413 if ($page) {
414 return $page->ID;
415 }
416 else {
417 return null;
418 }
419 }
420 }
421
422 if( ! function_exists( 'the_excerpt_max_charlength' ) ) {
423 function the_excerpt_max_charlength( $charlength ) {
424 $excerpt = get_the_excerpt();
425 $charlength ++;
426 if( strlen( $excerpt ) > $charlength ) {
427 $subex = substr( $excerpt, 0, $charlength-5 );
428 $exwords = explode( " ", $subex );
429 $excut = - ( strlen ( $exwords [ count( $exwords ) - 1 ] ) );
430 if( $excut < 0 ) {
431 echo substr( $subex, 0, $excut );
432 }
433 else {
434 echo $subex;
435 }
436 echo "...";
437 }
438 else {
439 echo $excerpt;
440 }
441 }
442 }
443
444 if( ! function_exists( 'gllr_page_css_class' ) ) {
445 function gllr_page_css_class( $classes, $item ) {
446 global $wpdb;
447 $post_type = get_query_var( 'post_type' );
448 $parent_id = 0;
449 if( $post_type == "gallery" ) {
450 $parent_id = $wpdb->get_var( "SELECT $wpdb->posts.ID FROM $wpdb->posts, $wpdb->postmeta WHERE meta_key = '_wp_page_template' AND meta_value = 'gallery-template.php' AND post_status = 'publish' AND $wpdb->posts.ID = $wpdb->postmeta.post_id" );
451 while ( $parent_id ) {
452 $page = get_page( $parent_id );
453 if( $page->post_parent > 0 )
454 $parent_id = $page->post_parent;
455 else
456 break;
457 }
458 wp_reset_query();
459 }
460 if ( $item->ID == $parent_id ) {
461 array_push( $classes, 'current_page_item' );
462 }
463 return $classes;
464 }
465 }
466
467 if( ! function_exists( 'bws_add_menu_render' ) ) {
468 function bws_add_menu_render() {
469 global $title;
470 $active_plugins = get_option('active_plugins');
471 $all_plugins = get_plugins();
472
473 $array_activate = array();
474 $array_install = array();
475 $array_recomend = array();
476 $count_activate = $count_install = $count_recomend = 0;
477 $array_plugins = array(
478 array( 'captcha\/captcha.php', 'Captcha', 'http://wordpress.org/extend/plugins/captcha/', 'http://bestwebsoft.com/plugin/captcha-plugin/', '/wp-admin/plugin-install.php?tab=search&type=term&s=Captcha+bestwebsoft&plugin-search-input=Search+Plugins', 'admin.php?page=captcha.php' ),
479 array( 'contact-form-plugin\/contact_form.php', 'Contact Form', 'http://wordpress.org/extend/plugins/contact-form-plugin/', 'http://bestwebsoft.com/plugin/contact-form/', '/wp-admin/plugin-install.php?tab=search&type=term&s=Contact+Form+bestwebsoft&plugin-search-input=Search+Plugins', 'admin.php?page=contact_form.php' ),
480 array( 'facebook-button-plugin\/facebook-button-plugin.php', 'Facebook Like Button Plugin', 'http://wordpress.org/extend/plugins/facebook-button-plugin/', 'http://bestwebsoft.com/plugin/facebook-like-button-plugin/', '/wp-admin/plugin-install.php?tab=search&type=term&s=Facebook+Like+Button+Plugin+bestwebsoft&plugin-search-input=Search+Plugins', 'admin.php?page=facebook-button-plugin.php' ),
481 array( 'twitter-plugin\/twitter.php', 'Twitter Plugin', 'http://wordpress.org/extend/plugins/twitter-plugin/', 'http://bestwebsoft.com/plugin/twitter-plugin/', '/wp-admin/plugin-install.php?tab=search&type=term&s=Twitter+Plugin+bestwebsoft&plugin-search-input=Search+Plugins', 'admin.php?page=twitter.php' ),
482 array( 'portfolio\/portfolio.php', 'Portfolio', 'http://wordpress.org/extend/plugins/portfolio/', 'http://bestwebsoft.com/plugin/portfolio-plugin/', '/wp-admin/plugin-install.php?tab=search&type=term&s=Portfolio+bestwebsoft&plugin-search-input=Search+Plugins', '' ),
483 array( 'gallery-plugin\/gallery-plugin.php', 'Gallery', 'http://wordpress.org/extend/plugins/gallery-plugin/', 'http://bestwebsoft.com/plugin/gallery-plugin/', '/wp-admin/plugin-install.php?tab=search&type=term&s=Gallery+Plugin+bestwebsoft&plugin-search-input=Search+Plugins', '' ),
484 array( 'adsense-plugin\/adsense-plugin.php', 'Google AdSense Plugin', 'http://wordpress.org/extend/plugins/adsense-plugin/', 'http://bestwebsoft.com/plugin/google-adsense-plugin/', '/wp-admin/plugin-install.php?tab=search&type=term&s=Adsense+Plugin+bestwebsoft&plugin-search-input=Search+Plugins', 'admin.php?page=adsense-plugin.php' ),
485 array( 'custom-search-plugin\/custom-search-plugin.php', 'Custom Search Plugin', 'http://wordpress.org/extend/plugins/custom-search-plugin/', 'http://bestwebsoft.com/plugin/custom-search-plugin/', '/wp-admin/plugin-install.php?tab=search&type=term&s=Custom+Search+plugin+bestwebsoft&plugin-search-input=Search+Plugins', 'admin.php?page=custom_search.php' ),
486 array( 'quotes-and-tips\/quotes-and-tips.php', 'Quotes and Tips', 'http://wordpress.org/extend/plugins/quotes-and-tips/', 'http://bestwebsoft.com/plugin/quotes-and-tips/', '/wp-admin/plugin-install.php?tab=search&type=term&s=Quotes+and+Tips+bestwebsoft&plugin-search-input=Search+Plugins', 'admin.php?page=quotes-and-tips.php' ),
487 array( 'google-sitemap-plugin\/google-sitemap-plugin.php', 'Google sitemap plugin', 'http://wordpress.org/extend/plugins/google-sitemap-plugin/', 'http://bestwebsoft.com/plugin/google-sitemap-plugin/', '/wp-admin/plugin-install.php?tab=search&type=term&s=Google+sitemap+plugin+bestwebsoft&plugin-search-input=Search+Plugins', 'admin.php?page=google-sitemap-plugin.php' )
488 );
489 foreach($array_plugins as $plugins) {
490 if( 0 < count( preg_grep( "/".$plugins[0]."/", $active_plugins ) ) ) {
491 $array_activate[$count_activate]['title'] = $plugins[1];
492 $array_activate[$count_activate]['link'] = $plugins[2];
493 $array_activate[$count_activate]['href'] = $plugins[3];
494 $array_activate[$count_activate]['url'] = $plugins[5];
495 $count_activate++;
496 }
497 else if( array_key_exists(str_replace("\\", "", $plugins[0]), $all_plugins) ) {
498 $array_install[$count_install]['title'] = $plugins[1];
499 $array_install[$count_install]['link'] = $plugins[2];
500 $array_install[$count_install]['href'] = $plugins[3];
501 $count_install++;
502 }
503 else {
504 $array_recomend[$count_recomend]['title'] = $plugins[1];
505 $array_recomend[$count_recomend]['link'] = $plugins[2];
506 $array_recomend[$count_recomend]['href'] = $plugins[3];
507 $array_recomend[$count_recomend]['slug'] = $plugins[4];
508 $count_recomend++;
509 }
510 }
511 ?>
512 <div class="wrap">
513 <div class="icon32 icon32-bws" id="icon-options-general"></div>
514 <h2><?php echo $title;?></h2>
515 <?php if( 0 < $count_activate ) { ?>
516 <div>
517 <h3><?php _e( 'Activated plugins', 'gallery' ); ?></h3>
518 <?php foreach( $array_activate as $activate_plugin ) { ?>
519 <div style="float:left; width:200px;"><?php echo $activate_plugin['title']; ?></div> <p><a href="<?php echo $activate_plugin['link']; ?>" target="_blank"><?php echo __( "Read more", 'gallery'); ?></a> <a href="<?php echo $activate_plugin['url']; ?>"><?php echo __( "Settings", 'gallery'); ?></a></p>
520 <?php } ?>
521 </div>
522 <?php } ?>
523 <?php if( 0 < $count_install ) { ?>
524 <div>
525 <h3><?php _e( 'Installed plugins', 'gallery' ); ?></h3>
526 <?php foreach($array_install as $install_plugin) { ?>
527 <div style="float:left; width:200px;"><?php echo $install_plugin['title']; ?></div> <p><a href="<?php echo $install_plugin['link']; ?>" target="_blank"><?php echo __( "Read more", 'gallery'); ?></a></p>
528 <?php } ?>
529 </div>
530 <?php } ?>
531 <?php if( 0 < $count_recomend ) { ?>
532 <div>
533 <h3><?php _e( 'Recommended plugins', 'gallery' ); ?></h3>
534 <?php foreach( $array_recomend as $recomend_plugin ) { ?>
535 <div style="float:left; width:200px;"><?php echo $recomend_plugin['title']; ?></div> <p><a href="<?php echo $recomend_plugin['link']; ?>" target="_blank"><?php echo __( "Read more", 'gallery'); ?></a> <a href="<?php echo $recomend_plugin['href']; ?>" target="_blank"><?php echo __( "Download", 'gallery'); ?></a> <a class="install-now" href="<?php echo get_bloginfo( "url" ) . $recomend_plugin['slug']; ?>" title="<?php esc_attr( sprintf( __( 'Install %s' ), $recomend_plugin['title'] ) ) ?>" target="_blank"><?php echo __( 'Install now from wordpress.org', 'gallery' ) ?></a></p>
536 <?php } ?>
537 <span style="color: rgb(136, 136, 136); font-size: 10px;"><?php _e( 'If you have any questions, please contact us via plugin@bestwebsoft.com or fill in our contact form on our site', 'gallery' ); ?> <a href="http://bestwebsoft.com/contact/">http://bestwebsoft.com/contact/</a></span>
538 </div>
539 <?php } ?>
540 </div>
541 <?php
542 }
543 }
544
545 if( ! function_exists( 'add_gllr_admin_menu' ) ) {
546 function add_gllr_admin_menu() {
547 add_menu_page( 'BWS Plugins', 'BWS Plugins', 'manage_options', 'bws_plugins', 'bws_add_menu_render', plugins_url("images/px.png", __FILE__), 1001);
548 add_submenu_page('bws_plugins', __( 'Gallery', 'gallery' ), __( 'Gallery', 'gallery' ), 'manage_options', "gallery-plugin.php", 'gllr_settings_page');
549
550 //call register settings function
551 add_action( 'admin_init', 'register_gllr_settings' );
552 }
553 }
554
555 // register settings function
556 if( ! function_exists( 'register_gllr_settings' ) ) {
557 function register_gllr_settings() {
558 global $wpmu;
559 global $gllr_options;
560
561 $gllr_option_defaults = array(
562 'gllr_custom_size_name' => array( 'album-thumb', 'photo-thumb' ),
563 'gllr_custom_size_px' => array( array(120, 80), array(160, 120) ),
564 'custom_image_row_count' => 3,
565 'start_slideshow' => 0,
566 'slideshow_interval' => 2000,
567 'order_by' => 'menu_order',
568 'order' => 'ASC',
569 'return_link' => 0,
570 'return_link_text' => 'Return to all albums',
571 'return_link_shortcode' => 0
572 );
573
574 // install the option defaults
575 if ( 1 == $wpmu ) {
576 if( ! get_site_option( 'gllr_options' ) ) {
577 add_site_option( 'gllr_options', $gllr_option_defaults, '', 'yes' );
578 }
579 }
580 else {
581 if( ! get_option( 'gllr_options' ) )
582 add_option( 'gllr_options', $gllr_option_defaults, '', 'yes' );
583 }
584
585 // get options from the database
586 if ( 1 == $wpmu )
587 $gllr_options = get_site_option( 'gllr_options' ); // get options from the database
588 else
589 $gllr_options = get_option( 'gllr_options' );// get options from the database
590
591 // array merge incase this version has added new options
592 $gllr_options = array_merge( $gllr_option_defaults, $gllr_options );
593 if ( function_exists( 'add_image_size' ) ) {
594 add_image_size( 'album-thumb', $gllr_options['gllr_custom_size_px'][0][0], $gllr_options['gllr_custom_size_px'][0][1], true );
595 add_image_size( 'photo-thumb', $gllr_options['gllr_custom_size_px'][1][0], $gllr_options['gllr_custom_size_px'][1][1], true );
596 }
597 }
598 }
599
600 if( ! function_exists( 'gllr_settings_page' ) ) {
601 function gllr_settings_page() {
602 global $gllr_options;
603 $error = "";
604
605 // Save data for settings page
606 if( isset( $_REQUEST['gllr_form_submit'] ) ) {
607 $gllr_request_options = array();
608 $gllr_request_options["gllr_custom_size_name"] = $gllr_options["gllr_custom_size_name"];
609
610 $gllr_request_options["gllr_custom_size_px"] = array(
611 array( intval( trim( $_REQUEST['custom_image_size_w_album'] ) ), intval( trim($_REQUEST['custom_image_size_h_album'] ) ) ),
612 array( intval( trim( $_REQUEST['custom_image_size_w_photo'] ) ), intval( trim($_REQUEST['custom_image_size_h_photo'] ) ) )
613 );
614 $gllr_request_options["custom_image_row_count"] = intval( trim( $_REQUEST['custom_image_row_count'] ) );
615 if( $gllr_request_options["custom_image_row_count"] == "" || $gllr_request_options["custom_image_row_count"] < 1 )
616 $gllr_request_options["custom_image_row_count"] = 1;
617
618 if( isset( $_REQUEST['start_slideshow'] ) )
619 $gllr_request_options["start_slideshow"] = 1;
620 else
621 $gllr_request_options["start_slideshow"] = 0;
622 $gllr_request_options["slideshow_interval"] = $_REQUEST['slideshow_interval'];
623 $gllr_request_options["order_by"] = $_REQUEST['order_by'];
624 $gllr_request_options["order"] = $_REQUEST['order'];
625
626 if( isset( $_REQUEST['return_link'] ) )
627 $gllr_request_options["return_link"] = 1;
628 else
629 $gllr_request_options["return_link"] = 0;
630
631 if( isset( $_REQUEST['return_link_shortcode'] ) )
632 $gllr_request_options["return_link_shortcode"] = 1;
633 else
634 $gllr_request_options["return_link_shortcode"] = 0;
635
636 $gllr_request_options["return_link_text"] = $_REQUEST['return_link_text'];
637
638 // array merge incase this version has added new options
639 $gllr_options = array_merge( $gllr_options, $gllr_request_options );
640
641 // Check select one point in the blocks Arithmetic actions and Difficulty on settings page
642 update_option( 'gllr_options', $gllr_options, '', 'yes' );
643 $message = __( "Options saved.", 'gallery' );
644 }
645
646 if ( ! file_exists( get_stylesheet_directory() .'/gallery-template.php' ) || ! file_exists( get_stylesheet_directory() .'/gallery-single-template.php' ) ) {
647 $error .= __( 'The following files "gallery-template.php" and "gallery-single-template.php" were not found in the directory of your theme. Please copy them from the directory `/wp-content/plugins/gallery-plugin/template/` to the directory of your theme for the correct work of the Gallery plugin', 'gallery' );
648 }
649
650 // Display form on the setting page
651 ?>
652 <div class="wrap">
653 <div class="icon32 icon32-bws" id="icon-options-general"></div>
654 <h2><?php _e('Gallery Options', 'gallery' ); ?></h2>
655 <div class="updated fade" <?php if( ! isset( $_REQUEST['gllr_form_submit'] ) || $error != "" ) echo "style=\"display:none\""; ?>><p><strong><?php echo $message; ?></strong></p></div>
656 <div class="error" <?php if( "" == $error ) echo "style=\"display:none\""; ?>><p><strong><?php echo $error; ?></strong></p></div>
657 <p><?php _e( "If you would like to add a Single Gallery to your page or post, just copy and put this shortcode onto your post or page content:", 'gallery' ); ?> [print_gllr id=Your_gallery_id]</p>
658 <form method="post" action="admin.php?page=gallery-plugin.php" id="gllr_form_image_size">
659 <table class="form-table">
660 <tr valign="top">
661 <th scope="row"><?php _e('The size of the cover album for gallery', 'gallery' ); ?> </th>
662 <td>
663 <label for="custom_image_size_name"><?php _e( 'Image size name', 'gallery' ); ?></label> <?php echo $gllr_options["gllr_custom_size_name"][0]; ?><br />
664 <label for="custom_image_size_w"><?php _e( 'Width (in px)', 'gallery' ); ?></label> <input type="text" name="custom_image_size_w_album" value="<?php echo $gllr_options["gllr_custom_size_px"][0][0]; ?>" /><br />
665 <label for="custom_image_size_h"><?php _e( 'Height (in px)', 'gallery' ); ?></label> <input type="text" name="custom_image_size_h_album" value="<?php echo $gllr_options["gllr_custom_size_px"][0][1]; ?>" />
666 </td>
667 </tr>
668 <tr valign="top">
669 <th scope="row"><?php _e('Size for gallery image', 'gallery' ); ?> </th>
670 <td>
671 <label for="custom_image_size_name"><?php _e( 'Image size name', 'gallery' ); ?></label> <?php echo $gllr_options["gllr_custom_size_name"][1]; ?><br />
672 <label for="custom_image_size_w"><?php _e( 'Width (in px)', 'gallery' ); ?></label> <input type="text" name="custom_image_size_w_photo" value="<?php echo $gllr_options["gllr_custom_size_px"][1][0]; ?>" /><br />
673 <label for="custom_image_size_h"><?php _e( 'Height (in px)', 'gallery' ); ?></label> <input type="text" name="custom_image_size_h_photo" value="<?php echo $gllr_options["gllr_custom_size_px"][1][1]; ?>" />
674 </td>
675 </tr>
676 <tr valign="top">
677 <td colspan="2"><span style="color: #888888;font-size: 10px;"><?php _e( 'WordPress will create a copy of the post thumbnail with the specified dimensions when you upload a new photo.', 'gallery' ); ?></span></th>
678 </tr>
679 <tr valign="top">
680 <th scope="row"><?php _e('Count images in row', 'gallery' ); ?> </th>
681 <td>
682 <input type="text" name="custom_image_row_count" value="<?php echo $gllr_options["custom_image_row_count"]; ?>" />
683 </td>
684 </tr>
685 <tr valign="top">
686 <th scope="row"><?php _e('Start slideshow', 'gallery' ); ?> </th>
687 <td>
688 <input type="checkbox" name="start_slideshow" value="1" <?php if( $gllr_options["start_slideshow"] == 1 ) echo 'checked="checked"'; ?> />
689 </td>
690 </tr>
691 <tr valign="top">
692 <th scope="row"><?php _e('Slideshow interval', 'gallery' ); ?> </th>
693 <td>
694 <input type="text" name="slideshow_interval" value="<?php echo $gllr_options["slideshow_interval"]; ?>" />
695 </td>
696 </tr>
697 <tr valign="top">
698 <th scope="row"><?php _e('Attachments order by', 'gallery' ); ?> </th>
699 <td>
700 <input type="radio" name="order_by" value="ID" <?php if( $gllr_options["order_by"] == 'ID' ) echo 'checked="checked"'; ?> /> <label class="label_radio" for="order_by"><?php _e( 'attachment id', 'gallery' ); ?></label><br />
701 <input type="radio" name="order_by" value="title" <?php if( $gllr_options["order_by"] == 'title' ) echo 'checked="checked"'; ?> /> <label class="label_radio" for="order_by"><?php _e( 'attachment title', 'gallery' ); ?></label><br />
702 <input type="radio" name="order_by" value="date" <?php if( $gllr_options["order_by"] == 'date' ) echo 'checked="checked"'; ?> /> <label class="label_radio" for="order_by"><?php _e( 'date', 'gallery' ); ?></label><br />
703 <input type="radio" name="order_by" value="menu_order" <?php if( $gllr_options["order_by"] == 'menu_order' ) echo 'checked="checked"'; ?> /> <label class="label_radio" for="order_by"><?php _e( 'attachments order (the integer fields in the Insert / Upload Media Gallery dialog )', 'gallery' ); ?></label><br />
704 <input type="radio" name="order_by" value="rand" <?php if( $gllr_options["order_by"] == 'rand' ) echo 'checked="checked"'; ?> /> <label class="label_radio" for="order_by"><?php _e( 'random', 'gallery' ); ?></label>
705 </td>
706 </tr>
707 <tr valign="top">
708 <th scope="row"><?php _e('Attachments order', 'gallery' ); ?> </th>
709 <td>
710 <input type="radio" name="order" value="ASC" <?php if( $gllr_options["order"] == 'ASC' ) echo 'checked="checked"'; ?> /> <label class="label_radio" for="order"><?php _e( 'ASC (ascending order from lowest to highest values - 1, 2, 3; a, b, c)', 'gallery' ); ?></label><br />
711 <input type="radio" name="order" value="DESC" <?php if( $gllr_options["order"] == 'DESC' ) echo 'checked="checked"'; ?> /> <label class="label_radio" for="order"><?php _e( 'DESC (descending order from highest to lowest values - 3, 2, 1; c, b, a)', 'gallery' ); ?></label>
712 </td>
713 </tr>
714 <tr valign="top">
715 <th scope="row"><?php _e('Display Return link', 'gallery' ); ?> </th>
716 <td>
717 <input type="checkbox" name="return_link" value="1" <?php if( $gllr_options["return_link"] == 1 ) echo 'checked="checked"'; ?> />
718 </td>
719 </tr>
720 <tr valign="top">
721 <th scope="row"><?php _e('Display Return link in shortcode', 'gallery' ); ?> </th>
722 <td>
723 <input type="checkbox" name="return_link_shortcode" value="1" <?php if( $gllr_options["return_link_shortcode"] == 1 ) echo 'checked="checked"'; ?> />
724 </td>
725 </tr>
726 <tr valign="top">
727 <th scope="row"><?php _e('Label for Return link', 'gallery' ); ?> </th>
728 <td>
729 <input type="text" name="return_link_text" value="<?php echo $gllr_options["return_link_text"]; ?>" style="width:200px;" />
730 </td>
731 </tr>
732 </table>
733 <input type="hidden" name="gllr_form_submit" value="submit" />
734 <p class="submit">
735 <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
736 </p>
737 </form>
738 </div>
739 <?php }
740 }
741
742 if( ! function_exists( 'gllr_register_plugin_links' ) ) {
743 function gllr_register_plugin_links($links, $file) {
744 $base = plugin_basename(__FILE__);
745 if ($file == $base) {
746 $links[] = '<a href="admin.php?page=gallery-plugin.php">' . __( 'Settings', 'gallery' ) . '</a>';
747 $links[] = '<a href="http://wordpress.org/extend/plugins/gallery-plugin/faq/" target="_blank">' . __( 'FAQ', 'gallery' ) . '</a>';
748 $links[] = '<a href="Mailto:plugin@bestwebsoft.com">' . __( 'Support', 'gallery' ) . '</a>';
749 }
750 return $links;
751 }
752 }
753
754 if( ! function_exists( 'gllr_plugin_action_links' ) ) {
755 function gllr_plugin_action_links( $links, $file ) {
756 //Static so we don't call plugin_basename on every plugin row.
757 static $this_plugin;
758 if ( ! $this_plugin ) $this_plugin = plugin_basename(__FILE__);
759
760 if ( $file == $this_plugin ){
761 $settings_link = '<a href="admin.php?page=gallery-plugin.php">' . __( 'Settings', 'gallery' ) . '</a>';
762 array_unshift( $links, $settings_link );
763 }
764 return $links;
765 } // end function gllr_plugin_action_links
766 }
767
768 if( ! function_exists( 'gllr_add_script' ) ){
769 function gllr_add_script() { ?>
770 <script type="text/javascript">
771 if ( ! window.jQuery ) {
772 document.write('<s'+'cript src="http://code.jquery.com/jquery-latest.js"></s'+'cript>');
773 }
774 </script>
775 <?php }
776 }
777
778 if ( ! function_exists ( 'gllr_admin_head' ) ) {
779 function gllr_admin_head() {
780 wp_enqueue_style( 'gllrStylesheet', plugins_url( 'css/stylesheet.css', __FILE__ ) );
781 wp_enqueue_style( 'gllrFileuploaderCss', plugins_url( 'upload/fileuploader.css', __FILE__ ) );
782 wp_enqueue_script( 'gllrFileuploaderJs', plugins_url( 'upload/fileuploader.js', __FILE__ ), array( 'jquery' ) );
783 }
784 }
785
786 if ( ! function_exists ( 'gllr_wp_head' ) ) {
787 function gllr_wp_head() {
788 wp_enqueue_style( 'gllrStylesheet', plugins_url( 'css/stylesheet.css', __FILE__ ) );
789 wp_enqueue_style( 'gllrFancyboxStylesheet', plugins_url( 'fancybox/jquery.fancybox-1.3.4.css', __FILE__ ) );
790 wp_enqueue_script( 'gllrFancyboxMousewheelJs', plugins_url( 'fancybox/jquery.mousewheel-3.0.4.pack.js', __FILE__ ), array( 'jquery' ) );
791 wp_enqueue_script( 'gllrFancyboxJs', plugins_url( 'fancybox/jquery.fancybox-1.3.4.pack.js', __FILE__ ), array( 'jquery' ) );
792 }
793 }
794
795 if ( ! function_exists ( 'gllr_shortcode' ) ) {
796 function gllr_shortcode( $atts ) {
797 extract( shortcode_atts( array(
798 'id' => ''
799 ), $attr )
800 );
801 $args = array(
802 'post_type' => 'gallery',
803 'post_status' => 'publish',
804 'p' => $id,
805 'posts_per_page' => 1
806 );
807 $second_query = new WP_Query( $args );
808 $gllr_options = get_option( 'gllr_options' );
809 if ($second_query->have_posts()) :
810 while ($second_query->have_posts()) :
811 global $post;
812 $second_query->the_post(); ?>
813 <div class="gallery_box_single">
814 <?php the_content();
815 $posts = get_posts(array(
816 "showposts" => -1,
817 "what_to_show" => "posts",
818 "post_status" => "inherit",
819 "post_type" => "attachment",
820 "orderby" => $gllr_options['order_by'],
821 "order" => $gllr_options['order'],
822 "post_mime_type"=> "image/jpeg,image/gif,image/jpg,image/png",
823 "post_parent" => $post->ID
824 ));
825 if( count( $posts ) > 0 ) {
826 $count_image_block = 0; ?>
827 <div class="gallery clearfix">
828 <?php foreach( $posts as $attachment ) {
829 $key = "gllr_image_text";
830 $image_attributes = wp_get_attachment_image_src( $attachment->ID, 'photo-thumb' );
831 $image_attributes_large = wp_get_attachment_image_src( $attachment->ID, 'large' );
832 if( $count_image_block % $gllr_options['custom_image_row_count'] == 0 ) { ?>
833 <div class="gllr_image_row">
834 <?php } ?>
835 <div class="gllr_image_block">
836 <p style="width:<?php echo $gllr_options['gllr_custom_size_px'][1][0]+20; ?>px;height:<?php echo $gllr_options['gllr_custom_size_px'][1][1]+20; ?>px;">
837 <a rel="gallery_fancybox" href="<?php echo $image_attributes_large[0]; ?>" title="<?php echo get_post_meta( $attachment->ID, $key, true ); ?>">
838 <img style="width:<?php echo $gllr_options['gllr_custom_size_px'][1][0]; ?>px;height:<?php echo $gllr_options['gllr_custom_size_px'][1][1]; ?>px;" alt="" title="<?php echo get_post_meta( $attachment->ID, $key, true ); ?>" src="<?php echo $image_attributes[0]; ?>" />
839 </a>
840 </p>
841 <div style="width:<?php echo $gllr_options['gllr_custom_size_px'][1][0]+20; ?>px;" class="gllr_single_image_text"><?php echo get_post_meta( $attachment->ID, $key, true ); ?>&nbsp;</div>
842 </div>
843 <?php if($count_image_block%$gllr_options['custom_image_row_count'] == $gllr_options['custom_image_row_count']-1 ) { ?>
844 </div>
845 <?php }
846 $count_image_block++;
847 }
848 if($count_image_block > 0 && $count_image_block%$gllr_options['custom_image_row_count'] != 0) { ?>
849 </div>
850 <?php } ?>
851 </div>
852 <?php } ?>
853 </div>
854 <div class="clear"></div>
855 <?php endwhile;
856 else: ?>
857 <div class="gallery_box_single">
858 <p class="not_found"><?php _e('Sorry - nothing to found.', 'gallery'); ?></p>
859 </div>
860 <?php endif; ?>
861 <?php if( $gllr_options['return_link_shortcode'] == 1 ) {
862 global $wpdb;
863 $parent = $wpdb->get_var("SELECT $wpdb->posts.ID FROM $wpdb->posts, $wpdb->postmeta WHERE meta_key = '_wp_page_template' AND meta_value = 'gallery-template.php' AND (post_status = 'publish' OR post_status = 'private') AND $wpdb->posts.ID = $wpdb->postmeta.post_id");
864 ?>
865 <div class="return_link"><a href="<?php echo ( !empty( $parent ) ? get_permalink( $parent ) : '' ); ?>"><?php echo $gllr_options['return_link_text']; ?></a></div>
866 <?php } ?>
867 <script type="text/javascript">
868 (function($){
869 $(document).ready(function(){
870 $("a[rel=gallery_fancybox]").fancybox({
871 'transitionIn' : 'elastic',
872 'transitionOut' : 'elastic',
873 'titlePosition' : 'inside',
874 'speedIn' : 500,
875 'speedOut' : 300,
876 'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
877 return '<span id="fancybox-title-inside">' + (title.length ? title + '<br />' : '') + 'Image ' + (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
878 }<?php if( $gllr_options['start_slideshow'] == 1 ) { ?>,
879 'onComplete': function() {
880 clearTimeout(jQuery.fancybox.slider);
881 jQuery.fancybox.slider=setTimeout("jQuery.fancybox.next()",<?php echo empty( $gllr_options['slideshow_interval'] )? 2000 : $gllr_options['slideshow_interval'] ; ?>);
882 }<?php } ?>
883 });
884 });
885 })(jQuery);
886 </script>
887 <?php
888 }
889 }
890
891 register_activation_hook( __FILE__, 'gllr_plugin_install' ); // activate plugin
892 register_uninstall_hook( __FILE__, 'gllr_plugin_uninstall' ); // deactivate plugin
893
894 // adds "Settings" link to the plugin action page
895 add_filter( 'plugin_action_links', 'gllr_plugin_action_links', 10, 2 );
896 //Additional links on the plugin page
897 add_filter( 'plugin_row_meta', 'gllr_register_plugin_links', 10, 2 );
898
899 add_action( 'admin_menu', 'add_gllr_admin_menu' );
900 add_action( 'init', 'gllr_plugin_init' );
901
902 add_action( 'init', 'post_type_images' ); // register post type
903 add_action( 'init', 'gllr_custom_permalinks' ); // add custom permalink for gallery
904
905 add_action( 'admin_init', 'gllr_admin_error' );
906
907 add_action( 'template_redirect', 'gllr_template_redirect' ); // add themplate for single gallery page
908
909 add_action( 'save_post', 'gllr_save_postdata', 1, 2 ); // save custom data from admin
910
911 add_filter( 'nav_menu_css_class', 'addImageAncestorToMenu' );
912 add_filter( 'page_css_class', 'gllr_page_css_class', 10, 2 );
913
914 add_filter( 'manage_gallery_posts_columns', 'gllr_change_columns' );
915 add_action( 'manage_gallery_posts_custom_column', 'gllr_custom_columns', 10, 2 );
916
917 add_action( 'wp_head', 'gllr_add_script' );
918 add_action( 'admin_enqueue_scripts', 'gllr_admin_head' );
919 add_action( 'wp_enqueue_scripts', 'gllr_wp_head' );
920
921 add_shortcode( 'print_gllr', 'gllr_shortcode' );
922 ?>