本文整理汇总了PHP中JS::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP JS::getInstance方法的具体用法?PHP JS::getInstance怎么用?PHP JS::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JS
的用法示例。
在下文中一共展示了JS::getInstance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Checks environment and build defaults
*
*/
protected function __construct()
{
// Instantiate Feature Manager
FeatureManager::getInstance();
// Instantiate Context Manager
ContextManager::getInstance();
// Instantiate URLs Manager
UrlManager::getInstance();
// Instantiate Paths Manager & set Bebop root directory
PathManager::getInstance()->set('bebop', __DIR__);
// Set default Media Mvc Model modifications on the Bebop HTTP API
Media::onContext('api', function ($media) {
$media->cacheAllImageSizes();
});
// Set default views directory
View::setViewsDir(PathManager::getInstance()->get('theme', 'views'));
// Instantiate CSS Manager
CSS::getInstance();
// Instantiate JS Manager
JS::getInstance();
// Instantiate UI
UI::getInstance();
// Instantiate Api
self::Api();
// Instantiate Config
Config::getInstance();
// Shortcode support for in editor use
add_shortcode('Bebop', array($this, '__bebopShortcodes'));
}
示例2: onInit
/**
* Register stuff on the init hook
*
* @return void
*/
public function onInit()
{
// Get configuration object
$config = Config::getInstance();
// Get remote configuration
if ($remote_config = $this->__getRemoteConfiguration()) {
foreach ($remote_config as $key => $value) {
$config->set($key, $value);
}
}
// Enable Intercom widget if we have the desired conditions
if ($config->get('app_id') && (is_user_logged_in() || $config->get('allow_visitors'))) {
// Get logged in user data
global $current_user;
get_currentuserinfo();
$script_id = 'bebop-intercom';
$script_name = $config->get('dev_env_enabled') ? 'bebop-intercom.js' : 'bebop-intercom.min.js';
$script_path = $config->get('plugin_base_url') . 'assets/js/' . $script_name;
$localization_name = 'intercomSettings';
$localization_value = ['app_id' => $config->get('app_id'), 'created_at' => date('U')];
// Add user WordPress data, if enabled
if (!$config->get('dont_send_user_data')) {
$localization_value['user_id'] = $current_user ? (getenv('APP_NAME') ?: $_SERVER['HTTP_HOST']) . '-' . $current_user->ID : null;
$localization_value['email'] = $current_user ? $current_user->user_email : null;
$localization_value['name'] = $current_user ? $current_user->display_name : null;
}
// Register, localize and enqueue plugin script on both front and back-end
$js = JS::getInstance();
$js->getHook('back')->register($script_id, $script_path)->localize($script_id, $localization_name, $localization_value)->enqueue($script_id);
// Optionally display Intercom widget on front-end
if ($config->get('display_on_front_end')) {
$js->getHook('front')->register($script_id, $script_path)->localize($script_id, $localization_name, $localization_value)->enqueue($script_id);
}
}
}