I’m very new to WordPress improvement. Once I submitted my plugin for evaluation it was rejected as a result of “## Generic operate/class/outline/namespace names”. I’m not capable of perceive tips on how to repair.
Assessment staff mark on a line of cede that’s update_post_meta( $post_id, $meta_field['id'], $_POST[ $meta_field['id'] ] );
I’ve generate code utilizing https://wp-skills.com/instruments/meta-box-generator/Og7AvMWAZGqFjcrQy3Q6
Full code are
class MetaBoxesForVideoTestimonialSliderMetaBox{
personal $display screen = array(
'put up',
);
personal $meta_fields = array(
array(
'label' => 'Designation',
'id' => 'designation',
'default' => 'Adi mother, Grade 8, USA',
'kind' => 'textual content',
),
array(
'label' => 'Nation',
'id' => 'nation',
'default' => 'India',
'kind' => 'choose',
'choices' => array(
'India',
'USA',
'United Kingdom'
)
),
array(
'label' => 'Star Ranking',
'id' => 'star_rating',
'kind' => 'choose',
'choices' => array(
'1',
'2',
'3',
'4',
'5'
)
),
array(
'label' => 'Video URL',
'id' => 'video_url',
'kind' => 'url',
)
);
public operate __construct() {
add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
add_action( 'save_post', array( $this, 'save_fields' ) );
}
public operate add_meta_boxes() {
foreach ( $this->display screen as $single_screen ) {
add_meta_box(
'MetaBoxesForVideoTestimonialSlider',
__( 'MetaBoxesForVideoTestimonialSlider', 'textdomain' ),
array( $this, 'meta_box_callback' ),
$single_screen,
'regular',
'default'
);
}
}
public operate meta_box_callback( $put up ) {
wp_nonce_field( 'MetaBoxesForVideoTestimonialSlider_data', 'MetaBoxesForVideoTestimonialSlider_nonce' );
$this->field_generator( $put up );
}
public operate field_generator( $put up ) {
$output="";
foreach ( $this->meta_fields as $meta_field ) {
$label="<label for="" . $meta_field['id'] . '">' . $meta_field['label'] . '</label>';
$meta_value = get_post_meta( $post->ID, $meta_field['id'], true );
if ( empty( $meta_value ) ) {
if ( isset( $meta_field['default'] ) ) {
$meta_value = $meta_field['default'];
}
}
swap ( $meta_field['type'] ) {
case 'choose':
$enter = sprintf(
'<choose id="%s" identify="%s">',
$meta_field['id'],
$meta_field['id']
);
foreach ( $meta_field['options'] as $key => $worth ) {
$meta_field_value = !is_numeric( $key ) ? $key : $worth;
$enter .= sprintf(
'<possibility %s worth="%s">%s</possibility>',
$meta_value === $meta_field_value ? 'chosen' : '',
$meta_field_value,
$worth
);
}
$enter .= '</choose>';
break;
default:
$enter = sprintf(
'<enter %s id="%s" identify="%s" kind="%s" worth="%s">',
$meta_field['type'] !== 'shade' ? 'model="width: 100%"' : '',
$meta_field['id'],
$meta_field['id'],
$meta_field['type'],
$meta_value
);
}
$output .= $this->format_rows( $label, $enter );
}
echo '<desk class="form-table"><tbody>' . $output . '</tbody></desk>';
}
public operate format_rows( $label, $enter ) {
return '<tr><th>'.$label.'</th><td>'.$enter.'</td></tr>';
}
public operate save_fields( $post_id ) {
if ( ! isset( $_POST['MetaBoxesForVideoTestimonialSlider_nonce'] ) )
return $post_id;
$nonce = $_POST['MetaBoxesForVideoTestimonialSlider_nonce'];
if ( !wp_verify_nonce( $nonce, 'MetaBoxesForVideoTestimonialSlider_data' ) )
return $post_id;
if ( outlined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
return $post_id;
foreach ( $this->meta_fields as $meta_field ) {
if ( isset( $_POST[ $meta_field['id'] ] ) ) {
swap ( $meta_field['type'] ) {
case 'electronic mail':
$_POST[ $meta_field['id'] ] = sanitize_email( $_POST[ $meta_field['id'] ] );
break;
case 'textual content':
$_POST[ $meta_field['id'] ] = sanitize_text_field( $_POST[ $meta_field['id'] ] );
break;
}
update_post_meta( $post_id, $meta_field['id'], $_POST[ $meta_field['id'] ] );
} else if ( $meta_field['type'] === 'checkbox' ) {
update_post_meta( $post_id, $meta_field['id'], '0' );
}
}
}
}
if (class_exists(‘MetaBoxesForVideoTestimonialSliderMetabox’)) {
new MetaBoxesForVideoTestimonialSliderMetabox;
};