query_vars['feed'] = 'markdown'; return; } if (preg_match('/^\/(.+)\.md$/i', $path, $matches)) { $path_without_md = $matches[1]; if ($path_without_md === 'index') { $post_id = url_to_postid(home_url('/index')); if (!$post_id) { $page_on_front = get_option('page_on_front'); if ($page_on_front) $post_id = (int)$page_on_front; } } else { $post_id = url_to_postid(home_url('/' . $path_without_md)); if (!$post_id) $post_id = url_to_postid(home_url('/' . $path_without_md . '/')); } if ($post_id) { $post = get_post($post_id); if ($post && ($post->post_status === 'publish' || ($post->post_type === 'attachment' && $post->post_status === 'inherit'))) { $allowed_cpts = get_option('aiutoma_markdown_cpts', false); if ($allowed_cpts === false) { $allowed_cpts = array_values(array_diff(array_keys(get_post_types(['public' => true])), ['attachment'])); } if (in_array($post->post_type, $allowed_cpts)) { if ($post->post_type === 'page') { $wp->query_vars['page_id'] = $post->ID; } else { $wp->query_vars['p'] = $post->ID; $wp->query_vars['post_type'] = $post->post_type; } $wp->query_vars['aiutoma_md'] = '1'; unset($wp->query_vars['pagename']); unset($wp->query_vars['name']); } } } } } }