[Plugin: NextGEN Gallery] I found two errors in the XML-RPC
-
1° When creating a new gallery, she does not return the same id, error in function to create: I recommend a place depending on the option to return the ID, (this work)
Here is how I did
function create_gallery($gallerytitle, $defaultpath, $output = true, $returnID = false) { global $wpdb, $user_ID; // get the current user ID get_currentuserinfo(); //cleanup pathname $galleryname = sanitize_file_name( $gallerytitle ); $galleryname = apply_filters('ngg_gallery_name', $galleryname); $nggpath = $defaultpath . $galleryname; $nggRoot = WINABSPATH . $defaultpath; $txt = ''; // No gallery name ? if ( empty($galleryname) ) { if ($output) nggGallery::show_error( __('No valid gallery name!', 'nggallery') ); return false; } // check for main folder if ( !is_dir($nggRoot) ) { if ( !wp_mkdir_p( $nggRoot ) ) { $txt = __('Directory', 'nggallery').' <strong>' . $defaultpath . '</strong> '.__('didn\'t exist. Please create first the main gallery folder ', 'nggallery').'!<br />'; $txt .= __('Check this link, if you didn\'t know how to set the permission :', 'nggallery').' <a href="http://codex.wordpress.org/Changing_File_Permissions">http://codex.wordpress.org/Changing_File_Permissions</a> '; if ($output) nggGallery::show_error($txt); return false; } } // check for permission settings, Safe mode limitations are not taken into account. if ( !is_writeable( $nggRoot ) ) { $txt = __('Directory', 'nggallery').' <strong>' . $defaultpath . '</strong> '.__('is not writeable !', 'nggallery').'<br />'; $txt .= __('Check this link, if you didn\'t know how to set the permission :', 'nggallery').' <a href="http://codex.wordpress.org/Changing_File_Permissions">http://codex.wordpress.org/Changing_File_Permissions</a> '; if ($output) nggGallery::show_error($txt); return false; } // 1. Create new gallery folder if ( !is_dir(WINABSPATH . $nggpath) ) { if ( !wp_mkdir_p (WINABSPATH . $nggpath) ) $txt = __('Unable to create directory ', 'nggallery').$nggpath.'!<br />'; } // 2. Check folder permission if ( !is_writeable(WINABSPATH . $nggpath ) ) $txt .= __('Directory', 'nggallery').' <strong>'.$nggpath.'</strong> '.__('is not writeable !', 'nggallery').'<br />'; // 3. Now create "thumbs" folder inside if ( !is_dir(WINABSPATH . $nggpath . '/thumbs') ) { if ( !wp_mkdir_p ( WINABSPATH . $nggpath . '/thumbs') ) $txt .= __('Unable to create directory ', 'nggallery').' <strong>' . $nggpath . '/thumbs !</strong>'; } if (SAFE_MODE) { $help = __('The server setting Safe-Mode is on !', 'nggallery'); $help .= '<br />'.__('If you have problems, please create directory', 'nggallery').' <strong>' . $nggpath . '</strong> '; $help .= __('and the thumbnails directory', 'nggallery').' <strong>' . $nggpath . '/thumbs</strong> '.__('with permission 777 manually !', 'nggallery'); if ($output) nggGallery::show_message($help); } // show a error message if ( !empty($txt) ) { if (SAFE_MODE) { // for safe_mode , better delete folder, both folder must be created manually @rmdir(WINABSPATH . $nggpath . '/thumbs'); @rmdir(WINABSPATH . $nggpath); } if ($output) nggGallery::show_error($txt); return false; } $result = $wpdb->get_var("SELECT name FROM $wpdb->nggallery WHERE name = '$galleryname' "); if ($result) { if ($output) nggGallery::show_error( _n( 'Gallery', 'Galleries', 1, 'nggallery' ) .' <strong>' . $galleryname . '</strong> '.__('already exists', 'nggallery')); return false; } else { $result = $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->nggallery (name, path, title, author) VALUES (%s, %s, %s, %s)", $galleryname, $nggpath, $gallerytitle , $user_ID) ); // and give me the new id $gallery_id = (int) $wpdb->insert_id; // here you can inject a custom function do_action('ngg_created_new_gallery', $gallery_id); // return only the id if defined if ($return_id) return $gallery_id; if ($result) { $message = __('Gallery %1$s successfully created.<br/>You can show this gallery with the tag %2$s.<br/>','nggallery'); $message = sprintf($message, $galleryname, '[nggallery id=' . $gallery_id . ']'); $message .= '<a href="' . admin_url() . 'admin.php?page=nggallery-manage-gallery&mode=edit&gid=' . $gallery_id . '" >'; $message .= __('Edit gallery','nggallery'); $message .= '</a>'; if ($output) nggGallery::show_message($message); } if($returnID){ return $gallery_id; } else{ return true; } } }2° I’m having trouble using the image upload, maybe the function is wp_upload_bits () that is the problem. You can simplify this step upload ..
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
The topic ‘[Plugin: NextGEN Gallery] I found two errors in the XML-RPC’ is closed to new replies.