PluginProbe ʕ •ᴥ•ʔ
Gallery : FooGallery / 3.2.6
Gallery : FooGallery v3.2.6
3.3.0 3.1.31 3.1.32 3.1.34 3.1.36 3.2.0 3.2.6 trunk 1.10.3 2.0.24 2.1.34 2.2.44 2.3.3 2.4.32 3.0.6 3.1.11 3.1.12 3.1.13 3.1.20 3.1.25 3.1.26 3.1.26.1 3.1.26.2
foogallery / includes / class-version-check.php
foogallery / includes Last commit date
abilities 3 weeks ago admin 3 weeks ago compatibility 3 weeks ago extensions 3 weeks ago foopluginbase 3 weeks ago public 3 weeks ago thumbs 3 weeks ago asset-manifest.php 3 weeks ago class-attachment-filters.php 3 weeks ago class-command-palette.php 3 weeks ago class-foogallery-animated-gif-support.php 3 weeks ago class-foogallery-attachment-custom-class.php 3 weeks ago class-foogallery-attachment-filename.php 3 weeks ago class-foogallery-attachment-type.php 3 weeks ago class-foogallery-attachment.php 3 weeks ago class-foogallery-cache.php 3 weeks ago class-foogallery-common-fields.php 3 weeks ago class-foogallery-crop-position.php 3 weeks ago class-foogallery-datasource-media_library.php 3 weeks ago class-foogallery-debug.php 3 weeks ago class-foogallery-delayed-runtime-loader.php 3 weeks ago class-foogallery-extensions-compatibility.php 3 weeks ago class-foogallery-force-https.php 3 weeks ago class-foogallery-lazyload.php 3 weeks ago class-foogallery-license-constant-handler.php 3 weeks ago class-foogallery-lightbox.php 3 weeks ago class-foogallery-paging.php 3 weeks ago class-foogallery-password-protect.php 3 weeks ago class-foogallery-sitemaps.php 3 weeks ago class-foogallery-widget.php 3 weeks ago class-foogallery.php 3 weeks ago class-gallery-advanced-settings.php 3 weeks ago class-il8n.php 3 weeks ago class-override-thumbnail.php 3 weeks ago class-posttypes.php 3 weeks ago class-previews.php 3 weeks ago class-retina.php 3 weeks ago class-thumbnail-dimensions.php 3 weeks ago class-thumbnails.php 3 weeks ago class-version-check.php 3 weeks ago constants.php 3 weeks ago functions.php 3 weeks ago gallery-management-functions.php 3 weeks ago includes.php 3 weeks ago index.php 3 weeks ago render-functions.php 3 weeks ago
class-version-check.php
136 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 /**
8 * Created by brad.
9 * Date: 15/11/2015
10 */
11 if ( ! class_exists( 'FooGallery_Version_Check' ) ) {
12
13 class FooGallery_Version_Check {
14
15 /**
16 * Wire up the check so it is done in the admin after admin includes are loaded.
17 */
18 public function wire_up_checker() {
19 if ( is_admin() ) {
20 // When in admin, check if a new version is running.
21 add_action( 'admin_init', array( $this, 'perform_check' ) );
22 }
23 }
24
25 /**
26 * Perform a check to see if the plugin has been updated
27 */
28 public function perform_check() {
29 $stored_version = self::get_stored_version();
30
31 if ( $stored_version != FOOGALLERY_VERSION ) {
32 //This code will run every time the plugin is updated
33
34 //perform all our housekeeping
35 $this->perform_housekeeping( $stored_version );
36
37 //set the current version, so that this does not run again until the next update!
38 update_site_option( FOOGALLERY_OPTION_VERSION, array(
39 'version' => FOOGALLERY_VERSION,
40 'updated_at' => time(),
41 ) );
42 }
43 }
44
45 /**
46 * Get the stored FooGallery version.
47 *
48 * @return string
49 */
50 public static function get_stored_version() {
51 $version_data = get_site_option( FOOGALLERY_OPTION_VERSION );
52
53 if ( is_array( $version_data ) && isset( $version_data['version'] ) ) {
54 return $version_data['version'];
55 }
56
57 return $version_data;
58 }
59
60 /**
61 * Get the last FooGallery update timestamp.
62 *
63 * @return int
64 */
65 public static function get_last_update_time() {
66 $version_data = get_site_option( FOOGALLERY_OPTION_VERSION );
67
68 if ( is_array( $version_data ) && isset( $version_data['updated_at'] ) ) {
69 return absint( $version_data['updated_at'] );
70 }
71
72 return 0;
73 }
74
75 /**
76 * Runs after FooGallery has been updated via the backend
77 *
78 * @param string|false $previous_version The previously stored FooGallery version.
79 */
80 function perform_housekeeping( $previous_version = false ) {
81 //allow extensions or other plugins to do stuff when foogallery is updated
82 // this will catch both manual and auto updates!
83 do_action( 'foogallery_admin_new_version_detected' );
84
85 $this->maybe_force_legacy_runtime_scripts_for_existing_install( $previous_version );
86
87 //we need to clear the foogallery css load optimizations when we update the plugin, to ensure the latest CSS files are loaded
88 foogallery_clear_all_css_load_optimizations();
89 }
90
91 /**
92 * Existing installs should keep the legacy runtime enqueue behavior unless explicitly opted in.
93 *
94 * @param string|false $previous_version The previously stored FooGallery version.
95 *
96 * @return void
97 */
98 private function maybe_force_legacy_runtime_scripts_for_existing_install( $previous_version ) {
99 if ( ! is_string( $previous_version ) || '' === $previous_version || ! version_compare( $previous_version, '3.1.36', '<' ) ) {
100 return;
101 }
102
103 if ( $this->setting_has_explicit_value( 'force_legacy_runtime_scripts' ) ) {
104 return;
105 }
106
107 foogallery_set_setting( 'force_legacy_runtime_scripts', 'on' );
108 }
109
110 /**
111 * Check if a setting is explicitly saved and not only supplied by defaults.
112 *
113 * @param string $key The setting key.
114 *
115 * @return bool
116 */
117 private function setting_has_explicit_value( $key ) {
118 $options = get_option( FOOGALLERY_SLUG );
119
120 if ( is_array( $options ) && array_key_exists( $key, $options ) ) {
121 return true;
122 }
123
124 if ( function_exists( 'is_multisite' ) && is_multisite() ) {
125 $site_options = get_site_option( FOOGALLERY_SLUG );
126
127 if ( is_array( $site_options ) && array_key_exists( $key, $site_options ) ) {
128 return true;
129 }
130 }
131
132 return false;
133 }
134 }
135 }
136