WPSEO_Admin_Banner_Sidebar

Represents the render object for generating the html for the given banner.

Defined (1)

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

/admin/banner/class-admin-banner-sidebar.php  
  1. class WPSEO_Admin_Banner_Sidebar { 
  2.  
  3. /** @var string */ 
  4. protected $title = ''; 
  5.  
  6. /** @var WPSEO_Admin_Banner_Spot[] */ 
  7. protected $banner_spots = array(); 
  8.  
  9. /** @var WPSEO_Admin_Banner_Renderer */ 
  10. protected $banner_renderer; 
  11.  
  12. /** 
  13. * WPSEO_Admin_Banner_Sidebar constructor. 
  14. * @param string $title The title for the sidebar. 
  15. * @param WPSEO_Admin_Banner_Renderer $banner_renderer The render class for banners. 
  16. */ 
  17. public function __construct( $title, WPSEO_Admin_Banner_Renderer $banner_renderer ) { 
  18. $this->title = $title; 
  19. $this->banner_renderer = $banner_renderer; 
  20.  
  21. /** 
  22. * Returns the set title. 
  23. * @return string 
  24. */ 
  25. public function get_title() { 
  26. return $this->title; 
  27.  
  28. /** 
  29. * Initializes the banner sidebar by setting its banner spots. 
  30. * @param WPSEO_Features $features Class regarding WPSEO Features. 
  31. */ 
  32. public function initialize( WPSEO_Features $features ) { 
  33. if ( $features->is_free() ) { 
  34. $this->add_banner_spot( $this->get_premium_spot() ); 
  35.  
  36. $this->add_banner_spot( $this->get_services_spot() ); 
  37.  
  38. $extensions_spot = $this->get_extensions_spot( $this->get_active_extensions() ); 
  39. if ( $extensions_spot->has_banners() ) { 
  40. $this->add_banner_spot( $extensions_spot ); 
  41.  
  42. $this->add_banner_spot( $this->get_courses_spot() ); 
  43. $this->add_banner_spot( $this->get_remove_banner_spot() ); 
  44.  
  45. /** 
  46. * Returns array with bannerspots. 
  47. * @return WPSEO_Admin_Banner_Spot[] 
  48. */ 
  49. public function get_banner_spots() { 
  50. return $this->banner_spots; 
  51.  
  52. /** 
  53. * Adds a banner spot. 
  54. * @param WPSEO_Admin_Banner_Spot $spot The spot to add. 
  55. */ 
  56. protected function add_banner_spot( WPSEO_Admin_Banner_Spot $spot ) { 
  57. $this->banner_spots[] = $spot; 
  58.  
  59. /** 
  60. * Returns the premium banner spot. 
  61. * @return WPSEO_Admin_Banner_Spot 
  62. */ 
  63. protected function get_premium_spot() { 
  64. $premium_spot = new WPSEO_Admin_Banner_Spot( '', $this->banner_renderer ); 
  65.  
  66. $premium_uri = WPSEO_Shortlinker::get( 'https://yoa.st/jj' ); 
  67.  
  68. $premium_spot->set_extra( 
  69. /** translators: %1$s expands to the plugin name */ 
  70. '<h2>' . sprintf( __( 'Get %1$s', 'wordpress-seo' ), 'Yoast SEO Premium' ) . '</h2>' . 
  71. '<ul>' . 
  72. '<li><strong>' . __( 'Multiple keywords', 'wordpress-seo' ) . '</strong><br/>' . __( 'Increase your SEO reach', 'wordpress-seo' ) . '</li>' . 
  73. '<li><strong>' . __( 'No more dead links', 'wordpress-seo' ) . '</strong><br/>' . __( 'Easy redirect manager', 'wordpress-seo' ) . '</li>' . 
  74. '<li><strong>' . __( 'Internal linking suggestions', 'wordpress-seo' ) . '</strong><br/>' . __( 'Find related posts superfast', 'wordpress-seo' ) . '</li>' . 
  75. '<li><strong>' . __( 'Social media preview', 'wordpress-seo' ) . '</strong><br/>' . esc_html__( 'Facebook & Twitter', 'wordpress-seo' ) . '</li>' . 
  76. '<li><strong>' . __( '24/7 support', 'wordpress-seo' ) . '</strong></li>' . 
  77. '<li><strong>' . __( 'No ads!', 'wordpress-seo' ) . '</strong></li>' . 
  78. '</ul>' . 
  79. /** translators: %s expands to Yoast SEO Premium */ 
  80. '<a id="wpseo-premium-button" class="button button-primary" href="' . $premium_uri . '">' . sprintf( __( 'Get %s now!', 'wordpress-seo' ), 'Yoast SEO Premium' ) . '</a><br/>' . 
  81. '<small>' . __( 'Prices start as low as 69, - for one site', 'wordpress-seo' ) . '</small><br/><br/>' 
  82. ); 
  83.  
  84. /** 
  85. $premium_spot->set_description( 
  86. sprintf( 
  87. /** translators: %1$s expands to a link start tag to the Yoast plugin page, %2$s is the link closing tag * / 
  88. __( 'Want to get the most out of your SEO-strategy? %1$sGo premium!%2$s.', 'wordpress-seo' ),  
  89. '<a target="_blank" href="' . WPSEO_Shortlinker::get( 'https://yoa.st/ji' ) . '">',  
  90. '</a>' 
  91. ); 
  92. /** 
  93.   
  94. $premium_spot->add_banner( 
  95. new WPSEO_Admin_Banner( 
  96. WPSEO_Shortlinker::get( 'https://yoa.st/jj' ),  
  97. 'premium-seo.png',  
  98. 261,  
  99. 152,  
  100. sprintf( 
  101. /** translators: %1$s expands to Yoast SEO Premium. * / 
  102. __( 'Buy the %1$s plugin now and get access to extra features and 24/7 support!', 'wordpress-seo' ),  
  103. 'Yoast SEO Premium' 
  104. ); 
  105. */ 
  106.  
  107. return $premium_spot; 
  108.  
  109. /** 
  110. * Returns the services banner spot. 
  111. * @return WPSEO_Admin_Banner_Spot 
  112. */ 
  113. protected function get_services_spot() { 
  114. $service_spot = new WPSEO_Admin_Banner_Spot( __( 'Services', 'wordpress-seo' ), $this->banner_renderer ); 
  115.  
  116. $service_spot->set_description( 
  117. sprintf( 
  118. /** translators: %1$s expands to a link start tag to the Yoast Services page, %2$s to Yoast, %3$s is the link closing tag. */ 
  119. __( 'Do you want to know how to improve your rankings? %1$sLet team %2$s help you!%3$s', 'wordpress-seo' ),  
  120. '<a target="_blank" href="' . WPSEO_Shortlinker::get( 'https://yoa.st/jk' ) . '">',  
  121. 'Yoast',  
  122. '</a>' 
  123. ); 
  124.  
  125. $service_spot->add_banner( 
  126. new WPSEO_Admin_Banner( 
  127. WPSEO_Shortlinker::get( 'https://yoa.st/jm' ),  
  128. 'configuration-service.png',  
  129. 261,  
  130. 152,  
  131. sprintf( 
  132. /** translators: %1$s expands to Yoast SEO Premium. */ 
  133. __( 'Let our experts set up your %1$s plugin!', 'wordpress-seo' ),  
  134. 'Yoast SEO Premium' 
  135. ); 
  136.  
  137. /** 
  138. $service_spot->add_banner( 
  139. new WPSEO_Admin_Banner( 
  140. WPSEO_Shortlinker::get( 'https://yoa.st/seo-care-banner' ),  
  141. 'seo-care.png',  
  142. 261,  
  143. 152,  
  144. sprintf( 
  145. /** translators: %1$s expands to Yoast SEO Care. * / 
  146. __( 'Let us help you take care of the SEO of your website. Order %1$s now!', 'wordpress-seo' ),  
  147. 'Yoast SEO Care' 
  148. ); 
  149. */ 
  150.  
  151. return $service_spot; 
  152.  
  153. /** 
  154. * Returns an array with the Yoast SEO extensions with the value true when they are active. 
  155. * @return array 
  156. */ 
  157. protected function get_active_extensions() { 
  158. return array( 
  159. 'video' => class_exists( 'wpseo_Video_Sitemap' ),  
  160. 'woocommerce' => class_exists( 'Woocommerce' ) && class_exists( 'Yoast_WooCommerce_SEO' ),  
  161. 'news' => class_exists( 'WPSEO_News' ),  
  162. 'local' => defined( 'WPSEO_LOCAL_VERSION' ),  
  163. ); 
  164.  
  165. /** 
  166. * Returns the extensions banner spot. 
  167. * @param array $active_extensions The active extensions. 
  168. * @return WPSEO_Admin_Banner_Spot 
  169. */ 
  170. protected function get_extensions_spot( array $active_extensions ) { 
  171. $extension_spot = new WPSEO_Admin_Banner_Spot( __( 'Extensions', 'wordpress-seo' ), $this->banner_renderer ); 
  172.  
  173. $extension_spot->set_description( 
  174. sprintf( 
  175. /** translators: %1$s expands to a link start tag to the Yoast plugin page, %2$s is the link closing tag. */ 
  176. __( 'Take your SEO to the next level and outrank your competition with our %1$sSEO plugins%2$s.', 'wordpress-seo' ),  
  177. '<a target="_blank" href="' . WPSEO_Shortlinker::get( 'https://yoa.st/jn' ) . '">',  
  178. '</a>' 
  179. ); 
  180.  
  181. if ( empty( $active_extensions['video'] ) ) { 
  182. $extension_spot->add_banner( 
  183. new WPSEO_Admin_Banner( 
  184. WPSEO_Shortlinker::get( 'https://yoa.st/jo' ),  
  185. 'video-seo.png',  
  186. 261,  
  187. 152,  
  188. sprintf( 
  189. /** translators: %1$s expands to Yoast Video SEO. */ 
  190. __( 'Buy the %1$s plugin now and optimize your videos for video search results and social media!', 'wordpress-seo' ),  
  191. 'Yoast Video SEO' 
  192. ); 
  193.  
  194. if ( empty( $active_extensions['woocommerce'] ) ) { 
  195. $extension_spot->add_banner( 
  196. new WPSEO_Admin_Banner( 
  197. WPSEO_Shortlinker::get( 'https://yoa.st/jp' ),  
  198. 'woocommerce-seo.png',  
  199. 261,  
  200. 152,  
  201. sprintf( 
  202. /** translators: %1$s expands to Yoast WooCommerce SEO. */ 
  203. __( 'Buy the %1$s plugin now and optimize your shop today to improve your product promotion!', 'wordpress-seo' ),  
  204. 'Yoast WooCommerce SEO' 
  205. ); 
  206.  
  207. if ( empty( $active_extensions['local'] ) ) { 
  208. $extension_spot->add_banner( 
  209. new WPSEO_Admin_Banner( 
  210. WPSEO_Shortlinker::get( 'https://yoa.st/jq' ),  
  211. 'local-seo.png', 261,  
  212. 152,  
  213. sprintf( 
  214. /** translators: %1$s expands to Yoast Local SEO. */ 
  215. __( 'Buy the %1$s plugin now to improve your site’s Local SEO and ranking in Google Maps!', 'wordpress-seo' ),  
  216. 'Yoast Local SEO' 
  217. ); 
  218.  
  219. if ( empty( $active_extensions['news'] ) ) { 
  220. $extension_spot->add_banner( 
  221. new WPSEO_Admin_Banner( 
  222. WPSEO_Shortlinker::get( 'https://yoa.st/jr' ),  
  223. 'news-seo.png',  
  224. 261,  
  225. 152,  
  226. sprintf( 
  227. /** translators: %1$s expands to Yoast News SEO. */ 
  228. __( 'Buy the %1$s plugin now and start optimizing to get your site featured in Google News!', 'wordpress-seo' ),  
  229. 'Yoast News SEO' 
  230. ); 
  231.  
  232. return $extension_spot; 
  233.  
  234. /** 
  235. * Returns the courses banner spot. 
  236. * @return WPSEO_Admin_Banner_Spot 
  237. */ 
  238. protected function get_courses_spot() { 
  239. $courses_spot = new WPSEO_Admin_Banner_Spot( __( 'Courses', 'wordpress-seo' ), $this->banner_renderer ); 
  240.  
  241. $courses_spot->set_description( 
  242. sprintf( 
  243. /** translators: %1$s expands to a link start tag to the Yoast Services page, %2$s is the link closing tag. */ 
  244. __( 'Do you want to get a grip on your own SEO-strategy? Learn all about it in one of %1$sour courses%2$s.', 'wordpress-seo' ),  
  245. '<a target="_blank" href="' . WPSEO_Shortlinker::get( 'https://yoa.st/jt' ) . '">',  
  246. '</a>' 
  247. ); 
  248.  
  249. $courses_spot->add_banner( 
  250. new WPSEO_Admin_Banner( 
  251. WPSEO_Shortlinker::get( 'https://yoa.st/ju' ),  
  252. 'basic-seo-training.png',  
  253. 261,  
  254. 152,  
  255. __( 'Take the online Basic SEO Training course and learn the fundamentals of SEO!', 'wordpress-seo' ) 
  256. ); 
  257.  
  258. $courses_spot->add_banner( 
  259. new WPSEO_Admin_Banner( 
  260. WPSEO_Shortlinker::get( 'https://yoa.st/jv' ),  
  261. 'yoast-seo-for-wordpress-training.png',  
  262. 261,  
  263. 152,  
  264. sprintf( 
  265. /** translators: %1$s expands to Yoast SEO for WordPress Training, %2$s to Yoast SEO for WordPress. */ 
  266. __( 'Take the %1$s course and become a certified %2$s expert!', 'wordpress-seo' ),  
  267. 'Yoast SEO for WordPress Training',  
  268. 'Yoast SEO for WordPress' 
  269. ); 
  270.  
  271. $courses_spot->add_banner( 
  272. new WPSEO_Admin_Banner( 
  273. WPSEO_Shortlinker::get( 'https://yoa.st/jw' ),  
  274. 'seo-copywriting-training.png',  
  275. 261,  
  276. 152,  
  277. __( 'Take the online SEO Copywriting Training course and learn how to write awesome copy that ranks!', 'wordpress-seo' ) 
  278. ); 
  279.  
  280. $courses_spot->add_banner( 
  281. new WPSEO_Admin_Banner( 
  282. WPSEO_Shortlinker::get( 'https://yoa.st/jx' ),  
  283. 'keyword-research-training.png',  
  284. 261,  
  285. 152,  
  286. __( 'Take the online Keyword Research Training course and learn how to rank with your keywords!', 'wordpress-seo' ) 
  287. ); 
  288.  
  289. $courses_spot->add_banner( 
  290. new WPSEO_Admin_Banner( 
  291. WPSEO_Shortlinker::get( 'https://yoa.st/qy' ),  
  292. 'site-structure-training.png',  
  293. 261,  
  294. 152,  
  295. __( 'Take the online Site Structure Training course and learn how to structure your website!', 'wordpress-seo' ) 
  296. ); 
  297.  
  298. $courses_spot->add_banner( 
  299. new WPSEO_Admin_Banner( 
  300. WPSEO_Shortlinker::get( 'https://yoa.st/jaa' ),  
  301. 'technical-seo-training.png',  
  302. 261,  
  303. 152,  
  304. __( 'Take the online Technical SEO Training course and learn essential technical SEO-concepts!', 'wordpress-seo' ) 
  305. ); 
  306.  
  307. return $courses_spot; 
  308.  
  309. /** 
  310. * Returns the remove banner spot. 
  311. * @return WPSEO_Admin_Banner_Spot 
  312. */ 
  313. protected function get_remove_banner_spot() { 
  314.  
  315. $remove_banner_spot = new WPSEO_Admin_Banner_Spot( 
  316. __( 'Remove these ads?', 'wordpress-seo' ) 
  317. ); 
  318.  
  319. $remove_banner_spot->set_description( 
  320. '<a target="_blank" href="' . WPSEO_Shortlinker::get( 'https://yoa.st/jy' ) . '">' . 
  321. /** translators: %1$s expands to Yoast SEO Premium */ 
  322. sprintf( __( 'Upgrade to %1$s »', 'wordpress-seo' ), 'Yoast SEO Premium' ) . 
  323. '</a>' 
  324. ); 
  325.  
  326. return $remove_banner_spot;