| Server IP : 38.190.208.107 / Your IP : 216.73.217.46 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : root ( 0) PHP Version : 8.2.28 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/wp.6/wp-content/plugins/fluentform/app/Services/Blocks/ |
Upload File : |
<?php
namespace FluentForm\App\Services\Blocks;
use FluentForm\App\Helpers\Helper;
use FluentForm\Framework\Support\Arr;
/**
* GutenbergBlock class for handling Fluent Forms Gutenberg block functionality
* @since 1.0.0
*/
class GutenbergBlock
{
/**
* Register the Gutenberg block
* @return void
*/
public static function register()
{
if (!function_exists('register_block_type')) {
return;
}
register_block_type('fluentfom/guten-block', [
'render_callback' => [self::class, 'render'],
'attributes' => BlockAttributes::getAttributes(),
'api_version' => 3,
]);
}
/**
* Render the Gutenberg block
*
* @param array $atts Block attributes
* @return string Rendered block HTML
*/
public static function render($atts)
{
$formId = (int)Arr::get($atts, 'formId', 0);
if (!$formId) {
return '<div class="fluentform-no-form-selected"><p>' . __('Please select a form', 'fluentform') . '</p></div>';
}
$className = sanitize_text_field(Arr::get($atts, 'className', ''));
$themeStyle = sanitize_text_field(Arr::get($atts, 'themeStyle', ''));
$type = Helper::isConversionForm($formId) ? 'conversational' : '';
// Custom CSS for block styling
$inlineStyle = '';
$customCss = Arr::get($atts, 'customCss', '');
$customCss = json_decode($customCss, true);
$customCss = is_string($customCss) ? $customCss : '';
if ($customCss && $customCss = fluentformSanitizeCSS($customCss)) {
$styleId = 'fluentform-block-custom-styles-' . $formId;
$inlineStyle = '<style id="' . esc_attr($styleId) . '">' . $customCss . '</style>';
if (wp_style_is('fluent-form-styles', 'enqueued') || wp_style_is('fluent-form-styles', 'registered')) {
wp_add_inline_style('fluent-form-styles', $customCss);
}
if (wp_style_is('fluentform-public-default', 'enqueued') || wp_style_is('fluentform-public-default', 'registered')) {
wp_add_inline_style('fluentform-public-default', $customCss);
}
}
// Return the form with inline styles
$formOutput = do_shortcode('[fluentform theme="' . $themeStyle . '" css_classes="' . $className . ' ff_guten_block ff_guten_block-' . $formId . '" id="' . $formId . '" type="' . $type . '"]');
if ($formOutput) {
$allStyles = '';
if ($inlineStyle) {
$allStyles .= $inlineStyle;
}
// if (!empty($individualStyleTag)) {
// $allStyles .= $individualStyleTag;
// }
if ($allStyles) {
return $allStyles . $formOutput;
}
return $formOutput;
}
return '';
}
}