Plugin Directory

Changeset 2954674


Ignore:
Timestamp:
08/17/2023 05:26:30 AM (3 years ago)
Author:
mikepsinn
Message:

Update to version 0.6.7 from GitHub

Location:
quantimodo
Files:
18 added
4 deleted
22 edited
1 copied

Legend:

Unmodified
Added
Removed
  • quantimodo/tags/0.6.7/README.md

    r2954190 r2954674  
    33Tags: social, science, quantified self, mood tracking, digital health, healthcare, mental health
    44Requires at least: 4.3
    5 Stable tag: 0.6.6
     5Stable tag: 0.6.7
    66License: GPLv2 or later
    77License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • quantimodo/tags/0.6.7/build/index.asset.php

    r2945198 r2954674  
    1 <?php return array('dependencies' => array('wp-element'), 'version' => '4d3206538082ae0e488f');
     1<?php return array('dependencies' => array('wp-element'), 'version' => '6d05a41645964c472cb9');
  • quantimodo/tags/0.6.7/build/index.js

    r2945198 r2954674  
    1 (()=>{"use strict";const o=window.wp.element;window.onload=function(){console.log("Quantimodo iFrame block loaded");const{registerBlockType:t}=wp.blocks,{ServerSideRender:e}=wp.editor;t("quantimodo/quantimodo-iframe",{title:"QuantiModo iFrame",icon:"format-gallery",category:"common",attributes:{},edit:function(t){return(0,o.createElement)(e,{block:"quantimodo/quantimodo-iframe",attributes:t.attributes})},save:function(){return null}})}})();
     1/******/ (() => { // webpackBootstrap
     2/******/    "use strict";
     3/******/    var __webpack_modules__ = ({
     4
     5/***/ "@wordpress/element":
     6/*!*********************************!*\
     7  !*** external ["wp","element"] ***!
     8  \*********************************/
     9/***/ ((module) => {
     10
     11module.exports = window["wp"]["element"];
     12
     13/***/ })
     14
     15/******/    });
     16/************************************************************************/
     17/******/    // The module cache
     18/******/    var __webpack_module_cache__ = {};
     19/******/   
     20/******/    // The require function
     21/******/    function __webpack_require__(moduleId) {
     22/******/        // Check if module is in cache
     23/******/        var cachedModule = __webpack_module_cache__[moduleId];
     24/******/        if (cachedModule !== undefined) {
     25/******/            return cachedModule.exports;
     26/******/        }
     27/******/        // Create a new module (and put it into the cache)
     28/******/        var module = __webpack_module_cache__[moduleId] = {
     29/******/            // no module.id needed
     30/******/            // no module.loaded needed
     31/******/            exports: {}
     32/******/        };
     33/******/   
     34/******/        // Execute the module function
     35/******/        __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
     36/******/   
     37/******/        // Return the exports of the module
     38/******/        return module.exports;
     39/******/    }
     40/******/   
     41/************************************************************************/
     42/******/    /* webpack/runtime/compat get default export */
     43/******/    (() => {
     44/******/        // getDefaultExport function for compatibility with non-harmony modules
     45/******/        __webpack_require__.n = (module) => {
     46/******/            var getter = module && module.__esModule ?
     47/******/                () => (module['default']) :
     48/******/                () => (module);
     49/******/            __webpack_require__.d(getter, { a: getter });
     50/******/            return getter;
     51/******/        };
     52/******/    })();
     53/******/   
     54/******/    /* webpack/runtime/define property getters */
     55/******/    (() => {
     56/******/        // define getter functions for harmony exports
     57/******/        __webpack_require__.d = (exports, definition) => {
     58/******/            for(var key in definition) {
     59/******/                if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
     60/******/                    Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
     61/******/                }
     62/******/            }
     63/******/        };
     64/******/    })();
     65/******/   
     66/******/    /* webpack/runtime/hasOwnProperty shorthand */
     67/******/    (() => {
     68/******/        __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
     69/******/    })();
     70/******/   
     71/******/    /* webpack/runtime/make namespace object */
     72/******/    (() => {
     73/******/        // define __esModule on exports
     74/******/        __webpack_require__.r = (exports) => {
     75/******/            if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
     76/******/                Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
     77/******/            }
     78/******/            Object.defineProperty(exports, '__esModule', { value: true });
     79/******/        };
     80/******/    })();
     81/******/   
     82/************************************************************************/
     83var __webpack_exports__ = {};
     84// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
     85(() => {
     86/*!***********************!*\
     87  !*** ./src/index.jsx ***!
     88  \***********************/
     89__webpack_require__.r(__webpack_exports__);
     90/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element");
     91/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
     92
     93function qm_register_blocks() {
     94  console.log('Quantimodo iFrame block loaded');
     95  const {
     96    registerBlockType
     97  } = wp.blocks;
     98  const {
     99    ServerSideRender
     100  } = wp.editor;
     101  debugger;
     102  registerBlockType('quantimodo/qm-iframe', {
     103    title: 'QuantiModo iFrame',
     104    icon: 'format-gallery',
     105    // Choose an icon: https://developer.wordpress.org/resource/dashicons/
     106    category: 'common',
     107    // Choose a category: https://developer.wordpress.org/block-editor/developers/block-api/block-registration/#category-optional
     108    attributes: {
     109      // Here you can define optional block attributes.
     110    },
     111    edit: function (props) {
     112      return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(ServerSideRender, {
     113        block: "quantimodo/qm-iframe",
     114        attributes: props.attributes
     115      });
     116    },
     117    save: function () {
     118      // This block is dynamic so we save nothing to the post content
     119      return null;
     120    }
     121  });
     122  registerBlockType('quantimodo/qm-redirect', {
     123    title: 'QuantiModo Redirect',
     124    icon: 'external',
     125    // Choose an icon: https://developer.wordpress.org/resource/dashicons/
     126    category: 'common',
     127    // Choose a category: https://developer.wordpress.org/block-editor/developers/block-api/block-registration/#category-optional
     128    attributes: {
     129      // Here you can define optional block attributes.
     130    },
     131    edit: function (props) {
     132      return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(ServerSideRender, {
     133        block: "quantimodo/qm-redirect",
     134        attributes: props.attributes
     135      }), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("h1", null, "Block That Redirects to Your QuantiModo App"));
     136    },
     137    save: function () {
     138      // This block is dynamic so we save nothing to the post content
     139      return null;
     140    }
     141  });
     142}
     143wp.domReady(qm_register_blocks);
     144})();
     145
     146/******/ })()
     147;
     148//# sourceMappingURL=index.js.map
  • quantimodo/tags/0.6.7/includes/access_token.php

    r2954190 r2954674  
    1919    $qmClientId = qm_api_client_id();
    2020    $qmClientSecret = $options['quantimodo_client_secret'] ?? null;
    21     $apiHostName = qm_api_hostname();
     21    $apiHostName = qm_api_origin();
    2222    $wpUser = wp_get_current_user();
    2323    $userData = clone $wpUser->data;
  • quantimodo/tags/0.6.7/includes/admin.php

    r2946898 r2954674  
    2424    $quantimodo_client_id = qm_api_client_id();
    2525    $builderUrl = get_app_builder_url();
    26     $introUrl = qm_api_hostname() . '/app/public/#/app/intro?clientId=' . $quantimodo_client_id;
     26    $introUrl = intro_url();
    2727
    2828    ?>
  • quantimodo/tags/0.6.7/includes/core.php

    r2954190 r2954674  
    11<?php
     2include 'notifications.php';
     3include 'settings.php';
     4include 'api.php';
     5include 'ui.php';
     6
    27/**
    38 * @param string $message
     
    712    error_log($message.PHP_EOL, 3, $pluginLog);
    813}
    9 function QuantiModo_register_settings()
    10 {
    11   register_setting( 'QuantiModo_settings_group', 'QuantiModo_settings' );
    12 }
    13 add_action( 'admin_init', 'QuantiModo_register_settings' );
    14 function QuantiModo_uninstall()
    15 {
    16   delete_option( 'QuantiModo_settings' );  // Delete options on uninstall
    17 }
    18 register_uninstall_hook( __FILE__, 'QuantiModo_uninstall' );
    19 register_activation_hook( __FILE__, 'fx_admin_notice_example_activation_hook' );
    20 /**
    21  * Runs only when the plugin is activated.
    22  * @since 0.1.0
    23  */
    24 function fx_admin_notice_example_activation_hook() {
    25     /* Create transient data */
    26     set_transient( 'fx-admin-notice-example', true, 5 );
    27 }
    28 add_action( 'admin_notices', 'fx_admin_notice_example_notice' );  /* Add admin notice */
    29 /**
    30  * Admin Notice on Activation.
    31  * @since 0.1.0
    32  */
    33 function fx_admin_notice_example_notice(){
    34     // Get options
    35     // Check to see if QuantiModo is enabled
    36     $has_client_id = !empty(qm_api_client_id());
    37     $settingsUrl = get_bloginfo('wpurl') . '/wp-admin/admin.php?page=menus.php';
    38     $builderUrl = get_app_builder_url();
    39     $html = '<div class="updated">';
    40     $html .= "<p>Get your <a href='".$builderUrl."' target=\"_blank\">QuantiModo client id</a> and add it to <a href='".$settingsUrl."'  target=\"_blank\">Settings -> QuantiModo</a></p>";
    41     $html .= '</div><!-- /.updated -->';
    42     if(!$has_client_id){
    43         echo $html;
    44     }
    45 }
    46 
    47 /**
    48  * @return string
    49  */
    50 function qm_api_hostname(): string
    51 {
    52     //return "https://local.quantimo.do";
    53     $apiHostName = "https://app.quantimo.do";
    54     $env = (isset($_SERVER["HTTP_REFERER"])) ? $_SERVER["HTTP_REFERER"] : getenv('APP_HOST_NAME');
    55     if (!$env) {
    56         $env = "https://" . $_SERVER["HTTP_HOST"];
    57     }
    58     if (stripos($env, "https://utopia.quantimo.do") === 0 || stripos($env, "https://app.quantimo.do") === 0) {
    59         $apiHostName = "https://utopia.quantimo.do";
    60     }
    61     return $apiHostName;
    62 }
    63 
    64 if(stripos(WP_SITEURL, '.quantimo.do') !== false){
    65     function send_push_notification( $message ) {
    66         $apiUrl = qm_api_hostname() . "/api/v1/messages";
    67         $response = wp_remote_post($apiUrl, ['body' => json_encode(['message' => $message])]);
    68         return $response;
    69     }
    70     add_action('messages_message_after_save', 'send_push_notification', 1, 1);
    71     function annointed_admin_bar_remove() {
    72         global $wp_admin_bar;
    73         if($wp_admin_bar && method_exists($wp_admin_bar, 'remove_menu')){$wp_admin_bar->remove_menu('wp-logo');}
    74     }
    75     add_action('wp_before_admin_bar_render', 'annointed_admin_bar_remove', 0); // Only done if stripos(WP_SITEURL, '.quantimo.do') !== false
    76     function change_footer_admin (): string
    77     {return ' ';} //Hide admin footer from admin
    78     add_filter('admin_footer_text', 'change_footer_admin', 9999); // Only done if stripos(WP_SITEURL, '.quantimo.do') !== false
    79     function change_footer_version(): string
    80     {return ' ';}
    81     add_filter( 'update_footer', 'change_footer_version', 9999); // Only done if stripos(WP_SITEURL, '.quantimo.do') !== false
    82     function qm_development_testing_login(){
    83         $origin = 'https://' . $_SERVER['HTTP_HOST'];
    84         if(!in_array($origin, [
    85             "https://staging-wp.quantimo.do",
    86             "https://dev-wp.quantimo.do"
    87         ])){return;}
    88         if(!isset($_GET['log']) || !isset($_GET['pwd'])){return;}
    89         add_action('init', function() {
    90             $origin =  'https://' . $_SERVER['HTTP_HOST'];
    91             $currentUrl = $origin . $_SERVER["REQUEST_URI"];
    92             $loginUrl = wp_login_url();
    93             $user = get_user_by('login', $_GET['log']);
    94             $redirect_to = admin_url();
    95             if($currentUrl !== $loginUrl){$redirect_to = explode("?", $currentUrl)[0];}
    96             if($user && wp_check_password($_GET['pwd'], $user->data->user_pass, $user->ID)){
    97                 wp_set_current_user($user->ID, $user->user_login);
    98                 wp_set_auth_cookie($user->ID, true);
    99                 do_action('wp_login', $user->user_login);
    100                 wp_redirect($redirect_to);
    101                 exit;
    102             }
    103             wp_redirect(home_url());
    104             exit;
    105         });
    106     }
    107     qm_development_testing_login();
    108 }
    109 
    110 function qm_api_client_id() {
    111     $options = qm_settings();
    112     $quantimodo_client_id = (isset($options['quantimodo_client_id'])) ? $options['quantimodo_client_id'] : null;
    113     return $quantimodo_client_id;
    114 }
    115 
    116 function qm_settings() {
    117     $settings = get_option('QuantiModo_settings');
    118     if(!$settings){$settings = [];}
    119     return $settings;
    120 }
    121 
    122 function get_qm_option(string $name, $default = null){
    123     $options = qm_settings();
    124     $value = (isset($options[$name])) ? $options[$name] : $default;
    125     return $value;
    126 }
    127 
    128 function get_app_builder_url(): string
    129 {
    130     $appBuilderUrl = APP_BUILDER_URL;
    131     $qmClientId = qm_api_client_id();
    132     if($qmClientId){$appBuilderUrl .= "?client_id=" . $qmClientId;}
    133     return $appBuilderUrl;
    134 }
    135 
    136 function qm_floating_button_enabled(): bool
    137 {
    138     $floating_button_enabled = get_qm_option('floating_button_enabled') == "on";
    139     return $floating_button_enabled;
    140 }
  • quantimodo/tags/0.6.7/includes/integration.js

    r2939071 r2954674  
    22    "use strict";
    33    window.QuantiModoIntegration = {options: {}};
    4     var defaultOptions = {
    5         clientUserId: encodeURIComponent('UNIQUE_ID_FOR_YOUR_USER'),
    6         clientUser: null,
    7         baseIonicPath: 'https://app.quantimo.do/app/public/#/app/',
    8         clientId: 'CLIENT_ID',
    9         logout: false,
    10         publicToken: '',
    11         qmAccessToken: null,
    12         fullscreen: true,
    13         showButton: false,
    14         defaultState: 'import',
    15         hideMenu: true,
    16         sideBarWidth: "600px",
    17         floatingActionButtonRightOffset: "15px",
    18         clientServerFinishUrl: "https://yourserver.com/api/v1/quantimodo/finish",
    19         finish: function(sessionTokenObject) {
    20             logError('You have not defined window.QuantiModoIntegration.options.finish!');
    21             console.warn("window.QuantiModoIntegration.options.finish is called after user finishes connecting their health data.");
    22             console.warn("You should set this to POST sessionTokenObject as-is to your server for step 2");
    23             console.warn("Also, include code here to refresh the page.");
    24             var req = new XMLHttpRequest();   // new HttpRequest instance
    25             req.open("POST", "https://app.quantimo.do/api/v1/quantimodo/connect/finish");
    26             req.setRequestHeader("Content-Type", "application/json");
    27             req.send(sessionTokenObject);
    28         },
    29         close: function() {
    30             /* (optional) Called when a user closes the popup without connecting any data sources */
    31         },
    32         error: function(err) {
    33             console.error(err);
    34             /* (optional) Called if an error occurs when loading the popup. */
    35         }
    36     };
     4    function getDefaultOptions() {
     5        return {
     6            clientUserId: encodeURIComponent('UNIQUE_ID_FOR_YOUR_USER'),
     7            clientUser: null,
     8            baseIonicPath: getApiOrigin()+'/app/public/#/app/',
     9            clientId: 'CLIENT_ID',
     10            logout: false,
     11            publicToken: '',
     12            qmAccessToken: null,
     13            fullscreen: true,
     14            showButton: false,
     15            defaultState: 'import',
     16            hideMenu: true,
     17            sideBarWidth: "600px",
     18            floatingActionButtonRightOffset: "15px",
     19            clientServerFinishUrl: "https://yourserver.com/api/v1/quantimodo/finish",
     20            finish: function(sessionTokenObject) {
     21                logError('You have not defined window.QuantiModoIntegration.options.finish!');
     22                console.warn("window.QuantiModoIntegration.options.finish is called after user finishes connecting their health data.");
     23                console.warn("You should set this to POST sessionTokenObject as-is to your server for step 2");
     24                console.warn("Also, include code here to refresh the page.");
     25                var req = new XMLHttpRequest();   // new HttpRequest instance
     26
     27                req.open("POST", getApiOrigin()+"/api/v1/quantimodo/connect/finish");
     28                req.setRequestHeader("Content-Type", "application/json");
     29                req.send(sessionTokenObject);
     30            },
     31            close: function() {
     32                /* (optional) Called when a user closes the popup without connecting any data sources */
     33            },
     34            error: function(err) {
     35                console.error(err);
     36                /* (optional) Called if an error occurs when loading the popup. */
     37            }
     38        }
     39    }
    3740    var qmMain;
    3841    var connectorList;
     
    5962            optionValue = window.QuantiModoIntegration.options[optionName];
    6063        } else {
    61             optionValue = defaultOptions[optionName];
     64            optionValue = getDefaultOptions()[optionName];
    6265        }
    6366        return optionValue;
     
    6669        console.error(errorMessage);
    6770        if(window.QuantiModoIntegration.error){window.QuantiModoIntegration.error(errorMessage);}
    68         if(defaultOptions.error){defaultOptions.error(errorMessage);}
     71        if(getDefaultOptions().error){getDefaultOptions().error(errorMessage);}
    6972    }
    7073    function dashesToCamelCase(myString) {return myString.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); });}
     
    7881        return clientId
    7982    }
    80     function getApiUrl() {
     83    function getApiHost() {
    8184        var apiUrl = getOption('apiUrl');
    8285        if (!apiUrl) {apiUrl = 'app.quantimo.do'}
     
    8790        return apiUrl
    8891    }
     92    function getApiOrigin() {
     93        return 'https://' + getApiHost()
     94    }
    8995    function getAppSettings (successHandler) {
    9096        var appSettings = localStorage.getItem('appSettings');
     
    95101            return;
    96102        }
    97         function getAppSettingsUrl () {return 'https://' + getApiUrl() + '/api/v1/appSettings?clientId=' + getClientId()}
     103        function getAppSettingsUrl () {return 'https://' + getApiHost() + '/api/v1/appSettings?clientId=' + getClientId()}
    98104        var xhr = new XMLHttpRequest();
    99105        xhr.open('GET', getAppSettingsUrl(), true);
     
    207213        if (!errorHandler) { errorHandler = function (err) { logError(err); }; }
    208214        var request = new XMLHttpRequest();
    209         request.open(method, 'https://' + getApiUrl() + requestPath + getAPIQueryString(), true);
     215        request.open(method, 'https://' + getApiHost() + requestPath + getAPIQueryString(), true);
    210216        request.onload = function () {
    211217            if (request.status >= 200 && request.status < 400) {
     
    377383            '           <h4 class="qm-account-name"><%= displayName %></h4>' +
    378384            '           <% if (!qmClient && connected && errorMessage) { %>' +
    379             '               <img class="qm-sync-image" src="https://images.quantimo.do/public/img/sync-btn-red.png" alt="qm-sync-image">' +
     385            '               <img class="qm-sync-image" src="https://static.quantimo.do/public/img/sync-btn-red.png"' +
     386                ' alt="qm-sync-image">' +
    380387            '           <% } else if (!qmClient && connected) { %>' +
    381             '               <img class="qm-sync-image" src="https://images.quantimo.do/public/img/sync-btn.png">' +
     388            '               <img class="qm-sync-image" src="https://static.quantimo.do/public/img/sync-btn.png">' +
    382389            '           <% } %>' +
    383390            '           <% if (!qmClient && errorMessage) { %><small class="qm-error"><%= errorMessage %></small><% } %>' +
     
    499506            loaderWrapper.setAttribute('id', 'qm-loader-wrapper');
    500507            var img = document.createElement('img');
    501             img.src = 'https://app.quantimo.do/qm-connect/loader_gears.gif';
     508            img.src = 'https://static.quantimo.do/qm-connect/loader_gears.gif';
    502509            img.setAttribute('id', 'qm-loader');
    503510            img.style['z-index'] = '31';
     
    517524        clearTimeout(callbackCancelTimeout);
    518525    }
     526
     527    function getIonicUrl(statePath) {
     528        return getDefaultOptions().baseIonicPath + statePath + window.QuantiModoIntegration.getIframeQueryString();
     529    }
     530
    519531    window.QuantiModoIntegration.qmSetupIonicPopupIframe = function (state) {
    520532        function createQmShowHideButtonBlock() {
     
    527539                '<div id="qm-popup">' +
    528540                '    <div id="qm-popup-inner">' +
    529                 '        <img id="qm-close" alt="x" src="https://app.quantimo.do/qm-connect/close.png">' +
     541                '        <img id="qm-close" alt="x" src="https://static.quantimo.do/qm-connect/close.png">' +
    530542                '        <div id="qm-main"></div>' +
    531543                '    </div>' +
     
    561573            var statePath = '';
    562574            if(state){statePath = '/app/' + state;}
    563             var url = defaultOptions.baseIonicPath + statePath + window.QuantiModoIntegration.getIframeQueryString()
     575            var url = getIonicUrl(statePath)
    564576            qmMain.innerHTML = '<iframe style="height:100%;width:100%;" id="ionic-app-frame" src="' + url + '" frameborder="0"></iframe>';
    565577            showPopup();
     
    576588                    '<div id="qm-popup">' +
    577589                    '    <div id="qm-popup-inner">' +
    578                     '        <img id="qm-close" alt="x" src="https://app.quantimo.do/qm-connect/close.png">' +
     590                    '        <img id="qm-close" alt="x" src="https://static.quantimo.do/qm-connect/close.png">' +
    579591                    '        <div id="qm-main"></div>' +
    580592                    '    </div>' +
     
    701713    }
    702714    window.QuantiModoIntegration.getIframeQueryString = function(){
    703         var str = '?apiUrl=' + getApiUrl();
     715        var str = '?apiUrl=' + getApiHost();
    704716        if(window.QuantiModoIntegration.options.qmAccessToken){str += '&accessToken=' + window.QuantiModoIntegration.options.qmAccessToken;}
    705717        if(window.QuantiModoIntegration.options.hideMenu){str += '&hideMenu=' + window.QuantiModoIntegration.options.hideMenu;}
    706718        if(window.QuantiModoIntegration.options.logout){str += '&logout=' + window.QuantiModoIntegration.options.logout;}
     719        if(window.QuantiModoIntegration.options.clientId){str += '&clientId=' + window.QuantiModoIntegration.options.clientId;}
    707720        return str;
    708721    };
     
    716729                '<div id="' + qmPageElements.qmIonicAppSidebar.id + '" style="display: none; z-index: 999997; height: 100%; position: fixed;right: 0; top: 0; border: 1px solid #eee; background: white; ">' +
    717730                '<iframe style="height:100%;width:' + getOption('sideBarWidth') + ';" id="ionic-app-frame" frameborder="0" ' +
    718                 'src="' + defaultOptions.baseIonicPath + statePath + window.QuantiModoIntegration.getIframeQueryString() + '">' +
     731                'src="' + getIonicUrl(statePath)+ '">' +
    719732                '</iframe>' +
    720733                '</div>';
  • quantimodo/tags/0.6.7/package.json

    r2945198 r2954674  
    66  "scripts": {
    77    "test": "echo \"No test specified\"",
    8     "build": "wp-scripts build"
     8    "build": "wp-scripts build",
     9    "start": "wp-scripts start"
    910  },
    1011  "repository": {
  • quantimodo/tags/0.6.7/qm-block.js

    r2946898 r2954674  
    33    const { registerBlockType } = wp.blocks;
    44    const { ServerSideRender } = wp.editor;
    5     debugger
     5    //debugger
    66
    7     registerBlockType('quantimodo/quantimodo-iframe', {
     7    registerBlockType('quantimodo/qm-iframe', {
    88        title: 'QuantiModo iFrame',
    99        icon: 'format-gallery',  // Choose an icon: https://developer.wordpress.org/resource/dashicons/
     
    1515            return (
    1616                <ServerSideRender
    17                     block="quantimodo/quantimodo-iframe"
     17                    block="quantimodo/qm-iframe"
    1818                    attributes={props.attributes}
    1919                />
  • quantimodo/tags/0.6.7/quantimodo.php

    r2954190 r2954674  
    22/*
    33 * Plugin Name: QuantiModo
    4  * Version: 0.6.6
     4 * Version: 0.6.7
    55 * Description: Allow your users to record, aggregate, analyze and visualize their health and life-tracking data.
    66 * Author: QuantiModo
     
    1212defined('ABSPATH') or die("Restricted access!");
    1313
    14 define('QUANTIMODO_4f050d29b8BB9_VERSION', '1.5');
     14
    1515define('QUANTIMODO_4f050d29b8BB9_DIR', plugin_dir_path(__FILE__));
    1616define('QUANTIMODO_4f050d29b8BB9_URL', plugin_dir_url(__FILE__));
    1717defined('QUANTIMODO_4f050d29b8BB9_PATH') or define('QUANTIMODO_4f050d29b8BB9_PATH', untrailingslashit(plugins_url('', __FILE__)));
    18 define('APP_BUILDER_URL', 'https://builder.quantimo.do');
     18const APP_BUILDER_URL = 'https://builder.quantimo.do';
    1919
    2020require_once(QUANTIMODO_4f050d29b8BB9_DIR . 'includes/core.php');
    2121require_once plugin_dir_path(__FILE__) . 'includes/access_token.php';
     22require_once plugin_dir_path(__FILE__) . 'includes/qm_url.php';
    2223require_once(QUANTIMODO_4f050d29b8BB9_DIR . 'includes/menus.php');
    2324require_once(QUANTIMODO_4f050d29b8BB9_DIR . 'includes/admin.php');
    24 require_once(QUANTIMODO_4f050d29b8BB9_DIR . 'includes/embed.php');
    25 require_once plugin_dir_path(__FILE__) . 'includes/shortcode.php';
     25require_once( QUANTIMODO_4f050d29b8BB9_DIR . 'includes/fab.php' );
     26require_once plugin_dir_path( __FILE__ ) . 'includes/qm_iframe_shortcode.php';
     27require_once plugin_dir_path( __FILE__ ) . 'includes/qm_redirect_shortcode.php';
    2628
    2729function enqueue_qm_block_assets() {
     
    3537add_action('enqueue_block_editor_assets', 'enqueue_qm_block_assets');
    3638
    37 function render_quantimodo_iframe_block($attributes, $content) {
    38     // Check if user is logged in
    39     if (!is_user_logged_in()) {
    40         // If user is not logged in, redirect to login page
    41         auth_redirect();
    42     }
    43     // Get the user's access token
    44     $access_token = get_qm_access_token();
     39function redirect_to_login_if_necessary(): void {
     40// Check if user is logged in
     41    if ( ! is_user_logged_in() ) {
     42        // If user is not logged in, redirect to login page
     43        auth_redirect();
     44    }
     45    // Get the user's access token
     46    $access_token = get_qm_access_token();
    4547
    46     if(!$access_token) {
    47         qm_error('No QM access token found');
    48     }
    49     // Your shortcode function here
    50     return quantimodo_iframe_func($attributes);
     48    if ( ! $access_token ) {
     49        qm_error( 'No QM access token found' );
     50    }
    5151}
    5252
    53 function register_quantimodo_iframe_block() {
     53function render_qm_iframe_block($attributes, $content) {
     54    redirect_to_login_if_necessary();
     55    // Your shortcode function here
     56    return qm_iframe_func($attributes);
     57}
     58
     59function register_qm_iframe_block() {
    5460    if (function_exists('register_block_type')) {
    55         register_block_type('quantimodo/quantimodo-iframe', array(
     61        register_block_type('quantimodo/qm-iframe', array(
    5662            'attributes' => array(
    5763                // Define your block's attributes here, if any
    5864            ),
    59             'render_callback' => 'render_quantimodo_iframe_block',
     65            'render_callback' => 'render_qm_iframe_block',
    6066        ));
    6167    }
    6268}
    63 add_action('init', 'register_quantimodo_iframe_block');
     69add_action('init', 'register_qm_iframe_block');
    6470
    6571
     72
     73
     74function render_qm_redirect_block($attributes, $content) {
     75    redirect_to_login_if_necessary();
     76    // Your shortcode function here
     77    return qm_redirect_func($attributes);
     78}
     79
     80/**
     81 * @return void
     82 */
     83
     84
     85function register_qm_redirect_block() {
     86    if (function_exists('register_block_type')) {
     87        register_block_type('quantimodo/qm-redirect', array(
     88            'attributes' => array(
     89                // Define your block's attributes here, if any
     90            ),
     91            'render_callback' => 'render_qm_redirect_block',
     92        ));
     93    }
     94}
     95add_action('init', 'register_qm_redirect_block');
     96
  • quantimodo/tags/0.6.7/src/index.jsx

    r2945198 r2954674  
    1 window.onload = function() {
     1function qm_register_blocks() {
    22    console.log('Quantimodo iFrame block loaded');
    3     const { registerBlockType } = wp.blocks;
    4     const { ServerSideRender } = wp.editor;
     3    const {registerBlockType} = wp.blocks;
     4    const {ServerSideRender} = wp.editor;
    55    debugger
    66
    7     registerBlockType('quantimodo/quantimodo-iframe', {
     7    registerBlockType('quantimodo/qm-iframe', {
    88        title: 'QuantiModo iFrame',
    99        icon: 'format-gallery',  // Choose an icon: https://developer.wordpress.org/resource/dashicons/
     
    1212            // Here you can define optional block attributes.
    1313        },
    14         edit: function(props) {
     14        edit: function (props) {
    1515            return (
    1616                <ServerSideRender
    17                     block="quantimodo/quantimodo-iframe"
     17                    block="quantimodo/qm-iframe"
    1818                    attributes={props.attributes}
    1919                />
    2020            );
    2121        },
    22         save: function() {
     22        save: function () {
     23            // This block is dynamic so we save nothing to the post content
     24            return null;
     25        },
     26    });
     27
     28    registerBlockType('quantimodo/qm-redirect', {
     29        title: 'QuantiModo Redirect',
     30        icon: 'external',  // Choose an icon: https://developer.wordpress.org/resource/dashicons/
     31        category: 'common',  // Choose a category: https://developer.wordpress.org/block-editor/developers/block-api/block-registration/#category-optional
     32        attributes: {
     33            // Here you can define optional block attributes.
     34        },
     35        edit: function (props) {
     36            return (
     37                <div>
     38                    <ServerSideRender
     39                        block="quantimodo/qm-redirect"
     40                        attributes={props.attributes}
     41                    />
     42                    <h1>Block That Redirects to Your QuantiModo App</h1>
     43                </div>
     44            );
     45        },
     46        save: function () {
    2347            // This block is dynamic so we save nothing to the post content
    2448            return null;
     
    2751}
    2852
     53wp.domReady(qm_register_blocks)
  • quantimodo/trunk/README.md

    r2954190 r2954674  
    33Tags: social, science, quantified self, mood tracking, digital health, healthcare, mental health
    44Requires at least: 4.3
    5 Stable tag: 0.6.6
     5Stable tag: 0.6.7
    66License: GPLv2 or later
    77License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • quantimodo/trunk/build/index.asset.php

    r2945198 r2954674  
    1 <?php return array('dependencies' => array('wp-element'), 'version' => '4d3206538082ae0e488f');
     1<?php return array('dependencies' => array('wp-element'), 'version' => '6d05a41645964c472cb9');
  • quantimodo/trunk/build/index.js

    r2945198 r2954674  
    1 (()=>{"use strict";const o=window.wp.element;window.onload=function(){console.log("Quantimodo iFrame block loaded");const{registerBlockType:t}=wp.blocks,{ServerSideRender:e}=wp.editor;t("quantimodo/quantimodo-iframe",{title:"QuantiModo iFrame",icon:"format-gallery",category:"common",attributes:{},edit:function(t){return(0,o.createElement)(e,{block:"quantimodo/quantimodo-iframe",attributes:t.attributes})},save:function(){return null}})}})();
     1/******/ (() => { // webpackBootstrap
     2/******/    "use strict";
     3/******/    var __webpack_modules__ = ({
     4
     5/***/ "@wordpress/element":
     6/*!*********************************!*\
     7  !*** external ["wp","element"] ***!
     8  \*********************************/
     9/***/ ((module) => {
     10
     11module.exports = window["wp"]["element"];
     12
     13/***/ })
     14
     15/******/    });
     16/************************************************************************/
     17/******/    // The module cache
     18/******/    var __webpack_module_cache__ = {};
     19/******/   
     20/******/    // The require function
     21/******/    function __webpack_require__(moduleId) {
     22/******/        // Check if module is in cache
     23/******/        var cachedModule = __webpack_module_cache__[moduleId];
     24/******/        if (cachedModule !== undefined) {
     25/******/            return cachedModule.exports;
     26/******/        }
     27/******/        // Create a new module (and put it into the cache)
     28/******/        var module = __webpack_module_cache__[moduleId] = {
     29/******/            // no module.id needed
     30/******/            // no module.loaded needed
     31/******/            exports: {}
     32/******/        };
     33/******/   
     34/******/        // Execute the module function
     35/******/        __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
     36/******/   
     37/******/        // Return the exports of the module
     38/******/        return module.exports;
     39/******/    }
     40/******/   
     41/************************************************************************/
     42/******/    /* webpack/runtime/compat get default export */
     43/******/    (() => {
     44/******/        // getDefaultExport function for compatibility with non-harmony modules
     45/******/        __webpack_require__.n = (module) => {
     46/******/            var getter = module && module.__esModule ?
     47/******/                () => (module['default']) :
     48/******/                () => (module);
     49/******/            __webpack_require__.d(getter, { a: getter });
     50/******/            return getter;
     51/******/        };
     52/******/    })();
     53/******/   
     54/******/    /* webpack/runtime/define property getters */
     55/******/    (() => {
     56/******/        // define getter functions for harmony exports
     57/******/        __webpack_require__.d = (exports, definition) => {
     58/******/            for(var key in definition) {
     59/******/                if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
     60/******/                    Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
     61/******/                }
     62/******/            }
     63/******/        };
     64/******/    })();
     65/******/   
     66/******/    /* webpack/runtime/hasOwnProperty shorthand */
     67/******/    (() => {
     68/******/        __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
     69/******/    })();
     70/******/   
     71/******/    /* webpack/runtime/make namespace object */
     72/******/    (() => {
     73/******/        // define __esModule on exports
     74/******/        __webpack_require__.r = (exports) => {
     75/******/            if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
     76/******/                Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
     77/******/            }
     78/******/            Object.defineProperty(exports, '__esModule', { value: true });
     79/******/        };
     80/******/    })();
     81/******/   
     82/************************************************************************/
     83var __webpack_exports__ = {};
     84// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
     85(() => {
     86/*!***********************!*\
     87  !*** ./src/index.jsx ***!
     88  \***********************/
     89__webpack_require__.r(__webpack_exports__);
     90/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element");
     91/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
     92
     93function qm_register_blocks() {
     94  console.log('Quantimodo iFrame block loaded');
     95  const {
     96    registerBlockType
     97  } = wp.blocks;
     98  const {
     99    ServerSideRender
     100  } = wp.editor;
     101  debugger;
     102  registerBlockType('quantimodo/qm-iframe', {
     103    title: 'QuantiModo iFrame',
     104    icon: 'format-gallery',
     105    // Choose an icon: https://developer.wordpress.org/resource/dashicons/
     106    category: 'common',
     107    // Choose a category: https://developer.wordpress.org/block-editor/developers/block-api/block-registration/#category-optional
     108    attributes: {
     109      // Here you can define optional block attributes.
     110    },
     111    edit: function (props) {
     112      return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(ServerSideRender, {
     113        block: "quantimodo/qm-iframe",
     114        attributes: props.attributes
     115      });
     116    },
     117    save: function () {
     118      // This block is dynamic so we save nothing to the post content
     119      return null;
     120    }
     121  });
     122  registerBlockType('quantimodo/qm-redirect', {
     123    title: 'QuantiModo Redirect',
     124    icon: 'external',
     125    // Choose an icon: https://developer.wordpress.org/resource/dashicons/
     126    category: 'common',
     127    // Choose a category: https://developer.wordpress.org/block-editor/developers/block-api/block-registration/#category-optional
     128    attributes: {
     129      // Here you can define optional block attributes.
     130    },
     131    edit: function (props) {
     132      return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(ServerSideRender, {
     133        block: "quantimodo/qm-redirect",
     134        attributes: props.attributes
     135      }), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("h1", null, "Block That Redirects to Your QuantiModo App"));
     136    },
     137    save: function () {
     138      // This block is dynamic so we save nothing to the post content
     139      return null;
     140    }
     141  });
     142}
     143wp.domReady(qm_register_blocks);
     144})();
     145
     146/******/ })()
     147;
     148//# sourceMappingURL=index.js.map
  • quantimodo/trunk/includes/access_token.php

    r2954190 r2954674  
    1919    $qmClientId = qm_api_client_id();
    2020    $qmClientSecret = $options['quantimodo_client_secret'] ?? null;
    21     $apiHostName = qm_api_hostname();
     21    $apiHostName = qm_api_origin();
    2222    $wpUser = wp_get_current_user();
    2323    $userData = clone $wpUser->data;
  • quantimodo/trunk/includes/admin.php

    r2946898 r2954674  
    2424    $quantimodo_client_id = qm_api_client_id();
    2525    $builderUrl = get_app_builder_url();
    26     $introUrl = qm_api_hostname() . '/app/public/#/app/intro?clientId=' . $quantimodo_client_id;
     26    $introUrl = intro_url();
    2727
    2828    ?>
  • quantimodo/trunk/includes/core.php

    r2954190 r2954674  
    11<?php
     2include 'notifications.php';
     3include 'settings.php';
     4include 'api.php';
     5include 'ui.php';
     6
    27/**
    38 * @param string $message
     
    712    error_log($message.PHP_EOL, 3, $pluginLog);
    813}
    9 function QuantiModo_register_settings()
    10 {
    11   register_setting( 'QuantiModo_settings_group', 'QuantiModo_settings' );
    12 }
    13 add_action( 'admin_init', 'QuantiModo_register_settings' );
    14 function QuantiModo_uninstall()
    15 {
    16   delete_option( 'QuantiModo_settings' );  // Delete options on uninstall
    17 }
    18 register_uninstall_hook( __FILE__, 'QuantiModo_uninstall' );
    19 register_activation_hook( __FILE__, 'fx_admin_notice_example_activation_hook' );
    20 /**
    21  * Runs only when the plugin is activated.
    22  * @since 0.1.0
    23  */
    24 function fx_admin_notice_example_activation_hook() {
    25     /* Create transient data */
    26     set_transient( 'fx-admin-notice-example', true, 5 );
    27 }
    28 add_action( 'admin_notices', 'fx_admin_notice_example_notice' );  /* Add admin notice */
    29 /**
    30  * Admin Notice on Activation.
    31  * @since 0.1.0
    32  */
    33 function fx_admin_notice_example_notice(){
    34     // Get options
    35     // Check to see if QuantiModo is enabled
    36     $has_client_id = !empty(qm_api_client_id());
    37     $settingsUrl = get_bloginfo('wpurl') . '/wp-admin/admin.php?page=menus.php';
    38     $builderUrl = get_app_builder_url();
    39     $html = '<div class="updated">';
    40     $html .= "<p>Get your <a href='".$builderUrl."' target=\"_blank\">QuantiModo client id</a> and add it to <a href='".$settingsUrl."'  target=\"_blank\">Settings -> QuantiModo</a></p>";
    41     $html .= '</div><!-- /.updated -->';
    42     if(!$has_client_id){
    43         echo $html;
    44     }
    45 }
    46 
    47 /**
    48  * @return string
    49  */
    50 function qm_api_hostname(): string
    51 {
    52     //return "https://local.quantimo.do";
    53     $apiHostName = "https://app.quantimo.do";
    54     $env = (isset($_SERVER["HTTP_REFERER"])) ? $_SERVER["HTTP_REFERER"] : getenv('APP_HOST_NAME');
    55     if (!$env) {
    56         $env = "https://" . $_SERVER["HTTP_HOST"];
    57     }
    58     if (stripos($env, "https://utopia.quantimo.do") === 0 || stripos($env, "https://app.quantimo.do") === 0) {
    59         $apiHostName = "https://utopia.quantimo.do";
    60     }
    61     return $apiHostName;
    62 }
    63 
    64 if(stripos(WP_SITEURL, '.quantimo.do') !== false){
    65     function send_push_notification( $message ) {
    66         $apiUrl = qm_api_hostname() . "/api/v1/messages";
    67         $response = wp_remote_post($apiUrl, ['body' => json_encode(['message' => $message])]);
    68         return $response;
    69     }
    70     add_action('messages_message_after_save', 'send_push_notification', 1, 1);
    71     function annointed_admin_bar_remove() {
    72         global $wp_admin_bar;
    73         if($wp_admin_bar && method_exists($wp_admin_bar, 'remove_menu')){$wp_admin_bar->remove_menu('wp-logo');}
    74     }
    75     add_action('wp_before_admin_bar_render', 'annointed_admin_bar_remove', 0); // Only done if stripos(WP_SITEURL, '.quantimo.do') !== false
    76     function change_footer_admin (): string
    77     {return ' ';} //Hide admin footer from admin
    78     add_filter('admin_footer_text', 'change_footer_admin', 9999); // Only done if stripos(WP_SITEURL, '.quantimo.do') !== false
    79     function change_footer_version(): string
    80     {return ' ';}
    81     add_filter( 'update_footer', 'change_footer_version', 9999); // Only done if stripos(WP_SITEURL, '.quantimo.do') !== false
    82     function qm_development_testing_login(){
    83         $origin = 'https://' . $_SERVER['HTTP_HOST'];
    84         if(!in_array($origin, [
    85             "https://staging-wp.quantimo.do",
    86             "https://dev-wp.quantimo.do"
    87         ])){return;}
    88         if(!isset($_GET['log']) || !isset($_GET['pwd'])){return;}
    89         add_action('init', function() {
    90             $origin =  'https://' . $_SERVER['HTTP_HOST'];
    91             $currentUrl = $origin . $_SERVER["REQUEST_URI"];
    92             $loginUrl = wp_login_url();
    93             $user = get_user_by('login', $_GET['log']);
    94             $redirect_to = admin_url();
    95             if($currentUrl !== $loginUrl){$redirect_to = explode("?", $currentUrl)[0];}
    96             if($user && wp_check_password($_GET['pwd'], $user->data->user_pass, $user->ID)){
    97                 wp_set_current_user($user->ID, $user->user_login);
    98                 wp_set_auth_cookie($user->ID, true);
    99                 do_action('wp_login', $user->user_login);
    100                 wp_redirect($redirect_to);
    101                 exit;
    102             }
    103             wp_redirect(home_url());
    104             exit;
    105         });
    106     }
    107     qm_development_testing_login();
    108 }
    109 
    110 function qm_api_client_id() {
    111     $options = qm_settings();
    112     $quantimodo_client_id = (isset($options['quantimodo_client_id'])) ? $options['quantimodo_client_id'] : null;
    113     return $quantimodo_client_id;
    114 }
    115 
    116 function qm_settings() {
    117     $settings = get_option('QuantiModo_settings');
    118     if(!$settings){$settings = [];}
    119     return $settings;
    120 }
    121 
    122 function get_qm_option(string $name, $default = null){
    123     $options = qm_settings();
    124     $value = (isset($options[$name])) ? $options[$name] : $default;
    125     return $value;
    126 }
    127 
    128 function get_app_builder_url(): string
    129 {
    130     $appBuilderUrl = APP_BUILDER_URL;
    131     $qmClientId = qm_api_client_id();
    132     if($qmClientId){$appBuilderUrl .= "?client_id=" . $qmClientId;}
    133     return $appBuilderUrl;
    134 }
    135 
    136 function qm_floating_button_enabled(): bool
    137 {
    138     $floating_button_enabled = get_qm_option('floating_button_enabled') == "on";
    139     return $floating_button_enabled;
    140 }
  • quantimodo/trunk/includes/integration.js

    r2939071 r2954674  
    22    "use strict";
    33    window.QuantiModoIntegration = {options: {}};
    4     var defaultOptions = {
    5         clientUserId: encodeURIComponent('UNIQUE_ID_FOR_YOUR_USER'),
    6         clientUser: null,
    7         baseIonicPath: 'https://app.quantimo.do/app/public/#/app/',
    8         clientId: 'CLIENT_ID',
    9         logout: false,
    10         publicToken: '',
    11         qmAccessToken: null,
    12         fullscreen: true,
    13         showButton: false,
    14         defaultState: 'import',
    15         hideMenu: true,
    16         sideBarWidth: "600px",
    17         floatingActionButtonRightOffset: "15px",
    18         clientServerFinishUrl: "https://yourserver.com/api/v1/quantimodo/finish",
    19         finish: function(sessionTokenObject) {
    20             logError('You have not defined window.QuantiModoIntegration.options.finish!');
    21             console.warn("window.QuantiModoIntegration.options.finish is called after user finishes connecting their health data.");
    22             console.warn("You should set this to POST sessionTokenObject as-is to your server for step 2");
    23             console.warn("Also, include code here to refresh the page.");
    24             var req = new XMLHttpRequest();   // new HttpRequest instance
    25             req.open("POST", "https://app.quantimo.do/api/v1/quantimodo/connect/finish");
    26             req.setRequestHeader("Content-Type", "application/json");
    27             req.send(sessionTokenObject);
    28         },
    29         close: function() {
    30             /* (optional) Called when a user closes the popup without connecting any data sources */
    31         },
    32         error: function(err) {
    33             console.error(err);
    34             /* (optional) Called if an error occurs when loading the popup. */
    35         }
    36     };
     4    function getDefaultOptions() {
     5        return {
     6            clientUserId: encodeURIComponent('UNIQUE_ID_FOR_YOUR_USER'),
     7            clientUser: null,
     8            baseIonicPath: getApiOrigin()+'/app/public/#/app/',
     9            clientId: 'CLIENT_ID',
     10            logout: false,
     11            publicToken: '',
     12            qmAccessToken: null,
     13            fullscreen: true,
     14            showButton: false,
     15            defaultState: 'import',
     16            hideMenu: true,
     17            sideBarWidth: "600px",
     18            floatingActionButtonRightOffset: "15px",
     19            clientServerFinishUrl: "https://yourserver.com/api/v1/quantimodo/finish",
     20            finish: function(sessionTokenObject) {
     21                logError('You have not defined window.QuantiModoIntegration.options.finish!');
     22                console.warn("window.QuantiModoIntegration.options.finish is called after user finishes connecting their health data.");
     23                console.warn("You should set this to POST sessionTokenObject as-is to your server for step 2");
     24                console.warn("Also, include code here to refresh the page.");
     25                var req = new XMLHttpRequest();   // new HttpRequest instance
     26
     27                req.open("POST", getApiOrigin()+"/api/v1/quantimodo/connect/finish");
     28                req.setRequestHeader("Content-Type", "application/json");
     29                req.send(sessionTokenObject);
     30            },
     31            close: function() {
     32                /* (optional) Called when a user closes the popup without connecting any data sources */
     33            },
     34            error: function(err) {
     35                console.error(err);
     36                /* (optional) Called if an error occurs when loading the popup. */
     37            }
     38        }
     39    }
    3740    var qmMain;
    3841    var connectorList;
     
    5962            optionValue = window.QuantiModoIntegration.options[optionName];
    6063        } else {
    61             optionValue = defaultOptions[optionName];
     64            optionValue = getDefaultOptions()[optionName];
    6265        }
    6366        return optionValue;
     
    6669        console.error(errorMessage);
    6770        if(window.QuantiModoIntegration.error){window.QuantiModoIntegration.error(errorMessage);}
    68         if(defaultOptions.error){defaultOptions.error(errorMessage);}
     71        if(getDefaultOptions().error){getDefaultOptions().error(errorMessage);}
    6972    }
    7073    function dashesToCamelCase(myString) {return myString.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); });}
     
    7881        return clientId
    7982    }
    80     function getApiUrl() {
     83    function getApiHost() {
    8184        var apiUrl = getOption('apiUrl');
    8285        if (!apiUrl) {apiUrl = 'app.quantimo.do'}
     
    8790        return apiUrl
    8891    }
     92    function getApiOrigin() {
     93        return 'https://' + getApiHost()
     94    }
    8995    function getAppSettings (successHandler) {
    9096        var appSettings = localStorage.getItem('appSettings');
     
    95101            return;
    96102        }
    97         function getAppSettingsUrl () {return 'https://' + getApiUrl() + '/api/v1/appSettings?clientId=' + getClientId()}
     103        function getAppSettingsUrl () {return 'https://' + getApiHost() + '/api/v1/appSettings?clientId=' + getClientId()}
    98104        var xhr = new XMLHttpRequest();
    99105        xhr.open('GET', getAppSettingsUrl(), true);
     
    207213        if (!errorHandler) { errorHandler = function (err) { logError(err); }; }
    208214        var request = new XMLHttpRequest();
    209         request.open(method, 'https://' + getApiUrl() + requestPath + getAPIQueryString(), true);
     215        request.open(method, 'https://' + getApiHost() + requestPath + getAPIQueryString(), true);
    210216        request.onload = function () {
    211217            if (request.status >= 200 && request.status < 400) {
     
    377383            '           <h4 class="qm-account-name"><%= displayName %></h4>' +
    378384            '           <% if (!qmClient && connected && errorMessage) { %>' +
    379             '               <img class="qm-sync-image" src="https://images.quantimo.do/public/img/sync-btn-red.png" alt="qm-sync-image">' +
     385            '               <img class="qm-sync-image" src="https://static.quantimo.do/public/img/sync-btn-red.png"' +
     386                ' alt="qm-sync-image">' +
    380387            '           <% } else if (!qmClient && connected) { %>' +
    381             '               <img class="qm-sync-image" src="https://images.quantimo.do/public/img/sync-btn.png">' +
     388            '               <img class="qm-sync-image" src="https://static.quantimo.do/public/img/sync-btn.png">' +
    382389            '           <% } %>' +
    383390            '           <% if (!qmClient && errorMessage) { %><small class="qm-error"><%= errorMessage %></small><% } %>' +
     
    499506            loaderWrapper.setAttribute('id', 'qm-loader-wrapper');
    500507            var img = document.createElement('img');
    501             img.src = 'https://app.quantimo.do/qm-connect/loader_gears.gif';
     508            img.src = 'https://static.quantimo.do/qm-connect/loader_gears.gif';
    502509            img.setAttribute('id', 'qm-loader');
    503510            img.style['z-index'] = '31';
     
    517524        clearTimeout(callbackCancelTimeout);
    518525    }
     526
     527    function getIonicUrl(statePath) {
     528        return getDefaultOptions().baseIonicPath + statePath + window.QuantiModoIntegration.getIframeQueryString();
     529    }
     530
    519531    window.QuantiModoIntegration.qmSetupIonicPopupIframe = function (state) {
    520532        function createQmShowHideButtonBlock() {
     
    527539                '<div id="qm-popup">' +
    528540                '    <div id="qm-popup-inner">' +
    529                 '        <img id="qm-close" alt="x" src="https://app.quantimo.do/qm-connect/close.png">' +
     541                '        <img id="qm-close" alt="x" src="https://static.quantimo.do/qm-connect/close.png">' +
    530542                '        <div id="qm-main"></div>' +
    531543                '    </div>' +
     
    561573            var statePath = '';
    562574            if(state){statePath = '/app/' + state;}
    563             var url = defaultOptions.baseIonicPath + statePath + window.QuantiModoIntegration.getIframeQueryString()
     575            var url = getIonicUrl(statePath)
    564576            qmMain.innerHTML = '<iframe style="height:100%;width:100%;" id="ionic-app-frame" src="' + url + '" frameborder="0"></iframe>';
    565577            showPopup();
     
    576588                    '<div id="qm-popup">' +
    577589                    '    <div id="qm-popup-inner">' +
    578                     '        <img id="qm-close" alt="x" src="https://app.quantimo.do/qm-connect/close.png">' +
     590                    '        <img id="qm-close" alt="x" src="https://static.quantimo.do/qm-connect/close.png">' +
    579591                    '        <div id="qm-main"></div>' +
    580592                    '    </div>' +
     
    701713    }
    702714    window.QuantiModoIntegration.getIframeQueryString = function(){
    703         var str = '?apiUrl=' + getApiUrl();
     715        var str = '?apiUrl=' + getApiHost();
    704716        if(window.QuantiModoIntegration.options.qmAccessToken){str += '&accessToken=' + window.QuantiModoIntegration.options.qmAccessToken;}
    705717        if(window.QuantiModoIntegration.options.hideMenu){str += '&hideMenu=' + window.QuantiModoIntegration.options.hideMenu;}
    706718        if(window.QuantiModoIntegration.options.logout){str += '&logout=' + window.QuantiModoIntegration.options.logout;}
     719        if(window.QuantiModoIntegration.options.clientId){str += '&clientId=' + window.QuantiModoIntegration.options.clientId;}
    707720        return str;
    708721    };
     
    716729                '<div id="' + qmPageElements.qmIonicAppSidebar.id + '" style="display: none; z-index: 999997; height: 100%; position: fixed;right: 0; top: 0; border: 1px solid #eee; background: white; ">' +
    717730                '<iframe style="height:100%;width:' + getOption('sideBarWidth') + ';" id="ionic-app-frame" frameborder="0" ' +
    718                 'src="' + defaultOptions.baseIonicPath + statePath + window.QuantiModoIntegration.getIframeQueryString() + '">' +
     731                'src="' + getIonicUrl(statePath)+ '">' +
    719732                '</iframe>' +
    720733                '</div>';
  • quantimodo/trunk/package.json

    r2945198 r2954674  
    66  "scripts": {
    77    "test": "echo \"No test specified\"",
    8     "build": "wp-scripts build"
     8    "build": "wp-scripts build",
     9    "start": "wp-scripts start"
    910  },
    1011  "repository": {
  • quantimodo/trunk/qm-block.js

    r2946898 r2954674  
    33    const { registerBlockType } = wp.blocks;
    44    const { ServerSideRender } = wp.editor;
    5     debugger
     5    //debugger
    66
    7     registerBlockType('quantimodo/quantimodo-iframe', {
     7    registerBlockType('quantimodo/qm-iframe', {
    88        title: 'QuantiModo iFrame',
    99        icon: 'format-gallery',  // Choose an icon: https://developer.wordpress.org/resource/dashicons/
     
    1515            return (
    1616                <ServerSideRender
    17                     block="quantimodo/quantimodo-iframe"
     17                    block="quantimodo/qm-iframe"
    1818                    attributes={props.attributes}
    1919                />
  • quantimodo/trunk/quantimodo.php

    r2954190 r2954674  
    22/*
    33 * Plugin Name: QuantiModo
    4  * Version: 0.6.6
     4 * Version: 0.6.7
    55 * Description: Allow your users to record, aggregate, analyze and visualize their health and life-tracking data.
    66 * Author: QuantiModo
     
    1212defined('ABSPATH') or die("Restricted access!");
    1313
    14 define('QUANTIMODO_4f050d29b8BB9_VERSION', '1.5');
     14
    1515define('QUANTIMODO_4f050d29b8BB9_DIR', plugin_dir_path(__FILE__));
    1616define('QUANTIMODO_4f050d29b8BB9_URL', plugin_dir_url(__FILE__));
    1717defined('QUANTIMODO_4f050d29b8BB9_PATH') or define('QUANTIMODO_4f050d29b8BB9_PATH', untrailingslashit(plugins_url('', __FILE__)));
    18 define('APP_BUILDER_URL', 'https://builder.quantimo.do');
     18const APP_BUILDER_URL = 'https://builder.quantimo.do';
    1919
    2020require_once(QUANTIMODO_4f050d29b8BB9_DIR . 'includes/core.php');
    2121require_once plugin_dir_path(__FILE__) . 'includes/access_token.php';
     22require_once plugin_dir_path(__FILE__) . 'includes/qm_url.php';
    2223require_once(QUANTIMODO_4f050d29b8BB9_DIR . 'includes/menus.php');
    2324require_once(QUANTIMODO_4f050d29b8BB9_DIR . 'includes/admin.php');
    24 require_once(QUANTIMODO_4f050d29b8BB9_DIR . 'includes/embed.php');
    25 require_once plugin_dir_path(__FILE__) . 'includes/shortcode.php';
     25require_once( QUANTIMODO_4f050d29b8BB9_DIR . 'includes/fab.php' );
     26require_once plugin_dir_path( __FILE__ ) . 'includes/qm_iframe_shortcode.php';
     27require_once plugin_dir_path( __FILE__ ) . 'includes/qm_redirect_shortcode.php';
    2628
    2729function enqueue_qm_block_assets() {
     
    3537add_action('enqueue_block_editor_assets', 'enqueue_qm_block_assets');
    3638
    37 function render_quantimodo_iframe_block($attributes, $content) {
    38     // Check if user is logged in
    39     if (!is_user_logged_in()) {
    40         // If user is not logged in, redirect to login page
    41         auth_redirect();
    42     }
    43     // Get the user's access token
    44     $access_token = get_qm_access_token();
     39function redirect_to_login_if_necessary(): void {
     40// Check if user is logged in
     41    if ( ! is_user_logged_in() ) {
     42        // If user is not logged in, redirect to login page
     43        auth_redirect();
     44    }
     45    // Get the user's access token
     46    $access_token = get_qm_access_token();
    4547
    46     if(!$access_token) {
    47         qm_error('No QM access token found');
    48     }
    49     // Your shortcode function here
    50     return quantimodo_iframe_func($attributes);
     48    if ( ! $access_token ) {
     49        qm_error( 'No QM access token found' );
     50    }
    5151}
    5252
    53 function register_quantimodo_iframe_block() {
     53function render_qm_iframe_block($attributes, $content) {
     54    redirect_to_login_if_necessary();
     55    // Your shortcode function here
     56    return qm_iframe_func($attributes);
     57}
     58
     59function register_qm_iframe_block() {
    5460    if (function_exists('register_block_type')) {
    55         register_block_type('quantimodo/quantimodo-iframe', array(
     61        register_block_type('quantimodo/qm-iframe', array(
    5662            'attributes' => array(
    5763                // Define your block's attributes here, if any
    5864            ),
    59             'render_callback' => 'render_quantimodo_iframe_block',
     65            'render_callback' => 'render_qm_iframe_block',
    6066        ));
    6167    }
    6268}
    63 add_action('init', 'register_quantimodo_iframe_block');
     69add_action('init', 'register_qm_iframe_block');
    6470
    6571
     72
     73
     74function render_qm_redirect_block($attributes, $content) {
     75    redirect_to_login_if_necessary();
     76    // Your shortcode function here
     77    return qm_redirect_func($attributes);
     78}
     79
     80/**
     81 * @return void
     82 */
     83
     84
     85function register_qm_redirect_block() {
     86    if (function_exists('register_block_type')) {
     87        register_block_type('quantimodo/qm-redirect', array(
     88            'attributes' => array(
     89                // Define your block's attributes here, if any
     90            ),
     91            'render_callback' => 'render_qm_redirect_block',
     92        ));
     93    }
     94}
     95add_action('init', 'register_qm_redirect_block');
     96
  • quantimodo/trunk/src/index.jsx

    r2945198 r2954674  
    1 window.onload = function() {
     1function qm_register_blocks() {
    22    console.log('Quantimodo iFrame block loaded');
    3     const { registerBlockType } = wp.blocks;
    4     const { ServerSideRender } = wp.editor;
     3    const {registerBlockType} = wp.blocks;
     4    const {ServerSideRender} = wp.editor;
    55    debugger
    66
    7     registerBlockType('quantimodo/quantimodo-iframe', {
     7    registerBlockType('quantimodo/qm-iframe', {
    88        title: 'QuantiModo iFrame',
    99        icon: 'format-gallery',  // Choose an icon: https://developer.wordpress.org/resource/dashicons/
     
    1212            // Here you can define optional block attributes.
    1313        },
    14         edit: function(props) {
     14        edit: function (props) {
    1515            return (
    1616                <ServerSideRender
    17                     block="quantimodo/quantimodo-iframe"
     17                    block="quantimodo/qm-iframe"
    1818                    attributes={props.attributes}
    1919                />
    2020            );
    2121        },
    22         save: function() {
     22        save: function () {
     23            // This block is dynamic so we save nothing to the post content
     24            return null;
     25        },
     26    });
     27
     28    registerBlockType('quantimodo/qm-redirect', {
     29        title: 'QuantiModo Redirect',
     30        icon: 'external',  // Choose an icon: https://developer.wordpress.org/resource/dashicons/
     31        category: 'common',  // Choose a category: https://developer.wordpress.org/block-editor/developers/block-api/block-registration/#category-optional
     32        attributes: {
     33            // Here you can define optional block attributes.
     34        },
     35        edit: function (props) {
     36            return (
     37                <div>
     38                    <ServerSideRender
     39                        block="quantimodo/qm-redirect"
     40                        attributes={props.attributes}
     41                    />
     42                    <h1>Block That Redirects to Your QuantiModo App</h1>
     43                </div>
     44            );
     45        },
     46        save: function () {
    2347            // This block is dynamic so we save nothing to the post content
    2448            return null;
     
    2751}
    2852
     53wp.domReady(qm_register_blocks)
Note: See TracChangeset for help on using the changeset viewer.