esc_html__( 'Blog Sidebar', 'adena'),
'id' => 'un-blog-sidebar',
'before_widget' => '
',
'after_widget' => '',
'before_title' => '',
'after_title' => '
',
);
register_sidebar( $un_blog_sidebar );
// Page Sidebar
$un_page_sidebar = array(
'name' => esc_html__( 'Page Sidebar', 'adena'),
'id' => 'un-page-sidebar',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '
',
);
register_sidebar( $un_page_sidebar );
// Shop Sidebar
if ( class_exists( 'WooCommerce' ) ) {
$un_shop_sidebar = array(
'name' => esc_html__('Shop Sidebar', 'adena'),
'id' => 'un-shop-sidebar',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '
',
);
register_sidebar($un_shop_sidebar);
}
// Dynamic Sidebars
$all_sidebars = un_redux_opt( UN, 'sidebars' );
if( count($all_sidebars) > 0 ){
$all_sidebars = un_redux_build_repeater( $all_sidebars );
foreach( $all_sidebars as $sidebar ){
if( $sidebar['title'] ) {
register_sidebar(
array(
'name' => $sidebar['title'],
'id' => sanitize_title( $sidebar['title'] ),
'description' => $sidebar['description'],
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '
',
)
);
}
}
}
// User Profile Socials
add_filter('user_contactmethods', 'un_user_profile_socials');
function un_user_profile_socials($profile_fields) {
// Add new fields
$profile_fields['twitter'] = esc_html__('Twitter URL', 'adena');
$profile_fields['facebook'] = esc_html__('Facebook URL', 'adena');
$profile_fields['googleplus'] = esc_html__('Google+ URL', 'adena');
$profile_fields['instagram'] = esc_html__('Instagram URL', 'adena');
$profile_fields['pinterest'] = esc_html__('Pinterest URL', 'adena');
$profile_fields['rss'] = esc_html__('RSS URL', 'adena');
return $profile_fields;
}
// Enable HTML in Author Description
remove_filter('pre_user_description', 'wp_filter_kses');
add_filter( 'pre_user_description', 'wp_filter_post_kses');
// WP_HEAD Custom Code
add_action( 'wp_head', 'un_head_custom_code' );
function un_head_custom_code() {
un_echo( un_redux_opt(UN, 'opt_adv_head_code'), 'full' );
}
// WP_FOOTER Custom Code
add_action( 'wp_footer', 'un_footer_custom_code' );
function un_footer_custom_code() {
un_echo( un_redux_opt(UN, 'opt_adv_foot_code'), 'full' );
}
// BODY additional classes
add_filter( 'body_class', 'un_body_classes' );
function un_body_classes( $classes ) {
global $is_redirect;
if( un_redux_opt(UN, 'opt_adv_loading')) {
$classes[] = 'loading';
}
// Menu
$menu_data = un_menu_type();
$head_data = un_page_head_builder();
if( $head_data['height'] != '100vh' && !$is_redirect ) {
$classes[] = $menu_data['body_class'];
}
return $classes;
}
/*************/
/* BASIC SEO */
/*************/
add_filter( 'wp_title', 'un_wp_title', 10, 2 );
function un_wp_title( $title, $sep ) {
if ( is_feed() ) {
return $title;
}
global $page, $paged;
$sep = ' - ';
// If Home
if( is_home() || is_front_page() ) {
return esc_html__( 'Home', 'adena') . $sep . get_bloginfo( 'description' );
}
// Add a page number if necessary:
if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) {
$title .= $sep . sprintf( esc_html__( 'Page %s', 'adena'), max( $paged, $page ) );
}
return $title;
}
/************************/
/* POSTS THUMB IN ADMIN */
/************************/
// Register thumb column
add_filter( 'manage_edit-post_columns', 'un_thumb_post_column_register' );
function un_thumb_post_column_register( $columns ) {
$columns['thumb'] = esc_html__( 'Thumbnail', 'adena' );
return $columns;
}
// Display thumb column content
add_action( 'manage_post_posts_custom_column', 'un_thumb_post_column_display', 10, 2 );
function un_thumb_post_column_display( $column_name, $post_id ) {
if ( 'thumb' != $column_name ){
return;
}
un_echo( un_post_thumbnail($post_id, 80, 60, true, true, UN_THEME_URI.'/assets/img/placeholder_80x60.png'), 'html' );
}
// ARCHIVE TITLE CUSTOMIZATION
add_filter( 'get_the_archive_title', function ( $title ) {
if ( is_category() ) {
$title = single_cat_title( '', false );
} elseif ( is_tag() ) {
$title = single_tag_title( '', false );
} elseif ( is_author() ) {
$title = get_the_author();
} elseif ( is_year() ) {
$title = get_the_date( _x( 'Y', 'yearly archives date format', 'adena' ) );
} elseif ( is_month() ) {
$title = get_the_date( _x( 'F Y', 'monthly archives date format', 'adena' ) );
} elseif ( is_day() ) {
$title = get_the_date( _x( 'F j, Y', 'daily archives date format', 'adena' ) );
}
return $title;
});
}
//******************//
// WP GALLERY SETUP //
//******************//
add_filter( 'post_gallery', 'un_post_gallery', 10, 2 );
function un_post_gallery($output, $attr){
$output = '';
// Columns
if( !isset($attr['columns']) ){
$attr['columns'] = 3;
}
switch( $attr['columns'] ){
case '1':
$col_class = 'col-xl-12';
break;
case '2':
$col_class = 'col-xl-6';
break;
case '3':
$col_class = 'col-xl-4 col-s-6';
break;
case '4':
$col_class = 'col-xl-3 col-m-4 col-s-6';
break;
case '6':
$col_class = 'col-xl-2 col-l-3 col-m-4 col-s-6';
break;
default:
$col_class = 'col-xl-4 col-s-6';
break;
}
// Query
$attachments = array();
if ( isset($attr['ids']) && !empty($attr['ids']) ) {
// Check IDs
$ids = preg_replace( '/[^0-9,]+/', '', $attr['ids'] );
// Ordering
if ( isset($attr['orderby']) && 'rand' == $attr['orderby'] ) {
$_attachments = get_posts( array('include' => $ids, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'rand') );
foreach ( $_attachments as $key => $val ) {
$attachments[$val->ID] = $_attachments[$key];
}
}else{
$ids = explode( ',', $ids);
foreach ( $ids as $id ) {
$_attachments = get_posts( array('include' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image') );
$attachments[$id] = $_attachments[0];
}
}
}
if( count($attachments) > 0 ){
$output .= '
';
}
return $output;
}