* * @copyright (c) 2018, Incsub (http://incsub.com) */ namespace Smush\Core\Integrations; if ( ! defined( 'WPINC' ) ) { die; } /** * Class Gutenberg for Gutenberg integration. * * @since 2.8.1 */ class Gutenberg extends Abstract_Integration { /** * Gutenberg constructor. * * @since 2.8.1 */ public function __construct() { $this->module = 'gutenberg'; $this->class = 'free'; $this->check_for_gutenberg(); parent::__construct(); if ( ! $this->enabled ) { // Disable setting if Gutenberg is not active. add_filter( 'wp_smush_integration_status_' . $this->module, '__return_true' ); // Hook at the end of setting row to output an error div. add_action( 'smush_setting_column_right_inside', array( $this, 'integration_error' ) ); return; } // Show submit button when Gutenberg is active. add_filter( 'wp_smush_integration_show_submit', '__return_true' ); // Register gutenberg block assets. add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_gb' ) ); } /************************************** * * OVERWRITE PARENT CLASS FUNCTIONALITY */ /** * Filters the setting variable to add Gutenberg setting title and description. * * @since 2.8.1 * * @param array $settings Settings array. * * @return mixed */ public function register( $settings ) { $settings[ $this->module ] = array( 'label' => esc_html__( 'Show Smush stats in Gutenberg blocks', 'wp-smushit' ), 'short_label' => esc_html__( 'Gutenberg Support', 'wp-smushit' ), 'desc' => esc_html__( 'Add statistics and the manual smush button to Gutenberg blocks that display images.', 'wp-smushit' ), ); return $settings; } /************************************** * * PUBLIC CLASSES */ /** * Prints the message for Gutenberg setup. * * @since 2.8.1 * * @param string $setting_key Settings key. */ public function integration_error( $setting_key ) { // Return if not Gutenberg integration. if ( $this->module !== $setting_key ) { return; } ?>