PluginProbe ʕ •ᴥ•ʔ
Core Web Vitals & PageSpeed Booster / 1.0.12
Core Web Vitals & PageSpeed Booster v1.0.12
trunk 1.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 1.0.25 1.0.26 1.0.27 1.0.28 1.0.29 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.7.1 1.0.7.2 1.0.8 1.0.9
core-web-vitals-pagespeed-booster / core-web-vitals-pagespeed-booster.php
core-web-vitals-pagespeed-booster Last commit date
css-extractor 3 years ago images 3 years ago includes 3 years ago languages 3 years ago core-web-vitals-pagespeed-booster.php 3 years ago readme.txt 3 years ago uninstall.php 3 years ago
core-web-vitals-pagespeed-booster.php
133 lines
1 <?php
2 /*
3 Plugin Name: Core Web Vitals & PageSpeed Booster
4 Description: Do you want to speed up your WordPress site? Fast loading pages improve user experience, increase your pageviews, and help with your WordPress SEO.
5 Version: 1.0.12
6 Author: Magazine3
7 Author URI: https://magazine3.company/
8 Donate link: https://www.paypal.me/Kaludi/25
9 Text Domain: cwvpsb
10 Domain Path: /languages
11 License: GPL2
12 */
13
14 // Exit if accessed directly.
15 if ( ! defined( 'ABSPATH' ) ) exit;
16
17 define('CWVPSB_PLUGIN_DIR', plugin_dir_path( __FILE__ ));
18 define('CWVPSB_PLUGIN_DIR_URI', plugin_dir_url(__FILE__));
19 define('CWVPSB_VERSION','1.0.12');
20 define('CWVPSB_DIR', dirname(__FILE__));
21 define('CWVPSB_BASE', plugin_basename(__FILE__));
22
23
24 /**
25 * Static cache path
26 **/
27 define('CWVPSB_CACHE_DIR', WP_CONTENT_DIR. '/cache/cwvpsb/static/');
28 define('CWVPSB_CACHE_AGGRESIVE_DIR', 'wp-content/cache/cwvpsb/static/');
29 /**
30 * Core images
31 **/
32 define('CWVPSB_IMAGE_DIR',plugin_dir_url(__FILE__).'images/');
33 $host = parse_url(get_site_url())['host'];
34 /**
35 * Font cache path
36 **/
37 define('CWVPSB_CACHE_FONTS_DIR', WP_CONTENT_DIR . "/cache/cwvpsb/fonts/");
38 define('CWVPSB_CACHE_FONTS_URL', site_url("/wp-content/cache/cwvpsb/fonts/"));
39 /**
40 * Critical css cache path
41 **/
42 define('CWVPSB_CRITICAL_CSS_CACHE_DIR', WP_CONTENT_DIR . "/cache/cwvpsb/css/");
43 /**
44 * Js Exclude Cache
45 **/
46
47 define('CWVPSB_JS_EXCLUDE_CACHE_DIR', WP_CONTENT_DIR . "/cache/cwvpsb/excluded-js/");
48 define('CWVPSB_JS_EXCLUDE_CACHE_URL', site_url("/wp-content/cache/cwvpsb/excluded-js/"));
49
50 /**
51 * Js Merging File Cache
52 **/
53 define('CWVPSB_JS_MERGE_FILE_CACHE_DIR', WP_CONTENT_DIR . "/cache/cwvpsb/merged-js/");
54 define('CWVPSB_JS_MERGE_FILE_CACHE_CACHE_URL', site_url("/wp-content/cache/cwvpsb/merged-js/"));
55 /**
56 * CSS Merging File Cache
57 **/
58 define('CWVPSB_CSS_MERGE_FILE_CACHE_DIR', WP_CONTENT_DIR . "/cache/cwvpsb/merged-css/");
59 define('CWVPSB_CSS_MERGE_FILE_CACHE_CACHE_URL', site_url("/wp-content/cache/cwvpsb/merged-css/"));
60 /**
61 * Cache transient
62 **/
63 define('CWVPSB_CACHE_NAME', 'cwvpsb_cleared_timestamp');
64
65 require_once CWVPSB_PLUGIN_DIR."includes/functions.php";
66 require_once CWVPSB_PLUGIN_DIR."includes/admin/helper-function.php";
67
68 add_action('plugins_loaded', 'cwv_pse_initiate');
69 function cwv_pse_initiate(){
70 require_once CWVPSB_PLUGIN_DIR."/includes/helper-section.php";
71 add_filter('wp_handle_upload', array('Core_Web_Vital_Helper_Section', 'do_upload_with_webp'), 10, 2);
72 }
73
74 register_activation_hook( __FILE__, 'cwvpb_on_activate' );
75
76 function cwvpb_on_activate( $network_wide ) {
77 global $wpdb;
78
79 if ( is_multisite() && $network_wide ) {
80 $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
81 foreach ( $blog_ids as $blog_id ) {
82 switch_to_blog( $blog_id );
83 cwvpb_on_install();
84 restore_current_blog();
85 }
86 } else {
87 cwvpb_on_install();
88 }
89 }
90
91 function cwvpb_on_install(){
92
93 global $wpdb;
94
95 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
96
97 $charset_collate = $engine = '';
98
99 if(!empty($wpdb->charset)) {
100 $charset_collate .= " DEFAULT CHARACTER SET {$wpdb->charset}";
101 }
102 if($wpdb->has_cap('collation') AND !empty($wpdb->collate)) {
103 $charset_collate .= " COLLATE {$wpdb->collate}";
104 }
105
106 $found_engine = $wpdb->get_var("SELECT ENGINE FROM `information_schema`.`TABLES` WHERE `TABLE_SCHEMA` = '".DB_NAME."' AND `TABLE_NAME` = '{$wpdb->prefix}posts';");
107
108 if(strtolower($found_engine) == 'innodb') {
109 $engine = ' ENGINE=InnoDB';
110 }
111
112 $found_tables = $wpdb->get_col("SHOW TABLES LIKE '{$wpdb->prefix}cwvpb%';");
113
114 if(!in_array("{$wpdb->prefix}cwvpb_critical_urls", $found_tables)) {
115
116 dbDelta("CREATE TABLE `{$wpdb->prefix}cwvpb_critical_urls` (
117 `id` bigint( 20 ) unsigned NOT NULL AUTO_INCREMENT,
118 `url_id` bigint( 20 ) unsigned NOT NULL,
119 `type` varchar(20),
120 `type_name` varchar(50),
121 `url` varchar(300) NOT NULL,
122 `status` varchar(20) NOT NULL default 'queue',
123 `cached_name` varchar(100),
124 `created_at` datetime NOT NULL,
125 `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
126 `failed_error` text NOT NULL Default '',
127 KEY `url` ( `url` ),
128 PRIMARY KEY (`id`),
129 CONSTRAINT cwvpb_unique UNIQUE (`url`)
130 ) ".$charset_collate.$engine.";");
131 }
132
133 }