WPSEO_Metabox_Formatter

This class forces needed methods for the metabox localization.

Defined (1)

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

/admin/formatter/class-metabox-formatter.php  
  1. class WPSEO_Metabox_Formatter { 
  2.  
  3. /** 
  4. * @var WPSEO_Metabox_Formatter_Interface Object that provides formatted values. 
  5. */ 
  6. private $formatter; 
  7.  
  8. /** 
  9. * Setting the formatter property. 
  10. * @param WPSEO_Metabox_Formatter_Interface $formatter Object that provides the formatted values. 
  11. */ 
  12. public function __construct( WPSEO_Metabox_Formatter_Interface $formatter ) { 
  13. $this->formatter = $formatter; 
  14.  
  15. /** 
  16. * Returns the values 
  17. * @return array 
  18. */ 
  19. public function get_values() { 
  20. $defaults = $this->get_defaults(); 
  21. $values = $this->formatter->get_values(); 
  22.  
  23. return ( $values + $defaults ); 
  24.  
  25. /** 
  26. * Returns array with all the values always needed by a scraper object 
  27. * @return array 
  28. */ 
  29. private function get_defaults() { 
  30. $analysis_seo = new WPSEO_Metabox_Analysis_SEO(); 
  31. $analysis_readability = new WPSEO_Metabox_Analysis_Readability(); 
  32.  
  33. return array( 
  34. 'search_url' => '',  
  35. 'post_edit_url' => '',  
  36. 'base_url' => '',  
  37. 'contentTab' => __( 'Readability', 'wordpress-seo' ),  
  38. 'keywordTab' => __( 'Keyword:', 'wordpress-seo' ),  
  39. 'enterFocusKeyword' => __( 'Enter your focus keyword', 'wordpress-seo' ),  
  40. 'removeKeyword' => __( 'Remove keyword', 'wordpress-seo' ),  
  41. 'contentLocale' => get_locale(),  
  42. 'userLocale' => WPSEO_Utils::get_user_locale(),  
  43. 'translations' => $this->get_translations(),  
  44. 'keyword_usage' => array(),  
  45. 'title_template' => '',  
  46. 'metadesc_template' => '',  
  47. 'contentAnalysisActive' => $analysis_readability->is_enabled() ? 1 : 0,  
  48. 'keywordAnalysisActive' => $analysis_seo->is_enabled() ? 1 : 0,  
  49.  
  50. /** 
  51. * Filter to determine if the markers should be enabled or not. 
  52. * @param bool $showMarkers Should the markers being enabled. Default = true. 
  53. */ 
  54. 'show_markers' => apply_filters( 'wpseo_enable_assessment_markers', true ),  
  55. 'publish_box' => array( 
  56. 'labels' => array( 
  57. 'content' => __( 'Readability', 'wordpress-seo' ),  
  58. 'keyword' => __( 'SEO', 'wordpress-seo' ),  
  59. ),  
  60. 'statuses' => array( 
  61. 'na' => __( 'Not available', 'wordpress-seo' ),  
  62. 'bad' => __( 'Needs improvement', 'wordpress-seo' ),  
  63. 'ok' => __( 'OK', 'wordpress-seo' ),  
  64. 'good' => __( 'Good', 'wordpress-seo' ),  
  65. ),  
  66. ),  
  67. ); 
  68.  
  69.  
  70. /** 
  71. * Returns Jed compatible YoastSEO.js translations. 
  72. * @return array 
  73. */ 
  74. private function get_translations() { 
  75. $locale = WPSEO_Utils::get_user_locale(); 
  76.  
  77. $file = plugin_dir_path( WPSEO_FILE ) . 'languages/wordpress-seo-' . $locale . '.json'; 
  78. if ( file_exists( $file ) && $file = file_get_contents( $file ) ) { 
  79. return json_decode( $file, true ); 
  80.  
  81. return array();