3 * @package WPSEO\Admin|Google_Search_Console
7 * Class WPSEO_GSC_Mapper
9 class WPSEO_GSC_Mapper {
12 * The platforms which can be mapped.
16 private static $platforms = array(
19 'smartphone_only' => 'smartphoneOnly',
20 'settings' => 'settings', // This one is basicly not a platform, but a tab.
24 * The categories which can be mapped
28 private static $categories = array(
29 'access_denied' => 'authPermissions',
30 'faulty_redirects' => 'manyToOneRedirect',
31 'not_followed' => 'notFollowed',
32 'not_found' => 'notFound',
34 'roboted' => 'roboted',
35 'server_error' => 'serverError',
36 'soft_404' => 'soft404',
40 * If there is no platform, just get the first key out of the array and redirect to it.
42 * @param string $platform
46 public static function get_current_platform( $platform ) {
47 if ( $current_platform = filter_input( INPUT_GET, $platform ) ) {
48 return $current_platform;
51 wp_redirect( add_query_arg( $platform, key( self::$platforms ) ) );
56 * Mapping the platform
58 * @param string $platform
62 public static function platform_to_api( $platform ) {
63 if ( ! empty( $platform ) && array_key_exists( $platform, self::$platforms ) ) {
64 return self::$platforms[ $platform ];
69 * Mapping the given platform by value and return its key
71 * @param string $platform
75 public static function platform_from_api( $platform ) {
76 if ( ! empty( $platform ) && $platform = array_search( $platform, self::$platforms ) ) {
84 * Mapping the given category by searching for its key.
86 * @param string $category
90 public static function category_to_api( $category) {
91 if ( ! empty( $category ) && array_key_exists( $category, self::$categories ) ) {
92 return self::$categories[ $category ];
99 * Mapping the given category by value and return its key
101 * @param string $category
105 public static function category_from_api( $category ) {
106 if ( ! empty( $category ) && $category = array_search( $category, self::$categories ) ) {