Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed errors #9

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified latch.zip
Binary file not shown.
17 changes: 11 additions & 6 deletions latch/latch.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,25 @@ static function latch_settings_page() {
}

static function latch_validate_appId($appId){
if (!empty($appId) && strlen($appId) != 20) {
/*if (!empty($appId) && strlen($appId) != 20) {
add_settings_Error('latch_invalid_appId', 'latch_invalid_appId', __('Invalid application ID', 'latch'));
return '';
} else {
return $appId;
}*/
if(!empty($appId) && strlen($appId) != 20){
add_settings_Error('latch_invalid_appId', 'latch_invalid_appId', __('Invalid application ID', 'latch'));
$appId = '';
}
return $appId;
}

static function latch_validate_appSecret($appSecret){
if (!empty($appSecret) && strlen($appSecret) != 40) {
add_settings_Error('latch_invalid_appSecret', 'latch_invalid_appSecret', __('Invalid secret key', 'latch'));
return '';
} else {
return $appSecret;
$appSecret = '';
}
return $appSecret;
}

static function latch_validate_host($host) {
Expand All @@ -108,9 +112,10 @@ static function latch_validate_host($host) {
/* -------- PROFILE SETTINGS (current user) --------- */

static function action_profile_personal_options() {
global $user_id, $is_profile_page;
global $user_id;
/*global $is_profile_page;*/ // Variable without using

$latch_id = trim( get_user_option('latch_id', $user_id ) );
$latch_id = trim( get_user_option('latch_id', $user_id ) );

echo "<h3>" . __( 'Latch Setup', 'latch' ) . "</h3>\n";
echo '<table class="form-table"><tbody><th>';
Expand Down
2 changes: 1 addition & 1 deletion latch/vendor/ElevenPaths/latch-sdk-php/src/Latch.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
version 2.2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
Expand Down
19 changes: 15 additions & 4 deletions latch/vendor/ElevenPaths/latch-sdk-php/src/LatchAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ abstract class LatchAuth {
private static $API_VERSION = "1.0";
public static $API_HOST = "https://latch.elevenpaths.com";


// App API
public static $API_CHECK_STATUS_URL = "/api/1.0/status";
public static $API_PAIR_URL = "/api/1.0/pair";
Expand Down Expand Up @@ -149,8 +150,8 @@ public function HTTP($method, $url, $headers, $params) {
curl_setopt($ch, CURLOPT_PROXY, self::$PROXY_HOST);

if ($method == "PUT" || $method == "POST"){
$params_string="";
foreach($params as $key=>$value) { $params_string .= $key.'='.$value.'&'; }
$params_string = "";
foreach($params as $key=>$value) {$params_string .= $key.'='.$value.'&';}
rtrim($params_string, '&');
curl_setopt($ch,CURLOPT_POST, count($params));
curl_setopt($ch,CURLOPT_POSTFIELDS, $params_string);
Expand Down Expand Up @@ -185,6 +186,7 @@ protected function HTTP_DELETE_proxy($url) {
return new LatchResponse($this->HTTP("DELETE", self::$API_HOST . $url, $this->authenticationHeaders("DELETE", $url, null), null));
}


/**
*
* @param string $data the string to sign
Expand Down Expand Up @@ -260,7 +262,16 @@ private function getSerializedHeaders($xHeaders) {
}

private function getSerializedParams($params) {
if($params != null) {
$ret = "";
if($params != NULL){
ksort($params);
foreach($params as $key=>$value){
$ret .= $key . "=" . $value . "&";
}
$ret = trim($ret,"&");
}
return $ret;
/*if($params != null) {
ksort($params);
$serializedParams = "";

Expand All @@ -270,7 +281,7 @@ private function getSerializedParams($params) {
return trim($serializedParams, "&");
} else {
return "";
}
}*/
}

/**
Expand Down
4 changes: 2 additions & 2 deletions latch/vendor/ElevenPaths/latch-sdk-php/src/LatchResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ public function setError($error) {
public function toJSON() {
$response = array();
if(!empty($this->data)) {
$response["data"] = $data;
$response["data"] = $this->data;
}

if(!empty($error)) {
$response["error"] = $error;
$response["error"] = $this->error;
}
return json_encode($response);
}
Expand Down