用 Sql 語法建立一個新的 WordPress Admin

Author: Eric  //  Category: Free Teaching

00. 為了 WordPress 安全起見, 很多人會把 WordPress 預設的 admin 做修改或刪除。如果刪除了預設的 admin, 也把文章都轉移到新建的管理員, 但一開始還能登入, 過一陣子突然不能登入了, 用 phpMyAdmin 進到您的 WordPress Database 下的 wp_users 也沒看到任何擁有管理權限的帳戶了, 那就繼續往下讀吧。 // Real Case Please Click Here

01. 請您先備份資料庫 Database
// 任何會動到資料庫 Database 的最好先備份, 人非聖賢, 孰能無過

02. 登入 phpMyAdmin, 我們要利用它來 run Sql 指令 Read more...

在虛擬主機有安裝 SuPHP 情況下啟用 Gzip

Author: Eric  //  Category: Free Teaching

01. 因為希望 WordPress 可以再快一點, 所以就想把 Gzip 打開, 這就是成長的動力, 好還要更好, 沒有最好只有更好, 於是創了個 phpinfo.php, 想更進一步的來了解一下自己的虛擬主機。

<?php phpinfo(); ?>

查看了自己的 Server 是否有支援 GZIP, 發現恰是一切正常.

HTTP_ACCEPT_ENCODING  gzip, deflate
_SERVER["HTTP_ACCEPT_ENCODING"] gzip, deflate
_ENV["HTTP_ACCEPT_ENCODING"] gzip, deflate

02. 於是分別在 .htaccess file 加上

a. 結果出現 HTTP 500 - Internal Server Error.

php_flag zlib.output_compression on
php_value zlib.output_compression_level 4

b. 第二種沒反應 // that is, 不支持 mod_deflate

<ifmodule mod_deflate.c>
DeflateCompressionLevel 4
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-httpd-php
AddOutputFilter DEFLATE js css
</ifmodule>

03. 兩種都沒成功, 於是又上網 Google , 找了好久才發現如果主機有裝 SuPHP, 寫法會有不同, 要稍稍修正。

When SuPHP is enabled, it is no longer possible to to include php_value directives in .htaccess files.

Instead of adding these directives to your .htaccess file, add them into a file called php.in and place this file in the same directory that your script runs in. Most often this will be public_html directory, but in some cases you will install your script in a subdirectory. Wherever your script runs, this is the place for your php.ini file. You will need to drop the "php_flag" and "php_value" prefix. You will also need to put an equals (=) sign between the setting and the value.

a. 前面不要加上 "php_flag" and "php_value"
b. 設定和值中間用 "=" 隔開
c. 原本放在 .htaccess file -> 改放置在 php.ini file

eg:原本放 .htaccess file

php_value max_execution_time 60
php_flag zlib.output_compression on

改後放 php.ini // 目錄下沒 php.ini, 就自己創, 改好後再上傳, 非 php.ini.txt 喔

max_execution_time = 60
zlib.output_compression = on

所以原本在 .htaccess file 的寫法, 要改成下面的樣子, 然後放置於 php.ini

zlib.output_compression = on
zlib.output_compression_level = 4

04. 最後, 別忘了來 Gzip Test 驗收成果

ps.
a. 如果啟用 Gzip 出現 HTTP 500 - Internal Server Error, 很可能就是您的虛擬主機有使用 SuPHP
b. JustHost 有使用 SuPHP
c. 沒特別設定 compression level 的話, 預設是6, 數字可以是 1~9
d. Compression test : 32,380 bytes // 超過 4 級就沒什麼差別了

Level 1: 9,161 bytes 71.7%
Level 2: 8,915 bytes 72.5%
Level 3: 8,757 bytes 73.0%
Level 4: 8,400 bytes 74.1%
Level 5: 8,215 bytes 74.6%
Level 6: 8,155 bytes 74.8%
Level 7: 8,120 bytes 74.9%
Level 8: 8,108 bytes 75.0%
Level 9: 8,100 bytes 75.0%

