我正在开发我的第一个wordpress插件.它只需要允许用户更改自定义模板中的徽标并更改自定义模板中的颜色方案.
我已经创建了一个管理选项页面,现在想要添加一个字段以允许用户上传图像.如何将图像上传到wp-content/uploads文件夹.到目前为止,我在一张表中有这个:
<td><input name="logo_image" type="file" id="logo_image" value="" /></td>
Run Code Online (Sandbox Code Playgroud)
这是正确的方法吗?如果是这样,我如何将文件定向到正确的文件夹?wordpress是否有自己处理文件上传的方式?
401我得到的具体错误信息是:
"error":"invalid_client","error_description":"The client credentials are invalid"}"
此错误未在 PayPal 文档中的任何地方列出。我确定我正在使用测试凭据并使用正确的沙箱端点。当我尝试获取访问令牌时发生错误。
这是检索访问令牌的类:
private function _generateAccessToken($config) {
$base64ClientID = base64_encode($this->clientId . ":" . $this->clientSecret);
$headers = array(
"User-Agent" => PPUserAgent::getValue(RestHandler::$sdkName, RestHandler::$sdkVersion),
"Authorization" => "Basic " . $base64ClientID,
"Accept" => "*/*"
);
$httpConfiguration = $this->getOAuthHttpConfiguration($config);
$httpConfiguration->setHeaders($headers);
$connection = PPConnectionManager::getInstance()->getConnection($httpConfiguration, $config);
//print_r($connection); die;
$res = $connection->execute("grant_type=client_credentials");
$jsonResponse = json_decode($res, true);
if($jsonResponse == NULL ||
!isset($jsonResponse["access_token"]) || !isset($jsonResponse["expires_in"]) ) {
$this->accessToken = NULL;
$this->tokenExpiresIn = NULL;
$this->logger->warning("Could not generate new Access token. Invalid response from …Run Code Online (Sandbox Code Playgroud)