Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPBカップ
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

WPCodeの紹介 – 簡単なWordPressコードマネージャでウェブサイトのカスタマイゼーションを未来につなげよう

編集メモ: WPBeginner のパートナーリンクから手数料を得ています。手数料は編集者の意見や評価に影響を与えません。編集プロセスについて詳しく知る。

サイトで使用しているWordPressプラグインの数を減らしたいと思ったことはありませんか?

サイトを壊すことなく、コード・スニペットを通して将来のWordPressカスタマイザーを追加できる簡単な方法があればいいと思いませんか?

もしあなたが私や他の多くの賢いサイトオーナーと同じなら、WordPressの旅の中で少なくとも2、3回はこの解決策を望んだことがあるはずだ。

今日は、WordPressのカスタマイザーの考え方を変える、無料のWPCodeプラグインを発表します。

サイトのカスタマイザーを管理する時間と手間を省くためにこのツールをビルトインしました。これは、あなたのサイトをより高速にしながら、既存のWordPressプラグインを何十も置き換えるのに役立つ究極のスイスアーミーナイフツールのようなものです。

Introducing WPCode - WordPress Code Snippets Plugin

裏話

2012年、私はInsert Headers and Footersという無料のプラグインを作った。

このプラグインの目的は、私や他のWPBeginner読者がテーマファイルを編集することなく、WordPressサイトのヘッダーとフッターエリアにコードを簡単に追加できるようにすることだった!

これには、Googleアナリティクススクリプト、カスタムCSSコード、Facebookピクセル、AdSenseコードなどが含まれます。

過去10年間で、このシンプルなプラグインは100万以上の有効化したインストールに成長した。

Enter tracking code in header

同じ期間に、WordPressも大量の新機能やプラグインで大きく成長した。

毎月、ユーザーから、特定のページで条件付きでスクリプトをロードする機能や、サイトの他のエリアにコードスニペットを追加する機能など、より多くの機能を追加してほしいという要望をもらっていた。

多くのフィードバックと検討の結果、この無料プラグインを拡張し、条件付きロジックや自動インサーターなどを備えたWordPress用のフル機能のコードスニペット管理ソリューションにすることにしました。

新規プラグインを使用すると、次のことができます:

  • 数回クリックするだけで、サイトにトラッキングスクリプト/各種ウェブマスターツール検証メタ情報を追加できます。
  • 各ブログ投稿の最初の段落の後、各ブログ投稿の最後などにバナー広告やその他の動的コンテンツ要素を追加する。
  • REST API、XML-RPC、コメントなど、不要なWordPress機能を削除する。
  • チュートリアルのコードスニペットをWordPressサイトにエラーなしで簡単にコピー&ペースト。
  • そして、これは本当に表面をかすめただけです。

これらの機能はすべて無料で利用できる!

あなたがマーケティング担当者なら、WPCodeはGoogleタグマネージャのようなもので、WordPressの中にあるとお考えください。

あなたが普通のビジネスオーナーなら、これはあなたのサイトのためのスイス軍用ナイフだと考えてください。それ以上でもそれ以下でもない。

WPCodeは、WordPressサイトにインストールするプラグインの中で最も強力なものです。

5分だけ時間をください。

動画版

Subscribe to WPBeginner

WPCodeとは?

WPCodeは強力なWordPressコードスニペットプラグインで、テーマのfunctions.phpファイルを編集することなく、コードスニペットを使ってWordPressのカスタム機能を簡単に追加することができます。

コードスニペットライブラリがビルトインされており、私の最も人気のあるWordPressコードスニペットを見つけることができます。

WPCode WordPress Code Snippets Library

例えば、スニペットの用意がある:

  • XML-RPCの無効化 –WordPressのセキュリティのために有効です。
  • SVGファイルのアップロードを許可する – プラグインを区切る必要がなくなる。
  • Gutenbergを無効化 – プラグインが不要になります。
  • コメント無効化 – 区切りプラグインが不要になります。
  • Google アナリティクス、Facebook、AdSense、およびその他のプラットフォーム用のトラッキングスクリプトを追加します。

また、サイト上のプラグインの数を減らしながらカスタマイザー機能を追加するために使用できるコードスニペットも、現在20種類以上あります。

平均的なサイトオーナーであれば、このプラグインを使うことで、今使っている他のプラグインを少なくとも6~8個は減らすことができるだろう。

私の計画では、人気のあるユースケースをカバーするため、カスタム・コード・スニペットをさらに追加していく予定です。ご提案がありましたら、こちらのフォームにご記入の上、お知らせください。

WordPress開発者/フリーランサーの方で、コードスニペットを提供したい方は、上記のフォームを使用してスニペットをお送りください。

将来を見据えたサイトのカスタマイズとコード管理

