WPSEO_GSC_Mapper

Class WPSEO_GSC_Mapper.

Defined (1)

The class is defined in the following location(s).

/admin/google_search_console/class-gsc-mapper.php  
  1. class WPSEO_GSC_Mapper { 
  2.  
  3. /** 
  4. * The platforms which can be mapped. 
  5. * @var array 
  6. */ 
  7. private static $platforms = array( 
  8. 'web' => 'web',  
  9. 'mobile' => 'mobile',  
  10. 'smartphone_only' => 'smartphoneOnly',  
  11. 'settings' => 'settings', // This one is basicly not a platform, but a tab. 
  12. ); 
  13.  
  14. /** 
  15. * The categories which can be mapped 
  16. * @var array 
  17. */ 
  18. private static $categories = array( 
  19. 'access_denied' => 'authPermissions',  
  20. 'faulty_redirects' => 'manyToOneRedirect',  
  21. 'not_followed' => 'notFollowed',  
  22. 'not_found' => 'notFound',  
  23. 'other' => 'other',  
  24. 'roboted' => 'roboted',  
  25. 'server_error' => 'serverError',  
  26. 'soft_404' => 'soft404',  
  27. ); 
  28.  
  29. /** 
  30. * If there is no platform, just get the first key out of the array and redirect to it. 
  31. * @param string $platform Platform (desktop, mobile, feature phone). 
  32. * @return mixed 
  33. */ 
  34. public static function get_current_platform( $platform ) { 
  35. if ( $current_platform = filter_input( INPUT_GET, $platform ) ) { 
  36. return $current_platform; 
  37.  
  38. wp_redirect( add_query_arg( $platform, key( self::$platforms ) ) ); 
  39. exit; 
  40.  
  41. /** 
  42. * Mapping the platform 
  43. * @param string $platform Platform (desktop, mobile, feature phone). 
  44. * @return mixed 
  45. */ 
  46. public static function platform_to_api( $platform ) { 
  47. if ( ! empty( $platform ) && array_key_exists( $platform, self::$platforms ) ) { 
  48. return self::$platforms[ $platform ]; 
  49.  
  50. /** 
  51. * Mapping the given platform by value and return its key 
  52. * @param string $platform Platform (desktop, mobile, feature phone). 
  53. * @return string 
  54. */ 
  55. public static function platform_from_api( $platform ) { 
  56. if ( ! empty( $platform ) && $platform = array_search( $platform, self::$platforms ) ) { 
  57. return $platform; 
  58.  
  59. return $platform; 
  60.  
  61. /** 
  62. * Mapping the given category by searching for its key. 
  63. * @param string $category Issue type. 
  64. * @return mixed 
  65. */ 
  66. public static function category_to_api( $category ) { 
  67. if ( ! empty( $category ) && array_key_exists( $category, self::$categories ) ) { 
  68. return self::$categories[ $category ]; 
  69.  
  70. return $category; 
  71.  
  72. /** 
  73. * Mapping the given category by value and return its key 
  74. * @param string $category Issue type. 
  75. * @return string 
  76. */ 
  77. public static function category_from_api( $category ) { 
  78. if ( ! empty( $category ) && $category = array_search( $category, self::$categories ) ) { 
  79. return $category; 
  80.  
  81. return $category;