=> 'string', ], 'fieldTextColor' => [ 'type' => 'string', ], 'labelSize' => [ 'type' => 'string', ], 'labelColor' => [ 'type' => 'string', ], 'labelSublabelColor' => [ 'type' => 'string', ], 'labelErrorColor' => [ 'type' => 'string', ], 'buttonSize' => [ 'type' => 'string', ], 'buttonBorderRadius' => [ 'type' => 'string', ], 'buttonBackgroundColor' => [ 'type' => 'string', ], 'buttonTextColor' => [ 'type' => 'string', ], 'copyPasteJsonValue' => [ 'type' => 'string', ], ]; $this->register_styles(); register_block_type( 'wpforms/form-selector', [ /** * Modify WPForms block attributes. * * @since 1.5.8.2 * * @param array $attributes Attributes. */ 'attributes' => apply_filters( 'wpforms_gutenberg_form_selector_attributes', $attributes ), // phpcs:ignore WPForms.PHP.ValidateHooks.InvalidHookName 'style' => 'wpforms-gutenberg-form-selector', 'editor_style' => 'wpforms-integrations', 'render_callback' => [ $this, 'get_form_html' ], ] ); } /** * Register WPForms Gutenberg block styles. * * @since 1.7.4.2 */ protected function register_styles() { if ( ! is_admin() ) { return; } $min = wpforms_get_min_suffix(); wp_register_style( 'wpforms-integrations', WPFORMS_PLUGIN_URL . "assets/css/admin-integrations{$min}.css", [], WPFORMS_VERSION ); if ( $this->disable_css_setting === 3 ) { return; } $css_file = $this->disable_css_setting === 2 ? 'base' : 'full'; wp_register_style( 'wpforms-gutenberg-form-selector', WPFORMS_PLUGIN_URL . "assets/css/frontend/{$this->render_engine}/wpforms-{$css_file}{$min}.css", [ 'wp-edit-blocks', 'wpforms-integrations' ], WPFORMS_VERSION ); } /** * Load WPForms Gutenberg block scripts. * * @since 1.4.8 */ public function enqueue_block_editor_assets() { $min = wpforms_get_min_suffix(); wp_enqueue_style( 'wpforms-integrations' ); $script = version_compare( $GLOBALS['wp_version'], '6.0', '>=' ) ? "formselector.es5{$min}.js" : "formselector-legacy.es5{$min}.js"; wp_enqueue_script( 'wpforms-gutenberg-form-selector', WPFORMS_PLUGIN_URL . 'assets/js/components/admin/gutenberg/' . $script, [ 'wp-blocks', 'wp-i18n', 'wp-element', 'jquery' ], WPFORMS_VERSION, true ); wp_localize_script( 'wpforms-gutenberg-form-selector', 'wpforms_gutenberg_form_selector', $this->get_localize_data() ); if ( $this->render_engine === 'modern' ) { wp_enqueue_script( 'wpforms-modern', WPFORMS_PLUGIN_URL . "assets/js/wpforms-modern{$min}.js", [ 'wpforms-gutenberg-form-selector' ], WPFORMS_VERSION, true ); } } /** * Get localize data. * * @since 1.8.1 * * @return array */ private function get_localize_data() { $strings = [ 'title' => esc_html__( 'WPForms', 'wpforms-lite' ), 'description' => esc_html__( 'Select and display one of your forms.', 'wpforms-lite' ), 'form_keywords' => [ esc_html__( 'form', 'wpforms-lite' ), esc_html__( 'contact', 'wpforms-lite' ), esc_html__( 'survey', 'wpforms-lite' ), 'the dude', ], 'form_select' => esc_html__( 'Select a Form', 'wpforms-lite' ), 'form_settings' => esc_html__( 'Form Settings', 'wpforms-lite' ), 'field_styles' => esc_html__( 'Field Styles', 'wpforms-lite' ), 'label_styles' => esc_html__( 'Label Styles', 'wpforms-lite' ), 'button_styles' => esc_html__( 'Button Styles', 'wpforms-lite' ), 'button_color_notice' => esc_html__( 'Also used for other fields like Multiple Choice, Checkboxes, Rating, and NPS Survey.', 'wpforms-lite' ), 'advanced' => esc_html__( 'Advanced', 'wpforms-lite' ), 'additional_css_classes' => esc_html__( 'Additional CSS Classes', 'wpforms-lite' ), 'form_selected' => esc_html__( 'Form', 'wpforms-lite' ), 'show_title' => esc_html__( 'Show Title', 'wpforms-lite' ), 'show_description' => esc_html__( 'Show Description', 'wpforms-lite' ), 'panel_notice_head' => esc_html__( 'Heads up!', 'wpforms-lite' ), 'panel_notice_text' => esc_html__( 'Do not forget to test your form.', 'wpforms-lite' ), 'panel_notice_link' => esc_url( wpforms_utm_link( 'https://wpforms.com/docs/how-to-properly-test-your-wordpress-forms-before-launching-checklist/', 'gutenberg' ) ), 'panel_notice_link_text' => esc_html__( 'Check out our complete guide!', 'wpforms-lite' ), 'update_wp_notice_head' => esc_html__( 'Want to customize your form styles without editing CSS?', 'wpforms-lite' ), 'update_wp_notice_text' => esc_html__( 'Update WordPress to the latest version to use our modern markup and unlock the controls below.', 'wpforms-lite' ), 'update_wp_notice_link' => esc_url( wpforms_utm_link( 'https://wpforms.com/docs/styling-your-forms/', 'Block Settings', 'Form Styles Documentation' ) ), 'learn_more' => esc_html__( 'Learn more', 'wpforms-lite' ), 'use_modern_notice_head' => esc_html__( 'Want to customize your form styles without editing CSS?', 'wpforms-lite' ), 'use_modern_notice_text' => esc_html__( 'Enable modern markup in your WPForms settings to unlock the controls below.', 'wpforms-lite' ), 'use_modern_notice_link' => esc_url( wpforms_utm_link( 'https://wpforms.com/docs/styling-your-forms/', 'Block Settings', 'Form Styles Documentation' ) ), 'lead_forms_panel_notice_head' => esc_html__( 'Form Styles are disabled because Lead Form Mode is turned on.', 'wpforms-lite' ), 'lead_forms_panel_notice_text' => esc_html__( 'To change the styling for this form, open it in the form builder and edit the options in the Lead Forms settings.', 'wpforms-lite' ), 'size' => esc_html__( 'Size', 'wpforms-lite' ), 'background' => esc_html__( 'Background', 'wpforms-lite' ), 'border' => esc_html__( 'Border', 'wpforms-lite' ), 'text' => esc_html__( 'Text', 'wpforms-lite' ), 'border_radius' => esc_html__( 'Border Radius', 'wpforms-lite' ), 'colors' => esc_html__( 'Colors', 'wpforms-lite' ), 'label' => esc_html__( 'Label', 'wpforms-lite' ), 'sublabel_hints' => esc_html__( 'Sublabel & Hint', 'wpforms-lite' ), 'error_message' => esc_html__( 'Error Message', 'wpforms-lite' ), 'small' => esc_html__( 'Small', 'wpforms-lite' ), 'medium' => esc_html__( 'Medium', 'wpforms-lite' ), 'large' => esc_html__( 'Large', 'wpforms-lite' ), 'reset_style_settings' => esc_html__( 'Reset Style Settings', 'wpforms-lite' ), 'reset_settings_confirm_text' => esc_html__( 'Are you sure you want to reset the style settings for this form? All your current styling will be removed and canʼt be recovered.', 'wpforms-lite' ), 'btn_yes_reset' => esc_html__( 'Yes, Reset', 'wpforms-lite' ), 'btn_no' => esc_html__( 'No', 'wpforms-lite' ), 'copy_paste_settings' => esc_html__( 'Copy / Paste Style Settings', 'wpforms-lite' ), 'copy_paste_error' => esc_html__( 'There was an error parsing your JSON code. Please check your code and try again.', 'wpforms-lite' ), 'copy_paste_notice' => esc_html__( 'If you\'ve copied style settings from another form, you can paste them here to add the same styling to this form. Any current style settings will be overwritten.', 'wpforms-lite' ), // Translators: %1$s: Opening strong tag, %2$s: Closing strong tag. 'wpforms_empty_info' => sprintf( esc_html__( 'You can use %1$sWPForms%2$s to build contact forms, surveys, payment forms, and more with just a few clicks.', 'wpforms-lite' ), '','' ), // Translators: %1$s: Opening anchor tag, %2$s: Closing achor tag. 'wpforms_empty_help' => sprintf( esc_html__( 'Need some help? Check out our %1$scomprehensive guide.%2$s', 'wpforms-lite' ), '','' ), ]; if ( version_compare( $GLOBALS['wp_version'], '5.1.1', '<=' ) ) { array_pop( $strings['form_keywords'] ); } $forms = wpforms()->get( 'form' )->get( '', [ 'order' => 'DESC' ] ); $forms = ! empty( $forms ) ? $forms : []; $forms = array_map( static function( $form ) { $form->post_title = htmlspecialchars_decode( $form->post_title, ENT_QUOTES ); return $form; }, $forms ); return [ 'logo_url' => WPFORMS_PLUGIN_URL . 'assets/images/sullie-alt.png', 'block_preview_url' => WPFORMS_PLUGIN_URL . 'assets/images/integrations/gutenberg/block-preview.png', 'block_empty_url' => WPFORMS_PLUGIN_URL . 'assets/images/empty-states/no-forms.svg', 'wpnonce' => wp_create_nonce( 'wpforms-gutenberg-form-selector' ), 'forms' => $forms, 'strings' => $strings, 'defaults' => self::DEFAULT_ATTRIBUTES, 'is_modern_markup' => $this->render_engine === 'modern', 'is_full_styling' => $this->disable_css_setting === 1, 'wpforms_guide' => esc_url( wpforms_utm_link( 'https://wpforms.com/docs/creating-first-form/', 'gutenberg', 'Create Your First Form Documentation' ) ), 'get_started_url' => esc_url( admin_url( 'admin.php?page=wpforms-builder' ) ), 'sizes' => [ 'field-size' => CSSVars::FIELD_SIZE, 'label-size' => CSSVars::LABEL_SIZE, 'button-size' => CSSVars::BUTTON_SIZE, ], ]; } /** * Let's WP know that we have translation strings on our block script. * * @since 1.8.3 * * @return void */ public function enable_block_translations() { wp_set_script_translations( 'wpforms-gutenberg-form-selector', 'wpforms-lite' ); } /** * Get form HTML to display in a WPForms Gutenberg block. * * @since 1.4.8 * * @param array $attr Attributes passed by WPForms Gutenberg block. * * @return string */ public function get_form_html( $attr ) { $id = ! empty( $attr['formId'] ) ? absint( $attr['formId'] ) : 0; if ( empty( $id ) ) { return ''; } $title = ! empty( $attr['displayTitle'] ); $desc = ! empty( $attr['displayDesc'] ); $is_gb_editor = $this->is_gb_editor(); if ( $is_gb_editor ) { $this->disable_fields_in_gb_editor(); } $this->add_class_callback( $id, $attr ); $content = $this->get_content( $id, $title, $desc, $attr ); // phpcs:disable WPForms.PHP.ValidateHooks.InvalidHookName /** * Filter Gutenberg block content. * * @since 1.5.8.2 * * @param string $content Block content. * @param int $id Form id. */ return apply_filters( 'wpforms_gutenberg_block_form_content', $content, $id ); // phpcs:enable WPForms.PHP.ValidateHooks.InvalidHookName } /** * Add class callback. * * @since 1.8.1 * * @param int $id Form id. * @param array $attr Form attributes. * * @return void */ private function add_class_callback( $id, $attr ) { // phpcs:ignore WPForms.PHP.HooksMethod.InvalidPlaceForAddingHooks $class_callback = static function ( $classes, $form_data ) use ( $id, $attr ) { if ( (int) $form_data['id'] !== $id ) { return $classes; } $cls = []; // Add custom class to form container. if ( ! empty( $attr['className'] ) ) { $cls = array_map( 'esc_attr', explode( ' ', $attr['className'] ) ); } // Add classes to identify that the form displays inside the block. $cls[] = 'wpforms-block'; if ( ! empty( $attr['clientId'] ) ) { $cls[] = 'wpforms-block-' . $attr['clientId']; } return array_unique( array_merge( $classes, $cls ) ); }; if ( empty( $this->callbacks[ $id ] ) ) { add_filter( 'wpforms_frontend_container_class', $class_callback, 10, 2 ); } $this->callbacks[ $id ][] = $class_callback; } /** * Get content. * * @since 1.8.1 * * @param int $id Form id. * @param bool $title Form title is not empty. * @param bool $desc Form desc is not empty. * @param array $attr Form attributes. * * @return string */ private function get_content( $id, $title, $desc, $attr ) { ob_start(); // phpcs:disable WPForms.PHP.ValidateHooks.InvalidHookName /** * Fires before Gutenberg block output. * * @since 1.5.8.2 */ do_action( 'wpforms_gutenberg_block_before' ); /** * Filter block title display flag. * * @since 1.5.8.2 * * @param bool $title Title display flag. * @param int $id Form id. */ $title = apply_filters( 'wpforms_gutenberg_block_form_title', $title, $id ); /** * Filter block description display flag. * * @since 1.5.8.2 * * @param bool $desc Description display flag. * @param int $id Form id. */ $desc = apply_filters( 'wpforms_gutenberg_block_form_desc', $desc, $id ); $this->output_css_vars( $attr ); $is_gb_editor = $this->is_gb_editor(); wpforms_display( $id, $title, $desc ); /** * Fires after Gutenberg block output. * * @since 1.5.8.2 */ do_action( 'wpforms_gutenberg_block_after' ); // phpcs:enable WPForms.PHP.ValidateHooks.InvalidHookName $content = ob_get_clean(); if ( ! $is_gb_editor ) { return $content; } if ( empty( $content ) ) { return '
' . '
' . esc_html__( 'The form cannot be displayed.', 'wpforms-lite' ) . '
'; } // phpcs:disable WordPress.PHP.DevelopmentFunctions.error_log_var_export // Unfortunately, the inline Mistakes You Should Avoid as an Entrepreneur Archives - KenyaInvest

Mistakes You Should Avoid as an Entrepreneur.

Becoming an entrepreneur is a dream many people have. This is because it offers freedom and a chance for increasing earnings. However, not everyone succeeds in entrepreneurship due to various…

Read More