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. 두 번째 해결 방법이 문제가 될 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. 본질적으로 재사 용할의 사용자 정의 기능에 이상적인 위치를 사용자 정의 코드를 결정합니다.