Skip to content

Commit

Permalink
fix: remove support for background gradients (#152)
Browse files Browse the repository at this point in the history
* fix: remove support for background gradients

* fix: add action to the_post to disable gradients

* feat: use get_post_type to check newsletters cpt
  • Loading branch information
thomasguillot authored Apr 27, 2020
1 parent 216aa9f commit f4b1120
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions includes/class-newspack-newsletters.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ public static function instance() {
*/
public function __construct() {
add_action( 'the_post', [ __CLASS__, 'remove_other_editor_modifications' ] );
add_action( 'the_post', [ __CLASS__, 'disable_gradients' ] );
add_action( 'init', [ __CLASS__, 'register_cpt' ] );
add_action( 'init', [ __CLASS__, 'register_meta' ] );
add_action( 'enqueue_block_editor_assets', [ __CLASS__, 'enqueue_block_editor_assets' ] );
add_action( 'enqueue_block_editor_assets', [ __CLASS__, 'disable_gradients' ] );
add_action( 'rest_api_init', [ __CLASS__, 'rest_api_init' ] );
add_action( 'default_title', [ __CLASS__, 'default_title' ], 10, 2 );
add_action( 'save_post_' . self::NEWSPACK_NEWSLETTERS_CPT, [ __CLASS__, 'save_post' ], 10, 3 );
Expand Down Expand Up @@ -477,7 +477,7 @@ public static function api_set_campaign_settings( $request ) {

$verified_domains = array_filter(
array_map(
function( $domain ) {
function( $domain ) {
return $domain['verified'] ? strtolower( trim( $domain['domain'] ) ) : null;
},
$result['domains']
Expand Down Expand Up @@ -756,7 +756,7 @@ public static function retrieve_data( $id ) {
);
}
$mc = new Mailchimp( self::mailchimp_api_key() );
$campaign = self::validate_mailchimp_operation(
$campaign = self::validate_mailchimp_operation(
$mc->get( "campaigns/$mc_campaign_id" ),
__( 'Error retrieving Mailchimp campaign.', 'newspack_newsletters' )
);
Expand Down Expand Up @@ -958,8 +958,7 @@ public static function get_newsletter_templates() {
* Disable gradients in Newsletter CPT.
*/
public static function disable_gradients() {
$screen = get_current_screen();
if ( ! $screen || self::NEWSPACK_NEWSLETTERS_CPT !== $screen->post_type ) {
if ( self::NEWSPACK_NEWSLETTERS_CPT != get_post_type() ) {
return;
}
add_theme_support( 'editor-gradient-presets', array() );
Expand Down

0 comments on commit f4b1120

Please sign in to comment.