Advertisement
Guest User

Untitled

a guest
May 28th, 2015
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. /**
  2. * Get packages in Field Editor format
  3. *
  4. *
  5. * @since 1.2.2
  6. *
  7. * @param bool $as_array
  8. *
  9. * @return array|string
  10. */
  11. static function get_packages( $as_array = FALSE ) {
  12.  
  13. $fpackages = array();
  14.  
  15. if( ! class_exists( 'WP_Job_Manager_WCPL_Submit_Job_Form' ) ) {
  16. if( ! defined( 'JOB_MANAGER_WCPL_PLUGIN_DIR' ) ) return false;
  17. $legacy_file = JOB_MANAGER_WCPL_PLUGIN_DIR . '/includes/class-wp-job-manager-wcpl-submit-job-form.php';
  18. $new_file = JOB_MANAGER_WCPL_PLUGIN_DIR . '/includes/class-wc-paid-listings-submit-job-form.php';
  19.  
  20. if( file_exists( $new_file ) ){
  21. include( $new_file );
  22. }elseif( file_exists( $legacy_file ) ){
  23. include( $legacy_file );
  24. } else{
  25. return false;
  26. }
  27.  
  28. }
  29.  
  30. $packages = WP_Job_Manager_WCPL_Submit_Job_Form::get_packages();
  31.  
  32. if( ! $packages ) return false;
  33.  
  34. foreach ( $packages as $key => $package ) {
  35. $product = get_product( $package );
  36. // Skip if not job package
  37. if ( ! $product->is_type( array( 'job_package', 'job_package_subscription', 'subscription' ) ) ) continue;
  38.  
  39. $fpackages[ $product->id ] = $product->get_title();
  40. }
  41.  
  42. if ( ! $as_array ) {
  43. $options = new WP_Job_Manager_Field_Editor_Fields_Options();
  44. return $options->convert( $fpackages );
  45. }
  46.  
  47. return $fpackages;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement