dvadf
File manager - Edit - /home/theblueo/tv/fb4e3b/history.tar
Back
module.php 0000666 00000004525 15213301453 0006551 0 ustar 00 <?php namespace Elementor\Modules\History; use Elementor\Core\Base\Module as BaseModule; use Elementor\Plugin; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } /** * Elementor history module. * * Elementor history module handler class is responsible for registering and * managing Elementor history modules. * * @since 1.7.0 */ class Module extends BaseModule { /** * Get module name. * * Retrieve the history module name. * * @since 1.7.0 * @access public * * @return string Module name. */ public function get_name() { return 'history'; } /** * Localize settings. * * Add new localized settings for the history module. * * Fired by `elementor/editor/localize_settings` filter. * * @since 1.7.0 * @access public * * @param array $settings Localized settings. * * @return array Localized settings. */ public function localize_settings( $settings ) { $settings = array_replace_recursive( $settings, [ 'i18n' => [ 'history' => __( 'History', 'elementor' ), 'template' => __( 'Template', 'elementor' ), 'added' => __( 'Added', 'elementor' ), 'removed' => __( 'Removed', 'elementor' ), 'edited' => __( 'Edited', 'elementor' ), 'moved' => __( 'Moved', 'elementor' ), 'pasted' => __( 'Pasted', 'elementor' ), 'editing_started' => __( 'Editing Started', 'elementor' ), 'style_pasted' => __( 'Style Pasted', 'elementor' ), 'style_reset' => __( 'Style Reset', 'elementor' ), 'settings_reset' => __( 'Settings Reset', 'elementor' ), 'enabled' => __( 'Enabled', 'elementor' ), 'disabled' => __( 'Disabled', 'elementor' ), 'all_content' => __( 'All Content', 'elementor' ), 'elements' => __( 'Elements', 'elementor' ), ], ] ); return $settings; } /** * @since 2.3.0 * @access public */ public function add_templates() { Plugin::$instance->common->add_template( __DIR__ . '/views/history-panel-template.php' ); Plugin::$instance->common->add_template( __DIR__ . '/views/revisions-panel-template.php' ); } /** * History module constructor. * * Initializing Elementor history module. * * @since 1.7.0 * @access public */ public function __construct() { add_filter( 'elementor/editor/localize_settings', [ $this, 'localize_settings' ] ); add_action( 'elementor/editor/init', [ $this, 'add_templates' ] ); } } views/revisions-panel-template.php 0000666 00000005207 15213301453 0013346 0 ustar 00 <?php if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } ?> <script type="text/template" id="tmpl-elementor-panel-revisions"> <div class="elementor-panel-box"> <div class="elementor-panel-scheme-buttons"> <div class="elementor-panel-scheme-button-wrapper elementor-panel-scheme-discard"> <button class="elementor-button" disabled> <i class="eicon-close" aria-hidden="true"></i> <?php echo __( 'Discard', 'elementor' ); ?> </button> </div> <div class="elementor-panel-scheme-button-wrapper elementor-panel-scheme-save"> <button class="elementor-button elementor-button-success" disabled> <?php echo __( 'Apply', 'elementor' ); ?> </button> </div> </div> </div> <div class="elementor-panel-box"> <div class="elementor-panel-heading"> <div class="elementor-panel-heading-title"><?php echo __( 'Revisions', 'elementor' ); ?></div> </div> <div id="elementor-revisions-list" class="elementor-panel-box-content"></div> </div> </script> <script type="text/template" id="tmpl-elementor-panel-revisions-no-revisions"> <img class="elementor-nerd-box-icon" src="<?php echo ELEMENTOR_ASSETS_URL . 'images/information.svg'; ?>" /> <div class="elementor-nerd-box-title"><?php echo __( 'No Revisions Saved Yet', 'elementor' ); ?></div> <div class="elementor-nerd-box-message">{{{ elementor.translate( elementor.config.document.revisions.enabled ? 'no_revisions_1' : 'revisions_disabled_1' ) }}}</div> <div class="elementor-nerd-box-message">{{{ elementor.translate( elementor.config.document.revisions.enabled ? 'no_revisions_2' : 'revisions_disabled_2' ) }}}</div> </script> <script type="text/template" id="tmpl-elementor-panel-revisions-loading"> <i class="eicon-loading eicon-animation-spin" aria-hidden="true"></i> </script> <script type="text/template" id="tmpl-elementor-panel-revisions-revision-item"> <div class="elementor-revision-item__wrapper {{ type }}"> <div class="elementor-revision-item__gravatar">{{{ gravatar }}}</div> <div class="elementor-revision-item__details"> <div class="elementor-revision-date">{{{ date }}}</div> <div class="elementor-revision-meta"><span>{{{ elementor.translate( type ) }}}</span> <?php echo __( 'By', 'elementor' ); ?> {{{ author }}}</div> </div> <div class="elementor-revision-item__tools"> <# if ( 'current' === type ) { #> <i class="elementor-revision-item__tools-current eicon-star" aria-hidden="true"></i> <span class="elementor-screen-only"><?php echo __( 'Current', 'elementor' ); ?></span> <# } #> <i class="elementor-revision-item__tools-spinner eicon-loading eicon-animation-spin" aria-hidden="true"></i> </div> </div> </script> views/history-panel-template.php 0000666 00000003322 15213301453 0013022 0 ustar 00 <?php if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } ?> <script type="text/template" id="tmpl-elementor-panel-history-page"> <div id="elementor-panel-elements-navigation" class="elementor-panel-navigation"> <div class="elementor-component-tab elementor-panel-navigation-tab" data-tab="actions"><?php echo __( 'Actions', 'elementor' ); ?></div> <div class="elementor-component-tab elementor-panel-navigation-tab" data-tab="revisions"><?php echo __( 'Revisions', 'elementor' ); ?></div> </div> <div id="elementor-panel-history-content"></div> </script> <script type="text/template" id="tmpl-elementor-panel-history-tab"> <div id="elementor-history-list"></div> <div class="elementor-history-revisions-message"><?php echo __( 'Switch to Revisions tab for older versions', 'elementor' ); ?></div> </script> <script type="text/template" id="tmpl-elementor-panel-history-no-items"> <img class="elementor-nerd-box-icon" src="<?php echo ELEMENTOR_ASSETS_URL . 'images/information.svg'; ?>" /> <div class="elementor-nerd-box-title"><?php echo __( 'No History Yet', 'elementor' ); ?></div> <div class="elementor-nerd-box-message"><?php echo __( 'Once you start working, you\'ll be able to redo / undo any action you make in the editor.', 'elementor' ); ?></div> </script> <script type="text/template" id="tmpl-elementor-panel-history-item"> <div class="elementor-history-item__details"> <span class="elementor-history-item__title">{{{ title }}}</span> <span class="elementor-history-item__subtitle">{{{ subTitle }}}</span> <span class="elementor-history-item__action">{{{ action }}}</span> </div> <div class="elementor-history-item__icon"> <span class="eicon" aria-hidden="true"></span> </div> </script> revisions-manager.php 0000666 00000025461 15213301453 0010717 0 ustar 00 <?php namespace Elementor\Modules\History; use Elementor\Core\Base\Document; use Elementor\Core\Common\Modules\Ajax\Module as Ajax; use Elementor\Core\Files\CSS\Post as Post_CSS; use Elementor\Plugin; use Elementor\Utils; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } /** * Elementor history revisions manager. * * Elementor history revisions manager handler class is responsible for * registering and managing Elementor revisions manager. * * @since 1.7.0 */ class Revisions_Manager { /** * Maximum number of revisions to display. */ const MAX_REVISIONS_TO_DISPLAY = 100; /** * Authors list. * * Holds all the authors. * * @access private * * @var array */ private static $authors = []; /** * History revisions manager constructor. * * Initializing Elementor history revisions manager. * * @since 1.7.0 * @access public */ public function __construct() { self::register_actions(); } /** * @since 1.7.0 * @access public * @static */ public static function handle_revision() { add_filter( 'wp_save_post_revision_check_for_changes', '__return_false' ); } /** * @since 2.0.0 * @access public * @static * * @param $post_content * @param $post_id * * @return string */ public static function avoid_delete_auto_save( $post_content, $post_id ) { // Add a temporary string in order the $post will not be equal to the $autosave // in edit-form-advanced.php:210 if ( $post_id && Plugin::$instance->db->is_built_with_elementor( $post_id ) ) { $post_content .= '<!-- Created with Elementor -->'; } return $post_content; } /** * @since 2.0.0 * @access public * @static */ public static function remove_temp_post_content() { global $post; if ( Plugin::$instance->db->is_built_with_elementor( $post->ID ) ) { $post->post_content = str_replace( '<!-- Created with Elementor -->', '', $post->post_content ); } } /** * @since 1.7.0 * @access public * @static * * @param int $post_id * @param array $query_args * @param bool $parse_result * * @return array */ public static function get_revisions( $post_id = 0, $query_args = [], $parse_result = true ) { $post = get_post( $post_id ); if ( ! $post || empty( $post->ID ) ) { return []; } $revisions = []; $default_query_args = [ 'posts_per_page' => self::MAX_REVISIONS_TO_DISPLAY, 'meta_key' => '_elementor_data', ]; $query_args = array_merge( $default_query_args, $query_args ); $posts = wp_get_post_revisions( $post->ID, $query_args ); if ( ! wp_revisions_enabled( $post ) ) { $autosave = Utils::get_post_autosave( $post->ID ); if ( $autosave ) { if ( $parse_result ) { array_unshift( $posts, $autosave ); } else { array_unshift( $posts, $autosave->ID ); } } } if ( $parse_result ) { array_unshift( $posts, $post ); } else { array_unshift( $posts, $post->ID ); return $posts; } $current_time = current_time( 'timestamp' ); /** @var \WP_Post $revision */ foreach ( $posts as $revision ) { $date = date_i18n( _x( 'M j @ H:i', 'revision date format', 'elementor' ), strtotime( $revision->post_modified ) ); $human_time = human_time_diff( strtotime( $revision->post_modified ), $current_time ); if ( $revision->ID === $post->ID ) { $type = 'current'; } elseif ( false !== strpos( $revision->post_name, 'autosave' ) ) { $type = 'autosave'; } else { $type = 'revision'; } if ( ! isset( self::$authors[ $revision->post_author ] ) ) { self::$authors[ $revision->post_author ] = [ 'avatar' => get_avatar( $revision->post_author, 22 ), 'display_name' => get_the_author_meta( 'display_name', $revision->post_author ), ]; } $revisions[] = [ 'id' => $revision->ID, 'author' => self::$authors[ $revision->post_author ]['display_name'], 'timestamp' => strtotime( $revision->post_modified ), 'date' => sprintf( /* translators: 1: Human readable time difference, 2: Date */ __( '%1$s ago (%2$s)', 'elementor' ), $human_time, $date ), 'type' => $type, 'gravatar' => self::$authors[ $revision->post_author ]['avatar'], ]; } return $revisions; } /** * @since 1.9.2 * @access public * @static */ public static function update_autosave( $autosave_data ) { self::save_revision( $autosave_data['ID'] ); } /** * @since 1.7.0 * @access public * @static */ public static function save_revision( $revision_id ) { $parent_id = wp_is_post_revision( $revision_id ); if ( $parent_id ) { Plugin::$instance->db->safe_copy_elementor_meta( $parent_id, $revision_id ); } } /** * @since 1.7.0 * @access public * @static */ public static function restore_revision( $parent_id, $revision_id ) { $is_built_with_elementor = Plugin::$instance->db->is_built_with_elementor( $revision_id ); Plugin::$instance->db->set_is_elementor_page( $parent_id, $is_built_with_elementor ); if ( ! $is_built_with_elementor ) { return; } Plugin::$instance->db->copy_elementor_meta( $revision_id, $parent_id ); $post_css = Post_CSS::create( $parent_id ); $post_css->update(); } /** * @since 2.3.0 * @access public * @static * * @param $data * * @return array * @throws \Exception */ public static function ajax_get_revision_data( array $data ) { if ( ! isset( $data['id'] ) ) { throw new \Exception( 'You must set the revision ID.' ); } $revision = Plugin::$instance->documents->get( $data['id'] ); if ( ! $revision ) { throw new \Exception( 'Invalid revision.' ); } if ( ! current_user_can( 'edit_post', $revision->get_id() ) ) { throw new \Exception( __( 'Access denied.', 'elementor' ) ); } $revision_data = [ 'settings' => $revision->get_settings(), 'elements' => $revision->get_elements_data(), ]; return $revision_data; } /** * @since 1.7.0 * @access public * @static */ public static function add_revision_support_for_all_post_types() { $post_types = get_post_types_by_support( 'elementor' ); foreach ( $post_types as $post_type ) { add_post_type_support( $post_type, 'revisions' ); } } /** * @since 2.0.0 * @access public * @static * @param array $return_data * @param Document $document * * @return array */ public static function on_ajax_save_builder_data( $return_data, $document ) { $post_id = $document->get_main_id(); $latest_revisions = self::get_revisions( $post_id, [ 'posts_per_page' => 1, ] ); $all_revision_ids = self::get_revisions( $post_id, [ 'fields' => 'ids', ], false ); // Send revisions data only if has revisions. if ( ! empty( $latest_revisions ) ) { $current_revision_id = self::current_revision_id( $post_id ); $return_data = array_replace_recursive( $return_data, [ 'config' => [ 'document' => [ 'revisions' => [ 'current_id' => $current_revision_id, ], ], ], 'latest_revisions' => $latest_revisions, 'revisions_ids' => $all_revision_ids, ] ); } return $return_data; } /** * @since 1.7.0 * @access public * @static */ public static function db_before_save( $status, $has_changes ) { if ( $has_changes ) { self::handle_revision(); } } public static function document_config( $settings, $post_id ) { $settings['revisions'] = [ 'enabled' => ( $post_id && wp_revisions_enabled( get_post( $post_id ) ) ), 'current_id' => self::current_revision_id( $post_id ), ]; return $settings; } /** * Localize settings. * * Add new localized settings for the revisions manager. * * Fired by `elementor/editor/editor_settings` filter. * * @since 1.7.0 * @access public * @static */ public static function editor_settings( $settings ) { $settings = array_replace_recursive( $settings, [ 'i18n' => [ 'edit_draft' => __( 'Edit Draft', 'elementor' ), 'edit_published' => __( 'Edit Published', 'elementor' ), 'no_revisions_1' => __( 'Revision history lets you save your previous versions of your work, and restore them any time.', 'elementor' ), 'no_revisions_2' => __( 'Start designing your page and you\'ll be able to see the entire revision history here.', 'elementor' ), 'current' => __( 'Current Version', 'elementor' ), 'restore' => __( 'Restore', 'elementor' ), 'restore_auto_saved_data' => __( 'Restore Auto Saved Data', 'elementor' ), 'restore_auto_saved_data_message' => __( 'There is an autosave of this post that is more recent than the version below. You can restore the saved data fron the Revisions panel', 'elementor' ), 'revision' => __( 'Revision', 'elementor' ), 'revision_history' => __( 'Revision History', 'elementor' ), 'revisions_disabled_1' => __( 'It looks like the post revision feature is unavailable in your website.', 'elementor' ), 'revisions_disabled_2' => sprintf( /* translators: %s: Codex URL */ __( 'Learn more about <a target="_blank" href="%s">WordPress revisions</a>', 'elementor' ), 'https://codex.wordpress.org/Revisions#Revision_Options' ), ], ] ); return $settings; } public static function ajax_get_revisions() { return self::get_revisions(); } /** * @since 2.3.0 * @access public * @static */ public static function register_ajax_actions( Ajax $ajax ) { $ajax->register_ajax_action( 'get_revisions', [ __CLASS__, 'ajax_get_revisions' ] ); $ajax->register_ajax_action( 'get_revision_data', [ __CLASS__, 'ajax_get_revision_data' ] ); } /** * @since 1.7.0 * @access private * @static */ private static function register_actions() { add_action( 'wp_restore_post_revision', [ __CLASS__, 'restore_revision' ], 10, 2 ); add_action( 'init', [ __CLASS__, 'add_revision_support_for_all_post_types' ], 9999 ); add_filter( 'elementor/editor/localize_settings', [ __CLASS__, 'editor_settings' ] ); add_filter( 'elementor/document/config', [ __CLASS__, 'document_config' ], 10, 2 ); add_action( 'elementor/db/before_save', [ __CLASS__, 'db_before_save' ], 10, 2 ); add_action( '_wp_put_post_revision', [ __CLASS__, 'save_revision' ] ); add_action( 'wp_creating_autosave', [ __CLASS__, 'update_autosave' ] ); add_action( 'elementor/ajax/register_actions', [ __CLASS__, 'register_ajax_actions' ] ); // Hack to avoid delete the auto-save revision in WP editor. add_filter( 'edit_post_content', [ __CLASS__, 'avoid_delete_auto_save' ], 10, 2 ); add_action( 'edit_form_after_title', [ __CLASS__, 'remove_temp_post_content' ] ); if ( wp_doing_ajax() ) { add_filter( 'elementor/documents/ajax_save/return_data', [ __CLASS__, 'on_ajax_save_builder_data' ], 10, 2 ); } } /** * @since 1.9.0 * @access private * @static */ private static function current_revision_id( $post_id ) { $current_revision_id = $post_id; $autosave = Utils::get_post_autosave( $post_id ); if ( is_object( $autosave ) ) { $current_revision_id = $autosave->ID; } return $current_revision_id; } }
dvadf
dvadf
| ver. 1.4 |
Github
|
.
| PHP 7.0.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings