Changeset 2718672
- Timestamp:
- 05/05/2022 02:40:33 PM (4 years ago)
- Location:
- wp-sms-functions/trunk
- Files:
-
- 6 edited
-
inc/providers/Gri_Provider.php (modified) (2 diffs)
-
lang/wp-sms-functions-tr_TR.mo (modified) (previous)
-
lang/wp-sms-functions-tr_TR.po (modified) (3 diffs)
-
lang/wp-sms-functions.pot (modified) (2 diffs)
-
readme.txt (modified) (1 diff)
-
wp-sms-functions.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wp-sms-functions/trunk/inc/providers/Gri_Provider.php
r2676477 r2718672 2 2 3 3 if (!class_exists('ProviderBase')) { 4 require_once 'ProviderBase.php';4 require_once 'ProviderBase.php'; 5 5 } 6 6 7 7 class Gri_Provider extends ProviderBase 8 8 { 9 public function __construct()10 {9 public function __construct() 10 { 11 11 12 $this->slug = 'Gri';13 $this->name = 'Gri SMS';14 $this->api_base_url = 'https://sms-api2.gri.net';12 $this->slug = 'Gri'; 13 $this->name = 'Gri SMS'; 14 $this->api_base_url = 'https://sms-api3.gri.net'; 15 15 16 add_filter('Smsfunctions_providers', function ($prov) {17 $prov[$this->slug] = $this->name;16 add_filter('Smsfunctions_providers', function ($prov) { 17 $prov[$this->slug] = $this->name; 18 18 19 return $prov;20 });19 return $prov; 20 }); 21 21 22 add_action('Smsfunctions_provider_settings', array($this, 'settings'));23 add_filter('Smsfunctions_fields', function ($fields) {24 return array_merge($fields, $this->fields());25 });22 add_action('Smsfunctions_provider_settings', array($this, 'settings')); 23 add_filter('Smsfunctions_fields', function ($fields) { 24 return array_merge($fields, $this->fields()); 25 }); 26 26 27 }27 } 28 28 29 public function fields()30 {31 return array(32 'gri_api_key',33 'gri_secret_key',34 'gri_msg_header'35 );36 }29 public function fields() 30 { 31 return array( 32 'gri_api_key', 33 'gri_secret_key', 34 'gri_msg_header' 35 ); 36 } 37 37 38 public function get_options()39 {40 $vals = array();41 $fields = $this->fields();42 foreach ($fields as $field) {43 $vals[$field] = get_option($field, '');44 }38 public function get_options() 39 { 40 $vals = array(); 41 $fields = $this->fields(); 42 foreach ($fields as $field) { 43 $vals[$field] = get_option($field, ''); 44 } 45 45 46 return $vals;47 }46 return $vals; 47 } 48 48 49 public function getAuthentication()50 {51 $options = $this->get_options();52 $api_key = $options['gri_api_key'];53 $secret_key = $options['gri_secret_key'];54 return array(55 'Authorization' => 'Basic ' . base64_encode($api_key . ':' . $secret_key),56 'Content-Type' => 'application/json'57 );58 }49 public function getAuthentication() 50 { 51 $options = $this->get_options(); 52 $api_key = $options['gri_api_key']; 53 $secret_key = $options['gri_secret_key']; 54 return array( 55 'Authorization' => 'Basic ' . base64_encode($api_key . ':' . $secret_key), 56 'Content-Type' => 'application/json' 57 ); 58 } 59 59 60 public function send_sms($gsmNo = '', $message = '')61 {62 $options = $this->get_options();63 $header = $options['gri_msg_header'];60 public function send_sms($gsmNo = '', $message = '') 61 { 62 $options = $this->get_options(); 63 $header = $options['gri_msg_header']; 64 64 65 $message = str_replace('\"', '"', $message); //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!65 $message = str_replace('\"', '"', $message); //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 66 66 67 $post_fields = json_encode(array(68 'header' => $header,69 'message' => $message,70 'phone' => $gsmNo71 ), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);67 $post_fields = json_encode(array( 68 'header' => $header, 69 'message' => $message, 70 'phone' => $gsmNo 71 ), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); 72 72 73 $authentication = $this->getAuthentication();73 $authentication = $this->getAuthentication(); 74 74 75 try { 76 $request = parent::wpPost($this->api_base_url . '/SendSms', $post_fields, $authentication); 77 $response = json_decode($request); 75 $request = parent::wpPost($this->api_base_url . '/SendSms', $post_fields, $authentication); 76 $response = json_decode($request); 78 77 79 $errors = array(); 80 if (isset($response->errors)) { 81 foreach ($response->errors as $error) 82 { 83 $errors[] = implode(" - " , $error); 84 } 85 throw new Exception( count( $errors ) ? implode("\n", $errors) : 'An error occurred!' ); 86 } 87 } catch (Exception $ex) { 88 throw $ex; 89 } 78 if(isset($response->Result)) 79 $response=$response->Result; 90 80 91 return true; 92 } 81 if( isset($response->status) && !$response->status && isset($response->message) ) 82 throw new \Exception($response->message); 93 83 94 public function settings($selected_provider) 95 {96 $options = $this->get_options(); 97 $selected_provider = strtolower($selected_provider); 98 $is_tokens = !empty($options['gri_api_key']) && !empty($options['gri_secret_key']);99 if ($selected_provider === 'gri') { 100 $request = parent::wpGet($this->api_base_url . '/Headers', array(), $this->getAuthentication());101 $response_for_sms_headers = json_decode($request); 84 $errors = array(); 85 if (isset($response->errors)) { 86 foreach ($response->errors as $error) 87 { 88 $errors[] = implode(" - " , $error); 89 } 90 throw new Exception( count( $errors ) ? implode("\n", $errors) : 'An error occurred!' ); 91 } 102 92 103 if (!is_array($response_for_sms_headers) && isset($response_for_sms_headers->message)) { 104 echo "<strong style='color:red'>" . 105 $response_for_sms_headers->message . 106 "</strong>"; 107 } 108 } 109 ?> 93 return true; 94 } 95 96 public function settings($selected_provider) 97 { 98 $options = $this->get_options(); 99 $selected_provider = strtolower($selected_provider); 100 $is_tokens = !empty($options['gri_api_key']) && !empty($options['gri_secret_key']); 101 if ($selected_provider === 'gri') { 102 $request = parent::wpGet($this->api_base_url . '/Headers', array(), $this->getAuthentication()); 103 $response_for_sms_headers = json_decode($request); 104 105 if(is_object($response_for_sms_headers) && isset($response_for_sms_headers->Result)) 106 $response_for_sms_headers = $response_for_sms_headers->Result; 107 108 if ( isset($response_for_sms_headers->status) && !($response_for_sms_headers->status) && isset($response_for_sms_headers->message)) { 109 echo "<strong style='color:red'>" . 110 $response_for_sms_headers->message . 111 "</strong>"; 112 } 113 } 114 ?> 110 115 <table id="gri" class="form-table provider_tab" 111 116 style="display: <?php echo esc_html((($selected_provider == 'gri') ? 'block' : 'none')); ?>"> … … 122 127 /></td> 123 128 </tr> 124 <?php if (is_array($response_for_sms_headers) && count($response_for_sms_headers)): ?>129 <?php if (is_array($response_for_sms_headers) && count($response_for_sms_headers)): ?> 125 130 <tr> 126 131 <th><?php esc_html_e('SMS Header', 'wp-sms-functions') ?></th> 127 132 <td> 128 <?php129 if (!$is_tokens) {130 esc_html_e('You must save api key and secret key to select the message header.', 'wp-sms-functions');131 } else {132 ?>133 <?php 134 if (!$is_tokens) { 135 esc_html_e('You must save api key and secret key to select the message header.', 'wp-sms-functions'); 136 } else { 137 ?> 133 138 <select name="gri_msg_header"> 134 139 <option value=""><?php esc_html_e('Select', 'wp-sms-functions'); ?></option> 135 <?php136 foreach ($response_for_sms_headers as $header) {137 $selected = ($options['gri_msg_header'] == $header) ? 'selected' : '';140 <?php 141 foreach ($response_for_sms_headers as $header) { 142 $selected = ($options['gri_msg_header'] == $header) ? 'selected' : ''; 138 143 139 echo "<option {$selected} value='{$header}'>{$header}</option>";140 }144 echo "<option {$selected} value='{$header}'>{$header}</option>"; 145 } 141 146 142 ?>147 ?> 143 148 </select> 144 <?php } ?>149 <?php } ?> 145 150 </td> 146 151 </tr> 147 152 <tr> 148 <th><?php esc_html_e(' Last Balance', 'wp-sms-functions') ?></th>153 <th><?php esc_html_e('Balance Remaining', 'wp-sms-functions') ?></th> 149 154 <td> 150 <?php 151 if (!$is_tokens) { 152 esc_html_e('You must save api key and secret key to view the balance.', 'wp-sms-functions'); 153 } else { 154 $request = parent::wpGet($this->api_base_url . '/Balance', array(), $this->getAuthentication()); 155 $response_for_balance = json_decode($request); 156 if ($response_for_balance->Balance) { 157 esc_html_e($response_for_balance->Balance); 158 } else { 159 esc_html_e('There is no balance defined for you. Please contact us!', 'wp-sms-functions'); 160 } 161 } 162 ?> 155 <?php 156 if (!$is_tokens) { 157 esc_html_e('You must save api key and secret key to view the balance.', 'wp-sms-functions'); 158 } else { 159 $request = parent::wpGet($this->api_base_url . '/Balance', array(), $this->getAuthentication()); 160 $response_for_balance = json_decode($request); 161 162 if (isset($response_for_balance->Data) && $response_for_balance->Data) { 163 esc_html_e($response_for_balance->Data); 164 } else { 165 esc_html_e('There is no balance defined for you. Please contact us!', 'wp-sms-functions'); 166 } 167 } 168 ?> 163 169 </td> 164 170 </tr> 165 <?php endif; ?>171 <?php endif; ?> 166 172 </table> 167 <?php168 }173 <?php 174 } 169 175 170 176 } -
wp-sms-functions/trunk/lang/wp-sms-functions-tr_TR.po
r2640749 r2718672 5 5 "Project-Id-Version: SMS Provider 1.0\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wp-sms-functions\n" 7 "POT-Creation-Date: 202 1-12-07 18:16+0300\n"8 "PO-Revision-Date: 202 1-12-07 18:17+0300\n"7 "POT-Creation-Date: 2022-05-05 17:39+0300\n" 8 "PO-Revision-Date: 2022-05-05 17:39+0300\n" 9 9 "Last-Translator: \n" 10 10 "Language-Team: \n" … … 105 105 msgstr "API Gizli Kodu(Secret)" 106 106 107 #: inc/providers/Gri_Provider.php:1 07inc/providers/PandaSMS_Provider.php:143107 #: inc/providers/Gri_Provider.php:118 inc/providers/PandaSMS_Provider.php:143 108 108 msgid "API Key" 109 109 msgstr "API Anahtarı" 110 110 111 #: inc/providers/Gri_Provider.php:1 13111 #: inc/providers/Gri_Provider.php:124 112 112 msgid "Secret Key" 113 113 msgstr "API Gizli Kodu(Secret)" 114 114 115 #: inc/providers/Gri_Provider.php:1 20115 #: inc/providers/Gri_Provider.php:131 116 116 msgid "SMS Header" 117 117 msgstr "SMS Başlığı" 118 118 119 #: inc/providers/Gri_Provider.php:1 24119 #: inc/providers/Gri_Provider.php:135 120 120 msgid "You must save api key and secret key to select the message header." 121 121 msgstr "Mesaj başlıklarının görüntülenebilmesi için API bilgilerinizi giriniz." 122 122 123 #: inc/providers/Gri_Provider.php:1 28123 #: inc/providers/Gri_Provider.php:139 124 124 msgid "Select" 125 125 msgstr "Seçiniz" 126 126 127 #: inc/providers/Gri_Provider.php:1 42128 msgid " Last Balance"127 #: inc/providers/Gri_Provider.php:153 128 msgid "Balance Remaining" 129 129 msgstr "Kalan Bakiye" 130 130 131 #: inc/providers/Gri_Provider.php:1 46131 #: inc/providers/Gri_Provider.php:157 132 132 msgid "You must save api key and secret key to view the balance." 133 133 msgstr "Kalan bakiye bilgisi için ilk olarak API bilgilerinizi kaydediniz." 134 134 135 #: inc/providers/Gri_Provider.php:1 53135 #: inc/providers/Gri_Provider.php:165 136 136 msgid "There is no balance defined for you. Please contact us!" 137 137 msgstr "Tanımlı bakiyeniz bulunamadı. Lütfen iletişime geçiniz. info@gri.net" … … 226 226 msgstr "https://www.gri.net" 227 227 228 #~ msgid "Last Balance" 229 #~ msgstr "Kalan Bakiye" 230 228 231 #~ msgid "You do not have sufficient permissions to access this page." 229 232 #~ msgstr "Bu sayfaya erişmek için yetkiniz yok." -
wp-sms-functions/trunk/lang/wp-sms-functions.pot
r2640749 r2718672 1 # Copyright (C) 202 1WP SMS Functions1 # Copyright (C) 2022 WP SMS Functions 2 2 # This file is distributed under the same license as the WP SMS Functions package. 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: WP SMS Functions 1.2. 4\n"5 "Project-Id-Version: WP SMS Functions 1.2.6\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wp-sms-functions\n" 7 "POT-Creation-Date: 202 1-12-07 15:15:26+00:00\n"7 "POT-Creation-Date: 2022-05-05 14:39:34+00:00\n" 8 8 "MIME-Version: 1.0\n" 9 9 "Content-Type: text/plain; charset=UTF-8\n" 10 10 "Content-Transfer-Encoding: 8bit\n" 11 "PO-Revision-Date: 202 1-MO-DA HO:MI+ZONE\n"11 "PO-Revision-Date: 2022-MO-DA HO:MI+ZONE\n" 12 12 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" 13 13 "Language-Team: LANGUAGE <LL@li.org>\n" … … 102 102 msgstr "" 103 103 104 #: inc/providers/Gri_Provider.php:1 07inc/providers/PandaSMS_Provider.php:143104 #: inc/providers/Gri_Provider.php:118 inc/providers/PandaSMS_Provider.php:143 105 105 msgid "API Key" 106 106 msgstr "" 107 107 108 #: inc/providers/Gri_Provider.php:1 13108 #: inc/providers/Gri_Provider.php:124 109 109 msgid "Secret Key" 110 110 msgstr "" 111 111 112 #: inc/providers/Gri_Provider.php:1 20112 #: inc/providers/Gri_Provider.php:131 113 113 msgid "SMS Header" 114 114 msgstr "" 115 115 116 #: inc/providers/Gri_Provider.php:1 24116 #: inc/providers/Gri_Provider.php:135 117 117 msgid "You must save api key and secret key to select the message header." 118 118 msgstr "" 119 119 120 #: inc/providers/Gri_Provider.php:1 28120 #: inc/providers/Gri_Provider.php:139 121 121 msgid "Select" 122 122 msgstr "" 123 123 124 #: inc/providers/Gri_Provider.php:1 42125 msgid " Last Balance"126 msgstr "" 127 128 #: inc/providers/Gri_Provider.php:1 46124 #: inc/providers/Gri_Provider.php:153 125 msgid "Balance Remaining" 126 msgstr "" 127 128 #: inc/providers/Gri_Provider.php:157 129 129 msgid "You must save api key and secret key to view the balance." 130 130 msgstr "" 131 131 132 #: inc/providers/Gri_Provider.php:1 53132 #: inc/providers/Gri_Provider.php:165 133 133 msgid "There is no balance defined for you. Please contact us!" 134 134 msgstr "" -
wp-sms-functions/trunk/readme.txt
r2676477 r2718672 46 46 == Changelog == 47 47 48 = 1.2.6 = 49 * Gri SMS provider updated. 50 48 51 = 1.2.5 = 49 52 * Gri SMS provider updated. -
wp-sms-functions/trunk/wp-sms-functions.php
r2676477 r2718672 6 6 * Author URI: https://www.gri.net 7 7 * Text Domain: wp-sms-functions 8 * Version: 1.2. 58 * Version: 1.2.6 9 9 * Domain Path: /lang 10 10 * Requires at least: 4.9
Note: See TracChangeset
for help on using the changeset viewer.