PluginProbe
Easy Age Verify / trunk
Easy Age Verify vtrunk
2.0.13 2.0.12 trunk 1.10 1.9 2.0 2.0.1 2.0.11 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9
easy-age-verify / easy-age-verify.php

easy-age-verify.php in Easy Age Verify trunk, at easy-age-verify.php

200 lines 7.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Plugin Name: Easy Age Verify
5 *
6 * Description: Adds a mobile friendly age verification screen to adults only, vape or alcohol websites. Get set-up in minutes.
7 * Author: 5 Star Plugins
8 * Author URI: https://5starplugins.com/
9 * Version: 2.0.13
10 *
11 * Requires at least: 4.6
12 * Requires PHP: 5.6
13 *
14 * Text Domain: easy-age-verify
15 * Domain Path: /languages
16 * License: GPLv2 or later
17 *
18 *
19 * Copyright 2021 5 Star Plugins
20 *
21 * The following code is a derivative work of the code from Chase Wiseman, which is licensed GPLv2.
22 * This code is then also licensed under the terms of the GPLv2.
23 */
24 /**
25 * The main plugin file.
26 *
27 * This file loads the main plugin class and gets things running.
28 *
29 * @since 1.0
30 *
31 * @package Easy_Age_Verify
32 *
33 */
34 if ( !defined( 'WPINC' ) ) {
35 die;
36 }
37 define( 'EVAV_PLUGIN_DIR_PATH', plugin_dir_path( __FILE__ ) );
38 define( 'EVAV_PLUGIN_FILE', plugin_basename( __FILE__ ) );
39 if ( function_exists( 'evav_fs' ) ) {
40 evav_fs()->set_basename( false, __FILE__ );
41 return;
42 }
43 // Don't allow this file to be accessed directly.
44 if ( !function_exists( 'evav_fs' ) ) {
45 // Create a helper function for easy SDK access.
46 /**
47 * @return Freemius
48 * @throws Freemius_Exception
49 */
50 function evav_fs() {
51 global $evav_fs;
52 if ( !isset( $evav_fs ) ) {
53 // Include Freemius SDK.
54 require_once EVAV_PLUGIN_DIR_PATH . 'includes/freemius/start.php';
55 $evav_fs = fs_dynamic_init( array(
56 'id' => '3551',
57 'slug' => 'easy-age-verify',
58 'type' => 'plugin',
59 'public_key' => 'pk_88a8f3865bc74bf9dcbe507dd437a',
60 'is_premium' => false,
61 'premium_suffix' => 'Premium',
62 'has_addons' => false,
63 'has_paid_plans' => true,
64 'trial' => array(
65 'days' => 14,
66 'is_require_payment' => false,
67 ),
68 'has_affiliation' => 'all',
69 'menu' => array(
70 'slug' => 'easy-age-verify',
71 ),
72 'is_live' => true,
73 'is_org_compliant' => true,
74 ) );
75 }
76 return $evav_fs;
77 }
78
79 }
80 // Init Freemius.
81 global $evav_fs;
82 $evav_fs = evav_fs();
83 $evav_fs->add_filter(
84 'connect_message_on_update',
85 'evav_fs_custom_connect_message_on_update',
86 10,
87 6
88 );
89 $evav_fs->add_filter(
90 'connect_message',
91 'evav_freemius_new_message',
92 10,
93 6
94 );
95 // Signal that SDK was initiated.
96 do_action( 'evav_fs_loaded' );
97 if ( !function_exists( 'evav_fs_settings_url' ) ) {
98 function evav_fs_settings_url() {
99 return admin_url( 'admin.php?page=easy-age-verify' );
100 }
101
102 }
103 $evav_fs->add_filter( 'after_skip_url', 'evav_fs_settings_url' );
104 $evav_fs->add_filter( 'after_connect_url', 'evav_fs_settings_url' );
105 $evav_fs->add_filter( 'after_pending_connect_url', 'evav_fs_settings_url' );
106 /**
107 * The main class definition.
108 */
109 require EVAV_PLUGIN_DIR_PATH . 'includes/class-easy-age-verify.php';
110 // Get the plugin running.
111 add_action( 'plugins_loaded', array('Easy_Age_Verify', 'get_instance') );
112 // Check that the admin is loaded.
113 if ( is_admin() ) {
114 /**
115 * The admin class definition.
116 */
117 require EVAV_PLUGIN_DIR_PATH . 'includes/admin/class-easy-age-verify-admin.php';
118 // Get the plugin's admin running.
119 add_action( 'plugins_loaded', array('Easy_Age_Verify_Admin', 'get_instance') );
120 add_action( 'admin_init', function () {
121 if ( !current_user_can( 'manage_options' ) ) {
122 return;
123 }
124 if ( !isset( $_GET['page'] ) || 'easy-age-verify' !== $_GET['page'] ) {
125 return;
126 }
127 $action = '';
128 if ( isset( $_GET['evav_review_action'] ) ) {
129 $action = sanitize_key( wp_unslash( $_GET['evav_review_action'] ) );
130 }
131 if ( !in_array( $action, array('dismiss', 'remind'), true ) ) {
132 return;
133 }
134 $user_id = get_current_user_id();
135 $meta_key_base = 'evav_review_notice';
136 $remind_transient = "{$meta_key_base}_remind_{$user_id}";
137 $settings_page_url = add_query_arg( 'page', 'easy-age-verify', admin_url( 'admin.php' ) );
138 if ( 'dismiss' === $action ) {
139 update_user_meta( $user_id, "{$meta_key_base}_dismissed", 'dismissed' );
140 delete_transient( $remind_transient );
141 } else {
142 set_transient( $remind_transient, time(), 7 * DAY_IN_SECONDS );
143 }
144 wp_safe_redirect( $settings_page_url );
145 exit;
146 } );
147 add_action( 'admin_notices', function () {
148 if ( !current_user_can( 'manage_options' ) ) {
149 return;
150 }
151 $user_id = get_current_user_id();
152 $meta_key_base = 'evav_review_notice';
153 $first_seen = get_user_meta( $user_id, "{$meta_key_base}_first_seen", true );
154 $dismissed = get_user_meta( $user_id, "{$meta_key_base}_dismissed", true );
155 $remind_transient = get_transient( "{$meta_key_base}_remind_{$user_id}" );
156 // Record first visit timestamp
157 if ( !$first_seen ) {
158 update_user_meta( $user_id, "{$meta_key_base}_first_seen", time() );
159 return;
160 }
161 // Wait 30 days from first seen
162 if ( time() - $first_seen < 30 * DAY_IN_SECONDS ) {
163 return;
164 }
165 if ( $dismissed === 'dismissed' ) {
166 return;
167 }
168 // Optional: only show on plugin settings page
169 if ( !isset( $_GET['page'] ) || $_GET['page'] !== 'easy-age-verify' ) {
170 return;
171 }
172 // Handle 7-day reminder delay
173 if ( $remind_transient ) {
174 return;
175 }
176 $review_url = 'http://wordpress.org/support/view/plugin-reviews/easy-age-verify/?rate=5#new-post';
177 $settings_url = add_query_arg( 'page', 'easy-age-verify', admin_url( 'admin.php' ) );
178 $remind_url = add_query_arg( 'evav_review_action', 'remind', $settings_url );
179 $dismiss_url = add_query_arg( 'evav_review_action', 'dismiss', $settings_url );
180 echo '<div class="notice notice-success is-dismissible">';
181 echo '<p><strong>' . esc_html__( 'Enjoying Easy Age Verify?', 'easy-age-verify' ) . '</strong> ' . sprintf( wp_kses(
182 /* translators: %s: review URL */
183 __( 'Please <a href="%s" target="_blank">leave a 5-star review</a> to support us! 🙌', 'easy-age-verify' ),
184 [
185 'a' => [
186 'href' => [],
187 'target' => [],
188 ],
189 ]
190 ), esc_url( $review_url ) ) . '</p>';
191 echo '<p>' . sprintf(
192 '<a href="%1$s">%2$s</a> | <a href="%3$s">%4$s</a>',
193 esc_url( $remind_url ),
194 esc_html__( 'Remind me later', 'easy-age-verify' ),
195 esc_url( $dismiss_url ),
196 esc_html__( 'Dismiss', 'easy-age-verify' )
197 ) . '</p>';
198 echo '</div>';
199 } );
200 }