| 1 |
<?php |
| 2 |
function wpupg_admin_premium_not_installed() |
| 3 |
{ |
| 4 |
return !WPUltimatePostGrid::is_premium_active(); |
| 5 |
} |
| 6 |
|
| 7 |
function wpupg_admin_premium_installed() |
| 8 |
{ |
| 9 |
return WPUltimatePostGrid::is_premium_active(); |
| 10 |
} |
| 11 |
|
| 12 |
function wpupg_admin_grids() |
| 13 |
{ |
| 14 |
$args = array( |
| 15 |
'post_type' => WPUPG_POST_TYPE, |
| 16 |
'post_status' => array( 'publish', 'private' ), |
| 17 |
'posts_per_page' => -1, |
| 18 |
'nopaging' => true, |
| 19 |
'orderby' => 'date', |
| 20 |
'order' => 'ASC', |
| 21 |
); |
| 22 |
|
| 23 |
$query = new WP_Query( $args ); |
| 24 |
$posts = $query->have_posts() ? $query->posts : array(); |
| 25 |
|
| 26 |
$grids = array(); |
| 27 |
foreach( $posts as $post ) { |
| 28 |
$grids[] = array( |
| 29 |
'value' => $post->ID, |
| 30 |
'label' => $post->post_title, |
| 31 |
); |
| 32 |
} |
| 33 |
|
| 34 |
return $grids; |
| 35 |
} |
| 36 |
|
| 37 |
function wpupg_admin_template_editor() |
| 38 |
{ |
| 39 |
if( WPUltimatePostGrid::is_addon_active( 'template-editor' ) ) { |
| 40 |
$url = WPUltimatePostGrid::addon( 'template-editor' )->editor_url(); |
| 41 |
$button = '<a href="' . $url . '" class="button button-primary" target="_blank">' . __('Open the Template Editor', 'wp-ultimate-post-grid') . '</a>'; |
| 42 |
} else { |
| 43 |
$button = '<a href="#" class="button button-primary button-disabled" disabled>' . __('Open the Template Editor', 'wp-ultimate-post-grid') . '</a>'; |
| 44 |
} |
| 45 |
|
| 46 |
return $button; |
| 47 |
} |
| 48 |
|
| 49 |
function wpupg_admin_post_types() |
| 50 |
{ |
| 51 |
$post_types = get_post_types( '', 'names' ); |
| 52 |
$types = array(); |
| 53 |
|
| 54 |
foreach( $post_types as $post_type ) { |
| 55 |
$types[] = array( |
| 56 |
'value' => $post_type, |
| 57 |
'label' => ucfirst( $post_type ) |
| 58 |
); |
| 59 |
} |
| 60 |
|
| 61 |
return $types; |
| 62 |
} |
| 63 |
|
| 64 |
VP_Security::instance()->whitelist_function( 'wpupg_admin_premium_not_installed' ); |
| 65 |
VP_Security::instance()->whitelist_function( 'wpupg_admin_premium_installed' ); |
| 66 |
VP_Security::instance()->whitelist_function( 'wpupg_admin_grids' ); |
| 67 |
VP_Security::instance()->whitelist_function( 'wpupg_admin_template_editor' ); |
| 68 |
VP_Security::instance()->whitelist_function( 'wpupg_admin_post_types' ); |