Server IP : 63.250.38.98 / Your IP : 216.73.216.80 Web Server : LiteSpeed System : Linux premium291.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64 User : samejjip ( 1289) PHP Version : 8.1.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/samejjip/www/wp-content/plugins/extendify/app/Shared/Services/Import/ |
Upload File : |
<?php /** * Import\Images Runner */ namespace Extendify\Shared\Services\Import; defined('ABSPATH') || die('No direct access.'); /** * This class will handle the actual imports */ class ImagesImporterRunner { /** * Process posts content to import external images. * * @return void */ public function run() { // Return early if conditions are not met for processing images. if ( !\get_option('extendify_check_for_image_imports') || \get_transient('extendify_import_images_check_delay') || \wp_get_upload_dir()['error'] ) { return; } // Try to execute set the limit to something that will work forever. // phpcs:ignore WordPress.PHP.NoSilencedErrors, Generic.PHP.NoSilencedErrors.Discouraged if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { // phpcs:ignore WordPress.PHP.NoSilencedErrors, Generic.PHP.NoSilencedErrors.Discouraged @set_time_limit(0); } // Set a marker in the future so we don't check while working. $this->delayProcessing(HOUR_IN_SECONDS); // Get the posts that we need to update. $posts = Post::all(); if (!$posts) { \delete_transient('extendify_import_images_check_delay'); return; } // loop over the posts. foreach ($posts as $post) { // If the post is locked we update the marker to run next hour. if (Post::isLocked($post->ID)) { $this->delayProcessing(15 * MINUTE_IN_SECONDS); continue; } $updatedBlockContent = (new BlocksUpdater())->getModifiedBlocksInPost($post); $status = Post::update($post, $updatedBlockContent); // If something went wrong, check again (much) later. if (is_wp_error($status)) { $this->delayProcessing(6 * HOUR_IN_SECONDS); } }//end foreach // Delete the signal that says there's something to import. if (!Post::countPostsNeedingUpdate()->posts_count) { \delete_option('extendify_check_for_image_imports'); } } /** * Sets a marker to delay processing until later. * * @param mixed $expiration Time until expiration in seconds. Default 86400 (one day). * * @return void */ public function delayProcessing($expiration) { \set_transient('extendify_import_images_check_delay', time(), $expiration); } }