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