本文整理汇总了PHP中PMXI_Plugin::buffer方法的典型用法代码示例。如果您正苦于以下问题:PHP PMXI_Plugin::buffer方法的具体用法?PHP PMXI_Plugin::buffer怎么用?PHP PMXI_Plugin::buffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PMXI_Plugin
的用法示例。
在下文中一共展示了PMXI_Plugin::buffer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __adminInit
/**
* pre-dispatching logic for admin page controllers
*/
public function __adminInit()
{
// create history folder
$uploads = wp_upload_dir();
$wpallimportDirs = array(WP_ALL_IMPORT_UPLOADS_BASE_DIRECTORY, self::LOGS_DIRECTORY, self::FILES_DIRECTORY, self::TEMP_DIRECTORY, self::UPLOADS_DIRECTORY, self::HISTORY_DIRECTORY);
foreach ($wpallimportDirs as $destination) {
$dir = $uploads['basedir'] . DIRECTORY_SEPARATOR . $destination;
if (!is_dir($dir)) {
wp_mkdir_p($dir);
}
if (!@file_exists($dir . DIRECTORY_SEPARATOR . 'index.php')) {
@touch($dir . DIRECTORY_SEPARATOR . 'index.php');
}
}
self::$session = new PMXI_Handler();
$input = new PMXI_Input();
$page = strtolower($input->getpost('page', ''));
if (preg_match('%^' . preg_quote(str_replace('_', '-', self::PREFIX), '%') . '([\\w-]+)$%', $page)) {
//$this->adminDispatcher($page, strtolower($input->getpost('action', 'index')));
$action = strtolower($input->getpost('action', 'index'));
// capitalize prefix and first letters of class name parts
if (function_exists('preg_replace_callback')) {
$controllerName = preg_replace_callback('%(^' . preg_quote(self::PREFIX, '%') . '|_).%', array($this, "replace_callback"), str_replace('-', '_', $page));
} else {
$controllerName = preg_replace('%(^' . preg_quote(self::PREFIX, '%') . '|_).%e', 'strtoupper("$0")', str_replace('-', '_', $page));
}
$actionName = str_replace('-', '_', $action);
if (method_exists($controllerName, $actionName)) {
@ini_set("max_input_time", PMXI_Plugin::getInstance()->getOption('max_input_time'));
@ini_set("max_execution_time", PMXI_Plugin::getInstance()->getOption('max_execution_time'));
if (!get_current_user_id() or !current_user_can('manage_options')) {
// This nonce is not valid.
die('Security check');
} else {
$this->_admin_current_screen = (object) array('id' => $controllerName, 'base' => $controllerName, 'action' => $actionName, 'is_ajax' => strpos($_SERVER["HTTP_ACCEPT"], 'json') !== false, 'is_network' => is_network_admin(), 'is_user' => is_user_admin());
add_filter('current_screen', array($this, 'getAdminCurrentScreen'));
add_filter('admin_body_class', create_function('', 'return "' . 'wpallimport-plugin";'));
$controller = new $controllerName();
if (!$controller instanceof PMXI_Controller_Admin) {
throw new Exception("Administration page `{$page}` matches to a wrong controller type.");
}
if ($this->_admin_current_screen->is_ajax) {
// ajax request
$controller->{$action}();
do_action('pmxi_action_after');
die;
// stop processing since we want to output only what controller is randered, nothing in addition
} elseif (!$controller->isInline) {
@ob_start();
$controller->{$action}();
self::$buffer = @ob_get_clean();
} else {
self::$buffer_callback = array($controller, $action);
}
}
} else {
// redirect to dashboard if requested page and/or action don't exist
wp_redirect(admin_url());
die;
}
}
}
示例2: __adminInit
/**
* pre-dispatching logic for admin page controllers
*/
public function __adminInit()
{
self::$session = new PMXI_Handler();
$input = new PMXI_Input();
$page = strtolower($input->getpost('page', ''));
if (preg_match('%^' . preg_quote(str_replace('_', '-', self::PREFIX), '%') . '([\\w-]+)$%', $page)) {
//$this->adminDispatcher($page, strtolower($input->getpost('action', 'index')));
$action = strtolower($input->getpost('action', 'index'));
// capitalize prefix and first letters of class name parts
if (function_exists('preg_replace_callback')) {
$controllerName = preg_replace_callback('%(^' . preg_quote(self::PREFIX, '%') . '|_).%', array($this, "replace_callback"), str_replace('-', '_', $page));
} else {
$controllerName = preg_replace('%(^' . preg_quote(self::PREFIX, '%') . '|_).%e', 'strtoupper("$0")', str_replace('-', '_', $page));
}
$actionName = str_replace('-', '_', $action);
if (method_exists($controllerName, $actionName)) {
$this->_admin_current_screen = (object) array('id' => $controllerName, 'base' => $controllerName, 'action' => $actionName, 'is_ajax' => strpos($_SERVER["HTTP_ACCEPT"], 'json') !== false, 'is_network' => is_network_admin(), 'is_user' => is_user_admin());
add_filter('current_screen', array($this, 'getAdminCurrentScreen'));
add_filter('admin_body_class', create_function('', 'return "' . 'wpallimport-plugin";'));
$controller = new $controllerName();
if (!$controller instanceof PMXI_Controller_Admin) {
throw new Exception("Administration page `{$page}` matches to a wrong controller type.");
}
if ($this->_admin_current_screen->is_ajax) {
// ajax request
$controller->{$action}();
do_action('pmxi_action_after');
die;
// stop processing since we want to output only what controller is randered, nothing in addition
} elseif (!$controller->isInline) {
@ob_start();
$controller->{$action}();
self::$buffer = @ob_get_clean();
} else {
self::$buffer_callback = array($controller, $action);
}
} else {
// redirect to dashboard if requested page and/or action don't exist
wp_redirect(admin_url());
die;
}
}
}