Make WordPress Core

Changeset 49374 for branches/5.5


Ignore:
Timestamp:
10/29/2020 04:52:48 PM (4 years ago)
Author:
whyisjake
Message:

Embeds: Disable embeds on deactivated Multisite sites.

Props xknown, whyisjake, zieladam, peterwilsoncc.

Location:
branches/5.5
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.5/src/wp-includes/embed.php

    r48574 r49374  
    610610        $sites = get_sites( $qv );
    611611        $site  = reset( $sites );
     612
     613        // Do not allow embeds for deleted/archived/spam sites.
     614        if ( ! empty( $site->deleted ) || ! empty( $site->spam ) || ! empty( $site->archived ) ) {
     615            return false;
     616        }
    612617
    613618        if ( $site && get_current_blog_id() !== (int) $site->blog_id ) {
  • branches/5.5/tests/phpunit/tests/multisite/site.php

    r48200 r49374  
    489489        }
    490490
     491        function test_content_from_spam_blog_is_not_available() {
     492            $spam_blog_id = self::factory()->blog->create();
     493            switch_to_blog( $spam_blog_id );
     494            $post_data      = array(
     495                'post_title'   => 'Hello World!',
     496                'post_content' => 'Hello world content',
     497            );
     498            $post_id        = self::factory()->post->create( $post_data );
     499            $post           = get_post( $post_id );
     500            $spam_permalink = site_url() . '/?p=' . $post->ID;
     501            $spam_embed_url = get_post_embed_url( $post_id );
     502
     503            restore_current_blog();
     504            $this->assertNotEmpty( $spam_permalink );
     505            $this->assertEquals( $post_data['post_title'], $post->post_title );
     506
     507            update_blog_status( $spam_blog_id, 'spam', 1 );
     508
     509            $post_id = self::factory()->post->create(
     510                array(
     511                    'post_content' => "\n $spam_permalink \n",
     512                )
     513            );
     514            $post    = get_post( $post_id );
     515            $content = apply_filters( 'the_content', $post->post_content );
     516
     517            $this->assertNotContains( $post_data['post_title'], $content );
     518            $this->assertNotContains( "src=\"{$spam_embed_url}#?", $content );
     519        }
     520
    491521        function test_update_blog_status_make_spam_blog_action() {
    492522            global $test_action_counter;
Note: See TracChangeset for help on using the changeset viewer.