class-add-keyword-modal.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * @package WPSEO\Admin
  4. */
  5. /**
  6. * Class to print out the translatable strings for the Add Keyword modal.
  7. */
  8. class WPSEO_Add_Keyword_Modal {
  9. /**
  10. * Returns the translations for the Add Keyword modal.
  11. *
  12. * These strings are not escaped because they're meant to be used with React
  13. * which already takes care of that. If used in PHP, they should be escaped.
  14. *
  15. * @return array Translated text strings for the Add Keyword modal.
  16. */
  17. public function get_translations() {
  18. return array(
  19. 'title' => __( 'Would you like to add more than one keyword?', 'wordpress-seo' ),
  20. 'intro' => sprintf(
  21. /* translators: %1$s expands to a 'Yoast SEO Premium' text linked to the yoast.com website. */
  22. __( 'Great news: you can, with %1$s!', 'wordpress-seo' ),
  23. '{{link}}Yoast SEO Premium{{/link}}'
  24. ),
  25. 'link' => WPSEO_Shortlinker::get( 'https://yoa.st/pe-premium-page' ),
  26. 'other' => sprintf(
  27. /* translators: %s expands to 'Yoast SEO Premium'. */
  28. __( 'Other benefits of %s for you:', 'wordpress-seo' ), 'Yoast SEO Premium'
  29. ),
  30. 'buylink' => WPSEO_Shortlinker::get( 'https://yoa.st/add-keywords-popup' ),
  31. 'buy' => sprintf(
  32. /* translators: %s expands to 'Yoast SEO Premium'. */
  33. __( 'Get %s now!', 'wordpress-seo' ), 'Yoast SEO Premium'
  34. ),
  35. 'small' => __( '1 year free updates and upgrades included!', 'wordpress-seo' ),
  36. 'a11yNotice.opensInNewTab' => __( '(Opens in a new browser tab)', 'wordpress-seo' ),
  37. );
  38. }
  39. /**
  40. * Passes translations to JS for the Add Keyword modal component.
  41. *
  42. * @return array Translated text strings for the Add Keyword modal component.
  43. */
  44. public function get_translations_for_js() {
  45. $translations = $this->get_translations();
  46. return array(
  47. 'locale' => WPSEO_Utils::get_user_locale(),
  48. 'intl' => $translations,
  49. );
  50. }
  51. /**
  52. * Prints the localized Add Keyword modal translations for JS.
  53. */
  54. public function enqueue_translations() {
  55. wp_localize_script( WPSEO_Admin_Asset_Manager::PREFIX . 'admin-global-script', 'yoastAddKeywordModalL10n', $this->get_translations_for_js() );
  56. }
  57. }