本文整理汇总了PHP中Jetpack::init方法的典型用法代码示例。如果您正苦于以下问题:PHP Jetpack::init方法的具体用法?PHP Jetpack::init怎么用?PHP Jetpack::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jetpack
的用法示例。
在下文中一共展示了Jetpack::init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
function __construct()
{
parent::__construct();
Jetpack::init();
// In WP 4.2 WP_List_Table will be sanitizing which values are __set()
global $wp_version;
if (version_compare($wp_version, '4.2-z', '>=') && $this->compat_fields && is_array($this->compat_fields)) {
array_push($this->compat_fields, 'all_items');
}
$this->items = $this->all_items = Jetpack_Admin::init()->get_modules();
$this->items = $this->filter_displayed_table_items($this->items);
/**
* Filters the list of modules available to be displayed in the Jetpack Settings screen.
*
* @since 3.0.0
*
* @param array $this->items Array of Jetpack modules.
*/
$this->items = apply_filters('jetpack_modules_list_table_items', $this->items);
$this->_column_headers = array($this->get_columns(), array(), array(), 'name');
$modal_info = isset($_GET['info']) ? $_GET['info'] : false;
wp_register_script('models.jetpack-modules', plugins_url('_inc/jetpack-modules.models.js', JETPACK__PLUGIN_FILE), array('backbone', 'underscore'), JETPACK__VERSION);
wp_register_script('views.jetpack-modules', plugins_url('_inc/jetpack-modules.views.js', JETPACK__PLUGIN_FILE), array('backbone', 'underscore', 'wp-util'), JETPACK__VERSION);
wp_register_script('jetpack-modules-list-table', plugins_url('_inc/jetpack-modules.js', JETPACK__PLUGIN_FILE), array('views.jetpack-modules', 'models.jetpack-modules', 'jquery'), JETPACK__VERSION, true);
wp_localize_script('jetpack-modules-list-table', 'jetpackModulesData', array('modules' => Jetpack::get_translated_modules($this->all_items), 'i18n' => array('search_placeholder' => __('Search Modules…', 'jetpack')), 'modalinfo' => $this->module_info_check($modal_info, $this->all_items), 'nonces' => array('bulk' => wp_create_nonce('bulk-jetpack_page_jetpack_modules')), 'coreIconAvailable' => Jetpack::jetpack_site_icon_available_in_core()));
wp_enqueue_script('jetpack-modules-list-table');
/**
* Filters the js_templates callback value.
*
* @since 3.6.0
*
* @param array array( $this, 'js_templates' ) js_templates callback.
*/
add_action('admin_footer', apply_filters('jetpack_modules_list_table_js_template_callback', array($this, 'js_templates')), 9);
}
示例2: __construct
function __construct()
{
$this->jetpack = Jetpack::init();
// Don't use COOKIEHASH as it could be shared across installs && is non-unique in multisite.
// @see: https://twitter.com/nacin/status/378246957451333632
self::$hash = md5(get_option('siteurl'));
add_filter('jetpack_xmlrpc_methods', array($this, 'xmlrpc_methods'));
// @todo remove sync from subscriptions and move elsewhere...
// Add Configuration Page
add_action('admin_init', array($this, 'configure'));
// Set up the subscription widget.
add_action('widgets_init', array($this, 'widget_init'));
// Catch subscription widget submits
if (isset($_REQUEST['jetpack_subscriptions_widget'])) {
add_action('template_redirect', array($this, 'widget_submit'));
}
// Set up the comment subscription checkboxes
add_action('comment_form', array($this, 'comment_subscribe_init'));
// Catch comment posts and check for subscriptions.
add_action('comment_post', array($this, 'comment_subscribe_submit'), 50, 2);
// Adds post meta checkbox in the post submit metabox
if (apply_filters('jetpack_allow_per_post_subscriptions', false)) {
add_action('post_submitbox_misc_actions', array($this, 'subscription_post_page_metabox'));
}
add_action('transition_post_status', array($this, 'maybe_send_subscription_email'), 10, 3);
}
示例3: cron_exec
/**
* Method that gets executed on the wp-cron call
*
* @since 2.3.3
* @global string $wp_version
*/
public function cron_exec()
{
$jetpack = Jetpack::init();
/*
* This should run daily. Figuring in for variances in
* WP_CRON, don't let it run more than every 23 hours at most.
*
* i.e. if it ran less than 23 hours ago, fail out.
*/
$last = (int) Jetpack_Options::get_option('last_heartbeat');
if ($last && $last + DAY_IN_SECONDS - HOUR_IN_SECONDS > time()) {
return;
}
/*
* Check for an identity crisis
*
* If one exists:
* - Bump stat for ID crisis
* - Email site admin about potential ID crisis
*/
// Coming Soon!
foreach (self::generate_stats_array('v2-') as $key => $value) {
$jetpack->stat($key, $value);
}
Jetpack_Options::update_option('last_heartbeat', time());
$jetpack->do_stats('server_side');
}
示例4: photon_msg
function photon_msg()
{
if (current_user_can('jetpack_manage_modules')) {
?>
<div class="jp-jitm">
<a href="#" data-module="photon" class="dismiss"><span class="genericon genericon-close"></span></a>
<div class="jp-emblem">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0" y="0" viewBox="0 0 172.9 172.9" enable-background="new 0 0 172.9 172.9" xml:space="preserve">
<path d="M86.4 0C38.7 0 0 38.7 0 86.4c0 47.7 38.7 86.4 86.4 86.4s86.4-38.7 86.4-86.4C172.9 38.7 134.2 0 86.4 0zM83.1 106.6l-27.1-6.9C49 98 45.7 90.1 49.3 84l33.8-58.5V106.6zM124.9 88.9l-33.8 58.5V66.3l27.1 6.9C125.1 74.9 128.4 82.8 124.9 88.9z"/>
</svg>
</div>
<p>
<?php
_e('Deliver super-fast images to your visitors that are automatically optimized for any device.', 'jetpack');
?>
</p>
<p>
<a href="#" data-module="photon" class="activate button button-jetpack">
<?php
esc_html_e('Activate Photon', 'jetpack');
?>
</a>
</p>
</div>
<?php
//jitm is being viewed, track it
$jetpack = Jetpack::init();
$jetpack->stat('jitm', 'photon-viewed');
$jetpack->do_stats('server_side');
}
}
示例5: admin_page_warning
function admin_page_warning()
{
$jetpack = Jetpack::init();
$blog_name = get_bloginfo('blogname');
if (empty($blog_name)) {
$blog_name = home_url('/');
}
?>
<div id="message" class="updated jetpack-message jp-connect">
<div class="jetpack-wrap-container">
<div class="jetpack-text-container">
<p><?php
printf(esc_html(wptexturize(__("To use Publicize, you'll need to link your %s account to your WordPress.com account using the link below.", 'jetpack'))), '<strong>' . esc_html($blog_name) . '</strong>');
?>
</p>
<p><?php
echo esc_html(wptexturize(__("If you don't have a WordPress.com account yet, you can sign up for free in just a few seconds.", 'jetpack')));
?>
</p>
</div>
<div class="jetpack-install-container">
<p class="submit"><a href="<?php
echo $jetpack->build_connect_url(false, menu_page_url('sharing', false));
?>
" class="button-connector" id="wpcom-connect"><?php
esc_html_e('Link account with WordPress.com', 'jetpack');
?>
</a></p>
</div>
</div>
</div>
<?php
}
示例6: __construct
private function __construct()
{
$this->jetpack = Jetpack::init();
jetpack_require_lib('admin-pages/class.jetpack-react-page');
$this->jetpack_react = new Jetpack_React_Page();
// TODO: reactify
require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-dashboard.php';
$this->sync_dashboard = new Jetpack_Sync_Dashboard();
$this->sync_dashboard->init();
// jetpack_require_lib( 'admin-pages/class.jetpack-landing-page' );
// $this->landing_page = new Jetpack_Landing_Page;
//
// jetpack_require_lib( 'admin-pages/class.jetpack-settings-page' );
// $this->settings_page = new Jetpack_Settings_Page;
//
// jetpack_require_lib( 'admin-pages/class.jetpack-my-jetpack-page' );
// $this->my_jetpack_page = new Jetpack_My_Jetpack_Page;
// if ( isset( $_POST['jetpack-set-master-user'] ) ) {
// add_action( 'init', array( $this->my_jetpack_page, 'jetpack_my_jetpack_change_user' ) );
// }
// Add hooks for admin menus
// add_action( 'jetpack_admin_menu', array( $this->jetpack_react, 'add_actions' ) );
add_action('admin_menu', array($this->jetpack_react, 'add_actions'), 998);
add_action('jetpack_admin_menu', array($this, 'admin_menu_debugger'));
add_action('jetpack_admin_menu', array($this->sync_dashboard, 'add_actions'));
// Add redirect to current page for activation/deactivation of modules
add_action('jetpack_pre_activate_module', array($this, 'fix_redirect'), 10, 2);
add_action('jetpack_pre_deactivate_module', array($this, 'fix_redirect'));
// Add module bulk actions handler
add_action('jetpack_unrecognized_action', array($this, 'handle_unrecognized_action'));
}
示例7: result
protected function result()
{
Jetpack::init();
do_action('jetpack_sync_all_registered_options');
$result['scheduled'] = true;
return $result;
}
示例8: Jetpack_Subscriptions
function Jetpack_Subscriptions()
{
$this->jetpack = Jetpack::init();
add_filter('jetpack_xmlrpc_methods', array($this, 'xmlrpc_methods'));
// @todo remove sync from subscriptions and move elsewhere...
// Add Configuration Page
add_action('admin_init', array($this, 'configure'));
// Handle Posts
add_action('transition_post_status', array($this, 'transition_post_status'), 10, 3);
add_action('trashed_post', array($this, 'delete_post'));
add_action('delete_post', array($this, 'delete_post'));
// Handle Taxonomy
add_action('created_term', array($this, 'save_taxonomy'), 10, 3);
add_action('edited_term', array($this, 'save_taxonomy'), 10, 3);
add_action('delete_term', array($this, 'delete_taxonomy'), 10, 3);
// Handle Comments
add_action('wp_insert_comment', array($this, 'save_comment'), 10, 2);
add_action('transition_comment_status', array($this, 'transition_comment_status'), 10, 3);
add_action('trashed_comment', array($this, 'delete_comment'));
add_action('delete_comment', array($this, 'delete_comment'));
// Set up the subscription widget.
add_action('widgets_init', array($this, 'widget_init'));
// Catch subscription widget submits
if (isset($_REQUEST['jetpack_subscriptions_widget'])) {
add_action('template_redirect', array($this, 'widget_submit'));
}
// Set up the comment subscription checkboxes
add_action('comment_form', array($this, 'comment_subscribe_init'));
// Catch comment posts and check for subscriptions.
add_action('comment_post', array($this, 'comment_subscribe_submit'), 50, 2);
}
示例9: result
protected function result()
{
Jetpack::init();
/** This action is documented in class.jetpack.php */
do_action('jetpack_sync_all_registered_options');
$result['scheduled'] = true;
return $result;
}
示例10: jetpack_json_api_toggle
/**
* Module Name: JSON API
* Module Description: Allow applications to securely access your content through the cloud.
* Sort Order: 100
* First Introduced: 1.9
* Requires Connection: Yes
* Auto Activate: Public
* Module Tags: Writing, Developers
*/
function jetpack_json_api_toggle()
{
$jetpack = Jetpack::init();
$jetpack->sync->register('noop');
if (false !== strpos(current_filter(), 'jetpack_activate_module_')) {
Jetpack::check_privacy(__FILE__);
}
}
示例11: module_state_toggle
function module_state_toggle()
{
// extra check that we are on the JP blog, just incase
if (class_exists('Jetpack') && $this->in_jetpack) {
$jetpack = Jetpack::init();
$jetpack->sync->register('noop');
}
}
示例12: __construct
function __construct()
{
$this->jetpack = Jetpack::init();
self::$block_page_rendering_for_idc = Jetpack::validate_sync_error_idc_option() && !Jetpack_Options::get_option('safe_mode_confirmed');
if (!self::$block_page_rendering_for_idc) {
add_action('admin_enqueue_scripts', array($this, 'additional_styles'));
}
}
示例13: sync_options
/**
* @param string $file __FILE__
* @param string $option, Option name to sync
* @param string $option ...
*/
static function sync_options($file, $option)
{
if (is_network_admin()) {
return;
}
$jetpack = Jetpack::init();
$args = func_get_args();
return call_user_func_array(array($jetpack->sync, 'options'), $args);
}
示例14: __construct
private function __construct()
{
$this->jetpack = Jetpack::init();
add_action('admin_menu', array($this, 'admin_menu'), 998);
add_action('jetpack_admin_menu', array($this, 'admin_menu_debugger'));
add_action('jetpack_admin_menu', array($this, 'admin_menu_modules'));
add_action('jetpack_pre_activate_module', array($this, 'fix_redirect'));
add_action('jetpack_pre_deactivate_module', array($this, 'fix_redirect'));
add_action('jetpack_unrecognized_action', array($this, 'handle_unrecognized_action'));
}
示例15: _get_post_count_cloud
private function _get_post_count_cloud()
{
$blog_id = Jetpack::init()->get_option('id');
$body = array('size' => 1);
$response = wp_remote_post("https://public-api.wordpress.com/rest/v1/sites/{$blog_id}/search", array('timeout' => 10, 'user-agent' => 'jetpack_related_posts', 'sslverify' => true, 'body' => $body));
if (is_wp_error($response)) {
return 0;
}
$results = json_decode(wp_remote_retrieve_body($response), true);
return (int) $results['results']['total'];
}