Changeset 431129
- Timestamp:
- 08/31/2011 09:27:28 AM (14 years ago)
- Location:
- nextgen-gallery-comments/tags/0.1.3
- Files:
-
- 3 edited
-
comments/comments.php (modified) (5 diffs)
-
nextgen-gallery-comments.php (modified) (6 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
nextgen-gallery-comments/tags/0.1.3/comments/comments.php
r429521 r431129 16 16 // FUNC: create custom post id and post meta on gallery creation __________________________________________________ 17 17 18 function rcwd_ngg_gallery_ date_insert($gid){18 function rcwd_ngg_gallery_comments_create_post($gid){ 19 19 global $wpdb, $nggdb; 20 20 $gallery = $nggdb->find_gallery($gid); … … 22 22 update_post_meta($post_id, '_rcwd_nggid', $gid); 23 23 } 24 add_action('ngg_created_new_gallery', 'rcwd_ngg_gallery_ date_insert');24 add_action('ngg_created_new_gallery', 'rcwd_ngg_gallery_comments_create_post'); 25 25 26 26 // FUNC: check custom post id and post meta on gallery update _____________________________________________________ 27 27 28 function rcwd_ngg_gallery_ date_update($gid, $post){28 function rcwd_ngg_gallery_comments_update_post($gid, $post){ 29 29 global $wpdb, $nggdb; 30 30 $post_id = rcwd_get_postid_from_custom('_rcwd_nggid', $gid); … … 37 37 } 38 38 } 39 add_action('ngg_update_gallery', 'rcwd_ngg_gallery_ date_update', 10, 2);39 add_action('ngg_update_gallery', 'rcwd_ngg_gallery_comments_update_post', 10, 2); 40 40 41 41 // FUNC: add stylesheet to comments page _________________________________________________________________________________________________ … … 175 175 176 176 function rcwd_ngg_gallery_output($out, $picturelist){ 177 global $rcwd_ngg_comments_are_displayed; 178 if(!isset($rcwd_ngg_comments_are_displayed)) $rcwd_ngg_comments_are_displayed = false; 179 echo $out; 180 if($rcwd_ngg_comments_are_displayed === false) rcwd_ngg_add_comment_to_gallery(); 177 if(get_query_var('gallery') != ''){ 178 global $rcwd_ngg_comments_are_displayed; 179 if(!isset($rcwd_ngg_comments_are_displayed)) $rcwd_ngg_comments_are_displayed = false; 180 echo $out; 181 if($rcwd_ngg_comments_are_displayed === false) rcwd_ngg_add_comment_to_gallery(); 182 }else{ 183 echo $out; 184 } 181 185 } 182 186 add_filter('ngg_gallery_output', 'rcwd_ngg_gallery_output', 10, 2); … … 201 205 202 206 function rcwd_ngg_add_comment_to_gallery($args = array()){ 203 global $wp_query, $ngg_query, $temp_wp_query, $ngg_post_id, $gallery_ID, $rcwd_ngg_comments_are_displayed; 204 if(!isset($rcwd_ngg_comments_are_displayed)) $rcwd_ngg_comments_are_displayed = false; 205 if($rcwd_ngg_comments_are_displayed === false){ 206 $is_html5 = isset($args['is_html5']) ? (bool)$args['is_html5'] : true; 207 $gallery_ID = isset($args['gid']) ? (int)$args['gid'] : $gallery_ID; 208 $template = isset($args['template']) ? $args['template'] : ''; 209 if($template == '/comments.php') die('Non puoi utilizzare il file dei commenti di wordpress, mi dispiace...'); 210 if($template == ''){ 211 add_filter('comments_template', 'rcwd_ngg_comments_template'); 212 } 213 $ngg_post_id = rcwd_get_postid_from_custom('_rcwd_nggid', $gallery_ID); 214 if($ngg_post_id != ''){ 215 if($is_html5 === true){ 216 $open_tag = '<section class="comments-box">'; 217 $close_tag = '</section>'; 218 }else{ 219 $open_tag = '<div class="comments-box">'; 220 $close_tag = '</div>'; 207 if(get_query_var('gallery') != ''){ 208 global $wp_query, $ngg_query, $temp_wp_query, $ngg_post_id, $gallery_ID, $rcwd_ngg_comments_are_displayed; 209 if(!isset($rcwd_ngg_comments_are_displayed)) $rcwd_ngg_comments_are_displayed = false; 210 if($rcwd_ngg_comments_are_displayed === false){ 211 $is_html5 = isset($args['is_html5']) ? (bool)$args['is_html5'] : true; 212 $gallery_ID = isset($args['gid']) ? (int)$args['gid'] : $gallery_ID; 213 $template = isset($args['template']) ? $args['template'] : ''; 214 if($template == '/comments.php') die('Non puoi utilizzare il file dei commenti di wordpress, mi dispiace...'); 215 if($template == ''){ 216 add_filter('comments_template', 'rcwd_ngg_comments_template'); 221 217 } 222 $temp_wp_query = $wp_query; 223 $ngg_query = new WP_Query(); 224 $ngg_query->query('p='.$ngg_post_id.'&post_type=rcwd-ngg'); 225 while ($ngg_query->have_posts()){ 226 $ngg_query->the_post(); 227 echo $open_tag; 228 comments_template( $template, true ); 229 echo $close_tag; 218 $ngg_post_id = rcwd_get_postid_from_custom('_rcwd_nggid', $gallery_ID); 219 if($ngg_post_id != ''){ 220 if($is_html5 === true){ 221 $open_tag = '<section class="comments-box">'; 222 $close_tag = '</section>'; 223 }else{ 224 $open_tag = '<div class="comments-box">'; 225 $close_tag = '</div>'; 226 } 227 $temp_wp_query = $wp_query; 228 $ngg_query = new WP_Query(); 229 $ngg_query->query('p='.$ngg_post_id.'&post_type=rcwd-ngg'); 230 while ($ngg_query->have_posts()){ 231 $ngg_query->the_post(); 232 echo $open_tag; 233 comments_template( $template, true ); 234 echo $close_tag; 235 } 236 $wp_query = $temp_wp_query; 237 wp_reset_postdata(); 238 $rcwd_ngg_comments_are_displayed = true; 239 return; 230 240 } 231 $wp_query = $temp_wp_query;232 wp_reset_postdata();233 $rcwd_ngg_comments_are_displayed = true;234 return;235 241 } 236 242 } -
nextgen-gallery-comments/tags/0.1.3/nextgen-gallery-comments.php
r429521 r431129 4 4 Plugin URI: 5 5 Description: This plugin add comments to every NextGEN gallery (admin and frontend) 6 Version: 0.1. 16 Version: 0.1.3 7 7 Author: Roberto Cantarano 8 8 Author URI: http://www.cantarano.com … … 29 29 if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('Non puoi accedere direttamente a questa pagina...'); } 30 30 31 / /ini_set('display_errors', '1');32 // ini_set('error_reporting', E_ALL); 31 /* ini_set('display_errors', '1'); 32 ini_set('error_reporting', E_ALL);*/ 33 33 34 34 $rcwd_ngg_base_page = 'admin.php?page=nggallery-manage-gallery'; … … 38 38 39 39 function init(){ 40 $active_plugins = get_option('active_plugins', FALSE);41 40 $this->vars_and_constants(); 42 $this->functions(); 43 if (!in_array($this->depends, $active_plugins)){ 44 deactivate_plugins(plugin_basename(__FILE__)); 45 wp_die("Questo plugin necessita l'attivazione di NEXTGEN... che non risulta essere presente."); 46 return; 41 if (in_array($this->depends, $this->active_plugins)){ 42 $this->load_options(); 43 $this->functions(); 44 $this->classes(); 45 register_activation_hook( $this->plugin_name, array(&$this, 'activate') ); 46 register_deactivation_hook( $this->plugin_name, array(&$this, 'deactivate') ); 47 add_action( 'plugins_loaded', array(&$this, 'start_plugin') ); 48 include_once(dirname(__FILE__).'/comments/comments.php'); 47 49 } 48 /* if(class_exists('nggGallery')){ TODO: find a way to use it!49 }*/50 register_activation_hook( $this->plugin_name, array(&$this, 'activate') );51 register_deactivation_hook( $this->plugin_name, array(&$this, 'deactivate') );52 add_action( 'plugins_loaded', array(&$this, 'start_plugin') );53 include_once(dirname(__FILE__).'/comments/comments.php');54 50 } 55 51 56 52 function vars_and_constants(){ 57 53 global $wpdb; 54 define('RCWDNGGCOMMENTS_VERSION', '0.1.3'); 58 55 define('RCWDNGGCOMMENTS_DIRNAME', plugin_basename( dirname(__FILE__))); 59 56 define('RCWDNGGCOMMENTS_ALBUM_TAB', $wpdb->prefix.'ngg_album'); … … 63 60 define('RCWDNGGCOMMENTS_THEME_TEMPLATE_FOLDER', 'nggallery'); 64 61 define('RCWDNGGCOMMENTS_TEMPLATE_PATH', RCWDNGGCOMMENTS_PATH.'/template/'.RCWDNGGCOMMENTS_TEMPLATE); 65 $this->plugin_name = plugin_basename(__FILE__); 66 $this->depends = 'nextgen-gallery/nggallery.php'; 62 $this->plugin_name = plugin_basename(__FILE__); 63 $this->depends = 'nextgen-gallery/nggallery.php'; 64 $this->active_plugins = get_option('active_plugins', FALSE); 67 65 } 68 66 … … 70 68 require_once(dirname(__FILE__).'/functions/functions.php'); 71 69 } 72 70 71 function classes(){ 72 } 73 73 74 function activate(){ 74 75 global $wpdb; … … 85 86 } 86 87 if(!current_user_can('activate_plugins')) return; 88 update_option( 'rcwdnggcomments_version', RCWDNGGCOMMENTS_VERSION ); 89 $this->update_existing_galleries(); 87 90 } 88 91 92 function load_options(){ 93 } 94 89 95 function deactivate(){ 90 96 } 91 97 92 function start_plugin(){ 98 function start_plugin(){ 93 99 load_plugin_textdomain('nggcomments', false, dirname(plugin_basename(__FILE__)).'/lang'); 94 } 100 $this->version_check(); 101 } 102 103 function update(){ 104 $this->update_existing_galleries(); 105 update_option( 'rcwdnggcomments_version', RCWDNGGCOMMENTS_VERSION ); 106 } 107 108 function version_check(){ 109 $old_rcwdnggcomments_version = get_option('rcwdnggcomments_version'); 110 if( empty($old_rcwdnggcomments_version) or (version_compare(RCWDNGGCOMMENTS_VERSION, $old_rcwdnggcomments_version, '>') )){ 111 $this->update(); 112 } 113 } 114 115 function update_existing_galleries(){ 116 global $wpdb; 117 if($wpdb->get_var( "SHOW TABLES LIKE '".RCWDNGGCOMMENTS_GALLERY_TAB."'")){ 118 $galleries = $wpdb->get_results("SELECT * FROM ".RCWDNGGCOMMENTS_GALLERY_TAB); 119 if($galleries !== false){ 120 foreach($galleries as $key => $value){ 121 $post_id = rcwd_get_postid_from_custom('_rcwd_nggid', $value->gid); 122 if($post_id === false){ 123 $post_id = wp_insert_post(array( 'post_type' => 'rcwd-ngg', 'post_title' => $value->title, 'post_author' => $value->author, 'post_status' => 'publish', 'comment_status' => 'open' )); 124 update_post_meta($post_id, '_rcwd_nggid', $value->gid); 125 } 126 127 } 128 } 129 } 130 } 95 131 } 96 132 } -
nextgen-gallery-comments/tags/0.1.3/readme.txt
r429674 r431129 4 4 Requires at least: 2.9.1 5 5 Tested up to: 3.2.1 6 Stable tag: 0.1. 26 Stable tag: 0.1.3 7 7 8 8 This plugin add comments (form and list) in every NextGEN Gallery. … … 13 13 14 14 NextGEN Gallery Comments give power to the best wordpress gallery plugin i have seen! With my plugin, now all users can leave comments to your galleries. Comments are also displayed in admin in Comments section and in manage gallery page. 15 16 **NOTE** 17 For now, comments are show on galleries only when they are non called directly in post/page with shortcode. Example: 18 19 20 [nggallery id=X] ----> gallery comments are not showed 21 22 [album id=X] ----> gallery comments are showed (Not in album list, but inside the gallery page) 23 24 25 I will check in next release to find a way to do it. 15 26 16 27 = Features = … … 54 65 == Changelog == 55 66 67 = V0.1.3 - 31.08.2011 = 68 * FIX: all existing galleries before the plugin activation don't show comments 69 * Removed comments from gallery when called directly with shortcode [nggallery id=X] 70 71 = V0.1.2 - 28.08.2011 = 72 * Fixed some bugs which did not allow the installation in NextGEN Gallery Date is active 73 56 74 = V0.1.1 - 27.08.2011 = 57 75 * Fixed some bugs which did not allow the display of comments
Note: See TracChangeset
for help on using the changeset viewer.