Skip to content

Instantly share code, notes, and snippets.

@s9011514
s9011514 / bulk-del-comments-meta.sql
Last active May 10, 2016 08:38
批次刪除WordPress垃圾留言
/* 批次刪除不存在的迴響之meta值 */
DELETE FROM wp_commentmeta WHERE comment_id NOT IN (SELECT comment_id FROM wp_comments);
@s9011514
s9011514 / bulk-comments-1.sql
Last active June 22, 2016 16:54
WordPress 批次開啟/關閉留言功能,教學說明: https://sofree.cc/wordpress-bulk-comment-close/
/*批次關閉所有文章留言*/
UPDATE wp_posts SET comment_status = 'close' WHERE post_type = 'post' ;
@s9011514
s9011514 / wp_srcset_fix.php
Last active December 15, 2015 09:06
解決WordPress 4.4 媒體庫破圖(srcset)設定問題 https://sofree.cc/wp-srcset-media-image-broken/
<?php
add_filter('wp_get_attachment_image_attributes', function($attr) {
if (isset($attr['sizes'])) unset($attr['sizes']);
if (isset($attr['srcset'])) unset($attr['srcset']);
return $attr;
}, PHP_INT_MAX);
add_filter('wp_calculate_image_sizes', '__return_false', PHP_INT_MAX);
add_filter('wp_calculate_image_srcset', '__return_false', PHP_INT_MAX);
remove_filter('the_content', 'wp_make_content_images_responsive');
<?php
/**
功能:檔案避免中文檔名
**/
function achang_chang_filename_to_date($filename) {
$info = pathinfo($filename);
$ext = empty($info['extension']) ? '' : '.' . $info['extension'];
$name = basename($filename, $ext);
if(!is_numeric($name)){
@s9011514
s9011514 / robots.txt
Created July 29, 2015 05:39
解決Googlebot 無法存取網站上的CSS和JS檔案
#Googlebot
User-agent: Googlebot
Allow: *.css
Allow: *.js
# Other bot spider
User-agent: *
Disallow: /wp-admin/
Disallow: /wp-includes/
@s9011514
s9011514 / php-mail.php
Created September 14, 2014 07:13
[PHP]使用Mail函式透過SMTP發信
<?php
$to =" yourmail@your.com "; //收件者
$subject = "test"; //信件標題
$msg = "smtp發信測試";//信件內容
$headers = "From: admin@your.com"; //寄件者
if(mail("$to", "$subject", "$msg", "$headers")):
echo "信件已經發送成功。";//寄信成功就會顯示的提示訊息
else:
echo "信件發送失敗!";//寄信失敗顯示的錯誤訊息
@s9011514
s9011514 / remove-iframe.html
Created April 13, 2014 16:15
[教學]如何解決網站被7headlines的iframe蓋台? http://sofree.cc/remove-iframe/
<script>
//<![CDATA[
if (top.location != location ) {
top.location.href = location.href;
}
//]]>
</script>
@s9011514
s9011514 / step1.html
Last active December 17, 2015 04:49
一鍵儲存檔案到 Google Drive 雲端硬碟 http://sofree.cc/save-files-to-google-drive/
<script src="https://apis.google.com/js/plusone.js"></script>
<div class="g-savetodrive" data-filename="檔案名稱" data-sitename="網站名稱" data-src="檔案路徑">
</div>
@s9011514
s9011514 / step1.html
Created April 29, 2013 06:38
在側邊欄加個浮動Facebook粉絲框 http://sofree.cc/sliding-fb-box/
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
@s9011514
s9011514 / step1.html
Created April 28, 2013 11:42
使用jQuery和CSS去除超連結虛線 http://sofree.cc/jquery-css-outline/
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>