本文整理汇总了PHP中My_Controller::init方法的典型用法代码示例。如果您正苦于以下问题:PHP My_Controller::init方法的具体用法?PHP My_Controller::init怎么用?PHP My_Controller::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类My_Controller
的用法示例。
在下文中一共展示了My_Controller::init方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: common
* - Each method in the class that matches a template name will be loaded for that template
* - Ex: `single()` will be loaded for single.php. `common()` is called for all templates
* - Within each method, use `$this->add( 'name', $data )` for each variable you'd like to pass to a template
* - Use `tpl_var('name')` or `get_tpl_var('name')` to call the data from within each template file
*
* @package WordPress
* @subpackage Template_Controller
* @uses Template_Controller Parent class for controller
*/
class My_Controller extends Template_Controller
{
public function common()
{
$this->add('hi', 'I load for every template on the site.');
}
public function page()
{
$this->add('yo', 'I load for page.php and custom page templates.');
}
public function single()
{
$this->add('whazup', 'I load for single.php, for all post types (any template that starts with "single-").');
}
public function single_post()
{
$this->add('dude', 'I load only for built in single post templates (aka single-post.php)');
}
}
// Initialize controller
My_Controller::init();