- WordPress core y plugins - Tema Twenty Twenty-Four configurado - Plugin allow-unfiltered-html.php simplificado - .gitignore configurado para excluir wp-config.php y uploads 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
201 lines
4.2 KiB
PHP
Executable File
201 lines
4.2 KiB
PHP
Executable File
<?php
|
||
/**
|
||
* WPPDF Review Class
|
||
*
|
||
* @since 5.1.0
|
||
*
|
||
* @package WP-PDF-Secure
|
||
*/
|
||
|
||
// Exit if accessed directly.
|
||
if ( ! defined( 'ABSPATH' ) ) {
|
||
exit;
|
||
}
|
||
|
||
/**
|
||
* Review Class
|
||
*
|
||
* @since 5.1.0
|
||
*/
|
||
class WPPDF_Review {
|
||
|
||
/**
|
||
* Holds the class object.
|
||
*
|
||
* @since 1.1.4.5
|
||
*
|
||
* @var object
|
||
*/
|
||
public static $instance;
|
||
|
||
/**
|
||
* Path to the file.
|
||
*
|
||
* @since 1.1.4.5
|
||
*
|
||
* @var string
|
||
*/
|
||
public $file = __FILE__;
|
||
|
||
/**
|
||
* Holds the review slug.
|
||
*
|
||
* @since 1.1.4.5
|
||
*
|
||
* @var string
|
||
*/
|
||
public $hook;
|
||
|
||
/**
|
||
* Holds the base class object.
|
||
*
|
||
* @since 1.1.4.5
|
||
*
|
||
* @var object
|
||
*/
|
||
public $base;
|
||
|
||
/**
|
||
* API Username.
|
||
*
|
||
* @since 1.1.4.5
|
||
*
|
||
* @var bool|string
|
||
*/
|
||
public $user = false;
|
||
|
||
|
||
/**
|
||
* Primary class constructor.
|
||
*
|
||
* @since 1.1.4.5
|
||
*/
|
||
public function __construct() {
|
||
|
||
add_action( 'admin_notices', array( $this, 'review' ) );
|
||
add_action( 'wp_ajax_wppdf_dismiss_review', array( $this, 'dismiss_review' ) );
|
||
|
||
}
|
||
|
||
/**
|
||
* Add admin notices as needed for reviews.
|
||
*
|
||
* @since 1.1.6.1
|
||
*/
|
||
public function review() {
|
||
|
||
// Verify that we can do a check for reviews.
|
||
$review = get_option( 'wppdf_review' );
|
||
$activation_time = get_option( 'wppdf_emb_activation', false );
|
||
$time = time();
|
||
$load = false;
|
||
|
||
if ( ! $review ) {
|
||
$review = array(
|
||
'time' => $time,
|
||
'dismissed' => false,
|
||
);
|
||
$load = true;
|
||
} else {
|
||
// Check if it has been dismissed or not.
|
||
if ( ( isset( $review['dismissed'] ) && ! $review['dismissed'] ) && ( isset( $review['time'] ) ) ) {
|
||
$load = true;
|
||
}
|
||
}
|
||
|
||
// If we cannot load, return early.
|
||
if ( ! $load ) {
|
||
return;
|
||
}
|
||
|
||
// Bail if activation time isnt set.
|
||
if ( ! $activation_time ) {
|
||
return;
|
||
}
|
||
$valid = false;
|
||
if ( intval( time() ) >= intval( strtotime( '+7 day', $activation_time ) ) ) {
|
||
$valid = true;
|
||
} else {
|
||
$valid = false;
|
||
}
|
||
|
||
// if there hasnt been enough time, dont show.
|
||
if ( ! $valid ) {
|
||
return;
|
||
}
|
||
|
||
// Update the review option now.
|
||
update_option( 'wppdf_review', $review );
|
||
|
||
// We have a candidate! Output a review message.
|
||
?>
|
||
<div class="notice notice-info is-dismissible wppdf-review-notice">
|
||
<p><?php esc_html_e( "Hey, I noticed you're using PDF Embedder - that’s awesome! Could you please do me a BIG favor and give it a 5-star rating on WordPress to help us spread the word and boost our motivation?", 'pdf-embedder' ); ?>
|
||
</p>
|
||
<p><strong><?php esc_html_e( '~ Nathan Singh - CEO of PDF Embedder', 'wppdf' ); ?></strong></p>
|
||
<p>
|
||
<a href="https://wordpress.org/support/plugin/pdf-embedder/reviews/?filter=5#new-post"
|
||
class="wppdf-dismiss-review-notice wppdf-review-out" target="_blank"
|
||
rel="noopener"><?php esc_html_e( 'Ok, you deserve it', 'pdf-embedder' ); ?></a><br>
|
||
<a href="#" class="wppdf-dismiss-review-notice" target="_blank"
|
||
rel="noopener"><?php esc_html_e( 'Nope, maybe later', 'pdf-embedder' ); ?></a><br>
|
||
<a href="#" class="wppdf-dismiss-review-notice" target="_blank"
|
||
rel="noopener"><?php esc_html_e( 'I already did', 'pdf-embedder' ); ?></a><br>
|
||
</p>
|
||
</div>
|
||
<script type="text/javascript">
|
||
jQuery(document).ready(function($) {
|
||
$(document).on('click', '.wppdf-dismiss-review-notice, .wppdf-review-notice button', function(event) {
|
||
if (!$(this).hasClass('wppdf-review-out')) {
|
||
event.preventDefault();
|
||
}
|
||
|
||
$.post(ajaxurl, {
|
||
action: 'wppdf_dismiss_review'
|
||
});
|
||
|
||
$('.wppdf-review-notice').remove();
|
||
});
|
||
});
|
||
</script>
|
||
<?php
|
||
}
|
||
|
||
/**
|
||
* Dismiss the review nag
|
||
*
|
||
* @since 1.1.6.1
|
||
*/
|
||
public function dismiss_review() {
|
||
|
||
$review = get_option( 'wppdf_review' );
|
||
if ( ! $review ) {
|
||
$review = array();
|
||
}
|
||
|
||
$review['time'] = time();
|
||
$review['dismissed'] = true;
|
||
|
||
update_option( 'wppdf_review', $review );
|
||
wp_send_json_success( $review );
|
||
die;
|
||
}
|
||
|
||
/**
|
||
* Singleton Instance
|
||
*
|
||
* @return object
|
||
*/
|
||
public static function get_instance() {
|
||
|
||
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WPPDF_Review ) ) {
|
||
self::$instance = new WPPDF_Review();
|
||
}
|
||
|
||
return self::$instance;
|
||
|
||
}
|
||
}
|
||
|
||
$wppdf_review = WPPDF_Review::get_instance();
|