C_NGG_WPCLI

Manage NextGen Gallery.

Defined (1)

The class is defined in the following location(s).

/products/photocrati_nextgen/modules/wpcli/module.wpcli.php  
  1. class C_NGG_WPCLI extends WP_CLI_Command 
  2. /** 
  3. * Flushes NextGen Gallery caches 
  4. */ 
  5. function flush_cache($args, $assoc_args) 
  6. C_Photocrati_Transient_Manager::flush(); 
  7. WP_CLI::success('Flushed all caches'); 
  8.  
  9. /** 
  10. * Create a new gallery 
  11. * @synopsis <gallery-name> --author=<user_login> 
  12. */ 
  13. function create_gallery($args, $assoc_args) 
  14. $mapper = C_Gallery_Mapper::get_instance(); 
  15.  
  16. $user = get_user_by('login', $assoc_args['author']); 
  17. if (!$user) 
  18. WP_CLI::error("Unable to find user {$assoc_args['author']}"); 
  19.  
  20. if (($gallery = $mapper->create(array('title' => $args[0], 'author' => $user->ID))) && $gallery->save()) 
  21. $gallery_id = $retval = $gallery->id(); 
  22. WP_CLI::success("Created gallery with id #{$gallery_id}"); 
  23. else { 
  24. WP_CLI::error("Unable to create gallery"); 
  25.  
  26. /** 
  27. * Import an image from the filesystem into NextGen 
  28. * @synopsis --filename=<absolute-path> --gallery=<gallery-id> 
  29. */ 
  30. function import_image($args, $assoc_args) 
  31. $mapper = C_Gallery_Mapper::get_instance(); 
  32. $storage = C_Gallery_Storage::get_instance(); 
  33.  
  34. if (($gallery = $mapper->find($assoc_args['gallery'], TRUE))) 
  35. $file_data = @file_get_contents($assoc_args['filename']); 
  36. $file_name = M_I18n::mb_basename($assoc_args['filename']); 
  37.  
  38. if (empty($file_data)) 
  39. WP_CLI::error('Could not load file'); 
  40.  
  41. $image = $storage->upload_base64_image($gallery, $file_data, $file_name); 
  42. $image_id = $image->{$image->id_field}; 
  43. if (!$image) 
  44. WP_CLI::error('Could not import image'); 
  45. else 
  46. WP_CLI::success("Imported image with id #{$image_id}"); 
  47. else { 
  48. WP_CLI::error("Gallery not found (with id #{$assoc_args['gallery']}"); 
  49.  
  50. /** 
  51. * Clear all dismissed notifications handled by C_Admin_Notification_Manager 
  52. * @synopsis 
  53. */ 
  54. function clear_dismissed_notifications($args, $assoc_args) 
  55. $settings = C_NextGen_Settings::get_instance(); 
  56. $settings->set('dismissed_notifications', array()); 
  57. $settings->set('gallery_created_after_reviews_introduced', FALSE); 
  58. $settings->save();