PluginProbe
EmailKit – Email Customizer for WooCommerce & WP / 1.5.2
EmailKit – Email Customizer for WooCommerce & WP v1.5.2
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 / Onboard / Classes / Utils.php

Utils.php in EmailKit – Email Customizer for WooCommerce & WP 1.5.2, at Promotional/Onboard/Classes/Utils.php

86 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace EmailKit\Promotional\Onboard\Classes;
4
5 defined( 'ABSPATH' ) || exit;
6
7 class Utils{
8
9 public static $instance = null;
10 private static $key = 'emailkit_onboard_options';
11
12 public static function get_dir(){
13 return EMAILKIT_DIR . 'Promotional/Onboard/';
14 }
15
16 public static function get_url(){
17 return EMAILKIT_URL . 'Promotional/Onboard/';
18 }
19
20 public function get_option($key, $default = ''){
21 $data_all = get_option(self::$key);
22 return (isset($data_all[$key]) && $data_all[$key] != '') ? $data_all[$key] : $default;
23 }
24
25 public function save_option($key, $value = ''){
26 $data_all = get_option(self::$key);
27 $data_all[$key] = $value;
28 update_option(self::$key, $data_all);
29 }
30
31 public function get_settings($key, $default = ''){
32 $data_all = $this->get_option('settings', []);
33 return (isset($data_all[$key]) && $data_all[$key] != '') ? $data_all[$key] : $default;
34 }
35
36 public function save_settings($new_data = ''){
37 $data_old = $this->get_option('settings', []);
38 $data = array_merge($data_old, $new_data);
39 $this->save_option('settings', $data);
40 }
41
42 /*
43 -> this method used to check weather the widget active/deactive
44 -> this method takes two paramitter 1. widget name 2. Active/deactive hook
45 */
46 public function is_widget_active_class( $widget_name, $pro_active ){
47 if($pro_active){
48 return 'label-'.esc_attr($widget_name).' attr-panel-heading';
49 }else{
50 return 'label-'.esc_attr($widget_name).' attr-panel-heading pro-disabled';
51 }
52 }
53
54 public function input($input_options){
55 $defaults = [
56 'type' => null,
57 'name' => '',
58 'value' => '',
59 'class' => '',
60 'label' => '',
61 'info' => '',
62 'disabled' => '',
63 'options' => [],
64 ];
65 $input_options = array_merge($defaults, $input_options);
66
67 if(file_exists(self::get_dir() . 'controls/settings/' . $input_options['type'] . '.php')){
68 extract($input_options);
69 include self::get_dir() . 'controls/settings/' . $input_options['type'] . '.php';
70 }
71 }
72
73 public static function strify($str){
74 return strtolower(preg_replace("/[^A-Za-z0-9]/", "__", $str));
75 }
76
77 public static function instance() {
78 if ( is_null( self::$instance ) ) {
79
80 // Fire the class instance
81 self::$instance = new self();
82 }
83
84 return self::$instance;
85 }
86 }