postStatus.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973
  1. <?php
  2. /**
  3. * @group canonical
  4. * @group rewrite
  5. * @group query
  6. */
  7. class Tests_Canonical_PostStatus extends WP_Canonical_UnitTestCase {
  8. /**
  9. * User IDs.
  10. *
  11. * @var array
  12. */
  13. public static $users;
  14. /**
  15. * Post Objects.
  16. *
  17. * @var array
  18. */
  19. public static $posts;
  20. public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
  21. self::setup_custom_types();
  22. self::$users = array(
  23. 'anon' => 0,
  24. 'subscriber' => $factory->user->create( array( 'role' => 'subscriber' ) ),
  25. 'content_author' => $factory->user->create( array( 'role' => 'author' ) ),
  26. 'editor' => $factory->user->create( array( 'role' => 'editor' ) ),
  27. );
  28. $post_statuses = array( 'publish', 'future', 'draft', 'pending', 'private', 'auto-draft', 'a-private-status' );
  29. foreach ( $post_statuses as $post_status ) {
  30. $post_date = '';
  31. if ( 'future' === $post_status ) {
  32. $post_date = strftime( '%Y-%m-%d %H:%M:%S', strtotime( '+1 year' ) );
  33. }
  34. self::$posts[ $post_status ] = $factory->post->create_and_get(
  35. array(
  36. 'post_type' => 'post',
  37. 'post_title' => "$post_status post",
  38. 'post_name' => "$post_status-post",
  39. 'post_status' => $post_status,
  40. 'post_content' => "Prevent canonical redirect exposing post slugs.\n\n<!--nextpage-->Page 2",
  41. 'post_author' => self::$users['content_author'],
  42. 'post_date' => $post_date,
  43. )
  44. );
  45. // Add fake attachment to the post (file upload not needed).
  46. self::$posts[ "$post_status-attachment" ] = $factory->post->create_and_get(
  47. array(
  48. 'post_type' => 'attachment',
  49. 'post_title' => "$post_status inherited attachment",
  50. 'post_name' => "$post_status-inherited-attachment",
  51. 'post_status' => 'inherit',
  52. 'post_content' => "Prevent canonical redirect exposing post via attachments.\n\n<!--nextpage-->Page 2",
  53. 'post_author' => self::$users['content_author'],
  54. 'post_parent' => self::$posts[ $post_status ]->ID,
  55. 'post_date' => $post_date,
  56. )
  57. );
  58. // Set up a page with same.
  59. self::$posts[ "$post_status-page" ] = $factory->post->create_and_get(
  60. array(
  61. 'post_type' => 'page',
  62. 'post_title' => "$post_status page",
  63. 'post_name' => "$post_status-page",
  64. 'post_status' => $post_status,
  65. 'post_content' => "Prevent canonical redirect exposing page slugs.\n\n<!--nextpage-->Page 2",
  66. 'post_author' => self::$users['content_author'],
  67. 'post_date' => $post_date,
  68. )
  69. );
  70. }
  71. // Create a public CPT using a private status.
  72. self::$posts['a-public-cpt'] = $factory->post->create_and_get(
  73. array(
  74. 'post_type' => 'a-public-cpt',
  75. 'post_title' => 'a-public-cpt',
  76. 'post_name' => 'a-public-cpt',
  77. 'post_status' => 'private',
  78. 'post_content' => 'Prevent canonical redirect exposing a-public-cpt titles.',
  79. 'post_author' => self::$users['content_author'],
  80. )
  81. );
  82. // Add fake attachment to the public cpt (file upload not needed).
  83. self::$posts['a-public-cpt-attachment'] = $factory->post->create_and_get(
  84. array(
  85. 'post_type' => 'attachment',
  86. 'post_title' => 'a-public-cpt post inherited attachment',
  87. 'post_name' => 'a-public-cpt-inherited-attachment',
  88. 'post_status' => 'inherit',
  89. 'post_content' => "Prevent canonical redirect exposing post via attachments.\n\n<!--nextpage-->Page 2",
  90. 'post_author' => self::$users['content_author'],
  91. 'post_parent' => self::$posts['a-public-cpt']->ID,
  92. )
  93. );
  94. // Create a private CPT with a public status.
  95. self::$posts['a-private-cpt'] = $factory->post->create_and_get(
  96. array(
  97. 'post_type' => 'a-private-cpt',
  98. 'post_title' => 'a-private-cpt',
  99. 'post_name' => 'a-private-cpt',
  100. 'post_status' => 'publish',
  101. 'post_content' => 'Prevent canonical redirect exposing a-private-cpt titles.',
  102. 'post_author' => self::$users['content_author'],
  103. )
  104. );
  105. // Add fake attachment to the private cpt (file upload not needed).
  106. self::$posts['a-private-cpt-attachment'] = $factory->post->create_and_get(
  107. array(
  108. 'post_type' => 'attachment',
  109. 'post_title' => 'a-private-cpt post inherited attachment',
  110. 'post_name' => 'a-private-cpt-inherited-attachment',
  111. 'post_status' => 'inherit',
  112. 'post_content' => "Prevent canonical redirect exposing post via attachments.\n\n<!--nextpage-->Page 2",
  113. 'post_author' => self::$users['content_author'],
  114. 'post_parent' => self::$posts['a-private-cpt']->ID,
  115. )
  116. );
  117. // Post for trashing.
  118. self::$posts['trash'] = $factory->post->create_and_get(
  119. array(
  120. 'post_type' => 'post',
  121. 'post_title' => 'trash post',
  122. 'post_name' => 'trash-post',
  123. 'post_status' => 'publish',
  124. 'post_content' => "Prevent canonical redirect exposing post slugs.\n\n<!--nextpage-->Page 2",
  125. 'post_author' => self::$users['content_author'],
  126. )
  127. );
  128. self::$posts['trash-attachment'] = $factory->post->create_and_get(
  129. array(
  130. 'post_type' => 'attachment',
  131. 'post_title' => 'trash post inherited attachment',
  132. 'post_name' => 'trash-post-inherited-attachment',
  133. 'post_status' => 'inherit',
  134. 'post_content' => "Prevent canonical redirect exposing post via attachments.\n\n<!--nextpage-->Page 2",
  135. 'post_author' => self::$users['content_author'],
  136. 'post_parent' => self::$posts['trash']->ID,
  137. )
  138. );
  139. // Page for trashing.
  140. self::$posts['trash-page'] = $factory->post->create_and_get(
  141. array(
  142. 'post_type' => 'page',
  143. 'post_title' => 'trash page',
  144. 'post_name' => 'trash-page',
  145. 'post_status' => 'publish',
  146. 'post_content' => "Prevent canonical redirect exposing page slugs.\n\n<!--nextpage-->Page 2",
  147. 'post_author' => self::$users['content_author'],
  148. )
  149. );
  150. wp_trash_post( self::$posts['trash']->ID );
  151. wp_trash_post( self::$posts['trash-page']->ID );
  152. }
  153. function setUp() {
  154. parent::setUp();
  155. self::setup_custom_types();
  156. }
  157. /**
  158. * Set up a custom post type and private status.
  159. *
  160. * This needs to be called both in the class setup and
  161. * test setup.
  162. */
  163. public static function setup_custom_types() {
  164. // Register public custom post type.
  165. register_post_type(
  166. 'a-public-cpt',
  167. array(
  168. 'public' => true,
  169. 'rewrite' => array(
  170. 'slug' => 'a-public-cpt',
  171. ),
  172. )
  173. );
  174. // Register private custom post type.
  175. register_post_type(
  176. 'a-private-cpt',
  177. array(
  178. 'public' => false,
  179. 'publicly_queryable' => false,
  180. 'rewrite' => array(
  181. 'slug' => 'a-private-cpt',
  182. ),
  183. 'map_meta_cap' => true,
  184. )
  185. );
  186. // Register custom private post status.
  187. register_post_status(
  188. 'a-private-status',
  189. array(
  190. 'private' => true,
  191. )
  192. );
  193. }
  194. /**
  195. * Test canonical redirect does not reveal private posts presence.
  196. *
  197. * @ticket 5272
  198. * @dataProvider data_canonical_redirects_to_plain_permalinks
  199. *
  200. * @param string $post_key Post key used for creating fixtures.
  201. * @param string $user_role User role.
  202. * @param string $requested Requested URL.
  203. * @param string $expected Expected URL.
  204. */
  205. public function test_canonical_redirects_to_plain_permalinks( $post_key, $user_role, $requested, $expected ) {
  206. wp_set_current_user( self::$users[ $user_role ] );
  207. $this->set_permalink_structure( '' );
  208. $post = self::$posts[ $post_key ];
  209. clean_post_cache( $post->ID );
  210. /*
  211. * The dataProvider runs before the fixures are set up, therefore the
  212. * post object IDs are placeholders that needs to be replaced.
  213. */
  214. $requested = str_replace( '%ID%', $post->ID, $requested );
  215. $expected = str_replace( '%ID%', $post->ID, $expected );
  216. $this->assertCanonical( $requested, $expected );
  217. }
  218. /**
  219. * Data provider for test_canonical_redirects_to_plain_permalinks.
  220. *
  221. * @return array[] Array of arguments for tests {
  222. * @type string $post_key Post key used for creating fixtures.
  223. * @type string $user_role User role.
  224. * @type string $requested Requested URL.
  225. * @type string $expected Expected URL.
  226. * }
  227. */
  228. function data_canonical_redirects_to_plain_permalinks() {
  229. $data = array();
  230. $all_user_list = array( 'anon', 'subscriber', 'content_author', 'editor' );
  231. $select_allow_list = array( 'content_author', 'editor' );
  232. $select_block_list = array( 'anon', 'subscriber' );
  233. // All post/page keys
  234. $all_user_post_status_keys = array( 'publish' );
  235. $select_user_post_status_keys = array( 'private', 'a-private-status' );
  236. $no_user_post_status_keys = array( 'future', 'draft', 'pending', 'auto-draft' ); // Excludes trash for attachment rules.
  237. $select_user_post_type_keys = array( 'a-public-cpt' );
  238. $no_user_post_type_keys = array( 'a-private-cpt' );
  239. foreach ( $all_user_post_status_keys as $post_key ) {
  240. foreach ( $all_user_list as $user ) {
  241. /*
  242. * In the event `redirect_canonical()` is updated to redirect plain permalinks
  243. * to a canonical plain version, these expected values can be changed.
  244. */
  245. $data[] = array(
  246. "$post_key-page",
  247. $user,
  248. '/?post_type=page&p=%ID%',
  249. '/?post_type=page&p=%ID%',
  250. );
  251. $data[] = array(
  252. $post_key,
  253. $user,
  254. "/?name=$post_key-post",
  255. "/?name=$post_key-post",
  256. );
  257. // Ensure rss redirects to rss2.
  258. $data[] = array(
  259. $post_key,
  260. $user,
  261. '/?feed=rss&p=%ID%',
  262. '/?feed=rss2&p=%ID%',
  263. );
  264. // Ensure rss redirects to rss2.
  265. $data[] = array(
  266. "$post_key-page",
  267. $user,
  268. '/?feed=rss&page_id=%ID%',
  269. '/?feed=rss2&page_id=%ID%',
  270. );
  271. }
  272. }
  273. foreach ( $select_user_post_status_keys as $post_key ) {
  274. foreach ( $select_allow_list as $user ) {
  275. /*
  276. * In the event `redirect_canonical()` is updated to redirect plain permalinks
  277. * to a canonical plain version, these expected values can be changed.
  278. */
  279. $data[] = array(
  280. "$post_key-page",
  281. $user,
  282. '/?post_type=page&p=%ID%',
  283. '/?post_type=page&p=%ID%',
  284. );
  285. $data[] = array(
  286. $post_key,
  287. $user,
  288. "/?name=$post_key-post",
  289. "/?name=$post_key-post",
  290. );
  291. // Ensure rss redirects to rss2.
  292. $data[] = array(
  293. $post_key,
  294. $user,
  295. '/?feed=rss&p=%ID%',
  296. '/?feed=rss2&p=%ID%',
  297. );
  298. // Ensure rss redirects to rss2.
  299. $data[] = array(
  300. "$post_key-page",
  301. $user,
  302. '/?feed=rss&page_id=%ID%',
  303. '/?feed=rss2&page_id=%ID%',
  304. );
  305. }
  306. foreach ( $select_block_list as $user ) {
  307. /*
  308. * In the event `redirect_canonical()` is updated to redirect plain permalinks
  309. * to a canonical plain version, these expected values MUST NOT be changed.
  310. */
  311. $data[] = array(
  312. "$post_key-page",
  313. $user,
  314. '/?post_type=page&p=%ID%',
  315. '/?post_type=page&p=%ID%',
  316. );
  317. $data[] = array(
  318. $post_key,
  319. $user,
  320. "/?name=$post_key-post",
  321. "/?name=$post_key-post",
  322. );
  323. // Ensure post's existence is not demonstrated by changing rss to rss2.
  324. $data[] = array(
  325. $post_key,
  326. $user,
  327. '/?feed=rss&p=%ID%',
  328. '/?feed=rss&p=%ID%',
  329. );
  330. // Ensure post's existence is not demonstrated by changing rss to rss2.
  331. $data[] = array(
  332. "$post_key-page",
  333. $user,
  334. '/?feed=rss&page_id=%ID%',
  335. '/?feed=rss&page_id=%ID%',
  336. );
  337. }
  338. }
  339. foreach ( $no_user_post_status_keys as $post_key ) {
  340. foreach ( $all_user_list as $user ) {
  341. /*
  342. * In the event `redirect_canonical()` is updated to redirect plain permalinks
  343. * to a canonical plain version, these expected values MUST NOT be changed.
  344. */
  345. $data[] = array(
  346. "$post_key-page",
  347. $user,
  348. '/?post_type=page&p=%ID%',
  349. '/?post_type=page&p=%ID%',
  350. );
  351. $data[] = array(
  352. $post_key,
  353. $user,
  354. "/?name=$post_key-post",
  355. "/?name=$post_key-post",
  356. );
  357. // Ensure post's existence is not demonstrated by changing rss to rss2.
  358. $data[] = array(
  359. $post_key,
  360. $user,
  361. '/?feed=rss&p=%ID%',
  362. '/?feed=rss&p=%ID%',
  363. );
  364. // Ensure post's existence is not demonstrated by changing rss to rss2.
  365. $data[] = array(
  366. "$post_key-page",
  367. $user,
  368. '/?feed=rss&page_id=%ID%',
  369. '/?feed=rss&page_id=%ID%',
  370. );
  371. }
  372. }
  373. foreach ( array( 'trash' ) as $post_key ) {
  374. foreach ( $all_user_list as $user ) {
  375. /*
  376. * In the event `redirect_canonical()` is updated to redirect plain permalinks
  377. * to a canonical plain version, these expected values MUST NOT be changed.
  378. */
  379. $data[] = array(
  380. "$post_key-page",
  381. $user,
  382. '/?post_type=page&p=%ID%',
  383. '/?post_type=page&p=%ID%',
  384. );
  385. $data[] = array(
  386. $post_key,
  387. $user,
  388. "/?name=$post_key-post",
  389. "/?name=$post_key-post",
  390. );
  391. // Ensure post's existence is not demonstrated by changing rss to rss2.
  392. $data[] = array(
  393. $post_key,
  394. $user,
  395. '/?feed=rss&p=%ID%',
  396. '/?feed=rss&p=%ID%',
  397. );
  398. // Ensure post's existence is not demonstrated by changing rss to rss2.
  399. $data[] = array(
  400. "$post_key-page",
  401. $user,
  402. '/?feed=rss&page_id=%ID%',
  403. '/?feed=rss&page_id=%ID%',
  404. );
  405. }
  406. }
  407. foreach ( $select_user_post_type_keys as $post_key ) {
  408. foreach ( $select_allow_list as $user ) {
  409. $data[] = array(
  410. $post_key,
  411. $user,
  412. '/?p=%ID%',
  413. '/?a-public-cpt=a-public-cpt',
  414. );
  415. $data[] = array(
  416. "$post_key-attachment",
  417. $user,
  418. '/?attachment_id=%ID%',
  419. '/?attachment_id=%ID%',
  420. );
  421. $data[] = array(
  422. $post_key,
  423. $user,
  424. "/?name=$post_key&post_type=$post_key",
  425. "/?name=$post_key&post_type=$post_key",
  426. );
  427. // Ensure rss is replaced by rss2.
  428. $data[] = array(
  429. $post_key,
  430. $user,
  431. '/?feed=rss&p=%ID%',
  432. '/?a-public-cpt=a-public-cpt&feed=rss2',
  433. );
  434. }
  435. foreach ( $select_block_list as $user ) {
  436. $data[] = array(
  437. $post_key,
  438. $user,
  439. '/?p=%ID%',
  440. '/?p=%ID%',
  441. );
  442. $data[] = array(
  443. "$post_key-attachment",
  444. $user,
  445. '/?attachment_id=%ID%',
  446. '/?attachment_id=%ID%',
  447. );
  448. $data[] = array(
  449. $post_key,
  450. $user,
  451. "/?name=$post_key&post_type=$post_key",
  452. "/?name=$post_key&post_type=$post_key",
  453. );
  454. // Ensure rss is not replaced with rss2.
  455. $data[] = array(
  456. $post_key,
  457. $user,
  458. '/?feed=rss&p=%ID%',
  459. '/?feed=rss&p=%ID%',
  460. );
  461. }
  462. }
  463. foreach ( $no_user_post_type_keys as $post_key ) {
  464. foreach ( $all_user_list as $user ) {
  465. $data[] = array(
  466. $post_key,
  467. $user,
  468. '/?p=%ID%',
  469. '/?p=%ID%',
  470. );
  471. $data[] = array(
  472. "$post_key-attachment",
  473. $user,
  474. '/?attachment_id=%ID%',
  475. '/?attachment_id=%ID%',
  476. );
  477. $data[] = array(
  478. $post_key,
  479. $user,
  480. "/?name=$post_key&post_type=$post_key",
  481. "/?name=$post_key&post_type=$post_key",
  482. );
  483. $data[] = array(
  484. $post_key,
  485. $user,
  486. '/?feed=rss&p=%ID%',
  487. '/?feed=rss&p=%ID%',
  488. );
  489. }
  490. }
  491. return $data;
  492. }
  493. /**
  494. * Test canonical redirect does not reveal private slugs.
  495. *
  496. * @ticket 5272
  497. * @dataProvider data_canonical_redirects_to_pretty_permalinks
  498. *
  499. * @param string $post_key Post key used for creating fixtures.
  500. * @param string $user_role User role.
  501. * @param string $requested Requested URL.
  502. * @param string $expected Expected URL.
  503. */
  504. public function test_canonical_redirects_to_pretty_permalinks( $post_key, $user_role, $requested, $expected ) {
  505. wp_set_current_user( self::$users[ $user_role ] );
  506. $this->set_permalink_structure( '/%postname%/' );
  507. $post = self::$posts[ $post_key ];
  508. clean_post_cache( $post->ID );
  509. /*
  510. * The dataProvider runs before the fixures are set up, therefore the
  511. * post object IDs are placeholders that needs to be replaced.
  512. */
  513. $requested = str_replace( '%ID%', $post->ID, $requested );
  514. $expected = str_replace( '%ID%', $post->ID, $expected );
  515. $this->assertCanonical( $requested, $expected );
  516. }
  517. /**
  518. * Data provider for test_canonical_redirects_to_pretty_permalinks.
  519. *
  520. * @return array[] Array of arguments for tests {
  521. * @type string $post_key Post key used for creating fixtures.
  522. * @type string $user_role User role.
  523. * @type string $requested Requested URL.
  524. * @type string $expected Expected URL.
  525. * }
  526. */
  527. function data_canonical_redirects_to_pretty_permalinks() {
  528. $data = array();
  529. $all_user_list = array( 'anon', 'subscriber', 'content_author', 'editor' );
  530. $select_allow_list = array( 'content_author', 'editor' );
  531. $select_block_list = array( 'anon', 'subscriber' );
  532. // All post/page keys
  533. $all_user_post_status_keys = array( 'publish' );
  534. $select_user_post_status_keys = array( 'private', 'a-private-status' );
  535. $no_user_post_status_keys = array( 'future', 'draft', 'pending', 'auto-draft' ); // Excludes trash for attachment rules.
  536. $select_user_post_type_keys = array( 'a-public-cpt' );
  537. $no_user_post_type_keys = array( 'a-private-cpt' );
  538. foreach ( $all_user_post_status_keys as $post_key ) {
  539. foreach ( $all_user_list as $user ) {
  540. $data[] = array(
  541. $post_key,
  542. $user,
  543. '/?p=%ID%',
  544. "/$post_key-post/",
  545. );
  546. $data[] = array(
  547. "$post_key-attachment",
  548. $user,
  549. '/?attachment_id=%ID%',
  550. "/$post_key-post/$post_key-inherited-attachment/",
  551. );
  552. $data[] = array(
  553. "$post_key-page",
  554. $user,
  555. '/?post_type=page&p=%ID%',
  556. "/$post_key-page/",
  557. );
  558. $data[] = array(
  559. "$post_key-page",
  560. $user,
  561. '/?page_id=%ID%',
  562. "/$post_key-page/",
  563. );
  564. $data[] = array(
  565. $post_key,
  566. $user,
  567. "/?name=$post_key-post",
  568. "/$post_key-post/",
  569. );
  570. $data[] = array(
  571. $post_key,
  572. $user,
  573. '/?feed=rss&p=%ID%',
  574. "/$post_key-post/feed/",
  575. );
  576. $data[] = array(
  577. "$post_key-page",
  578. $user,
  579. '/?feed=rss&page_id=%ID%',
  580. "/$post_key-page/feed/",
  581. );
  582. }
  583. }
  584. foreach ( $select_user_post_status_keys as $post_key ) {
  585. foreach ( $select_allow_list as $user ) {
  586. $data[] = array(
  587. $post_key,
  588. $user,
  589. '/?p=%ID%',
  590. "/$post_key-post/",
  591. );
  592. $data[] = array(
  593. "$post_key-attachment",
  594. $user,
  595. '/?attachment_id=%ID%',
  596. "/$post_key-post/$post_key-inherited-attachment/",
  597. );
  598. $data[] = array(
  599. "$post_key-page",
  600. $user,
  601. '/?post_type=page&p=%ID%',
  602. "/$post_key-page/",
  603. );
  604. $data[] = array(
  605. "$post_key-page",
  606. $user,
  607. '/?page_id=%ID%',
  608. "/$post_key-page/",
  609. );
  610. $data[] = array(
  611. $post_key,
  612. $user,
  613. "/?name=$post_key-post",
  614. "/$post_key-post/",
  615. );
  616. $data[] = array(
  617. $post_key,
  618. $user,
  619. '/?feed=rss&p=%ID%',
  620. "/$post_key-post/feed/",
  621. );
  622. $data[] = array(
  623. "$post_key-page",
  624. $user,
  625. '/?feed=rss&page_id=%ID%',
  626. "/$post_key-page/feed/",
  627. );
  628. }
  629. foreach ( $select_block_list as $user ) {
  630. $data[] = array(
  631. $post_key,
  632. $user,
  633. '/?p=%ID%',
  634. '/?p=%ID%',
  635. );
  636. $data[] = array(
  637. "$post_key-attachment",
  638. $user,
  639. '/?attachment_id=%ID%',
  640. '/?attachment_id=%ID%',
  641. );
  642. $data[] = array(
  643. "$post_key-page",
  644. $user,
  645. '/?post_type=page&p=%ID%',
  646. '/?post_type=page&p=%ID%',
  647. );
  648. $data[] = array(
  649. "$post_key-page",
  650. $user,
  651. '/?page_id=%ID%',
  652. '/?page_id=%ID%',
  653. );
  654. $data[] = array(
  655. $post_key,
  656. $user,
  657. "/?name=$post_key-post",
  658. "/?name=$post_key-post",
  659. );
  660. $data[] = array(
  661. $post_key,
  662. $user,
  663. '/?feed=rss&p=%ID%',
  664. '/?feed=rss&p=%ID%',
  665. );
  666. $data[] = array(
  667. "$post_key-page",
  668. $user,
  669. '/?feed=rss&page_id=%ID%',
  670. '/?feed=rss&page_id=%ID%',
  671. );
  672. }
  673. }
  674. foreach ( $select_user_post_type_keys as $post_key ) {
  675. foreach ( $select_allow_list as $user ) {
  676. $data[] = array(
  677. $post_key,
  678. $user,
  679. '/?p=%ID%',
  680. "/$post_key/$post_key/",
  681. );
  682. $data[] = array(
  683. "$post_key-attachment",
  684. $user,
  685. '/?attachment_id=%ID%',
  686. "/$post_key/$post_key/$post_key-inherited-attachment/",
  687. );
  688. $data[] = array(
  689. $post_key,
  690. $user,
  691. "/?name=$post_key&post_type=$post_key",
  692. "/$post_key/$post_key/?post_type=$post_key",
  693. );
  694. $data[] = array(
  695. $post_key,
  696. $user,
  697. '/?feed=rss&p=%ID%',
  698. "/$post_key/$post_key/feed/",
  699. );
  700. }
  701. foreach ( $select_block_list as $user ) {
  702. $data[] = array(
  703. $post_key,
  704. $user,
  705. '/?p=%ID%',
  706. '/?p=%ID%',
  707. );
  708. $data[] = array(
  709. "$post_key-attachment",
  710. $user,
  711. '/?attachment_id=%ID%',
  712. '/?attachment_id=%ID%',
  713. );
  714. $data[] = array(
  715. $post_key,
  716. $user,
  717. "/?name=$post_key&post_type=$post_key",
  718. "/?name=$post_key&post_type=$post_key",
  719. );
  720. $data[] = array(
  721. $post_key,
  722. $user,
  723. '/?feed=rss&p=%ID%',
  724. '/?feed=rss&p=%ID%',
  725. );
  726. }
  727. }
  728. foreach ( $no_user_post_type_keys as $post_key ) {
  729. foreach ( $all_user_list as $user ) {
  730. $data[] = array(
  731. $post_key,
  732. $user,
  733. '/?p=%ID%',
  734. '/?p=%ID%',
  735. );
  736. $data[] = array(
  737. "$post_key-attachment",
  738. $user,
  739. '/?attachment_id=%ID%',
  740. '/?attachment_id=%ID%',
  741. // "/$post_key-inherited-attachment/",
  742. );
  743. $data[] = array(
  744. $post_key,
  745. $user,
  746. "/?name=$post_key&post_type=$post_key",
  747. "/?name=$post_key&post_type=$post_key",
  748. );
  749. $data[] = array(
  750. $post_key,
  751. $user,
  752. '/?feed=rss&p=%ID%',
  753. '/?feed=rss&p=%ID%',
  754. );
  755. }
  756. }
  757. foreach ( $no_user_post_status_keys as $post_key ) {
  758. foreach ( $all_user_list as $user ) {
  759. $data[] = array(
  760. $post_key,
  761. $user,
  762. '/?p=%ID%',
  763. '/?p=%ID%',
  764. );
  765. $data[] = array(
  766. "$post_key-attachment",
  767. $user,
  768. '/?attachment_id=%ID%',
  769. '/?attachment_id=%ID%',
  770. );
  771. $data[] = array(
  772. "$post_key-page",
  773. $user,
  774. '/?post_type=page&p=%ID%',
  775. '/?post_type=page&p=%ID%',
  776. );
  777. $data[] = array(
  778. "$post_key-page",
  779. $user,
  780. '/?page_id=%ID%',
  781. '/?page_id=%ID%',
  782. );
  783. $data[] = array(
  784. $post_key,
  785. $user,
  786. "/?name=$post_key-post",
  787. "/?name=$post_key-post",
  788. );
  789. $data[] = array(
  790. $post_key,
  791. $user,
  792. '/?feed=rss&p=%ID%',
  793. '/?feed=rss&p=%ID%',
  794. );
  795. $data[] = array(
  796. "$post_key-page",
  797. $user,
  798. '/?feed=rss&page_id=%ID%',
  799. '/?feed=rss&page_id=%ID%',
  800. );
  801. }
  802. }
  803. foreach ( array( 'trash' ) as $post_key ) {
  804. foreach ( $all_user_list as $user ) {
  805. $data[] = array(
  806. $post_key,
  807. $user,
  808. '/?p=%ID%',
  809. '/?p=%ID%',
  810. );
  811. $data[] = array(
  812. "$post_key-attachment",
  813. $user,
  814. '/?attachment_id=%ID%',
  815. '/?attachment_id=%ID%',
  816. );
  817. $data[] = array(
  818. "$post_key-attachment",
  819. $user,
  820. '/trash-post/trash-post-inherited-attachment/',
  821. '/?attachment_id=%ID%',
  822. );
  823. $data[] = array(
  824. "$post_key-attachment",
  825. $user,
  826. '/trash-post__trashed/trash-post-inherited-attachment/',
  827. '/?attachment_id=%ID%',
  828. );
  829. $data[] = array(
  830. "$post_key-page",
  831. $user,
  832. '/?post_type=page&p=%ID%',
  833. '/?post_type=page&p=%ID%',
  834. );
  835. $data[] = array(
  836. "$post_key-page",
  837. $user,
  838. '/?page_id=%ID%',
  839. '/?page_id=%ID%',
  840. );
  841. $data[] = array(
  842. $post_key,
  843. $user,
  844. "/?name=$post_key-post",
  845. "/?name=$post_key-post",
  846. );
  847. $data[] = array(
  848. $post_key,
  849. $user,
  850. '/?feed=rss&p=%ID%',
  851. '/?feed=rss&p=%ID%',
  852. );
  853. $data[] = array(
  854. "$post_key-page",
  855. $user,
  856. '/?feed=rss&page_id=%ID%',
  857. '/?feed=rss&page_id=%ID%',
  858. );
  859. }
  860. }
  861. return $data;
  862. }
  863. }