* * @copyright (c) 2018, Incsub (http://incsub.com) */ namespace Smush\Core\Integrations; use Smush\WP_Smush; if ( ! defined( 'WPINC' ) ) { die; } /** * Class Composer for WPBakery Page Builder integration. * * @since 3.2.1 */ class Composer extends Abstract_Integration { /** * Composer constructor. * * @since 3.2.1 */ public function __construct() { $this->module = 'js_builder'; $this->class = 'free'; $this->check_for_js_builder(); parent::__construct(); // Hook at the end of setting row to output a error div. add_action( 'smush_setting_column_right_inside', array( $this, 'additional_notice' ) ); // Add beta tag. add_action( 'smush_setting_column_tag', array( $this, 'add_beta_tag' ) ); if ( $this->settings->get( 'js_builder' ) ) { add_filter( 'image_make_intermediate_size', array( $this, 'process_image_resize' ) ); } } /************************************** * * OVERWRITE PARENT CLASS FUNCTIONALITY */ /** * Filters the setting variable to add NextGen setting title and description * * @since 3.2.1 * * @param array $settings Settings. * * @return mixed */ public function register( $settings ) { $settings[ $this->module ] = array( 'label' => esc_html__( 'Enable WPBakery Page Builder integration', 'wp-smushit' ), 'short_label' => esc_html__( 'WPBakery Page Builder', 'wp-smushit' ), 'desc' => esc_html__( 'Allow smushing images resized in WPBakery Page Builder editor.', 'wp-smushit' ), ); return $settings; } /** * Show additional notice if the required plugins are not installed. * * @since 3.2.1 * * @param string $name Setting name. */ public function additional_notice( $name ) { if ( 'js_builder' === $name && ! $this->enabled ) { ?>

module !== $setting_key ) { return; } $tooltip_text = __( 'This feature is likely to work without issue, however the integration is in beta stage and some issues are still present.', 'wp-smushit' ); ?> core()->mod->smush->do_smushit( $vc_image ); return $image_src; } /************************************** * * PRIVATE CLASSES */ /** * Should only be active when WPBakery Page Builder is installed. * * @since 3.2.1 */ private function check_for_js_builder() { if ( ! function_exists( 'is_plugin_active' ) ) { /* @noinspection PhpIncludeInspection */ include_once ABSPATH . 'wp-admin/includes/plugin.php'; } $this->enabled = defined( 'WPB_VC_VERSION' ) && is_plugin_active( 'js_composer/js_composer.php' ); } }