PluginProbe
Analytify – Google Analytics Dashboard For WordPress (GA4 analytics tracking) / trunk
Analytify – Google Analytics Dashboard For WordPress (GA4 analytics tracking) vtrunk
9.1.2 9.1.1 9.1.0 9.0.2 9.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.1.0 1.1.1 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 1.3.1 1.3.2 All 153 releases
wp-analytify / classes / analytify-update-routine.php

analytify-update-routine.php in Analytify – Google Analytics Dashboard For WordPress (GA4 analytics tracking) trunk, at classes/analytify-update-routine.php

76 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName -- File naming is acceptable
2 /**
3 * Update routine class.
4 *
5 * This class handles plugin update routines and version-specific updates.
6 *
7 * @package WP_Analytify
8 * @since 1.0.0
9 */
10
11 // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName -- File name follows project convention
12
13 /**
14 * Update routine class.
15 *
16 * @package WP_Analytify
17 * @since 1.0.0
18 */
19 class Analytify_Update_Routine {
20
21 /**
22 * Current version.
23 *
24 * @var string
25 */
26 private $current_version = '';
27
28 /**
29 * Constructor.
30 *
31 * @param string $current_version The current version.
32 */
33 public function __construct( $current_version ) {
34 $this->current_version = $current_version;
35 $this->run_routines();
36 }
37
38 /**
39 * Run update routines.
40 * This will run all preceding update routine than current version if required.
41 *
42 * @return void
43 */
44 private function run_routines() {
45
46 if ( version_compare( $this->current_version, '4.1.1', '<' ) ) {
47 $this->update_routine_411();
48 }
49
50 // Update version to latest release.
51 update_option( 'analytify_current_version', defined( 'ANALYTIFY_VERSION' ) ? ANALYTIFY_VERSION : '1.0.0' );
52 }
53
54 /**
55 * Update routine for version 4.1.1
56 *
57 * @return void
58 */
59 private function update_routine_411() {
60 update_option( 'analytify_gtag_move_to_notice', 'visible' );
61 }
62 }
63
64 // Get current plugin version.
65 $analytify_current_version = get_option( 'analytify_current_version', '4.1.0' );
66
67 // Upcoming version on which routine will run.
68 $run_routine_ver = '4.1.1';
69
70 // Call update routine.
71 if ( version_compare( $analytify_current_version, $run_routine_ver, '<' ) ) {
72
73 // Note: Analytify_Update_Routine will run all updates preceding the version in $run_routine_ver.
74 new Analytify_Update_Routine( $analytify_current_version );
75 }
76