options = $options; } /** * {@inheritdoc} */ public static function get_subscribed_events() { return [ 'wp_default_scripts' => [ 'dequeue_jquery_migrate' ], ]; } /** * Dequeue jquery migrate * * @since 3.5 * @author Soponar Cristina * * @param WP_Scripts $scripts WP_Scripts instance. * @return bool|void */ public function dequeue_jquery_migrate( $scripts ) { if ( ! $this->is_allowed() ) { return false; } if ( ! empty( $scripts->registered['jquery'] ) ) { $jquery_dependencies = $scripts->registered['jquery']->deps; $scripts->registered['jquery']->deps = array_diff( $jquery_dependencies, [ 'jquery-migrate' ] ); } } /** * Check if dequeue jquery migrate option is enabled * * @since 3.5 * @author Soponar Cristina * * @return boolean */ protected function is_allowed() { if ( rocket_get_constant( 'DONOTROCKETOPTIMIZE', false ) ) { return false; } if ( ! $this->options->get( 'dequeue_jquery_migrate' ) ) { return false; } return true; } }