Recommended
1 year ago
Support
1 year ago
Cross.php
1 year ago
Fallback.php
1 year ago
Fields.php
1 year ago
Helper.php
1 year ago
I18n.php
1 year ago
Plugin.php
1 year ago
Popup.php
1 year ago
PostType.php
1 year ago
Review.php
1 year ago
Settings.php
1 year ago
Shortcode.php
1 year ago
Upgrade.php
1 year ago
Fields.php
143 lines
| 1 | <?php |
| 2 | |
| 3 | namespace NTA_WhatsApp; |
| 4 | |
| 5 | defined( 'ABSPATH' ) || exit; |
| 6 | |
| 7 | class Fields { |
| 8 | |
| 9 | protected static $instance = null; |
| 10 | |
| 11 | public static function getInstance() { |
| 12 | if ( null === self::$instance ) { |
| 13 | self::$instance = new self(); |
| 14 | } |
| 15 | return self::$instance; |
| 16 | } |
| 17 | |
| 18 | public function __construct() { |
| 19 | } |
| 20 | |
| 21 | public static function getButtonStyles( $postId ) { |
| 22 | $meta = get_post_meta( $postId, 'nta_wa_button_styles', true ); |
| 23 | return wp_parse_args( |
| 24 | $meta === false ? array() : $meta, |
| 25 | array( |
| 26 | 'type' => 'round', |
| 27 | 'backgroundColor' => '#2DB742', |
| 28 | 'textColor' => '#fff', |
| 29 | 'label' => __( 'Need Help? Chat with us', 'wp-whatsapp' ), |
| 30 | 'width' => 300, |
| 31 | 'height' => 64, |
| 32 | ) |
| 33 | ); |
| 34 | } |
| 35 | |
| 36 | |
| 37 | public static function getWidgetDisplay() { |
| 38 | return wp_parse_args( |
| 39 | get_option( 'nta_wa_widget_display', array() ), |
| 40 | array( |
| 41 | 'displayCondition' => 'showAllPage', |
| 42 | 'includePages' => array(), |
| 43 | 'excludePages' => array(), |
| 44 | 'includePosts' => array(), |
| 45 | 'showOnDesktop' => 'ON', |
| 46 | 'showOnMobile' => 'ON', |
| 47 | 'time_symbols' => 'h:m', |
| 48 | ) |
| 49 | ); |
| 50 | } |
| 51 | |
| 52 | public static function getURLSettings() { |
| 53 | return wp_parse_args( |
| 54 | get_option( 'nta_wa_url', array() ), |
| 55 | array( |
| 56 | 'onDesktop' => 'api', |
| 57 | 'onMobile' => 'api', |
| 58 | 'openInNewTab' => 'ON', |
| 59 | ) |
| 60 | ); |
| 61 | } |
| 62 | |
| 63 | public static function getWidgetStyles() { |
| 64 | return wp_parse_args( |
| 65 | get_option( 'nta_wa_widget_styles', array() ), |
| 66 | array( |
| 67 | 'title' => __( 'Start a Conversation', 'wp-whatsapp' ), |
| 68 | 'responseText' => __( 'The team typically replies in a few minutes.', 'wp-whatsapp' ), |
| 69 | 'description' => __( 'Hi! Click one of our member below to chat on <strong>WhatsApp</strong>', 'wp-whatsapp' ), |
| 70 | 'backgroundColor' => '#2db742', |
| 71 | 'textColor' => '#fff', |
| 72 | 'titleSize' => 18, |
| 73 | 'accountNameSize' => 14, |
| 74 | 'descriptionTextSize' => 12, |
| 75 | 'regularTextSize' => 11, |
| 76 | 'scrollHeight' => 500, |
| 77 | 'isShowScroll' => 'OFF', |
| 78 | 'isShowResponseText' => 'ON', |
| 79 | 'isShowPoweredBy' => 'ON', |
| 80 | |
| 81 | 'btnLabel' => __( 'Need Help? <strong>Chat with us</strong>', 'wp-whatsapp' ), |
| 82 | 'btnLabelWidth' => 156, |
| 83 | 'btnPosition' => 'right', |
| 84 | 'btnLeftDistance' => 30, |
| 85 | 'btnRightDistance' => 30, |
| 86 | 'btnBottomDistance' => 30, |
| 87 | 'isShowBtnLabel' => 'ON', |
| 88 | |
| 89 | 'isShowGDPR' => 'OFF', |
| 90 | 'gdprContent' => __( 'Please accept our <a href="https://ninjateam.org/privacy-policy/">privacy policy</a> first to start a conversation.', 'wp-whatsapp' ), |
| 91 | ) |
| 92 | ); |
| 93 | } |
| 94 | |
| 95 | public static function getWoocommerceSetting() { |
| 96 | $option = get_option( 'nta_wa_woocommerce', array() ); |
| 97 | return wp_parse_args( |
| 98 | $option, |
| 99 | array( |
| 100 | 'position' => 'after_atc', |
| 101 | 'isShow' => 'OFF', |
| 102 | ) |
| 103 | ); |
| 104 | } |
| 105 | |
| 106 | public static function getAnalyticsSetting() { |
| 107 | $option = get_option( 'nta_wa_analytics', array() ); |
| 108 | return wp_parse_args( |
| 109 | $option, |
| 110 | array( |
| 111 | 'enabledGoogle' => 'OFF', |
| 112 | 'enabledFacebook' => 'OFF', |
| 113 | 'enabledGoogleGA4' => 'OFF', |
| 114 | ) |
| 115 | ); |
| 116 | } |
| 117 | |
| 118 | public static function getDefaultMetaAccount( $daysOfWeek ) { |
| 119 | $meta = array( |
| 120 | 'number' => '', |
| 121 | 'title' => '', |
| 122 | 'predefinedText' => '', |
| 123 | 'willBeBackText' => __( 'I will be back in [njwa_time_work]', 'wp-whatsapp' ), |
| 124 | 'dayOffsText' => __( 'I will be back soon', 'wp-whatsapp' ), |
| 125 | 'isAlwaysAvailable' => 'ON', |
| 126 | ); |
| 127 | |
| 128 | foreach ( $daysOfWeek as $dayKey ) { |
| 129 | $meta['daysOfWeekWorking'][ $dayKey ] = array( |
| 130 | 'isWorkingOnDay' => 'OFF', |
| 131 | 'workHours' => array( |
| 132 | array( |
| 133 | 'startTime' => '08:00', |
| 134 | 'endTime' => '17:30', |
| 135 | ), |
| 136 | ), |
| 137 | ); |
| 138 | } |
| 139 | |
| 140 | return $meta; |
| 141 | } |
| 142 | } |
| 143 |