class-multiple-keywords-modal.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * @package WPSEO\Admin
  4. */
  5. /**
  6. * Class to print out the translatable strings for the Multiple Keywords modal.
  7. */
  8. class WPSEO_Multiple_Keywords_Modal {
  9. /**
  10. * Returns the translations for the Multiple Keywords 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 Multiple Keywords modal.
  16. */
  17. public function get_translations() {
  18. return array(
  19. 'title' => __( 'Would you like to add another 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' ),
  29. 'Yoast SEO Premium'
  30. ),
  31. 'buylink' => WPSEO_Shortlinker::get( 'https://yoa.st/add-keywords-popup' ),
  32. 'buy' => sprintf(
  33. /* translators: %s expands to 'Yoast SEO Premium'. */
  34. __( 'Get %s now!', 'wordpress-seo' ),
  35. 'Yoast SEO Premium'
  36. ),
  37. 'small' => __( '1 year free updates and upgrades included!', 'wordpress-seo' ),
  38. 'a11yNotice.opensInNewTab' => __( '(Opens in a new browser tab)', 'wordpress-seo' ),
  39. );
  40. }
  41. /**
  42. * Passes translations to JS for the Multiple Keywords modal component.
  43. *
  44. * @return array Translated text strings for the Multiple Keywords modal component.
  45. */
  46. public function get_translations_for_js() {
  47. $translations = $this->get_translations();
  48. return array(
  49. 'locale' => WPSEO_Utils::get_user_locale(),
  50. 'intl' => $translations,
  51. );
  52. }
  53. /**
  54. * Prints the localized Multiple Keywords modal translations for JS.
  55. *
  56. * @return void
  57. */
  58. public function enqueue_translations() {
  59. wp_localize_script( WPSEO_Admin_Asset_Manager::PREFIX . 'admin-global-script', 'yoastMultipleKeywordsModalL10n', $this->get_translations_for_js() );
  60. }
  61. }