Nginx禁用缓存的配置 1https://www.cnblogs.com/xiohao/p/14691517.html 在网站程序调试的时候,经常会遇到浏览器的缓存问题导致修改过的前端代码无效果。每次通过Ctrl+F5强制刷新后才能清掉缓存。这时如果禁用掉nginx缓存,可以减少一些小麻烦,让浏览器每次到服务器去请求文件,而不是在浏览器中读取缓存文件。 当程序调试好上线后,可以开启nginx缓存,节省服务器的带宽流量,减少一些请求,降低服务器的压力。 通过配置nginx的配置文件/usr/local/nginx/conf/nginx.conf实现开关效果 1. 启用缓存 1234location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css)$ { #设置缓存上面定义的后缀文件缓存到浏览器的生存时间 expires 3d; } 2. 禁用缓存 1234location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css)$ { #禁止缓存,每次都从服务器请求 add_header Cache-Control no-store; } 3. 查看本机的位置 123cd /usr/local/nginx/conf/vhost vi www.vermax.cn.conf vi www.huajunstone.com.conf 123456789 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { […]
Category Archives: WordPress代码
WordPress 代码高亮插件 CodeColorer 123https://huyangjia.com/replace-the-code-highlighting-plugin-for-codecolorer.html https://www.sohu.com/a/227329060_100003313 https://kpumuk.info/projects/wordpress-plugins/codecolorer/ 边框设计参考如下网站: 12http://www.linuxcache.com/archives/3896 这个字体色漂亮 http://www.divcss5.com/wenji/w503.shtml 这个表格边框漂亮 1. 插件下载: https://webcode.bndstone.com/wordpress/plugin/codecolorer.zip 2. 安装插件 Wordpress 后台 –> Plugins –> Add New –> Upload Plugin –> 选择文件 –> Install Now –> Active Now 3. 设置CodeColorer 3-1. 安装完后 就可以看到 Settings –> CodeColorer 3-2. 例出每种风格 Slush & Poppies […]
wordpress后台加载速度慢,Functions.php 用代码加速 12https://may90.com/building/hm.html http://www.mlwei.com/1459.html 1. 打开调试模式,查看哪些地方影响速度. WordPress 后台 – 快捷键F12 – 网络(Network) – F5刷新 2. 屏蔽掉无用的后台查询功能,把以下代码添加到你当前主题目录下的函数文件functions.php中: 12cd /home/wwwroot/default/vermaxcn/wp-content/themes/flatsome vi functions.php 123456789101112131415161718192021222324252627282930function disable_dashboard_widgets() { remove_meta_box(‘dashboard_recent_comments’, ‘dashboard’, ‘normal’); remove_meta_box(‘dashboard_recent_drafts’, ‘dashboard’, ‘normal’); remove_meta_box(‘dashboard_primary’, ‘dashboard’, ‘core’); remove_meta_box(‘dashboard_secondary’, ‘dashboard’, ‘core’); remove_meta_box(‘dashboard_right_now’, ‘dashboard’, ‘core’); remove_meta_box(‘dashboard_incoming_links’, ‘dashboard’, ‘core’); remove_meta_box(‘dashboard_plugins’, ‘dashboard’, ‘core’); remove_meta_box(‘dashboard_quick_press’, ‘dashboard’, ‘core’); } add_action(‘admin_menu’, ‘disable_dashboard_widgets’); function wpdaxue_remove_cssjs_ver( $src ) { […]
字体背景及颜色的控制. 1. p标签 If there is any question , Please feel free to contact us. Thank you for your time 123<p style="background-color:#398BFC;font-size:14px; color: rgb(255, 255, 255); font-family: arial; font-weight: Bold;"> If there is any question , Please feel free to contact us. Thank you for your time </p> 2. span标签 If there is any question […]
themes\flatsome\404.php 分析 1. 引用header部份 1<?php get_header(); ?> 2. 引用Footer部份 1<?php get_footer(); ?> 3. 修改 “404” 1<div class="col medium-3"><span class="header-font" style="font-size: 6em; font-weight: bold; opacity: .3">404</span></div> 4. 修改 “Oops! That page can’t be found.” 1<h1 class="page-title"><?php esc_html_e( ‘Oops! That page can’t be found.’, ‘flatsome’ ); ?></h1> 5. 修改 “It looks like nothing was found at this […]
当WordPress文章中没有设置特色图片时,读取文章中的第一张图片 1https://www.91wordpress.com/370.html 1. 切换到你主题所在目录,打开function.php文件,加入下面这段代码:注:此方法工作原理是查找文章内有没img这个标签,如果有就调出第一张图片,如果没有就用一张设计好的图片代替 12345678910111213function catch_that_image() { global $post, $posts; $first_img = ”; ob_start(); ob_end_clean(); $output = preg_match_all(‘/<img.+src=[\’"]([^\’"]+)[\’"].*>/i’, $post->post_content, $matches); $first_img = $matches [1] [0]; if(empty($first_img)){ //Defines a default image $first_img = get_bloginfo(‘template_url’)."/images/default.jpg"; } return $first_img; } 2. 在想调用的地方,加入下面这段代码: 1234<?php $a=catch_that_image(); echo ‘<img src="’.$a.’" […]
备注: 一开始用的是插件,设置起来非常麻烦.后来改用代码,直接申请个专用密码就可以,非常简单. 这两种方法都不需要启用 postfix ,也无需启用任何端口. 1. 用代码代替如下 Gmail Smtp 插件 12https://bndstone.com/458.html https://www.91wordpress.com/408.html 1-1. 切换到主题目录,打开 functions.php 文件, 12cd /home/wwwroot/default/bndstone/wp-content/themes/flatsome/ vi functions.php 1-2. 添加如下代码: 123456789101112function mail_smtp($phpmailer) { $phpmailer->isSMTP(); $phpmailer->SMTPAuth = true; //不用改, 启用SMTPAuth服务 $phpmailer->Port = 465; //不用改, SMTP邮件发送端口,常用端口有:25,安全链接端口:465、587 […]
WordPress内容页图片智能添加alt属性(自动添加文章标题作为图片alt属性) 1https://www.91wordpress.com/457.html 切换到主题目录,打开functions.php文件,添加如下代码: 12345678910111213141516171819202122function image_alt( $imgalt ){ global $post; $title = $post->post_title; $imgUrl = "<img\s[^>]*src=("??)([^" >]*?)\\1[^>]*>"; if(preg_match_all("/$imgUrl/siU",$imgalt,$matches,PREG_SET_ORDER)){ if( !empty($matches) ){ […]
代码实现文章缩略图的方法 1https://www.91wordpress.com/703.html 12cd /home/wwwroot/default/vermaxcn/wp-content/themes/flatsome/ vi functions.php 12345678910111213141516171819add_theme_support( ‘post-thumbnails’ ); function post_thumbnail( $width = 255,$height = 130 ){ global $post; if( has_post_thumbnail() ){ $timthumb_src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID),’full’); $post_timthumb = ‘<img src="’.get_bloginfo("template_url").’/timthumb.php?src=’.$timthumb_src[0].’&h=’.$height.’&w=’.$width.’&zc=1" alt="’.$post->post_title.’" class="thumb" title="’.get_the_title().’"/>’; echo $post_timthumb; } else { […]
代码实现 关闭后台自动更新功能 1https://www.91wordpress.com/934.html 1. 关闭后台更新提示 切换到主题目录,打开functions.php文件,加入以下代码: 12cd /home/wwwroot/default/vermaxcn/wp-content/themes/flatsome/ vi functions.php 1234567//移除更新提示 function remove_core_updates(){ global $wp_version;return(object) array(‘last_checked’=> time(),’version_checked’=> $wp_version,); } add_filter(‘pre_site_transient_update_core’,’remove_core_updates’); add_filter(‘pre_site_transient_update_plugins’,’remove_core_updates’); add_filter(‘pre_site_transient_update_themes’,’remove_core_updates’); 2. 关闭自动更新功能切换到网站根目录,打开config.php文件,加入以下代码: 12cd /home/wwwroot/default/vermaxcn vi wp-config.php 1define( ‘AUTOMATIC_UPDATER_DISABLED’, true ); 3. 重启 nginx 1systemctl restart nginx.service 4. 已成功,后台 修改前后对比