/** * Get a value not saved locally. * * @since 4.3.0 * * @param string $module Module slug. * @param string $option Option name. * * @return bool Whether user is receiving notifications or not. */ public static function get_remote_value($module, $option) { if (in_array($module, array('post-by-email'), true)) { $option .= get_current_user_id(); } // If option doesn't exist, 'does_not_exist' will be returned. $value = get_option($option, 'does_not_exist'); // If option exists, just return it. if ('does_not_exist' !== $value) { return $value; } // Only check a remote option if Jetpack is connected. if (!Jetpack::is_active()) { return false; } // If the module is inactive, load the class to use the method. if (!did_action('jetpack_module_loaded_' . $module)) { // Class can't be found so do nothing. if (!@(include Jetpack::get_module_path($module))) { return false; } } // Do what is necessary for each module. switch ($module) { case 'monitor': $monitor = new Jetpack_Monitor(); $value = $monitor->user_receives_notifications(false); break; case 'post-by-email': $post_by_email = new Jetpack_Post_By_Email(); $value = $post_by_email->get_post_by_email_address(); if ($value === null) { $value = 'NULL'; // sentinel value so it actually gets set } break; } // Normalize value to boolean. if (is_wp_error($value) || is_null($value)) { $value = false; } // Save option to use it next time. update_option($option, $value); return $value; }