PluginProbe
EmailKit – Email Customizer for WooCommerce & WP / 1.6.0
EmailKit – Email Customizer for WooCommerce & WP v1.6.0
1.6.9 1.6.8 1.6.7 trunk 1.0.0 1.2.0 1.4.0 1.4.5 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6
emailkit / Promotional / Util.php

Util.php in EmailKit – Email Customizer for WooCommerce & WP 1.6.0, at Promotional/Util.php

109 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace EmailKit\Promotional;
3
4 defined( 'ABSPATH' ) || exit;
5 /**
6 * Global helper class.
7 *
8 * @since 1.0.0
9 */
10
11 class Util{
12
13 public static $instance = null;
14 private static $key = 'emailkit_options';
15
16 public static function get_option( $key, $default = '' ) {
17 $data_all = get_option( self::$key );
18 return ( isset( $data_all[ $key ] ) && $data_all[ $key ] != '' ) ? $data_all[ $key ] : $default;
19 }
20
21 public static function save_option( $key, $value = '' ) {
22 $data_all = get_option( self::$key ) ?? [];
23 $data_all[ $key ] = $value;
24 return update_option( self::$key, $data_all );
25 }
26
27 public static function get_settings( $key, $default = '' ) {
28 $data_all = self::get_option( 'settings', array() );
29 return ( isset( $data_all[ $key ] ) && $data_all[ $key ] != '' ) ? $data_all[ $key ] : $default;
30 }
31
32 public static function save_settings( $new_data = '' ) {
33 $data_old = self::get_option( 'settings', array() );
34 $data = array_merge( $data_old, $new_data );
35 return self::save_option( 'settings', $data );
36 }
37
38 public static function emailkit_admin_action() {
39 // Check for nonce security
40 $status = '';
41
42 if (!isset($_POST['nonce']) || ! wp_verify_nonce( sanitize_key(wp_unslash($_POST['nonce'])), 'ajax-nonce' ) ) {
43 return;
44 }
45
46
47 if ( ! current_user_can( 'manage_options' ) ) {
48 return;
49 }
50
51
52 if ( isset( $_POST['settings'] ) ) {
53 $status = self::save_settings( empty( $_POST['settings'] ) ? array() : map_deep( wp_unslash( $_POST['settings'] ) , 'sanitize_text_field' ) );
54 }
55
56 if($status){
57 wp_send_json_success();
58 }else{
59 wp_send_json_error();
60 }
61 exit;
62 }
63
64 public static function instance() {
65 if ( is_null( self::$instance ) ) {
66
67 // Fire the class instance
68 self::$instance = new self();
69 }
70
71 return self::$instance;
72 }
73
74
75 /**
76 * Get emailkit older version if has any.
77 *
78 * @since 1.0.0
79 * @access public
80 */
81 public static function old_version(){
82 $version = get_option('emailkit_version');
83 return null == $version ? -1 : $version;
84 }
85
86 public static function array_push_assoc($array, $key, $value){
87 $array[$key] = $value;
88 return $array;
89 }
90
91 public static function render($content){
92 if (stripos($content, "emailkit-has-lisence") !== false) {
93 return null;
94 }
95
96 return $content;
97 }
98
99 public static function get_form_settings($key){
100 $options = get_option('emailkit_option__settings');
101 return isset($options[$key]) ? $options[$key] : '';
102 }
103 public static function emailkit_content_renderer($content){
104 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
105 echo $content;
106 }
107
108 }
109