A problem with no object in class-mb-yoast-seo.php
Support › MB Yoast SEO Integration › A problem with no object in class-mb-yoast-seo.phpResolved
- This topic has 2 replies, 3 voices, and was last updated 3 years, 9 months ago by
Ole Poetter.
-
AuthorPosts
-
June 17, 2021 at 7:32 PM #28964
Alexandre Siqueira siqale
ParticipantI don't use Yoast in my project. I have this message on front end form submission to a especific post type:
Notice: Trying to get property 'base' of non-object in /var/www/html/wp-content/plugins/meta-box-aio/vendor/meta-box/mb-yoast-seo/class-mb-yoast-seo.php on line 22
<?php
class MB_Yoast_SEO {
/**
* Store IDs of fields that need to analyze content.
*
* @var array
*/
protected $fields = array();/**
* Enqueue plugin script.
*
* @param RW_Meta_Box $meta_box The meta box object.
*/
public function enqueue( RW_Meta_Box $meta_box ) {// Use helper function to get correct URL to current folder, which can be used in themes/plugins.
list( , $url ) = RWMB_Loader::get_path( dirname( __FILE__ ) );// Only for posts.
$screen = get_current_screen();
if ( 'post' !== $screen->base ) {
return;
} /// the bug is here// Get all field IDs that adds content to Yoast SEO analyzer.
$this->add_fields( $meta_box->fields );if ( empty( $this->fields ) ) {
return;
}wp_enqueue_script( 'mb-yoast-seo', $url . 'script.js', array( 'jquery', 'yoast-seo-post-scraper' ), '1.3.1', true );
// Send list of fields to JavaScript.
wp_localize_script( 'mb-yoast-seo', 'MBYoastSEO', $this->fields );
}/**
* Add group of fields.
*
* @param array $fields Array of fields.
*/
protected function add_fields( $fields ) {
array_walk( $fields, array( $this, 'add_field' ) );
}/**
* Add a single field.
*
* @param array $field Field parameters.
*/
protected function add_field( $field ) {
if ( empty( $field['id_attr'] ) ) {
$field['id_attr'] = $field['id'];
}// Add sub-fields recursively.
if ( isset( $field['fields'] ) ) {
foreach ( $field['fields'] as &$sub_field ) {
$sub_field['id_attr'] = $field['id_attr'] . '_' . $sub_field['id'];
}
$this->add_fields( $field['fields'] );
}// Add the single field.
if ( $this->is_analyzable( $field ) ) {
$this->fields[] = $field['id_attr'];
}
}/**
* Check if field content is analyzable by Yoast SEO.
*
* @param array $field Field parameters.
*
* @return bool
*/
protected function is_analyzable( $field ) {
return ! in_array( $field['id'], $this->fields, true ) && ! empty( $field['add_to_wpseo_analysis'] );
}
}I'm not intent install the Yoast plugin and I would like that this message do not show. The form works perfectly. I updated the MetaBox plugin, but the message still there.
June 17, 2021 at 10:10 PM #28970Long Nguyen
ModeratorHi,
Thank you for your feedback.
I've escalated this issue to the development team to fix it in the next update.
July 28, 2021 at 1:56 AM #29737Ole Poetter
ParticipantWhen is the ETA of this fix in Meta Box AIO?
-
AuthorPosts
- You must be logged in to reply to this topic.