PluginProbe ʕ •ᴥ•ʔ
WP Chat App / 3.8.2
WP Chat App v3.8.2
3.8.1 3.8.2 trunk 2.6 3.4 3.4.1 3.4.2 3.4.4 3.4.5 3.4.6 3.5 3.6 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.6.9 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.8.0
wp-whatsapp / includes / Helper.php
wp-whatsapp / includes Last commit date
Support 2 months ago Cross.php 2 months ago Fallback.php 2 months ago Fields.php 2 months ago Helper.php 2 months ago I18n.php 2 months ago Plugin.php 2 months ago Popup.php 2 months ago PostType.php 2 months ago Review.php 2 months ago Settings.php 2 months ago Shortcode.php 2 months ago Upgrade.php 2 months ago
Helper.php
129 lines
1 <?php
2 namespace NTA_WhatsApp;
3
4 defined( 'ABSPATH' ) || exit;
5
6 class Helper {
7
8 protected static $instance = null;
9 public static function getInstance() {
10 if ( null === self::$instance ) {
11 self::$instance = new self();
12 }
13 return self::$instance;
14 }
15
16 public function __construct() {
17 }
18
19 public static function printWorkingDays( $array_data ) {
20 if ( $array_data['isAlwaysAvailable'] === 'ON' ) {
21 return __( 'Always online', 'wp-whatsapp' );
22 }
23
24 $date_string = '';
25 $daysOfWeek = array(
26 'sunday' => __( 'Sunday', 'wp-whatsapp' ),
27 'monday' => __( 'Monday', 'wp-whatsapp' ),
28 'tuesday' => __( 'Tuesday', 'wp-whatsapp' ),
29 'wednesday' => __( 'Wednesday', 'wp-whatsapp' ),
30 'thursday' => __( 'Thursday', 'wp-whatsapp' ),
31 'friday' => __( 'Friday', 'wp-whatsapp' ),
32 'saturday' => __( 'Saturday', 'wp-whatsapp' ),
33 );
34
35 foreach ( $array_data['daysOfWeekWorking'] as $dayKey => $dayVal ) {
36 if ( $dayVal['isWorkingOnDay'] === 'ON' ) {
37 $date_string .= $daysOfWeek[ $dayKey ] . ', ';
38 }
39 }
40
41 $date_string = trim( $date_string, ', ' );
42 return $date_string;
43 }
44
45 public static function getValueOrDefault( $object, $objectKey, $defaultValue = '' ) {
46 return ( isset( $object[ $objectKey ] ) ? $object[ $objectKey ] : $defaultValue );
47 }
48
49 public static function buildTimeSelector( $default = '08:00', $interval = '+30 minutes' ) {
50 $output = '';
51
52 $current = strtotime( '00:00' );
53 $end = strtotime( '23:59' );
54
55 while ( $current <= $end ) {
56 $time = date( 'H:i', $current );
57 $sel = ( $time == $default ) ? ' selected' : '';
58
59 $output .= "<option value=\"{$time}\"{$sel}>" . date( 'H:i', $current ) . '</option>';
60 $current = strtotime( $interval, $current );
61 }
62 $sel = ( $default === '23:59' ) ? ' selected' : '';
63 $output .= "<option value=\"23:59\"{$sel}>" . '23:59' . '</option>';
64 return $output;
65 }
66
67 public static function sanitize_array( $var ) {
68 if ( is_array( $var ) ) {
69 return array_map( 'self::sanitize_array', $var );
70 } else {
71 return is_scalar( $var ) ? sanitize_text_field( $var ) : $var;
72 }
73 }
74
75 public static function checkGDPR( $option ) {
76 if ( $option['isShowGDPR'] === 'OFF' ) {
77 return false;
78 }
79 if ( isset( $_COOKIE['nta-wa-gdpr'] ) && $_COOKIE['nta-wa-gdpr'] == 'accept' ) {
80 return false;
81 }
82 return true;
83 }
84
85 public static function isSaveNewPost( $refererUrl ) {
86 $add_new_action = strpos( $refererUrl, 'post-new.php' );
87 if ( $add_new_action !== false ) {
88 return true;
89 }
90 return false;
91 }
92
93 public static function wp_timezone_string() {
94 $timezone_string = get_option( 'timezone_string' );
95
96 if ( $timezone_string ) {
97 return $timezone_string;
98 }
99
100 $offset = (float) get_option( 'gmt_offset' );
101 $hours = (int) $offset;
102 $minutes = ( $offset - $hours );
103
104 $sign = ( $offset < 0 ) ? '-' : '+';
105 $abs_hour = abs( $hours );
106 $abs_mins = abs( $minutes * 60 );
107 $tz_offset = sprintf( '%s%02d:%02d', $sign, $abs_hour, $abs_mins );
108
109 return $tz_offset;
110 }
111
112 public static function print_icon() {
113 return '<svg width="48px" height="48px" class="nta-whatsapp-default-avatar" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
114 viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve">
115 <path style="fill:#EDEDED;" d="M0,512l35.31-128C12.359,344.276,0,300.138,0,254.234C0,114.759,114.759,0,255.117,0
116 S512,114.759,512,254.234S395.476,512,255.117,512c-44.138,0-86.51-14.124-124.469-35.31L0,512z"/>
117 <path style="fill:#55CD6C;" d="M137.71,430.786l7.945,4.414c32.662,20.303,70.621,32.662,110.345,32.662
118 c115.641,0,211.862-96.221,211.862-213.628S371.641,44.138,255.117,44.138S44.138,137.71,44.138,254.234
119 c0,40.607,11.476,80.331,32.662,113.876l5.297,7.945l-20.303,74.152L137.71,430.786z"/>
120 <path style="fill:#FEFEFE;" d="M187.145,135.945l-16.772-0.883c-5.297,0-10.593,1.766-14.124,5.297
121 c-7.945,7.062-21.186,20.303-24.717,37.959c-6.179,26.483,3.531,58.262,26.483,90.041s67.09,82.979,144.772,105.048
122 c24.717,7.062,44.138,2.648,60.028-7.062c12.359-7.945,20.303-20.303,22.952-33.545l2.648-12.359
123 c0.883-3.531-0.883-7.945-4.414-9.71l-55.614-25.6c-3.531-1.766-7.945-0.883-10.593,2.648l-22.069,28.248
124 c-1.766,1.766-4.414,2.648-7.062,1.766c-15.007-5.297-65.324-26.483-92.69-79.448c-0.883-2.648-0.883-5.297,0.883-7.062
125 l21.186-23.834c1.766-2.648,2.648-6.179,1.766-8.828l-25.6-57.379C193.324,138.593,190.676,135.945,187.145,135.945"/>
126 </svg>';
127 }
128 }
129