Block_Rules::user_may_edit( $uid ), 'blockTypes' => Settings::get( 'block_types' ), 'canUnfilteredHtml' => current_user_can( 'unfiltered_html' ), 'timezone' => wp_timezone_string(), 'clear' => Widget_Copyover::CLEAR, 'widgetRuleNonce' => current_user_can( 'edit_theme_options' ) ? wp_create_nonce( 'gtfg_widget_rule' ) : '', 'importUrl' => current_user_can( 'edit_theme_options' ) ? admin_url( 'tools.php?page=gateforge-import' ) : '', 'snippetUrl' => current_user_can( 'edit_theme_options' ) ? admin_url( 'tools.php?page=gateforge-import#gtfg-snippet' ) : '', 'widgetRules' => array(), ); $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null; if ( current_user_can( 'edit_theme_options' ) && ( ( $screen && 'widgets' === $screen->id ) || is_customize_preview() || did_action( 'customize_controls_init' ) ) ) { foreach ( Widget_Store::all_rules() as $wid => $raw ) { $rule = Rule::from_stored( $raw, 'widget' ); $entry = array( 'imported' => Rule::STATE_OK === $rule->state && is_array( $rule->import ), 'summary' => Rule::STATE_OK === $rule->state ? Summarizer::summarize( $rule->tree ) : __( 'This rule cannot be read, so the widget is hidden.', 'gateforge' ), ); if ( 0 !== strpos( (string) $wid, 'block-' ) ) { $entry['rule'] = $raw; } $data['widgetRules'][ $wid ] = $entry; } } return $data; } /** * Block editors (post, Site Editor, block widgets). */ public static function block_editor() { self::builder(); wp_enqueue_script( 'gateforge-block-editor', self::url( 'js/block-editor.js' ), array( 'gateforge-builder', 'wp-compose', 'wp-block-editor', 'wp-hooks', 'wp-data', 'wp-element', 'wp-components', 'wp-i18n' ), GATEFORGE_VERSION, true ); wp_set_script_translations( 'gateforge-block-editor', 'gateforge' ); wp_enqueue_style( 'gateforge-admin' ); } /** * Canvas outline style: editor only. */ public static function canvas() { if ( ! is_admin() ) { return; } wp_enqueue_style( 'gateforge-canvas', self::url( 'css/editor-canvas.css' ), array(), GATEFORGE_VERSION ); } /** * Widgets screen. * * @param string $hook Screen hook. */ public static function widgets_screen( $hook ) { if ( 'widgets.php' === $hook ) { self::widget_form(); } } /** * Classic widget form script. */ public static function widget_form() { if ( ! current_user_can( 'edit_theme_options' ) ) { return; } self::builder(); wp_enqueue_script( 'gateforge-widget-form', self::url( 'js/widget-form.js' ), array( 'gateforge-builder', 'jquery' ), GATEFORGE_VERSION, true ); wp_set_script_translations( 'gateforge-widget-form', 'gateforge' ); wp_enqueue_style( 'gateforge-admin' ); } }