Plugin Directory

Changeset 2319500


Ignore:
Timestamp:
06/06/2020 02:24:05 PM (6 years ago)
Author:
mikepsinn
Message:

Deploy to WordPress.org via Jenkins

Location:
quantimodo/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • quantimodo/trunk/includes/admin.php

    r2125567 r2319500  
    11<?php
    2 
     2/**
     3 * @return string
     4 */
     5function quantimodo_get_client_secret_instructions(){
     6    return 'Get your client secret from the
     7    <a href="https://builder.quantimo.do" target="_blank" title="Open QuantiModo app builder">QuantiModo app builder</a>
     8    by clicking SETTINGS -> OAUTH.';
     9}
    310// Output the options page
    411function quantimodo_options_page()
     
    8592            </tr>
    8693            </table>
    87             Get your client secret from the
    88             <a href="https://builder.quantimo.do" target="_blank" title="Open QuantiModo app builder">QuantiModo app builder</a>
    89             by clicking SETTINGS -> OAUTH.
     94            <?php echo quantimodo_get_client_secret_instructions(); ?>
    9095            <?php if ( ! esc_attr( $options['quantimodo_widget_code'] ) ) { ?>
    9196                <h3>You can find your QuantiModo client id after
  • quantimodo/trunk/includes/core.php

    r2096018 r2319500  
    2727    // Get options
    2828    $options = get_option('QuantiModo_settings');
    29 
    3029    // Check to see if QuantiModo is enabled
    3130    $quantimodo_activated = false;
     
    4544    function send_push_notification( $message ) {
    4645        $apiUrl = "https://app.quantimo.do/api/v1/messages";
    47         if(stripos(WP_SITEURL, 'local.quantimo.do') !== false){
    48             $apiUrl = "https://local.quantimo.do/api/v1/messages";
    49         }
     46        if(stripos(WP_SITEURL, 'local.quantimo.do') !== false){$apiUrl = "https://local.quantimo.do/api/v1/messages";}
    5047        $response = wp_remote_post($apiUrl, ['body' => json_encode(['message' => $message])]);
    5148        return $response;
    5249    }
    5350    add_action('messages_message_after_save', 'send_push_notification', 1, 1);
    54 
    5551    function annointed_admin_bar_remove() {
    5652        global $wp_admin_bar;
    57         $wp_admin_bar->remove_menu('wp-logo');
     53        if($wp_admin_bar && method_exists($wp_admin_bar, 'remove_menu')){$wp_admin_bar->remove_menu('wp-logo');}
    5854    }
    59     add_action('wp_before_admin_bar_render', 'annointed_admin_bar_remove', 0);
    60 
    61     //Hide admin footer from admin
    62     function change_footer_admin () {return ' ';}
    63     add_filter('admin_footer_text', 'change_footer_admin', 9999);
     55    add_action('wp_before_admin_bar_render', 'annointed_admin_bar_remove', 0); // Only done if stripos(WP_SITEURL, '.quantimo.do') !== false
     56    function change_footer_admin () {return ' ';} //Hide admin footer from admin
     57    add_filter('admin_footer_text', 'change_footer_admin', 9999); // Only done if stripos(WP_SITEURL, '.quantimo.do') !== false
    6458    function change_footer_version() {return ' ';}
    65     add_filter( 'update_footer', 'change_footer_version', 9999);
     59    add_filter( 'update_footer', 'change_footer_version', 9999); // Only done if stripos(WP_SITEURL, '.quantimo.do') !== false
     60    function qm_development_testing_login(){
     61        $origin = 'https://' . $_SERVER['HTTP_HOST'];
     62        if(!in_array($origin, [
     63            "https://staging-wp.quantimo.do",
     64            "https://dev-wp.quantimo.do"
     65        ])){return;}
     66        if(!isset($_GET['log']) || !isset($_GET['pwd'])){return;}
     67        add_action('init', function() {
     68            $origin =  'https://' . $_SERVER['HTTP_HOST'];
     69            $currentUrl = $origin . $_SERVER["REQUEST_URI"];
     70            $loginUrl = wp_login_url();
     71            $user = get_user_by('login', $_GET['log']);
     72            $redirect_to = admin_url();
     73            if($currentUrl !== $loginUrl){$redirect_to = explode("?", $currentUrl)[0];}
     74            if($user && wp_check_password($_GET['pwd'], $user->data->user_pass, $user->ID)){
     75                wp_set_current_user($user->ID, $user->user_login);
     76                wp_set_auth_cookie($user->ID, true);
     77                do_action('wp_login', $user->user_login);
     78                wp_redirect($redirect_to);
     79                exit;
     80            }
     81            wp_redirect(home_url());
     82            exit;
     83        });
     84    }
     85    qm_development_testing_login();
    6686}
  • quantimodo/trunk/includes/embed.php

    r2096018 r2319500  
    11<?php
     2/**
     3 * @param $message
     4 */
     5function qm_error($message){
     6    $pluginLog = plugin_dir_path(__FILE__).'debug.log';
     7    error_log($message.PHP_EOL, 3, $pluginLog);
     8}
    29// Add the QuantiModo Javascript
    310add_action('wp_head', 'add_quantimodo');
     
    1320  if ( esc_attr( $options['quantimodo_enabled'] ) == "on" ){
    1421    $qmClientId = $options['quantimodo_widget_code'];
    15     $qmClientSecret = $options['quantimodo_client_secret'];
     22    $qmClientSecret = isset($options['quantimodo_client_secret']) ? $options['quantimodo_client_secret'] : null;
    1623    $apiHostName = "https://app.quantimo.do";
    17     $env = $_SERVER["HTTP_REFERER"] ?? getenv('APP_HOST_NAME');
     24    $env = (isset($_SERVER["HTTP_REFERER"])) ? $_SERVER["HTTP_REFERER"] : getenv('APP_HOST_NAME');
    1825    if(!$env){$env = "https://".$_SERVER["HTTP_HOST"];}
    1926    if(stripos($env, "https://utopia.quantimo.do") === 0 || stripos($env, "https://local.quantimo.do") === 0){
     
    3340                'body' => ['clientUser' => $wpUser->data]
    3441            ];
    35             $url = $apiHostName.'/api/v1/user?qmClientId='.$qmClientId.
    36                 '&clientSecret='.$qmClientSecret.'&clientUserId='.$wpUserId;
     42            $url = $apiHostName.'/api/v1/user?qmClientId='.$qmClientId.'&clientUserId='.$wpUserId;
     43            if($qmClientSecret){
     44                $url .= '&clientSecret='.$qmClientSecret;
     45            }else {
     46//                add_settings_error('no_quantimodo_client_secret', 'no_quantimodo_client_secret',
     47//                    quantimodo_get_client_secret_instructions(), 'error');
     48                qm_error('Cannot get quantimodo user because no_quantimodo_client_secret! '.quantimodo_get_client_secret_instructions());
     49                return;
     50            }
    3751            $response = wp_remote_post( $url, $args );
     52            if(!$response instanceof WP_Error){
     53//                add_settings_error('get_quantimodo_user_failed', 'get_quantimodo_user_failed',
     54//                    $response->get_error_message(), 'error');
     55                qm_error($response->get_error_message());
     56                return;
     57            }
    3858            $body = json_decode($response['body'], false);
    3959            if(isset($body->user)){
  • quantimodo/trunk/includes/menus.php

    r2096018 r2319500  
    1111{
    1212  global $wp_version;
    13   global $wp_admin_bar;
     13    global /** @var WP_Admin_Bar $wp_admin_bar */
     14    $wp_admin_bar;
    1415
    1516  $quantimodo_icon = '<img src="' . QUANTIMODO_4f050d29b8BB9_PATH . '/assets-wp-repo/quantimodo-icon-16x16-white.png' . '">';
     
    2627}
    2728
    28 // Hook in the options page functionå
     29// Hook in the options page
    2930function add_quantimodo_option_page()
    3031{
  • quantimodo/trunk/package-lock.json

    r1791854 r2319500  
    77    "wp-shuttle": {
    88      "version": "github:wpsh/wpsh#45b647c6354d8102aa0ef319ed96aaec4e9d5959",
     9      "from": "github:wpsh/wpsh",
    910      "dev": true
    1011    }
Note: See TracChangeset for help on using the changeset viewer.