WordPress.org

Forums

NextCellent Gallery - NextGEN Legacy
NGG Cusotm field issue (3 posts)

  1. svobop7
    Member
    Posted 1 year ago #

    Hi I'm using NextCellent gallery plugin version 1.9.18 and NGG Custom fields version 1.2.3 and the custom fields for the galleries doesn't work (I can't see them). The custom fields for images forks fine.

    Cheers.

    https://wordpress.org/plugins/nextcellent-gallery-nextgen-legacy/

  2. niknetniko
    Member
    Posted 1 year ago #

    This is actually a problem with NGG Custom fields. Version 1.2.3 of that plugin uses a new filter from NGG 2.X, which isn't supported by NextCellent Gallery.

    Please contact the plugin author and point them to this post or give them this information:

    To make it work again with NextCellent, replace

    add_filter('ngg_manage_gallery_fields', 'nggcf_add_gallery_col', 11, 2);
    		function nggcf_add_gallery_col($fields=array(), $gallery=NULL) {
    			$fields['left']['ngg_cf_options'] = array(
    				'callback'	=> 'nggcf_admin_gallery_col',
    				'label'		=>	_('Custom Fields:'),
    				'tooltip'   =>  NULL,
    				'id'		=>	'ngg_cf_options'
    				);
    
    			return $fields;
    		}
    
    		function nggcf_admin_gallery_col($gallery=array()) {
    			global $wpdb;
    			$fields = nggcf_get_field_list(NGGCF_GALLERY, $gallery->gid);
    
    			echo '<strong>Custom Columns</strong><hr /><input type="hidden" name="nggcf_gallery[ngg_gallery_id]" value="'.$gallery->gid.'" />';
    
    			foreach ((array)$fields as $key=>$val) {
    
    				echo htmlspecialchars($val->field_name).'<br />';
    
    				$value = $wpdb->get_row("SELECT * FROM ".$wpdb->prefix."nggcf_field_values WHERE pid = '".$wpdb->escape($gallery->gid)."' AND fid = '".$val->id."' AND ngg_type = '".NGGCF_GALLERY."'");
    				switch($val->field_type) {
    				case NGGCF_FIELD_TYPE_INPUT :
    					echo '<input name="nggcf_gallery['.$val->id.']" style="width:95%;" value="'.esc_attr($value->field_value).'" />';
    					break;
    				case NGGCF_FIELD_TYPE_TEXTAREA :
    					echo '<textarea name="nggcf_gallery['.$val->id.']" style="width:95%;">'.esc_attr($value->field_value).'</textarea>';
    					break;
    				case NGGCF_FIELD_TYPE_SELECT :
    					$opts = explode(",", $val->drop_options);
    					echo '<select name="nggcf_gallery['.$val->id.']">';
    					echo '<option value=""></option>';
    					foreach ((array)$opts as $optVal) {
    						echo '<option value="'.trim(esc_attr($optVal)).'" '.(trim(esc_attr($optVal)) == esc_attr($value->field_value) ? ' selected="selected"' : '').'>'.trim(esc_attr($optVal)).'</option>';
    					}
    					echo '</select>';
    					break;
    				}
    				echo '<br />';
    			}
    		}
    	//}

    with

    $plugin = get_plugin_data( NGGALLERY_ABSPATH . '/nggallery.php', true, false );
    		if ( $plugin['name'] = 'NextCellent Gallery') {
    		add_action('ngg_manage_gallery_settings', 'nggcf_admin_gallery_col');
    		function nggcf_admin_gallery_col($act_gid) {
    			global $wpdb;
    			$fields = nggcf_get_field_list(NGGCF_GALLERY, $act_gid);
    
    			echo '<tr>';
    			echo '<td colspan="4" align="left">';
    			echo '<strong>Custom Columns</strong><hr /><input type="hidden" name="nggcf_gallery[ngg_gallery_id]" value="'.$act_gid.'" />';
    
    			foreach ((array)$fields as $key=>$val) {
    				echo '<tr>';
    				echo '<td align="right">'.htmlspecialchars($val->field_name).'</td>';
    				echo '<td>';
    
    				$value = $wpdb->get_row("SELECT * FROM ".$wpdb->prefix."nggcf_field_values WHERE pid = '".$wpdb->escape($act_gid)."' AND fid = '".$val->id."' AND ngg_type = '".NGGCF_GALLERY."'");
    				switch($val->field_type) {
    				case NGGCF_FIELD_TYPE_INPUT :
    					echo '<input name="nggcf_gallery['.$val->id.']" style="width:95%;" value="'.esc_attr($value->field_value).'" />';
    					break;
    				case NGGCF_FIELD_TYPE_TEXTAREA :
    					echo '<textarea name="nggcf_gallery['.$val->id.']" style="width:95%;">'.esc_attr($value->field_value).'</textarea>';
    					break;
    				case NGGCF_FIELD_TYPE_SELECT :
    					$opts = explode(",", $val->drop_options);
    					echo '<select name="nggcf_gallery['.$val->id.']">';
    					echo '<option value=""></option>';
    					foreach ((array)$opts as $optVal) {
    						echo '<option value="'.trim(esc_attr($optVal)).'" '.(trim(esc_attr($optVal)) == esc_attr($value->field_value) ? ' selected="selected"' : '').'>'.trim(esc_attr($optVal)).'</option>';
    					}
    					echo '</select>';
    					break;
    				}
    
    				echo '</td>';
    				echo '</tr>';
    			}
    
    			echo '</td>';
    			echo '</tr>';
    		}
    	//}
    		} else {
    		add_filter('ngg_manage_gallery_fields', 'nggcf_add_gallery_col', 11, 2);
    		function nggcf_add_gallery_col($fields=array(), $gallery=NULL) {
    			$fields['left']['ngg_cf_options'] = array(
    				'callback'	=> 'nggcf_admin_gallery_col',
    				'label'		=>	_('Custom Fields:'),
    				'tooltip'   =>  NULL,
    				'id'		=>	'ngg_cf_options'
    				);
    
    			return $fields;
    		}
    
    		function nggcf_admin_gallery_col($gallery=array()) {
    			global $wpdb;
    			$fields = nggcf_get_field_list(NGGCF_GALLERY, $gallery->gid);
    
    			echo '<strong>Custom Columns</strong><hr /><input type="hidden" name="nggcf_gallery[ngg_gallery_id]" value="'.$gallery->gid.'" />';
    
    			foreach ((array)$fields as $key=>$val) {
    
    				echo htmlspecialchars($val->field_name).'<br />';
    
    				$value = $wpdb->get_row("SELECT * FROM ".$wpdb->prefix."nggcf_field_values WHERE pid = '".$wpdb->escape($gallery->gid)."' AND fid = '".$val->id."' AND ngg_type = '".NGGCF_GALLERY."'");
    				switch($val->field_type) {
    				case NGGCF_FIELD_TYPE_INPUT :
    					echo '<input name="nggcf_gallery['.$val->id.']" style="width:95%;" value="'.esc_attr($value->field_value).'" />';
    					break;
    				case NGGCF_FIELD_TYPE_TEXTAREA :
    					echo '<textarea name="nggcf_gallery['.$val->id.']" style="width:95%;">'.esc_attr($value->field_value).'</textarea>';
    					break;
    				case NGGCF_FIELD_TYPE_SELECT :
    					$opts = explode(",", $val->drop_options);
    					echo '<select name="nggcf_gallery['.$val->id.']">';
    					echo '<option value=""></option>';
    					foreach ((array)$opts as $optVal) {
    						echo '<option value="'.trim(esc_attr($optVal)).'" '.(trim(esc_attr($optVal)) == esc_attr($value->field_value) ? ' selected="selected"' : '').'>'.trim(esc_attr($optVal)).'</option>';
    					}
    					echo '</select>';
    					break;
    				}
    				echo '<br />';
    			}
    		}
    	//}
    	}

    This should be done with all new hooks and stuff they use from NextGEN 2.X.

  3. WPReady
    Member
    Plugin Author

    Posted 1 year ago #

    Excellent Niko, i figured out the filter problem, but not the workaround!!!
    Great!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic