I honestly wish I knew. That spot was coded before I had ever touched the plugin, so I have no idea of the source or what it’s meant for.
I am not sure, but I guess that portion of code needs to be run without any condition. I think you can omit that condition as it will always return true.
The whole plugin more or less needs to be rewritten for NGG 2.x so it’ll go away whenever that ends up happening.
So, I got curious. I did an svn checkout of the entire NextGen Gallery repo.
I ran an ack search for the string.
it was part of the addgallery.php file for NextGen core, in the admin, as late as version 1.3.1.
Checked the trac repo for NGG. 1.3.1 was released in 2008/2009. “5 years ago”. So our plugin shows its age as well. *sigh*
if ($_POST['uploadimage']){
check_admin_referer('ngg_addgallery');
if ($_FILES['MF__F_0_0']['error'] == 0) {
$messagetext = nggAdmin::upload_images();
}
else
nggGallery::show_error( __('Upload failed!','nggallery') );
}
Thanks for the information. I have also seen the similarity between addgallery.php and class.npu.uploader.php
But still it’s weird. Why would someone write something like that?
Anyway, if you guys think of updating your plugin any time, I have a simple suggestion. You are using this to show error.
self::show_error( __( 'No gallery selected.', 'nextgen-public-uploader' ) );
The definition of show_error is this
public static function show_error( $msg ) {
if ( is_user_logged_in() && apply_filters( 'uploader_ngg_admin_show_error', true ) ) {
nggGallery::show_error( $msg );
}
}
The show_error($msg) function echo the $msg directly, which shouldn’t be done in a shortcode. Instead you should return that message. I had to face weird problem because of that.
Anyway, despite these little quirks, It’s really a good plugin. Thanks for the plugin.
I was actually thinking about using this because I can’t find any other way to hook into before the upload process. i.e. I’ll set $_FILES[‘MF__F_0_0’][‘error’] = 1.
Is there a better way? i.e. On the server I’d like to check the file size, etc before the file gets uploaded.
Any help would be appreciated!