Last active
November 4, 2018 22:16
-
-
Save tripflex/0cf3379bea01b645dc8e653a0f6f3149 to your computer and use it in GitHub Desktop.
WP Job Manager WooCommerce Paid Listings My Packages Shortcode
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
<?php | |
add_shortcode( 'wcpl_my_packages', 'smyles_output_wcpl_my_packages' ); | |
function smyles_output_wcpl_my_packages() { | |
// Make sure WCPL plugin is installed and activated | |
if( ! function_exists( 'wc_paid_listings_get_user_packages' ) || ! defined( 'JOB_MANAGER_WCPL_TEMPLATE_PATH' ) ){ | |
return ''; | |
} | |
$user_id = get_current_user_id(); | |
// User not logged in, don't output anything | |
if( empty( $user_id ) ){ | |
return ''; | |
} | |
ob_start(); | |
if ( ( $packages = wc_paid_listings_get_user_packages( $user_id, 'job_listing' ) ) && is_array( $packages ) && sizeof( $packages ) > 0 ) { | |
wc_get_template( 'my-packages.php', array( | |
'packages' => $packages, | |
'type' => 'job_listing', | |
), 'wc-paid-listings/', JOB_MANAGER_WCPL_TEMPLATE_PATH ); | |
} | |
if ( ( $packages = wc_paid_listings_get_user_packages( get_current_user_id(), 'resume' ) ) && is_array( $packages ) && sizeof( $packages ) > 0 ) { | |
wc_get_template( 'my-packages.php', array( | |
'packages' => $packages, | |
'type' => 'resume', | |
), 'wc-paid-listings/', JOB_MANAGER_WCPL_TEMPLATE_PATH ); | |
} | |
return ob_get_clean(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code is provided as a courtesy, I do not provide support for WooCommerce Paid Listings