Initial commit xmarticaims

This commit is contained in:
2026-11-02 10:26:32 -06:00
commit e74236f5c1
9764 changed files with 2880647 additions and 0 deletions
@@ -0,0 +1,112 @@
<?php
namespace WP_Rocket\Engine\Preload\Admin;
use WP_Rocket\Engine\Preload\Controller\PreloadUrl;
use WP_Rocket\Admin\Options_Data;
class Settings {
/**
* Instance of options handler.
*
* @var Options_Data
*/
protected $options;
/**
* PreloadUrl instance
*
* @var PreloadUrl
*/
private $preload_url;
/**
* Instantiate the class
*
* @param Options_Data $options Instance of options handler.
* @param PreloadUrl $preload_url PreloadUrl instance.
*/
public function __construct( Options_Data $options, PreloadUrl $preload_url ) {
$this->options = $options;
$this->preload_url = $preload_url;
}
/**
* Maybe display the preload notice.
*
* @return void
*/
public function maybe_display_preload_notice() {
if ( ! $this->can_display_notice() ) {
return;
}
if ( false === get_transient( 'wpr_preload_running' ) ) {
return;
}
$boxes = get_user_meta( get_current_user_id(), 'rocket_boxes', true );
if ( in_array( 'preload_notice', (array) $boxes, true ) ) {
return;
}
$message = sprintf(
// translators: %1$s = plugin name.
__( '%1$s: The preload service is now active. After the initial preload it will continue to cache all your pages whenever they are purged. No further action is needed.', 'rocket' ),
'<strong>WP Rocket</strong>'
);
rocket_dismiss_box( 'preload_notice' );
rocket_notice_html(
[
'status' => 'info',
'message' => $message,
'id' => 'rocket-notice-preload-processing',
]
);
}
/**
* Checks if we can display the Preload notices.
*
* @return bool
*/
private function can_display_notice(): bool {
$screen = get_current_screen();
if (
isset( $screen->id )
&&
'settings_page_wprocket' !== $screen->id
) {
return false;
}
if ( ! current_user_can( 'rocket_manage_options' ) ) {
return false;
}
return $this->is_enabled();
}
/**
* Determines if Preload option is enabled.
*
* @return boolean
*/
public function is_enabled(): bool {
return (bool) $this->options->get( 'manual_preload', 0 );
}
/**
* Preload the homepage
*
* @return void
*/
public function preload_homepage() {
$this->preload_url->preload_url( home_url() );
}
}
@@ -0,0 +1,109 @@
<?php
namespace WP_Rocket\Engine\Preload\Admin;
use stdClass;
use WP_Rocket\Admin\Options_Data;
use WP_Rocket\Engine\Preload\Controller\ClearCache;
use WP_Rocket\Event_Management\Subscriber_Interface;
use WP_Rocket\Logger\Logger;
use WP_Rocket\Engine\Admin\Settings\Settings as AdminSettings;
class Subscriber implements Subscriber_Interface {
/**
* Options instance.
*
* @var Options_Data
*/
protected $options;
/**
* Settings instance.
*
* @var Settings
*/
protected $settings;
/**
* Creates an instance of the class.
*
* @param Options_Data $options Options instance.
* @param Settings $settings Settings instance.
*/
public function __construct( Options_Data $options, Settings $settings ) {
$this->options = $options;
$this->settings = $settings;
}
/**
* Return an array of events that this subscriber wants to listen to.
*
* @return array
*/
public static function get_subscribed_events() {
return [
'admin_notices' => [
[ 'maybe_display_preload_notice' ],
],
'rocket_options_changed' => 'preload_homepage',
'switch_theme' => 'preload_homepage',
'rocket_after_clean_used_css' => 'preload_homepage',
'rocket_domain_options_changed' => 'preload_homepage',
'rocket_input_sanitize' => 'sanitize_options',
'wp_rocket_upgrade' => [ 'maybe_clean_cron', 15, 2 ],
];
}
/**
* Maybe display the preload notice.
*
* @return void
*/
public function maybe_display_preload_notice() {
$this->settings->maybe_display_preload_notice();
}
/**
* Preload the homepage after changing the settings
*
* @return void
*/
public function preload_homepage() {
$this->settings->preload_homepage();
}
/**
* Sanitizes Preload Excluded URI option when saving the settings
*
* @param array $input Array of values submitted from the form.
*
* @return array
*/
public function sanitize_options( $input ): array {
if ( empty( $input['preload_excluded_uri'] ) ) {
$input['preload_excluded_uri'] = [];
return $input;
}
$input['preload_excluded_uri'] = rocket_sanitize_textarea_field( 'preload_excluded_uri', $input['preload_excluded_uri'] );
return $input;
}
/**
* Unlock all preload URL on update.
*
* @param string $wp_rocket_version Latest WP Rocket version.
* @param string $actual_version Installed WP Rocket version.
*/
public function maybe_clean_cron( $wp_rocket_version, $actual_version ) {
if ( version_compare( $actual_version, '3.12.5', '<' ) ) {
return;
}
wp_clear_scheduled_hook( 'rocket_preload_revert_old_in_progress_rows' );
}
}