plugin_file ); deactivate_plugins( $gutenberg_extension_plugin, true ); if ( $needs_redirect ) { wp_safe_redirect( admin_url( 'plugins.php' ) ); tribe_exit(); } } /** * Filter when we are in the classic editor page * * @since 4.7.4 * * @param boolean $pre * * @return boolean */ public function filter_is_classic_editor( $is_classic_editor = false ) { if ( ! $this->is_blocks_editor_toggled_on() ) { return true; } return $is_classic_editor; } /** * Gets if user toggled blocks editor on the settings * * @since 4.7 * * @return bool */ public function is_blocks_editor_toggled_on() { $is_on = tribe_get_option( $this->get_toggle_blocks_editor_key(), false ); /** * Filters whether the Blocks Editor is on or not. * * @since 5.1.1 * * @param bool $is_on Whether the Blocks Editor is on or not. */ $is_on = (bool) apply_filters( 'tribe_events_blocks_editor_is_on', $is_on ); return tribe_is_truthy( $is_on ); } /** * Gets the option key for toggling Blocks Editor active * * @since 4.7 * * @return string */ public function get_toggle_blocks_editor_key() { return 'toggle_blocks_editor'; } /** * Gets the option key for the Hidden Field of toggling blocks editor * * @since 4.7 * * @return string */ public function get_toggle_blocks_editor_hidden_key() { return 'toggle_blocks_editor_hidden_field'; } /** * Inserts the Toggle and Hidden Field for the Activation of Blocks Editor * * @since 4.7 * * @param array $fields Fields from Options General * * @return array */ public function insert_toggle_blocks_editor_field( $fields = [] ) { if ( ! tribe( 'editor' )->is_wp_version() ) { return $fields; } $read_more_url = 'https://theeventscalendar.com/gutenberg-block-editor-news/?utm_source=tec&utm_medium=eventscalendarapp&utm_term=adminnotice&utm_campaign=gutenbergrelease&utm_content=ebook-gutenberg&cid=tec_eventscalendarapp_adminnotice_gutenbergrelease_ebook-gutenberg'; $read_more_link = sprintf( ' %1$s.', esc_html__( 'Read more', 'the-events-calendar' ), esc_url( $read_more_url ) ); $insert_before = 'showComments'; $insert_data = [ $this->get_toggle_blocks_editor_key() => [ 'type' => 'checkbox_bool', 'label' => esc_html__( 'Activate Block Editor for Events', 'the-events-calendar' ), 'tooltip' => esc_html__( 'Enable the Gutenberg block editor interface for creating events.', 'the-events-calendar' ) . $read_more_link, 'default' => false, 'validation_type' => 'boolean', 'attributes' => [ 'id' => 'tribe-blocks-editor-toggle-field' ], ], $this->get_toggle_blocks_editor_hidden_key() => [ 'type' => 'checkbox_bool', 'label' => esc_html__( 'Hidden Blocks Editor Config', 'the-events-calendar' ), 'default' => false, 'validation_type' => 'boolean', 'attributes' => [ 'id' => 'tribe-blocks-editor-toggle-hidden-field' ], ], ]; return Tribe__Main::array_insert_before_key( $insert_before, $fields, $insert_data ); } }