File manager - Edit - /home/premiey/www/wp-includes/images/media/astra-rollback.tar
Back
class-astra-rollback-version.php 0000666 00000011454 15165304313 0012756 0 ustar 00 <?php /** * Astra version Rollback file. * * @version 3.6.1 * * @package astra-addon */ if ( ! defined( 'ABSPATH' ) ) { exit(); } /** * Class Astra_Rollback_version. */ class Astra_Rollback_Version { /** * Version. * * Holds the version. * * @since 3.6.1 * @access protected * * @var string Package URL. */ protected $version; /** * Plugin name. * * Holds the theme name. * * @since 3.6.1 * @access protected * * @var string Plugin name. */ protected $theme_name; /** * Theme slug. * * Holds the Theme slug. * * @since 3.6.1 * @access protected * * @var string Theme slug. */ protected $theme_slug; /** * * Initializing Rollback. * * @since 3.6.1 * @access public * * @param array $args arguments for theme rollback. */ public function __construct( $args = array() ) { foreach ( $args as $key => $value ) { $this->{$key} = $value; } } /** * Apply package. * * Change the theme data when WordPress checks for updates. This method * modifies package data to update the theme from a specific URL containing * the version package. * * @since 3.6.1 * @access protected */ protected function apply_package() { $update_themes = get_site_transient( 'update_themes' ); if ( ! is_object( $update_themes ) ) { $update_themes = new stdClass(); } $theme_info = array(); $theme_info['theme'] = $this->theme_slug; $theme_info['new_version'] = $this->version; $theme_info['slug'] = $this->theme_slug; $theme_info['package'] = sprintf( 'https://downloads.wordpress.org/theme/%s.%s.zip', $this->theme_slug, $this->version ); $update_themes->response[ $this->theme_slug ] = $theme_info; set_site_transient( 'update_themes', $update_themes ); } /** * Upgrade. * * Run WordPress upgrade to Rollback to previous version. * * @since 3.6.1 * @access protected */ protected function upgrade() { require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; $theme_name = self::astra_get_white_lable_name(); $upgrader_args = array( 'url' => 'update.php?action=upgrade-theme&theme=' . rawurlencode( $this->theme_slug ), 'theme' => $this->theme_slug, 'nonce' => 'upgrade-theme_' . $this->theme_slug, /* translators: %s: whitelable name and version */ 'title' => sprintf( __( 'Rollback %1$s to version %2$s', 'astra-addon' ), $theme_name, $this->version ), ); $upgrader = new Theme_Upgrader( new Theme_Upgrader_Skin( $upgrader_args ) ); $upgrader->upgrade( $this->theme_slug ); } /** * * Rollback to previous versions. * * @since 3.6.1 * @access public */ public function run() { $this->apply_package(); $this->upgrade(); } /** * Get Rollback versions. * * @since 3.6.1 * @return array * @access public */ public static function get_theme_all_versions() { $rollback_versions = get_transient( 'astra_theme_rollback_versions_' . ASTRA_THEME_VERSION ); if ( ! empty( $rollback_versions ) ) { return $rollback_versions; } $max_versions = apply_filters( 'astra_show_max_rollback_versions', 5 ); $rollback_versions = array(); require_once ABSPATH . 'wp-admin/includes/theme-install.php'; $theme_information = themes_api( 'theme_information', array( 'slug' => 'astra', 'fields' => array( 'versions' => true, ), ) ); if ( empty( $theme_information->versions ) || ! is_array( $theme_information->versions ) ) { return $rollback_versions; } $reverse_theme_versions = array_reverse( $theme_information->versions ); // Reverse the order of array elements. foreach ( $reverse_theme_versions as $version => $download_link ) { $lowercase_version = strtolower( $version ); $is_valid_rollback_version = ! preg_match( '/(trunk|beta|rc|dev)/i', $lowercase_version ); if ( ! $is_valid_rollback_version ) { continue; } if ( version_compare( $version, ASTRA_THEME_VERSION, '>=' ) ) { continue; } $rollback_versions[] = $version; } $rollback_versions = array_slice( $rollback_versions, 0, $max_versions, true ); // Max verisons to be shown. set_transient( 'astra_theme_rollback_versions_' . ASTRA_THEME_VERSION, $rollback_versions, WEEK_IN_SECONDS ); return $rollback_versions; } /** * Get the astra white lable name. */ public static function astra_get_white_lable_name() { $theme_name = __( 'Astra', 'astra-addon' ); $theme_whitelabelled_name = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra', 'name', false ); if ( false !== $theme_whitelabelled_name ) { return $theme_whitelabelled_name; } return $theme_name; } } assets/js/astra-rollback.js 0000666 00000003514 15165304313 0011731 0 ustar 00 /** * Astra Theme rollback version * * @package Astra Addon * @since x.x.x */ (function( $ ) { astRollbackVersion = { init: function() { $( document ).on('change', '.ast-rollback-version-select' , astRollbackVersion.onSelectVersion ); $( document ).on('click', '.ast-rollback-button' , astRollbackVersion.onRollbackClick ); $( document ).on('click', '.ast-confirm-cancel' , astRollbackVersion.closeRollbackPopup ); $( document ).on('click', '.ast-confirm-ok' , astRollbackVersion.onRollbackOk ); }, onSelectVersion:function() { var selectRollback = jQuery( this ); rollbackButton = selectRollback.next( '.ast-rollback-button' ) placeholderUrl = rollbackButton.data( 'placeholder-url' ); rollbackButton.attr( 'href', placeholderUrl.replace( 'VERSION', selectRollback.val() ) ); }, onRollbackClick: function ( e ) { e.preventDefault(); rollbackConfirmText = $('.ast-confirm-text'); versionNumber = $('.ast-rollback-version-select').val(); rollbackConfirmdata = rollbackConfirmText.data('text').replace( '#VERSION#', versionNumber ); rollbackConfirmText.html( rollbackConfirmdata ); document.querySelector('.ast-confirm-rollback-popup').style.display = 'block'; }, closeRollbackPopup: function ( e ) { document.querySelector('.ast-confirm-rollback-popup').style.display = 'none'; }, onRollbackOk:function ( e ) { e.preventDefault(); location.href = $( '.ast-rollback-button' ).attr('href'); astRollbackVersion.closeRollbackPopup( e ); } } $( document ).ready(function() { astRollbackVersion.init(); }); })( jQuery ); assets/css/astra-rollback.css 0000666 00000000346 15165304313 0012261 0 ustar 00 .ast-confirm-rollback-popup .ast-confirm-cancel{ padding: 0px 16px; } .ast-confirm-rollback-popup .ast-confirm-ok{ float:right; padding: 0px 16px; } .postbox .rollback-divider { margin-top: 15px; } class-astra-rollback-version-manager.php 0000666 00000011253 15165304313 0014363 0 ustar 00 <?php /** * Theme Rollback Version manager class file. * * @package astra-addon */ if ( ! defined( 'ABSPATH' ) ) { exit; } /** * Astra Rollback Version manager. */ class Astra_Rollback_Version_Manager { /** * This is set for lage reload cache. * * @var $reload_page_cache */ public static $reload_page_cache = 1; /** * This is set for theme white lable name. * * @var $theme_name */ public $theme_name; /** * Constructor function that initializes required sections. */ public function __construct() { $this->theme_name = Astra_Rollback_version::astra_get_white_lable_name(); add_action( 'admin_notices', array( $this, 'download_rollback_version' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'load_scripts' ) ); } /** * Display Theme Rollback to privious versions form. * * @since 3.6.1 */ public function render_rollback_version_form() { add_action( 'admin_footer', array( $this, 'rollback_version_popup' ) ); // Enqueue scripts only when this function is called. wp_enqueue_script( 'astra-version-rollback' ); wp_enqueue_style( 'astra-version-rollback-css' ); $theme_versions = Astra_Rollback_version::get_theme_all_versions(); if ( empty( $theme_versions ) ) { echo esc_html__( 'No Versions Found! ', 'astra-addon' ); return; } ?> <select class="ast-rollback-version-select"> <?php foreach ( $theme_versions as $version ) { ?> <option value="<?php echo esc_attr( $version ); ?>"><?php echo esc_html( $version ); ?> </option> <?php } ?> </select> <a data-placeholder-text=" <?php echo esc_html__( 'Rollback', 'astra-addon' ); ?>" href="<?php echo esc_url( add_query_arg( 'version_no', $theme_versions[0], wp_nonce_url( admin_url( 'index.php?action=astra-rollback' ), 'astra_rollback' ) ) ); ?>" data-placeholder-url="<?php echo esc_url( wp_nonce_url( admin_url( 'index.php?action=astra-rollback&version_no=VERSION' ), 'astra_rollback' ) ); ?>" class="button ast-rollback-button"><?php echo esc_html__( 'Rollback', 'astra-addon' ); ?> </a> </select> <?php } /** * Download Astra Theme Version here. */ public function download_rollback_version() { if ( ! current_user_can( 'update_themes' ) ) { return false; } if ( empty( $_GET['version_no'] ) || empty( $_GET['action'] ) || 'astra-rollback' !== $_GET['action'] ) { return false; } check_admin_referer( 'astra_rollback' ); $version_no = sanitize_text_field( $_GET['version_no'] ); $theme_slug = 'astra'; $theme_name = 'Astra'; $rollback = new Astra_Rollback_Version( array( 'version' => $version_no, 'theme_name' => $theme_name, 'theme_slug' => $theme_slug, ) ); $rollback->run(); wp_die(); } /** * Version rollback Confirmation popup. * * @since 3.6.1 */ public function rollback_version_popup() { // This is set to fix the duplicate markup on page load. if ( 1 !== self::$reload_page_cache ) { return; } self::$reload_page_cache = 0; ?> <div class="ast-confirm-rollback-popup" style="display:none;"> <div class="bsf-core-rollback-overlay"></div> <div class="bsf-confirm-rollback-popup-content"> <h3 class="bsf-rollback-heading"><?php /* translators: %s: whitelable name */ echo esc_html( sprintf( __( 'Rollback %s Version', 'astra-addon' ), $this->theme_name ) ); ?></h3> <p class="ast-confirm-text" data-text="<?php /* translators: %s: whitelable name */ echo esc_html( sprintf( __( 'Are you sure you want to rollback %s to version #VERSION#?', 'astra-addon' ), $this->theme_name ) ); ?>" ></p> <div class="bsf-confirm-rollback-popup-buttons-wrapper"> <button class="button bsf-product-license button-default ast-confirm-cancel"><?php esc_html_e( 'Cancel', 'astra-addon' ); ?></button> <button class="button button-primary ast-confirm-ok"><?php esc_html_e( 'Continue', 'astra-addon' ); ?></button> </div> </div> </div> <?php } /** * Load Scripts * * @since 3.6.1 * * @param string $hook Current Hook. * @return void */ public function load_scripts( $hook = '' ) { wp_register_script( 'astra-version-rollback', ASTRA_EXT_URI . 'admin/astra-rollback/assets/js/astra-rollback.js', array( 'jquery' ), ASTRA_EXT_VER, true ); wp_register_style( 'astra-version-rollback-css', ASTRA_EXT_URI . 'admin/astra-rollback/assets/css/astra-rollback.css', array(), ASTRA_EXT_VER ); } } new Astra_Rollback_Version_Manager(); /** * Render Rollback versoin form. */ function render_theme_rollback_form() { $instance = new Astra_Rollback_Version_Manager(); $instance->render_rollback_version_form(); }
| ver. 1.4 |
Github
|
.
| PHP 5.4.45 | Generation time: 0 |
proxy
|
phpinfo
|
Settings