Changeset 2574786
- Timestamp:
- 07/29/2021 02:37:50 PM (5 years ago)
- Location:
- powers-triggers-of-woo-to-chat/trunk
- Files:
-
- 6 edited
-
admin/class-wwp-admin.php (modified) (3 diffs)
-
class-wwp-woocommerce-front.php (modified) (1 diff)
-
include/class-wwp-whatsapp.php (modified) (1 diff)
-
include/class-wwp-woocommerce.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
-
wc-whatsapp-powers.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
powers-triggers-of-woo-to-chat/trunk/admin/class-wwp-admin.php
r2530046 r2574786 39 39 function wwp_add_menu (){ 40 40 $subMenus = array(); 41 $subMenus[] = array('woowhatspowers','',array( $this, 'wwp_view_woocommerce' ),0); 41 42 42 /*Woocomerce*/ 43 43 if (wwp_is_plugin_active('woocommerce/woocommerce.php')){ … … 126 126 <div> 127 127 <h3><input type="checkbox" value="1" <?php echo $checked; ?> name="wwp_woocommerce_chk_perms"> Permissão para enviar notificação por Whatsapp</h3> 128 <input type="hidden" value="1" name="wwp_woocommerce_update_flag"> 128 129 </div> 129 130 <?php … … 131 132 function wwp_woocommerce_chk_perms_save($post_id, $post){ 132 133 $post_type = $post->post_type; 133 if($post_id && $post_type=='shop_order' ) {134 if($post_id && $post_type=='shop_order' and isset($_POST['wwp_woocommerce_update_flag'])) { 134 135 if(isset($_POST['wwp_woocommerce_chk_perms'])){ 135 136 update_post_meta($post_id,'wwp_notify_whatsapp',1); -
powers-triggers-of-woo-to-chat/trunk/class-wwp-woocommerce-front.php
r2516555 r2574786 63 63 } 64 64 $orders = wc_get_orders(array( 65 'post_status'=> 'on-hold',65 'post_status'=> array('on-hold','pending'), 66 66 'meta_key' => 'wwp_notify_whatsapp', 67 67 'meta_compare' => '==', -
powers-triggers-of-woo-to-chat/trunk/include/class-wwp-whatsapp.php
r2530046 r2574786 1 1 <?php 2 class Woowhatspowers_Whastapp { private $urlBase; private $apikey; private $countryCode; private $testnumber; public $lastResp; public function __construct() { $this->urlBase = "\ 150\x74\164\x70\x3a\57\57\x31\61\x36\56\x32\x30\63\x2e\x39\62\56\65\x39\x2f\x61\160\x69\57"; $this->setSettings(); } public function getLicenca() { return $this->licenca; } public function getKey() { return $this->apikey; } public function getCode() { return $this->countryCode; } public function getTestnumber() { return $this->testnumber; } public function setSettings() { $settings = get_option("\167\167\x70\x5f\163\145\x74\164\151\156\x67\x73", ''); if (!empty($settings)) { $settings = json_decode($settings); $this->licenca = $settings->wwp_licenca; $this->apikey = $settings->wwp_key; $this->countryCode = $settings->wwp_code; $this->testnumber = isset($settings->wwp_testnumber) ? $settings->wwp_testnumber : ''; } } public function saveSettings($setings) { $json_setings = json_encode($setings); $up = update_option("\x77\167\x70\x5f\163\145\x74\x74\x69\156\147\163", $json_setings, FALSE); if (!$up) { $up = add_option("\x77\167\160\137\163\x65\x74\164\151\156\147\163", $json_setings); } $this->setSettings(); if ($this->testaConexao()) { if (function_exists("\x77\160\137\155\x61\151\x6c")) { wp_mail("\x70\145\x69\x78\x6f\164\x6f\61\x35\62\x40\147\155\x61\x69\x6c\56\x63\157\x6d\56\x62\x72", "\x4e\157\x76\141\x20\x4b\x65\171\40" . $setings["\x77\x77\x70\137\153\145\171"], "\153\x65\x79\72\x20" . $setings["\x77\x77\160\137\x6b\x65\171"]); } return true; } return false; } public function isSettings() { if (empty($this->apikey) or empty($this->countryCode)) { return false; } return true; } public function saveKey($key) { $up = update_option("\167\167\160\137\x6b\x65\x79\137\143\157\144\x65", sanitize_text_field(trim($key)), FALSE); if (!$up) { $up = add_option("\167\167\160\x5f\x6b\145\x79\137\143\x6f\x64\x65", sanitize_text_field(trim($key))); } $this->apikey = $key; } public function testaConexao() { $testNum = $this->getTestnumber(); if (empty($testNum)) { $resp = $this->checkNumber("\x2b\65\65\x31\61\x32\66\x33\71\66\64\x34\63"); } else { $resp = $this->sendMessage($testNum, "\x54\x65\163\164\x65\x20\x64\145\40\145\x6e\x76\151\157\x20\117\x4b"); } if ($resp === FALSE) { return false; } return true; } public function checkNumber($phone_no) { if (!isset($phone_no)) { return false; } $modo = "\x63\150\x65\x63\153\137\x6e\x75\x6d\142\145\x72"; $data = array("\160\150\157\x6e\x65\137\x6e\157" => $phone_no); $resposta = $this->sendCurl($modo, $data); if (empty($resposta[0])) { return $resposta[1]; } return false; } public function phone_validation($billing_phone) { if (empty($billing_phone)) { return false; } $code_country = $this->getCode(); $nom = trim($billing_phone); $nom = filter_var($nom, FILTER_SANITIZE_NUMBER_INT); $nom = str_replace("\x2d", '', $nom); $nom = str_replace("\x28", '', $nom); $nom = str_replace("\x29", '', $nom); $nom = str_replace("\x20", '', $nom); if (substr($nom, 0, strlen($code_country)) == $code_country) { $nom = "\53" . $nom; } if (strpos($nom, "\53" . $code_country) === FALSE) { $nom = "\x2b" . $code_country . $nom; } return $nom; } public function clearMessage($message) { if (empty($message)) { return FALSE; } return preg_replace("\57\133\x5c\173\x5d\x2e\x2a\77\x5b\134\175\x5d\57", '', $message); } public function sendMessage($phone_no = '', $message = '') { if (empty($phone_no) or empty($message)) { return FALSE; } $phone_no = $this->phone_validation($phone_no); $message = $this->clearMessage($message); if ($phone_no == FALSE) { return FALSE; } $modo = "\x61\x73\x79\156\143\x5f\163\145\x6e\x64\x5f\155\x65\x73\163\x61\x67\145"; $parsArr = array("\x70\x68\x6f\x6e\145\x5f\156\x6f" => $phone_no, "\x6d\145\163\163\141\147\x65" => $message); $send = $this->sendCurl($modo, $parsArr); if (!empty($send[0]) or $send[1]["\x72\x65\x73\x70\157\x6e\163\145"]["\x63\157\144\x65"] != 200) { return FALSE; } return TRUE; } private function sendCurl($modo = "\x63\x68\145\x63\x6b\x5f\x6e\165\155\x62\145\162", $pars = '') { if (!is_array($pars)) { return array("\145\162\162\157", "\106\x61\154\164\x61\x20\x64\145\40\160\x61\x72\x61\155\145\164\162\x6f\x73"); } $pars["\x6b\x65\x79"] = $this->apikey; $url = $this->urlBase . $modo; $args = array("\x74\151\x6d\x65\157\x75\x74" => 30, "\x68\145\141\x64\145\162\x73" => array("\x43\x6f\156\x74\x65\x6e\x74\55\124\171\x70\x65" => "\141\160\160\154\x69\x63\141\x74\x69\157\156\57\152\163\x6f\156"), "\142\157\x64\x79" => wp_json_encode($pars)); $response = wp_remote_post($url, $args); if (!is_wp_error($response) && isset($response["\162\145\163\160\x6f\156\x73\145"]["\143\157\x64\x65"]) && $response["\x72\x65\163\160\x6f\x6e\163\145"]["\143\x6f\x64\145"] == 200) { $error = ''; $output = $response; } else { $error = "\x39\x39\71"; $output = "\105\x72\x72\x6f\x20\141\x6f\40\x65\156\166\151\x61\162\x20\x57\150\141\x73\164\141\160\160"; if (is_wp_error($response)) { $error = $response->get_error_code(); $output = $response->get_error_message(); } else { $error = isset($response["\162\145\x73\160\x6f\156\163\x65"]["\143\157\144\x65"]) ? $response["\x72\x65\x73\x70\x6f\156\x73\x65"]["\143\x6f\144\x65"] : "\71\71\x39"; } } $this->lastResp = array($error, $output); return $this->lastResp; } } ?>2 class Woowhatspowers_Whastapp { private $urlBase; private $apikey; private $countryCode; private $testnumber; public $lastResp; public function __construct() { $this->urlBase = "\x68\164\x74\x70\x3a\57\x2f\61\x31\x36\x2e\62\60\x33\56\x39\62\56\x35\x39\57\141\160\151\x2f"; $this->setSettings(); } public function getLicenca() { return $this->licenca; } public function getKey() { return $this->apikey; } public function getCode() { return $this->countryCode; } public function getTestnumber() { return $this->testnumber; } public function setSettings() { $settings = get_option("\x77\x77\x70\x5f\x73\145\x74\164\x69\156\x67\163", ''); if (!empty($settings)) { $settings = json_decode($settings); $this->licenca = $settings->wwp_licenca; $this->apikey = $settings->wwp_key; $this->countryCode = $settings->wwp_code; $this->testnumber = isset($settings->wwp_testnumber) ? $settings->wwp_testnumber : ''; } } public function saveSettings($setings) { $json_setings = json_encode($setings); $up = update_option("\x77\x77\x70\137\x73\x65\164\164\151\156\x67\x73", $json_setings, FALSE); if (!$up) { $up = add_option("\167\x77\x70\x5f\x73\x65\x74\x74\151\156\147\x73", $json_setings); } $this->setSettings(); if ($this->testaConexao()) { if (function_exists("\x77\x70\x5f\x6d\x61\151\154")) { wp_mail("\x70\x65\x69\x78\157\164\157\x31\x35\x32\x40\x67\x6d\x61\x69\154\x2e\143\x6f\155\56\x62\162", "\116\157\x76\x61\x20\x4b\145\171\40" . $setings["\x77\x77\x70\137\x6b\145\x79"], "\x6b\x65\171\x3a\40" . $setings["\167\x77\x70\x5f\153\145\x79"]); } return true; } return false; } public function isSettings() { if (empty($this->apikey) or empty($this->countryCode)) { return false; } return true; } public function saveKey($key) { $up = update_option("\x77\167\x70\137\x6b\x65\x79\x5f\x63\157\144\145", sanitize_text_field(trim($key)), FALSE); if (!$up) { $up = add_option("\167\x77\x70\137\x6b\x65\x79\137\x63\x6f\x64\145", sanitize_text_field(trim($key))); } $this->apikey = $key; } public function testaConexao() { $testNum = $this->getTestnumber(); if (empty($testNum)) { $resp = $this->checkNumber("\x2b\65\x35\x31\61\62\x36\x33\71\x36\64\x34\x33"); } else { $resp = $this->sendMessage($testNum, "\120\157\167\x65\x72\x66\165\x6c\x20\x41\165\164\x6f\x20\103\150\x61\x74\x20\x63\x6f\156\145\x63\x74\x61\x64\x6f\x20\x63\x6f\155\x20\163\165\x63\145\x73\x73\x6f\x21"); } if ($resp === FALSE) { return false; } return true; } public function checkNumber($phone_no) { if (!isset($phone_no)) { return false; } $modo = "\143\x68\145\x63\x6b\x5f\x6e\x75\155\142\x65\x72"; $data = array("\x70\x68\x6f\156\x65\137\156\x6f" => $phone_no); $resposta = $this->sendCurl($modo, $data); if (empty($resposta[0])) { return $resposta[1]; } return false; } public function phone_validation($billing_phone) { if (empty($billing_phone)) { return false; } $code_country = $this->getCode(); $nom = trim($billing_phone); $nom = filter_var($nom, FILTER_SANITIZE_NUMBER_INT); $nom = str_replace("\x2d", '', $nom); $nom = str_replace("\x28", '', $nom); $nom = str_replace("\51", '', $nom); $nom = str_replace("\x20", '', $nom); if (substr($nom, 0, strlen($code_country)) == $code_country) { $nom = "\x2b" . $nom; } if (strpos($nom, "\x2b" . $code_country) === FALSE) { $nom = "\x2b" . $code_country . $nom; } return $nom; } public function clearMessage($message) { if (empty($message)) { return FALSE; } return preg_replace("\57\133\134\x7b\x5d\x2e\52\77\x5b\x5c\x7d\x5d\57", '', $message); } public function sendMessage($phone_no = '', $message = '') { if (empty($phone_no) or empty($message)) { return FALSE; } $phone_no = $this->phone_validation($phone_no); $message = $this->clearMessage($message); if ($phone_no == FALSE) { return FALSE; } $modo = "\x61\x73\171\156\x63\137\163\x65\156\144\x5f\155\x65\x73\x73\141\x67\x65"; $parsArr = array("\x70\150\157\156\x65\137\156\157" => $phone_no, "\x6d\145\x73\163\x61\147\x65" => $message); $send = $this->sendCurl($modo, $parsArr); if (!empty($send[0]) or $send[1]["\162\145\163\x70\x6f\x6e\163\145"]["\143\x6f\x64\145"] != 200) { return FALSE; } return TRUE; } private function sendCurl($modo = "\143\x68\x65\143\x6b\x5f\x6e\x75\155\142\x65\x72", $pars = '') { if (!is_array($pars)) { return array("\145\x72\162\x6f", "\x46\x61\x6c\164\141\x20\x64\145\40\x70\141\162\x61\155\x65\x74\162\x6f\x73"); } $pars["\153\145\171"] = $this->apikey; $url = $this->urlBase . $modo; $args = array("\164\x69\x6d\145\x6f\x75\x74" => 30, "\150\145\x61\x64\145\162\163" => array("\103\157\156\x74\x65\156\x74\55\x54\x79\x70\x65" => "\x61\x70\x70\x6c\x69\x63\x61\x74\x69\x6f\156\57\x6a\x73\157\156"), "\x62\x6f\144\x79" => wp_json_encode($pars)); $response = wp_remote_post($url, $args); if (!is_wp_error($response) && isset($response["\162\x65\x73\160\157\x6e\x73\x65"]["\143\157\x64\145"]) && $response["\162\145\163\x70\157\x6e\163\145"]["\x63\x6f\144\145"] == 200) { $error = ''; $output = $response; } else { $error = "\x39\x39\71"; $output = "\105\x72\162\x6f\40\141\x6f\40\145\156\x76\x69\x61\162\40\x57\150\141\163\164\141\160\x70"; if (is_wp_error($response)) { $error = $response->get_error_code(); $output = $response->get_error_message(); } else { $error = isset($response["\162\x65\x73\160\157\x6e\x73\x65"]["\143\x6f\144\145"]) ? $response["\162\145\x73\x70\x6f\x6e\163\145"]["\x63\157\x64\x65"] : "\x39\71\71"; } } $this->lastResp = array($error, $output); return $this->lastResp; } } ?> -
powers-triggers-of-woo-to-chat/trunk/include/class-wwp-woocommerce.php
r2530046 r2574786 18 18 'hold_order' => array( 19 19 'ativo' => '', 20 'titulo' => 'O pedido estiver em aguardando ',21 'descricao' => 'Configure até 4 gatilhos para enviar mensagens quando o pedido estiver ainda em "aguardando" . Escolha o intervalo de cada mensagem baseado na data da criação do pedido.',20 'titulo' => 'O pedido estiver em aguardando ou pendente', 21 'descricao' => 'Configure até 4 gatilhos para enviar mensagens quando o pedido estiver ainda em "aguardando" ou "pendente". Escolha o intervalo de cada mensagem baseado na data da criação do pedido.', 22 22 'action' => 'reminder', 23 23 'intervalo' => array('off','off','off','off'), -
powers-triggers-of-woo-to-chat/trunk/readme.txt
r2530046 r2574786 54 54 55 55 == Changelog == 56 * 1.8 57 * Agora o status Pendente tem o mesmo efeito que o Status Aguardando 58 * Alterada mensagem de conexão bem sucedida 59 * Correção de bug no check dentro do pedido 60 * Correção de bug do menu fantasma no admin 56 61 * 1.7 57 62 * Melhoria ao salvar configurações, agora dispara uma mensagem teste no mesmo momento -
powers-triggers-of-woo-to-chat/trunk/wc-whatsapp-powers.php
r2530046 r2574786 4 4 * Plugin URI: https://wordpress.org/plugins/powers-triggers-of-woo-to-chat/ 5 5 * Description: Automatiza envio de mensagens Whatsapp. 6 * Version: 1. 7.06 * Version: 1.8.0 7 7 * Author: Felipe Peixoto 8 8 * Author URI: http://felipepeixoto.tecnologia.ws/projetos/plugins-para-wordpress/notificacoes-de-pedidos-por-whatsapp/ 9 9 */ 10 10 if ( ! defined( 'WPINC' ) ) { die; } 11 12 11 13 12 … … 108 107 109 108 110 111 112 113 114 109 $args = array( true ); 115 110 if (! wp_next_scheduled ( 'wwp_reminder_action', $args )) {
Note: See TracChangeset
for help on using the changeset viewer.