Skip to content

Commit b6fd15f

Browse files
authored
Revert "Add global settings for card and text field"
1 parent 8cc470d commit b6fd15f

File tree

19 files changed

+38
-290
lines changed

19 files changed

+38
-290
lines changed

plugin/assets/css/src/customize-controls.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
content: "\f460" !important;
5151
}
5252

53-
& .customize-section-description-container .customize-section-title {
53+
& .customize-section-description-container {
5454
display: none;
5555
}
5656
}

plugin/assets/src/block-editor/blocks/card/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ import edit from './edit';
2727
import save from './save';
2828
import metadata from './block.json';
2929
import { example } from './example';
30-
import { isDefaultCardStyleOutlined } from '../../utils';
31-
metadata.attributes.outlined.default = isDefaultCardStyleOutlined();
30+
3231
const { name } = metadata;
3332

3433
export { metadata, name };

plugin/assets/src/block-editor/blocks/cards-collection/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,9 @@ import edit from './edit';
2727
import save from './save';
2828
import { example } from './example';
2929
import metadata from './block.json';
30-
import { isDefaultCardStyleOutlined } from '../../utils';
3130

3231
const { name } = metadata;
3332

34-
metadata.attributes.outlined.default = isDefaultCardStyleOutlined();
3533
export { metadata, name };
3634

3735
/**

plugin/assets/src/block-editor/blocks/contact-form/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ import { __ } from '@wordpress/i18n';
2525
import edit from './edit';
2626
import save from './save';
2727
import metadata from './block.json';
28-
import { isDefaultTextFieldStyleOutlined } from '../../utils';
29-
30-
metadata.attributes.outlined.default = isDefaultTextFieldStyleOutlined();
3128

3229
const { name } = metadata;
3330

plugin/assets/src/block-editor/blocks/hand-picked-posts/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ import metadata from './block.json';
2727

2828
const { name } = metadata;
2929

30-
import { isDefaultCardStyleOutlined } from '../../utils';
31-
metadata.attributes.outlined.default = isDefaultCardStyleOutlined();
3230
export { metadata, name };
3331

3432
/**

plugin/assets/src/block-editor/blocks/recent-posts/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ import { __ } from '@wordpress/i18n';
2525
import edit from './edit';
2626
import metadata from './block.json';
2727
import { example } from './example';
28-
import { isDefaultCardStyleOutlined } from '../../utils';
2928

3029
const { name } = metadata;
31-
metadata.attributes.outlined.default = isDefaultCardStyleOutlined();
30+
3231
export { metadata, name };
3332

3433
/**

plugin/assets/src/block-editor/utils/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,3 @@
1717
export { default as findIcon } from './find-icon';
1818
export { default as getConfig } from './get-config';
1919
export { default as getIconName } from './get-icon-name';
20-
export { default as isDefaultCardStyleOutlined } from './is-default-card-style-outlined';
21-
export { default as isDefaultTextFieldStyleOutlined } from './is-default-text-field-outlined';

plugin/assets/src/block-editor/utils/is-default-card-style-outlined.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

plugin/assets/src/block-editor/utils/is-default-text-field-outlined.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

plugin/php/class-block-types.php

Lines changed: 13 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -86,27 +86,19 @@ public function register_blocks() {
8686

8787
$blocks_dir = $this->plugin->dir_path . '/assets/js/blocks/';
8888
$block_folders = [
89-
'button' => [],
90-
'card' => [
91-
'outlined' => [ $this, 'is_default_card_style_outlined' ],
92-
],
93-
'cards-collection' => [
94-
'outlined' => [ $this, 'is_default_card_style_outlined' ],
95-
],
96-
'contact-form' => [
97-
'outlined' => [ $this, 'is_default_text_field_style_outlined' ],
98-
],
99-
'data-table' => [],
100-
'hand-picked-posts' => [],
101-
'image-list' => [],
102-
'list' => [],
103-
'recent-posts' => [
104-
'outlined' => [ $this, 'is_default_card_style_outlined' ],
105-
],
106-
'tab-bar' => [],
89+
'button',
90+
'card',
91+
'cards-collection',
92+
'contact-form',
93+
'data-table',
94+
'hand-picked-posts',
95+
'image-list',
96+
'list',
97+
'recent-posts',
98+
'tab-bar',
10799
];
108100

109-
foreach ( $block_folders as $block_name => $override_attributes ) {
101+
foreach ( $block_folders as $block_name ) {
110102
$block_json_file = $blocks_dir . $block_name . '/block.json';
111103
if ( ! file_exists( $block_json_file ) ) {
112104
continue;
@@ -117,10 +109,6 @@ public function register_blocks() {
117109
continue;
118110
}
119111

120-
foreach ( $override_attributes as $attr_key => $attr ) {
121-
$metadata['attributes'][ $attr_key ]['default'] = call_user_func( $attr );
122-
}
123-
124112
$metadata['editor_script'] = 'material-block-editor-js';
125113
$metadata['editor_style'] = 'material-block-editor-css';
126114

@@ -225,9 +213,8 @@ public function enqueue_block_editor_assets() {
225213
'tab_bar_preview' => $this->plugin->asset_url( 'assets/images/preview/tab-bar.jpg' ),
226214
'contact_form_preview' => $this->plugin->asset_url( 'assets/images/preview/contact-form.jpg' ),
227215
'defaults' => [
228-
'blocks' => $this->get_block_defaults(),
229-
'colors' => $this->get_color_defaults(),
230-
'globalStyle' => $this->get_global_styles(),
216+
'blocks' => $this->get_block_defaults(),
217+
'colors' => $this->get_color_defaults(),
231218
],
232219
'customizerUrls' => [
233220
'colors' => add_query_arg( 'autofocus[section]', $slug . '_colors', $customizer_url ),
@@ -321,51 +308,6 @@ public function get_color_defaults() {
321308
return $defaults;
322309
}
323310

324-
/**
325-
* Get global style configs.
326-
*
327-
* @param string $key get single value.
328-
*
329-
* @return array|string
330-
*/
331-
public function get_global_styles( $key = null ) {
332-
$defaults = [];
333-
$controls = $this->plugin->customizer_controls;
334-
335-
foreach ( $controls->get_global_style_controls() as $control ) {
336-
$value = $controls->get_option( $control['id'] );
337-
if ( ! empty( $value ) ) {
338-
$defaults[ $control['id'] ] = $value;
339-
}
340-
}
341-
342-
return ( $key ? ( isset( $defaults[ $key ] ) ? $defaults[ $key ] : '' ) : $defaults );
343-
}
344-
345-
/**
346-
* Whether default card style is outlined.
347-
*
348-
* @return bool
349-
*/
350-
public function is_default_card_style_outlined() {
351-
$style = $this->get_global_styles();
352-
$style = isset( $style['card_style'] ) ? $style['card_style'] : '';
353-
354-
return 'outlined' === $style;
355-
}
356-
357-
/**
358-
* Whether default text field style is outlined.
359-
*
360-
* @return bool
361-
*/
362-
public function is_default_text_field_style_outlined() {
363-
$style = $this->get_global_styles();
364-
$style = isset( $style['text_field_style'] ) ? $style['text_field_style'] : '';
365-
366-
return 'outlined' === $style;
367-
}
368-
369311
/**
370312
* Gets the REST API controller for a post type.
371313
*

0 commit comments

Comments
 (0)