current_user_has_visible_role() ) { return; }
foreach ( $post_types as $post_type ) {
add_meta_box(
'ait_aipseo_box',
__( 'AI-Powered SEO', 'ai-powered-seo-suggestions' ),
[ $this, 'render' ],
$post_type,
'side',
'high',
array(
'__back_compat_meta_box' => true,
)
);
}
}
public function render( $post, $args ) {
$manual_meta_disabled = AIT_AIPSEO_Settings::get('manual_meta_disabled');
$kws = get_post_meta( $post->ID, 'ait_aipseo_target_keywords', true );
$title = get_post_meta( $post->ID, 'ait_aipseo_meta_title', true );
$desc = get_post_meta( $post->ID, 'ait_aipseo_meta_description', true );
$pro = (bool) apply_filters('ait_aipseo/can_pro', false);
wp_nonce_field( 'ait_aipseo_meta', 'ait_aipseo_meta_nonce' );
?>
ID );
if ( ! empty( $kw_items ) && is_array( $kw_items ) ) : ?>
ID );
if ( ! empty( $fix_items ) && is_array( $fix_items ) ) : ?>
current_user_has_visible_role() ) { return; }
$manual_meta_disabled = AIT_AIPSEO_Settings::get('manual_meta_disabled');
$map = [ 'ait_aipseo_target_keywords' => 'sanitize_text_field' ];
if ( empty( $manual_meta_disabled ) ) {
$map['ait_aipseo_meta_title'] = 'sanitize_text_field';
$map['ait_aipseo_meta_description'] = 'sanitize_textarea_field';
}
foreach ( $map as $key => $cb ) {
if ( isset( $_POST[ $key ] ) ) {
$value = call_user_func( $cb, wp_unslash( $_POST[ $key ] ) );
update_post_meta( $post_id, $key, $value );
}
}
}
private function current_user_has_visible_role(): bool {
$allowed = AIT_AIPSEO_Settings::get('visible_roles');
$user = wp_get_current_user();
if ( empty( $user->roles ) ) {
return false;
}
return (bool) array_intersect( $allowed, (array) $user->roles );
}
}