AnsPress_Admin::check_pages_exists()
Description #
Check if AnsPress pages are exists.
Source #
File: admin/anspress-admin.php
private static function check_pages_exists() {
$cache = get_transient( 'ap_pages_check' );
if ( false === $cache ) {
$opt = ap_opt();
$pages_slug = array_keys( ap_main_pages() );
$pages_in = array();
foreach ( $pages_slug as $slug ) {
if ( ! empty( $opt[ $slug ] ) ) {
$pages_in[] = $opt[ $slug ];
}
}
$args = array(
'include' => $pages_in,
'post_type' => 'page',
'post_status' => 'publish',
);
$pages = get_posts( $args );
if ( count( $pages ) < count( $pages_slug ) ) {
$cache = '0';
set_transient( 'ap_pages_check', '0', HOUR_IN_SECONDS );
} else {
set_transient( 'ap_pages_check', '1', HOUR_IN_SECONDS );
$cache = '1';
}
}
return '0' === $cache ? false : true;
}
Expand full source code Collapse full source code View on GitHub: admin/anspress-admin.php:734
Add your comment