| 1 |
<?php |
| 2 |
/** |
| 3 |
* Functions |
| 4 |
* |
| 5 |
* @package AutomatorWP\Integrations\WishList_Member\Functions |
| 6 |
* @author AutomatorWP <[email protected]>, Ruben Garcia <[email protected]> |
| 7 |
* @since 1.0.0 |
| 8 |
*/ |
| 9 |
// Exit if accessed directly |
| 10 |
if( !defined( 'ABSPATH' ) ) exit; |
| 11 |
|
| 12 |
/** |
| 13 |
* Options callback for levels options |
| 14 |
* |
| 15 |
* @since 1.0.0 |
| 16 |
* |
| 17 |
* @param stdClass $field |
| 18 |
* |
| 19 |
* @return array |
| 20 |
*/ |
| 21 |
function automatorwp_wishlist_member_levels_options_cb( $field ) { |
| 22 |
|
| 23 |
$options = array( |
| 24 |
'any' => __( 'any level', 'automatorwp' ), |
| 25 |
); |
| 26 |
|
| 27 |
if( function_exists( 'wlmapi_get_levels' ) ) { |
| 28 |
|
| 29 |
// Get all registered levels |
| 30 |
$levels = wlmapi_get_levels(); |
| 31 |
|
| 32 |
// Check that levels are correctly setup |
| 33 |
if ( is_array( $levels ) |
| 34 |
&& isset( $levels['levels'] ) |
| 35 |
&& isset( $levels['levels']['level'] ) |
| 36 |
&& ! empty( $levels['levels']['level'] ) ) { |
| 37 |
|
| 38 |
// Loop levels to add them as options |
| 39 |
foreach ( $levels['levels']['level'] as $level ) { |
| 40 |
$options[$level['id']] = $level['name']; |
| 41 |
} |
| 42 |
|
| 43 |
} |
| 44 |
|
| 45 |
} |
| 46 |
|
| 47 |
return $options; |
| 48 |
|
| 49 |
} |