WP init
This commit is contained in:
@@ -0,0 +1,256 @@
|
||||
<?php
|
||||
namespace WprAddons\Admin\Notices;
|
||||
|
||||
use WprAddons\Classes\Utilities;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class WprPluginSaleNotice {
|
||||
// Declare class properties
|
||||
public $past_date;
|
||||
public $past_date_rml;
|
||||
public $install_date;
|
||||
public $remind_me_later;
|
||||
|
||||
public function __construct() {
|
||||
// delete_option('wpr_plugin_sale_dismiss_notice'); // uncomment for testing
|
||||
|
||||
$this->past_date = strtotime( '-2 days' );
|
||||
$this->past_date_rml = strtotime( '-15 days' );
|
||||
$this->install_date = get_option('royal_elementor_addons_activation_time_for_sale');
|
||||
$this->remind_me_later = get_option('wpr_sale_remind_me_later');
|
||||
// add_action( 'admin_init', [$this, 'render_notice'] ); // uncomment for testing
|
||||
|
||||
if ( current_user_can('administrator') ) {
|
||||
if ( !get_option('wpr_plugin_sale_dismiss_notice') ) {
|
||||
if ( (!defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code()) && !wpr_fs()->is_plan( 'expert' ) ) {
|
||||
add_action( 'admin_init', [$this, 'render_notice'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_admin() ) {
|
||||
add_action( 'admin_head', [$this, 'enqueue_scripts' ] );
|
||||
}
|
||||
|
||||
add_action( 'wp_ajax_wpr_plugin_sale_dismiss_notice', [$this, 'wpr_plugin_sale_dismiss_notice'] );
|
||||
add_action( 'wp_ajax_wpr_sale_remind_me_later', [$this, 'wpr_sale_remind_me_later'] );
|
||||
}
|
||||
|
||||
public function render_notice() {
|
||||
// add_action( 'admin_notices', [$this, 'render_plugin_sale_notice' ]); // uncomment for testing
|
||||
if ( $this->past_date >= $this->install_date ) {
|
||||
if ( get_option('wpr_sale_remind_me_later') && !($this->past_date_rml >= $this->remind_me_later) ) {
|
||||
return;
|
||||
}
|
||||
add_action( 'admin_notices', [$this, 'render_plugin_sale_notice' ]);
|
||||
}
|
||||
}
|
||||
|
||||
public function wpr_plugin_sale_dismiss_notice() {
|
||||
$nonce = $_POST['nonce'];
|
||||
|
||||
if ( !wp_verify_nonce( $nonce, 'wpr-plugin-notice-js') || !current_user_can( 'manage_options' ) ) {
|
||||
exit; // Get out of here, the nonce is rotten!
|
||||
}
|
||||
|
||||
add_option( 'wpr_plugin_sale_dismiss_notice', true );
|
||||
}
|
||||
|
||||
public function wpr_sale_remind_me_later() {
|
||||
$nonce = $_POST['nonce'];
|
||||
|
||||
if ( !wp_verify_nonce( $nonce, 'wpr-plugin-notice-js') || !current_user_can( 'manage_options' ) ) {
|
||||
exit; // Get out of here, the nonce is rotten!
|
||||
}
|
||||
|
||||
update_option( 'wpr_sale_remind_me_later', absint(intval(strtotime('now'))) );
|
||||
}
|
||||
|
||||
public function render_plugin_sale_notice() {
|
||||
if ( is_admin() ) {
|
||||
echo '<div class="notice wpr-plugin-sale-notice is-dismissible">
|
||||
<div>
|
||||
<h3><span>Flash Sale</span><br> Royal Elementor Addons Pro</h3>
|
||||
<ul>
|
||||
<li>
|
||||
<img src="'. esc_url(WPR_ADDONS_ASSETS_URL) .'img/check-mark.png">
|
||||
140+ Designer Made Templates Kit
|
||||
</li>
|
||||
<li>
|
||||
<img src="'. esc_url(WPR_ADDONS_ASSETS_URL) .'img/check-mark.png">
|
||||
100+ Advanced Elementor Widgets
|
||||
</li>
|
||||
<li>
|
||||
<img src="'. esc_url(WPR_ADDONS_ASSETS_URL) .'img/check-mark.png">
|
||||
Dynamic Website Builder <a class="wpr-dynamic-tutorial" href="https://www.youtube.com/watch?v=kE1zmi3fxh8" target="_blank">View Demo</a>
|
||||
</li>
|
||||
<li>
|
||||
<img src="'. esc_url(WPR_ADDONS_ASSETS_URL) .'img/check-mark.png">
|
||||
Advanced Theme Builder
|
||||
</li>
|
||||
<li>
|
||||
<img src="'. esc_url(WPR_ADDONS_ASSETS_URL) .'img/check-mark.png">
|
||||
Advanced WooCommerce Builder
|
||||
</li>
|
||||
<li>
|
||||
<img src="'. esc_url(WPR_ADDONS_ASSETS_URL) .'img/check-mark.png">
|
||||
Advanced Form Builder
|
||||
</li>
|
||||
<li>
|
||||
<img src="'. esc_url(WPR_ADDONS_ASSETS_URL) .'img/check-mark.png">
|
||||
Mega Menu Builder
|
||||
</li>
|
||||
<li>
|
||||
<img src="'. esc_url(WPR_ADDONS_ASSETS_URL) .'img/check-mark.png">
|
||||
Ajax Live Search and much more...
|
||||
</li>
|
||||
</ul>
|
||||
<p>
|
||||
Hurry up! Upgrade within the <strong>next 24 hours</strong> and get a
|
||||
<strong>20% Discount</strong>.<br><br>
|
||||
Use Promo Code: <strong style="border: 1px dashed #C3C4C7;padding: 2px 10px;">REAFLASH20</strong>
|
||||
</p>
|
||||
<br>
|
||||
<div>
|
||||
<a href="https://royal-elementor-addons.com/?ref=rea-plugin-backend-salebanner-upgrade-pro#purchasepro" target="_blank" class="wpr-upgrade-to-pro-button button button-secondary">Upgrade to Pro <span class="dashicons dashicons-arrow-right-alt"></span></a>
|
||||
<a target="#" target="_blank" class="wpr-upgrade-to-pro-button button button-secondary wpr-remind-later">Remind Me Later</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="image-wrap"><img src="'. esc_url(WPR_ADDONS_ASSETS_URL) .'img/sale-banner-20.png"></div>
|
||||
<canvas id="wpr-notice-confetti"></canvas>
|
||||
</div>';
|
||||
}
|
||||
}
|
||||
|
||||
public static function enqueue_scripts() {
|
||||
// Load Confetti
|
||||
wp_enqueue_script( 'wpr-confetti-js', WPR_ADDONS_URL .'assets/js/admin/lib/confetti/confetti.min.js', ['jquery'] );
|
||||
|
||||
// Scripts & Styles
|
||||
echo "
|
||||
<style>
|
||||
.wpr-plugin-sale-notice {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-top: 20px;
|
||||
margin-bottom: 20px;
|
||||
padding: 30px;
|
||||
border: 0 !important;
|
||||
box-shadow: 0 0 5px rgb(0 0 0 / 0.1);
|
||||
|
||||
padding-left: 40px;
|
||||
}
|
||||
|
||||
.wpr-plugin-sale-notice-logo {
|
||||
display: none;
|
||||
margin-right: 30px;
|
||||
}
|
||||
|
||||
.wpr-plugin-sale-notice-logo img {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.wpr-plugin-sale-notice h3 {
|
||||
font-size: 36px;
|
||||
margin-top: 0;
|
||||
margin-bottom: 35px;
|
||||
}
|
||||
|
||||
.wpr-plugin-sale-notice h3 span {
|
||||
display: inline-block;
|
||||
margin-bottom: 15px;
|
||||
font-size: 12px;
|
||||
color: #fff;
|
||||
background-color: #f51f3d;
|
||||
padding: 2px 12px 4px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.wpr-plugin-sale-notice ul li {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.wpr-plugin-sale-notice ul img {
|
||||
display: inline-block;
|
||||
width: 11px;
|
||||
margin-right: 2px;
|
||||
}
|
||||
|
||||
.wpr-plugin-sale-notice p {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 15px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.wpr-plugin-sale-notice .wpr-upgrade-to-pro-button {
|
||||
border: 2px solid #e4e4e4;
|
||||
color: #9f9c9c;
|
||||
background-color: #fff;
|
||||
padding: 5px 25px;
|
||||
font-weight: bold;
|
||||
letter-spacing: 0.3px;
|
||||
}
|
||||
|
||||
.wpr-plugin-sale-notice .wpr-upgrade-to-pro-button:hover {
|
||||
border: 2px solid #6a4bff4f;
|
||||
color: #6A4BFF;
|
||||
background: #f6f7f7;
|
||||
}
|
||||
|
||||
.wpr-plugin-sale-notice .wpr-upgrade-to-pro-button:first-child {
|
||||
border: 2px solid #6A4BFF;
|
||||
color: #ffffff;
|
||||
background-color: #6A4BFF;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.wpr-plugin-sale-notice .wpr-upgrade-to-pro-button .dashicons {
|
||||
font-size: 14px;
|
||||
line-height: 30px;
|
||||
}
|
||||
|
||||
.wpr-plugin-sale-notice .wpr-dynamic-tutorial {
|
||||
text-decoration: none;
|
||||
color: #FFF;
|
||||
background: #e1ad01;
|
||||
padding: 4px 10px;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.wpr-plugin-sale-notice .image-wrap {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
#wpr-notice-confetti {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 1400px) {
|
||||
.wpr-plugin-sale-notice .image-wrap img {
|
||||
zoom: 0.9;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 1366px) {
|
||||
.wpr-plugin-sale-notice .image-wrap img {
|
||||
zoom: 0.7;
|
||||
}
|
||||
}
|
||||
</style>";
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'Royal Addons' === Utilities::get_plugin_name() ) {
|
||||
new WprPluginSaleNotice();
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
<?php
|
||||
namespace WprAddons\Admin\Notices;
|
||||
|
||||
use WprAddons\Classes\Utilities;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class WprPluginNotice {
|
||||
public function __construct() {
|
||||
|
||||
if ( current_user_can('administrator') ) {
|
||||
|
||||
if ( !get_option('wpr_plugin_update_dismiss_notice' ) ) {
|
||||
add_action( 'admin_init', [$this, 'render_notice'] );
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_admin() ) {
|
||||
add_action( 'admin_head', [$this, 'enqueue_scripts' ] );
|
||||
}
|
||||
|
||||
add_action( 'wp_ajax_wpr_plugin_update_dismiss_notice', [$this, 'wpr_plugin_update_dismiss_notice'] );
|
||||
}
|
||||
|
||||
public function render_notice() {
|
||||
add_action( 'admin_notices', [$this, 'render_plugin_update_notice' ]);
|
||||
}
|
||||
|
||||
public function wpr_plugin_update_dismiss_notice() {
|
||||
$nonce = $_POST['nonce'];
|
||||
|
||||
if ( !wp_verify_nonce( $nonce, 'wpr-plugin-notice-js') || !current_user_can( 'manage_options' ) ) {
|
||||
exit; // Get out of here, the nonce is rotten!
|
||||
}
|
||||
|
||||
add_option( 'wpr_plugin_update_dismiss_notice', true );
|
||||
}
|
||||
|
||||
public function render_plugin_update_notice() {
|
||||
global $current_screen;
|
||||
|
||||
if ( is_admin() ) {
|
||||
if ( 'royal-addons_page_wpr-templates-kit' === $current_screen->id || 'update' === $current_screen->id ) {
|
||||
return;
|
||||
}
|
||||
|
||||
echo '<div class="notice wpr-plugin-update-notice is-dismissible">
|
||||
<div class="wpr-plugin-update-notice-logo">
|
||||
<img src="'. esc_url(WPR_ADDONS_ASSETS_URL) .'/img/logo-128x128.png">
|
||||
</div>
|
||||
<div>
|
||||
<h3><span>New Features</span><br> Introducing New Widgets</h3>
|
||||
<p>We are excited to announce that we have added new Widgets, Template Kits, and other Elementor<br> features to enhance your website building experience. Stay tuned for the weekly updates!</p>
|
||||
<ul class="wpr-new-widgets-list">
|
||||
<li><a target="_blank" href="https://royal-elementor-addons.com/advanced-sticky-header/?ref=rea-plugin-backend-update-notice">Advanced Sticky Header</a></li>
|
||||
<li><a target="_blank" href="https://royal-elementor-addons.com/elementor-form-builder-widget/?ref=rea-plugin-backend-update-notice">Form Builder</a></li>
|
||||
<li><a target="_blank" href="https://royal-elementor-addons.com/elementor-mega-menu-widget/?ref=rea-plugin-backend-update-notice">Mega Menu</a></li>
|
||||
<li><a target="_blank" href="https://royal-elementor-addons.com/elementor-offcanvas-menu-widget/?ref=rea-plugin-backend-update-notice">Off-Canvas Content</a></li>
|
||||
<li><a target="_blank" href="https://royal-elementor-addons.com/elementor-instagram-feed-widget/?ref=rea-plugin-backend-update-notice">Instagram Feed</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="image-wrap"><img src="'. esc_url(WPR_ADDONS_ASSETS_URL) .'img/new-theme-builder.png"></div>
|
||||
<canvas id="wpr-notice-confetti"></canvas>
|
||||
</div>';
|
||||
}
|
||||
}
|
||||
|
||||
public static function enqueue_scripts() {
|
||||
// Load Confetti
|
||||
wp_enqueue_script( 'wpr-confetti-js', WPR_ADDONS_URL .'assets/js/admin/lib/confetti/confetti.min.js', ['jquery'] );
|
||||
|
||||
// Scripts & Styles
|
||||
echo "
|
||||
<style>
|
||||
.wpr-plugin-update-notice {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-top: 20px;
|
||||
margin-bottom: 20px;
|
||||
padding: 30px;
|
||||
border: 0 !important;
|
||||
box-shadow: 0 0 5px rgb(0 0 0 / 0.1);
|
||||
|
||||
padding-left: 40px;
|
||||
}
|
||||
|
||||
.wpr-plugin-update-notice-logo {
|
||||
display: none;
|
||||
margin-right: 30px;
|
||||
}
|
||||
|
||||
.wpr-plugin-update-notice-logo img {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.wpr-plugin-update-notice h3 {
|
||||
font-size: 36px;
|
||||
margin-top: 0;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.wpr-plugin-update-notice h3 span {
|
||||
display: inline-block;
|
||||
margin-bottom: 15px;
|
||||
font-size: 12px;
|
||||
color: #fff;
|
||||
background-color: #f51f3d;
|
||||
padding: 2px 12px 4px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.wpr-plugin-update-notice p {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 15px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.wpr-plugin-update-notice ul {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.wpr-plugin-update-notice ul a {
|
||||
display: block;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.wpr-plugin-update-notice ul li a:after {
|
||||
content: ' ';
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
top: -2px;
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
margin-left: 12px;
|
||||
margin-right: 12px;
|
||||
background-color: #e0e0e0;
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
|
||||
.wpr-plugin-update-notice ul li:last-child a:after {
|
||||
display: none;
|
||||
}
|
||||
.wpr-get-started-button.button-primary {
|
||||
background-color: #6A4BFF;
|
||||
}
|
||||
|
||||
.wpr-get-started-button.button-primary:hover {
|
||||
background-color: #583ed7;
|
||||
}
|
||||
|
||||
.wpr-get-started-button.button-secondary {
|
||||
border: 1px solid #6A4BFF;
|
||||
color: #6A4BFF;
|
||||
}
|
||||
|
||||
.wpr-get-started-button.button-secondary:hover {
|
||||
background-color: #6A4BFF;
|
||||
border: 2px solid #6A4BFF;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.wpr-get-started-button {
|
||||
padding: 5px 25px !important;
|
||||
}
|
||||
|
||||
.wpr-get-started-button .dashicons {
|
||||
font-size: 12px;
|
||||
line-height: 28px;
|
||||
}
|
||||
|
||||
.wpr-plugin-update-notice .image-wrap {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.wpr-plugin-update-notice .image-wrap img {
|
||||
zoom: 0.45;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 1366px) {
|
||||
.wpr-plugin-update-notice h3 {
|
||||
font-size: 32px;
|
||||
}
|
||||
|
||||
.wpr-plugin-update-notice .image-wrap img {
|
||||
zoom: 0.4;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 1280px) {
|
||||
.wpr-plugin-update-notice .image-wrap img {
|
||||
zoom: 0.35;
|
||||
}
|
||||
}
|
||||
|
||||
#wpr-notice-confetti {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
pointer-events: none;
|
||||
}
|
||||
</style>";
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'Royal Addons' === Utilities::get_plugin_name() ) {
|
||||
new WprPluginNotice();
|
||||
}
|
||||
@@ -0,0 +1,312 @@
|
||||
<?php
|
||||
namespace WprAddons\Admin\Notices;
|
||||
|
||||
use WprAddons\Classes\Utilities;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class WprProFeaturesNotice {
|
||||
public function __construct() {
|
||||
|
||||
if ( function_exists('wpr_fs') && !wpr_fs()->is_plan( 'expert' ) ) {
|
||||
|
||||
if ( current_user_can('administrator') ) {
|
||||
|
||||
if ( !get_option('wpr_pro_features_dismiss_notice' ) ) {
|
||||
add_action( 'admin_init', [$this, 'render_notice'] );
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_admin() && !get_option('wpr_pro_features_dismiss_notice' ) ) {
|
||||
add_action( 'admin_head', [$this, 'enqueue_scripts' ] );
|
||||
}
|
||||
|
||||
add_action( 'wp_ajax_wpr_pro_features_dismiss_notice', [$this, 'wpr_pro_features_dismiss_notice'] );
|
||||
}
|
||||
}
|
||||
|
||||
public function render_notice() {
|
||||
add_action( 'admin_notices', [$this, 'render_pro_features_notice' ]);
|
||||
}
|
||||
|
||||
public function wpr_pro_features_dismiss_notice() {
|
||||
$nonce = $_POST['nonce'];
|
||||
|
||||
if ( !wp_verify_nonce( $nonce, 'wpr-plugin-notice-js') || !current_user_can( 'manage_options' ) ) {
|
||||
exit; // Get out of here, the nonce is rotten!
|
||||
}
|
||||
|
||||
add_option( 'wpr_pro_features_dismiss_notice', true );
|
||||
return 'responsetext';
|
||||
}
|
||||
|
||||
public function render_pro_features_notice() {
|
||||
global $current_screen;
|
||||
|
||||
if ( is_admin() && 'toplevel_page_wpr-addons' == $current_screen->id ) {
|
||||
echo '<div class="wpr-pro-features-notice-wrap">';
|
||||
echo '<div class="notice wpr-pro-features-notice is-dismissible">
|
||||
<div class="wpr-pro-features-notice-logo">
|
||||
<img src="'. esc_url(WPR_ADDONS_ASSETS_URL) .'/img/logo-128x128.png">
|
||||
</div>
|
||||
<div>
|
||||
<h3><span>Big Update</span><br>Dynamic Content</h3>
|
||||
<p>We are happy to announce that <strong>Royal Elementor Addons Expert</strong> version now supports <strong>Dynamic Content</strong> wich includes:</p>
|
||||
<ul class="wpr-new-widgets-list">
|
||||
<li><strong>Dynamic Tags (Elementor)</strong></li>
|
||||
<li><strong>Advanced Custom Fields (Extended)</strong></li>
|
||||
<li><strong>Custom Post Type Generator</strong></li>
|
||||
<li><strong>Custom Taxonomy Generator</strong></li>
|
||||
<li><a target="_blank" href="https://www.youtube.com/watch?v=wis1rQTn1tg">Product Wishlist (WooCommerce)</a></li>
|
||||
<li><a target="_blank" href="https://www.youtube.com/watch?v=wis1rQTn1tg">Product Compare (WooCommerce)</a></li>
|
||||
</ul>
|
||||
|
||||
<a class="wpr-pro-features-btn" href="https://royal-elementor-addons.com/#purchasepro?ref=rea-plugin-backend-expertnoticebanner-checkbtn-upgrade-expert#purchasepro" target="_blank">Upgrade to Expert</a>
|
||||
<a class="wpr-pro-features-btn wpr-dynamic-tutorial" href="https://www.youtube.com/watch?v=kE1zmi3fxh8" target="_blank">Dynamic Tutorial</a>
|
||||
</div>
|
||||
<canvas id="wpr-notice-confetti"></canvas>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
public static function enqueue_scripts() {
|
||||
global $current_screen;
|
||||
|
||||
|
||||
if ( !(is_admin() && 'toplevel_page_wpr-addons' == $current_screen->id) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Load Confetti
|
||||
wp_enqueue_script( 'wpr-confetti-js', WPR_ADDONS_URL .'assets/js/admin/lib/confetti/confetti.min.js', ['jquery'] );
|
||||
|
||||
// Scripts & Styles
|
||||
echo "
|
||||
<script>
|
||||
jQuery( document ).ready( function($) {
|
||||
|
||||
$('html, body').animate({
|
||||
scrollTop: 0
|
||||
}, 'slow');
|
||||
$('body').addClass('wpr-pro-features-body');
|
||||
$(document).find('.wpr-pro-features-notice-wrap').css('opacity', 1);
|
||||
|
||||
if ( jQuery('#wpr-notice-confetti').length ) {
|
||||
const wprConfetti = confetti.create( document.getElementById('wpr-notice-confetti'), {
|
||||
resize: true
|
||||
});
|
||||
|
||||
setTimeout( function () {
|
||||
wprConfetti( {
|
||||
particleCount: 150,
|
||||
origin: { x: 1, y: 2 },
|
||||
gravity: 0.3,
|
||||
spread: 50,
|
||||
ticks: 150,
|
||||
angle: 120,
|
||||
startVelocity: 60,
|
||||
colors: [
|
||||
'#0e6ef1',
|
||||
'#f5b800',
|
||||
'#ff344c',
|
||||
'#98e027',
|
||||
'#9900f1',
|
||||
],
|
||||
} );
|
||||
}, 500 );
|
||||
|
||||
setTimeout( function () {
|
||||
wprConfetti( {
|
||||
particleCount: 150,
|
||||
origin: { x: 0, y: 2 },
|
||||
gravity: 0.3,
|
||||
spread: 50,
|
||||
ticks: 200,
|
||||
angle: 60,
|
||||
startVelocity: 60,
|
||||
colors: [
|
||||
'#0e6ef1',
|
||||
'#f5b800',
|
||||
'#ff344c',
|
||||
'#98e027',
|
||||
'#9900f1',
|
||||
],
|
||||
} );
|
||||
}, 900 );
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.wpr-pro-features-body {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.wpr-pro-features-notice-wrap {
|
||||
position: absolute;
|
||||
display: block;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
z-index: 999;
|
||||
background-color: rgba(0, 0, 0, 0.2);
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.wpr-settings-page-header .wpr-pro-features-notice.notice {
|
||||
display: flex !important;
|
||||
position: absolute !important;
|
||||
top: 30%;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
width: 410px;
|
||||
align-items: center;
|
||||
margin-top: 20px;
|
||||
margin-bottom: 20px;
|
||||
padding: 30px;
|
||||
border: 0 !important;
|
||||
box-shadow: 0 0 5px rgb(0 0 0 / 0.3);
|
||||
padding-left: 40px;
|
||||
z-index: 999;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.wpr-pro-features-notice-logo {
|
||||
display: none;
|
||||
margin-right: 30px;
|
||||
}
|
||||
|
||||
.wpr-pro-features-notice-logo img {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.wpr-pro-features-notice h3 {
|
||||
font-size: 32px;
|
||||
margin-top: 0;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.wpr-pro-features-notice h3 span {
|
||||
display: inline-block;
|
||||
margin-bottom: 15px;
|
||||
font-size: 12px;
|
||||
color: #fff;
|
||||
background-color: #f51f3d;
|
||||
padding: 2px 12px 4px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.wpr-pro-features-notice p {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 25px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.wpr-pro-features-notice ul a {
|
||||
display: block;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.wpr-pro-features-notice ul li:last-child a:after {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.wpr-pro-features-btn,
|
||||
.wpr-new-widgets-list + a {
|
||||
display: inline-block;
|
||||
text-decoration: none;
|
||||
text-transform: uppercase;
|
||||
color: #fff;
|
||||
background: #6A4BFF;
|
||||
padding: 5px 18px 7px;
|
||||
border-radius: 3px;
|
||||
margin-top: 30px;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.3px;
|
||||
}
|
||||
|
||||
.wpr-pro-features-btn.wpr-dynamic-tutorial {
|
||||
background: #e1ad01;
|
||||
}
|
||||
|
||||
.wpr-pro-features-btn:hover {
|
||||
color: #FFF;
|
||||
}
|
||||
|
||||
.wpr-pro-features-btn:focus {
|
||||
color: #FFF;
|
||||
}
|
||||
|
||||
.wpr-get-started-button.button-primary {
|
||||
background-color: #6A4BFF;
|
||||
}
|
||||
|
||||
.wpr-get-started-button.button-primary:hover {
|
||||
background-color: #583ed7;
|
||||
}
|
||||
|
||||
.wpr-get-started-button.button-secondary {
|
||||
border: 1px solid #6A4BFF;
|
||||
color: #6A4BFF;
|
||||
}
|
||||
|
||||
.wpr-get-started-button.button-secondary:hover {
|
||||
background-color: #6A4BFF;
|
||||
border: 2px solid #6A4BFF;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.wpr-get-started-button {
|
||||
padding: 5px 25px !important;
|
||||
}
|
||||
|
||||
.wpr-get-started-button .dashicons {
|
||||
font-size: 12px;
|
||||
line-height: 28px;
|
||||
}
|
||||
|
||||
.wpr-pro-features-notice .image-wrap {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.wpr-pro-features-notice .image-wrap img {
|
||||
zoom: 0.45;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 1366px) {
|
||||
.wpr-pro-features-notice h3 {
|
||||
font-size: 32px;
|
||||
}
|
||||
|
||||
.wpr-pro-features-notice .image-wrap img {
|
||||
zoom: 0.4;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 1280px) {
|
||||
.wpr-pro-features-notice .image-wrap img {
|
||||
zoom: 0.35;
|
||||
}
|
||||
}
|
||||
|
||||
#wpr-notice-confetti {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
pointer-events: none;
|
||||
}
|
||||
</style>";
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'Royal Addons' === Utilities::get_plugin_name() ) {
|
||||
new WprProFeaturesNotice();
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
<?php
|
||||
namespace WprAddons\Admin\Notices;
|
||||
|
||||
use WprAddons\Classes\Utilities;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class WprRatingNotice {
|
||||
private $past_date;
|
||||
|
||||
public function __construct() {
|
||||
global $pagenow;
|
||||
$this->past_date = false == get_option('wpr_maybe_later_time') ? strtotime( '-14 days' ) : strtotime('-7 days');
|
||||
|
||||
if ( current_user_can('administrator') ) {
|
||||
if ( empty(get_option('wpr_rating_dismiss_notice', false)) && empty(get_option('wpr_rating_already_rated', false)) ) {
|
||||
add_action( 'admin_init', [$this, 'check_plugin_install_time'] );
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_admin() ) {
|
||||
add_action( 'admin_head', [$this, 'enqueue_scripts' ] );
|
||||
}
|
||||
|
||||
add_action( 'wp_ajax_wpr_rating_dismiss_notice', [$this, 'wpr_rating_dismiss_notice'] );
|
||||
add_action( 'wp_ajax_wpr_rating_maybe_later', [$this, 'wpr_rating_maybe_later'] );
|
||||
add_action( 'wp_ajax_wpr_rating_already_rated', [$this, 'wpr_rating_already_rated'] );
|
||||
add_action( 'wp_ajax_wpr_rating_need_help', [$this, 'wpr_rating_need_help'] );
|
||||
}
|
||||
|
||||
public function check_plugin_install_time() {
|
||||
$install_date = get_option('royal_elementor_addons_activation_time');
|
||||
|
||||
if ( false == get_option('wpr_maybe_later_time') && false !== $install_date && $this->past_date >= $install_date ) {
|
||||
add_action( 'admin_notices', [$this, 'render_rating_notice' ]);
|
||||
} else if ( false != get_option('wpr_maybe_later_time') && $this->past_date >= get_option('wpr_maybe_later_time') ) {
|
||||
add_action( 'admin_notices', [$this, 'render_rating_notice' ]);
|
||||
}
|
||||
}
|
||||
|
||||
public function wpr_rating_maybe_later() {
|
||||
$nonce = $_POST['nonce'];
|
||||
|
||||
if ( !wp_verify_nonce( $nonce, 'wpr-plugin-notice-js') || !current_user_can( 'manage_options' ) ) {
|
||||
exit; // Get out of here, the nonce is rotten!
|
||||
}
|
||||
|
||||
update_option( 'wpr_maybe_later_time', strtotime('now') );
|
||||
}
|
||||
|
||||
function wpr_rating_already_rated() {
|
||||
$nonce = $_POST['nonce'];
|
||||
|
||||
if ( !wp_verify_nonce( $nonce, 'wpr-plugin-notice-js') || !current_user_can( 'manage_options' ) ) {
|
||||
exit; // Get out of here, the nonce is rotten!
|
||||
}
|
||||
|
||||
update_option( 'wpr_rating_already_rated' , true );
|
||||
}
|
||||
|
||||
public function wpr_rating_dismiss_notice() {
|
||||
$nonce = $_POST['nonce'];
|
||||
|
||||
if ( !wp_verify_nonce( $nonce, 'wpr-plugin-notice-js') || !current_user_can( 'manage_options' ) ) {
|
||||
exit; // Get out of here, the nonce is rotten!
|
||||
}
|
||||
|
||||
update_option( 'wpr_rating_dismiss_notice', true );
|
||||
}
|
||||
|
||||
public function wpr_rating_need_help() {
|
||||
$nonce = $_POST['nonce'];
|
||||
|
||||
if ( !wp_verify_nonce( $nonce, 'wpr-plugin-notice-js') || !current_user_can( 'manage_options' ) ) {
|
||||
exit; // Get out of here, the nonce is rotten!
|
||||
}
|
||||
|
||||
// Reset Activation Time if user Needs Help
|
||||
update_option( 'royal_elementor_addons_activation_time', strtotime('now') );
|
||||
}
|
||||
|
||||
public function render_rating_notice() {
|
||||
global $pagenow;
|
||||
|
||||
if ( is_admin() ) {
|
||||
$plugin_info = get_plugin_data( __FILE__ , true, true );
|
||||
$dont_disturb = esc_url( get_admin_url() . '?spare_me=1' );
|
||||
|
||||
echo '<div class="notice wpr-rating-notice is-dismissible" style="border-left-color: #7A75FF!important; display: flex; align-items: center; position: relative;">
|
||||
<div class="wpr-rating-notice-logo">
|
||||
<img src="' . WPR_ADDONS_ASSETS_URL . '/img/logo-128x128.png">
|
||||
</div>
|
||||
<div>
|
||||
<h3>Thank you for using Royal Elementor Addons to build this website!</h3>
|
||||
<p style="">Could you please do us a BIG favor and give it a 5-star rating on WordPress? Just to help us spread the word and boost our motivation.</p>
|
||||
<p>
|
||||
<a href="https://wordpress.org/support/plugin/royal-elementor-addons/reviews/" target="_blank" class="wpr-you-deserve-it button button-primary">OK, you deserve it!</a>
|
||||
<a class="wpr-maybe-later"><span class="dashicons dashicons-clock"></span> Maybe Later</a>
|
||||
<a class="wpr-already-rated"><span class="dashicons dashicons-yes"></span> I Already did</a>
|
||||
</p>
|
||||
</div>
|
||||
<button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button>
|
||||
</div>';
|
||||
|
||||
// <a href="https://wordpress.org/support/plugin/royal-elementor-addons/" target="_blank" class="wpr-need-support"><span class="dashicons dashicons-sos"></span> I need support!</a>
|
||||
// <a class="wpr-notice-dismiss-2"><span class="dashicons dashicons-thumbs-down"></span> NO, not good enough</a>
|
||||
}
|
||||
}
|
||||
|
||||
public static function enqueue_scripts() {
|
||||
echo "
|
||||
<style>
|
||||
.wpr-rating-notice {
|
||||
padding: 10px 20px;
|
||||
border-top: 0;
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.wpr-rating-notice-logo {
|
||||
margin-right: 20px;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
.wpr-rating-notice-logo img {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.wpr-rating-notice h3 {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.wpr-rating-notice p {
|
||||
margin-top: 3px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.wpr-maybe-later,
|
||||
.wpr-already-rated,
|
||||
.wpr-need-support,
|
||||
.wpr-notice-dismiss-2 {
|
||||
text-decoration: none;
|
||||
margin-left: 12px;
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.wpr-already-rated .dashicons,
|
||||
.wpr-maybe-later .dashicons,
|
||||
.wpr-need-support .dashicons {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.wpr-notice-dismiss-2 .dashicons {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.wpr-rating-notice .notice-dismiss {
|
||||
display: block;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 1px;
|
||||
border: none;
|
||||
margin: 0;
|
||||
padding: 9px;
|
||||
background: none;
|
||||
color: #787c82;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.wpr-rating-notice .notice-dismiss:before {
|
||||
background: none;
|
||||
color: #787c82;
|
||||
content: '\\f153';
|
||||
display: block;
|
||||
font: normal 16px/20px dashicons;
|
||||
speak: never;
|
||||
height: 20px;
|
||||
text-align: center;
|
||||
width: 20px;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
.wpr-rating-notice .notice-dismiss:hover:before {
|
||||
color: #d63638;
|
||||
}
|
||||
</style>
|
||||
";
|
||||
|
||||
echo "
|
||||
<script>
|
||||
jQuery(document).ready(function($) {
|
||||
$('.wpr-rating-notice .notice-dismiss').on('click', function() {
|
||||
$.ajax({
|
||||
url: ajaxurl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'wpr_rating_dismiss_notice',
|
||||
nonce: '" . wp_create_nonce('wpr-plugin-notice-js') . "'
|
||||
},
|
||||
success: function() {
|
||||
$('.wpr-rating-notice').fadeOut();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( 'Royal Addons' === Utilities::get_plugin_name() ) {
|
||||
new WprRatingNotice();
|
||||
}
|
||||
Reference in New Issue
Block a user