3 * @package WPSEO\Admin|Google_Search_Console
7 * Class WPSEO_GSC_Platform_Tabs
9 class WPSEO_GSC_Platform_Tabs {
17 * Return the tabs as a string
21 public function __toString() {
22 return $this->platform_tabs();
26 * Getting the current_tab
30 public function current_tab() {
31 return $this->current_tab;
35 * Loops through the array with all the platforms and convert it into an array
39 private function platform_tabs() {
40 $tabs = array( 'settings' => __( 'Settings', 'wordpress-seo' ) );
43 'web' => __( 'Desktop', 'wordpress-seo' ),
44 'smartphone_only' => __( 'Smartphone', 'wordpress-seo' ),
45 'mobile' => __( 'Feature phone', 'wordpress-seo' ),
48 if ( WPSEO_GSC_Settings::get_profile() !== '' ) {
49 $tabs = array_merge( $platforms, $tabs );
52 $admin_link = admin_url( 'admin.php?page=wpseo_search_console&tab=' );
54 $this->set_current_tab( $tabs );
58 foreach ( $tabs as $platform_target => $platform_value ) {
59 $return .= $this->platform_tab( $platform_target, $platform_value, $admin_link );
66 * Setting the current tab
68 * @param array $platforms
70 private function set_current_tab( array $platforms ) {
71 $this->current_tab = key( $platforms );
72 if ( $current_platform = filter_input( INPUT_GET, 'tab' ) ) {
73 $this->current_tab = $current_platform;
80 * @param string $platform_target
81 * @param string $platform_value
82 * @param string $admin_link
86 private function platform_tab( $platform_target, $platform_value, $admin_link ) {
88 if ( $this->current_tab === $platform_target ) {
89 $active = ' nav-tab-active';
92 return '<a class="nav-tab ' . $active . '" id="' . $platform_target . '-tab" href="' . $admin_link . $platform_target . '">' . $platform_value . '</a>';