PluginProbe ʕ •ᴥ•ʔ
Email Encoder – Protect Email Addresses and Phone Numbers / 2.2.0
Email Encoder – Protect Email Addresses and Phone Numbers v2.2.0
2.5.0 2.4.8 trunk 0.10 0.11 0.12 0.20 0.21 0.22 0.30 0.31 0.32 0.40 0.41 0.42 0.50 0.60 0.70 0.71 0.80 1.0.0 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.3.0 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.5 1.5.2 1.51 1.53 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.10 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7
email-encoder-bundle / core / includes / classes / class-email-encoder-bundle-run-admin.php
email-encoder-bundle / core / includes / classes Last commit date
class-email-encoder-bundle-ajax.php 2 years ago class-email-encoder-bundle-helpers.php 2 years ago class-email-encoder-bundle-run-admin.php 2 years ago class-email-encoder-bundle-run.php 2 years ago class-email-encoder-bundle-settings.php 2 years ago class-email-encoder-bundle-validate.php 2 years ago index.php 2 years ago
class-email-encoder-bundle-run-admin.php
275 lines
1 <?php
2
3 /**
4 * Class Email_Encoder_Run
5 *
6 * Thats where we bring the plugin to life
7 *
8 * @since 2.0.0
9 * @package EEB
10 * @author Ironikus <info@ironikus.com>
11 */
12
13 class Email_Encoder_Run{
14
15 /**
16 * The main page name for our admin page
17 *
18 * @var string
19 * @since 2.0.0
20 */
21 private $page_name;
22
23 /**
24 * The main page title for our admin page
25 *
26 * @var string
27 * @since 2.0.0
28 */
29 private $page_title;
30
31 /**
32 * The page hook itself for registering the meta boxes
33 *
34 * @var string
35 * @since 2.0.0
36 */
37 private $pagehook;
38
39 /**
40 * The settings key
41 *
42 * @var string
43 * @since 2.0.0
44 */
45 private $settings_key;
46
47 /**
48 * The display notices
49 *
50 * @var string
51 * @since 2.0.0
52 */
53 private $display_notices;
54
55 /**
56 * Our Email_Encoder_Run constructor.
57 */
58 function __construct(){
59 $this->page_name = EEB()->settings->get_page_name();
60 $this->page_title = EEB()->settings->get_page_title();
61 $this->settings_key = EEB()->settings->get_settings_key();
62 $this->display_notices = array();
63 $this->add_hooks();
64 }
65
66 /**
67 * Define all of our necessary hooks
68 */
69 private function add_hooks(){
70
71 add_action( 'plugin_action_links_' . EEB_PLUGIN_BASE, array($this, 'plugin_action_links') );
72 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts_and_styles' ) );
73 add_action( 'admin_menu', array( $this, 'add_user_submenu' ), 150 );
74 add_action( 'admin_init', array( $this, 'save_settings' ), 10 );
75 }
76
77 /**
78 * Plugin action links.
79 *
80 * Adds action links to the plugin list table
81 *
82 * Fired by `plugin_action_links` filter.
83 *
84 * @since 2.0.0
85 * @access public
86 *
87 * @param array $links An array of plugin action links.
88 *
89 * @return array An array of plugin action links.
90 */
91 public function plugin_action_links( $links ) {
92 $settings_link = sprintf( '<a href="%s">%s</a>', admin_url( 'options-general.php?page=' . $this->page_name ), __( 'Settings', 'email-encoder-bundle' ) );
93
94 array_unshift( $links, $settings_link );
95
96 $links['visit_us'] = sprintf( '<a href="%s" target="_blank" style="font-weight:700;color:#f1592a;">%s</a>', 'https://wpemailencoder.com/?utm_source=email-encoder-bundle&utm_medium=plugin-overview-website-button&utm_campaign=WP%20Mailto%20Links', __('Visit us', 'email-encoder-bundle') );
97
98 return $links;
99 }
100
101 /**
102 * ######################
103 * ###
104 * #### SCRIPTS & STYLES
105 * ###
106 * ######################
107 */
108
109 /**
110 * Register all necessary scripts and styles
111 *
112 * @since 2.0.0
113 */
114 public function enqueue_scripts_and_styles() {
115 if( EEB()->helpers->is_page( $this->page_name ) ) {
116 $js_version = date( "ymd-Gis", filemtime( EEB_PLUGIN_DIR . 'core/includes/assets/js/custom-admin.js' ));
117 $css_version = date( "ymd-Gis", filemtime( EEB_PLUGIN_DIR . 'core/includes/assets/css/style-admin.css' ));
118
119 wp_enqueue_script( 'eeb-admin-scripts', EEB_PLUGIN_URL . 'core/includes/assets/js/custom-admin.js', array( 'jquery' ), $js_version, true );
120 wp_register_style( 'eeb-css-backend', EEB_PLUGIN_URL . 'core/includes/assets/css/style-admin.css', false, $css_version );
121 wp_enqueue_style ( 'eeb-css-backend' );
122 }
123 }
124
125 /**
126 * ######################
127 * ###
128 * #### MENU TEMPLATE ITEMS
129 * ###
130 * ######################
131 */
132
133 /**
134 * Add our custom admin user page
135 */
136 public function add_user_submenu(){
137
138 if( (string) EEB()->settings->get_setting( 'own_admin_menu', true ) !== '1' ){
139 $this->pagehook = add_submenu_page( 'options-general.php', __( $this->page_title, 'email-encoder-bundle' ), __( $this->page_title, 'email-encoder-bundle' ), EEB()->settings->get_admin_cap( 'admin-add-submenu-page-item' ), $this->page_name, array( $this, 'render_admin_menu_page' ) );
140 } else {
141 $this->pagehook = add_menu_page( __( $this->page_title, 'email-encoder-bundle' ), __( $this->page_title, 'email-encoder-bundle' ), EEB()->settings->get_admin_cap( 'admin-add-menu-page-item' ), $this->page_name, array( $this, 'render_admin_menu_page' ), plugins_url( 'core/includes/assets/img/icon-email-encoder-bundle.png', EEB_PLUGIN_FILE ) );
142 }
143
144 add_action( 'load-' . $this->pagehook, array( $this, 'add_help_tabs' ) );
145 }
146
147 /**
148 * Render the admin submenu page
149 *
150 * You need the specified capability to edit it.
151 */
152 public function render_admin_menu_page(){
153 if( ! current_user_can( EEB()->settings->get_admin_cap('admin-menu-page') ) ){
154 wp_die( __( EEB()->settings->get_default_string( 'insufficient-permissions' ), 'email-encoder-bundle' ) );
155 }
156
157 include( EEB_PLUGIN_DIR . 'core/includes/partials/eeb-page-display.php' );
158
159 }
160
161 /**
162 * ######################
163 * ###
164 * #### SETTINGS LOGIC
165 * ###
166 * ######################
167 */
168
169 public function save_settings(){
170
171 if( isset( $_POST[ $this->page_name . '_nonce' ] ) ){
172 if( ! wp_verify_nonce( $_POST[ $this->page_name . '_nonce' ], $this->page_name ) ){
173 wp_die( __( 'You don\'t have permission to update these settings.', 'email-encoder-bundle' ) );
174 }
175
176 if( ! current_user_can( EEB()->settings->get_admin_cap( 'admin-update-settings' ) ) ){
177 wp_die( __( 'You don\'t have permission to update these settings.', 'email-encoder-bundle' ) );
178 }
179
180 if( isset( $_POST[ $this->settings_key ] ) && is_array( $_POST[ $this->settings_key ] ) ){
181 $check = update_option( $this->settings_key, $_POST[ $this->settings_key ] );
182 if( $check ){
183 EEB()->settings->reload_settings();
184 $update_notice = EEB()->helpers->create_admin_notice( 'Settings successfully saved.', 'success', true );
185 $this->display_notices[] = $update_notice;
186 } else {
187 $update_notice = EEB()->helpers->create_admin_notice( 'No changes were made to your settings with your last save.', 'info', true );
188 $this->display_notices[] = $update_notice;
189 }
190 }
191
192 }
193
194 }
195
196 /**
197 * ######################
198 * ###
199 * #### HELP TABS TEMPLATE ITEMS
200 * ###
201 * ######################
202 */
203 public function add_help_tabs(){
204 $screen = get_current_screen();
205
206 $defaults = array(
207 'content' => '',
208 'callback' => array( $this, 'load_help_tabs' ),
209 );
210
211 $screen->add_help_tab(wp_parse_args(array(
212 'id' => 'general',
213 'title' => __('General', 'email-encoder-bundle'),
214 ), $defaults));
215
216 $screen->add_help_tab(wp_parse_args(array(
217 'id' => 'shortcodes',
218 'title' => __('Shortcode', 'email-encoder-bundle'),
219 ), $defaults));
220
221 $screen->add_help_tab(wp_parse_args(array(
222 'id' => 'template-tags',
223 'title' => __('Template Tags', 'email-encoder-bundle'),
224 ), $defaults));
225
226 if( EEB()->helpers->is_page( $this->page_name ) ){
227 add_meta_box( 'encode_form', __( $this->page_title, 'email-encoder-bundle' ), array( $this, 'show_meta_box_content' ), null, 'normal', 'core', array( 'encode_form' ) );
228 }
229
230 }
231
232 public function load_help_tabs($screen, array $args){
233
234 if( ! empty( $args['id'] ) ){
235 include( EEB_PLUGIN_DIR . 'core/includes/partials/help-tabs/' . $args['id'] . '.php' );
236 }
237
238 }
239
240 /**
241 * Show content of metabox (callback)
242 * @param array $post
243 * @param array $meta_box
244 */
245 public function show_meta_box_content( $post, $meta_box ) {
246 $key = $meta_box['args'][0];
247
248 if ($key === 'encode_form') {
249 ?>
250 <p><?php _e('If you like you can also create you own secured emails manually with this form. Just copy/paste the generated code and put it in your post, page or template. We choose automatically the best method for you, based on your settings.', 'email-encoder-bundle') ?></p>
251
252 <hr style="border:1px solid #FFF; border-top:1px solid #EEE;" />
253
254 <?php echo EEB()->validate->get_encoder_form(); ?>
255
256 <hr style="border:1px solid #FFF; border-top:1px solid #EEE;"/>
257
258 <?php
259
260 $form_frontend = (bool) EEB()->settings->get_setting( 'encoder_form_frontend', true, 'encoder_form' );
261 if( $form_frontend ){
262 ?>
263 <p class="description"><?php _e('You can also put the encoder form on your site by using the shortcode <code>[eeb_form]</code> or the template function <code>eeb_form()</code>.', 'email-encoder-bundle') ?></p>
264 <?php
265 } else {
266 ?>
267 <p class="description"><?php _e('In case you want to display the Email Encoder form within the frontend, you can activate it inside of the Advanced settings.', 'email-encoder-bundle') ?></p>
268 <?php
269 }
270 }
271
272 }
273
274 }
275