form = wpforms()->get( 'form' )->get( $form_id ); $this->form_data = $this->form ? wpforms_decode( $this->form->post_content ) : false; // Get current revision, if available. $revision = wpforms()->get( 'revisions' )->get_revision(); // If we're viewing a valid revision, replace the form data so the Form Builder shows correct state. if ( $revision && isset( $revision->post_content ) ) { $this->form_data = wpforms_decode( $revision->post_content ); } // Bootstrap. $this->init(); // Save instance. self::$instance = $this; // Primary panel button. add_action( 'wpforms_builder_panel_buttons', [ $this, 'button' ], $this->order, 2 ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended $is_active = $this->slug === sanitize_key( $_GET['view'] ?? 'setup' ); if ( $this->on_demand && ! $is_active ) { // Load panel loader enqueues. add_action( 'admin_enqueue_scripts', [ $this, 'enqueues_loader' ] ); } // Load panel specific enqueues. add_action( 'admin_enqueue_scripts', [ $this, 'enqueues' ], 15 ); if ( $is_active || ! $this->on_demand ) { // Output. add_action( 'wpforms_builder_panels', [ $this, 'panel_output' ], $this->order, 2 ); } } /** * Get class instance. * * @since 1.7.7 * * @return static */ public static function instance() { if ( self::$instance === null || ! self::$instance instanceof static ) { self::$instance = new static(); } return self::$instance; } /** * All systems go. Used by children. * * @since 1.0.0 */ public function init() { } /** * Enqueue assets for the builder. Used by children. * * @since 1.0.0 */ public function enqueues() { } /** * Enqueue panel loader assets. * * @since 1.8.6 */ public function enqueues_loader() { $min = wpforms_get_min_suffix(); wp_enqueue_script( 'wpforms-builder-panel-loader', WPFORMS_PLUGIN_URL . "assets/js/components/admin/builder/panel-loader{$min}.js", [ 'wpforms-builder' ], WPFORMS_VERSION, true ); } /** * Primary panel button in the left panel navigation. * * @since 1.0.0 * * @param mixed $form * @param string $view */ public function button( $form, $view ) { $active = $view === $this->slug ? 'active' : ''; ?> sidebar ? 'wpforms-panel-sidebar-content' : 'wpforms-panel-full-content'; $classes = [ 'wpforms-panel' ]; if ( in_array( $this->slug, [ 'fields', 'revisions' ], true ) ) { $classes[] = 'wpforms-panel-fields'; } if ( $view === $this->slug ) { $classes[] = 'active'; } printf( '