/admin/class-cornerstone-field.php

  1. <?php 
  2. /** 
  3. * @package WPSEO\Admin 
  4. */ 
  5.  
  6. /** 
  7. * Adds a checkbox to the focus keyword section. 
  8. */ 
  9. class WPSEO_Cornerstone_Field { 
  10.  
  11. /** 
  12. * Returns a label with a checkbox in it. Make it possible to mark the page as cornerstone content. 
  13. * 
  14. * @param WP_POST $post The post object. 
  15. * 
  16. * @return string The HTML to show. 
  17. */ 
  18. public function get_html( $post ) { 
  19. $return = ''; 
  20. $return .= sprintf( 
  21. '<input id="%1$s" class="wpseo-cornerstone-checkbox" type="checkbox" value="1" name="%1$s" %2$s/>',  
  22. WPSEO_Cornerstone::META_NAME,  
  23. checked( $this->get_meta_value( $post->ID ), '1', false ) 
  24. ); 
  25.  
  26. $return .= sprintf( '<label for="%1$s">', WPSEO_Cornerstone::META_NAME ); 
  27.  
  28. /** translators: 1: link open tag; 2: link close tag. */ 
  29. $return .= sprintf( 
  30. __( 'This article is %1$scornerstone content%2$s', 'wordpress-seo' ),  
  31. '<a href="' . WPSEO_Shortlinker::get( 'https://yoa.st/metabox-help-cornerstone' ) . '" target="_blank">',  
  32. '</a>' 
  33. ); 
  34. $return .= '</label>'; 
  35.  
  36. return $return; 
  37.  
  38. /** 
  39. * Gets the meta value from the database. 
  40. * 
  41. * @param int $post_id The post id to get the meta value for. 
  42. * 
  43. * @return null|string The meta value from the database. 
  44. */ 
  45. protected function get_meta_value( $post_id ) { 
  46. return get_post_meta( $post_id, WPSEO_Cornerstone::META_NAME, true ); 
.