Add Yoast SEO analyzer text tool to custom metabox editor wp

Question

I need to add Yoast SEO analysis tool content text of textarea editor who is below, like this image

enter image description here

to custom editor, i have a custom textarea editor meta box, this is the code

function rohitink_add_meta_box() {
   add_meta_box(
      'rohitink-meta',
      __( 'My Meta Box Title', 'text-domain' ),
      'rohitink_meta_html',
      'post', //Post Type
      'normal', //Location
      'high' //Priority
   ); 
}
add_action( 'add_meta_boxes', 'rohitink_add_meta_box', 1 );

function rohitink_meta_html( $post) {
   wp_nonce_field( '_rohitink_meta_nonce', 'rohitink_meta_nonce' ); ?>
        <p>
      <label for="rohitink_meta_content"><?php _e( 'My Textarea', 'text-domain' ); ?></label><br>
      <textarea name="rohitink_meta_content" id="rohitink_meta_content"><?php echo rohitink_get_meta( 'rohitink_meta_content' ); ?>"></textarea>
   </p>
<? } //endfunction ?>

function rohitink_get_meta( $value ) {
   global $post;

   $field = get_post_meta( $post->ID, $value, true );
   if ( ! empty( $field ) ) {
      return is_array( $field ) ? stripslashes_deep( $field ) : stripslashes( wp_kses_decode_entities( $field ) );
   } else {
      return false;
   }
}

function rohitink_meta_save( $post_id ) {
   if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
   if ( ! isset( $_POST['rohitink_meta_nonce'] ) || ! wp_verify_nonce( $_POST['rohitink_meta_nonce'], '_rohitink_meta_nonce' ) ) return;
   
   if ( ! current_user_can( 'edit_post', $post_id ) ) return;

   if ( isset( $_POST['rohitink_meta_content'] ) )
      update_post_meta( $post_id, 'rohitink_meta_content', esc_attr( $_POST['rohitink_meta_content'] ) );
}
add_action( 'save_post', 'rohitink_meta_save' );

How add Yoast SEO analyzer text tool to custom metabox editor wp?

Note: the plugin can be anything seo plugin, Yoast SEO is just a example

0
user3185638 7 months 2021-05-18T06:05:09-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse