<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

// WIDGETS
// To ensure that the output of our shortcode callback is not wrapped in paragraph tags
add_filter( 'widget_text', 'shortcode_unautop');
// Enable the use of shortcodes in text widgets.
add_filter( 'widget_text', 'do_shortcode' );
// Add "first" and "last" CSS classes to dynamic sidebar widgets
add_filter('dynamic_sidebar_params','widget_first_last_classes');

/* MENU */
// add first and last class to menus
add_filter('wp_nav_menu_objects', 'add_first_and_last_menu_class');
// add slug class to menu item
add_filter( 'wp_nav_menu_objects', 'add_menu_slug_class' );
// add current_page_parent class to singular custom post-types (ingredients)
add_filter( 'nav_menu_css_class', 'wp_custom_nav_classes', 10, 2 );
// add class to menu links
add_filter( 'nav_menu_link_attributes', 'custom_link_atts');

// Move Yoast to bottom
add_filter( 'wpseo_metabox_prio', 'yoasttobottom');

//add_action( 'template_redirect', 'custom_page_template_redirect' );

// customize login screen
add_action( 'login_enqueue_scripts', 'my_login_logo' );
add_filter( 'login_headerurl', 'my_login_logo_url' );
add_filter( 'login_headertitle', 'my_login_logo_url_title' );

// keep emoticons as text
add_filter('option_use_smilies', function(){ return false; });

// Register our callback to the appropriate filter
add_filter('mce_buttons_2', 'my_mce_buttons_2');
// initialize custom tinymce settings
add_filter('tiny_mce_before_init', 'wp_custom_tinymce_settings' );

// add custom classes to body
add_filter( 'body_class', 'custom_body_classes' );

// add classes to posts
add_filter( 'post_class', 'post_classes' );

// add custom image size to admin media library 
add_filter( 'image_size_names_choose', 'my_custom_sizes' );

// disable emoji
add_action( 'init', 'disable_emojis' );

// odstranimo linke iz headerja
remove_action( 'wp_head', 'feed_links_extra', 3 ); // Display the links to the extra feeds such as category feeds
remove_action( 'wp_head', 'feed_links', 2 ); // Display the links to the general feeds: Post and Comment Feed
remove_action( 'wp_head', 'rsd_link' ); // Display the link to the Really Simple Discovery service endpoint, EditURI link
remove_action( 'wp_head', 'wlwmanifest_link' ); // Display the link to the Windows Live Writer manifest file.
remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); // prev link
remove_action( 'wp_head', 'start_post_rel_link', 10, 0 ); // start link
remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 ); // Display relational links for the posts adjacent to the current post.
// odstrani name="framework" ki ga da capabillity manager - capsman
remove_action('wp_head', '_ak_framework_meta_tags');

// preconnect for Google Fonts.
add_filter( 'wp_resource_hints', 'custom_resource_hints', 10, 2 );

// custom pre_get_posts functions
add_filter('pre_get_posts', 'custom_pre_get_posts_options');

// remove automatic adding of paragraphs in widgets
//remove_filter('widget_text_content', 'wpautop');

// Hardcode gallery output
add_filter('post_gallery', 'wp_custom_post_gallery', 10, 2);

// add active link to widget archives
add_filter('get_archives_link', 'theme_get_archives_link');

// add inline script
//add_action( 'wp_enqueue_scripts', 'theme_prefix_enqueue_script' );

// add attribute to foogallery images to show next/prev buttons and group images together
add_filter('foogallery_attachment_html_link_attributes', 'add_foogallery_link_rel', 10, 3);

// remove font awesome from front end
add_action( 'wp_print_styles', 'custom_dequeue_font_awesome_style' );

// redirect on page edit when post is published
//add_filter('redirect_post_location', 'redirect_to_post_on_publish_or_save');

// add custom query vars
add_filter( 'query_vars', 'add_custom_query_vars_filter' );

// remove archive title labels
add_filter( 'get_the_archive_title', 'remove_archive_title_labels' );

// remove shortcode p wraps
add_filter('the_content', 'wp_custom_clean_shortcodes');