ほとんどのWordPressカスタマイズチュートリアルでは、テーマのfunctions.phpファイルにコードスニペットを追加するよう求められます。この古い方法は、コードスニペットの管理を面倒にするだけでなく、テーマの更新を妨げます。

テーマを更新したり、他のテーマに変更したりすると、functions.phpファイルに追加したカスタマイザー関数はすべて失われます。

WPCodeは、WordPressダッシュボードから直接他のコードスニペットと一緒にヘッダーとフッタースクリプトを挿入する簡単な方法を提供することにより、これを解決します。これらのコードスニペットは、実際にはテーマのfunctions.phpファイルにあるかのように実行されますが、私たちはあなたのカスタマイザーが将来的に保証されるようにします。

Create New Custom Snippet in WordPress

重要なサイトのカスタマイザーを失うことなく、テーマの更新や別のテーマへの切り替えを安全に行うことができます。

テーマのfunctions.phpファイルにカスタム・コード・スニペットを追加することのもう一つの問題は、小さなミスでもサイトを壊してアクセスできなくしてしまうことだった。

そこで、私たちはスマートコードスニペット検証を作成しました。これにより、コードスニペットやヘッダー・フッタースクリプトを追加する際に、よくあるコードエラーを防ぎ、サイトを壊すことがないようにします。

ヘッダーやフッタースクリプト、その他のカスタムコードスニペットをすべて個別画面で管理できます。タグを使ってコードスニペットを整理したり、各コードスニペットにリマインダーのメモを追加することも簡単です。

WPCode - WordPress Snippets Organized by Tags

ビルトインWordPressコードジェネレータ

増え続けるコードスニペットライブラリの他に、WordPress コードジェネレータもあり、最新の WordPress コーディング標準や API を使用して、すぐに使えるカスタムコードを素早く作成することができます。

WPCode Generators for WordPress

管理者UIを備えたカスタマイザー・コードジェネレータの例としては、以下のようなものがあります:

  • カスタム投稿タイプジェネレータ – 投稿タイプのカスタムコードスニペットを作成します。
  • Custom Taxonomy Generator – タクソノミー用のカスタムコードスニペットを取得します。
  • WP Query Generator – 投稿を読み込むためのWP_Queryのカスタムコードスニペットを取得します。
  • Custom Sidebar Generator – カスタムサイドバーやウィジェット対応エリアを登録するためのカスタムコードスニペットを作成します。
  • Custom Widget Generator – カスタムウィジェットを登録するためのカスタムコードスニペット。
  • Navigation Menu Generator – テーマに新しいナビゲーションメニューの場所を登録するためのカスタムコードスニペット。

上記以外にも、cronジョブのスケジュール、スクリプトとスタイルシートの登録、カスタム投稿ステータスの追加などのためのコードスニペットジェネレータがあります。

以前は、初心者や中級ユーザーはWordPressプラグインを使って、カスタム投稿タイプやタクソノミーなどを管理者UIで作成していた。問題なのは、これらのプラグインは一度しか使わないプラグインであり、バックグラウンドではカスタマイザーコードを生成しているだけだということです。

WPCodeフリージェネレータを使えば、プラグインを使わずに、管理者用UIで必要なカスタム機能を追加することができます。

これは、新規WordPress開発者や、クライアントのためにサイトを構築しているウェブ専門家にとって、大きな時間節約になるだろう。

コード・スニペットの条件ロジック+自動挿入の優先順位

WPCodeの私の目標は、簡単で強力なWordPressコードスニペットプラグインを作成することでした。

そのため、グローバルなヘッダーとフッターのスクリプトとは別に、コードスニペット用の条件ロジックのような高度な機能を追加し、簡単にできるようにしました。

WordPressの条件付きロジックのクエリーを学ぶ代わりに、ビジュアル条件付きロジックを使用して、特定のスニペットがロードされるタイミングを決定することができます。

WPCode Smart Conditional Logic

WPCode条件ロジックの使用例:

  • ログイン中のユーザーのみにコードスニペットをロードする
  • 特定のユーザー権限グループに対してPHPコードスニペットをロードする
  • 特定のページURLにのみPHPコードスニペットをロードする
  • 特定のページにヘッダーとフッターのピクセルスクリプトを挿入する
  • ページのタイプに応じたコードスニペットの表示
  • 特定の投稿タイプでのみコードスニペットを実行する
  • 参照元に基づいてヘッダーとフッターのコードスニペットを読み込む
  • などなど

また、自動コード挿入とショートコードを使った手動出力の両方を追加しました。これにより、カスタマイザーショートコードを使用して機能を追加したり、単純に必要なエリアに特定の機能を自動的に追加することができます。

WPCode Auto Insert PHP Code

