<?php
class WPCSR_Pages{
	public static function add_wpcsr_custom_pages() {
		if( empty( get_option( 'wpcsr_request_single_parcel' ) ) ){
			if( get_page_by_path('wpcsr-add-parcel') == NULL ) {
				$single_args = array(
					'comment_status' => 'closed',
					'ping_status' => 'closed',
					'post_author' => 1,
					'post_date' => date('Y-m-d H:i:s'),
					'post_name' => 'wpcsr-add-parcel',
					'post_status' => 'publish',
					'post_title' => __('Add Parcel'),
					'post_type' => 'page',
					'post_content' => '[wpcsr_single_rate_shipment]',
				);
				$single_page = wp_insert_post( $single_args, false );
				if( wpcfe_admin_page() ){
					update_post_meta( $single_page, '_wp_page_template', 'dashboard.php' );
				}
			}
			update_option( 'wpcsr_request_single_parcel', $single_page );
		}
		if( empty( get_option( 'wpcsr_request_result' ) ) ){
			if( get_page_by_path('search-shipping-rate') == NULL ) {
				$search_args = array(
					'comment_status' => 'closed',
					'ping_status' => 'closed',
					'post_author' => 1,
					'post_date' => date('Y-m-d H:i:s'),
					'post_name' => 'search-shipping-rate',
					'post_status' => 'publish',
					'post_title' => 'Search Result',
					'post_type' => 'page',
					'post_content' => '[wpcsr_search_result]'
				);
				$search_page = wp_insert_post($search_args, false);
			}
			update_option( 'wpcsr_request_result', $search_page );
		}
	}
}