PluginProbe
FlyWP Helper – Page Cache, Page Optimization, Emails for FlyWP Server Control Panel / 1.4.0
FlyWP Helper – Page Cache, Page Optimization, Emails for FlyWP Server Control Panel v1.4.0
1.7.1 1.7.0 1.6.0 1.5.2 trunk 0.1 0.2.0 0.2.1 0.3 0.3.1 0.3.2 0.3.3 0.3.4 0.4 0.4.1 0.4.2 0.4.3 1.0 1.1 1.2 1.3.1 1.4.0 1.4.1 1.5.0 1.5.1 All 26 releases
flywp / includes / Litespeed.php

Litespeed.php in FlyWP Helper – Page Cache, Page Optimization, Emails for FlyWP Server Control Panel 1.4.0, at includes/Litespeed.php

90 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FlyWP;
4
5 class Litespeed {
6
7 public const PLUGIN_SLUG = 'litespeed-cache/litespeed-cache.php';
8 public const OPTION_KEY = 'litespeed.conf.cache';
9
10 /**
11 * Check if LiteSpeed Cache plugin is enabled.
12 *
13 * @return bool
14 */
15 public function is_plugin_active() {
16 return is_plugin_active( self::PLUGIN_SLUG );
17 }
18
19 /**
20 * Check if LiteSpeed Cache plugin is installed.
21 *
22 * @return bool
23 */
24 public function is_plugin_installed() {
25 if ( ! function_exists( 'get_plugins' ) ) {
26 require_once ABSPATH . 'wp-admin/includes/plugin.php';
27 }
28
29 $plugins = get_plugins();
30
31 return isset( $plugins[self::PLUGIN_SLUG] );
32 }
33
34 /**
35 * Check if LiteSpeed Cache is enabled.
36 *
37 * @return bool
38 */
39 public function cache_enabled() {
40 return $this->is_plugin_active() && get_option( self::OPTION_KEY ) === '1';
41 }
42
43 /**
44 * Get cache purge URL.
45 *
46 * @return string
47 */
48 public function purge_cache_url() {
49 if ( ! $this->is_plugin_active() ) {
50 return '';
51 }
52
53 return \LiteSpeed\Utility::build_url(
54 \LiteSpeed\Router::ACTION_PURGE,
55 \LiteSpeed\Purge::TYPE_PURGE_ALL_LSCACHE,
56 false,
57 );
58 }
59
60 /**
61 * Get settings URL.
62 *
63 * @return array
64 */
65 public function settings_url() {
66 if ( $this->is_plugin_active() ) {
67 return [
68 'url' => admin_url( 'admin.php?page=litespeed-cache#cache' ),
69 'text' => __( 'Settings', 'flywp' ),
70 ];
71 } elseif ( $this->is_plugin_installed() ) {
72 return [
73 'url' => wp_nonce_url(
74 admin_url( 'plugins.php?action=activate&plugin=' . self::PLUGIN_SLUG ),
75 'activate-plugin_' . self::PLUGIN_SLUG
76 ),
77 'text' => __( 'Activate Plugin', 'flywp' ),
78 ];
79 }
80
81 return [
82 'url' => wp_nonce_url(
83 admin_url( 'update.php?action=install-plugin&plugin=litespeed-cache' ),
84 'install-plugin_litespeed-cache'
85 ),
86 'text' => __( 'Install Plugin', 'flywp' ),
87 ];
88 }
89 }
90