自動挿入機能では、コードスニペットをあらゆる場所で実行したり、以下のようなカスタマイザーオプションを設定することができます:

  • フロントエンドでのみコードスニペットを実行する
  • WordPress管理エリアでのみコードスニペットを実行する
  • ヘッダーとフッターのスクリプトをサイト全体に追加する
  • 投稿コンテンツの前後にPHPコードスニペットを挿入する
  • 特定の段落の前後にコードスニペットを挿入する
  • 特定のアーカイブページにコードスニペットを挿入する

また、コードスニペットの優先順位を視覚的に設定できるようになったので、カスタム関数の順番を決めて、コードの衝突を避けることができます。

Add code description, tags, and priority in WPCode

ユースケースとプラグインを置き換える例とは?

WPCodeは、機能を失うことなく、他の何十ものプラグインを取り除くのに役立つプラグインです。

主な使用例を紹介しよう:

  • ヘッダーとフッターにスクリプトを挿入する
  • ヘッダーとフッターにGoogle アナリティクスのトラッキングコードを挿入する
  • テーマのfunctions.phpファイルを変更することなく、PHPコードスニペットまたはJavaScriptコードスニペットを挿入します。
  • WordPress のヘッダーとフッターに Facebook Pixels コード、Google Conversion Pixels コード、その他の広告コンバージョンピクセルスクリプトを条件付きロジックで挿入する
  • Google AdSense広告コード、Amazonネイティブコンテクスト広告コード、その他のメディア広告コードの挿入
  • カスタムJavaScript、CSS、HTMLコードの挿入
  • ソーシャルメディア、Google Search Console、その他のドメイン検証用のサイト検証メタ情報をサイトのヘッダーとフッターに挿入
  • 再利用可能なカスタムコンテンツブロックの挿入
  • 特定の段落の後のコンテンツに広告コードを挿入する。
  • 条件ロジックに基づくカスタムコードスニペットの表示/非表示
  • プラグインを追加することなく、XML-RPCの無効化、Rest APIの無効化、コメントの無効化、SVGファイルのアップロードの許可、Gutenbergの無効化、クラシックエディターの有効化が可能。

私たちの現在の機能と既製のコードスニペットライブラリを使用するだけで、次のようないくつかの人気のあるプラグインを置き換えることができます:

WPCodeには、既製のコードスニペットライブラリが付属しており、以下のような人気のあるプラグインを置き換えることができます:

  • コメントプラグインの無効化
  • XML-RPC プラグインの無効化
  • Rest API プラグインの無効化
  • Gutenberg プラグインの無効化
  • クラシックエディタープラグイン
  • SVG ファイルアップロードプラグインを許可する
  • RSSフィードプラグインの無効化
  • 検索プラグインの無効化
  • 自動更新プラグインの無効化
  • 管理バー無効化プラグイン
  • ウィジェット・ブロック・プラグインの無効化
  • クラシック・ウィジェット・プラグイン
  • WordPressのバージョン番号を削除するプラグイン
  • Facebook Pixel プラグイン
  • Google Adsenseのプラグイン
  • カスタム投稿タイプUIプラグイン
  • その他のWordPressジェネレータプラグイン

一般的なサイトでは、このような単発のプラグインをインストールすることが多いため、平均して6~8個の既存のプラグインを簡単に置き換えることができると思います。

プラグインを削除して管理エリアをすっきりさせ、サイト管理をシンプルにすることができます。

WPCodeの次に来るものは?

Insert Headers and Footersプラグインは100万人以上のユーザーを抱えていたため、これらの新機能をすべて無料で手に入れることができたのは、誰にとっても驚きだった。

これまでのところ、コミュニティーの反応には非常に満足している。みんなが新機能を気に入ってくれているからね。

私たちは、このプラグインをさらに強力なものにするために、エキサイティングなロードマップを用意しています。私たちが取り組んでいることの一部をご紹介します:

  • WordPressのエキスパートが吟味したコードスニペットライブラリの豊富なリスト
  • カスタムスニペットをクラウドに保存 – プラグイン内でパーソナライズされたスニペットライブラリを構築できるので、複数のサイトを作成・管理している方に最適です。
  • などなど

私たちはここで本当に特別なものを作っています。このプラグインをもっと皆様のお役に立てるようにするためのアイデアがありましたら、ぜひお寄せください。

今後ともWPBeginnerをよろしくお願いいたします。

本当にありがとう、

