Plugin Directory

Changeset 3261474


Ignore:
Timestamp:
03/25/2025 11:12:55 AM (12 months ago)
Author:
fromdoppler
Message:

update plugin version 1.0.12

Location:
doppler-for-learnpress
Files:
80 added
5 edited

Legend:

Unmodified
Added
Removed
  • doppler-for-learnpress/trunk/README.txt

    r3226551 r3261474  
    44Tags: email marketing
    55Requires at least: 4.9
    6 Tested up to: 6.7.1
     6Tested up to: 6.7.2
    77Requires PHP: 5.6.4
    8 Stable tag: 1.0.11
     8Stable tag: 1.0.12
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1313
    1414== Changelog ==
     15= 1.0.12 =
     16* Update: Add counter for syncronized contacts
     17
    1518= 1.0.11 =
    1619* Update: Apply Doppler's style library
  • doppler-for-learnpress/trunk/admin/class-doppler-for-learnpress-admin.php

    r3166525 r3261474  
    240240
    241241        if(empty($_POST['list_id'])) wp_die();
    242        
    243242        $list_id = intval($_POST['list_id']);       
    244243        $students = $this->get_students();
     
    248247            wp_die();
    249248        }
     249        $studentsAmount = is_array($students) ? count($students) : 0;
    250250        $subscriber_resource = $this->doppler_service->getResource( 'subscribers' );
    251251        $this->set_origin();
     
    258258   
    259259        if( !empty($map) ){
     260            $lists = $this->get_alpha_lists();
    260261            foreach($map as $mapped_course){
    261                     $course_id = $mapped_course['course_id'];
    262                     $students = $this->get_students_from_course ($course_id);
    263                     $result = $subscriber_resource->importSubscribers( $mapped_course['list_id'], $this->get_subscribers_for_import($students) )['body'];
    264             }
    265         }
    266        
    267         echo $result;
     262                    if(isset($lists[$mapped_course['list_id']]))
     263                    {
     264                        $course_id = $mapped_course['course_id'];
     265                        $students = $this->get_students_from_course ($course_id);
     266                        $subscriber_resource->importSubscribers( $mapped_course['list_id'], $this->get_subscribers_for_import($students) )['body'];
     267                    }
     268            }
     269        }
     270
     271        echo json_encode(array('apiResponse' => $result, 'studentsCount' => $studentsAmount));
    268272        wp_die();
    269273    }
     
    290294        return array( 'email'=>$student->user_email, "fields" => array() );
    291295    }
    292 
    293     /**
    294      * Subscribe customer to list after
    295      * course subscription from fromt-end
    296      *
    297      * @since 1.0.0
    298      */
    299     /*
    300     public function dplr_after_customer_subscription( $order_id ) {
    301         echo 'dplr_after_customer_subscription';
    302         die();
    303         $order = new LP_Order( $order_id );
    304         $lists = get_option('dplr_learnpress_subscribers_list');
    305         if(!empty($lists)){
    306             $list_id = $lists['buyers'];
    307             $order = new LP_Order( $order_id );
    308             $user_data = get_userdata($order->user_id);
    309             $user_email = $user_data->data->user_email;
    310             $this->set_credentials();
    311             $this->subscribe_customer( $list_id, $user_email, array() );
    312         }
    313     }*/
    314296
    315297    /**
     
    332314                //Subscribe to global buyers list.
    333315                $lists = get_option('dplr_learnpress_subscribers_list');
    334                 $list_id = $lists['buyers'];
    335                 $this->subscribe_user_or_users($users, $list_id);
     316                if (is_array($lists)) {
     317                    $list_id = $lists['buyers'];
     318                    $this->subscribe_user_or_users($users, $list_id);
     319                    $lists['count'] = intval($lists['count']) + (is_array($users) ? count($users) : 1);
     320                    update_option('dplr_learnpress_subscribers_list', $lists);
     321                }
    336322               
    337323                //Check if course is mapped for registering subscriptions and subscribe.
    338324                $map = get_option('dplr_learnpress_courses_map');
    339325                if( !empty($map) ){
    340                     foreach($map as $mapped_course){
     326                    foreach($map as $index => $mapped_course){
    341327                        foreach($order_items as $k=>$order_item){
    342328                            $course_id = $order_item['course_id'];
     
    344330                                //Subscribe user or users
    345331                                $this->subscribe_user_or_users($users, $mapped_course['list_id']);
     332           
     333                                //update counter
     334                                $mapped_course['count'] += (is_array($users) ? count($users) : 1);
     335                                $map[$index] = $mapped_course;
    346336                            }
    347337                        }
    348338                    }
     339                    update_option('dplr_learnpress_courses_map', $map);
    349340                }
    350341            }
     
    355346                $list_id = $lists['buyers'];
    356347                $this->subscribe_user_or_users($users, $list_id, $user_email);
     348                $lists['count'] += (is_array($users) ? count($users) : 1);
     349
     350                update_option('dplr_learnpress_courses_map', $lists);
    357351
    358352                $map = get_option('dplr_learnpress_courses_map');
    359353                if( !empty($map) ){
    360                     foreach($map as $mapped_course){
     354                    foreach($map as $index => $mapped_course){
    361355                        foreach($order_items as $k=>$order_item){
    362356                            $course_id = $order_item['course_id'];
     
    364358                                //Subscribe user or users
    365359                                $this->subscribe_user_or_users($users, $mapped_course['list_id'], $user_email);
     360
     361                                //update counter
     362                                $mapped_course['count'] += (is_array($users) ? count($users) : 1);
     363                                $map[$index] = $mapped_course;
    366364                            }
    367365                        }
    368366                    }
     367                    update_option('dplr_learnpress_courses_map', $map);
    369368                }
    370369            }
     
    520519        }
    521520
    522         //TODO: action_id is always 1 atm.
    523         //a course plus an action have an associated list
    524         //$dplr_courses_map[][$_POST['course_id']][$_POST['action_id']] = $_POST['list_id'];
     521        $students = $this->get_students_from_course ($_POST['course_id']);
     522        $subscriber_resource = $this->doppler_service->getResource('subscribers');
     523        $subscribers = $this->get_subscribers_for_import($students);
     524        $result = $subscriber_resource->importSubscribers( $_POST['list_id'], $subscribers )['body'];
     525       
    525526        $dplr_courses_map[] = array(
    526                             'course_id'=>$_POST['course_id'],
    527                             'action_id'=>$_POST['action_id'],
    528                             'list_id'=>$_POST['list_id']
    529                         );
    530         if(update_option( 'dplr_learnpress_courses_map', $dplr_courses_map )){
    531             //Map, then synch!
    532             $students = $this->get_students_from_course ($_POST['course_id']);
    533             $subscriber_resource = $this->doppler_service->getResource('subscribers');
    534             $result = $subscriber_resource->importSubscribers( $_POST['list_id'], $this->get_subscribers_for_import($students) )['body'];
    535             wp_send_json_success();
    536         }
     527            'course_id'=>$_POST['course_id'],
     528            'action_id'=>$_POST['action_id'],
     529            'list_id'=>$_POST['list_id'],
     530            'count'=>count($subscribers['items'])
     531        );
     532        update_option('dplr_learnpress_courses_map', $dplr_courses_map);
     533
     534        wp_send_json_success();
     535
    537536        wp_die();
    538537    }
  • doppler-for-learnpress/trunk/admin/js/doppler-for-learnpress-admin.js

    r3166525 r3261474  
    3737            synchBuyers(buyersList).then(function (response) {
    3838                var obj = JSON.parse(response);
    39                 if (obj.createdResourceId || obj.errCode == "NoStudentsFound") {
     39                if (JSON.parse(obj.apiResponse).createdResourceId || obj.errCode == "NoStudentsFound") {
     40                    $('<input>').attr({
     41                        type: 'hidden',
     42                        id: 'counter',
     43                        name: 'dplr_learnpress_subscribers_list[count]',
     44                        value: obj.studentsCount
     45                    }).appendTo('#dplr-lp-form-list');
     46
    4047                    $("#dplr-lp-form-list").submit();
    4148                } else {
  • doppler-for-learnpress/trunk/admin/partials/doppler-for-learnpress-admin-display.php

    r3166525 r3261474  
    3737            $active_tab = 'settings';
    3838           
    39             if( isset($_POST['dplr_learnpress_subscribers_list']) && $this->validate_subscribers_list($_POST['dplr_learnpress_subscribers_list']) && current_user_can('manage_options') && check_admin_referer('map-lists') ){
     39            if( isset($_POST['dplr_learnpress_subscribers_list'])
     40                && $this->validate_subscribers_list($_POST['dplr_learnpress_subscribers_list'])
     41            && current_user_can('manage_options')
     42            && check_admin_referer('map-lists') )
     43            {
    4044                update_option( 'dplr_learnpress_subscribers_list', $this->sanitize_subscribers_list($_POST['dplr_learnpress_subscribers_list']) );
    4145                $this->set_success_message(__('Your List has been syncronized and saved succesfully.', 'doppler-for-learnpress'));
     
    4953
    5054            require_once('settings.php');
    51 
    52                
    5355            ?>
    5456           
  • doppler-for-learnpress/trunk/doppler-for-learnpress.php

    r3166525 r3261474  
    1111 * Plugin URI:        www.fromdoppler.com
    1212 * Description:       Submit your LearnPress students to a Doppler Lists.
    13  * Version:           1.0.11
     13 * Version:           1.0.12
    1414 * Author:            Doppler
    1515 * License:           GPL-2.0+
     
    2424}
    2525
    26 define( 'DOPPLER_FOR_LEARNPRESS_VERSION', '1.0.11' );
     26define( 'DOPPLER_FOR_LEARNPRESS_VERSION', '1.0.12' );
    2727define( 'DOPPLER_FOR_LEARNPRESS_PLUGIN_FILE', plugin_basename( __FILE__ ));
    2828define( 'DOPPLER_FOR_LEARNPRESS_URL', plugin_dir_url(__FILE__) );
Note: See TracChangeset for help on using the changeset viewer.