文件操作 - theme-updater.php
返回文件管理
返回主菜单
删除本文件
文件: /storage/v12552/jimbrandstatter/public_html/wp-content/themes/Total/inc/updates/theme-updater.php
编辑文件内容
<?php namespace TotalTheme\Updates; \defined( 'ABSPATH' ) || exit; /** * Provides updates for the Total theme. */ final class Theme_Updater { /** * Total theme updater API url. */ private const API_URL = 'https://wpexplorer-updates.com/api/v1/'; /** * Active theme license. * * @return string */ private $theme_license; /** * Instance. * * @access private * @var object Class object. */ private static $instance; /** * Create or retrieve the instance of Theme_Updater. */ public static function instance() { if ( \is_null( static::$instance ) ) { static::$instance = new self(); static::$instance->init_hooks(); } return static::$instance; } /** * Run action hooks. */ public function init_hooks() { if ( ! $this->is_enabled() ) { return; } // This is for testing only !!!! //set_site_transient( 'update_themes', null ); if ( $this->get_theme_license() ) { \add_filter( 'pre_set_site_transient_update_themes', [ $this, 'check_for_update' ] ); } } /** * Returns the active theme license. */ private function get_theme_license() { if ( \is_null( $this->theme_license ) ) { $this->theme_license = wpex_get_theme_license(); } return $this->theme_license; } /** * Checks if auto updates are enabled. */ public function is_enabled() { return (bool) \apply_filters( 'totaltheme/updates/theme_updater/is_enabled', true ); } /** * Makes a call to the API. */ private function call_api( $action, $params ) { $api = \add_query_arg( $params, self::API_URL . $action ); $request = \wp_safe_remote_get( $api ); if ( \is_wp_error( $request ) ) { return false; } $body = \wp_remote_retrieve_body( $request ); return \json_decode( $body ); } /** * Checks the API response to see if there was an error. */ private function is_api_error( $response ) { if ( $response === false || ! \is_object( $response ) || isset( $response->error ) ) { return true; } return false; } /** * Calls the License Manager API to get the license information for the * current product. */ private function get_license_info() { return $this->call_api( 'info', [ 'theme' => 'Total', 'license' => \urlencode( \sanitize_text_field( $this->get_theme_license() ) ), ] ); } /** * Check for updates. */ private function update_request() { $license_info = $this->get_license_info(); if ( $this->is_api_error( $license_info ) ) { return false; } return $license_info; } /** * The filter that checks if there are updates to the theme. */ public function check_for_update( $transient ) { if ( empty( $transient->checked ) ) { return $transient; } // Query API for updates. $update = $this->update_request(); if ( $this->is_api_error( $update ) ) { return $transient; } $theme = \wp_get_theme( 'Total' ); // Update is available. if ( isset( $update->version ) && isset( $update->package ) && \version_compare( $theme->get( 'Version' ), $update->version, '<' ) ) { $transient->response['Total'] = [ 'theme' => 'Total', 'new_version' => $update->version, 'package' => $update->package, 'requires' => $update->requires ?? '', 'requires_php' => $update->requires_php ?? '', 'url' => $update->changelog ?? \WPEX_THEME_CHANGELOG_URL, ]; } return $transient; } }
修改文件时间
将文件时间修改为当前时间的前一年
删除文件