Skip to content

Commit

Permalink
Merge pull request #129 from ahmedkaludi/1.0.17
Browse files Browse the repository at this point in the history
1.0.17
  • Loading branch information
akshaywali committed Jan 19, 2024
2 parents 9b92fc3 + 17bbbdb commit ff6d40b
Show file tree
Hide file tree
Showing 325 changed files with 16,242 additions and 11,126 deletions.
14 changes: 7 additions & 7 deletions core-web-vitals-pagespeed-booster.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
Plugin Name: Core Web Vitals & PageSpeed Booster
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.
Version: 1.0.16
Version: 1.0.17
Author: Magazine3
Author URI: https://magazine3.company/
Donate link: https://www.paypal.me/Kaludi/25
Expand All @@ -16,15 +16,15 @@

define('CWVPSB_PLUGIN_DIR', plugin_dir_path( __FILE__ ));
define('CWVPSB_PLUGIN_DIR_URI', plugin_dir_url(__FILE__));
define('CWVPSB_VERSION','1.0.15');
define('CWVPSB_VERSION','1.0.17');
define('CWVPSB_DIR', dirname(__FILE__));
define('CWVPSB_BASE', plugin_basename(__FILE__));


/**
* Static cache path
**/
define('CWVPSB_CACHE_DIR', WP_CONTENT_DIR. '/cache/cwvpsb/static/');
define('CWVPSB_CACHE_DIR', WP_CONTENT_DIR. '/cache/cwvpsb/');
define('CWVPSB_CACHE_AGGRESIVE_DIR', 'wp-content/cache/cwvpsb/static/');
/**
* Core images
Expand Down Expand Up @@ -72,9 +72,9 @@ function cwv_pse_initiate(){
add_filter('wp_handle_upload', array('Core_Web_Vital_Helper_Section', 'do_upload_with_webp'), 10, 2);
}

register_activation_hook( __FILE__, 'cwvpb_on_activate' );
register_activation_hook( __FILE__, 'cwvpsb_on_activate' );

function cwvpb_on_activate( $network_wide ) {
function cwvpsb_on_activate( $network_wide ) {
global $wpdb;

if ( is_multisite() && $network_wide ) {
Expand All @@ -85,11 +85,11 @@ function cwvpb_on_activate( $network_wide ) {
restore_current_blog();
}
} else {
cwvpb_on_install();
cwvpsb_on_install();
}
}

function cwvpb_on_install(){
function cwvpsb_on_install(){

global $wpdb;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ protected function createDomDocumentFromHtml($html)
{
$document = new \DOMDocument('1.0', 'UTF-8');
$internalErrors = libxml_use_internal_errors(true);
$document->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'));
$decodedHtml = htmlspecialchars_decode(html_entity_decode($html, ENT_QUOTES, 'UTF-8'), ENT_QUOTES);
$document->loadHTML($decodedHtml);
libxml_use_internal_errors($internalErrors);
$document->formatOutput = true;

Expand Down
2 changes: 1 addition & 1 deletion css-extractor/vendor/twig/twig/src/Error/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ private function updateRepr()
if (\is_string($this->name) || (\is_object($this->name) && method_exists($this->name, '__toString'))) {
$name = sprintf('"%s"', $this->name);
} else {
$name = json_encode($this->name);
$name = wp_json_encode($this->name);
}
$this->message .= sprintf(' in %s', $name);
}
Expand Down
2 changes: 1 addition & 1 deletion css-extractor/vendor/twig/twig/src/ExtensionSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function getExtensions(): array

public function getSignature(): string
{
return json_encode(array_keys($this->extensions));
return wp_json_encode(array_keys($this->extensions));
}

public function isInitialized(): bool
Expand Down
8 changes: 4 additions & 4 deletions includes/admin/deactivate-feedback.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<div id="cwv-reloaded-feedback-overlay" style="display: none;">
<div id="cwv-reloaded-feedback-content">
<form action="" method="post">
<h3><strong><?php _e('If you have a moment, please let us know why you are deactivating:', 'cwvpsb'); ?></strong></h3>
<h3><strong><?php esc_html_e('If you have a moment, please let us know why you are deactivating:', 'cwvpsb'); ?></strong></h3>
<ul>
<?php
foreach ($reasons as $reason){
Expand All @@ -29,9 +29,9 @@
<?php if ($email) : ?>
<input type="hidden" name="cwv_disable_from" value="<?php echo $email; ?>"/>
<?php endif; ?>
<input id="cwv-reloaded-feedback-submit" class="button button-primary" type="submit" name="cwv_disable_submit" value="<?php _e('Submit & Deactivate', 'cwvpsb'); ?>"/>
<a class="button"><?php _e('Only Deactivate', 'cwvpsb'); ?></a>
<a class="cwv-feedback-not-deactivate" href="#"><?php _e('Don\'t deactivate', 'cwvpsb'); ?></a>
<input id="cwv-reloaded-feedback-submit" class="button button-primary" type="submit" name="cwv_disable_submit" value="<?php esc_html_e('Submit & Deactivate', 'cwvpsb'); ?>"/>
<a class="button"><?php esc_html_e('Only Deactivate', 'cwvpsb'); ?></a>
<a class="cwv-feedback-not-deactivate" href="#"><?php esc_html_e('Don\'t deactivate', 'cwvpsb'); ?></a>
</form>
</div>
</div>
30 changes: 18 additions & 12 deletions includes/admin/helper-function.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@
* @return bool
*/
function cwv_is_plugins_page() {
global $pagenow;

return ( 'plugins.php' === $pagenow );
if(function_exists('get_current_screen')){
$screen = get_current_screen();
if(is_object($screen)){
if($screen->id == 'plugins' || $screen->id == 'plugins-network'){
return true;
}
}
}
return false;
}

