Initial commit: Atomaste website

This commit is contained in:
2025-12-10 12:17:30 -05:00
commit 0b9e5d1605
19260 changed files with 5206382 additions and 0 deletions

View File

@@ -0,0 +1,90 @@
<?php
/**
* LiteSpeed Cache Crawler Blocklist
*
* @package LiteSpeed
* @since 1.0.0
*/
namespace LiteSpeed;
defined( 'WPINC' ) || exit;
$crawler_summary = Crawler::get_summary();
$__map = Crawler_Map::cls();
$__admin_display = Admin_Display::cls();
$list = $__map->list_blacklist( 30 );
$count = $__map->count_blacklist();
$pagination = Utility::pagination( $count, 30 );
?>
<p class="litespeed-right">
<a href="<?php echo esc_url( Utility::build_url( Router::ACTION_CRAWLER, Crawler::TYPE_BLACKLIST_EMPTY ) ); ?>" class="button litespeed-btn-warning" data-litespeed-cfm="<?php esc_attr_e( 'Are you sure to delete all existing blocklist items?', 'litespeed-cache' ); ?>">
<?php esc_html_e( 'Empty blocklist', 'litespeed-cache' ); ?>
</a>
</p>
<h3 class="litespeed-title">
<?php esc_html_e( 'Blocklist', 'litespeed-cache' ); ?>
<?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/crawler/#blocklist-tab' ); ?>
</h3>
<?php echo esc_html__( 'Total', 'litespeed-cache' ) . ': ' . esc_html( $count ); ?>
<?php echo wp_kses_post( $pagination ); ?>
<div class="litespeed-table-responsive">
<table class="wp-list-table widefat striped">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col"><?php esc_html_e( 'URL', 'litespeed-cache' ); ?></th>
<th scope="col"><?php esc_html_e( 'Status', 'litespeed-cache' ); ?></th>
<th scope="col"><?php esc_html_e( 'Operation', 'litespeed-cache' ); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ( $list as $i => $v ) : ?>
<tr>
<td><?php echo esc_html( $i + 1 ); ?></td>
<td><?php echo esc_html( $v['url'] ); ?></td>
<td><?php echo wp_kses_post( Crawler::cls()->display_status( $v['res'], $v['reason'] ) ); ?></td>
<td>
<a href="<?php echo esc_url( Utility::build_url( Router::ACTION_CRAWLER, Crawler::TYPE_BLACKLIST_DEL, false, null, array( 'id' => $v['id'] ) ) ); ?>" class="button button-secondary">
<?php esc_html_e( 'Remove from Blocklist', 'litespeed-cache' ); ?>
</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php echo wp_kses_post( $pagination ); ?>
<p>
<span class="litespeed-success">
<?php
printf(
esc_html__( 'API: PHP Constant %s available to disable blocklist.', 'litespeed-cache' ),
'<code>LITESPEED_CRAWLER_DISABLE_BLOCKLIST</code>'
);
?>
</span>
</p>
<p>
<span class="litespeed-success">
<?php
printf(
esc_html__( 'API: Filter %s available to disable blocklist.', 'litespeed-cache' ),
'<code>add_filter( \'litespeed_crawler_disable_blocklist\', \'__return_true\' );</code>'
);
?>
</span>
</p>
<?php $__admin_display->_check_overwritten( 'crawler-blocklist' ); ?>
<p>
<i class="litespeed-dot litespeed-bg-default"></i> = <?php esc_html_e( 'Not blocklisted', 'litespeed-cache' ); ?><br>
<i class="litespeed-dot litespeed-bg-warning"></i> = <?php esc_html_e( 'Blocklisted due to not cacheable', 'litespeed-cache' ); ?><br>
<i class="litespeed-dot litespeed-bg-danger"></i> = <?php esc_html_e( 'Blocklisted', 'litespeed-cache' ); ?><br>
</p>

View File

@@ -0,0 +1,50 @@
<?php
/**
* LiteSpeed Cache Crawler Settings
*
* @package LiteSpeed
* @since 1.0.0
*/
namespace LiteSpeed;
defined( 'WPINC' ) || exit;
$menu_list = [
'summary' => esc_html__( 'Summary', 'litespeed-cache' ),
'map' => esc_html__( 'Map', 'litespeed-cache' ),
'blacklist' => esc_html__( 'Blocklist', 'litespeed-cache' ),
'settings' => esc_html__( 'Settings', 'litespeed-cache' ),
];
?>
<div class="wrap">
<h1 class="litespeed-h1">
<?php esc_html_e( 'LiteSpeed Cache Crawler', 'litespeed-cache' ); ?>
</h1>
<span class="litespeed-desc">
<?php echo esc_html( 'v' . Core::VER ); ?>
</span>
<hr class="wp-header-end">
</div>
<div class="litespeed-wrap">
<h2 class="litespeed-header nav-tab-wrapper">
<?php GUI::display_tab_list( $menu_list ); ?>
</h2>
<div class="litespeed-body">
<?php
foreach ( $menu_list as $menu_key => $menu_value ) {
printf(
'<div data-litespeed-layout="%s">',
esc_attr( $menu_key )
);
require LSCWP_DIR . "tpl/crawler/$menu_key.tpl.php";
echo '</div>';
}
?>
</div>
</div>
<iframe name="litespeedHiddenIframe" src="" width="0" height="0" frameborder="0"></iframe>

