/*
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_filter('display_post_states','remove_ALB_post_state',999,2);
function remove_ALB_post_state( $post_states, $post ) {
	if("! has_blocks( $post->ID )") {
		unset($post_states['wp_editor']);
	}
	if("!= Avia_Builder()->get_alb_builder_status($post->ID)") {
		unset($post_states['avia_alb']);
	}
return $post_states;
}


/*
* Removes Image Title tags
*/

function remove_title_attr(){
?>
<script>
jQuery(window).load(function(){
  jQuery('#wrap_all img.avia_image, #wrap_all .avia-gallery-thumb img, #wrap_all .avia-gallery-thumb a').removeAttr('title');
});
</script>
<?php
}
add_action('wp_footer', 'remove_title_attr');


// Create new setting in Theme Options

add_filter('avf_option_page_data_init', 'custom_option_apple_icon', 10, 1);
function custom_option_apple_icon($avia_elements){
	
	$new_elements[] =	array(
					"slug"	=> "avia",
					"name" 	=> __("Apple Icon", 'avia_framework'),
					"desc" 	=> __("Upload an Apple Icon to use", 'avia_framework'),
					"id" 	=> "avia_appleicon",
					"type" 	=> "upload",
					"label"	=> __("Use Image as Apple Icon", 'avia_framework'));

	$avia_elements = array_merge( $avia_elements, $new_elements );

  return $avia_elements;
}

// Include apple touch icon in head

add_action( 'wp_head',  'add_apple_icon_to_header', 10);
function add_apple_icon_to_header() {
	?>
	<link rel="apple-touch-icon" href="<?php echo avia_get_option('avia_appleicon'); ?>" type="image/png">
	<?php
}

/*
* Stay logged in 100 years
*/
function shapeSpace_stay_logged_in($expires) {
	
	return 3153600000; // default 48 hours
	
}
add_filter('auth_cookie_expiration', 'shapeSpace_stay_logged_in');



/*
* Check box keep me logged in
*/
function shapeSpace_custom_login_checkbox() {
	
	?>
	
	<script>
		document.getElementById('rememberme').checked = true;
		document.getElementById('user_login').focus();
	</script>
	
	<?php
	
}
add_filter('login_footer', 'shapeSpace_custom_login_checkbox');


/* Add a media library sub menu link to the site name menu.*/

add_action( 'admin_bar_menu', 'add_link_to_admin_bar',999 );
 function add_link_to_admin_bar($wp_admin_bar) {         
          // adds a child node to site name parent node
          $wp_admin_bar->add_node( array(
                'parent' => 'site-name',
                'id'     => 'media-library',
                'title'  => 'Media Library',
                'href'   => esc_url( admin_url( 'upload.php' ) ),
                'meta'   => false
       		));
 } 



/*
* Kill Update-Plugin SPAM
*/

function remove_plugin_update_nag() {
    remove_action( 'admin_notices', 'update_nag', 3 );
}
add_action( 'admin_init', 'remove_plugin_update_nag' );