this version of the php is better looking/working
/* image SEO reminder class
by serge liatko
updated version 0.2
*/
class image_seo_reminder {
private $allowed = array(
'a' => array(
'class' => array(),
'href' => array(),
'rel' => array(),
'title' => array(),
'target' => array()),
'span' => array(
'class' => array(),
'title' => array()),
'em' => array(),
'strong' => array(),
'u' => array(),
'code' => array(),
'sup' => array(),
'sub' => array(),
'cite' => array(),
'strike' => array(),
'br' => array()
);
public function __construct() {
add_action('admin_init',array($this,'admin_init'),99,0);
}
public function admin_init() {
add_filter("attachment_fields_to_edit", array($this,"alt_text_field_reminder"), 15, 1);
add_filter( "manage_media_columns", array($this,'img_columns'),10,1);
add_action('manage_media_custom_column',array($this,'print_img_columns'),10,2);
}
public function img_columns($columns) {
$columns['image_alt'] = __('Alternate Text');
$columns['post_excerpt'] = __('Caption');
return $columns;
}
public function print_img_columns($name, $post_id) {
$attachment = get_post($post_id);
if(!is_object($attachment) || is_wp_error($attachment)) return;
if(substr($attachment->post_mime_type, 0, 5) == 'image') {
switch($name) {
case 'image_alt' :
$none = '<span style="color:#dd0000;">'. __('Empty') .'</span>';
$alt = stripslashes(get_post_meta($post_id, '_wp_attachment_image_alt', true ));
echo !empty($alt) ? $alt : $none;
break;
case 'post_excerpt' :
echo (!empty($attachment->post_excerpt)) ? trim(wptexturize(wp_kses(stripslashes($attachment->post_excerpt), $this->allowed))) : '' ;
break;
}
}
}
public function alt_text_field_reminder($form_fields) {
if (isset($form_fields['image_alt']) && is_array($form_fields['image_alt']) && isset($form_fields['image_alt']['helps'])) {
$form_fields['image_alt']['helps'] = __('Alt text is <strong>mandatory</strong> if you care about SEO of your website!','ewpfi_lang') . ' <a href="http://wordpress.org/extend/ideas/topic/auto-populate-alternative-text-to-match-title-unless-otherwise-specified/" target="_blank">'. __('Read More') .'</a>';
$form_fields['image_alt']['required'] = true;
}
return $form_fields;
}
}
$image_seo_reminder = new image_seo_reminder ;