View File

@@ -0,0 +1,105 @@
<?php
/**
* LiteSpeed Cache Crawler Sitemap List
*
* @package LiteSpeed
* @since 1.0.0
*/
namespace LiteSpeed;
defined( 'WPINC' ) || exit;
$crawler_summary = Crawler::get_summary();
$__map = Crawler_Map::cls();
$list = $__map->list_map( 30 );
$count = $__map->count_map();
$pagination = Utility::pagination( $count, 30 );
$kw = '';
if (! empty( $_POST['kw'] ) && ! empty( $_POST['_wpnonce'] )) {
$nonce = sanitize_text_field(wp_unslash($_POST['_wpnonce']));
if (wp_verify_nonce($nonce)) {
$kw = sanitize_text_field(wp_unslash($_POST['kw']));
}
}
?>
<p class="litespeed-right">
<a href="<?php echo esc_url( Utility::build_url( Router::ACTION_CRAWLER, Crawler::TYPE_EMPTY ) ); ?>" class="button litespeed-btn-warning">
<?php esc_html_e( 'Clean Crawler Map', 'litespeed-cache' ); ?>
</a>
<a href="<?php echo esc_url( Utility::build_url( Router::ACTION_CRAWLER, Crawler::TYPE_REFRESH_MAP ) ); ?>" class="button button-secondary">
<?php esc_html_e( 'Refresh Crawler Map', 'litespeed-cache' ); ?>
</a>
</p>
<p>
<?php
if ( ! empty( $crawler_summary['sitemap_time'] ) ) {
printf(
esc_html__( 'Generated at %s', 'litespeed-cache' ),
esc_html( Utility::readable_time( $crawler_summary['sitemap_time'] ) )
);
}
?>
</p>
<h3 class="litespeed-title">
<?php esc_html_e( 'Sitemap List', 'litespeed-cache' ); ?>
<?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/crawler/#map-tab' ); ?>
</h3>
<?php echo esc_html__( 'Sitemap Total', 'litespeed-cache' ) . ': ' . esc_html( $count ); ?>
<div style="display: flex; justify-content: space-between;">
<div style="margin-top:10px;">
<form action="<?php echo esc_url( admin_url( 'admin.php?page=litespeed-crawler' ) ); ?>" method="post">
<?php wp_nonce_field(); ?>
<input type="text" name="kw" value="<?php echo esc_attr( $kw ); ?>" placeholder="<?php esc_attr_e( 'URL Search', 'litespeed-cache' ); ?>" style="width: 600px;" />
</form>
</div>
<div>
<a style="padding-right:10px;" href="<?php echo esc_url( admin_url( 'admin.php?page=litespeed-crawler&' . Router::TYPE . '=hit' ) ); ?>"><?php esc_html_e( 'Cache Hit', 'litespeed-cache' ); ?></a>
<a style="padding-right:10px;" href="<?php echo esc_url( admin_url( 'admin.php?page=litespeed-crawler&' . Router::TYPE . '=miss' ) ); ?>"><?php esc_html_e( 'Cache Miss', 'litespeed-cache' ); ?></a>
<a style="padding-right:10px;" href="<?php echo esc_url( admin_url( 'admin.php?page=litespeed-crawler&' . Router::TYPE . '=blacklisted' ) ); ?>"><?php esc_html_e( 'Blocklisted', 'litespeed-cache' ); ?></a>
</div>
<div>
<?php echo wp_kses_post( $pagination ); ?>
</div>
</div>
<div class="litespeed-table-responsive">
<table class="wp-list-table widefat striped">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col"><?php esc_html_e( 'URL', 'litespeed-cache' ); ?></th>
<th scope="col"><?php esc_html_e( 'Crawler Status', 'litespeed-cache' ); ?></th>
<th scope="col"><?php esc_html_e( 'Operation', 'litespeed-cache' ); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ( $list as $i => $v ) : ?>
<tr>
<td><?php echo esc_html( $i + 1 ); ?></td>
<td><?php echo esc_html( $v['url'] ); ?></td>
<td><?php echo wp_kses_post( Crawler::cls()->display_status( $v['res'], $v['reason'] ) ); ?></td>
<td>
<a href="<?php echo esc_url( Utility::build_url( Router::ACTION_CRAWLER, Crawler::TYPE_BLACKLIST_ADD, false, null, array( 'id' => $v['id'] ) ) ); ?>" class="button button-secondary">
<?php esc_html_e( 'Add to Blocklist', 'litespeed-cache' ); ?>
</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php echo wp_kses_post( $pagination ); ?>
<p>
<i class="litespeed-dot litespeed-bg-success"></i> = <?php esc_html_e( 'Cache Hit', 'litespeed-cache' ); ?><br>
<i class="litespeed-dot litespeed-bg-primary"></i> = <?php esc_html_e( 'Cache Miss', 'litespeed-cache' ); ?><br>
<i class="litespeed-dot litespeed-bg-warning"></i> = <?php esc_html_e( 'Blocklisted due to not cacheable', 'litespeed-cache' ); ?><br>
<i class="litespeed-dot litespeed-bg-danger"></i> = <?php esc_html_e( 'Blocklisted', 'litespeed-cache' ); ?><br>
</p>

