Plugin Directory

Changeset 2426245


Ignore:
Timestamp:
11/26/2020 05:07:05 AM (5 years ago)
Author:
felipemontoya
Message:

Update trunk to version 2.6.1

Location:
edunext-openedx-integrator/trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • edunext-openedx-integrator/trunk/assets/js/commons.min.js

    r2152571 r2426245  
    44ENEXT.OPENEDX_DOMAIN = ENEXT_SRV.lms_base_url;
    55ENEXT.WP_LOGOUT_URL = ENEXT_SRV.wp_logout_url;
     6ENEXT.WP_USER_LOGGEDIN = Boolean(ENEXT_SRV.wp_user_logged_in);
    67ENEXT.ENROLLMENT_API_LOCATION = ENEXT.OPENEDX_DOMAIN + ENEXT_SRV.enrollment_api_location;
    78
     
    4647
    4748ENEXT.assertSessionSynchrony = function() {
    48     if (!ENEXT.amILoggedIn()) {
     49    if (!ENEXT.amILoggedIn() && ENEXT.WP_USER_LOGGEDIN) {
    4950        jQuery.ajax({
    5051            url: ENEXT.WP_LOGOUT_URL
  • edunext-openedx-integrator/trunk/assets/js/wcWorkflow.min.js

    r2152571 r2426245  
    11'use strict';
    22window.ENEXT = window.ENEXT || {};
     3window.ENEXT_SRV = window.ENEXT_SRV || {};
     4window.ENEXT_SC = window.ENEXT_SC || {};
    35
    4 ENEXT.OPENEDX_DOMAIN = ENEXT_SRV.lms_base_url;
     6ENEXT.OPENEDX_DOMAIN = ENEXT_SRV.lms_base_url || ENEXT_SC.lms_base_url;
    57ENEXT.LOGIN_NEXT = ENEXT_SRV.lms_wp_return_path;
    68ENEXT.LOGIN_PATH = ENEXT_SRV.lms_login_path;
    7 ENEXT.RUN_FUNCTIONS = ENEXT_SRV.run_functions;
     9ENEXT.RUN_FUNCTIONS = [].concat(ENEXT_SRV.run_functions).concat(ENEXT_SC.run_shortcode);
     10ENEXT.PREFILL_MAPPINGS = ENEXT_SRV.prefill_mappings;
    811
    912ENEXT.CACHE = {};
    1013
    1114
    12 ENEXT.callMeAtOpenEdx = function() {
    13     if ('api_user_v1_me' in ENEXT.CACHE) {
    14         return ENEXT.CACHE['api_user_v1_me'];
     15ENEXT.callApiAtOpenEdx = function(endpoint) {
     16    if ('api_user_v1_' + endpoint in ENEXT.CACHE) {
     17        return ENEXT.CACHE['api_user_v1_' + endpoint];
    1518    }
    16     ENEXT.CACHE['api_user_v1_me'] = jQuery.ajax({
    17         url: ENEXT.OPENEDX_DOMAIN + "/api/user/v1/me",
     19    ENEXT.CACHE['api_user_v1_' + endpoint] = jQuery.ajax({
     20        url: ENEXT.OPENEDX_DOMAIN + "/api/user/v1/" + endpoint,
    1821        method: "GET",
    1922        xhrFields: {
     
    2124        }
    2225    })
    23     return ENEXT.CACHE['api_user_v1_me'];
     26    return ENEXT.CACHE['api_user_v1_' + endpoint];
    2427}
    2528
    26 ENEXT.assertOpenEdxLoggedIn = function() {
    27     ENEXT.callMeAtOpenEdx().fail(function(xhr) {
     29ENEXT.assertOpenEdxLoggedIn = function(includeData) {
     30    var endpoint = 'me';
     31    if (includeData) {
     32        var endpoint = 'accounts';
     33    }
     34
     35    ENEXT.callApiAtOpenEdx(endpoint).fail(function(xhr) {
    2836        if (xhr.status === 401) {
    2937            // Not logged in, redirecting
     
    4149};
    4250
    43 ENEXT.addUsernameToCheckout = function() {
    44     ENEXT.callMeAtOpenEdx().success(function(data) {
    45         if ('username' in data) {
    46             var apiUsername = data.username;
    47             jQuery('form[name="checkout"]').append('<input type="hidden" name="wpt_oer_username" value="' + apiUsername + '">');
     51ENEXT.assertOpenEdxLoggedInWithData = function(includeData) {
     52    ENEXT.assertOpenEdxLoggedIn(true);
     53}
     54
     55ENEXT.prefillVisibleFields = function() {
     56    ENEXT.callApiAtOpenEdx('accounts').success(function(dataArray) {
     57        var data = dataArray[0];
     58        var mappings = JSON.parse(ENEXT.PREFILL_MAPPINGS);
     59        data['extended_profile'].map(( ({field_name, field_value}) => data[field_name] = field_value));
     60
     61        for (let prop in mappings) {
     62            jQuery('form[name="checkout"] #' + prop).val(data[mappings[prop]]);
    4863        }
    49         else {
    50             console.warn("The openedx integrator plugin could not find the username to insert to the checkout form.");
     64    });
     65}
     66
     67ENEXT.replaceShortcodeFields = function() {
     68    ENEXT.callApiAtOpenEdx('accounts').success(function(dataArray) {
     69        var data = dataArray[0];
     70        jQuery('.js-order-info-sc').each(function(index, item){
     71            var $item = jQuery(item);
     72            if ($item.data('field') in data) {
     73                $item.html(data[$item.data('field')]);
     74            }
     75        });
     76    });
     77}
     78
     79ENEXT.addInfoToCheckout = function() {
     80    ENEXT.callApiAtOpenEdx('accounts').success(function(dataArray) {
     81        var data = dataArray[0];
     82        var fields = ['username', 'name', 'email'];
     83        for (var i = fields.length - 1; i >= 0; i--) {
     84            if (fields[i] in data) {
     85                jQuery('form[name="checkout"]').append('<input type="hidden" name="wpt_oer_' + fields[i] + '" value="' + data[fields[i]] + '">');
     86            }
     87            else {
     88                console.warn("The openedx integrator plugin could not find the " + fields[i] + " to insert to the checkout form.");
     89            }
    5190        }
    5291    });
     
    5594// Run the defined functions
    5695for (var i = 0; i < ENEXT.RUN_FUNCTIONS.length; i++) {
    57     ENEXT[ENEXT.RUN_FUNCTIONS[i]]();
     96    if (ENEXT.RUN_FUNCTIONS[i] in ENEXT) {
     97        ENEXT[ENEXT.RUN_FUNCTIONS[i]]();
     98    }
    5899}
  • edunext-openedx-integrator/trunk/includes/class-wp-edunext-marketing-site-settings.php

    r2152571 r2426245  
    204204                array(
    205205                    'id'               => 'enable_session_existence_sync',
    206                     'label'            => __( 'Log out of WP when openedx is not logged in', 'wp-edunext-marketing-site' ),
    207                     'description'      => __( 'This will force the users to login on openedx to mantain a valid session on WordPress.', 'wp-edunext-marketing-site' ),
     206                    'label'            => __( 'Log out of WP when Open edX is not logged in', 'wp-edunext-marketing-site' ),
     207                    'description'      => __( 'This will force the users to login on Open edX to mantain a valid session on WordPress.', 'wp-edunext-marketing-site' ),
    208208                    'type'             => 'checkbox',
    209209                    'default'          => false,
     
    661661                array(
    662662                    'id'               => 'enable_wc_checkout_loggedin_intervention',
    663                     'label'            => __( 'Get username information from openedx into the checkout page', 'wp-edunext-marketing-site' ),
     663                    'label'            => __( 'Get username information from Open edX into the checkout page', 'wp-edunext-marketing-site' ),
    664664                    'description'      => __( 'Make sure that users have a valid session when they access the woocommerce checkout form. The username for said session is then used for the order fulfillment.', 'wp-edunext-marketing-site' ),
    665665                    'type'             => 'checkbox',
     
    675675                    'default'     => '/checkout',
    676676                    'placeholder' => '/cart',
     677                ),
     678                array(
     679                    'id'               => 'enable_wc_checkout_client_prefill',
     680                    'label'            => __( 'Enable Checkout client-side fields pre-filling', 'wp-edunext-marketing-site' ),
     681                    'description'      => __( 'Enables the pre-filling of the checkout form fields by the calls to the Open edX accounts API. Requires the users to have a valid Open edX session.', 'wp-edunext-marketing-site' ),
     682                    'type'             => 'checkbox',
     683                    'default'          => false,
     684                    'placeholder'      => '',
     685                    'advanced_setting' => true,
     686                ),
     687                array(
     688                    'id'               => 'enable_wc_checkout_client_prefill_mappings',
     689                    'label'            => __( 'User Profile fields mapping for client-side pre-filling', 'wp-edunext-marketing-site' ),
     690                    'description'      => __( 'Mapping of user fields for pre-filling, from the accounts api in Open edX to the to Woocommerce chekout form fields.', 'wp-edunext-marketing-site', 'wp-edunext-marketing-site' ),
     691                    'type'             => 'textarea',
     692                    'default'          => '{"billing_email": "email" , "billing_first_name": "name"}',
     693                    'placeholder'      => '{"billing_email": "email" , "billing_first_name": "name", ...}',
     694                    'advanced_setting' => true,
    677695                ),
    678696            ),
  • edunext-openedx-integrator/trunk/includes/class-wp-edunext-marketing-site.php

    r2152571 r2426245  
    280280            'user_enrollment_url'        => get_option( 'wpt_user_enrollment_url' ),
    281281            'course_has_not_started_url' => get_option( 'wpt_course_has_not_started_url' ),
     282            'wp_user_logged_in'          => is_user_logged_in(),
    282283            'wp_logout_url'              => false,
    283284        );
  • edunext-openedx-integrator/trunk/includes/lib/class-wp-edunext-marketing-site-menu-items-attributes.php

    r2152571 r2426245  
    1515        $item_output = '';
    1616        parent::start_el( $item_output, $item, $depth, $args );
     17
    1718        // Inject $new_fields before: <div class="menu-item-actions description-wide submitbox">.
    18         if ( $new_fields = Edx_Nav_Menu_Item_Custom_Fields::get_field( $item, $depth, $args ) ) {
     19        $new_fields = Edx_Nav_Menu_Item_Custom_Fields::get_field( $item, $depth, $args );
     20        if ( $new_fields ) {
    1921            $label       = '<p class="edx-hide-if">Hide if Open edX user is:</p>';
    2022            $new_html    = '<div class="clear">' . $label . $new_fields . '</div>';
  • edunext-openedx-integrator/trunk/readme.txt

    r2152571 r2426245  
    33Tags: wordpress, Open edX, LMS
    44Requires at least: 4.0
    5 Tested up to: 5.2
    6 Stable tag: 2.1.0
     5Tested up to: 5.5.3
     6Stable tag: 2.6.1
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    131131    [edunext_enroll_button course_id="course-v1:organization+coursenumber+courserun" label_enroll="Enroll in the course now"]
    132132
    133 == Screenshots ==       
    134 1. General Settings     
    135 2. Configuration of the User Menu       
    136 3. Addition of the User Menu       
    137 4. Configuration of the course buttons     
    138 5. Addition of course buttons       
    139 6. Woocommerce integration     
     133== Screenshots ==
     1341. General Settings
     1352. Configuration of the User Menu
     1363. Addition of the User Menu
     1374. Configuration of the course buttons
     1385. Addition of course buttons
     1396. Woocommerce integration
    1401407. EOX - API backend
    141141
     
    168168* Initial release
    169169
    170 == Translations ==     
    171 * English - default, always included       
     170== Translations ==
     171* English - default, always included
    172172
    173173Note: All the strings in this plugins are localized / translateable by default. In case you need assistance with a particular localization issue, or want to contribute with one traslation, please reach out to eduNEXT (https://edunext.co)
  • edunext-openedx-integrator/trunk/wp-edunext-marketing-site.php

    r2152571 r2426245  
    22/**
    33 * Plugin Name: Open edX LMS and WordPress integrator (LITE)
    4  * Version: 2.1.0
     4 * Version: 2.6.1
    55 * Description: Set up your WordPress site as the front end site or marketing site for your online learning initiative powered by the open edX platform.
    66 * Author: eduNEXT
    77 * Author URI: https://edunext.co/
    88 * Requires at least: 4.0
    9  * Tested up to: 5.2
     9 * Tested up to: 5.5.3
    1010 *
    1111 * Text Domain: wp-edunext-marketing-site
     
    4343 */
    4444function WP_eduNEXT_Marketing_Site() {
    45     $instance = WP_eduNEXT_Marketing_Site::instance( __FILE__, '2.1.0' );
     45    $instance = WP_eduNEXT_Marketing_Site::instance( __FILE__, '2.6.1' );
    4646
    4747    if ( is_null( $instance->settings ) ) {
Note: See TracChangeset for help on using the changeset viewer.