' . esc_html__('Filter by type, status or indexing, edit the rows you need, then save. Filters and pagination are kept. The score filter only applies to the displayed page.', 'multipify-seo-boost') . '
' . esc_html__('The “Explicit noindex” filter shows directives saved on items and the “Force noindex” exceptions. It does not include content excluded only by a global rule.', 'multipify-seo-boost') . '
');
echo ('
');
echo ('
' . esc_html__('The score is calculated on the fly: this filter only acts on the rows already displayed, without changing pagination or the results of other pages.', 'multipify-seo-boost') . '
');
echo ('
' . esc_html__('The “Allow” exception overrides the content type’s default noindex, but does not remove an explicit noindex checked on the item. Bulk actions only affect the selected rows (200 maximum).', 'multipify-seo-boost') . '
';
}
static function save(){
if(!MPSEO_Access::allowed())wp_die(esc_html__('Access denied', 'multipify-seo-boost'));check_admin_referer('mpseo_bulk_save');
$type=isset($_POST['post_type'])&&is_string($_POST['post_type'])?sanitize_key(wp_unslash($_POST['post_type'])):'post';if(!post_type_exists($type)||!is_post_type_viewable($type)||$type==='attachment')$type='post';
if(!empty($_POST['apply_bulk'])){
$selected=isset($_POST['selected'])&&is_array($_POST['selected'])?array_map('absint',wp_unslash($_POST['selected'])):[];$selected=array_slice(array_values(array_filter(array_unique($selected))),0,200);$action=isset($_POST['bulk_action'])&&is_string($_POST['bulk_action'])?sanitize_text_field(wp_unslash($_POST['bulk_action'])):'';
$schemas=['Article','WebPage','Product'];foreach($selected as $id){if(!$id||get_post_type($id)!==$type||!current_user_can('edit_post',$id))continue;if($action==='inherit'){update_post_meta($id,MPSEO_Meta::OV,'default');}elseif($action==='index'){update_post_meta($id,MPSEO_Meta::OV,'index');}elseif($action==='noindex'){update_post_meta($id,MPSEO_Meta::OV,'noindex');}elseif(strpos($action,'schema:')===0){$schema=substr($action,7);if(in_array($schema,$schemas,true))update_post_meta($id,MPSEO_Meta::S,$schema);}}
}else{
$rows=[];if(isset($_POST['rows'])&&is_array($_POST['rows'])){foreach(array_slice(map_deep(wp_unslash($_POST['rows']),'sanitize_text_field'),0,100,true) as $row_id=>$row){if(!is_array($row))continue;$safe=[];foreach(['title','desc','kw','noindex','override'] as $field){if(isset($row[$field])&&is_string($row[$field]))$safe[$field]=sanitize_text_field($row[$field]);}$rows[$row_id]=$safe;}}foreach($rows as $id=>$r){$id=is_scalar($id)?absint($id):0;if(!$id||get_post_type($id)!==$type||!current_user_can('edit_post',$id)||!is_array($r))continue;foreach($r as $field=>$value){if(!in_array($field,['title','desc','kw','noindex','override'],true)||!is_string($value))unset($r[$field]);else $r[$field]=sanitize_text_field($value);}update_post_meta($id,MPSEO_Meta::T,sanitize_text_field($r['title']??''));update_post_meta($id,MPSEO_Meta::D,sanitize_textarea_field($r['desc']??''));update_post_meta($id,MPSEO_Meta::K,sanitize_text_field($r['kw']??''));update_post_meta($id,MPSEO_Meta::N,!empty($r['noindex'])?'1':'0');$override=isset($r['override'])&&is_string($r['override'])?sanitize_key($r['override']):'default';update_post_meta($id,MPSEO_Meta::OV,in_array($override,['default','index','noindex'],true)?$override:'default');}
}
$url=admin_url('admin.php?page=mpseo-bulk&ptype='.$type.'&saved=1');$status=isset($_POST['return_status'])&&is_string($_POST['return_status'])?sanitize_key(wp_unslash($_POST['return_status'])):'all';if(in_array($status,['publish','draft','private'],true))$url=add_query_arg('status',$status,$url);$index_filter=isset($_POST['return_index_filter'])&&is_string($_POST['return_index_filter'])?sanitize_key(wp_unslash($_POST['return_index_filter'])):'all';if(in_array($index_filter,['noindex','exceptions','inherit'],true))$url=add_query_arg('index_filter',$index_filter,$url);$search=isset($_POST['return_search'])&&is_string($_POST['return_search'])?sanitize_text_field(wp_unslash($_POST['return_search'])):'';if($search!=='')$url=add_query_arg('s',$search,$url);$paged=min(100000,max(1,absint(isset($_POST['return_paged'])&&is_scalar($_POST['return_paged'])?wp_unslash($_POST['return_paged']):1)));$per=absint(isset($_POST['return_per_page'])&&is_scalar($_POST['return_per_page'])?wp_unslash($_POST['return_per_page']):20);if(!in_array($per,[10,20,50,100],true))$per=20;$orderby=isset($_POST['return_orderby'])&&is_string($_POST['return_orderby'])?sanitize_key(wp_unslash($_POST['return_orderby'])):'modified';if(!in_array($orderby,['modified','date','title'],true))$orderby='modified';$order=isset($_POST['return_order'])&&is_string($_POST['return_order'])?sanitize_key(wp_unslash($_POST['return_order'])):'desc';if(!in_array($order,['asc','desc'],true))$order='desc';$url=add_query_arg(['paged'=>$paged,'per_page'=>$per,'orderby'=>$orderby,'order'=>$order],$url);wp_safe_redirect($url);exit;
}
}