View File

@@ -0,0 +1,189 @@
<?php
/**
* LiteSpeed Cache Crawler General Settings
*
* @package LiteSpeed
* @since 1.0.0
*/
namespace LiteSpeed;
defined( 'WPINC' ) || exit;
$this->form_action();
?>
<h3 class="litespeed-title-short">
<?php esc_html_e( 'Crawler General Settings', 'litespeed-cache' ); ?>
<?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/crawler/#general-settings-tab' ); ?>
</h3>
<table class="wp-list-table striped litespeed-table">
<tbody>
<tr>
<th>
<?php $option_id = Base::O_CRAWLER; ?>
<?php $this->title( $option_id ); ?>
</th>
<td>
<?php $this->build_switch( $option_id ); ?>
<div class="litespeed-desc">
<?php esc_html_e( 'This will enable crawler cron.', 'litespeed-cache' ); ?>
<br><?php Doc::notice_htaccess(); ?>
</div>
</td>
</tr>
<tr>
<th>
<?php $option_id = Base::O_CRAWLER_CRAWL_INTERVAL; ?>
<?php $this->title( $option_id ); ?>
</th>
<td>
<?php $this->build_input( $option_id ); ?> <?php esc_html_e( 'seconds', 'litespeed-cache' ); ?>
<div class="litespeed-desc">
<?php esc_html_e( 'Specify how long in seconds before the crawler should initiate crawling the entire sitemap again.', 'litespeed-cache' ); ?>
<?php $this->recommended( $option_id ); ?>
</div>
</td>
</tr>
<tr>
<th>
<?php $option_id = Base::O_CRAWLER_SITEMAP; ?>
<?php $this->title( $option_id ); ?>
</th>
<td>
<?php $this->build_textarea( $option_id ); ?>
<div class="litespeed-desc">
<?php esc_html_e( 'The crawler will use your XML sitemap or sitemap index. Enter the full URL to your sitemap here.', 'litespeed-cache' ); ?>
<?php Doc::one_per_line(); ?>
</div>
</td>
</tr>
<tr>
<th>
<?php $option_id = Base::O_CRAWLER_LOAD_LIMIT; ?>
<?php $this->title( $option_id ); ?>
</th>
<td>
<?php $this->build_input( $option_id ); ?>
<div class="litespeed-desc">
<?php esc_html_e( 'The maximum average server load allowed while crawling. The number of crawler threads in use will be actively reduced until average server load falls under this limit. If this cannot be achieved with a single thread, the current crawler run will be terminated.', 'litespeed-cache' ); ?>
<?php if ( ! empty( $_SERVER[ Base::ENV_CRAWLER_LOAD_LIMIT_ENFORCE ] ) ) : ?>
<span class="litespeed-warning">
<?php esc_html_e( 'NOTE', 'litespeed-cache' ); ?>:
<?php
printf(
esc_html__( 'Server enforced value: %s', 'litespeed-cache' ),
'<code>' . esc_html( sanitize_text_field( wp_unslash( $_SERVER[ Base::ENV_CRAWLER_LOAD_LIMIT_ENFORCE ] ) ) ) . '</code>'
);
?>
</span>
<?php elseif ( ! empty( $_SERVER[ Base::ENV_CRAWLER_LOAD_LIMIT ] ) ) : ?>
<span class="litespeed-warning">
<?php esc_html_e( 'NOTE', 'litespeed-cache' ); ?>:
<?php
printf(
esc_html__( 'Server allowed max value: %s', 'litespeed-cache' ),
'<code>' . esc_html( sanitize_text_field( wp_unslash( $_SERVER[ Base::ENV_CRAWLER_LOAD_LIMIT ] ) ) ) . '</code>'
);
?>
</span>
<?php endif; ?>
<br>
<?php $this->_api_env_var( Base::ENV_CRAWLER_LOAD_LIMIT, Base::ENV_CRAWLER_LOAD_LIMIT_ENFORCE ); ?>
</div>
</td>
</tr>
<tr>
<th>
<?php $option_id = Base::O_CRAWLER_ROLES; ?>
<?php $this->title( $option_id ); ?>
</th>
<td>
<?php $this->build_textarea( $option_id, 20 ); ?>
<div class="litespeed-desc">
<?php esc_html_e( 'To crawl the site as a logged-in user, enter the user ids to be simulated.', 'litespeed-cache' ); ?>
<?php Doc::one_per_line(); ?>
<?php if ( empty( $this->conf( Base::O_SERVER_IP ) ) ) : ?>
<div class="litespeed-danger litespeed-text-bold">
🚨 <?php esc_html_e( 'NOTICE', 'litespeed-cache' ); ?>:
<?php
printf(
esc_html__( 'You must set %s before using this feature.', 'litespeed-cache' ),
esc_html( Lang::title( Base::O_SERVER_IP ) )
);
?>
<?php
Doc::learn_more(
esc_url( admin_url( 'admin.php?page=litespeed-general#settings' ) ),
esc_html__( 'Click here to set.', 'litespeed-cache' ),
true,
false,
true
);
?>
</div>
<?php endif; ?>
<?php if ( empty( $this->conf( Base::O_ESI ) ) ) : ?>
<div class="litespeed-danger litespeed-text-bold">
🚨 <?php esc_html_e( 'NOTICE', 'litespeed-cache' ); ?>:
<?php
printf(
esc_html__( 'You must set %1$s to %2$s before using this feature.', 'litespeed-cache' ),
esc_html( Lang::title( Base::O_ESI ) ),
esc_html__( 'ON', 'litespeed-cache' )
);
?>
<?php
Doc::learn_more(
esc_url( admin_url( 'admin.php?page=litespeed-cache#esi' ) ),
esc_html__( 'Click here to set.', 'litespeed-cache' ),
true,
false,
true
);
?>
</div>
<?php endif; ?>
</div>
</td>
</tr>
<tr>
<th>
<?php $option_id = Base::O_CRAWLER_COOKIES; ?>
<?php $this->title( $option_id ); ?>
</th>
<td>
<?php $this->enroll( $option_id . '[name][]' ); ?>
<?php $this->enroll( $option_id . '[vals][]' ); ?>
<div id="litespeed_crawler_simulation_div"></div>
<script type="text/babel">
ReactDOM.render(
<CrawlerSimulate list={ <?php echo wp_json_encode( $this->conf( $option_id ) ); ?> } />,
document.getElementById( 'litespeed_crawler_simulation_div' )
);
</script>
<div class="litespeed-desc">
<?php esc_html_e( 'To crawl for a particular cookie, enter the cookie name, and the values you wish to crawl for. Values should be one per line. There will be one crawler created per cookie value, per simulated role.', 'litespeed-cache' ); ?>
<?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/crawler/#cookie-simulation' ); ?>
<p>
<?php
printf(
esc_html__( 'Use %1$s in %2$s to indicate this cookie has not been set.', 'litespeed-cache' ),
'<code>_null</code>',
esc_html__( 'Cookie Values', 'litespeed-cache' )
);
?>
</p>
</div>
</td>
</tr>
</tbody>
</table>
<?php $this->form_end(); ?>

