Making WordPress.org

Changeset 7502


Ignore:
Timestamp:
07/26/2018 12:38:22 PM (6 years ago)
Author:
vedjain
Message:

oming Soon: Add a filter to prevent publicizing a post when coming soon mode is ON.

Fixes #3725.

props vedjain, dd32

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-coming-soon-page/classes/wordcamp-coming-soon-page.php

    r7173 r7502  
    2020        add_action( 'admin_notices',              array( $this, 'block_new_post_admin_notice'     )        );
    2121        add_filter( 'get_post_metadata',          array( $this, 'jetpack_dont_email_post_to_subs' ), 10, 4 );
     22        add_filter( 'publicize_should_publicize_published_post', array( $this, 'jetpack_prevent_publicize' ) );
    2223
    2324        add_image_size( 'wccsp_image_medium_rectangle', 500, 300 );
     
    397398            $class   = 'notice notice-warning';
    398399            $message = sprintf(
    399                 __( '<a href="%s">Coming Soon mode</a> is enabled. Site subscribers will not receive email notifications about published posts.', 'wordcamporg' ),
     400                __( '<a href="%s">Coming Soon mode</a> is enabled. Site subscribers will not receive email notifications about published posts. Published posts will not be automatically cross-posted to social media accounts.', 'wordcamporg' ),
    400401                esc_url( $setting_url )
    401402            );
     
    432433    }
    433434
     435    /**
     436     * Disable publicizing posts when Coming Soon mode is on. Note that even if we return false here, when publishing a
     437     * post, we will see a message that post has been cross posted in social media accounts. That message is incorrect,
     438     * but can only be fixed in JetPack, not here.
     439     *
     440     * @param bool $should_publicize Whether this post can be publicized or not
     441     *
     442     * @return bool
     443     */
     444    public function jetpack_prevent_publicize( $should_publicize ) {
     445        $settings = $GLOBALS['WCCSP_Settings']->get_settings();
     446
     447        if ( 'on' === $settings['enabled'] ) {
     448            return false;
     449        }
     450
     451        return $should_publicize;
     452    }
     453
    434454} // end WordCamp_Coming_Soon_Page.
Note: See TracChangeset for help on using the changeset viewer.