wordpress 处理流程
在安装好WP的前提下
使用模板 :
1. savoy-minimalist-ajax-woocommerce-theme-3.0.7.zip
2. blocksy-companion-pro-2.1.1-fixed.zip
安装插件:Woocommerce
支付插件:WP NMI Gateway PCl for Woocommerce
导入shopify数据: s2w-import-shopify-to-woocommerce_1.3.2.zip
############
修改后台目录 为安全起见 更改登录目录
cp wp-login.php pancartLogin.php
mv wp-login.php wp-login-bak.php
或者
mv wp-login.php pancartLogin.php#替换默认登录地址
vim pancartLogin.php
:%s/wp\-login\.php/pancartLogin\.php/g
#备份一下关键文件
cp wp-includes/general-template.php wp-includes/general-template-bak.php
#进到文件, 替换登录地址
vim wp-includes/general-template.php
:%s/wp\-login\.php/pancartLogin\.php/g
#查找$login_url 将 site_url的值 改成 index.php (这样处理 可以不用在主题里面增加代码)
:%s/$login_url = site_url( \'pancartLogin\.php/$login_url = site_url( \'index\.php/g
#给到文件权限
chown -R www-data:www-data *
////修改主题文件 #####################################################
#模板function.php下
#
if ( current_user_can( 'administrator' ) ) {
$httpType = $_SERVER['HTTP_X_FORWARDED_PROTO']??'';
// 如果当前用户是管理员,执行这里的代码
if($httpType && $httpType=='https'){ header("location: http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'],true,301);}
}
###################################
#结合cloudeflare 使用默认的HTTLS证书(不需要在服务器端安装证书)
vim wp-blog-header.php
# 在 wp() 下增加
$httpType = $_SERVER['HTTP_X_FORWARDED_PROTO']??'';
if(!is_user_logged_in()){
//echo '<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">';
$_SERVER['HTTPS']='on';
if($httpType && $httpType=='http'){ header("location: https://".$_SERVER['HTTP_HOST'],true,301);}
}else{
if ( current_user_can( 'administrator' ) ) {
if($httpType && $httpType=='https'){ header("location: http://".$_SERVER['HTTP_HOST'],true,301);}
}
}
if(is_page('checkout') || is_page('cart') || is_page('product') || is_product()){
echo '<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">';
}
或
if(!is_user_logged_in()){
//echo '<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">';
$_SERVER['HTTPS']='on';
$httpType = $_SERVER['HTTP_X_FORWARDED_PROTO']??'';
if($httpType && $httpType=='http'){ header("location: https://".$_SERVER['HTTP_HOST'],true,301);}
}
if(is_page('checkout') || is_page('cart') || is_page('product')){
echo '<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">';
}
或
if(!is_user_logged_in()){
echo '<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">';
$httpType = $_SERVER['HTTP_CF_VISITOR']??'';
if($httpType){
$httpType = json_decode($httpType,true);
$scheme = $httpType['scheme']??'';
if($scheme=='http'){ header("location: https://".$_SERVER['HTTP_HOST'],true,301);}
}
}
# 在 require_once ABSPATH . WPINC . '/template-loader.php'; 上添加
if(is_page('cart')){
echo '<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">';
}
# 在 require_once ABSPATH . WPINC . '/template-loader.php'; 下添加 用于购物车页面样式混乱 的问题
if(is_page('checkout') || is_page('cart') || is_page('product')):
$htmlCss = '
<style>
.section_wrapper, .container{height:auto;}
</style> ';
echo $htmlCss;
endif;
################
版权属于:BLOG DEWEBSTUDIO 本文作者:狒狒
原文地址: http://blog.dewebstudio.com/?post=155
版权声明:转载时必须以链接形式注明原始出处及本声明。
继续浏览:
发表评论