Created
April 19, 2015 02:07
-
-
Save tripflex/3502ead48a729e10b74a to your computer and use it in GitHub Desktop.
WCPL get_packages function update to support new WCPL filenames
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment