6

プラグインをインストールしてアクティブ化せずに Option Tree フレームワークを Wordpress テーマに統合したいのですが、どうすればよいですか?

4

4 に答える 4

8

バージョン 2.0 以降、プラグイン開発者は functions.php で使用できる多くのフィルターを含めました。これらにはTheme Mode、および ot-loader.php 状態内のコメントが含まれます。

   * For developers: Theme mode.
   *
   * Run a filter and set to true to enable OptionTree theme mode.
   * You must have this files parent directory inside of 
   * your themes root directory. As well, you must include 
   * a reference to this file in your themes functions.php.
   * @since     2.0
   */
  define( 'OT_THEME_MODE', apply_filters( 'ot_theme_mode', false ) );

オプション ツリーをプラグインとしてではなくテーマで有効にするには、すべてのプラグイン ファイルをテーマのルート ディレクトリに含めます。

/wp-content/themes/my-awesome-theme/options-tree

このフィルターをfunctions.php実行してから、ot-loader.php ファイルを含めます。これを以下に示しました。また、show_pages フィルターも示しました。

add_filter( 'ot_theme_mode', '__return_true' );
add_filter( 'ot_show_pages', '__return_true' );

require_once ('option-tree/ot-loader.php');

show_pages フィルターは便利です。テーマとオプションを設定した後、それを false に設定すると、クライアントにはメインのオプション ツリー管理メニューが表示されず、「いじくり」やゴミ箱を開始できないためです。すべての。あなたはそれを次のように変更します。

add_filter( 'ot_show_pages', '__return_false' );
于 2012-12-12T11:26:59.433 に答える