20230901: 后台开发的时候。注意大小写,注意大小写,注意大小写。包括传递的参数都要注意大小写。在使用wp_insert_user( $userdata )函数时,userdata里面的ID正确的为大写,小写就是找不到。
20230726:腾讯云租用服务器
20230727:二级域名a.bdsp.top解析到腾讯云
云服务器安装WAMP。
安装过程出现“由于找不到vcruntime140_1.dll,无法继续执行代码“错误提示,导致WAMP安装失败。到官网下载 Microsoft Visual C++ Redistributable进行安装后,WAMP 安装成功。
云服务器安装IIS,默认网站可以访问。
更改IIS监听端口为8080,WAMP监听端口 80
云服务器增加网站,访问a.bdsp.top 出现“403 Forbidden"错误,修改httpd-vhosts.conf配置 ,问题解决。
下载wordpress,解压后放到网站根目录。
20230804:先安装wordpress,然后使用 Astra 主题,该主题可以更换不用的模板。
配置好网站,上传完产品之后,将可以删除的插件全部删除,可以加快访问速度。
进入Astra 菜单里面的custom,可以进行菜单,页面的定制修改。
可以考虑将操作系统由windows更换未 centos,以加速apache响应。
2023086: 参考 wordpress建站教程:woocommerce产品属性调用方法 - 悦然wordpress建站 (zsxxfx.com) 这篇文章,可以在短描述或者详情页当中显示产品自定义的 属性。
20230809: astra 主题的设置中,性能里面可以选择本地加载谷歌字体,以提供响应速度。
20230826:自定义API, 使用外观菜单下面的 主题文件编辑器,对模版函数文件 function.php 文件进行更改。使用add_action( 'rest_api_init', function () { 增加自定义路由API接口。注意 使用echo会返回JSON类型,而使用Return会返回 String
可以使用短代码快速设置产品属性。
20230826: 所有自定义API和短代码都写入到插件 HELLO DOLLY的 Hello.php文件中。使用插件菜单下面的插件文件编辑器进行编辑。
//短代码示例
//使用方法[product_additional_information]或[product_additional_information id='66']
//调用产品属性的短代码
if ( ! function_exists( 'display_product_additional_information' ) ) {
function display_product_additional_information($atts) {
// Shortcode attribute (or argument)
$atts = shortcode_atts( array(
'id' => ''
), $atts, 'product_additional_information' );
// If the "id" argument is not defined, we try to get the post Id
if ( ! ( ! empty($atts['id']) && $atts['id'] > 0 ) ) {
$atts['id'] = get_the_id();
}
// We check that the "id" argument is a product id
if ( get_post_type($atts['id']) === 'product' ) {
$product = wc_get_product($atts['id']);
}
// If not we exit
else {
return;
}
ob_start(); // Start buffering
do_action( 'woocommerce_product_additional_information', $product );
return ob_get_clean(); // Return the buffered outpout
}
add_shortcode('product_additional_information', 'display_product_additional_information');
}
//增加自定义路由API 接口 示例
add_action( 'rest_api_init', function () {
register_rest_route( 'myapi/v1', '/getopenid', array(
'methods' => 'GET',
'callback' => 'myapi_getopenid'
) );
} );
function myapi_getopenid( $request ) {
//$token = $request->get_header( 'Authorization' );
//$token = $request->get_param('code');
$code=$_GET["code"];
$url = "https://api.weixin.qq.com/sns/jscode2session?js_code=$code"; //经试验这个js_code=$code写不到下面POST参数中
echo curl_get_https($url); //使用echo会返回JSON类型,而使用Return会返回 String
//$result = curl_get_https($url);
//var_dump($result);
//return $result;
}
function curl_get_https($url){
$curl = curl_init();
//如果需要参数,设置POST参数
$post_string = array('appid'=>'wxde8c3aecea62bc16','secret'=>'81f7e0b8f31dbae296d4f2462d042d4f'); //小程序ID和密钥
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post_string));
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // 跳过检查
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); // 跳过检查
$tmpInfo = curl_exec($curl);
curl_close($curl);
return $tmpInfo; //返回json对象
}
以下是推荐安装的插件。
共有条评论 网友评论