小编bbb*_*bbb的帖子

Wordpress:在管理员选项页面上传图片

我正在开发我的第一个wordpress插件.它只需要允许用户更改自定义模板中的徽标并更改自定义模板中的颜色方案.

我已经创建了一个管理选项页面,现在想要添加一个字段以允许用户上传图像.如何将图像上传到wp-content/uploads文件夹.到目前为止,我在一张表中有这个:

<td><input name="logo_image" type="file" id="logo_image" value="" /></td>
Run Code Online (Sandbox Code Playgroud)

这是正确的方法吗?如果是这样,我如何将文件定向到正确的文件夹?wordpress是否有自己处理文件上传的方式?

php forms wordpress upload image

9
推荐指数
2
解决办法
2万
查看次数

PayPal API:异常:访问 https://api.sandbox.paypal.com/v1/oauth2/token 时为 401

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)

php paypal oauth-2.0

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

php ×2

forms ×1

image ×1

oauth-2.0 ×1

paypal ×1

upload ×1

wordpress ×1