PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.7.1
GenerateBlocks v1.7.1
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 3 years ago class-do-css.php 3 years ago class-dynamic-content.php 3 years ago class-enqueue-css.php 3 years ago class-legacy-attributes.php 4 years ago class-plugin-update.php 5 years ago class-query-loop.php 3 years ago class-render-blocks.php 3 years ago class-rest.php 3 years ago class-settings.php 4 years ago dashboard.php 3 years ago defaults.php 3 years ago functions.php 3 years ago general.php 3 years ago
class-plugin-update.php
80 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 {
16 /**
17 * Class instance.
18 *
19 * @access private
20 * @var $instance Class instance.
21 */
22 private static $instance;
23
24 /**
25 * Initiator
26 */
27 public static function get_instance() {
28 if ( ! isset( self::$instance ) ) {
29 self::$instance = new self();
30 }
31 return self::$instance;
32 }
33
34 /**
35 * Constructor
36 */
37 public function __construct() {
38 if ( is_admin() ) {
39 add_action( 'admin_init', __CLASS__ . '::init', 5 );
40 } else {
41 add_action( 'wp', __CLASS__ . '::init', 5 );
42 }
43 }
44
45 /**
46 * Implement plugin update logic.
47 *
48 * @since 1.1.0
49 */
50 public static function init() {
51 if ( is_customize_preview() ) {
52 return;
53 }
54
55 $saved_version = get_option( 'generateblocks_version', false );
56
57 if ( false === $saved_version ) {
58 if ( 'admin_init' === current_action() ) {
59 // If we're in the admin, add our version to the database.
60 update_option( 'generateblocks_version', sanitize_text_field( GENERATEBLOCKS_VERSION ) );
61 }
62
63 // Not an existing install, so no need to proceed further.
64 return;
65 }
66
67 if ( version_compare( $saved_version, GENERATEBLOCKS_VERSION, '=' ) ) {
68 return;
69 }
70
71 // Force regenerate our static CSS files.
72 update_option( 'generateblocks_dynamic_css_posts', array() );
73
74 // Last thing to do is update our version.
75 update_option( 'generateblocks_version', sanitize_text_field( GENERATEBLOCKS_VERSION ) );
76 }
77 }
78
79 GenerateBlocks_Plugin_Update::get_instance();
80