Ref:
01. All servers having SuPHP installed for added security
02. How to use gzip compression on your PHP websites
03. Force GZIP compression on your HostMonster-hosted website
04. GZIP files

自動為圖片添加浮水印 WordPress Watermark Plulgin

Author: Eric  //  Category: Free Teaching

01. WP-WaterMark 是一款名副其實 (亦作名符其實) 的 WordPress 自動添加 Watermark 浮水印的 Plugin。

a. 請到這下載 WP-WaterMark,解壓上傳至 /wp-content/plugins/ 下,並在後台啟用。
// 有兩種版本,一種是 with fonts、without fonts,如果您是要加自己的圖片 or 有自己較喜歡的字型,那下載 without fonts 即可。

b. 打開 /wp-admin/includes/media.php,用 Ctrl+F 找到 "function media_handle_upload" 或 "// Save the data",然後在適當位置 "// Save the data" 前加入下面的 code

    // For WP WaterMark
    MM_Execute_WM( $file, '' );

c. 圖片浮水印 : 請把 /wp-content/plugins/watermark/ 下的 stempel.png 換成您想要加的 logo。

d. 文字浮水印 : 請上傳您想用的字型到 /wp-content/plugins/watermark/fonts/ 下。

e. 請移駕玉步到 WP 後台 -> Settings -> Watermark -> 進行設定。

啟用 -> 選位置 (用Offset微調) -> 選圖片型 Watermark 浮水印 -> Save。

啟用 -> 選位置 (用Offset微調) -> 選文字型 Watermark 浮水印 -> 設定字型、大小、顏色(Html Color Code)、要顯示的文字、不透明度 (100:完全不透明,0:完全透明)、陰影。

f. 這樣只要自 WP 後台上傳的圖片,都會自動加上 浮水印 Watermark 了。


Read more...

WordPress Page Related Plugin: Page Links and Exclude Pages from Navigation Menu

Author: Eric  //  Category: Free Teaching

01. WordPress Plugin : Page Links To 是一個可以讓 Page 或 Post,連結到您想要的網址,還有是否以新視窗開始、以 301 還是 302 來做 Redirect 的選項可以選擇。

eg: 如果您有論壇 or 相簿,但無法整合到 WordPress 時,Page Links To 這個 WP Plugin 就非常好用。

a. 填上您想要連結的網址 : Point to this URL
b. 如果想要以新視窗開啟 : Open this link in a new window
c. 不勾為301,打勾為302 : Use a temporary 302 redirect (default is a permanent 301 redirect)

02. WordPress Plugin : Exclude Pages from Navigation 是一個可以讓您經由簡單的設定,來決定是否讓 Page 顯示在 Navigation Menus (導航欄)。

a. 打勾代表要顯示於Navigation Menus (導航欄) : Include this page in user menus
b. 假設把 about 隱藏起來,但如果知道連結還是可以打個開喔 -> http://who-know.com/about/

03. WordPress Plugin : Page Link Manager 是一個跟 Exclude Pages from Navigation 很類似的 WP Plugin,不過當您有很多分頁時,要一一的去設定顯示 or 隱藏,這時 Page Link Manager 會是一個更好的選擇,它會把所有的分頁列出來,可以直接勾選是否顯示出來。

a. 打勾代表要顯示於Navigation Menus (導航欄) : Include this page in user menus
b. 假設把 about 隱藏起來,但如果知道連結還是可以打個開喔 -> http://who-know.com/about/

// Page Links ToExclude Pages from Navigation 都是在新增一個 Post 或 Page 那裡設定,但 Page Link Manager 則是在 Tools (工具) -> Page Links 下去做設定。

還在用 wp_list_pages(); 的 exclude 和查 Page ID,然後再辛苦的去改 Theme,來隱藏分頁嗎 ?
那就趕快來試試 Exclude Pages from NavigationPage Link Manager 吧。

Pages: Prev 1 2 3 4 5 6 7 8 9 Next