Changeset 3492699
- Timestamp:
- 03/27/2026 01:30:37 PM (21 hours ago)
- Location:
- better-block-editor
- Files:
-
- 10 added
- 2 deleted
- 49 edited
- 2 copied
-
tags/1.4.0 (copied) (copied from better-block-editor/trunk)
-
tags/1.4.0/Base/ModuleBase.php (modified) (2 diffs)
-
tags/1.4.0/Core/BundledAssetsManager.php (modified) (13 diffs)
-
tags/1.4.0/Core/ModulesManager.php (modified) (1 diff)
-
tags/1.4.0/Core/Settings.php (modified) (12 diffs)
-
tags/1.4.0/Modules/ButtonsResponsive/Module.php (modified) (1 diff)
-
tags/1.4.0/Modules/ColumnsResponsive/Module.php (modified) (1 diff)
-
tags/1.4.0/Modules/ContactForm7Block/Module.php (modified) (3 diffs)
-
tags/1.4.0/Modules/DemoContent/Module.php (modified) (3 diffs)
-
tags/1.4.0/Modules/DesignSystemParts/Module.php (modified) (5 diffs)
-
tags/1.4.0/Modules/GridResponsive/Module.php (modified) (1 diff)
-
tags/1.4.0/Modules/GroupResponsive/Module.php (modified) (1 diff)
-
tags/1.4.0/Modules/NavigationResponsive/Module.php (modified) (1 diff)
-
tags/1.4.0/Modules/PostTemplateResponsive/Module.php (modified) (1 diff)
-
tags/1.4.0/Modules/RowResponsive/Module.php (modified) (1 diff)
-
tags/1.4.0/Modules/TextResponsive/Module.php (modified) (2 diffs)
-
tags/1.4.0/Modules/TextStyleFromElement/Module.php (modified) (8 diffs)
-
tags/1.4.0/Modules/UploadSVG/Module.php (modified) (2 diffs)
-
tags/1.4.0/Modules/Visibility/Module.php (modified) (6 diffs)
-
tags/1.4.0/admin/css/settings (added)
-
tags/1.4.0/admin/css/settings/settings.css (added)
-
tags/1.4.0/admin/js/settings/breakpoints.js (deleted)
-
tags/1.4.0/admin/js/settings/settings.js (added)
-
tags/1.4.0/admin/templates/settings/_multicheckbox.php (modified) (2 diffs)
-
tags/1.4.0/admin/templates/settings/_pro_separator.php (added)
-
tags/1.4.0/admin/templates/settings/_setting_wrapper.php (added)
-
tags/1.4.0/admin/templates/settings/breakpoints.php (modified) (1 diff)
-
tags/1.4.0/admin/templates/settings/page.php (modified) (1 diff)
-
tags/1.4.0/better-block-editor.php (modified) (2 diffs)
-
tags/1.4.0/plugin.php (modified) (3 diffs)
-
tags/1.4.0/readme.txt (copied) (copied from better-block-editor/trunk/readme.txt) (3 diffs)
-
tags/1.4.0/vendor/composer/installed.php (modified) (2 diffs)
-
trunk/Base/ModuleBase.php (modified) (2 diffs)
-
trunk/Core/BundledAssetsManager.php (modified) (13 diffs)
-
trunk/Core/ModulesManager.php (modified) (1 diff)
-
trunk/Core/Settings.php (modified) (12 diffs)
-
trunk/Modules/ButtonsResponsive/Module.php (modified) (1 diff)
-
trunk/Modules/ColumnsResponsive/Module.php (modified) (1 diff)
-
trunk/Modules/ContactForm7Block/Module.php (modified) (3 diffs)
-
trunk/Modules/DemoContent/Module.php (modified) (3 diffs)
-
trunk/Modules/DesignSystemParts/Module.php (modified) (5 diffs)
-
trunk/Modules/GridResponsive/Module.php (modified) (1 diff)
-
trunk/Modules/GroupResponsive/Module.php (modified) (1 diff)
-
trunk/Modules/NavigationResponsive/Module.php (modified) (1 diff)
-
trunk/Modules/PostTemplateResponsive/Module.php (modified) (1 diff)
-
trunk/Modules/RowResponsive/Module.php (modified) (1 diff)
-
trunk/Modules/TextResponsive/Module.php (modified) (2 diffs)
-
trunk/Modules/TextStyleFromElement/Module.php (modified) (8 diffs)
-
trunk/Modules/UploadSVG/Module.php (modified) (2 diffs)
-
trunk/Modules/Visibility/Module.php (modified) (6 diffs)
-
trunk/admin/css/settings (added)
-
trunk/admin/css/settings/settings.css (added)
-
trunk/admin/js/settings/breakpoints.js (deleted)
-
trunk/admin/js/settings/settings.js (added)
-
trunk/admin/templates/settings/_multicheckbox.php (modified) (2 diffs)
-
trunk/admin/templates/settings/_pro_separator.php (added)
-
trunk/admin/templates/settings/_setting_wrapper.php (added)
-
trunk/admin/templates/settings/breakpoints.php (modified) (1 diff)
-
trunk/admin/templates/settings/page.php (modified) (1 diff)
-
trunk/better-block-editor.php (modified) (2 diffs)
-
trunk/plugin.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/vendor/composer/installed.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
better-block-editor/tags/1.4.0/Base/ModuleBase.php
r3449829 r3492699 113 113 public static function get_settings_order() { 114 114 return static::SETTINGS_ORDER; 115 } 116 117 /** 118 * {inheritdocs} 119 */ 120 public static function get_tab() { 121 return Settings::TAB_FEATURES; 115 122 } 116 123 … … 291 298 protected function get_option( string $key = null, $default = null ) { 292 299 $option_name = Settings::build_module_settings_name( $this->get_identifier() ); 293 294 $options = get_option( $option_name, array() ); 295 296 if ( null === $key ) { 297 return $options; 298 } 299 300 return $options[ $key ] ?? $default; 300 return Settings::get_setting($option_name, $key, $default ); 301 301 } 302 302 -
better-block-editor/tags/1.4.0/Core/BundledAssetsManager.php
r3386474 r3492699 33 33 private $plugin_dist; 34 34 35 public function __construct( string $plugin_id, string $plugin_dist, string $plugin_dist_url ) { 35 /** 36 * @var array Dependencies for each bundle (optional, can be empty). 37 * Format: array( 'bundle_key' => array( 'dependency_handle1', 'dependency_handle2' ) ) 38 */ 39 private $dependencies; 40 41 public function __construct( string $plugin_id, string $plugin_dist, string $plugin_dist_url, array $dependencies = array() ) { 36 42 $this->plugin_id = $plugin_id; 37 43 $this->plugin_dist = $plugin_dist; 38 44 $this->plugin_dist_url = $plugin_dist_url; 45 $this->dependencies = $dependencies; 39 46 } 40 47 … … 44 51 * @return void 45 52 */ 46 public function process_editor_assets() {47 $this->register_assets( 'editor');48 $this->enqueue_assets( 'enqueue_block_editor_assets', 'editor');53 public function process_editor_assets(): void { 54 $this->register_assets( self::EDITOR_BUNDLE ); 55 $this->enqueue_assets( self::EDITOR_BUNDLE ); 49 56 } 50 57 … … 54 61 * @return void 55 62 */ 56 public function process_editor_content_assets() {57 $this->register_assets( 'editor-content');58 $this->enqueue_assets( 'enqueue_block_assets', 'editor-content');63 public function process_editor_content_assets(): void { 64 $this->register_assets( self::EDITOR_CONTENT_BUNDLE ); 65 $this->enqueue_assets( self::EDITOR_CONTENT_BUNDLE ); 59 66 } 60 67 … … 64 71 * @return void 65 72 */ 66 public function process_view_assets() {67 $this->register_assets( 'view');68 $this->enqueue_assets( 'wp_enqueue_scripts', 'view');73 public function process_view_assets(): void { 74 $this->register_assets( self::VIEW_BUNDLE ); 75 $this->enqueue_assets( self::VIEW_BUNDLE ); 69 76 } 70 77 71 78 /** 72 79 * Add inline JS code just before bundle code (see wp_add_inline_script()) 80 * Before mode does not affect "defer" script attribute 73 81 * 74 82 * @param string $bundle_name Bundle name(key) to add code to (see self::*_BUNDLE) … … 77 85 * @return bool 78 86 */ 79 public function add_inline_js_before_bundle( $bundle_name, $js ) {87 public function add_inline_js_before_bundle( $bundle_name, $js ): bool { 80 88 return wp_add_inline_script( 81 89 $this->build_script_handle( $bundle_name ), … … 86 94 87 95 /** 88 * Add inline JS code just after bundle code (see wp_add_inline_script()) 89 * 90 * @param string $bundle_name Bundle name(key) to add code to (see self::*_BUNDLE) 96 * Add inline JS code to footer 97 * We use fake handler to non existing script to add inline code to footer 98 * Bundle name is required to add code with appropriate hook (editor, editor-content, view) 99 * 100 * @param string $bundle_name Bundle name (see self::*_BUNDLE) to add code with appropriate hook 91 101 * @param string $js JS code to be added as inline script 92 102 * 93 103 * @return bool 94 104 */ 95 public function add_inline_js_after_bundle( $bundle_name, $js ) { 96 return wp_add_inline_script( 97 $this->build_script_handle( $bundle_name ), 98 $js, 99 'after' 100 ); 105 public function add_inline_js_to_footer($bundle_name, $js ): bool { 106 107 $handle = $this->build_script_handle( 'footer-inline' ) . '__handler'; 108 109 // register only once 110 if ( ! wp_script_is( $handle, 'registered' ) ) { 111 wp_register_script( 112 $handle, 113 false, // no source file 114 array(), 115 false, 116 array( 'in_footer' => true ) // it won't be deferred because we add inline script to it 117 ); 118 119 $action = $this->get_action_for_bundle( $bundle_name ); 120 121 if ( null === $action ) { 122 return false; 123 } 124 125 add_action( 126 $action, 127 function () use ( $handle ) { 128 wp_enqueue_script( $handle ); 129 } 130 ); 131 } 132 133 return wp_add_inline_script( $handle, $js, 'before' ); 134 } 135 136 /** 137 * Build a handle name for a given plugin ID, bundle key and type (script or style). 138 * 139 * @param string $plugin_id Plugin ID. 140 * @param string $bundle_key Bundle key (one of 'editor', 'editor-content', 'view'). 141 * @param string $type Type of handle ('script' or 'style'). 142 * 143 * @return string Handle name. 144 */ 145 public static function build_handle( $plugin_id, $bundle_key, $type ): string { 146 return $plugin_id . '__bundle__' . $bundle_key . '-' . $type; 147 } 148 149 /** 150 * Get the appropriate action hook for enqueuing assets based on the bundle name. 151 * 152 * @param string $bundle_name Bundle name(key) to get action for (see self::*_BUNDLE) 153 * 154 * @return string|null Action hook name or null if bundle name is invalid. 155 */ 156 private function get_action_for_bundle( $bundle_name ): ?string { 157 $map = array( 158 self::EDITOR_BUNDLE => 'enqueue_block_editor_assets', 159 self::EDITOR_CONTENT_BUNDLE => 'enqueue_block_assets', 160 self::VIEW_BUNDLE => 'wp_enqueue_scripts', 161 ); 162 163 return array_key_exists( $bundle_name, $map ) ? $map[ $bundle_name ] : null; 101 164 } 102 165 … … 105 168 * 106 169 * @param string $key Bundle key (one of 'editor', 'editor-content', 'view'). 107 * @param array $script_register_options Optional script registration options. 108 * 109 * @return void 110 */ 111 private function register_assets( $key, $script_register_options = array() ) { 170 * 171 * @return void 172 */ 173 private function register_assets( $key ): void { 112 174 if ( ! file_exists( $this->get_asset_filename( $key ) ) ) { 113 175 return; … … 116 178 $asset_file = require $this->get_asset_filename( $key ); 117 179 118 // script119 $default_options = array(120 'strategy' => 'defer',121 'in_footer' => false,122 );123 180 // it's safe to return here as css is added only using js import construction 124 181 if ( ! file_exists( $this->plugin_dist . self::BUNDLE_DIR . $key . '.js' ) ) { … … 126 183 } 127 184 128 $res = wp_register_script( 185 // merge "native" dependencies from asset file with any additional dependencies provided added manually 186 $script_dependencies = array_merge( $asset_file['dependencies'], (array)($this->dependencies[ $key ] ?? array()) ); 187 188 189 wp_register_script( 129 190 $this->build_script_handle( $key ), 130 191 $this->plugin_dist_url . self::BUNDLE_DIR . $key . '.js', 131 $ asset_file['dependencies'],192 $script_dependencies, 132 193 $asset_file['version'], 133 array_merge( $default_options, $script_register_options ) 194 // it's important to use defer for all scripts in the bundle 195 // otherwise the order of execution will be broken and it may cause errors 196 // we add to header as it's common practice 197 array( 198 'strategy' => 'defer', 199 'in_footer' => false, 200 ) 134 201 ); 135 202 … … 148 215 149 216 /** 150 * Enqueue registered script and style assets for a given action and bundle key. 151 * 152 * @param string $action WordPress action hook. 153 * @param string $key Bundle key (one of 'editor', 'editor-content', 'view'). 154 * 155 * @return void 156 */ 157 private function enqueue_assets( $action, $key ) { 217 * Enqueue registered script and style assets for a given supported bundle key. 218 * 219 * @param string $key Bundle key (one of 'editor', 'editor-content', 'view'). 220 * 221 * @return void 222 */ 223 private function enqueue_assets( $key ): void { 158 224 $script_handle = $this->build_script_handle( $key ); 159 225 $style_handle = $this->build_style_handle( $key ); 226 227 $action = $this->get_action_for_bundle( $key ); 228 229 // if action is null it means that bundle key is invalid and we should not enqueue assets 230 if ( null === $action ) { 231 return; 232 } 160 233 161 234 add_action( … … 175 248 * @return string Path to the asset metadata file. 176 249 */ 177 private function get_asset_filename( $key ) {250 private function get_asset_filename( $key ): string { 178 251 return $this->plugin_dist . self::BUNDLE_DIR . $key . '.asset.php'; 179 252 } … … 186 259 * @return string Script handle name. 187 260 */ 188 p rivate function build_script_handle( $key ){189 return $this->plugin_id . '__' . 'bundle' . '__' . $key . '-script';261 public function build_script_handle( $key ): string { 262 return self::build_handle( $this->plugin_id, $key, 'script' ); 190 263 } 191 264 … … 197 270 * @return string Style handle name. 198 271 */ 199 private function build_style_handle( $key ) {200 return $this->plugin_id . '__' . 'bundle' . '__' . $key . '-style';272 private function build_style_handle( $key ): string { 273 return self::build_handle( $this->plugin_id, $key, 'style' ); 201 274 } 202 275 } -
better-block-editor/tags/1.4.0/Core/ModulesManager.php
r3449829 r3492699 131 131 'label' => $classname::get_label(), 132 132 'description' => $classname::get_description(), 133 'tab' => $classname::get_tab(), 133 134 'settings_order' => $classname::get_settings_order(), 134 135 'enabled' => self::is_module_enabled( $classname ), 135 'is_freemium' => is_a( $classname, 'BetterBlockEditor\Base\ModuleInterface', true ),136 'is_freemium' => !is_a( $classname, 'BbeProKit\Base\ModuleBasePro', true ), 136 137 'classname' => $classname, 137 138 'active' => isset( $this->modules[ $classname::get_identifier() ] ), -
better-block-editor/tags/1.4.0/Core/Settings.php
r3473824 r3492699 16 16 class Settings { 17 17 18 protected static $allowed_breakpoint_units = array( 'px', 'em', 'rem', 'vw', 'vh' ); 18 public const TAB_FEATURES = 'features'; 19 public const TAB_BLOCKS = 'blocks'; 20 public const TAB_DESIGN = 'design'; 21 public const TAB_BREAKPOINTS = 'breakpoints'; 22 23 protected static $allowed_breakpoint_units = array( 'px', 'rem' ); 19 24 20 25 // WP permission to open the Settings Page … … 26 31 const TEMPLATES_FOLDER_NAME = WPBBE_DIR . 'admin/templates/settings/'; 27 32 33 protected static $pro_separator_added = false; 28 34 29 35 /** … … 67 73 68 74 foreach ( $modules_data as $module_data ) { 69 self::add_module_enable_checkbox( 70 $module_data['identifier'], 71 $module_data['title'], 75 self::add_module_enable_checkbox( $module_data ); 76 // add module settings 77 $classname = $module_data['classname'] ?? null; 78 if ( $classname && is_a( $classname, ConfigurableModuleInterface::class, true ) ) { 79 foreach ( $classname::get_settings() as $key => $field ) { 80 self::add_module_settigns( $module_data, $key, $field ); 81 } 82 } 83 } 84 85 self::add_user_defined_breakpoint_options(); 86 87 add_action( 'admin_enqueue_scripts', array( self::class, 'enqueue_admin_assets' ) ); 88 } 89 90 /** 91 * Enqueue admin assets for settings page. 92 * * @param string $hook_suffix The current admin page hook suffix. 93 */ 94 public static function enqueue_admin_assets( $hook_suffix ) { 95 // if not on the settings page, do not enqueue the script 96 if ( 'settings_page_' . self::MENU_PAGE_SLUG !== $hook_suffix ) { 97 return; 98 } 99 // add js to the page 100 $handle = WPBBE_PLUGIN_ID . '__core-settings-script'; 101 wp_register_script( 102 $handle, 103 WPBBE_URL . 'admin/js/settings/settings.js', 104 array(), // no dependencies for this script 105 WPBBE_VERSION, // use plugin version as script version 106 array( 107 'in_footer' => true, // load script in footer as we need to access the DOM elements 108 ) 109 ); 110 111 $translations = array( 112 'remove_breakpoint_confirm_message' => esc_js( __( 'Do you want to remove this breakpoint?', 'better-block-editor' ) ), 113 'remove_breakpoint_button_title' => esc_js( __( 'Remove breakpoint', 'better-block-editor' ) ), 114 ); 115 116 $inline_script = 'const WPBBE_RESPONSIVE_BREAKPOINT_SETTINGS = ' . wp_json_encode( 72 117 array( 73 ' label' => $module_data['label'],74 ' description' => $module_data['description'],75 ' enabled' => $module_data['enabled'],118 'ALLOWED_SIZE_UNITS' => self::$allowed_breakpoint_units, 119 'WP_OPTION_NAME' => self::build_user_defined_breakpoints_option_name(), 120 'I18N_TRANSLATIONS' => $translations, 76 121 ) 77 ); 122 ) . ';'; 123 124 // initialize the Map to store breakpoints 125 $inline_script .= 'WPBBE_RESPONSIVE_BREAKPOINT_SETTINGS.BREAKPOINT_LIST = new Map();' . "\n"; 126 // we use Map to keep breakpoints order (otherwise it will be sorted by keys) 127 foreach ( self::get_active_user_defined_breakpoints() as $key => $breakpoint ) { 128 $inline_script .= sprintf( 129 'WPBBE_RESPONSIVE_BREAKPOINT_SETTINGS.BREAKPOINT_LIST.set(\'%s\', %s);', 130 esc_js( (string) $key ), 131 wp_json_encode( $breakpoint ) 132 ) . "\n"; 133 } 134 135 wp_add_inline_script( $handle, $inline_script, 'before' ); 136 137 wp_enqueue_script( $handle ); 138 wp_enqueue_style( 139 WPBBE_PLUGIN_ID . '__core-settings-style', 140 WPBBE_URL . 'admin/css/settings/settings.css', 141 array(), 142 WPBBE_VERSION 143 ); 144 } 145 146 public static function rest_settings_init() { 147 $modules_data = Plugin::instance()->modules_manager->get_managable_modules_data(); 148 foreach ( $modules_data as $module_data ) { 149 self::add_module_enable_checkbox( $module_data,true ); 78 150 // add module settings 79 151 if ( $module_data['enabled'] ) { … … 81 153 if ( $classname && is_a( $classname, ConfigurableModuleInterface::class, true ) ) { 82 154 foreach ( $classname::get_settings() as $key => $field ) { 83 self::add_module_settigns( $module_data['identifier'], $key, $field ); 84 } 85 } 86 } 87 } 88 89 self::add_user_defined_breakpoint_options(); 90 } 91 92 public static function rest_settings_init() { 93 $modules_data = Plugin::instance()->modules_manager->get_managable_modules_data(); 94 foreach ( $modules_data as $module_data ) { 95 self::add_module_enable_checkbox( 96 $module_data['identifier'], 97 $module_data['title'], 98 array( 99 'label' => $module_data['label'], 100 'description' => $module_data['description'], 101 'enabled' => $module_data['enabled'], 102 ), 103 true 104 ); 105 // add module settings 106 if ( $module_data['enabled'] ) { 107 $classname = $module_data['classname'] ?? null; 108 if ( $classname && is_a( $classname, ConfigurableModuleInterface::class, true ) ) { 109 foreach ( $classname::get_settings() as $key => $field ) { 110 self::add_module_settigns( $module_data['identifier'], $key, $field, true ); 155 self::add_module_settigns( $module_data, $key, $field, true ); 111 156 } 112 157 } … … 179 224 __( 'Breakpoints', 'better-block-editor' ), 180 225 function () { 181 self::parse_template( 'breakpoints', array() ); 226 self::parse_template('_setting_wrapper', [ 227 'tab' => self::TAB_BREAKPOINTS, 228 'template' => 'breakpoints', 229 ]); 182 230 }, 183 231 self::MENU_PAGE_SLUG, 184 232 WPBBE_PLUGIN_ID . '_settings_section' 185 );186 187 // add js to the page188 $relative_filename = 'admin/js/settings/breakpoints.js';189 $handle = WPBBE_PLUGIN_ID . '__core-settings__breakpoints-script';190 wp_register_script(191 $handle,192 WPBBE_URL . $relative_filename,193 array(), // no dependencies for this script194 WPBBE_VERSION, // use plugin version as script version195 array(196 'in_footer' => true, // load script in footer as we need to access the DOM elements197 )198 );199 200 $translations = array(201 'remove_breakpoint_confirm_message' => esc_js( __( 'Do you want to remove this breakpoint?', 'better-block-editor' ) ),202 'remove_breakpoint_button_title' => esc_js( __( 'Remove breakpoint', 'better-block-editor' ) ),203 );204 205 $inline_script = 'const WPBBE_RESPONSIVE_BREAKPOINT_SETTINGS = ' . wp_json_encode(206 array(207 'ALLOWED_SIZE_UNITS' => self::$allowed_breakpoint_units,208 'WP_OPTION_NAME' => self::build_user_defined_breakpoints_option_name(),209 'I18N_TRANSLATIONS' => $translations,210 )211 ) . ';';212 213 // initialize the Map to store breakpoints214 $inline_script .= 'WPBBE_RESPONSIVE_BREAKPOINT_SETTINGS.BREAKPOINT_LIST = new Map();' . "\n";215 // we use Map to keep breakpoints order (otherwise it will be sorted by keys)216 foreach ( self::get_active_user_defined_breakpoints() as $key => $breakpoint ) {217 $inline_script .= sprintf(218 'WPBBE_RESPONSIVE_BREAKPOINT_SETTINGS.BREAKPOINT_LIST.set(\'%s\', %s);',219 esc_js( (string) $key ),220 wp_json_encode( $breakpoint )221 ) . "\n";222 }223 224 wp_add_inline_script( $handle, $inline_script, 'before' );225 226 add_action(227 'admin_enqueue_scripts',228 function ( $hook_suffix ) use ( $handle ) {229 // if not on the settings page, do not enqueue the script230 if ( 'settings_page_' . self::MENU_PAGE_SLUG !== $hook_suffix ) {231 return;232 }233 wp_enqueue_script( $handle );234 }235 233 ); 236 234 } … … 279 277 } 280 278 281 private static function add_module_enable_checkbox( $module_identifier, $title, $args = array(), $rest = false ) { 279 private static function add_module_enable_checkbox($args = array(), $rest = false ) { 280 $args = array_merge( 281 array( 282 'identifier' => '', 283 'title' => '', 284 'label' => null, 285 'description' => null, 286 'enabled' => false, 287 'tab' => '', 288 ), 289 $args 290 ); 291 292 $module_identifier = $args['identifier']; 293 $title = $args['title']; 282 294 $name = self::build_module_enabled_option_name( $module_identifier ); 283 295 register_setting( … … 300 312 return; 301 313 } 302 $args = array( 303 'identifier' => $name, 304 'title' => $title, 305 'label' => $args['label'] ?? null, 306 'description' => $args['description'] ?? null, 307 'value' => $args['enabled'], 308 ); 309 314 // dirty trick: add the separator before premium features as setting field so we don't need to create 315 // separate section for premium features and can keep them separated in the UI with the separator element 316 if (!self::$pro_separator_added && !$args['is_freemium']) { 317 add_settings_field( 318 'wpbbe_pro_separator', 319 self::parse_template('_pro_separator', [], true), 320 function () { }, 321 self::MENU_PAGE_SLUG, 322 WPBBE_PLUGIN_ID . '_settings_section', 323 array( 'class' => 'wpbbe-separator-row wpbbe-plus-separator' ) 324 ); 325 self::$pro_separator_added = true; 326 } 327 $args['module_identifier'] = $module_identifier; 328 $args['identifier'] = $name; 329 $args['value'] = $args['enabled']; 330 $args['class'] = $args['is_freemium'] ? '' : 'wpbbe-plus-feature'; 310 331 add_settings_field( 311 332 $name, 312 333 $title, 313 334 function ( $args ) { 314 self::parse_template( '_checkbox', $args ); 335 self::parse_template('_setting_wrapper', [ 336 'tab' => $args['tab'], 337 'class' => 'wpbbe-module-enable', 338 'module' => $args['module_identifier'], 339 'template' => '_checkbox', 340 'template_args' => $args, 341 ]); 315 342 }, 316 343 self::MENU_PAGE_SLUG, … … 330 357 * @return void 331 358 */ 332 p rivate static function parse_template( $template_name, $args) {359 public static function parse_template( $template_name, $args, $return = false ) { 333 360 $template_full_name = self::TEMPLATES_FOLDER_NAME . $template_name . '.php'; 334 361 335 362 if ( ! is_file( $template_full_name ) || ! is_readable( $template_full_name ) ) { 336 363 throw new Exception( 'Can not read template: ' . esc_html( $template_full_name ) ); 364 } 365 366 if ( $return ) { 367 ob_start(); 368 include $template_full_name; 369 370 return ob_get_clean(); 337 371 } 338 372 … … 410 444 * @return void 411 445 */ 412 private static function add_module_settigns( $module_identifier, $option_key, $field, $rest = false ) { 446 private static function add_module_settigns( $module_data, $option_key, $field, $rest = false ) { 447 $module_identifier = $module_data['identifier']; 413 448 $option_name = self::build_module_settings_name( $module_identifier ); // store all sub options as array 414 449 … … 426 461 switch ( $field['type'] ?? 'text' ) { 427 462 case 'multicheckbox': 428 $ available= $field['options'] ?? array();463 $field_options = $field['options'] ?? array(); 429 464 $output[ $option_key ] = $output[ $option_key ] ?? array(); 430 foreach ( $available as $key => $_ ) { 431 if ( ! empty( $input[ $option_key ][ $key ] ) ) { 432 $output[ $option_key ][ $key ] = 1; 465 466 foreach ( $field_options as $key => $_ ) { 467 $is_disabled = ! empty( $field_options[ $key ]['disabled'] ); 468 //for disabled options we want keep the checkbox disabled and ignore changes from user (use default value) 469 if ( $is_disabled ) { 470 // remove disabled options from the saved settings 471 unset( $output[ $option_key ][ $key ] ); 433 472 } else { 434 unset( $output[ $option_key ][ $key ] ); 435 } 436 } 473 $output[ $option_key ][ $key ] = isset( $input[ $option_key ][ $key ] ) ? 1 : 0; 474 }} 437 475 break; 438 476 case 'checkbox': … … 457 495 return; 458 496 } 497 $title = $field['title'] ?? ''; 459 498 add_settings_field( 460 499 $option_name . '__' . $option_key, 461 $field['label'], 462 function () use ( $module_identifier, $option_key, $field, $option_name ) { 463 $stored_value = get_option( $option_name, array() ); 464 $value = $stored_value[ $option_key ] ?? $field['default']; 465 466 $template_name = '_' . $field['type']; 467 self::parse_template( 468 $template_name, 469 array_merge( 500 $title, 501 function () use ( $module_data, $option_key, $field, $option_name ) { 502 $merged_value = self::get_setting( 503 $option_name, 504 $option_key, 505 $field['default'] ?? null 506 ); 507 508 self::parse_template('_setting_wrapper', [ 509 'tab' => $module_data['tab'], 510 'class' => 'wpbbe-module-setting', 511 'module' => $module_data['identifier'], 512 'template' => '_' . $field['type'], 513 'template_args' => array_merge( 470 514 $field, 471 515 array( 472 516 'identifier' => $option_name . '[' . $option_key . ']', 473 'value' => $ value,517 'value' => $merged_value, 474 518 ) 475 ) 476 );519 ), 520 ]); 477 521 }, 478 522 self::MENU_PAGE_SLUG, … … 480 524 ); 481 525 } 526 527 528 /** 529 * Retrieves a specific setting value for a module, with support for default values and array merging. 530 * 531 * @param string $option_name The name of the option in the database (usually built with build_module_settings_name). 532 * @param string $option_key The specific key of the setting within the module's settings array. 533 * @param mixed $default The default value to return if the setting is not found. Can be an array for settings that are arrays. 534 * 535 * @return mixed The setting value, merged with defaults if it's an array, or the default value if not set. 536 */ 537 public static function get_setting( $option_name, $key, $default = null ) { 538 $stored = get_option( $option_name, null ); 539 540 // If there is no stored value for the module settings, return the default value 541 if ( $stored === null ) { 542 return $default; 543 } 544 545 if ( null === $key ) { 546 return $stored; 547 } 548 549 $value = $stored[ $key ] ?? null; 550 551 // array merge (add new defaults, keep user values) 552 if ( is_array( $default ) && is_array( $value ) ) { 553 return array_replace( $default, $value ); 554 } 555 556 // if value exists use it 557 if ( $value !== null ) { 558 return $value; 559 } 560 // if value does not exist return default 561 return $default; 562 } 482 563 } -
better-block-editor/tags/1.4.0/Modules/ButtonsResponsive/Module.php
r3386474 r3492699 28 28 29 29 public static function get_label() { 30 return __( 'Add Responsive settings to Buttons block.', 'better-block-editor' );30 return __( 'Add Responsive Settings to Buttons block.', 'better-block-editor' ); 31 31 } 32 32 -
better-block-editor/tags/1.4.0/Modules/ColumnsResponsive/Module.php
r3386474 r3492699 201 201 202 202 public static function get_label() { 203 return __( 'Add responsiveness settings to Columns block.', 'better-block-editor' );203 return __( 'Add Responsive Settings to Columns block.', 'better-block-editor' ); 204 204 } 205 205 } -
better-block-editor/tags/1.4.0/Modules/ContactForm7Block/Module.php
r3449829 r3492699 12 12 use BetterBlockEditor\Core\BlockUtils; 13 13 use BetterBlockEditor\Base\ModuleBase; 14 use BetterBlockEditor\Core\Settings; 14 15 use BetterBlockEditor\Modules\StyleEngine\Module as StyleEngineModule; 15 16 … … 166 167 } 167 168 169 public static function get_tab() { 170 return Settings::TAB_BLOCKS; 171 } 172 168 173 public static function get_title() { 169 return __( 'B etter Contact Form 7 Block', 'better-block-editor' );174 return __( 'BBE Contact Form 7', 'better-block-editor' ); 170 175 } 171 176 172 177 public static function get_label() { 173 return __( 'Enable Better Contact Form 7 block.', 'better-block-editor' ); 174 } 178 return __( 'Enable BBE Contact Form 7 block.', 'better-block-editor' ); 179 } 180 175 181 public function render( $attributes ) { 176 182 $id = intval( $attributes['id'] ?? 0 ); … … 235 241 self::DESIGN_STYLES_OPTION => array( 236 242 'type' => 'checkbox', 237 'label' => __( ' Better Contact Form 7 Styles', 'better-block-editor' ),243 'label' => __( 'Enable form styling.', 'better-block-editor' ), 238 244 'default' => 1, 239 'description' => __( ' Enable configurable styles for Better Contact Form 7 block.', 'better-block-editor' ),245 'description' => __( 'When enabled, form styling settings become available in the BBE Contact Form 7 block. If disabled, default theme styles will be used.', 'better-block-editor' ), 240 246 ), 241 247 ); -
better-block-editor/tags/1.4.0/Modules/DemoContent/Module.php
r3386474 r3492699 10 10 namespace BetterBlockEditor\Modules\DemoContent; 11 11 12 use BetterBlockEditor\Base\ManagableModuleInterface; 12 13 use BetterBlockEditor\Base\ModuleBase; 13 14 use BetterBlockEditor\Modules\DemoContent\AjaxHandlers\ImportContentAjaxHandler; … … 23 24 * Bootstraps Demo Content importer admin experience. 24 25 */ 25 class Module extends ModuleBase {26 class Module extends ModuleBase implements ManagableModuleInterface { 26 27 27 28 const MODULE_IDENTIFIER = 'demo-content'; … … 45 46 */ 46 47 protected $page_hook = null; 48 49 public static function get_title() { 50 return __( 'Site Templates', 'better-block-editor' ); 51 } 52 53 public static function get_label() { 54 return __('Enable BBE pre-made Site Templates', 'better-block-editor' ); 55 } 56 57 public static function get_settings_order() { 58 return 50; 59 } 60 47 61 48 62 /** -
better-block-editor/tags/1.4.0/Modules/DesignSystemParts/Module.php
r3386474 r3492699 11 11 use BetterBlockEditor\Base\ManagableModuleInterface; 12 12 use BetterBlockEditor\Base\ConfigurableModuleInterface; 13 use BetterBlockEditor\Core\Settings; 13 14 14 15 defined( 'ABSPATH' ) || exit; … … 23 24 public static function get_default_state() { 24 25 return false; 26 } 27 28 public static function get_tab() { 29 return Settings::TAB_DESIGN; 25 30 } 26 31 … … 37 42 // add filter on very late stage to change theme data just before using it in FE 38 43 add_filter( 'wp_theme_json_data_theme', array( $this, 'modify_theme_json_values' ), 1000 ); 39 // exclude parts of design system , later add an option to settings page to control it44 // exclude parts of design system 40 45 add_filter( 'wpbbe_design_system_parts', array( $this, 'filter_design_system_parts' ), 10, 2 ); 41 46 add_action( 'rest_api_init', array( $this, 'register_rest_routes' ) ); … … 43 48 44 49 public function filter_design_system_parts( $parts, $context ) { 45 $active_parts = $this->get_option( self::ACTIVE_PARTS, array());50 $active_parts = $this->get_option( self::ACTIVE_PARTS, self::get_settings()[ self::ACTIVE_PARTS ]['default'] ); 46 51 $map = array( 47 52 'color' => array( 'colorPalette', 'colorGradients' ), … … 197 202 self::ACTIVE_PARTS => array( 198 203 'type' => 'multicheckbox', 199 ' label' => __( 'Design System Parts', 'better-block-editor' ),204 'title' => __( 'Design System Parts', 'better-block-editor' ), 200 205 'options' => array( 201 206 'color' => __( 'Colors', 'better-block-editor' ), 202 207 'typography' => __( 'Typography', 'better-block-editor' ), 208 'spacing' => array( 'label' => __( 'Spacing', 'better-block-editor' ), 'disabled' => true ) 203 209 ), 204 'default' => array( ''),210 'default' => array( 'color'=> 1, 'typography' => 1, 'spacing' => 1 ), 205 211 'description' => __( 'Choose active parts of the design system.', 'better-block-editor' ), 206 212 ), -
better-block-editor/tags/1.4.0/Modules/GridResponsive/Module.php
r3386474 r3492699 29 29 30 30 public static function get_label() { 31 return __( 'Add responsiveness settings to Grid block.', 'better-block-editor' );31 return __( 'Add Responsive Settings to Grid block.', 'better-block-editor' ); 32 32 } 33 33 -
better-block-editor/tags/1.4.0/Modules/GroupResponsive/Module.php
r3386474 r3492699 29 29 30 30 public static function get_label() { 31 return __( 'Add responsiveness settings to Group block.', 'better-block-editor' );31 return __( 'Add Responsive Settings to Group block.', 'better-block-editor' ); 32 32 } 33 33 -
better-block-editor/tags/1.4.0/Modules/NavigationResponsive/Module.php
r3386474 r3492699 111 111 112 112 public static function get_label() { 113 return __( 'Add responsiveness settings to Navigation block.', 'better-block-editor' );113 return __( 'Add Responsive Settings to Navigation block.', 'better-block-editor' ); 114 114 } 115 115 } -
better-block-editor/tags/1.4.0/Modules/PostTemplateResponsive/Module.php
r3386474 r3492699 28 28 29 29 public static function get_label() { 30 return __( 'Add responsiveness settings to Post Template block.', 'better-block-editor' );30 return __( 'Add Responsive Settings to Post Template block when used in Grid view.', 'better-block-editor' ); 31 31 } 32 32 -
better-block-editor/tags/1.4.0/Modules/RowResponsive/Module.php
r3386474 r3492699 29 29 30 30 public static function get_label() { 31 return __( 'Add responsiveness settings to Row block.', 'better-block-editor' );31 return __( 'Add Responsive Settings to Row block.', 'better-block-editor' ); 32 32 } 33 33 -
better-block-editor/tags/1.4.0/Modules/TextResponsive/Module.php
r3386474 r3492699 19 19 const ASSETS_BUILD_PATH = 'editor/blocks/__all__/text-responsive/'; 20 20 21 const SETTINGS_ORDER = 1400;21 const SETTINGS_ORDER = 920; 22 22 23 23 const BLOCK_NAMES = array( … … 33 33 34 34 public static function get_label() { 35 return __( 'Add responsive text alignment settings to Header, Paragraph, Post Title and Post Excerpt blocks.', 'better-block-editor' );35 return __( 'Add Responsive text alignment settings to Header, Paragraph, Post Title and Post Excerpt blocks.', 'better-block-editor' ); 36 36 } 37 37 -
better-block-editor/tags/1.4.0/Modules/TextStyleFromElement/Module.php
r3443250 r3492699 20 20 const ASSETS_BUILD_PATH = 'editor/blocks/__all__/text-style-from-element/'; 21 21 22 const SETTINGS_ORDER = 1500;22 const SETTINGS_ORDER = 930; 23 23 24 24 const ATTRIBUTE_TEXT_STYLE = 'wpbbeTextStyleFromElement'; … … 34 34 35 35 const TEXT_STYLE_CLASSNAME_PREFIX = 'wpbbe-text-style-from-element-'; 36 36 37 37 public function init(): void { 38 38 … … 57 57 58 58 // settings from the "All Headings" element 59 $all_headings_styling_data = $this->get_text_style_to_borrow( 60 $theme_json_data['styles']['elements'][ self::ALL_HEADINGS_ELEMENT ] ?? array() 59 $all_headings_styling_data = $this->get_text_style_to_borrow( 60 $theme_json_data['styles']['elements'][ self::ALL_HEADINGS_ELEMENT ] ?? array() 61 61 ); 62 62 … … 69 69 $all_headings_styling_data, 70 70 array( 71 'selector' => implode( ', ', 72 array_map( 73 function ( $heading_element ) { 71 'selector' => implode( ', ', 72 array_map( 73 function ( $heading_element ) { 74 74 return str_repeat('.' . self::TEXT_STYLE_CLASSNAME_PREFIX . $heading_element, 2); 75 }, 76 self::HEADING_ELEMENTS 77 ) 75 }, 76 self::HEADING_ELEMENTS 77 ) 78 78 ), 79 79 'context' => 'core', … … 81 81 ); 82 82 } 83 83 84 84 85 85 // individual heading (h1, h2, etc.) settings … … 87 87 if ( in_array( $element_name, self::HEADING_ELEMENTS, true ) ) { 88 88 $heading_element_styling_data = $this->get_text_style_to_borrow( $element_settings ); 89 89 90 90 if ( empty( $heading_element_styling_data ) ) { 91 91 continue; 92 } 92 } 93 93 94 94 StyleEngineModule::get_styles( … … 136 136 // also add the core heading class if the style is taken from a heading element 137 137 $cssClasses[] = self::WP_CORE_HEADING_CLASSNAME; 138 } 138 } 139 139 140 140 $block_content = BlockUtils::append_classes( $block_content, $cssClasses); … … 144 144 145 145 public static function get_title(): string { 146 return __( ' Text Blocks Style', 'better-block-editor' );146 return __( 'Change Style for Text Blocks', 'better-block-editor' ); 147 147 } 148 148 149 149 public static function get_label(): string { 150 return __( 'Add Style setting for Heading, Paragraph, Post Title, and Post Excerpt blocks.', 'better-block-editor' );150 return __( 'Add a "Change style" setting for Heading, Paragraph, Post Title, and Post Excerpt blocks. Select a visual style (H1–H6, Paragraph) for text blocks without changing their HTML tag.', 'better-block-editor' ); 151 151 } 152 152 -
better-block-editor/tags/1.4.0/Modules/UploadSVG/Module.php
r3386474 r3492699 10 10 use BetterBlockEditor\Base\ModuleBase; 11 11 use BetterBlockEditor\Base\ManagableModuleInterface; 12 use BetterBlockEditor\Core\Settings; 12 13 use enshrined\svgSanitize\Sanitizer; 13 14 … … 493 494 494 495 public static function get_title() { 495 return __( 'Inline SVG', 'better-block-editor' ); 496 return __( 'BBE SVG Icon', 'better-block-editor' ); 497 } 498 499 public static function get_tab() { 500 return Settings::TAB_BLOCKS; 496 501 } 497 502 498 503 public static function get_label() { 499 return __( 'Allow to upload and display the SVG icon', 'better-block-editor' );504 return __( 'Allow uploading SVG images, and enable the BBE SVG Icon block.', 'better-block-editor' ); 500 505 } 501 506 } -
better-block-editor/tags/1.4.0/Modules/Visibility/Module.php
r3459110 r3492699 2 2 /** 3 3 * Adds responsive visibility settings to all blocks. 4 * Standard approach with ResponsiveBlockModuleBase can not be used here 4 * Standard approach with ResponsiveBlockModuleBase can not be used here 5 5 * as visibility='hidden' must work even without any responsive settings 6 * 6 * 7 7 * @package BetterBlockEditor 8 8 */ … … 24 24 const PLUGIN_ASSETS_BUILD_PATH = 'editor/plugins/visibility/'; 25 25 26 const SETTINGS_ORDER = 100;26 const SETTINGS_ORDER = 990; 27 27 28 28 const ATTRIBUTES = 'wpbbeVisibility'; … … 90 90 return $block_content; 91 91 } 92 92 93 93 /** 94 94 * Helper to get visibility settings from block attributes 95 * 95 * 96 96 * @return array [ visibility, breakpoint, breakpointCustomValue ] 97 97 */ 98 98 private function get_visibility_settings( $attributes ): array { 99 return 99 return 100 100 array( 101 101 $attributes[ self::ATTRIBUTES ]['visibility'] ?? 'visible', // default to visible if not set … … 112 112 if ( null === $switch_width ) { 113 113 if ( $visibility === 'hidden' ) { 114 // if block is always hidden 114 // if block is always hidden 115 115 BlockUtils::add_styles_from_css_rules( 116 116 array( … … 129 129 ".{$class_id}.{$class_id}", 130 130 array( 'display' => 'none !important' ) 131 ); 131 ); 132 132 } 133 133 … … 137 137 138 138 public static function get_label() { 139 return __( 'Add responsive Visibility settings to all blocks.', 'better-block-editor' );139 return __( 'Add Responsive Visibility Settings to all blocks.', 'better-block-editor' ); 140 140 } 141 141 } -
better-block-editor/tags/1.4.0/admin/templates/settings/_multicheckbox.php
r3386474 r3492699 6 6 <?php endif; ?> 7 7 8 <?php foreach ( $args['options'] as $key => $label ) : 8 <?php foreach ( $args['options'] as $key => $value ) : 9 $disabled = false; 10 $label = ''; 11 if ( is_array( $value ) ) { 12 $label = $value['label'] ?? $key; 13 $disabled = ! empty( $value['disabled'] ); 14 } else { 15 $label = $value; 16 } 9 17 $checked = !empty($args['value'][$key]); 10 18 ?> … … 14 22 name="<?php echo esc_attr( $args['identifier'] . '[' . $key . ']' ); ?>" 15 23 value="1" 24 <?php disabled( $disabled ); ?> 16 25 <?php checked( $checked ); ?> 17 26 /> -
better-block-editor/tags/1.4.0/admin/templates/settings/breakpoints.php
r3386474 r3492699 5 5 </div> 6 6 7 <button 8 type="button" 9 class="button button-secondary" 7 <button 8 type="button" 9 class="button button-secondary" 10 10 onclick="window.wpbbeSettingsAddBreakpoint(event)" 11 11 > 12 <span 13 class="dashicons dashicons-plus" 14 style="width: auto; height: auto; font-size: 1.2em; vertical-align: middle;" 12 <span 13 class="dashicons dashicons-plus" 14 style="width: auto; height: auto; font-size: 1.2em; vertical-align: middle;" 15 15 title="<?php echo esc_attr( __( 'Add breakpoint', 'better-block-editor' ) ); ?>" 16 16 /> -
better-block-editor/tags/1.4.0/admin/templates/settings/page.php
r3386474 r3492699 5 5 defined( 'ABSPATH' ) || exit; ?> 6 6 7 <?php 8 $tabs = array( 9 Settings::TAB_FEATURES => array( 10 'label' => __( 'Features', 'better-block-editor' ), 11 ), 12 Settings::TAB_BREAKPOINTS => array( 13 'label' => __( 'Breakpoints', 'better-block-editor' ), 14 ), 15 Settings::TAB_DESIGN => array( 16 'label' => __( 'Design System', 'better-block-editor' ), 17 ), 18 Settings::TAB_BLOCKS => array( 19 'label' => __( 'Blocks', 'better-block-editor' ), 20 ), 21 ); 22 //Allow adding custom tabs 23 $tabs = apply_filters('wpbbe-settings_tabs', $tabs); 24 ?> 25 7 26 <div class="wrap"> 8 9 27 <h1><?php echo esc_html( __( 'Better Block Editor', 'better-block-editor' ) ); ?></h1> 10 28 <nav class="nav-tab-wrapper wpbbe-tabs"> 29 <?php foreach ( $tabs as $tab_slug => $tab ) : ?> 30 <a href="#" 31 class="nav-tab" 32 data-tab="<?php echo esc_attr( $tab_slug ); ?>"> 33 <?php echo esc_html( $tab['label'] ); ?> 34 </a> 35 <?php endforeach; ?> 36 </nav> 11 37 <form action="options.php" method="post"> 12 38 <?php 13 39 settings_fields( WPBBE_PLUGIN_ID . '_settings' ); 14 15 40 do_settings_sections( Settings::MENU_PAGE_SLUG ); 16 17 18 41 submit_button( esc_attr( __( 'Save Settings', 'better-block-editor' ) ) ); 19 42 ?> 20 43 </form> 21 22 44 </div> -
better-block-editor/tags/1.4.0/better-block-editor.php
r3473824 r3492699 5 5 * Requires at least: 6.8 6 6 * Requires PHP: 7.4 7 * Version: 1. 3.07 * Version: 1.4.0 8 8 * Author: Dream-Theme 9 9 * License: GPLv2 or later … … 21 21 require_once __DIR__ . '/plugin.php'; 22 22 23 define( 'WPBBE_VERSION', '1. 3.0' );23 define( 'WPBBE_VERSION', '1.4.0' ); 24 24 25 25 define( 'WPBBE_FILE', __FILE__ ); -
better-block-editor/tags/1.4.0/plugin.php
r3386474 r3492699 70 70 return $links; 71 71 }, 10, 2 ); 72 73 $this->bundled_assets_manager = new BundledAssetsManager( WPBBE_PLUGIN_ID, WPBBE_DIST, WPBBE_URL_DIST );74 72 } 75 73 … … 101 99 $this->modules_manager = new ModulesManager(); 102 100 $this->modules_manager->setup_hooks(); 101 102 // in case there is BBE Pro Kit we have to add BBE Pro Kit bundles as dependencies for our bundles 103 // so they are loaded before our bundles (based on defer loading strategy). 104 $dependencies =array(); 105 106 if ( defined('BBE_PRO_KIT_PLUGIN_ID')) { 107 $supported_bundles = array( 108 BundledAssetsManager::EDITOR_BUNDLE, 109 BundledAssetsManager::EDITOR_CONTENT_BUNDLE, 110 BundledAssetsManager::VIEW_BUNDLE, 111 ); 112 113 foreach ( $supported_bundles as $bundle ) { 114 $dependencies[ $bundle ] = array( 115 BundledAssetsManager::build_handle( BBE_PRO_KIT_PLUGIN_ID, $bundle, 'script' ) 116 ); 117 } 118 } 119 120 $this->bundled_assets_manager = new BundledAssetsManager( 121 WPBBE_PLUGIN_ID, 122 WPBBE_DIST, 123 WPBBE_URL_DIST, 124 $dependencies 125 ); 103 126 104 127 if ( $this->is_asset_bundle_mode() ) { … … 130 153 } 131 154 ); 132 133 155 return empty( $disabled_modules ); 134 156 } -
better-block-editor/tags/1.4.0/readme.txt
r3477947 r3492699 5 5 Tested up to: 6.9 6 6 Requires PHP: 7.4 7 Stable tag: 1. 3.07 Stable tag: 1.4.0 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 11 11 == Description == 12 12 13 https://www.youtube.com/watch?v= WhWGnT5hi-813 https://www.youtube.com/watch?v=YwZZb_XIkJs 14 14 15 15 Better Block Editor (BBE) adds responsive layout controls, hover effects, on-scroll animations, and ready-to-use site templates to Block Editor. It’s not another page builder. It doesn’t replace core blocks or add bloat — BBE just adds the missing settings where needed. It works with your current block theme and plugins, so your existing content stays intact. … … 69 69 * User Guide — [https://docs.wpbbe.io/](https://docs.wpbbe.io/) 70 70 == Changelog == 71 = 1.4.0 (27-03-2026) = 72 1. Improved Better Block Editor settings interface. 73 2. Added option to remove Site Templates link from admin menu. 71 74 = 1.3.0 (03-03-2026) = 72 75 1. Added accessibility enhancements for SVG Icon block. -
better-block-editor/tags/1.4.0/vendor/composer/installed.php
r3473824 r3492699 2 2 'root' => array( 3 3 'name' => 'dream-theme/better-block-editor', 4 'pretty_version' => 'v1. 3.0',5 'version' => '1. 3.0.0',6 'reference' => ' 151321e2b14e0e968a72c181b9d47a231657e33f',4 'pretty_version' => 'v1.4.0', 5 'version' => '1.4.0.0', 6 'reference' => '694e99ca742cbf09a53c056940dca8a28f513cd3', 7 7 'type' => 'project', 8 8 'install_path' => __DIR__ . '/../../', … … 21 21 ), 22 22 'dream-theme/better-block-editor' => array( 23 'pretty_version' => 'v1. 3.0',24 'version' => '1. 3.0.0',25 'reference' => ' 151321e2b14e0e968a72c181b9d47a231657e33f',23 'pretty_version' => 'v1.4.0', 24 'version' => '1.4.0.0', 25 'reference' => '694e99ca742cbf09a53c056940dca8a28f513cd3', 26 26 'type' => 'project', 27 27 'install_path' => __DIR__ . '/../../', -
better-block-editor/trunk/Base/ModuleBase.php
r3449829 r3492699 113 113 public static function get_settings_order() { 114 114 return static::SETTINGS_ORDER; 115 } 116 117 /** 118 * {inheritdocs} 119 */ 120 public static function get_tab() { 121 return Settings::TAB_FEATURES; 115 122 } 116 123 … … 291 298 protected function get_option( string $key = null, $default = null ) { 292 299 $option_name = Settings::build_module_settings_name( $this->get_identifier() ); 293 294 $options = get_option( $option_name, array() ); 295 296 if ( null === $key ) { 297 return $options; 298 } 299 300 return $options[ $key ] ?? $default; 300 return Settings::get_setting($option_name, $key, $default ); 301 301 } 302 302 -
better-block-editor/trunk/Core/BundledAssetsManager.php
r3386474 r3492699 33 33 private $plugin_dist; 34 34 35 public function __construct( string $plugin_id, string $plugin_dist, string $plugin_dist_url ) { 35 /** 36 * @var array Dependencies for each bundle (optional, can be empty). 37 * Format: array( 'bundle_key' => array( 'dependency_handle1', 'dependency_handle2' ) ) 38 */ 39 private $dependencies; 40 41 public function __construct( string $plugin_id, string $plugin_dist, string $plugin_dist_url, array $dependencies = array() ) { 36 42 $this->plugin_id = $plugin_id; 37 43 $this->plugin_dist = $plugin_dist; 38 44 $this->plugin_dist_url = $plugin_dist_url; 45 $this->dependencies = $dependencies; 39 46 } 40 47 … … 44 51 * @return void 45 52 */ 46 public function process_editor_assets() {47 $this->register_assets( 'editor');48 $this->enqueue_assets( 'enqueue_block_editor_assets', 'editor');53 public function process_editor_assets(): void { 54 $this->register_assets( self::EDITOR_BUNDLE ); 55 $this->enqueue_assets( self::EDITOR_BUNDLE ); 49 56 } 50 57 … … 54 61 * @return void 55 62 */ 56 public function process_editor_content_assets() {57 $this->register_assets( 'editor-content');58 $this->enqueue_assets( 'enqueue_block_assets', 'editor-content');63 public function process_editor_content_assets(): void { 64 $this->register_assets( self::EDITOR_CONTENT_BUNDLE ); 65 $this->enqueue_assets( self::EDITOR_CONTENT_BUNDLE ); 59 66 } 60 67 … … 64 71 * @return void 65 72 */ 66 public function process_view_assets() {67 $this->register_assets( 'view');68 $this->enqueue_assets( 'wp_enqueue_scripts', 'view');73 public function process_view_assets(): void { 74 $this->register_assets( self::VIEW_BUNDLE ); 75 $this->enqueue_assets( self::VIEW_BUNDLE ); 69 76 } 70 77 71 78 /** 72 79 * Add inline JS code just before bundle code (see wp_add_inline_script()) 80 * Before mode does not affect "defer" script attribute 73 81 * 74 82 * @param string $bundle_name Bundle name(key) to add code to (see self::*_BUNDLE) … … 77 85 * @return bool 78 86 */ 79 public function add_inline_js_before_bundle( $bundle_name, $js ) {87 public function add_inline_js_before_bundle( $bundle_name, $js ): bool { 80 88 return wp_add_inline_script( 81 89 $this->build_script_handle( $bundle_name ), … … 86 94 87 95 /** 88 * Add inline JS code just after bundle code (see wp_add_inline_script()) 89 * 90 * @param string $bundle_name Bundle name(key) to add code to (see self::*_BUNDLE) 96 * Add inline JS code to footer 97 * We use fake handler to non existing script to add inline code to footer 98 * Bundle name is required to add code with appropriate hook (editor, editor-content, view) 99 * 100 * @param string $bundle_name Bundle name (see self::*_BUNDLE) to add code with appropriate hook 91 101 * @param string $js JS code to be added as inline script 92 102 * 93 103 * @return bool 94 104 */ 95 public function add_inline_js_after_bundle( $bundle_name, $js ) { 96 return wp_add_inline_script( 97 $this->build_script_handle( $bundle_name ), 98 $js, 99 'after' 100 ); 105 public function add_inline_js_to_footer($bundle_name, $js ): bool { 106 107 $handle = $this->build_script_handle( 'footer-inline' ) . '__handler'; 108 109 // register only once 110 if ( ! wp_script_is( $handle, 'registered' ) ) { 111 wp_register_script( 112 $handle, 113 false, // no source file 114 array(), 115 false, 116 array( 'in_footer' => true ) // it won't be deferred because we add inline script to it 117 ); 118 119 $action = $this->get_action_for_bundle( $bundle_name ); 120 121 if ( null === $action ) { 122 return false; 123 } 124 125 add_action( 126 $action, 127 function () use ( $handle ) { 128 wp_enqueue_script( $handle ); 129 } 130 ); 131 } 132 133 return wp_add_inline_script( $handle, $js, 'before' ); 134 } 135 136 /** 137 * Build a handle name for a given plugin ID, bundle key and type (script or style). 138 * 139 * @param string $plugin_id Plugin ID. 140 * @param string $bundle_key Bundle key (one of 'editor', 'editor-content', 'view'). 141 * @param string $type Type of handle ('script' or 'style'). 142 * 143 * @return string Handle name. 144 */ 145 public static function build_handle( $plugin_id, $bundle_key, $type ): string { 146 return $plugin_id . '__bundle__' . $bundle_key . '-' . $type; 147 } 148 149 /** 150 * Get the appropriate action hook for enqueuing assets based on the bundle name. 151 * 152 * @param string $bundle_name Bundle name(key) to get action for (see self::*_BUNDLE) 153 * 154 * @return string|null Action hook name or null if bundle name is invalid. 155 */ 156 private function get_action_for_bundle( $bundle_name ): ?string { 157 $map = array( 158 self::EDITOR_BUNDLE => 'enqueue_block_editor_assets', 159 self::EDITOR_CONTENT_BUNDLE => 'enqueue_block_assets', 160 self::VIEW_BUNDLE => 'wp_enqueue_scripts', 161 ); 162 163 return array_key_exists( $bundle_name, $map ) ? $map[ $bundle_name ] : null; 101 164 } 102 165 … … 105 168 * 106 169 * @param string $key Bundle key (one of 'editor', 'editor-content', 'view'). 107 * @param array $script_register_options Optional script registration options. 108 * 109 * @return void 110 */ 111 private function register_assets( $key, $script_register_options = array() ) { 170 * 171 * @return void 172 */ 173 private function register_assets( $key ): void { 112 174 if ( ! file_exists( $this->get_asset_filename( $key ) ) ) { 113 175 return; … … 116 178 $asset_file = require $this->get_asset_filename( $key ); 117 179 118 // script119 $default_options = array(120 'strategy' => 'defer',121 'in_footer' => false,122 );123 180 // it's safe to return here as css is added only using js import construction 124 181 if ( ! file_exists( $this->plugin_dist . self::BUNDLE_DIR . $key . '.js' ) ) { … … 126 183 } 127 184 128 $res = wp_register_script( 185 // merge "native" dependencies from asset file with any additional dependencies provided added manually 186 $script_dependencies = array_merge( $asset_file['dependencies'], (array)($this->dependencies[ $key ] ?? array()) ); 187 188 189 wp_register_script( 129 190 $this->build_script_handle( $key ), 130 191 $this->plugin_dist_url . self::BUNDLE_DIR . $key . '.js', 131 $ asset_file['dependencies'],192 $script_dependencies, 132 193 $asset_file['version'], 133 array_merge( $default_options, $script_register_options ) 194 // it's important to use defer for all scripts in the bundle 195 // otherwise the order of execution will be broken and it may cause errors 196 // we add to header as it's common practice 197 array( 198 'strategy' => 'defer', 199 'in_footer' => false, 200 ) 134 201 ); 135 202 … … 148 215 149 216 /** 150 * Enqueue registered script and style assets for a given action and bundle key. 151 * 152 * @param string $action WordPress action hook. 153 * @param string $key Bundle key (one of 'editor', 'editor-content', 'view'). 154 * 155 * @return void 156 */ 157 private function enqueue_assets( $action, $key ) { 217 * Enqueue registered script and style assets for a given supported bundle key. 218 * 219 * @param string $key Bundle key (one of 'editor', 'editor-content', 'view'). 220 * 221 * @return void 222 */ 223 private function enqueue_assets( $key ): void { 158 224 $script_handle = $this->build_script_handle( $key ); 159 225 $style_handle = $this->build_style_handle( $key ); 226 227 $action = $this->get_action_for_bundle( $key ); 228 229 // if action is null it means that bundle key is invalid and we should not enqueue assets 230 if ( null === $action ) { 231 return; 232 } 160 233 161 234 add_action( … … 175 248 * @return string Path to the asset metadata file. 176 249 */ 177 private function get_asset_filename( $key ) {250 private function get_asset_filename( $key ): string { 178 251 return $this->plugin_dist . self::BUNDLE_DIR . $key . '.asset.php'; 179 252 } … … 186 259 * @return string Script handle name. 187 260 */ 188 p rivate function build_script_handle( $key ){189 return $this->plugin_id . '__' . 'bundle' . '__' . $key . '-script';261 public function build_script_handle( $key ): string { 262 return self::build_handle( $this->plugin_id, $key, 'script' ); 190 263 } 191 264 … … 197 270 * @return string Style handle name. 198 271 */ 199 private function build_style_handle( $key ) {200 return $this->plugin_id . '__' . 'bundle' . '__' . $key . '-style';272 private function build_style_handle( $key ): string { 273 return self::build_handle( $this->plugin_id, $key, 'style' ); 201 274 } 202 275 } -
better-block-editor/trunk/Core/ModulesManager.php
r3449829 r3492699 131 131 'label' => $classname::get_label(), 132 132 'description' => $classname::get_description(), 133 'tab' => $classname::get_tab(), 133 134 'settings_order' => $classname::get_settings_order(), 134 135 'enabled' => self::is_module_enabled( $classname ), 135 'is_freemium' => is_a( $classname, 'BetterBlockEditor\Base\ModuleInterface', true ),136 'is_freemium' => !is_a( $classname, 'BbeProKit\Base\ModuleBasePro', true ), 136 137 'classname' => $classname, 137 138 'active' => isset( $this->modules[ $classname::get_identifier() ] ), -
better-block-editor/trunk/Core/Settings.php
r3473824 r3492699 16 16 class Settings { 17 17 18 protected static $allowed_breakpoint_units = array( 'px', 'em', 'rem', 'vw', 'vh' ); 18 public const TAB_FEATURES = 'features'; 19 public const TAB_BLOCKS = 'blocks'; 20 public const TAB_DESIGN = 'design'; 21 public const TAB_BREAKPOINTS = 'breakpoints'; 22 23 protected static $allowed_breakpoint_units = array( 'px', 'rem' ); 19 24 20 25 // WP permission to open the Settings Page … … 26 31 const TEMPLATES_FOLDER_NAME = WPBBE_DIR . 'admin/templates/settings/'; 27 32 33 protected static $pro_separator_added = false; 28 34 29 35 /** … … 67 73 68 74 foreach ( $modules_data as $module_data ) { 69 self::add_module_enable_checkbox( 70 $module_data['identifier'], 71 $module_data['title'], 75 self::add_module_enable_checkbox( $module_data ); 76 // add module settings 77 $classname = $module_data['classname'] ?? null; 78 if ( $classname && is_a( $classname, ConfigurableModuleInterface::class, true ) ) { 79 foreach ( $classname::get_settings() as $key => $field ) { 80 self::add_module_settigns( $module_data, $key, $field ); 81 } 82 } 83 } 84 85 self::add_user_defined_breakpoint_options(); 86 87 add_action( 'admin_enqueue_scripts', array( self::class, 'enqueue_admin_assets' ) ); 88 } 89 90 /** 91 * Enqueue admin assets for settings page. 92 * * @param string $hook_suffix The current admin page hook suffix. 93 */ 94 public static function enqueue_admin_assets( $hook_suffix ) { 95 // if not on the settings page, do not enqueue the script 96 if ( 'settings_page_' . self::MENU_PAGE_SLUG !== $hook_suffix ) { 97 return; 98 } 99 // add js to the page 100 $handle = WPBBE_PLUGIN_ID . '__core-settings-script'; 101 wp_register_script( 102 $handle, 103 WPBBE_URL . 'admin/js/settings/settings.js', 104 array(), // no dependencies for this script 105 WPBBE_VERSION, // use plugin version as script version 106 array( 107 'in_footer' => true, // load script in footer as we need to access the DOM elements 108 ) 109 ); 110 111 $translations = array( 112 'remove_breakpoint_confirm_message' => esc_js( __( 'Do you want to remove this breakpoint?', 'better-block-editor' ) ), 113 'remove_breakpoint_button_title' => esc_js( __( 'Remove breakpoint', 'better-block-editor' ) ), 114 ); 115 116 $inline_script = 'const WPBBE_RESPONSIVE_BREAKPOINT_SETTINGS = ' . wp_json_encode( 72 117 array( 73 ' label' => $module_data['label'],74 ' description' => $module_data['description'],75 ' enabled' => $module_data['enabled'],118 'ALLOWED_SIZE_UNITS' => self::$allowed_breakpoint_units, 119 'WP_OPTION_NAME' => self::build_user_defined_breakpoints_option_name(), 120 'I18N_TRANSLATIONS' => $translations, 76 121 ) 77 ); 122 ) . ';'; 123 124 // initialize the Map to store breakpoints 125 $inline_script .= 'WPBBE_RESPONSIVE_BREAKPOINT_SETTINGS.BREAKPOINT_LIST = new Map();' . "\n"; 126 // we use Map to keep breakpoints order (otherwise it will be sorted by keys) 127 foreach ( self::get_active_user_defined_breakpoints() as $key => $breakpoint ) { 128 $inline_script .= sprintf( 129 'WPBBE_RESPONSIVE_BREAKPOINT_SETTINGS.BREAKPOINT_LIST.set(\'%s\', %s);', 130 esc_js( (string) $key ), 131 wp_json_encode( $breakpoint ) 132 ) . "\n"; 133 } 134 135 wp_add_inline_script( $handle, $inline_script, 'before' ); 136 137 wp_enqueue_script( $handle ); 138 wp_enqueue_style( 139 WPBBE_PLUGIN_ID . '__core-settings-style', 140 WPBBE_URL . 'admin/css/settings/settings.css', 141 array(), 142 WPBBE_VERSION 143 ); 144 } 145 146 public static function rest_settings_init() { 147 $modules_data = Plugin::instance()->modules_manager->get_managable_modules_data(); 148 foreach ( $modules_data as $module_data ) { 149 self::add_module_enable_checkbox( $module_data,true ); 78 150 // add module settings 79 151 if ( $module_data['enabled'] ) { … … 81 153 if ( $classname && is_a( $classname, ConfigurableModuleInterface::class, true ) ) { 82 154 foreach ( $classname::get_settings() as $key => $field ) { 83 self::add_module_settigns( $module_data['identifier'], $key, $field ); 84 } 85 } 86 } 87 } 88 89 self::add_user_defined_breakpoint_options(); 90 } 91 92 public static function rest_settings_init() { 93 $modules_data = Plugin::instance()->modules_manager->get_managable_modules_data(); 94 foreach ( $modules_data as $module_data ) { 95 self::add_module_enable_checkbox( 96 $module_data['identifier'], 97 $module_data['title'], 98 array( 99 'label' => $module_data['label'], 100 'description' => $module_data['description'], 101 'enabled' => $module_data['enabled'], 102 ), 103 true 104 ); 105 // add module settings 106 if ( $module_data['enabled'] ) { 107 $classname = $module_data['classname'] ?? null; 108 if ( $classname && is_a( $classname, ConfigurableModuleInterface::class, true ) ) { 109 foreach ( $classname::get_settings() as $key => $field ) { 110 self::add_module_settigns( $module_data['identifier'], $key, $field, true ); 155 self::add_module_settigns( $module_data, $key, $field, true ); 111 156 } 112 157 } … … 179 224 __( 'Breakpoints', 'better-block-editor' ), 180 225 function () { 181 self::parse_template( 'breakpoints', array() ); 226 self::parse_template('_setting_wrapper', [ 227 'tab' => self::TAB_BREAKPOINTS, 228 'template' => 'breakpoints', 229 ]); 182 230 }, 183 231 self::MENU_PAGE_SLUG, 184 232 WPBBE_PLUGIN_ID . '_settings_section' 185 );186 187 // add js to the page188 $relative_filename = 'admin/js/settings/breakpoints.js';189 $handle = WPBBE_PLUGIN_ID . '__core-settings__breakpoints-script';190 wp_register_script(191 $handle,192 WPBBE_URL . $relative_filename,193 array(), // no dependencies for this script194 WPBBE_VERSION, // use plugin version as script version195 array(196 'in_footer' => true, // load script in footer as we need to access the DOM elements197 )198 );199 200 $translations = array(201 'remove_breakpoint_confirm_message' => esc_js( __( 'Do you want to remove this breakpoint?', 'better-block-editor' ) ),202 'remove_breakpoint_button_title' => esc_js( __( 'Remove breakpoint', 'better-block-editor' ) ),203 );204 205 $inline_script = 'const WPBBE_RESPONSIVE_BREAKPOINT_SETTINGS = ' . wp_json_encode(206 array(207 'ALLOWED_SIZE_UNITS' => self::$allowed_breakpoint_units,208 'WP_OPTION_NAME' => self::build_user_defined_breakpoints_option_name(),209 'I18N_TRANSLATIONS' => $translations,210 )211 ) . ';';212 213 // initialize the Map to store breakpoints214 $inline_script .= 'WPBBE_RESPONSIVE_BREAKPOINT_SETTINGS.BREAKPOINT_LIST = new Map();' . "\n";215 // we use Map to keep breakpoints order (otherwise it will be sorted by keys)216 foreach ( self::get_active_user_defined_breakpoints() as $key => $breakpoint ) {217 $inline_script .= sprintf(218 'WPBBE_RESPONSIVE_BREAKPOINT_SETTINGS.BREAKPOINT_LIST.set(\'%s\', %s);',219 esc_js( (string) $key ),220 wp_json_encode( $breakpoint )221 ) . "\n";222 }223 224 wp_add_inline_script( $handle, $inline_script, 'before' );225 226 add_action(227 'admin_enqueue_scripts',228 function ( $hook_suffix ) use ( $handle ) {229 // if not on the settings page, do not enqueue the script230 if ( 'settings_page_' . self::MENU_PAGE_SLUG !== $hook_suffix ) {231 return;232 }233 wp_enqueue_script( $handle );234 }235 233 ); 236 234 } … … 279 277 } 280 278 281 private static function add_module_enable_checkbox( $module_identifier, $title, $args = array(), $rest = false ) { 279 private static function add_module_enable_checkbox($args = array(), $rest = false ) { 280 $args = array_merge( 281 array( 282 'identifier' => '', 283 'title' => '', 284 'label' => null, 285 'description' => null, 286 'enabled' => false, 287 'tab' => '', 288 ), 289 $args 290 ); 291 292 $module_identifier = $args['identifier']; 293 $title = $args['title']; 282 294 $name = self::build_module_enabled_option_name( $module_identifier ); 283 295 register_setting( … … 300 312 return; 301 313 } 302 $args = array( 303 'identifier' => $name, 304 'title' => $title, 305 'label' => $args['label'] ?? null, 306 'description' => $args['description'] ?? null, 307 'value' => $args['enabled'], 308 ); 309 314 // dirty trick: add the separator before premium features as setting field so we don't need to create 315 // separate section for premium features and can keep them separated in the UI with the separator element 316 if (!self::$pro_separator_added && !$args['is_freemium']) { 317 add_settings_field( 318 'wpbbe_pro_separator', 319 self::parse_template('_pro_separator', [], true), 320 function () { }, 321 self::MENU_PAGE_SLUG, 322 WPBBE_PLUGIN_ID . '_settings_section', 323 array( 'class' => 'wpbbe-separator-row wpbbe-plus-separator' ) 324 ); 325 self::$pro_separator_added = true; 326 } 327 $args['module_identifier'] = $module_identifier; 328 $args['identifier'] = $name; 329 $args['value'] = $args['enabled']; 330 $args['class'] = $args['is_freemium'] ? '' : 'wpbbe-plus-feature'; 310 331 add_settings_field( 311 332 $name, 312 333 $title, 313 334 function ( $args ) { 314 self::parse_template( '_checkbox', $args ); 335 self::parse_template('_setting_wrapper', [ 336 'tab' => $args['tab'], 337 'class' => 'wpbbe-module-enable', 338 'module' => $args['module_identifier'], 339 'template' => '_checkbox', 340 'template_args' => $args, 341 ]); 315 342 }, 316 343 self::MENU_PAGE_SLUG, … … 330 357 * @return void 331 358 */ 332 p rivate static function parse_template( $template_name, $args) {359 public static function parse_template( $template_name, $args, $return = false ) { 333 360 $template_full_name = self::TEMPLATES_FOLDER_NAME . $template_name . '.php'; 334 361 335 362 if ( ! is_file( $template_full_name ) || ! is_readable( $template_full_name ) ) { 336 363 throw new Exception( 'Can not read template: ' . esc_html( $template_full_name ) ); 364 } 365 366 if ( $return ) { 367 ob_start(); 368 include $template_full_name; 369 370 return ob_get_clean(); 337 371 } 338 372 … … 410 444 * @return void 411 445 */ 412 private static function add_module_settigns( $module_identifier, $option_key, $field, $rest = false ) { 446 private static function add_module_settigns( $module_data, $option_key, $field, $rest = false ) { 447 $module_identifier = $module_data['identifier']; 413 448 $option_name = self::build_module_settings_name( $module_identifier ); // store all sub options as array 414 449 … … 426 461 switch ( $field['type'] ?? 'text' ) { 427 462 case 'multicheckbox': 428 $ available= $field['options'] ?? array();463 $field_options = $field['options'] ?? array(); 429 464 $output[ $option_key ] = $output[ $option_key ] ?? array(); 430 foreach ( $available as $key => $_ ) { 431 if ( ! empty( $input[ $option_key ][ $key ] ) ) { 432 $output[ $option_key ][ $key ] = 1; 465 466 foreach ( $field_options as $key => $_ ) { 467 $is_disabled = ! empty( $field_options[ $key ]['disabled'] ); 468 //for disabled options we want keep the checkbox disabled and ignore changes from user (use default value) 469 if ( $is_disabled ) { 470 // remove disabled options from the saved settings 471 unset( $output[ $option_key ][ $key ] ); 433 472 } else { 434 unset( $output[ $option_key ][ $key ] ); 435 } 436 } 473 $output[ $option_key ][ $key ] = isset( $input[ $option_key ][ $key ] ) ? 1 : 0; 474 }} 437 475 break; 438 476 case 'checkbox': … … 457 495 return; 458 496 } 497 $title = $field['title'] ?? ''; 459 498 add_settings_field( 460 499 $option_name . '__' . $option_key, 461 $field['label'], 462 function () use ( $module_identifier, $option_key, $field, $option_name ) { 463 $stored_value = get_option( $option_name, array() ); 464 $value = $stored_value[ $option_key ] ?? $field['default']; 465 466 $template_name = '_' . $field['type']; 467 self::parse_template( 468 $template_name, 469 array_merge( 500 $title, 501 function () use ( $module_data, $option_key, $field, $option_name ) { 502 $merged_value = self::get_setting( 503 $option_name, 504 $option_key, 505 $field['default'] ?? null 506 ); 507 508 self::parse_template('_setting_wrapper', [ 509 'tab' => $module_data['tab'], 510 'class' => 'wpbbe-module-setting', 511 'module' => $module_data['identifier'], 512 'template' => '_' . $field['type'], 513 'template_args' => array_merge( 470 514 $field, 471 515 array( 472 516 'identifier' => $option_name . '[' . $option_key . ']', 473 'value' => $ value,517 'value' => $merged_value, 474 518 ) 475 ) 476 );519 ), 520 ]); 477 521 }, 478 522 self::MENU_PAGE_SLUG, … … 480 524 ); 481 525 } 526 527 528 /** 529 * Retrieves a specific setting value for a module, with support for default values and array merging. 530 * 531 * @param string $option_name The name of the option in the database (usually built with build_module_settings_name). 532 * @param string $option_key The specific key of the setting within the module's settings array. 533 * @param mixed $default The default value to return if the setting is not found. Can be an array for settings that are arrays. 534 * 535 * @return mixed The setting value, merged with defaults if it's an array, or the default value if not set. 536 */ 537 public static function get_setting( $option_name, $key, $default = null ) { 538 $stored = get_option( $option_name, null ); 539 540 // If there is no stored value for the module settings, return the default value 541 if ( $stored === null ) { 542 return $default; 543 } 544 545 if ( null === $key ) { 546 return $stored; 547 } 548 549 $value = $stored[ $key ] ?? null; 550 551 // array merge (add new defaults, keep user values) 552 if ( is_array( $default ) && is_array( $value ) ) { 553 return array_replace( $default, $value ); 554 } 555 556 // if value exists use it 557 if ( $value !== null ) { 558 return $value; 559 } 560 // if value does not exist return default 561 return $default; 562 } 482 563 } -
better-block-editor/trunk/Modules/ButtonsResponsive/Module.php
r3386474 r3492699 28 28 29 29 public static function get_label() { 30 return __( 'Add Responsive settings to Buttons block.', 'better-block-editor' );30 return __( 'Add Responsive Settings to Buttons block.', 'better-block-editor' ); 31 31 } 32 32 -
better-block-editor/trunk/Modules/ColumnsResponsive/Module.php
r3386474 r3492699 201 201 202 202 public static function get_label() { 203 return __( 'Add responsiveness settings to Columns block.', 'better-block-editor' );203 return __( 'Add Responsive Settings to Columns block.', 'better-block-editor' ); 204 204 } 205 205 } -
better-block-editor/trunk/Modules/ContactForm7Block/Module.php
r3449829 r3492699 12 12 use BetterBlockEditor\Core\BlockUtils; 13 13 use BetterBlockEditor\Base\ModuleBase; 14 use BetterBlockEditor\Core\Settings; 14 15 use BetterBlockEditor\Modules\StyleEngine\Module as StyleEngineModule; 15 16 … … 166 167 } 167 168 169 public static function get_tab() { 170 return Settings::TAB_BLOCKS; 171 } 172 168 173 public static function get_title() { 169 return __( 'B etter Contact Form 7 Block', 'better-block-editor' );174 return __( 'BBE Contact Form 7', 'better-block-editor' ); 170 175 } 171 176 172 177 public static function get_label() { 173 return __( 'Enable Better Contact Form 7 block.', 'better-block-editor' ); 174 } 178 return __( 'Enable BBE Contact Form 7 block.', 'better-block-editor' ); 179 } 180 175 181 public function render( $attributes ) { 176 182 $id = intval( $attributes['id'] ?? 0 ); … … 235 241 self::DESIGN_STYLES_OPTION => array( 236 242 'type' => 'checkbox', 237 'label' => __( ' Better Contact Form 7 Styles', 'better-block-editor' ),243 'label' => __( 'Enable form styling.', 'better-block-editor' ), 238 244 'default' => 1, 239 'description' => __( ' Enable configurable styles for Better Contact Form 7 block.', 'better-block-editor' ),245 'description' => __( 'When enabled, form styling settings become available in the BBE Contact Form 7 block. If disabled, default theme styles will be used.', 'better-block-editor' ), 240 246 ), 241 247 ); -
better-block-editor/trunk/Modules/DemoContent/Module.php
r3386474 r3492699 10 10 namespace BetterBlockEditor\Modules\DemoContent; 11 11 12 use BetterBlockEditor\Base\ManagableModuleInterface; 12 13 use BetterBlockEditor\Base\ModuleBase; 13 14 use BetterBlockEditor\Modules\DemoContent\AjaxHandlers\ImportContentAjaxHandler; … … 23 24 * Bootstraps Demo Content importer admin experience. 24 25 */ 25 class Module extends ModuleBase {26 class Module extends ModuleBase implements ManagableModuleInterface { 26 27 27 28 const MODULE_IDENTIFIER = 'demo-content'; … … 45 46 */ 46 47 protected $page_hook = null; 48 49 public static function get_title() { 50 return __( 'Site Templates', 'better-block-editor' ); 51 } 52 53 public static function get_label() { 54 return __('Enable BBE pre-made Site Templates', 'better-block-editor' ); 55 } 56 57 public static function get_settings_order() { 58 return 50; 59 } 60 47 61 48 62 /** -
better-block-editor/trunk/Modules/DesignSystemParts/Module.php
r3386474 r3492699 11 11 use BetterBlockEditor\Base\ManagableModuleInterface; 12 12 use BetterBlockEditor\Base\ConfigurableModuleInterface; 13 use BetterBlockEditor\Core\Settings; 13 14 14 15 defined( 'ABSPATH' ) || exit; … … 23 24 public static function get_default_state() { 24 25 return false; 26 } 27 28 public static function get_tab() { 29 return Settings::TAB_DESIGN; 25 30 } 26 31 … … 37 42 // add filter on very late stage to change theme data just before using it in FE 38 43 add_filter( 'wp_theme_json_data_theme', array( $this, 'modify_theme_json_values' ), 1000 ); 39 // exclude parts of design system , later add an option to settings page to control it44 // exclude parts of design system 40 45 add_filter( 'wpbbe_design_system_parts', array( $this, 'filter_design_system_parts' ), 10, 2 ); 41 46 add_action( 'rest_api_init', array( $this, 'register_rest_routes' ) ); … … 43 48 44 49 public function filter_design_system_parts( $parts, $context ) { 45 $active_parts = $this->get_option( self::ACTIVE_PARTS, array());50 $active_parts = $this->get_option( self::ACTIVE_PARTS, self::get_settings()[ self::ACTIVE_PARTS ]['default'] ); 46 51 $map = array( 47 52 'color' => array( 'colorPalette', 'colorGradients' ), … … 197 202 self::ACTIVE_PARTS => array( 198 203 'type' => 'multicheckbox', 199 ' label' => __( 'Design System Parts', 'better-block-editor' ),204 'title' => __( 'Design System Parts', 'better-block-editor' ), 200 205 'options' => array( 201 206 'color' => __( 'Colors', 'better-block-editor' ), 202 207 'typography' => __( 'Typography', 'better-block-editor' ), 208 'spacing' => array( 'label' => __( 'Spacing', 'better-block-editor' ), 'disabled' => true ) 203 209 ), 204 'default' => array( ''),210 'default' => array( 'color'=> 1, 'typography' => 1, 'spacing' => 1 ), 205 211 'description' => __( 'Choose active parts of the design system.', 'better-block-editor' ), 206 212 ), -
better-block-editor/trunk/Modules/GridResponsive/Module.php
r3386474 r3492699 29 29 30 30 public static function get_label() { 31 return __( 'Add responsiveness settings to Grid block.', 'better-block-editor' );31 return __( 'Add Responsive Settings to Grid block.', 'better-block-editor' ); 32 32 } 33 33 -
better-block-editor/trunk/Modules/GroupResponsive/Module.php
r3386474 r3492699 29 29 30 30 public static function get_label() { 31 return __( 'Add responsiveness settings to Group block.', 'better-block-editor' );31 return __( 'Add Responsive Settings to Group block.', 'better-block-editor' ); 32 32 } 33 33 -
better-block-editor/trunk/Modules/NavigationResponsive/Module.php
r3386474 r3492699 111 111 112 112 public static function get_label() { 113 return __( 'Add responsiveness settings to Navigation block.', 'better-block-editor' );113 return __( 'Add Responsive Settings to Navigation block.', 'better-block-editor' ); 114 114 } 115 115 } -
better-block-editor/trunk/Modules/PostTemplateResponsive/Module.php
r3386474 r3492699 28 28 29 29 public static function get_label() { 30 return __( 'Add responsiveness settings to Post Template block.', 'better-block-editor' );30 return __( 'Add Responsive Settings to Post Template block when used in Grid view.', 'better-block-editor' ); 31 31 } 32 32 -
better-block-editor/trunk/Modules/RowResponsive/Module.php
r3386474 r3492699 29 29 30 30 public static function get_label() { 31 return __( 'Add responsiveness settings to Row block.', 'better-block-editor' );31 return __( 'Add Responsive Settings to Row block.', 'better-block-editor' ); 32 32 } 33 33 -
better-block-editor/trunk/Modules/TextResponsive/Module.php
r3386474 r3492699 19 19 const ASSETS_BUILD_PATH = 'editor/blocks/__all__/text-responsive/'; 20 20 21 const SETTINGS_ORDER = 1400;21 const SETTINGS_ORDER = 920; 22 22 23 23 const BLOCK_NAMES = array( … … 33 33 34 34 public static function get_label() { 35 return __( 'Add responsive text alignment settings to Header, Paragraph, Post Title and Post Excerpt blocks.', 'better-block-editor' );35 return __( 'Add Responsive text alignment settings to Header, Paragraph, Post Title and Post Excerpt blocks.', 'better-block-editor' ); 36 36 } 37 37 -
better-block-editor/trunk/Modules/TextStyleFromElement/Module.php
r3443250 r3492699 20 20 const ASSETS_BUILD_PATH = 'editor/blocks/__all__/text-style-from-element/'; 21 21 22 const SETTINGS_ORDER = 1500;22 const SETTINGS_ORDER = 930; 23 23 24 24 const ATTRIBUTE_TEXT_STYLE = 'wpbbeTextStyleFromElement'; … … 34 34 35 35 const TEXT_STYLE_CLASSNAME_PREFIX = 'wpbbe-text-style-from-element-'; 36 36 37 37 public function init(): void { 38 38 … … 57 57 58 58 // settings from the "All Headings" element 59 $all_headings_styling_data = $this->get_text_style_to_borrow( 60 $theme_json_data['styles']['elements'][ self::ALL_HEADINGS_ELEMENT ] ?? array() 59 $all_headings_styling_data = $this->get_text_style_to_borrow( 60 $theme_json_data['styles']['elements'][ self::ALL_HEADINGS_ELEMENT ] ?? array() 61 61 ); 62 62 … … 69 69 $all_headings_styling_data, 70 70 array( 71 'selector' => implode( ', ', 72 array_map( 73 function ( $heading_element ) { 71 'selector' => implode( ', ', 72 array_map( 73 function ( $heading_element ) { 74 74 return str_repeat('.' . self::TEXT_STYLE_CLASSNAME_PREFIX . $heading_element, 2); 75 }, 76 self::HEADING_ELEMENTS 77 ) 75 }, 76 self::HEADING_ELEMENTS 77 ) 78 78 ), 79 79 'context' => 'core', … … 81 81 ); 82 82 } 83 83 84 84 85 85 // individual heading (h1, h2, etc.) settings … … 87 87 if ( in_array( $element_name, self::HEADING_ELEMENTS, true ) ) { 88 88 $heading_element_styling_data = $this->get_text_style_to_borrow( $element_settings ); 89 89 90 90 if ( empty( $heading_element_styling_data ) ) { 91 91 continue; 92 } 92 } 93 93 94 94 StyleEngineModule::get_styles( … … 136 136 // also add the core heading class if the style is taken from a heading element 137 137 $cssClasses[] = self::WP_CORE_HEADING_CLASSNAME; 138 } 138 } 139 139 140 140 $block_content = BlockUtils::append_classes( $block_content, $cssClasses); … … 144 144 145 145 public static function get_title(): string { 146 return __( ' Text Blocks Style', 'better-block-editor' );146 return __( 'Change Style for Text Blocks', 'better-block-editor' ); 147 147 } 148 148 149 149 public static function get_label(): string { 150 return __( 'Add Style setting for Heading, Paragraph, Post Title, and Post Excerpt blocks.', 'better-block-editor' );150 return __( 'Add a "Change style" setting for Heading, Paragraph, Post Title, and Post Excerpt blocks. Select a visual style (H1–H6, Paragraph) for text blocks without changing their HTML tag.', 'better-block-editor' ); 151 151 } 152 152 -
better-block-editor/trunk/Modules/UploadSVG/Module.php
r3386474 r3492699 10 10 use BetterBlockEditor\Base\ModuleBase; 11 11 use BetterBlockEditor\Base\ManagableModuleInterface; 12 use BetterBlockEditor\Core\Settings; 12 13 use enshrined\svgSanitize\Sanitizer; 13 14 … … 493 494 494 495 public static function get_title() { 495 return __( 'Inline SVG', 'better-block-editor' ); 496 return __( 'BBE SVG Icon', 'better-block-editor' ); 497 } 498 499 public static function get_tab() { 500 return Settings::TAB_BLOCKS; 496 501 } 497 502 498 503 public static function get_label() { 499 return __( 'Allow to upload and display the SVG icon', 'better-block-editor' );504 return __( 'Allow uploading SVG images, and enable the BBE SVG Icon block.', 'better-block-editor' ); 500 505 } 501 506 } -
better-block-editor/trunk/Modules/Visibility/Module.php
r3459110 r3492699 2 2 /** 3 3 * Adds responsive visibility settings to all blocks. 4 * Standard approach with ResponsiveBlockModuleBase can not be used here 4 * Standard approach with ResponsiveBlockModuleBase can not be used here 5 5 * as visibility='hidden' must work even without any responsive settings 6 * 6 * 7 7 * @package BetterBlockEditor 8 8 */ … … 24 24 const PLUGIN_ASSETS_BUILD_PATH = 'editor/plugins/visibility/'; 25 25 26 const SETTINGS_ORDER = 100;26 const SETTINGS_ORDER = 990; 27 27 28 28 const ATTRIBUTES = 'wpbbeVisibility'; … … 90 90 return $block_content; 91 91 } 92 92 93 93 /** 94 94 * Helper to get visibility settings from block attributes 95 * 95 * 96 96 * @return array [ visibility, breakpoint, breakpointCustomValue ] 97 97 */ 98 98 private function get_visibility_settings( $attributes ): array { 99 return 99 return 100 100 array( 101 101 $attributes[ self::ATTRIBUTES ]['visibility'] ?? 'visible', // default to visible if not set … … 112 112 if ( null === $switch_width ) { 113 113 if ( $visibility === 'hidden' ) { 114 // if block is always hidden 114 // if block is always hidden 115 115 BlockUtils::add_styles_from_css_rules( 116 116 array( … … 129 129 ".{$class_id}.{$class_id}", 130 130 array( 'display' => 'none !important' ) 131 ); 131 ); 132 132 } 133 133 … … 137 137 138 138 public static function get_label() { 139 return __( 'Add responsive Visibility settings to all blocks.', 'better-block-editor' );139 return __( 'Add Responsive Visibility Settings to all blocks.', 'better-block-editor' ); 140 140 } 141 141 } -
better-block-editor/trunk/admin/templates/settings/_multicheckbox.php
r3386474 r3492699 6 6 <?php endif; ?> 7 7 8 <?php foreach ( $args['options'] as $key => $label ) : 8 <?php foreach ( $args['options'] as $key => $value ) : 9 $disabled = false; 10 $label = ''; 11 if ( is_array( $value ) ) { 12 $label = $value['label'] ?? $key; 13 $disabled = ! empty( $value['disabled'] ); 14 } else { 15 $label = $value; 16 } 9 17 $checked = !empty($args['value'][$key]); 10 18 ?> … … 14 22 name="<?php echo esc_attr( $args['identifier'] . '[' . $key . ']' ); ?>" 15 23 value="1" 24 <?php disabled( $disabled ); ?> 16 25 <?php checked( $checked ); ?> 17 26 /> -
better-block-editor/trunk/admin/templates/settings/breakpoints.php
r3386474 r3492699 5 5 </div> 6 6 7 <button 8 type="button" 9 class="button button-secondary" 7 <button 8 type="button" 9 class="button button-secondary" 10 10 onclick="window.wpbbeSettingsAddBreakpoint(event)" 11 11 > 12 <span 13 class="dashicons dashicons-plus" 14 style="width: auto; height: auto; font-size: 1.2em; vertical-align: middle;" 12 <span 13 class="dashicons dashicons-plus" 14 style="width: auto; height: auto; font-size: 1.2em; vertical-align: middle;" 15 15 title="<?php echo esc_attr( __( 'Add breakpoint', 'better-block-editor' ) ); ?>" 16 16 /> -
better-block-editor/trunk/admin/templates/settings/page.php
r3386474 r3492699 5 5 defined( 'ABSPATH' ) || exit; ?> 6 6 7 <?php 8 $tabs = array( 9 Settings::TAB_FEATURES => array( 10 'label' => __( 'Features', 'better-block-editor' ), 11 ), 12 Settings::TAB_BREAKPOINTS => array( 13 'label' => __( 'Breakpoints', 'better-block-editor' ), 14 ), 15 Settings::TAB_DESIGN => array( 16 'label' => __( 'Design System', 'better-block-editor' ), 17 ), 18 Settings::TAB_BLOCKS => array( 19 'label' => __( 'Blocks', 'better-block-editor' ), 20 ), 21 ); 22 //Allow adding custom tabs 23 $tabs = apply_filters('wpbbe-settings_tabs', $tabs); 24 ?> 25 7 26 <div class="wrap"> 8 9 27 <h1><?php echo esc_html( __( 'Better Block Editor', 'better-block-editor' ) ); ?></h1> 10 28 <nav class="nav-tab-wrapper wpbbe-tabs"> 29 <?php foreach ( $tabs as $tab_slug => $tab ) : ?> 30 <a href="#" 31 class="nav-tab" 32 data-tab="<?php echo esc_attr( $tab_slug ); ?>"> 33 <?php echo esc_html( $tab['label'] ); ?> 34 </a> 35 <?php endforeach; ?> 36 </nav> 11 37 <form action="options.php" method="post"> 12 38 <?php 13 39 settings_fields( WPBBE_PLUGIN_ID . '_settings' ); 14 15 40 do_settings_sections( Settings::MENU_PAGE_SLUG ); 16 17 18 41 submit_button( esc_attr( __( 'Save Settings', 'better-block-editor' ) ) ); 19 42 ?> 20 43 </form> 21 22 44 </div> -
better-block-editor/trunk/better-block-editor.php
r3473824 r3492699 5 5 * Requires at least: 6.8 6 6 * Requires PHP: 7.4 7 * Version: 1. 3.07 * Version: 1.4.0 8 8 * Author: Dream-Theme 9 9 * License: GPLv2 or later … … 21 21 require_once __DIR__ . '/plugin.php'; 22 22 23 define( 'WPBBE_VERSION', '1. 3.0' );23 define( 'WPBBE_VERSION', '1.4.0' ); 24 24 25 25 define( 'WPBBE_FILE', __FILE__ ); -
better-block-editor/trunk/plugin.php
r3386474 r3492699 70 70 return $links; 71 71 }, 10, 2 ); 72 73 $this->bundled_assets_manager = new BundledAssetsManager( WPBBE_PLUGIN_ID, WPBBE_DIST, WPBBE_URL_DIST );74 72 } 75 73 … … 101 99 $this->modules_manager = new ModulesManager(); 102 100 $this->modules_manager->setup_hooks(); 101 102 // in case there is BBE Pro Kit we have to add BBE Pro Kit bundles as dependencies for our bundles 103 // so they are loaded before our bundles (based on defer loading strategy). 104 $dependencies =array(); 105 106 if ( defined('BBE_PRO_KIT_PLUGIN_ID')) { 107 $supported_bundles = array( 108 BundledAssetsManager::EDITOR_BUNDLE, 109 BundledAssetsManager::EDITOR_CONTENT_BUNDLE, 110 BundledAssetsManager::VIEW_BUNDLE, 111 ); 112 113 foreach ( $supported_bundles as $bundle ) { 114 $dependencies[ $bundle ] = array( 115 BundledAssetsManager::build_handle( BBE_PRO_KIT_PLUGIN_ID, $bundle, 'script' ) 116 ); 117 } 118 } 119 120 $this->bundled_assets_manager = new BundledAssetsManager( 121 WPBBE_PLUGIN_ID, 122 WPBBE_DIST, 123 WPBBE_URL_DIST, 124 $dependencies 125 ); 103 126 104 127 if ( $this->is_asset_bundle_mode() ) { … … 130 153 } 131 154 ); 132 133 155 return empty( $disabled_modules ); 134 156 } -
better-block-editor/trunk/readme.txt
r3477947 r3492699 5 5 Tested up to: 6.9 6 6 Requires PHP: 7.4 7 Stable tag: 1. 3.07 Stable tag: 1.4.0 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 11 11 == Description == 12 12 13 https://www.youtube.com/watch?v= WhWGnT5hi-813 https://www.youtube.com/watch?v=YwZZb_XIkJs 14 14 15 15 Better Block Editor (BBE) adds responsive layout controls, hover effects, on-scroll animations, and ready-to-use site templates to Block Editor. It’s not another page builder. It doesn’t replace core blocks or add bloat — BBE just adds the missing settings where needed. It works with your current block theme and plugins, so your existing content stays intact. … … 69 69 * User Guide — [https://docs.wpbbe.io/](https://docs.wpbbe.io/) 70 70 == Changelog == 71 = 1.4.0 (27-03-2026) = 72 1. Improved Better Block Editor settings interface. 73 2. Added option to remove Site Templates link from admin menu. 71 74 = 1.3.0 (03-03-2026) = 72 75 1. Added accessibility enhancements for SVG Icon block. -
better-block-editor/trunk/vendor/composer/installed.php
r3473824 r3492699 2 2 'root' => array( 3 3 'name' => 'dream-theme/better-block-editor', 4 'pretty_version' => 'v1. 3.0',5 'version' => '1. 3.0.0',6 'reference' => ' 151321e2b14e0e968a72c181b9d47a231657e33f',4 'pretty_version' => 'v1.4.0', 5 'version' => '1.4.0.0', 6 'reference' => '694e99ca742cbf09a53c056940dca8a28f513cd3', 7 7 'type' => 'project', 8 8 'install_path' => __DIR__ . '/../../', … … 21 21 ), 22 22 'dream-theme/better-block-editor' => array( 23 'pretty_version' => 'v1. 3.0',24 'version' => '1. 3.0.0',25 'reference' => ' 151321e2b14e0e968a72c181b9d47a231657e33f',23 'pretty_version' => 'v1.4.0', 24 'version' => '1.4.0.0', 25 'reference' => '694e99ca742cbf09a53c056940dca8a28f513cd3', 26 26 'type' => 'project', 27 27 'install_path' => __DIR__ . '/../../',
Note: See TracChangeset
for help on using the changeset viewer.