Recently the question (How to add add custom functions to a theme) was posed in最近では、質問(カスタム機能を追加する方法を追加してテーマ)が提起さ WordPress Support Forum WordPressのサポートフォーラム .です。 Personally I faced the same question when re-designing個人的に私と同じ問題に直面するときに再設計 this siteこのサイトについて .です。 The following is a discussion of the option with the pros and cons.は、次のオプションは、議論の長所と短所です。

There are two solutions.には2つのソリューションです。
The first is to create a plugin which goes with the theme.の最初のプラグインを作成するには、これが当てはまるのテーマです。 However the theme, when invoking functions defined in the plugin should check first for the availability of the function.しかし、テーマは、差込式で定義された関数を呼び出す際に最初は、空室状況を確認すると、関数です。 It should also provide a fallback option if the plugin is not available or has not been activated.フォールバックオプションを提供することも差込式ではないがご利用の場合、または活性化されていない。

 if(function_exists('your_function_name')) {     // Invoke your function: your_function_name()...もし( function_exists ( ' your_function_name ( ' ) ) ( / /起動して機能: your_function_name ( ()... else {     // Execute fallback option }他( / /実行フォールバックオプション) 

The advantages are:の利点は:

  • The plugin can be independently managed.差込式に個別に管理することです。
  • The plugin can be reused for other purposes.差込式は、他の目的のために再利用します。

The disadvantages are:の短所は:

  • It requires another additional step for the theme user to remember.別の追加が必要な手順をテーマにユーザーを覚えています。
  • It slightly complicates development and testing.やや複雑、開発およびテストのことです。

The second solution to this problem would be to incorporate the functionaility in a php file (as usual) which resides in the theme directory. 2番目のこの問題の解決策を組み込むことをfunctionailityをPHPファイルに保存(いつもどおり)に居住してテーマディレクトリにコピーします。 This file is included in header.php like:このファイルはheader.phpに含まれるように:
include (’your_php_file.php’); 含まれて( ' your_php_file.php ' ) ;

Yes you may also require it for simplicity like:はいすることも簡単にするために必要なことのよう:
require (’your_php_file.php’); 必要( ' your_php_file.php ' ) ;

The advantage to this approach is simplicity of usage and deployment by end-users.このアプローチの利点を利用方法は、シンプルなエンドユーザと展開されています。 It also simplifies development.また、開発を簡素化します。

If the user later decides to switch to a different theme and yet wants to retain the functionality, he would have to re-purpose the custom code into a plugin.ユーザーへの場合、決定に切り替えるには、別のテーマと機能を保持するにはまだありません望ん、彼は、目的のために、カスタムコードを再するプラグインです。

In essence the reusability of the custom functionality determines the ideal location of the custom code.本質的に、カスタム機能の再利用には理想の場所を決定しているカスタムコードです。