/wp-content/plugins/wordpress-seo/admin/class-cornerstone-field.php
https://bitbucket.org/carloskikea/helpet · PHP · 57 lines · 26 code · 8 blank · 23 comment · 2 complexity · cbb59bd04c1c2fe2d4a6af62478725ed MD5 · raw file
- <?php
- /**
- * WPSEO plugin file.
- *
- * @package WPSEO\Admin
- */
- /**
- * Adds a checkbox to the focus keyword section.
- */
- class WPSEO_Cornerstone_Field {
- /**
- * Returns a label with a checkbox in it. Make it possible to mark the page as cornerstone content.
- *
- * @param WP_POST $post The post object.
- *
- * @return string The HTML to show.
- */
- public function get_html( $post ) {
- $post_types = apply_filters( 'wpseo_cornerstone_post_types', WPSEO_Post_Type::get_accessible_post_types() );
- if ( ! is_array( $post_types ) || ! isset( $post_types[ get_post_type( $post ) ] ) ) {
- return '';
- }
- $return = '';
- $return .= sprintf(
- '<input id="%1$s" class="wpseo-cornerstone-checkbox" type="checkbox" value="1" name="%1$s" %2$s/>',
- WPSEO_Cornerstone::FIELD_NAME,
- checked( $this->get_meta_value( $post->ID ), '1', false )
- );
- $return .= sprintf( '<label for="%1$s">', WPSEO_Cornerstone::FIELD_NAME );
- $return .= sprintf(
- /* translators: 1: link open tag; 2: link close tag. */
- __( 'This article is %1$scornerstone content%2$s', 'wordpress-seo' ),
- '<a href="' . WPSEO_Shortlinker::get( 'https://yoa.st/metabox-help-cornerstone' ) . '" target="_blank">',
- '</a>'
- );
- $return .= '</label>';
- return $return;
- }
- /**
- * Gets the meta value from the database.
- *
- * @param int $post_id The post id to get the meta value for.
- *
- * @return null|string The meta value from the database.
- */
- protected function get_meta_value( $post_id ) {
- return WPSEO_Meta::get_value( WPSEO_Cornerstone::META_NAME, $post_id );
- }
- }