wc.php
/**
* Get packages in Field Editor format
*
*
* @since 1.2.2
*
* @param bool $as_array
*
* @return array|string
*/
static function get_packages( $as_array = FALSE ) {
$fpackages = array();
if( ! class_exists( 'WP_Job_Manager_WCPL_Submit_Job_Form' ) ) {
if( ! defined( 'JOB_MANAGER_WCPL_PLUGIN_DIR' ) ) return false;
$legacy_file = JOB_MANAGER_WCPL_PLUGIN_DIR . '/includes/class-wp-job-manager-wcpl-submit-job-form.php';
$new_file = JOB_MANAGER_WCPL_PLUGIN_DIR . '/includes/class-wc-paid-listings-submit-job-form.php';
if( file_exists( $new_file ) ){
include( $new_file );
}elseif( file_exists( $legacy_file ) ){
include( $legacy_file );
} else{
return false;
}
}
$packages = WP_Job_Manager_WCPL_Submit_Job_Form::get_packages();
if( ! $packages ) return false;
foreach ( $packages as $key => $package ) {
$product = get_product( $package );
// Skip if not job package
if ( ! $product->is_type( array( 'job_package', 'job_package_subscription', 'subscription' ) ) ) continue;
$fpackages[ $product->id ] = $product->get_title();
}
if ( ! $as_array ) {
$options = new WP_Job_Manager_Field_Editor_Fields_Options();
return $options->convert( $fpackages );
}
return $fpackages;
}
No comments yet.