Syed Balkhi(サイード・バルキー
WPBeginner創設者

追伸:あなたのWordPressビジネスを買収または投資してほしいですか?WPBeginner成長ファンドについてさらに詳しく。

情報開示 私たちのコンテンツは読者支援型です。これは、あなたが私たちのリンクの一部をクリックした場合、私たちはコミッションを得ることができることを意味します。 WPBeginnerの資金源 をご覧ください。3$編集プロセスをご覧ください。

Avatar

Syed Balkhi is the founder of WPBeginner and Awesome Motive Inc. He started using WordPress in 2006 and has over 16 years of experience building WordPress websites, WordPress plugins, and custom WordPress themes. His WordPress plugins and software apps are used by over 25 million websites today. Syed was recognized as the top 100 entrepreneur under the age of 30 by the United Nations, and his work is featured in top publications like Entrepreneur, Forbes, Inc, Business Insider, The Guardian, Wired Magazine, and more.

究極のWordPressツールキット

ツールキットへの無料アクセス - すべてのプロフェッショナルが持つべきWordPress関連製品とリソースのコレクション!

Reader Interactions

25件のコメント返信を残す

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Moinuddin Waheed says

    I have used insert header and footer lately and I can testify that it feels intuitive when you can have your desired functionality without adding new plugin for additional functionality.
    now when it has become wpcode and comes with lots of features, I am sure it will help improve the website speed and optimization.
    It will also eliminate the need to add several plugins for small small issues. Thanks a ton wpbeginner.

  3. László says

    If I delete a manual code ( ie. FB Pixel code) from the header in WPCode editor would it be removed from all pages’ headers? In all languages?

    • WPBeginner Support says

      If you remove code from the plugin then it would be removed from your site where the plugin added it. If you have caching, don’t forget to clear it to ensure it’s removed! :)

      管理者

  4. Joe C says

    Thanks – always hated putting stuff in functions.php because it gets changed on updates (I never use child themes), but I hate even more 1-task plugins :)

    We had a single php file code snipets and only mod to functions.php was to “include” our snippet file. Simplified re-editing functions.php after an update.

    This plugin should eliminate that process all together

    This is probably the best idea and plugin you guys have come up with yet. I suspect we will integrate it into all 300-odd WP sites we own and/or manage.

    Thanks!

  5. Joe C says

    How would code, such as your code – intended for the functions.php – that would turn of WP “feeds” (recent email you sent out) fit in this plugin?

    Joe C.

    • WPBeginner Support says

      You would use the run everywhere option for the snippet for it to load everywhere :)

      管理者

  6. Debbie says

    I’m so excited about this — and it’s potential! Anything that retains Classic Editor is a huge plus in my world. It’s so much easier to tweak code than try to remove the underline from a space, for example. :) And there are soooo many single use plugins that you need now. It will be good to streamline that aspect…. Thanks, y’all!

  7. Ian says

    Sounds like this will be very nice! Any plans to make it paid and/or have a paid/subscription based premium option in the future?

    • Editorial Staff says

      Hey Ian,

      Right now our main focus is making the best free code snippets plugin that offers our users a tool that I wish I had with ready-made snippets that our teams frequently use.

      In the future, we will add premium features for developer audience to improve their workflow, but the core tool will always remain free and will get even more powerful in our next update :D

      管理者

  8. Sue Surdam says

    Love this concept! Experimenting right now with a local site with all the options. Hoping you are planning tutorials for Custom Post types and other options.

  9. Nate Ruske says

    Hi,

    I wanted to let you know the pain this conversion from Insert Headers and Footers to WP CODE caused me this morning.

    I use Securi, and the very first thing I see this morning is a security alert with the message WP CODE turn off all comments – and another – Display a message after the 1st paragraph of posts

    In addition to the update, it has also messed up site design and completely removed my search bars throughout the site even though the two code snippets are inactive.

    Currently working with securi to work out what the plugin is doing so we can get the site back to what it was before the update.

    All the best with WPCODE

    • Editorial Staff says

      Thank you for leaving a comment Nate.

      The Sucuri alert is a false flag because all it’s saying is that 2 new “Post Drafts” were created (because that’s how code snippets are stored). But those snippets are not live, and they should NOT cause any front-end conflict. Over 26% of all sites (~400k sites) have updated to the latest version without any notable issues like this.

      I’m going to have my team reach out to you using the email you left here in the comment, so we can work closely with you to resolve this.

      -Syed

      管理者

  10. Karim Twin says

    What an amazing plugin!

    I didn’t know that’s some WordPress tool like that.

    As a WordPress user, I’ve struggling to minimize the use of many plugins.

    Every WP customer wants to use the best WordPress plugins for his or her website. But the odds are many plugins means low site speed and more errors chances. That’s why finding a tool WPcode can help solve the problem in a better way.

    I’ll start using it definitely .

    Thanks for adding value to WordPress.

返信を残す

コメントありがとうございます。すべてのコメントは私たちのコメントポリシーに従ってモデレートされ、あなたのメールアドレスが公開されることはありませんのでご留意ください。名前欄にキーワードを使用しないでください。個人的で有意義な会話をしましょう。