/**
Expand Down Expand Up @@ -59,7 +65,7 @@ function cwv_send_feedback() {


if ( ! current_user_can( 'manage_options' ) ) {
echo json_encode(array("status"=> 400, "msg"=>esc_html__("Permission verification failed", 'cwvpsb') ));die;
wp_send_json(array("status"=> 400, "msg"=>esc_html__("Permission verification failed", 'cwvpsb') ));
}

if( isset( $_POST['data'] ) ) {
Expand Down Expand Up @@ -113,18 +119,18 @@ function cwv_enqueue_makebetter_email_js(){
if( !is_admin() && !cwv_is_plugins_page()) {
return;
}

wp_enqueue_script( 'cwv-make-better-js', CWVPSB_PLUGIN_DIR_URI . 'includes/admin/make-better-admin.js', array( 'jquery' ), CWVPSB_VERSION);
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
wp_enqueue_script( 'cwv-make-better-js', CWVPSB_PLUGIN_DIR_URI . "includes/admin/make-better-admin{$min}.js", array( 'jquery' ), CWVPSB_VERSION);
wp_localize_script('cwv-make-better-js', 'cwvpsb_script_vars', array(
'nonce' => wp_create_nonce( 'cwvpsb-admin-nonce' ),
)
);
wp_enqueue_style( 'cwv-make-better-css', CWVPSB_PLUGIN_DIR_URI . 'includes/admin/make-better-admin.css', false , CWVPSB_VERSION );
wp_enqueue_style( 'cwv-make-better-css', CWVPSB_PLUGIN_DIR_URI . "includes/admin/make-better-admin{$min}.css", false , CWVPSB_VERSION );
}

if( is_admin() && cwv_is_plugins_page()) {
add_filter('admin_footer', 'cwv_add_deactivation_feedback_modal');
}

add_filter('admin_footer', 'cwv_add_deactivation_feedback_modal');


function cwvpbs_get_total_urls(){

Expand Down Expand Up @@ -267,11 +273,11 @@ function cwvpsb_send_query_message(){

if($sent){

echo json_encode(array('status'=>'t'));
wp_send_json(array('status'=>'t'));

}else{

echo json_encode(array('status'=>'f'));
wp_send_json(array('status'=>'f'));

}

Expand Down
42 changes: 42 additions & 0 deletions includes/admin/make-better-admin.min.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* makebetter admin css*/

/**
PLUGINS ADMIN PAGE
*/
#cwv-reloaded-feedback-overlay {
/* Height & width depends on how you want to reveal the overlay (see JS below) */
height: 100%;
width: 100%;
position: fixed; /* Stay in place */
z-index: 10000; /* Sit on top */
left: 0;
top: 0;
background-color: rgb(120,120,120); /* Black fallback color */
background-color: rgba(0,0,0, 0.5); /* Black w/opacity */
}
#cwv-reloaded-feedback-content {
position: relative;
top: 25%; /* 25% from the top */
width: 500px;
max-width: 100%;
margin: auto;
margin-top: 30px; /* 30px top margin to avoid conflict with the close button on smaller screens */
max-height: 50%;
padding: 20px;
background-color: #fff;
overflow-y: auto;
}
.mb-box{display: none;width:100%;}
.cwv-feedback-not-deactivate { display: block; text-align: right; }

#cwv-reloaded-feedback-content h3{
margin:5px;
font-size: 1em;
}

