/** * Prepare actions according to screen and post type. * * @since 3.8.2 * * @uses Jetpack_Autoupdate::get_possible_failures() * * @param object $screen */ function prepare_jitms($screen) { if (!current_user_can('jetpack_manage_modules')) { return; } global $pagenow; // Only show auto update JITM if auto updates are allowed in this installation $possible_reasons_for_failure = Jetpack_Autoupdate::get_possible_failures(); self::$auto_updates_allowed = empty($possible_reasons_for_failure); if ('media-new.php' == $pagenow && !Jetpack::is_module_active('photon')) { add_action('admin_enqueue_scripts', array($this, 'jitm_enqueue_files')); add_action('post-plupload-upload-ui', array($this, 'photon_msg')); } elseif ('post-new.php' == $pagenow && in_array($screen->post_type, array('post', 'page'))) { add_action('admin_enqueue_scripts', array($this, 'jitm_enqueue_files')); add_action('admin_notices', array($this, 'editor_msg')); } elseif (self::$auto_updates_allowed) { if ('update-core.php' == $pagenow && !Jetpack::is_module_active('manage')) { add_action('admin_enqueue_scripts', array($this, 'jitm_enqueue_files')); add_action('admin_notices', array($this, 'manage_msg')); } elseif ('plugins.php' == $pagenow) { if (isset($_GET['activate']) && 'true' === $_GET['activate'] || isset($_GET['activate-multi']) && 'true' === $_GET['activate-multi']) { add_action('admin_enqueue_scripts', array($this, 'jitm_enqueue_files')); add_action('pre_current_active_plugins', array($this, 'manage_pi_msg')); } else { // Save plugins that are activated. This is used when one or more plugins are activated to know // what was activated and use it in Jetpack_JITM::manage_pi_msg() before deleting the option. $wp_list_table = _get_list_table('WP_Plugins_List_Table'); $action = $wp_list_table->current_action(); if ($action && ('activate' == $action || 'activate-selected' == $action)) { update_option('jetpack_temp_active_plugins_before', get_option('active_plugins', array())); } } } } }
protected function result() { add_action('automatic_updates_complete', array($this, 'get_update_results'), 100, 1); wp_maybe_auto_update(); $result['log'] = $this->update_results; if (empty($result['log'])) { $possible_reasons_for_failure = Jetpack_Autoupdate::get_possible_failures(); if ($possible_reasons_for_failure) { $result['log']['error'] = $possible_reasons_for_failure; } } return $result; }