/** * * Create new WordPress page. * * @param [object] $post Post object, class rebuildPagesMajestic_Post * @param [array] $options Array of plugin options. * @param [string] $home_url Home url of WordPress blog * * @return [int | null] Returnes created post id or null if failed. * */ private function create_post($post, $options, $home_url) { if ($post) { $guid = parse_url($post->getUrl(), PHP_URL_PATH); $guid = ltrim($guid, '/'); if (strlen($guid) > 1) { $post_content = sprintf('Oops. Page not found. Go to <a href="%s">homepage</a>', $home_url); $new_post = array('post_title' => convert_chars($guid), 'post_content' => $post_content, 'post_status' => 'publish', 'post_type' => 'page', 'guid' => $guid, 'post_name' => $guid); $id = wp_insert_post($new_post); update_post_meta($id, 'custom_permalink', $guid); return $id; } } return null; }