@media screen and (max-width:400px){
#cwv-reloaded-feedback-content {
padding:0px;
padding-bottom:50px;
}
}
82 changes: 82 additions & 0 deletions includes/admin/make-better-admin.min.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
var strict;

jQuery(document).ready(function ($) {
/**
* DEACTIVATION FEEDBACK FORM
*/
// show overlay when clicked on "deactivate"
cwv_deactivate_link = $('.wp-admin.plugins-php tr[data-slug="core-web-vitals-pagespeed-booster"] .row-actions .deactivate a');
cwv_deactivate_link_url = cwv_deactivate_link.attr('href');

cwv_deactivate_link.click(function (e) {
e.preventDefault();

// only show feedback form once per 30 days
var c_value = cwv_admin_get_cookie("cwv_hide_deactivate_feedback");

if (c_value === undefined) {
$('#cwv-reloaded-feedback-overlay').show();
} else {
// click on the link
window.location.href = cwv_deactivate_link_url;
}
});
// show text fields
$('#cwv-reloaded-feedback-content input[type="radio"]').click(function () {
// show text field if there is one
var inputValue = $(this).attr("value");
var targetBox = $("." + inputValue);
$(".mb-box").not(targetBox).hide();
$(targetBox).show();
});
// send form or close it
$('#cwv-reloaded-feedback-content .button').click(function (e) {
e.preventDefault();
// set cookie for 30 days
var exdate = new Date();
exdate.setSeconds(exdate.getSeconds() + 2592000);
document.cookie = "cwv_hide_deactivate_feedback=1; expires=" + exdate.toUTCString() + "; path=/";

$('#cwv-reloaded-feedback-overlay').hide();
if ('cwv-reloaded-feedback-submit' === this.id) {
// Send form data
$.ajax({
type: 'POST',
url: ajaxurl,
dataType: 'json',
data: {
action: 'cwv_send_feedback',
data: $('#cwv-reloaded-feedback-content form').serialize()
},
complete: function (MLHttpRequest, textStatus, errorThrown) {
// deactivate the plugin and close the popup
$('#cwv-reloaded-feedback-overlay').remove();
window.location.href = cwv_deactivate_link_url;

}
});
} else {
$('#cwv-reloaded-feedback-overlay').remove();
window.location.href = cwv_deactivate_link_url;
}
});
// close form without doing anything
$('.cwv-feedback-not-deactivate').click(function (e) {
$('#cwv-reloaded-feedback-overlay').hide();
});

function cwv_admin_get_cookie (name) {
var i, x, y, cwv_cookies = document.cookie.split( ";" );
for (i = 0; i < cwv_cookies.length; i++)
{
x = cwv_cookies[i].substr( 0, cwv_cookies[i].indexOf( "=" ) );
y = cwv_cookies[i].substr( cwv_cookies[i].indexOf( "=" ) + 1 );
x = x.replace( /^\s+|\s+$/g, "" );
if (x === name)
{
return unescape( y );
}
}
}

}); // document ready
18 changes: 12 additions & 6 deletions includes/admin/newsletter.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ function cwvpsb_subscribe_to_news_letter(){
return;
}
$name = isset($_POST['name'])?sanitize_text_field($_POST['name']):'';
$email = isset($_POST['email'])?sanitize_text_field($_POST['email']):'';
$website = isset($_POST['website'])?sanitize_text_field($_POST['website']):'';
$email = isset($_POST['email'])?sanitize_email($_POST['email']):'';
$website = isset($_POST['website'])?sanitize_url($_POST['website']):'';

if($email){

Expand All @@ -47,11 +47,17 @@ function cwvpsb_subscribe_to_news_letter(){
);

$response = wp_remote_post( $api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
$response = wp_remote_retrieve_body( $response );
echo $response;
if ( is_wp_error( $response ) ) {
$error_message = $response->get_error_message();
echo "Something went wrong: $error_message";
} else {
$response = wp_remote_retrieve_body( $response );
wp_send_json( $response );
}


}else{
echo 'Email id required';
echo esc_html__('Email id required','cwvpsb');
}

wp_die();
Expand Down Expand Up @@ -80,7 +86,7 @@ function cwvpb_add_localize_footer_data($object, $object_name){
$object['current_user_email'] = $current_user->user_email;
$object['current_user_name'] = $current_user->display_name;
$object['displayID'] = '#menu-settings';
$object['button1'] = 'No Thanks';
$object['button1'] = esc_html__('No Thanks','cwvpsb');
$object['button2'] = false;
$object['function_name'] = '';
$object['ajax_url'] = admin_url( 'admin-ajax.php' );
Expand Down
Loading

0 comments on commit ff6d40b

Please sign in to comment.