0 && get_post( $option_value ) ) return; $page_found = null; if ( strlen( $page_content ) > 0 ) { // Search for an existing page with the specified page content (typically a shortcode) $page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->posts . " WHERE post_type='page' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) ); } else { // Search for an existing page with the specified page slug $page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->posts . " WHERE post_type='page' AND post_name = %s LIMIT 1;", $slug ) ); } if ( $page_found ) { if ( ! $option_value ) update_option( $option, $page_found ); return; } $page_data = array( 'post_status' => 'publish', 'post_type' => 'page', 'post_author' => 1, 'post_name' => $slug, 'post_title' => $page_title, 'post_content' => $page_content, 'post_parent' => $post_parent, 'comment_status' => 'closed' ); $page_id = wp_insert_post( $page_data ); if ( $option ) update_option( $option, $page_id ); return $page_id; } /** * Output admin fields. * * Loops though the woocommerce options array and outputs each field. * * @param array $options Opens array to output */ function woocommerce_admin_fields( $options ) { if ( ! class_exists( 'WC_Admin_Settings' ) ) include 'class-wc-admin-settings.php'; WC_Admin_Settings::output_fields( $options ); } /** * Update all settings which are passed. * * @access public * @param array $options * @return void */ function woocommerce_update_options( $options ) { if ( ! class_exists( 'WC_Admin_Settings' ) ) include 'class-wc-admin-settings.php'; WC_Admin_Settings::save_fields( $options ); } /** * Get a setting from the settings API. * * @param mixed $option * @return string */ function woocommerce_settings_get_option( $option_name, $default = '' ) { if ( ! class_exists( 'WC_Admin_Settings' ) ) include 'class-wc-admin-settings.php'; return WC_Admin_Settings::get_option( $option_name, $default ); }