-
Notifications
You must be signed in to change notification settings - Fork 67
Fix: sunset block defaults #3563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6bce616
deprecate block defaults
kaeizen 653ff3c
Update src/welcome/admin.js [skip ci]
bfintal 82594d7
Update src/welcome/admin.js [skip ci]
bfintal 1582de4
Update src/welcome/admin.js
bfintal e4b57c6
minor fix
kaeizen 5d3a6ca
remove test, add note
kaeizen 9069672
Merge branch 'develop' into fix/3500-sunset-block-defaults
kaeizen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| <?php | ||
| /** | ||
| * Block Defaults are deprecated since v3.18.0 | ||
| * | ||
| */ | ||
|
|
||
| // Exit if accessed directly. | ||
| if ( ! defined( 'ABSPATH' ) ) { | ||
| exit; | ||
| } | ||
|
|
||
| if ( ! function_exists( 'stackable_deprecated_block_defaults_option' ) ) { | ||
|
|
||
| function stackable_deprecated_block_defaults_option() { | ||
| // If true, Block Defaults will be enabled in the editor | ||
| register_setting( | ||
| 'stackable_editor_settings', | ||
| 'stackable_enable_block_defaults', | ||
| array( | ||
| 'type' => 'boolean', | ||
| 'description' => __( 'Use Block Defaults in the editor', STACKABLE_I18N ), | ||
| 'sanitize_callback' => 'sanitize_text_field', | ||
| 'show_in_rest' => true, | ||
| 'default' => false, | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| function stackable_add_deprecated_block_defaults_setting( $settings ) { | ||
| $settings['stackable_enable_block_defaults'] = boolval( get_option( 'stackable_enable_block_defaults', false ) ); | ||
| return $settings; | ||
| } | ||
|
|
||
| // Make setting available in the editor. | ||
| add_filter( 'stackable_js_settings', 'stackable_add_deprecated_block_defaults_setting' ); | ||
| add_action( 'init', 'stackable_deprecated_block_defaults_option' ); | ||
| } | ||
|
|
||
| if ( ! function_exists( 'stackable_deprecated_block_defaults' ) ) { | ||
|
|
||
| /** | ||
| * Upon upgrading to v3.18.0 or later, Block Defaults will be enabled only if existing Block Defaults are present; | ||
| * otherwise, they will be disabled. | ||
| * For new installations, Block Defaults will be disabled by default. | ||
| */ | ||
| function stackable_deprecated_block_defaults( $old_version, $new_version ) { | ||
| if ( ! empty( $old_version ) && version_compare( $old_version, "3.18.0", "<" ) ) { | ||
|
|
||
| // set option to true if there are saved block defaults | ||
| if ( ! empty( get_option( 'stackable_block_styles', [] ) ) ) { | ||
| update_option( 'stackable_enable_block_defaults', true, false ); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| function stackable_require_block_defaults_script() { | ||
| if ( get_option( 'stackable_enable_block_defaults', false ) ) { | ||
| require_once( plugin_dir_path( __FILE__ ) . 'block-defaults/custom-block-styles.php' ); | ||
| } | ||
| } | ||
|
|
||
| add_action( 'stackable_early_version_upgraded', 'stackable_deprecated_block_defaults', 10, 2 ); | ||
| add_action( 'init', 'stackable_require_block_defaults_script' ); | ||
| } |
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { settings as stackableSettings } from 'stackable' | ||
|
|
||
| // Conditionally import scripts | ||
| if ( stackableSettings.stackable_enable_block_defaults ) { | ||
| import( './save-block' ) | ||
| import( './global-settings' ) | ||
| } |
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
src/hooks/use-saved-default-block-style.js → ...ve-block/use-saved-default-block-style.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @mxkae
Could you include in this PR of yours these changes of mine to this file #3414 from over 5 months ago?
Thanks.