PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 2.4.1
GenerateBlocks v2.4.1
2.4.1 2.4.0 trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.3.0
generateblocks / includes / class-plugin-update.php
generateblocks / includes Last commit date
blocks 2 months ago dynamic-tags 1 month ago pattern-library 1 week ago utils 2 years ago class-do-css.php 3 years ago class-dynamic-content.php 1 month ago class-dynamic-tag-security.php 1 month ago class-enqueue-css.php 1 month ago class-legacy-attributes.php 4 years ago class-map-deprecated-attributes.php 3 years ago class-meta-handler.php 1 month ago class-plugin-update.php 1 year ago class-query-loop.php 2 years ago class-query-utils.php 1 month ago class-render-blocks.php 1 month ago class-rest.php 1 year ago class-save-gate.php 1 month ago class-settings.php 1 year ago dashboard.php 1 month ago defaults.php 1 year ago deprecated.php 1 year ago functions.php 1 month ago general.php 1 month ago
class-plugin-update.php
78 lines
1 <?php
2 /**
3 * Handles option changes on plugin updates.
4 *
5 * @package GenerateBlocks
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit if accessed directly.
10 }
11
12 /**
13 * Process option updates if necessary.
14 */
15 class GenerateBlocks_Plugin_Update extends GenerateBlocks_Singleton {
16 /**
17 * Constructor
18 */
19 public function init() {
20 add_action( 'admin_init', [ $this, 'updates' ], 5 );
21 }
22
23 /**
24 * Implement plugin update logic.
25 *
26 * @since 1.1.0
27 */
28 public function updates() {
29 if ( is_customize_preview() ) {
30 return;
31 }
32
33 $saved_version = get_option( 'generateblocks_version', false );
34
35 if ( false === $saved_version ) {
36 update_option( 'generateblocks_version', sanitize_text_field( GENERATEBLOCKS_VERSION ) );
37
38 // Not an existing install, so no need to proceed further.
39 return;
40 }
41
42 if ( version_compare( $saved_version, GENERATEBLOCKS_VERSION, '=' ) ) {
43 return;
44 }
45
46 if ( version_compare( $saved_version, '2.0.0-alpha.1', '<' ) ) {
47 self::v_2_0_0();
48 }
49
50 // Force regenerate our static CSS files.
51 update_option( 'generateblocks_dynamic_css_posts', array() );
52
53 // Last thing to do is update our version.
54 update_option( 'generateblocks_version', sanitize_text_field( GENERATEBLOCKS_VERSION ) );
55 }
56
57 /**
58 * Update options for version 2.0.0.
59 */
60 public static function v_2_0_0() {
61 $settings = get_option( 'generateblocks', [] );
62
63 // `disable_google_fonts` use to be false by default.
64 // If the user has come from 1.x and they haven't set this option,
65 // set it back to false.
66 if ( empty( $settings['disable_google_fonts'] ) ) {
67 $settings['disable_google_fonts'] = false;
68 }
69
70 update_option( 'generateblocks', $settings );
71
72 // Turn on v1 blocks by default for users coming from 1.x.
73 update_option( 'gb_use_v1_blocks', true, false );
74 }
75 }
76
77 GenerateBlocks_Plugin_Update::get_instance()->init();
78