Plugin Directory

Changeset 431129


Ignore:
Timestamp:
08/31/2011 09:27:28 AM (14 years ago)
Author:
roberto.c
Message:
 
Location:
nextgen-gallery-comments/tags/0.1.3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • nextgen-gallery-comments/tags/0.1.3/comments/comments.php

    r429521 r431129  
    1616    // FUNC: create custom post id and post meta on gallery creation __________________________________________________
    1717   
    18         function rcwd_ngg_gallery_date_insert($gid){
     18        function rcwd_ngg_gallery_comments_create_post($gid){
    1919            global $wpdb, $nggdb;
    2020            $gallery = $nggdb->find_gallery($gid);
     
    2222            update_post_meta($post_id, '_rcwd_nggid', $gid);
    2323        }
    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');
    2525
    2626    // FUNC: check custom post id and post meta on gallery update _____________________________________________________
    2727   
    28         function rcwd_ngg_gallery_date_update($gid, $post){
     28        function rcwd_ngg_gallery_comments_update_post($gid, $post){
    2929            global $wpdb, $nggdb;
    3030            $post_id    = rcwd_get_postid_from_custom('_rcwd_nggid', $gid);
     
    3737            }
    3838        }
    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);
    4040               
    4141    // FUNC: add stylesheet to comments page _________________________________________________________________________________________________
     
    175175   
    176176        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            }
    181185        }
    182186        add_filter('ngg_gallery_output', 'rcwd_ngg_gallery_output', 10, 2);
     
    201205       
    202206        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');
    221217                    }
    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;     
    230240                    }
    231                     $wp_query = $temp_wp_query;
    232                     wp_reset_postdata();
    233                     $rcwd_ngg_comments_are_displayed = true;
    234                     return;     
    235241                }
    236242            }
  • nextgen-gallery-comments/tags/0.1.3/nextgen-gallery-comments.php

    r429521 r431129  
    44Plugin URI:
    55Description: This plugin add comments to every NextGEN gallery (admin and frontend)
    6 Version: 0.1.1
     6Version: 0.1.3
    77Author: Roberto Cantarano
    88Author URI: http://www.cantarano.com
     
    2929if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('Non puoi accedere direttamente a questa pagina...'); }
    3030
    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);*/
    3333
    3434$rcwd_ngg_base_page = 'admin.php?page=nggallery-manage-gallery';
     
    3838       
    3939        function init(){
    40             $active_plugins = get_option('active_plugins', FALSE);
    4140            $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');
    4749            }               
    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');
    5450        }
    5551   
    5652        function vars_and_constants(){
    5753            global $wpdb;
     54            define('RCWDNGGCOMMENTS_VERSION', '0.1.3');
    5855            define('RCWDNGGCOMMENTS_DIRNAME', plugin_basename( dirname(__FILE__)));
    5956            define('RCWDNGGCOMMENTS_ALBUM_TAB', $wpdb->prefix.'ngg_album');
     
    6360            define('RCWDNGGCOMMENTS_THEME_TEMPLATE_FOLDER', 'nggallery');
    6461            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);
    6765        }
    6866   
     
    7068            require_once(dirname(__FILE__).'/functions/functions.php');
    7169        }
    72        
     70
     71        function classes(){
     72        }
     73               
    7374        function activate(){
    7475            global $wpdb;
     
    8586            }
    8687            if(!current_user_can('activate_plugins')) return;   
     88            update_option( 'rcwdnggcomments_version', RCWDNGGCOMMENTS_VERSION );
     89            $this->update_existing_galleries();
    8790        }
    88        
     91
     92        function load_options(){
     93        }
     94               
    8995        function deactivate(){
    9096        }   
    9197
    92         function start_plugin(){
     98        function start_plugin(){           
    9399            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        }
    95131    }
    96132}
  • nextgen-gallery-comments/tags/0.1.3/readme.txt

    r429674 r431129  
    44Requires at least: 2.9.1
    55Tested up to: 3.2.1
    6 Stable tag: 0.1.2
     6Stable tag: 0.1.3
    77
    88This plugin add comments (form and list) in every NextGEN Gallery.
     
    1313
    1414NextGEN 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**
     17For 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
     25I will check in next release to find a way to do it.
    1526
    1627= Features =
     
    5465== Changelog ==
    5566
     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
    5674= V0.1.1 - 27.08.2011 =
    5775* Fixed some bugs which did not allow the display of comments
Note: See TracChangeset for help on using the changeset viewer.