LoginSignup
3
1

More than 5 years have passed since last update.

CloudFront下のWordPressでは投稿画面でビジュアルモードが使えない

Posted at

原因

User-Agentが Amazon CloudFront に書き換えられてるから。
UAを見てモバイルか判定してビジュアルモードをon/offしてる。
CloudFrontのForward Headers設定をAllにすると問題なく使えることもあるけど使えないこともあってはっきりしない。

プラグイン作った

functions.phpで解決できるけど100個以上のWPで一つ一つ手作業とか無理なのでプラグイン化。
使い方はインストールして有効化するだけ。

CloudFront側で CloudFront-Is-Desktop-Viewer headerを通す設定は必要。
モバイルでは元々無効なので無効なまま。

wp-cliでインストール

wp plugin install visual-mode-in-cloudfront --activate

もしくは(所有者が違う場合など)

sudo -u nginx wp plugin install visual-mode-in-cloudfront --activate

/var/www/vhosts/以下に全部インストールしたい場合は
これと同じようにすればいいはず。
http://qiita.com/wokamoto/items/4f70664a743f7e82bb16

初めてWPプラグイン作ったメモ

  • プラグイン名の最初に他社が権利持ってそうな名前は使えない。正確には名前というかhttps://wordpress.org/plugins/以下のディレクトリ名。CloudFrontとかAmazonとかGoogleとか。〇〇 for CloudFrontと後ろに付けるかCFと省略すれば使える。
  • git/GitHubで管理しつつWordPressにはsvnでデプロイする古い情報が色々あるけど全部無視したほうがいい。

これのdeploy-plugin.shだけで十分。これも数年前だけど。
https://github.com/sudar/wp-plugin-in-github

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1