ap_create_base_page()
Description #
Create base page for AnsPress.
This function is called in plugin activation. This function checks if base page already exists, if not then it create a new one and update the option.
Source #
File: includes/functions.php
function ap_create_base_page() { $opt = ap_opt(); $pages = ap_main_pages(); foreach ( $pages as $slug => $page ) { // Check if page already exists. $_post = get_page( ap_opt( $slug ) ); if ( ! $_post || 'trash' === $_post->post_status ) { $args = wp_parse_args( $page, array( 'post_type' => 'page', 'post_content' => '[anspress]', 'post_status' => 'publish', 'comment_status' => 'closed', ) ); if ( 'base_page' !== $slug ) { $args['post_parent'] = ap_opt( 'base_page' ); } // Now create post. $new_page_id = wp_insert_post( $args ); if ( $new_page_id ) { $page = get_page( $new_page_id ); ap_opt( $slug, $page->ID ); ap_opt( $slug . '_id', $page->post_name ); } } } }
Expand full source code Collapse full source code View on GitHub: includes/functions.php:917
Add your comment