View File

@@ -0,0 +1,521 @@
<?php
/**
* LiteSpeed Cache Crawler Summary
*
* @package LiteSpeed
* @since 1.0.0
*/
namespace LiteSpeed;
defined( 'WPINC' ) || exit;
$__crawler = Crawler::cls();
$crawler_list = $__crawler->list_crawlers();
$summary = Crawler::get_summary();
if ( $summary['curr_crawler'] >= count( $crawler_list ) ) {
$summary['curr_crawler'] = 0;
}
$is_running = time() - $summary['is_running'] <= 900;
$disabled = Router::can_crawl() ? '' : 'disabled';
$disabled_tip = '';
if ( ! $this->conf( Base::O_CRAWLER_SITEMAP ) ) {
$disabled = 'disabled';
$disabled_tip = '<span class="litespeed-callout notice notice-error inline litespeed-left20">' . sprintf(
esc_html__( 'You need to set the %s in Settings first before using the crawler', 'litespeed-cache' ),
'<code>' . esc_html( Lang::title( Base::O_CRAWLER_SITEMAP ) ) . '</code>'
) . '</span>';
}
$crawler_run_interval = defined( 'LITESPEED_CRAWLER_RUN_INTERVAL' ) ? LITESPEED_CRAWLER_RUN_INTERVAL : 600;
if ( $crawler_run_interval > 0 ) :
$recurrence = '';
$hours = (int) floor( $crawler_run_interval / 3600 );
if ( $hours ) {
$recurrence .= sprintf(
$hours > 1 ? esc_html__( '%d hours', 'litespeed-cache' ) : esc_html__( '%d hour', 'litespeed-cache' ),
$hours
);
}
$minutes = (int) floor( ( $crawler_run_interval % 3600 ) / 60 );
if ( $minutes ) {
$recurrence .= ' ';
$recurrence .= sprintf(
$minutes > 1 ? esc_html__( '%d minutes', 'litespeed-cache' ) : esc_html__( '%d minute', 'litespeed-cache' ),
$minutes
);
}
?>
<h3 class="litespeed-title litespeed-relative">
<?php esc_html_e( 'Crawler Cron', 'litespeed-cache' ); ?>
<?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/crawler/' ); ?>
</h3>
<?php if ( ! Router::can_crawl() ) : ?>
<div class="litespeed-callout notice notice-error inline">
<h4><?php esc_html_e( 'WARNING', 'litespeed-cache' ); ?></h4>
<p><?php esc_html_e( 'The crawler feature is not enabled on the LiteSpeed server. Please consult your server admin or hosting provider.', 'litespeed-cache' ); ?></p>
<p>
<?php
printf(
/* translators: %s: Link tags */
esc_html__( 'See %sIntroduction for Enabling the Crawler%s for detailed information.', 'litespeed-cache' ),
'<a href="https://docs.litespeedtech.com/lscache/lscwp/admin/#enabling-and-limiting-the-crawler" target="_blank" rel="noopener">',
'</a>'
);
?>
</p>
</div>
<?php endif; ?>
<?php if ( $summary['this_full_beginning_time'] ) : ?>
<p>
<b><?php esc_html_e( 'Current sitemap crawl started at', 'litespeed-cache' ); ?>:</b>
<?php echo esc_html( Utility::readable_time( $summary['this_full_beginning_time'] ) ); ?>
</p>
<?php if ( ! $is_running ) : ?>
<p>
<b><?php esc_html_e( 'The next complete sitemap crawl will start at', 'litespeed-cache' ); ?>:</b>
<?php echo esc_html( gmdate( 'm/d/Y H:i:s', $summary['this_full_beginning_time'] + LITESPEED_TIME_OFFSET + (int) $summary['last_full_time_cost'] + $this->conf( Base::O_CRAWLER_CRAWL_INTERVAL ) ) ); ?>
</p>
<?php endif; ?>
<?php endif; ?>
<?php if ( $summary['last_full_time_cost'] ) : ?>
<p>
<b><?php esc_html_e( 'Last complete run time for all crawlers', 'litespeed-cache' ); ?>:</b>
<?php printf( esc_html__( '%d seconds', 'litespeed-cache' ), (int) $summary['last_full_time_cost'] ); ?>
</p>
<?php endif; ?>
<?php if ( $summary['last_crawler_total_cost'] ) : ?>
<p>
<b><?php esc_html_e( 'Run time for previous crawler', 'litespeed-cache' ); ?>:</b>
<?php printf( esc_html__( '%d seconds', 'litespeed-cache' ), (int) $summary['last_crawler_total_cost'] ); ?>
</p>
<?php endif; ?>
<?php if ( $summary['curr_crawler_beginning_time'] ) : ?>
<p>
<b><?php esc_html_e( 'Current crawler started at', 'litespeed-cache' ); ?>:</b>
<?php echo esc_html( Utility::readable_time( $summary['curr_crawler_beginning_time'] ) ); ?>
</p>
<?php endif; ?>
<p>
<b><?php esc_html_e( 'Current server load', 'litespeed-cache' ); ?>:</b>
<?php echo esc_html( $__crawler->get_server_load() ); ?>
</p>
<?php if ( $summary['last_start_time'] ) : ?>
<p class="litespeed-desc">
<b><?php esc_html_e( 'Last interval', 'litespeed-cache' ); ?>:</b>
<?php echo esc_html( Utility::readable_time( $summary['last_start_time'] ) ); ?>
</p>
<?php endif; ?>
<?php if ( $summary['end_reason'] ) : ?>
<p class="litespeed-desc">
<b><?php esc_html_e( 'Ended reason', 'litespeed-cache' ); ?>:</b>
<?php echo esc_html( $summary['end_reason'] ); ?>
</p>
<?php endif; ?>
<?php if ( $summary['last_crawled'] ) : ?>
<p class="litespeed-desc">
<b><?php esc_html_e( 'Last crawled', 'litespeed-cache' ); ?>:</b>
<?php
printf(
esc_html__( '%d item(s)', 'litespeed-cache' ),
esc_html( $summary['last_crawled'] )
);
?>
</p>
<?php endif; ?>
<p>
<a href="<?php echo esc_url( Utility::build_url( Router::ACTION_CRAWLER, Crawler::TYPE_RESET ) ); ?>" class="button litespeed-btn-warning"><?php esc_html_e( 'Reset position', 'litespeed-cache' ); ?></a>
<a href="<?php echo Router::can_crawl() ? esc_url( Utility::build_url( Router::ACTION_CRAWLER, Crawler::TYPE_START ) ) : 'javascript:;'; ?>" id="litespeed_manual_trigger" class="button litespeed-btn-success" litespeed-accesskey="R" <?php echo wp_kses_post( $disabled ); ?>><?php esc_html_e( 'Manually run', 'litespeed-cache' ); ?></a>
<?php echo wp_kses_post( $disabled_tip ); ?>
</p>
<div class="litespeed-table-responsive">
<table class="wp-list-table widefat striped" data-crawler-list>
<thead>
<tr>
<th scope="col">#</th>
<th scope="col"><?php esc_html_e( 'Cron Name', 'litespeed-cache' ); ?></th>
<th scope="col"><?php esc_html_e( 'Run Frequency', 'litespeed-cache' ); ?></th>
<th scope="col"><?php esc_html_e( 'Status', 'litespeed-cache' ); ?></th>
<th scope="col"><?php esc_html_e( 'Activate', 'litespeed-cache' ); ?></th>
<th scope="col"><?php esc_html_e( 'Running', 'litespeed-cache' ); ?></th>
</tr>
</thead>
<tbody>
<?php
foreach ( $crawler_list as $i => $v ) :
$hit = ! empty( $summary['crawler_stats'][ $i ][ Crawler::STATUS_HIT ] ) ? (int) $summary['crawler_stats'][ $i ][ Crawler::STATUS_HIT ] : 0;
$miss = ! empty( $summary['crawler_stats'][ $i ][ Crawler::STATUS_MISS ] ) ? (int) $summary['crawler_stats'][ $i ][ Crawler::STATUS_MISS ] : 0;
$blacklisted = ! empty( $summary['crawler_stats'][ $i ][ Crawler::STATUS_BLACKLIST ] ) ? (int) $summary['crawler_stats'][ $i ][ Crawler::STATUS_BLACKLIST ] : 0;
$blacklisted += ! empty( $summary['crawler_stats'][ $i ][ Crawler::STATUS_NOCACHE ] ) ? (int) $summary['crawler_stats'][ $i ][ Crawler::STATUS_NOCACHE ] : 0;
$waiting = isset( $summary['crawler_stats'][ $i ][ Crawler::STATUS_WAIT ] )
? (int) $summary['crawler_stats'][ $i ][ Crawler::STATUS_WAIT ]
: (int) ( $summary['list_size'] - $hit - $miss - $blacklisted );
?>
<tr>
<td>
<?php
echo esc_html( $i + 1 );
if ( $i === $summary['curr_crawler'] ) {
echo '<img class="litespeed-crawler-curr" src="' . esc_url( LSWCP_PLUGIN_URL . 'assets/img/Litespeed.icon.svg' ) . '" alt="Current Crawler">';
}
?>
</td>
<td><?php echo wp_kses_post( $v['title'] ); ?></td>
<td><?php echo esc_html( $recurrence ); ?></td>
<td>
<?php
printf(
'<i class="litespeed-badge litespeed-bg-default" data-balloon-pos="up" aria-label="%s">%s</i> ',
esc_attr__( 'Waiting', 'litespeed-cache' ),
esc_html( $waiting > 0 ? $waiting : '-' )
);
printf(
'<i class="litespeed-badge litespeed-bg-success" data-balloon-pos="up" aria-label="%s">%s</i> ',
esc_attr__( 'Hit', 'litespeed-cache' ),
esc_html( $hit > 0 ? $hit : '-' )
);
printf(
'<i class="litespeed-badge litespeed-bg-primary" data-balloon-pos="up" aria-label="%s">%s</i> ',
esc_attr__( 'Miss', 'litespeed-cache' ),
esc_html( $miss > 0 ? $miss : '-' )
);
printf(
'<i class="litespeed-badge litespeed-bg-danger" data-balloon-pos="up" aria-label="%s">%s</i> ',
esc_attr__( 'Blocklisted', 'litespeed-cache' ),
esc_html( $blacklisted > 0 ? $blacklisted : '-' )
);
?>
</td>
<td>
<?php $this->build_toggle( 'litespeed-crawler-' . $i, $__crawler->is_active( $i ) ); ?>
<?php if ( ! empty( $v['uid'] ) && empty( $this->conf( Base::O_SERVER_IP ) ) ) : ?>
<div class="litespeed-danger litespeed-text-bold">
🚨 <?php esc_html_e( 'NOTICE', 'litespeed-cache' ); ?>:
<?php
printf(
esc_html__( 'You must set %s before using this feature.', 'litespeed-cache' ),
esc_html( Lang::title( Base::O_SERVER_IP ) )
);
?>
<?php
Doc::learn_more(
esc_url( admin_url( 'admin.php?page=litespeed-general#settings' ) ),
esc_html__( 'Click here to set.', 'litespeed-cache' ),
true,
false,
true
);
?>
</div>
<?php endif; ?>
</td>
<td>
<?php
if ( $i === $summary['curr_crawler'] ) {
echo esc_html__( 'Position: ', 'litespeed-cache' ) . esc_html( $summary['last_pos'] + 1 );
if ( $is_running ) {
echo ' <span class="litespeed-label-success">' . esc_html__( 'running', 'litespeed-cache' ) . '</span>';
}
}
?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<p>
<i class="litespeed-badge litespeed-bg-default"></i> = <?php esc_html_e( 'Waiting to be Crawled', 'litespeed-cache' ); ?><br>
<i class="litespeed-badge litespeed-bg-success"></i> = <?php esc_html_e( 'Already Cached', 'litespeed-cache' ); ?><br>
<i class="litespeed-badge litespeed-bg-primary"></i> = <?php esc_html_e( 'Successfully Crawled', 'litespeed-cache' ); ?><br>
<i class="litespeed-badge litespeed-bg-danger"></i> = <?php esc_html_e( 'Blocklisted', 'litespeed-cache' ); ?><br>
</p>
<div class="litespeed-desc">
<div><?php esc_html_e( 'Run frequency is set by the Interval Between Runs setting.', 'litespeed-cache' ); ?></div>
<div>
<?php
esc_html_e( 'Crawlers cannot run concurrently. If both the cron and a manual run start at similar times, the first to be started will take precedence.', 'litespeed-cache' );
?>
</div>
<div>
<?php
printf(
/* translators: %s: Link tags */
esc_html__( 'Please see %sHooking WP-Cron Into the System Task Scheduler%s to learn how to create the system cron task.', 'litespeed-cache' ),
'<a href="https://developer.wordpress.org/plugins/cron/hooking-wp-cron-into-the-system-task-scheduler/" target="_blank" rel="noopener">',
'</a>'
);
?>
</div>
</div>
<?php
endif;
?>
<h3 class="litespeed-title"><?php esc_html_e( 'Watch Crawler Status', 'litespeed-cache' ); ?></h3>
<?php
$ajax_url = $__crawler->json_path();
if ( $ajax_url ) :
?>
<input type="button" id="litespeed-crawl-url-btn" value="<?php esc_attr_e( 'Show crawler status', 'litespeed-cache' ); ?>" class="button button-secondary" data-url="<?php echo esc_url( $ajax_url ); ?>" />
<div class="litespeed-shell litespeed-hide">
<div class="litespeed-shell-header-bar"></div>
<div class="litespeed-shell-header">
<div class="litespeed-shell-header-bg"></div>
<div class="litespeed-shell-header-icon-container">
<img id="litespeed-shell-icon" src="<?php echo esc_url( LSWCP_PLUGIN_URL . 'assets/img/Litespeed.icon.svg' ); ?>" alt="LiteSpeed Icon" />
</div>
</div>
<ul class="litespeed-shell-body">
<li><?php esc_html_e( 'Start watching...', 'litespeed-cache' ); ?></li>
<li id="litespeed-loading-dot"></li>
</ul>
</div>
<?php else : ?>
<p><?php esc_html_e( 'No crawler meta file generated yet', 'litespeed-cache' ); ?></p>
<?php endif; ?>
<script>
var _litespeed_meta;
var _litespeed_shell_interval = 3; // seconds
var _litespeed_shell_interval_range = [3, 60];
var _litespeed_shell_handle;
var _litespeed_shell_display_handle;
var _litespeed_crawler_url;
var _litespeed_dots;
(function ($) {
'use strict';
jQuery(document).ready(function () {
$('#litespeed-crawl-url-btn').on('click', function () {
if (!$(this).data('url')) {
return false;
}
$('.litespeed-shell').removeClass('litespeed-hide');
_litespeed_dots = window.setInterval(_litespeed_loading_dots, 300);
_litespeed_crawler_url = $(this).data('url');
litespeed_fetch_meta();
$(this).hide();
});
$('#litespeed_manual_trigger').on('click', function (event) {
$('#litespeed-loading-dot').before('<li>Manually Started</li>');
_litespeed_shell_interval = _litespeed_shell_interval_range[0];
litespeed_fetch_meta();
});
/**
* Freeze or melt a specific crawler
* @since 4.3
*/
if ($('[data-crawler-list] [data-litespeed_toggle_id]').length > 0) {
$('[data-crawler-list] [data-litespeed_toggle_id]').on('click', function (e) {
var crawler_id = $(this).attr('data-litespeed_toggle_id');
var crawler_id = Number(crawler_id.split('-').pop());
var that = this;
$.ajax({
url: '<?php echo function_exists('get_rest_url') ? get_rest_url(null, 'litespeed/v1/toggle_crawler_state') : '/'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>',
dataType: 'json',
method: 'POST',
cache: false,
data: { crawler_id: crawler_id },
beforeSend: function (xhr) {
xhr.setRequestHeader('X-WP-Nonce', '<?php echo esc_js( wp_create_nonce('wp_rest') ); ?>');
},
success: function (data) {
$(that)
.toggleClass('litespeed-toggle-btn-default litespeed-toggleoff', data == 0)
.toggleClass('litespeed-toggle-btn-primary', data == 1);
console.log('litespeed-crawler-ajax: change Activate option');
},
error: function (xhr, error) {
console.log(xhr);
console.log(error);
console.log('litespeed-crawler-ajax: option failed to save due to some error');
},
});
});
}
});
})(jQuery);
function litespeed_fetch_meta() {
window.clearTimeout(_litespeed_shell_handle);
jQuery('#litespeed-loading-dot').text('');
jQuery.ajaxSetup({ cache: false });
jQuery.getJSON(_litespeed_crawler_url, function (meta) {
litespeed_pulse();
var changed = false;
if (meta && 'list_size' in meta) {
new_meta =
meta.list_size + ' ' + meta.file_time + ' ' + meta.curr_crawler + ' ' + meta.last_pos + ' ' + meta.last_count + ' ' + meta.last_start_time + ' ' + meta.is_running;
if (new_meta != _litespeed_meta) {
_litespeed_meta = new_meta;
changed = true;
string = _litespeed_build_meta(meta);
jQuery('#litespeed-loading-dot').before(string);
// remove first log elements
log_length = jQuery('.litespeed-shell-body li').length;
if (log_length > 50) {
jQuery('.litespeed-shell-body li:lt(' + (log_length - 50) + ')').remove();
}
// scroll to end
jQuery('.litespeed-shell-body')
.stop()
.animate(
{
scrollTop: jQuery('.litespeed-shell-body')[0].scrollHeight,
},
800,
);
}
// dynamic adjust the interval length
_litespeed_adjust_interval(changed);
}
// display interval counting
litespeed_display_interval_reset();
_litespeed_shell_handle = window.setTimeout(_litespeed_dynamic_timeout, _litespeed_shell_interval * 1000);
});
}
function _litespeed_loading_dots() {
jQuery('#litespeed-loading-dot').append('.');
}
/**
* Dynamic adjust interval
*/
function _litespeed_adjust_interval(changed) {
if (changed) {
_litespeed_shell_interval -= Math.ceil(_litespeed_shell_interval / 2);
} else {
_litespeed_shell_interval++;
}
if (_litespeed_shell_interval < _litespeed_shell_interval_range[0]) {
_litespeed_shell_interval = _litespeed_shell_interval_range[0];
}
if (_litespeed_shell_interval > _litespeed_shell_interval_range[1]) {
_litespeed_shell_interval = _litespeed_shell_interval_range[1];
}
}
function _litespeed_build_meta(meta) {
var string =
'<li>' +
litespeed_date(meta.last_update_time) +
'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Size: ' +
meta.list_size +
'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Crawler: #' +
(meta.curr_crawler * 1 + 1) +
'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Position: ' +
(meta.last_pos * 1 + 1) +
'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Threads: ' +
meta.last_count +
'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Status: ';
if (meta.is_running) {
string += 'crawling, ' + meta.last_status;
} else {
string += meta.end_reason ? meta.end_reason : '-';
}
string += '</li>';
return string;
}
function _litespeed_dynamic_timeout() {
litespeed_fetch_meta();
}
function litespeed_display_interval_reset() {
window.clearInterval(_litespeed_shell_display_handle);
jQuery('.litespeed-shell-header-bar').data('num', _litespeed_shell_interval);
_litespeed_shell_display_handle = window.setInterval(_litespeed_display_interval, 1000);
jQuery('.litespeed-shell-header-bar')
.stop()
.animate({ width: '100%' }, 500, function () {
jQuery('.litespeed-shell-header-bar').css('width', '0%');
});
}
function _litespeed_display_interval() {
var num = jQuery('.litespeed-shell-header-bar').data('num');
jQuery('.litespeed-shell-header-bar')
.stop()
.animate({ width: litespeed_get_percent(num, _litespeed_shell_interval) + '%' }, 1000);
if (num > 0) num--;
if (num < 0) num = 0;
jQuery('.litespeed-shell-header-bar').data('num', num);
}
function litespeed_get_percent(num1, num2) {
num1 = num1 * 1;
num2 = num2 * 1;
num = (num2 - num1) / num2;
return num * 100;
}
function litespeed_date(timestamp) {
var a = new Date(timestamp * 1000);
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
var year = a.getFullYear();
var month = months[a.getMonth()];
var date = litespeed_add_zero(a.getDate());
var hour = litespeed_add_zero(a.getHours());
var min = litespeed_add_zero(a.getMinutes());
var sec = litespeed_add_zero(a.getSeconds());
var time = date + ' ' + month + ' ' + year + ' ' + hour + ':' + min + ':' + sec;
return time;
}
function litespeed_add_zero(i) {
if (i < 10) {
i = '0' + i;
}
return i;
}
function litespeed_pulse() {
jQuery('#litespeed-shell-icon').animate(
{
width: 27,
height: 34,
opacity: 1,
},
700,
function () {
jQuery('#litespeed-shell-icon').animate(
{
width: 23,
height: 29,
opacity: 0.5,
},
700,
);
},
);
}
</script>