/*
Theme Name: Enfold Child
Description: A <a href='http://codex.wordpress.org/Child_Themes'>Child Theme</a> for the Enfold Wordpress Theme. If you plan to do a lot of file modifications we recommend to use this Theme instead of the original Theme. Updating will be much easier then.
Version: 1.0
Author: Kriesi
Author URI: http://www.kriesi.at
Template: enfold
*/



/*Add your own styles here:*/

/* 01 remove-avia-framework-debug-information */
remove_action('wp_head','avia_debugging_info',1000);

/* 04 Automatically set the image Title, Alt-Text, Caption & Description upon upload */
add_action( 'add_attachment', 'ced_add_image_meta_data' );
function ced_add_image_meta_data( $attachment_ID ) {

 $filename   =   $_REQUEST['name']; // or get_post by ID
 $withoutExt =   preg_replace('/\\.[^.\\s]{3,4}$/', '', $filename);
 $withoutExt =   str_replace(array('-','_'), ' ', $withoutExt);

 $my_post = array(
   'ID'           => $attachment_ID,
   'post_excerpt' => $withoutExt,  // caption
   'post_content' => $withoutExt,  // description
 );
 wp_update_post( $my_post );
 // update alt text for post
 update_post_meta($attachment_ID, '_wp_attachment_image_alt', $withoutExt );
}


// 11 Disable loads of Enfold & WP image sizes upon upload

add_action('init', 'remove_enfold_image_sizes');
function remove_enfold_image_sizes() {
remove_image_size('medium_large');
remove_image_size('1536x1536');
remove_image_size('2048x2048');
remove_image_size('widget');
remove_image_size('square');
remove_image_size('featured');
remove_image_size('featured_large');
remove_image_size('extra_large');
remove_image_size('portfolio');
remove_image_size('portfolio_small');
remove_image_size('gallery');
remove_image_size('magazine');
remove_image_size('masonry');
remove_image_size('entry_without_sidebar');
remove_image_size('entry_with_sidebar');
remove_image_size('shop_thumbnail');
remove_image_size('shop_catalog');
remove_image_size('shop_single'); 
remove_image_size('shop_gallery_thumbnail');
}

/* Force Wordpress to Show Pages Instead of Category */
function wpa_alter_cat_links( $termlink, $term, $taxonomy ){
    if( 'category' == $taxonomy && 0 == $term->parent ){
        return str_replace( '/category', '', $termlink );
    }
    return $termlink;
}
add_filter( 'term_link', 'wpa_alter_cat_links', 10, 3 );



