licenses.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <?php
  2. /**
  3. * WPSEO plugin file.
  4. *
  5. * @package WPSEO\Admin
  6. * @since 5.1
  7. */
  8. if ( ! defined( 'WPSEO_VERSION' ) ) {
  9. header( 'Status: 403 Forbidden' );
  10. header( 'HTTP/1.1 403 Forbidden' );
  11. exit();
  12. }
  13. $extension_list = new WPSEO_Extensions();
  14. $extensions = $extension_list->get();
  15. // First invalidate all licenses.
  16. array_map( [ $extension_list, 'invalidate' ], $extensions );
  17. $premium_extension = new WPSEO_Extension(
  18. [
  19. 'buyUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/zz' ),
  20. 'infoUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/zy' ),
  21. 'title' => 'Yoast SEO Premium',
  22. /* translators: %1$s expands to Yoast SEO */
  23. 'desc' => sprintf( __( 'The premium version of %1$s with more features & support.', 'wordpress-seo' ), 'Yoast SEO' ),
  24. 'benefits' => [],
  25. ]
  26. );
  27. $extensions = [
  28. WPSEO_Addon_Manager::LOCAL_SLUG => new WPSEO_Extension(
  29. [
  30. 'buyUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/zt' ),
  31. 'infoUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/zs' ),
  32. 'title' => 'Local SEO',
  33. 'display_title' => 'Stop losing customers to other local businesses',
  34. 'desc' => __( 'Rank better locally and in Google Maps, without breaking a sweat!', 'wordpress-seo' ),
  35. 'image' => plugins_url( 'images/local_plugin_assistant.svg?v=' . WPSEO_VERSION, WPSEO_FILE ),
  36. 'benefits' => [
  37. __( 'Get better search results in local search', 'wordpress-seo' ),
  38. __( 'Easily insert Google Maps, a store locator, opening hours and more', 'wordpress-seo' ),
  39. /* translators: %1$s expands to WooCommerce */
  40. sprintf( __( 'Allow customers to pick up their %s order locally', 'wordpress-seo' ), 'WooCommerce' ),
  41. ],
  42. ]
  43. ),
  44. WPSEO_Addon_Manager::VIDEO_SLUG => new WPSEO_Extension(
  45. [
  46. 'buyUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/zx/' ),
  47. 'infoUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/zw/' ),
  48. 'title' => 'Video SEO',
  49. 'display_title' => 'Start ranking better for your videos',
  50. 'desc' => __( 'Optimize your videos to show them off in search results and get more clicks!', 'wordpress-seo' ),
  51. 'image' => plugins_url( 'images/video_plugin_assistant.svg?v=' . WPSEO_VERSION, WPSEO_FILE ),
  52. 'benefits' => [
  53. __( 'Show your videos in Google Videos', 'wordpress-seo' ),
  54. __( 'Enhance the experience of sharing posts with videos', 'wordpress-seo' ),
  55. __( 'Make videos responsive through enabling fitvids.js', 'wordpress-seo' ),
  56. ],
  57. ]
  58. ),
  59. WPSEO_Addon_Manager::NEWS_SLUG => new WPSEO_Extension(
  60. [
  61. 'buyUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/zv/' ),
  62. 'infoUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/zu/' ),
  63. 'title' => 'News SEO',
  64. 'display_title' => 'Everything you need for Google News',
  65. 'desc' => __( 'Are you in Google News? Increase your traffic from Google News by optimizing for it!', 'wordpress-seo' ),
  66. 'image' => plugins_url( 'images/news_plugin_assistant.svg?v=' . WPSEO_VERSION, WPSEO_FILE ),
  67. 'benefits' => [
  68. __( 'Optimize your site for Google News', 'wordpress-seo' ),
  69. __( 'Immediately pings Google on the publication of a new post', 'wordpress-seo' ),
  70. __( 'Creates XML News Sitemaps', 'wordpress-seo' ),
  71. ],
  72. ]
  73. ),
  74. ];
  75. // Add Yoast WooCommerce SEO when WooCommerce is active.
  76. if ( WPSEO_Utils::is_woocommerce_active() ) {
  77. $extensions[ WPSEO_Addon_Manager::WOOCOMMERCE_SLUG ] = new WPSEO_Extension(
  78. [
  79. 'buyUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/zr' ),
  80. 'infoUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/zq' ),
  81. 'title' => 'Yoast WooCommerce SEO',
  82. 'display_title' => 'Make your products stand out in Google',
  83. /* translators: %1$s expands to Yoast SEO */
  84. 'desc' => sprintf( __( 'Seamlessly integrate WooCommerce with %1$s and get extra features!', 'wordpress-seo' ), 'Yoast SEO' ),
  85. 'image' => plugins_url( 'images/woo_plugin_assistant.svg?v=' . WPSEO_VERSION, WPSEO_FILE ),
  86. 'benefits' => [
  87. sprintf( __( 'Improve sharing on Facebook and Pinterest', 'wordpress-seo' ) ),
  88. /* translators: %1$s expands to Yoast, %2$s expands to WooCommerce */
  89. sprintf( __( 'Use %1$s breadcrumbs instead of %2$s ones', 'wordpress-seo' ), 'Yoast', 'WooCommerce' ),
  90. /* translators: %1$s expands to Yoast SEO, %2$s expands to WooCommerce */
  91. sprintf( __( 'A seamless integration between %1$s and %2$s', 'wordpress-seo' ), 'Yoast SEO', 'WooCommerce' ),
  92. ],
  93. 'buy_button' => 'WooCommerce SEO',
  94. ]
  95. );
  96. }
  97. $addon_manager = new WPSEO_Addon_Manager();
  98. $has_valid_premium_subscription = WPSEO_Utils::is_yoast_seo_premium() && $addon_manager->has_valid_subscription( WPSEO_Addon_Manager::PREMIUM_SLUG );
  99. /* translators: %1$s expands to Yoast SEO. */
  100. $wpseo_extensions_header = sprintf( __( '%1$s Extensions', 'wordpress-seo' ), 'Yoast SEO' );
  101. $new_tab_message = sprintf(
  102. '<span class="screen-reader-text">%1$s</span>',
  103. esc_html__( '(Opens in a new browser tab)', 'wordpress-seo' )
  104. );
  105. ?>
  106. <div class="wrap yoast wpseo_table_page">
  107. <h1 id="wpseo-title" class="yoast-h1"><?php echo esc_html( $wpseo_extensions_header ); ?></h1>
  108. <div id="extensions">
  109. <section class="yoast-seo-premium-extension">
  110. <h2>
  111. <?php
  112. printf(
  113. /* translators: 1: expands to Yoast SEO Premium */
  114. esc_html__( '%1$s, take your optimization to the next level!', 'wordpress-seo' ),
  115. // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: The `get_title` value is hardcoded; only passed through the WPSEO_Extensions class.
  116. '<span class="yoast-heading-highlight">' . $premium_extension->get_title() . '</span>'
  117. );
  118. ?>
  119. </h2>
  120. <?php
  121. if ( ! $has_valid_premium_subscription ) :
  122. ?>
  123. <ul class="yoast-seo-premium-benefits yoast-list--usp">
  124. <li class="yoast-seo-premium-benefits__item">
  125. <span class="yoast-seo-premium-benefits__title"><?php esc_html_e( 'Redirect manager', 'wordpress-seo' ); ?></span>
  126. <span class="yoast-seo-premium-benefits__description"><?php esc_html_e( 'create and manage redirects from within your WordPress install.', 'wordpress-seo' ); ?></span>
  127. </li>
  128. <li class="yoast-seo-premium-benefits__item">
  129. <span class="yoast-seo-premium-benefits__title"><?php esc_html_e( 'Synonyms & related keyphrases', 'wordpress-seo' ); ?></span>
  130. <span class="yoast-seo-premium-benefits__description"><?php esc_html_e( 'optimize a single post for synonyms and related keyphrases.', 'wordpress-seo' ); ?></span>
  131. </li>
  132. <li class="yoast-seo-premium-benefits__item">
  133. <span class="yoast-seo-premium-benefits__title"><?php esc_html_e( 'Social previews', 'wordpress-seo' ); ?></span>
  134. <span class="yoast-seo-premium-benefits__description"><?php esc_html_e( 'check what your Facebook or Twitter post will look like.', 'wordpress-seo' ); ?></span>
  135. </li>
  136. <li class="yoast-seo-premium-benefits__item">
  137. <span class="yoast-seo-premium-benefits__title"><?php esc_html_e( 'Premium support', 'wordpress-seo' ); ?></span>
  138. <span class="yoast-seo-premium-benefits__description"><?php esc_html_e( 'gain access to our 24/7 support team.', 'wordpress-seo' ); ?></span>
  139. </li>
  140. </ul>
  141. <?php endif; ?>
  142. <?php if ( $extension_list->is_installed( $premium_extension->get_title() ) ) : ?>
  143. <div class="yoast-button yoast-button--noarrow yoast-button--extension yoast-button--extension-installed"><?php esc_html_e( 'Installed', 'wordpress-seo' ); ?></div>
  144. <?php if ( $has_valid_premium_subscription ) : ?>
  145. <div class="yoast-button yoast-button--noarrow yoast-button--extension yoast-button--extension-activated"><?php esc_html_e( 'Activated', 'wordpress-seo' ); ?></div>
  146. <a target="_blank" href="<?php WPSEO_Shortlinker::show( 'https://yoa.st/13k' ); ?>"
  147. class="yoast-link--license">
  148. <?php
  149. printf(
  150. /* translators: %s expands to the extension title */
  151. esc_html__( 'Manage your %s subscription on MyYoast', 'wordpress-seo' ),
  152. // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: The `get_title` value is hardcoded; only passed through the WPSEO_Extensions class.
  153. $premium_extension->get_title()
  154. );
  155. // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: $new_tab_message is properly escaped.
  156. echo $new_tab_message;
  157. ?>
  158. </a>
  159. <?php else : ?>
  160. <div class="yoast-button yoast-button--noarrow yoast-button--extension yoast-button--extension-not-activated"><?php esc_html_e( 'Not activated', 'wordpress-seo' ); ?></div>
  161. <a target="_blank" href="<?php WPSEO_Shortlinker::show( 'https://yoa.st/13i' ); ?>"
  162. class="yoast-link--license">
  163. <?php
  164. printf(
  165. /* translators: %s expands to the extension title */
  166. esc_html__( 'Activate %s for your site on MyYoast', 'wordpress-seo' ),
  167. // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: The `get_title` value is hardcoded; only passed through the WPSEO_Extensions class.
  168. $premium_extension->get_title()
  169. );
  170. // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: $new_tab_message is properly escaped.
  171. echo $new_tab_message;
  172. ?>
  173. </a>
  174. <?php endif; ?>
  175. <?php else : ?>
  176. <a target="_blank" href="<?php echo esc_url( $premium_extension->get_buy_url() ); ?>"
  177. class="yoast-button-upsell">
  178. <?php
  179. printf(
  180. /* translators: $s expands to Yoast SEO Premium */
  181. esc_html__( 'Buy %s', 'wordpress-seo' ),
  182. // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: The `get_title` value is hardcoded; only passed through the WPSEO_Extensions class.
  183. $premium_extension->get_title()
  184. );
  185. // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: $new_tab_message is properly escaped.
  186. echo $new_tab_message;
  187. echo '<span aria-hidden="true" class="yoast-button-upsell__caret"></span>';
  188. ?>
  189. </a>
  190. <a target="_blank" href="<?php echo esc_url( $premium_extension->get_info_url() ); ?>"
  191. class="yoast-link--more-info">
  192. <?php
  193. printf(
  194. /* translators: Text between 1: and 2: will only be shown to screen readers. 3: expands to the product name. */
  195. esc_html__( 'More information %1$sabout %3$s%2$s', 'wordpress-seo' ),
  196. '<span class="screen-reader-text">',
  197. '</span>',
  198. // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: The `get_title` value is hardcoded; only passed through the WPSEO_Extensions class.
  199. $premium_extension->get_title()
  200. );
  201. // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: $new_tab_message is properly escaped.
  202. echo $new_tab_message;
  203. ?>
  204. </a>
  205. <?php endif; ?>
  206. <?php if ( ! $has_valid_premium_subscription ) { ?>
  207. <p>
  208. <small class="yoast-money-back-guarantee"><?php esc_html_e( 'Comes with our 30-day no questions asked money back guarantee', 'wordpress-seo' ); ?></small>
  209. </p>
  210. <?php } ?>
  211. </section>
  212. <hr class="yoast-hr" aria-hidden="true"/>
  213. <section class="yoast-promo-extensions">
  214. <h2>
  215. <?php
  216. /* translators: 1: expands to Yoast SEO */
  217. $yoast_seo_extensions = sprintf( esc_html__( '%1$s extensions', 'wordpress-seo' ), 'Yoast SEO' );
  218. $yoast_seo_extensions = '<span class="yoast-heading-highlight">' . $yoast_seo_extensions . '</span>';
  219. printf(
  220. /* translators: 1: expands to Yoast SEO extensions */
  221. esc_html__( '%1$s to optimize your site even further', 'wordpress-seo' ),
  222. // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: $yoast_seo_extensions is properly escaped.
  223. $yoast_seo_extensions
  224. );
  225. ?>
  226. </h2>
  227. <?php foreach ( $extensions as $slug => $extension ) : ?>
  228. <section class="yoast-promoblock secondary yoast-promo-extension">
  229. <h3>
  230. <img alt="" width="100" height="100" src="<?php echo esc_attr( $extension->get_image() ); ?>"/>
  231. <?php echo esc_html( $extension->get_display_title() ); ?>
  232. </h3>
  233. <ul class="yoast-list--usp">
  234. <?php foreach ( $extension->get_benefits() as $benefit ) : ?>
  235. <li><?php echo esc_html( $benefit ); ?></li>
  236. <?php endforeach; ?>
  237. </ul>
  238. <div class="yoast-button-container">
  239. <?php if ( $extension_list->is_installed( $extension->get_title() ) ) : ?>
  240. <div class="yoast-button yoast-button--noarrow yoast-button--extension yoast-button--extension-installed"><?php esc_html_e( 'Installed', 'wordpress-seo' ); ?></div>
  241. <?php if ( $addon_manager->has_valid_subscription( $slug ) ) : ?>
  242. <div class="yoast-button yoast-button--noarrow yoast-button--extension yoast-button--extension-activated"><?php esc_html_e( 'Activated', 'wordpress-seo' ); ?></div>
  243. <a target="_blank" href="<?php WPSEO_Shortlinker::show( 'https://yoa.st/13k' ); ?>"
  244. class="yoast-link--license">
  245. <?php
  246. printf(
  247. /* translators: %s expands to the extension title */
  248. esc_html__( 'Manage your %s subscription on MyYoast', 'wordpress-seo' ),
  249. // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: The `get_title` value is hardcoded; only passed through the WPSEO_Extensions class.
  250. $extension->get_title()
  251. );
  252. // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: $new_tab_message is properly escaped.
  253. echo $new_tab_message;
  254. ?>
  255. </a>
  256. <?php else : ?>
  257. <div class="yoast-button yoast-button--noarrow yoast-button--extension yoast-button--extension-not-activated"><?php esc_html_e( 'Not activated', 'wordpress-seo' ); ?></div>
  258. <a target="_blank" href="<?php WPSEO_Shortlinker::show( 'https://yoa.st/13i' ); ?>"
  259. class="yoast-link--license">
  260. <?php
  261. printf(
  262. /* translators: %s expands to the extension title */
  263. esc_html__( 'Activate %s for your site on MyYoast', 'wordpress-seo' ),
  264. // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: The `get_title` value is hardcoded; only passed through the WPSEO_Extensions class.
  265. $extension->get_title()
  266. );
  267. // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: $new_tab_message is properly escaped.
  268. echo $new_tab_message;
  269. ?>
  270. </a>
  271. <?php endif; ?>
  272. <?php else : ?>
  273. <a target="_blank" class="yoast-button-upsell"
  274. href="<?php echo esc_url( $extension->get_buy_url() ); ?>">
  275. <?php
  276. printf(
  277. /* translators: %s expands to the product name */
  278. esc_html__( 'Buy %s', 'wordpress-seo' ),
  279. // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: The possible `get_buy_button` values are hardcoded (buy_button or title); only passed through the WPSEO_Extensions class.
  280. $extension->get_buy_button()
  281. );
  282. // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: $new_tab_message is properly escaped.
  283. echo $new_tab_message;
  284. echo '<span aria-hidden="true" class="yoast-button-upsell__caret"></span>';
  285. ?>
  286. </a>
  287. <a target="_blank" class="yoast-link--more-info"
  288. href="<?php echo esc_url( $extension->get_info_url() ); ?>">
  289. <?php
  290. printf(
  291. /* translators: Text between 1: and 2: will only be shown to screen readers. 3: expands to the product name. */
  292. esc_html__( 'More information %1$sabout %3$s%2$s', 'wordpress-seo' ),
  293. '<span class="screen-reader-text">',
  294. '</span>',
  295. // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: The `get_title` value is hardcoded; only passed through the WPSEO_Extensions class.
  296. $extension->get_title()
  297. );
  298. // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: $new_tab_message is properly escaped.
  299. echo $new_tab_message;
  300. ?>
  301. </a>
  302. <?php endif; ?>
  303. </div>
  304. </section>
  305. <?php endforeach; ?>
  306. </section>
  307. </div>
  308. </div>