function jetpack_verification_tool_box() { global $current_user; if (!apply_filters('jetpack_enable_site_verification', true)) { return; } $list = array(); foreach (jetpack_verification_services() as $key => $service) { $list[] = '<a href="' . esc_url($service['url']) . '">' . esc_html($service['name']) . '</a>'; } $last = array_pop($list); if (current_user_can('manage_options')) { echo '<div class="tool-box"><h3 class="title">' . __('Website Verification Services', 'jetpack') . ' <a href="http://support.wordpress.com/webmaster-tools/" target="_blank">(?)</a></h3>'; echo '<p>' . sprintf(esc_html(__('Enter your meta key "content" value to verify your blog with %s', 'jetpack')), implode(', ', $list)) . ' ' . __('and', 'jetpack') . ' ' . $last . '.</p>'; jetpack_verification_options_form(); echo '</div>'; } }
/** * Get services that this site is verified with. * * @since 4.3.0 * * @return mixed|WP_Error List of services that verified this site. Otherwise, a WP_Error instance with the corresponding error. */ public function get_verification_tools_data() { if (!Jetpack::is_module_active('verification-tools')) { return new WP_Error('not_active', esc_html__('The requested Jetpack module is not active.', 'jetpack'), array('status' => 404)); } $verification_services_codes = get_option('verification_services_codes'); if (!is_array($verification_services_codes) || empty($verification_services_codes)) { return new WP_Error('empty', esc_html__('Site not verified with any service.', 'jetpack'), array('status' => 404)); } $services = array(); foreach (jetpack_verification_services() as $name => $service) { if (is_array($service) && !empty($verification_services_codes[$name])) { switch ($name) { case 'google': $services[] = 'Google'; break; case 'bing': $services[] = 'Bing'; break; case 'pinterest': $services[] = 'Pinterest'; break; case 'yandex': $services[] = 'Yandex'; break; } } } if (empty($services)) { return new WP_Error('empty', esc_html__('Site not verified with any service.', 'jetpack'), array('status' => 404)); } if (2 > count($services)) { $message = esc_html(sprintf(__('Your site is verified with %s.', 'jetpack'), $services[0])); } else { $copy_services = $services; $last = count($copy_services) - 1; $last_service = $copy_services[$last]; unset($copy_services[$last]); $message = esc_html(sprintf(__('Your site is verified with %1$s and %2$s.', 'jetpack'), join(', ', $copy_services), $last_service)); } return rest_ensure_response(array('code' => 'success', 'message' => $message, 'services' => $services)); }