| Server IP : 193.146.211.90 / Your IP : 10.85.6.55 Web Server : Apache System : Linux wordpress-gti-69dcdb54f7-n4wdq 6.11.8-arch1-2 #1 SMP PREEMPT_DYNAMIC Fri, 15 Nov 2024 15:35:07 +0000 x86_64 User : 1001 ( 1001) PHP Version : 8.2.25 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /bitnami/wordpress/wp-content/plugins/presto-player/inc/Database/Upgrades/ |
Upload File : |
<?php
namespace PrestoPlayer\Database\Upgrades;
use PrestoPlayer\Plugin;
/**
* Clears pro transients every upgrade to ensure update notifications are immediate
*/
class TransientsUpgrade {
protected $name = 'presto_player_pro_update_transient';
public function run() {
$this->runUpdate();
}
/**
* Checks to see if update is run
*
* @return void
*/
public function runUpdate() {
$current_version = get_option( $this->name, 0 );
// we've done this for the update already
if ( Plugin::version() === $current_version ) {
return;
}
// delete update transient to check for pro upgrade
$this->deleteTransients();
// update version
update_option( $this->name, Plugin::version() );
}
/**
* Delete upgrade transients by key
*
* @return void
*/
public function deleteTransients() {
foreach ( $this->getTransientsWithPrefix( 'presto_player_check_for_plugin_update' ) as $key ) {
delete_site_transient( $key );
}
}
/**
* Gets transients with a specific prefix.
*
* @param string $prefix
* @return array
*/
public function getTransientsWithPrefix( $prefix ) {
global $wpdb;
$prefix = $wpdb->esc_like( '_site_transient_' . $prefix );
$sql = "SELECT `option_name` FROM $wpdb->options WHERE `option_name` LIKE '%s'";
$keys = $wpdb->get_results( $wpdb->prepare( $sql, $prefix . '%' ), ARRAY_A );
if ( is_wp_error( $keys ) ) {
return array();
}
// Remove '_transient_' from the option name.
return array_map(
function ( $key ) {
return ltrim( $key['option_name'], '_transient_' );
},
$keys
);
}
}