123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973 |
- <?php
- /**
- * @group canonical
- * @group rewrite
- * @group query
- */
- class Tests_Canonical_PostStatus extends WP_Canonical_UnitTestCase {
- /**
- * User IDs.
- *
- * @var array
- */
- public static $users;
- /**
- * Post Objects.
- *
- * @var array
- */
- public static $posts;
- public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
- self::setup_custom_types();
- self::$users = array(
- 'anon' => 0,
- 'subscriber' => $factory->user->create( array( 'role' => 'subscriber' ) ),
- 'content_author' => $factory->user->create( array( 'role' => 'author' ) ),
- 'editor' => $factory->user->create( array( 'role' => 'editor' ) ),
- );
- $post_statuses = array( 'publish', 'future', 'draft', 'pending', 'private', 'auto-draft', 'a-private-status' );
- foreach ( $post_statuses as $post_status ) {
- $post_date = '';
- if ( 'future' === $post_status ) {
- $post_date = strftime( '%Y-%m-%d %H:%M:%S', strtotime( '+1 year' ) );
- }
- self::$posts[ $post_status ] = $factory->post->create_and_get(
- array(
- 'post_type' => 'post',
- 'post_title' => "$post_status post",
- 'post_name' => "$post_status-post",
- 'post_status' => $post_status,
- 'post_content' => "Prevent canonical redirect exposing post slugs.\n\n<!--nextpage-->Page 2",
- 'post_author' => self::$users['content_author'],
- 'post_date' => $post_date,
- )
- );
- // Add fake attachment to the post (file upload not needed).
- self::$posts[ "$post_status-attachment" ] = $factory->post->create_and_get(
- array(
- 'post_type' => 'attachment',
- 'post_title' => "$post_status inherited attachment",
- 'post_name' => "$post_status-inherited-attachment",
- 'post_status' => 'inherit',
- 'post_content' => "Prevent canonical redirect exposing post via attachments.\n\n<!--nextpage-->Page 2",
- 'post_author' => self::$users['content_author'],
- 'post_parent' => self::$posts[ $post_status ]->ID,
- 'post_date' => $post_date,
- )
- );
- // Set up a page with same.
- self::$posts[ "$post_status-page" ] = $factory->post->create_and_get(
- array(
- 'post_type' => 'page',
- 'post_title' => "$post_status page",
- 'post_name' => "$post_status-page",
- 'post_status' => $post_status,
- 'post_content' => "Prevent canonical redirect exposing page slugs.\n\n<!--nextpage-->Page 2",
- 'post_author' => self::$users['content_author'],
- 'post_date' => $post_date,
- )
- );
- }
- // Create a public CPT using a private status.
- self::$posts['a-public-cpt'] = $factory->post->create_and_get(
- array(
- 'post_type' => 'a-public-cpt',
- 'post_title' => 'a-public-cpt',
- 'post_name' => 'a-public-cpt',
- 'post_status' => 'private',
- 'post_content' => 'Prevent canonical redirect exposing a-public-cpt titles.',
- 'post_author' => self::$users['content_author'],
- )
- );
- // Add fake attachment to the public cpt (file upload not needed).
- self::$posts['a-public-cpt-attachment'] = $factory->post->create_and_get(
- array(
- 'post_type' => 'attachment',
- 'post_title' => 'a-public-cpt post inherited attachment',
- 'post_name' => 'a-public-cpt-inherited-attachment',
- 'post_status' => 'inherit',
- 'post_content' => "Prevent canonical redirect exposing post via attachments.\n\n<!--nextpage-->Page 2",
- 'post_author' => self::$users['content_author'],
- 'post_parent' => self::$posts['a-public-cpt']->ID,
- )
- );
- // Create a private CPT with a public status.
- self::$posts['a-private-cpt'] = $factory->post->create_and_get(
- array(
- 'post_type' => 'a-private-cpt',
- 'post_title' => 'a-private-cpt',
- 'post_name' => 'a-private-cpt',
- 'post_status' => 'publish',
- 'post_content' => 'Prevent canonical redirect exposing a-private-cpt titles.',
- 'post_author' => self::$users['content_author'],
- )
- );
- // Add fake attachment to the private cpt (file upload not needed).
- self::$posts['a-private-cpt-attachment'] = $factory->post->create_and_get(
- array(
- 'post_type' => 'attachment',
- 'post_title' => 'a-private-cpt post inherited attachment',
- 'post_name' => 'a-private-cpt-inherited-attachment',
- 'post_status' => 'inherit',
- 'post_content' => "Prevent canonical redirect exposing post via attachments.\n\n<!--nextpage-->Page 2",
- 'post_author' => self::$users['content_author'],
- 'post_parent' => self::$posts['a-private-cpt']->ID,
- )
- );
- // Post for trashing.
- self::$posts['trash'] = $factory->post->create_and_get(
- array(
- 'post_type' => 'post',
- 'post_title' => 'trash post',
- 'post_name' => 'trash-post',
- 'post_status' => 'publish',
- 'post_content' => "Prevent canonical redirect exposing post slugs.\n\n<!--nextpage-->Page 2",
- 'post_author' => self::$users['content_author'],
- )
- );
- self::$posts['trash-attachment'] = $factory->post->create_and_get(
- array(
- 'post_type' => 'attachment',
- 'post_title' => 'trash post inherited attachment',
- 'post_name' => 'trash-post-inherited-attachment',
- 'post_status' => 'inherit',
- 'post_content' => "Prevent canonical redirect exposing post via attachments.\n\n<!--nextpage-->Page 2",
- 'post_author' => self::$users['content_author'],
- 'post_parent' => self::$posts['trash']->ID,
- )
- );
- // Page for trashing.
- self::$posts['trash-page'] = $factory->post->create_and_get(
- array(
- 'post_type' => 'page',
- 'post_title' => 'trash page',
- 'post_name' => 'trash-page',
- 'post_status' => 'publish',
- 'post_content' => "Prevent canonical redirect exposing page slugs.\n\n<!--nextpage-->Page 2",
- 'post_author' => self::$users['content_author'],
- )
- );
- wp_trash_post( self::$posts['trash']->ID );
- wp_trash_post( self::$posts['trash-page']->ID );
- }
- function setUp() {
- parent::setUp();
- self::setup_custom_types();
- }
- /**
- * Set up a custom post type and private status.
- *
- * This needs to be called both in the class setup and
- * test setup.
- */
- public static function setup_custom_types() {
- // Register public custom post type.
- register_post_type(
- 'a-public-cpt',
- array(
- 'public' => true,
- 'rewrite' => array(
- 'slug' => 'a-public-cpt',
- ),
- )
- );
- // Register private custom post type.
- register_post_type(
- 'a-private-cpt',
- array(
- 'public' => false,
- 'publicly_queryable' => false,
- 'rewrite' => array(
- 'slug' => 'a-private-cpt',
- ),
- 'map_meta_cap' => true,
- )
- );
- // Register custom private post status.
- register_post_status(
- 'a-private-status',
- array(
- 'private' => true,
- )
- );
- }
- /**
- * Test canonical redirect does not reveal private posts presence.
- *
- * @ticket 5272
- * @dataProvider data_canonical_redirects_to_plain_permalinks
- *
- * @param string $post_key Post key used for creating fixtures.
- * @param string $user_role User role.
- * @param string $requested Requested URL.
- * @param string $expected Expected URL.
- */
- public function test_canonical_redirects_to_plain_permalinks( $post_key, $user_role, $requested, $expected ) {
- wp_set_current_user( self::$users[ $user_role ] );
- $this->set_permalink_structure( '' );
- $post = self::$posts[ $post_key ];
- clean_post_cache( $post->ID );
- /*
- * The dataProvider runs before the fixures are set up, therefore the
- * post object IDs are placeholders that needs to be replaced.
- */
- $requested = str_replace( '%ID%', $post->ID, $requested );
- $expected = str_replace( '%ID%', $post->ID, $expected );
- $this->assertCanonical( $requested, $expected );
- }
- /**
- * Data provider for test_canonical_redirects_to_plain_permalinks.
- *
- * @return array[] Array of arguments for tests {
- * @type string $post_key Post key used for creating fixtures.
- * @type string $user_role User role.
- * @type string $requested Requested URL.
- * @type string $expected Expected URL.
- * }
- */
- function data_canonical_redirects_to_plain_permalinks() {
- $data = array();
- $all_user_list = array( 'anon', 'subscriber', 'content_author', 'editor' );
- $select_allow_list = array( 'content_author', 'editor' );
- $select_block_list = array( 'anon', 'subscriber' );
- // All post/page keys
- $all_user_post_status_keys = array( 'publish' );
- $select_user_post_status_keys = array( 'private', 'a-private-status' );
- $no_user_post_status_keys = array( 'future', 'draft', 'pending', 'auto-draft' ); // Excludes trash for attachment rules.
- $select_user_post_type_keys = array( 'a-public-cpt' );
- $no_user_post_type_keys = array( 'a-private-cpt' );
- foreach ( $all_user_post_status_keys as $post_key ) {
- foreach ( $all_user_list as $user ) {
- /*
- * In the event `redirect_canonical()` is updated to redirect plain permalinks
- * to a canonical plain version, these expected values can be changed.
- */
- $data[] = array(
- "$post_key-page",
- $user,
- '/?post_type=page&p=%ID%',
- '/?post_type=page&p=%ID%',
- );
- $data[] = array(
- $post_key,
- $user,
- "/?name=$post_key-post",
- "/?name=$post_key-post",
- );
- // Ensure rss redirects to rss2.
- $data[] = array(
- $post_key,
- $user,
- '/?feed=rss&p=%ID%',
- '/?feed=rss2&p=%ID%',
- );
- // Ensure rss redirects to rss2.
- $data[] = array(
- "$post_key-page",
- $user,
- '/?feed=rss&page_id=%ID%',
- '/?feed=rss2&page_id=%ID%',
- );
- }
- }
- foreach ( $select_user_post_status_keys as $post_key ) {
- foreach ( $select_allow_list as $user ) {
- /*
- * In the event `redirect_canonical()` is updated to redirect plain permalinks
- * to a canonical plain version, these expected values can be changed.
- */
- $data[] = array(
- "$post_key-page",
- $user,
- '/?post_type=page&p=%ID%',
- '/?post_type=page&p=%ID%',
- );
- $data[] = array(
- $post_key,
- $user,
- "/?name=$post_key-post",
- "/?name=$post_key-post",
- );
- // Ensure rss redirects to rss2.
- $data[] = array(
- $post_key,
- $user,
- '/?feed=rss&p=%ID%',
- '/?feed=rss2&p=%ID%',
- );
- // Ensure rss redirects to rss2.
- $data[] = array(
- "$post_key-page",
- $user,
- '/?feed=rss&page_id=%ID%',
- '/?feed=rss2&page_id=%ID%',
- );
- }
- foreach ( $select_block_list as $user ) {
- /*
- * In the event `redirect_canonical()` is updated to redirect plain permalinks
- * to a canonical plain version, these expected values MUST NOT be changed.
- */
- $data[] = array(
- "$post_key-page",
- $user,
- '/?post_type=page&p=%ID%',
- '/?post_type=page&p=%ID%',
- );
- $data[] = array(
- $post_key,
- $user,
- "/?name=$post_key-post",
- "/?name=$post_key-post",
- );
- // Ensure post's existence is not demonstrated by changing rss to rss2.
- $data[] = array(
- $post_key,
- $user,
- '/?feed=rss&p=%ID%',
- '/?feed=rss&p=%ID%',
- );
- // Ensure post's existence is not demonstrated by changing rss to rss2.
- $data[] = array(
- "$post_key-page",
- $user,
- '/?feed=rss&page_id=%ID%',
- '/?feed=rss&page_id=%ID%',
- );
- }
- }
- foreach ( $no_user_post_status_keys as $post_key ) {
- foreach ( $all_user_list as $user ) {
- /*
- * In the event `redirect_canonical()` is updated to redirect plain permalinks
- * to a canonical plain version, these expected values MUST NOT be changed.
- */
- $data[] = array(
- "$post_key-page",
- $user,
- '/?post_type=page&p=%ID%',
- '/?post_type=page&p=%ID%',
- );
- $data[] = array(
- $post_key,
- $user,
- "/?name=$post_key-post",
- "/?name=$post_key-post",
- );
- // Ensure post's existence is not demonstrated by changing rss to rss2.
- $data[] = array(
- $post_key,
- $user,
- '/?feed=rss&p=%ID%',
- '/?feed=rss&p=%ID%',
- );
- // Ensure post's existence is not demonstrated by changing rss to rss2.
- $data[] = array(
- "$post_key-page",
- $user,
- '/?feed=rss&page_id=%ID%',
- '/?feed=rss&page_id=%ID%',
- );
- }
- }
- foreach ( array( 'trash' ) as $post_key ) {
- foreach ( $all_user_list as $user ) {
- /*
- * In the event `redirect_canonical()` is updated to redirect plain permalinks
- * to a canonical plain version, these expected values MUST NOT be changed.
- */
- $data[] = array(
- "$post_key-page",
- $user,
- '/?post_type=page&p=%ID%',
- '/?post_type=page&p=%ID%',
- );
- $data[] = array(
- $post_key,
- $user,
- "/?name=$post_key-post",
- "/?name=$post_key-post",
- );
- // Ensure post's existence is not demonstrated by changing rss to rss2.
- $data[] = array(
- $post_key,
- $user,
- '/?feed=rss&p=%ID%',
- '/?feed=rss&p=%ID%',
- );
- // Ensure post's existence is not demonstrated by changing rss to rss2.
- $data[] = array(
- "$post_key-page",
- $user,
- '/?feed=rss&page_id=%ID%',
- '/?feed=rss&page_id=%ID%',
- );
- }
- }
- foreach ( $select_user_post_type_keys as $post_key ) {
- foreach ( $select_allow_list as $user ) {
- $data[] = array(
- $post_key,
- $user,
- '/?p=%ID%',
- '/?a-public-cpt=a-public-cpt',
- );
- $data[] = array(
- "$post_key-attachment",
- $user,
- '/?attachment_id=%ID%',
- '/?attachment_id=%ID%',
- );
- $data[] = array(
- $post_key,
- $user,
- "/?name=$post_key&post_type=$post_key",
- "/?name=$post_key&post_type=$post_key",
- );
- // Ensure rss is replaced by rss2.
- $data[] = array(
- $post_key,
- $user,
- '/?feed=rss&p=%ID%',
- '/?a-public-cpt=a-public-cpt&feed=rss2',
- );
- }
- foreach ( $select_block_list as $user ) {
- $data[] = array(
- $post_key,
- $user,
- '/?p=%ID%',
- '/?p=%ID%',
- );
- $data[] = array(
- "$post_key-attachment",
- $user,
- '/?attachment_id=%ID%',
- '/?attachment_id=%ID%',
- );
- $data[] = array(
- $post_key,
- $user,
- "/?name=$post_key&post_type=$post_key",
- "/?name=$post_key&post_type=$post_key",
- );
- // Ensure rss is not replaced with rss2.
- $data[] = array(
- $post_key,
- $user,
- '/?feed=rss&p=%ID%',
- '/?feed=rss&p=%ID%',
- );
- }
- }
- foreach ( $no_user_post_type_keys as $post_key ) {
- foreach ( $all_user_list as $user ) {
- $data[] = array(
- $post_key,
- $user,
- '/?p=%ID%',
- '/?p=%ID%',
- );
- $data[] = array(
- "$post_key-attachment",
- $user,
- '/?attachment_id=%ID%',
- '/?attachment_id=%ID%',
- );
- $data[] = array(
- $post_key,
- $user,
- "/?name=$post_key&post_type=$post_key",
- "/?name=$post_key&post_type=$post_key",
- );
- $data[] = array(
- $post_key,
- $user,
- '/?feed=rss&p=%ID%',
- '/?feed=rss&p=%ID%',
- );
- }
- }
- return $data;
- }
- /**
- * Test canonical redirect does not reveal private slugs.
- *
- * @ticket 5272
- * @dataProvider data_canonical_redirects_to_pretty_permalinks
- *
- * @param string $post_key Post key used for creating fixtures.
- * @param string $user_role User role.
- * @param string $requested Requested URL.
- * @param string $expected Expected URL.
- */
- public function test_canonical_redirects_to_pretty_permalinks( $post_key, $user_role, $requested, $expected ) {
- wp_set_current_user( self::$users[ $user_role ] );
- $this->set_permalink_structure( '/%postname%/' );
- $post = self::$posts[ $post_key ];
- clean_post_cache( $post->ID );
- /*
- * The dataProvider runs before the fixures are set up, therefore the
- * post object IDs are placeholders that needs to be replaced.
- */
- $requested = str_replace( '%ID%', $post->ID, $requested );
- $expected = str_replace( '%ID%', $post->ID, $expected );
- $this->assertCanonical( $requested, $expected );
- }
- /**
- * Data provider for test_canonical_redirects_to_pretty_permalinks.
- *
- * @return array[] Array of arguments for tests {
- * @type string $post_key Post key used for creating fixtures.
- * @type string $user_role User role.
- * @type string $requested Requested URL.
- * @type string $expected Expected URL.
- * }
- */
- function data_canonical_redirects_to_pretty_permalinks() {
- $data = array();
- $all_user_list = array( 'anon', 'subscriber', 'content_author', 'editor' );
- $select_allow_list = array( 'content_author', 'editor' );
- $select_block_list = array( 'anon', 'subscriber' );
- // All post/page keys
- $all_user_post_status_keys = array( 'publish' );
- $select_user_post_status_keys = array( 'private', 'a-private-status' );
- $no_user_post_status_keys = array( 'future', 'draft', 'pending', 'auto-draft' ); // Excludes trash for attachment rules.
- $select_user_post_type_keys = array( 'a-public-cpt' );
- $no_user_post_type_keys = array( 'a-private-cpt' );
- foreach ( $all_user_post_status_keys as $post_key ) {
- foreach ( $all_user_list as $user ) {
- $data[] = array(
- $post_key,
- $user,
- '/?p=%ID%',
- "/$post_key-post/",
- );
- $data[] = array(
- "$post_key-attachment",
- $user,
- '/?attachment_id=%ID%',
- "/$post_key-post/$post_key-inherited-attachment/",
- );
- $data[] = array(
- "$post_key-page",
- $user,
- '/?post_type=page&p=%ID%',
- "/$post_key-page/",
- );
- $data[] = array(
- "$post_key-page",
- $user,
- '/?page_id=%ID%',
- "/$post_key-page/",
- );
- $data[] = array(
- $post_key,
- $user,
- "/?name=$post_key-post",
- "/$post_key-post/",
- );
- $data[] = array(
- $post_key,
- $user,
- '/?feed=rss&p=%ID%',
- "/$post_key-post/feed/",
- );
- $data[] = array(
- "$post_key-page",
- $user,
- '/?feed=rss&page_id=%ID%',
- "/$post_key-page/feed/",
- );
- }
- }
- foreach ( $select_user_post_status_keys as $post_key ) {
- foreach ( $select_allow_list as $user ) {
- $data[] = array(
- $post_key,
- $user,
- '/?p=%ID%',
- "/$post_key-post/",
- );
- $data[] = array(
- "$post_key-attachment",
- $user,
- '/?attachment_id=%ID%',
- "/$post_key-post/$post_key-inherited-attachment/",
- );
- $data[] = array(
- "$post_key-page",
- $user,
- '/?post_type=page&p=%ID%',
- "/$post_key-page/",
- );
- $data[] = array(
- "$post_key-page",
- $user,
- '/?page_id=%ID%',
- "/$post_key-page/",
- );
- $data[] = array(
- $post_key,
- $user,
- "/?name=$post_key-post",
- "/$post_key-post/",
- );
- $data[] = array(
- $post_key,
- $user,
- '/?feed=rss&p=%ID%',
- "/$post_key-post/feed/",
- );
- $data[] = array(
- "$post_key-page",
- $user,
- '/?feed=rss&page_id=%ID%',
- "/$post_key-page/feed/",
- );
- }
- foreach ( $select_block_list as $user ) {
- $data[] = array(
- $post_key,
- $user,
- '/?p=%ID%',
- '/?p=%ID%',
- );
- $data[] = array(
- "$post_key-attachment",
- $user,
- '/?attachment_id=%ID%',
- '/?attachment_id=%ID%',
- );
- $data[] = array(
- "$post_key-page",
- $user,
- '/?post_type=page&p=%ID%',
- '/?post_type=page&p=%ID%',
- );
- $data[] = array(
- "$post_key-page",
- $user,
- '/?page_id=%ID%',
- '/?page_id=%ID%',
- );
- $data[] = array(
- $post_key,
- $user,
- "/?name=$post_key-post",
- "/?name=$post_key-post",
- );
- $data[] = array(
- $post_key,
- $user,
- '/?feed=rss&p=%ID%',
- '/?feed=rss&p=%ID%',
- );
- $data[] = array(
- "$post_key-page",
- $user,
- '/?feed=rss&page_id=%ID%',
- '/?feed=rss&page_id=%ID%',
- );
- }
- }
- foreach ( $select_user_post_type_keys as $post_key ) {
- foreach ( $select_allow_list as $user ) {
- $data[] = array(
- $post_key,
- $user,
- '/?p=%ID%',
- "/$post_key/$post_key/",
- );
- $data[] = array(
- "$post_key-attachment",
- $user,
- '/?attachment_id=%ID%',
- "/$post_key/$post_key/$post_key-inherited-attachment/",
- );
- $data[] = array(
- $post_key,
- $user,
- "/?name=$post_key&post_type=$post_key",
- "/$post_key/$post_key/?post_type=$post_key",
- );
- $data[] = array(
- $post_key,
- $user,
- '/?feed=rss&p=%ID%',
- "/$post_key/$post_key/feed/",
- );
- }
- foreach ( $select_block_list as $user ) {
- $data[] = array(
- $post_key,
- $user,
- '/?p=%ID%',
- '/?p=%ID%',
- );
- $data[] = array(
- "$post_key-attachment",
- $user,
- '/?attachment_id=%ID%',
- '/?attachment_id=%ID%',
- );
- $data[] = array(
- $post_key,
- $user,
- "/?name=$post_key&post_type=$post_key",
- "/?name=$post_key&post_type=$post_key",
- );
- $data[] = array(
- $post_key,
- $user,
- '/?feed=rss&p=%ID%',
- '/?feed=rss&p=%ID%',
- );
- }
- }
- foreach ( $no_user_post_type_keys as $post_key ) {
- foreach ( $all_user_list as $user ) {
- $data[] = array(
- $post_key,
- $user,
- '/?p=%ID%',
- '/?p=%ID%',
- );
- $data[] = array(
- "$post_key-attachment",
- $user,
- '/?attachment_id=%ID%',
- '/?attachment_id=%ID%',
- // "/$post_key-inherited-attachment/",
- );
- $data[] = array(
- $post_key,
- $user,
- "/?name=$post_key&post_type=$post_key",
- "/?name=$post_key&post_type=$post_key",
- );
- $data[] = array(
- $post_key,
- $user,
- '/?feed=rss&p=%ID%',
- '/?feed=rss&p=%ID%',
- );
- }
- }
- foreach ( $no_user_post_status_keys as $post_key ) {
- foreach ( $all_user_list as $user ) {
- $data[] = array(
- $post_key,
- $user,
- '/?p=%ID%',
- '/?p=%ID%',
- );
- $data[] = array(
- "$post_key-attachment",
- $user,
- '/?attachment_id=%ID%',
- '/?attachment_id=%ID%',
- );
- $data[] = array(
- "$post_key-page",
- $user,
- '/?post_type=page&p=%ID%',
- '/?post_type=page&p=%ID%',
- );
- $data[] = array(
- "$post_key-page",
- $user,
- '/?page_id=%ID%',
- '/?page_id=%ID%',
- );
- $data[] = array(
- $post_key,
- $user,
- "/?name=$post_key-post",
- "/?name=$post_key-post",
- );
- $data[] = array(
- $post_key,
- $user,
- '/?feed=rss&p=%ID%',
- '/?feed=rss&p=%ID%',
- );
- $data[] = array(
- "$post_key-page",
- $user,
- '/?feed=rss&page_id=%ID%',
- '/?feed=rss&page_id=%ID%',
- );
- }
- }
- foreach ( array( 'trash' ) as $post_key ) {
- foreach ( $all_user_list as $user ) {
- $data[] = array(
- $post_key,
- $user,
- '/?p=%ID%',
- '/?p=%ID%',
- );
- $data[] = array(
- "$post_key-attachment",
- $user,
- '/?attachment_id=%ID%',
- '/?attachment_id=%ID%',
- );
- $data[] = array(
- "$post_key-attachment",
- $user,
- '/trash-post/trash-post-inherited-attachment/',
- '/?attachment_id=%ID%',
- );
- $data[] = array(
- "$post_key-attachment",
- $user,
- '/trash-post__trashed/trash-post-inherited-attachment/',
- '/?attachment_id=%ID%',
- );
- $data[] = array(
- "$post_key-page",
- $user,
- '/?post_type=page&p=%ID%',
- '/?post_type=page&p=%ID%',
- );
- $data[] = array(
- "$post_key-page",
- $user,
- '/?page_id=%ID%',
- '/?page_id=%ID%',
- );
- $data[] = array(
- $post_key,
- $user,
- "/?name=$post_key-post",
- "/?name=$post_key-post",
- );
- $data[] = array(
- $post_key,
- $user,
- '/?feed=rss&p=%ID%',
- '/?feed=rss&p=%ID%',
- );
- $data[] = array(
- "$post_key-page",
- $user,
- '/?feed=rss&page_id=%ID%',
- '/?feed=rss&page_id=%ID%',
- );
- }
- }
- return $data;
- }
- }
|