Changeset 2319500
- Timestamp:
- 06/06/2020 02:24:05 PM (6 years ago)
- Location:
- quantimodo/trunk
- Files:
-
- 5 edited
-
includes/admin.php (modified) (2 diffs)
-
includes/core.php (modified) (2 diffs)
-
includes/embed.php (modified) (3 diffs)
-
includes/menus.php (modified) (2 diffs)
-
package-lock.json (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
quantimodo/trunk/includes/admin.php
r2125567 r2319500 1 1 <?php 2 2 /** 3 * @return string 4 */ 5 function 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 } 3 10 // Output the options page 4 11 function quantimodo_options_page() … … 85 92 </tr> 86 93 </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(); ?> 90 95 <?php if ( ! esc_attr( $options['quantimodo_widget_code'] ) ) { ?> 91 96 <h3>You can find your QuantiModo client id after -
quantimodo/trunk/includes/core.php
r2096018 r2319500 27 27 // Get options 28 28 $options = get_option('QuantiModo_settings'); 29 30 29 // Check to see if QuantiModo is enabled 31 30 $quantimodo_activated = false; … … 45 44 function send_push_notification( $message ) { 46 45 $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";} 50 47 $response = wp_remote_post($apiUrl, ['body' => json_encode(['message' => $message])]); 51 48 return $response; 52 49 } 53 50 add_action('messages_message_after_save', 'send_push_notification', 1, 1); 54 55 51 function annointed_admin_bar_remove() { 56 52 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');} 58 54 } 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 64 58 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(); 66 86 } -
quantimodo/trunk/includes/embed.php
r2096018 r2319500 1 1 <?php 2 /** 3 * @param $message 4 */ 5 function qm_error($message){ 6 $pluginLog = plugin_dir_path(__FILE__).'debug.log'; 7 error_log($message.PHP_EOL, 3, $pluginLog); 8 } 2 9 // Add the QuantiModo Javascript 3 10 add_action('wp_head', 'add_quantimodo'); … … 13 20 if ( esc_attr( $options['quantimodo_enabled'] ) == "on" ){ 14 21 $qmClientId = $options['quantimodo_widget_code']; 15 $qmClientSecret = $options['quantimodo_client_secret'];22 $qmClientSecret = isset($options['quantimodo_client_secret']) ? $options['quantimodo_client_secret'] : null; 16 23 $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'); 18 25 if(!$env){$env = "https://".$_SERVER["HTTP_HOST"];} 19 26 if(stripos($env, "https://utopia.quantimo.do") === 0 || stripos($env, "https://local.quantimo.do") === 0){ … … 33 40 'body' => ['clientUser' => $wpUser->data] 34 41 ]; 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 } 37 51 $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 } 38 58 $body = json_decode($response['body'], false); 39 59 if(isset($body->user)){ -
quantimodo/trunk/includes/menus.php
r2096018 r2319500 11 11 { 12 12 global $wp_version; 13 global $wp_admin_bar; 13 global /** @var WP_Admin_Bar $wp_admin_bar */ 14 $wp_admin_bar; 14 15 15 16 $quantimodo_icon = '<img src="' . QUANTIMODO_4f050d29b8BB9_PATH . '/assets-wp-repo/quantimodo-icon-16x16-white.png' . '">'; … … 26 27 } 27 28 28 // Hook in the options page functionå29 // Hook in the options page 29 30 function add_quantimodo_option_page() 30 31 { -
quantimodo/trunk/package-lock.json
r1791854 r2319500 7 7 "wp-shuttle": { 8 8 "version": "github:wpsh/wpsh#45b647c6354d8102aa0ef319ed96aaec4e9d5959", 9 "from": "github:wpsh/wpsh", 9 10 "dev": true 10 11 }
Note: See TracChangeset
for help on using the changeset viewer.