'fff',
'width' => 1379,
'height' => 570,
'flex-width' => true,
'flex-height' => true,
'default-image' => '',
'upload' => true,
'wp-head-callback' => '',
);
$args = apply_filters( 'passport_custom_header_args', $args );
add_theme_support( 'custom-header', $args );
}
}
add_action( 'after_setup_theme', 'passport_custom_header_setup' );
/**
* Setup the WordPress core custom background feature.
* ------------------------------------------------------------------------
* Use add_theme_support to register support for WordPress 3.4+
* Hooks into the after_setup_theme action.
*
* @since Passport 1.0
*
*/
if( ! function_exists( 'passport_register_custom_background' ) ) {
function passport_register_custom_background() {
$args = array(
'default-color' => 'f1f1f1',
'default-repeat' => 'no-repeat',
'default-position-x' => '',
'default-attachment' => 'fixed',
'wp-head-callback' => '_custom_background_cb',
'admin-head-callback' => '',
'admin-preview-callback' => ''
);
$args = apply_filters( 'passport_custom_background_args', $args );
add_theme_support( 'custom-background', $args );
}
}
add_action( 'after_setup_theme', 'passport_register_custom_background' );
/**
* Setup the WordPress core custom.
* ------------------------------------------------------------------------
* Use add_theme_support to register support for WordPress 3.4+
* Hooks into the after_setup_theme action.
*
* @since Passport 1.0
*
*/
if( ! function_exists( 'passport_custom_theme_setup' ) ) {
function passport_custom_theme_setup() {
// Add default posts and comments RSS feed links to head.
add_theme_support( 'automatic-feed-links' );
/*
* Let WordPress manage the document title.
* By adding theme support, we declare that this theme does not use a
* hard-coded
tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
/*
* Enable support for Post Thumbnails on posts and pages.
*
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
*/
add_theme_support( 'post-thumbnails' );
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support( 'html5', array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
) );
/* Adds post formats to theme. */
add_theme_support(
'post-formats',
array(
'aside',
'link',
'quote',
'image',
'gallery',
'audio',
'video'
)
);
}
}
add_action( 'after_setup_theme', 'passport_custom_theme_setup', 20 );
/**
* Enqueue the front-end script and style function
* ------------------------------------------------------------------------
* Function to enqueue the front-end scrip and style.
*
*
* @since passport 1.0
*
*/
if( ! function_exists( 'passport_adding_script' ) ) {
function passport_adding_scripts() {
global $wp_styles;
/**
* Front end Scripts
*/
/*Comment Reply*/
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
/* bootstrap */
wp_enqueue_script(
PASSPORT_THEME_SLUG . '-bootstrap',
get_template_directory_uri() . '/assets/third-party/bootstrap/dist/js/bootstrap.min.js',
array(
'jquery'
),
'3.3.4',
true
);
/* Masonry and ImagesLoaded */
wp_enqueue_script(
PASSPORT_THEME_SLUG . '-masonry',
get_template_directory_uri() . '/assets/third-party/masonry/dist/masonry.pkgd.min.js',
array(
'jquery',
PASSPORT_THEME_SLUG . '-bootstrap'
),
'3.2',
true
);
/* Images loaded */
wp_enqueue_script(
PASSPORT_THEME_SLUG . '-imagesloaded',
get_template_directory_uri() . '/assets/third-party/imagesloaded/imagesloaded.pkgd.min.js',
array(
'jquery',
PASSPORT_THEME_SLUG . '-bootstrap',
PASSPORT_THEME_SLUG . '-masonry'
),
'3.1.8',
true
);
/* Imagefill */
wp_enqueue_script(
PASSPORT_THEME_SLUG . '-imagefill',
get_template_directory_uri() . '/assets/third-party/imagefill/js/jquery-imagefill.js',
array(
'jquery',
PASSPORT_THEME_SLUG . '-imagesloaded'
),
'1.0.0',
true
);
/* Owl */
wp_enqueue_script(
PASSPORT_THEME_SLUG . '-owl-carousel',
get_template_directory_uri() . '/assets/third-party/owl.carousel/owl.carousel.min.js',
array(
'jquery'
),
'2.0.0',
true
);
/* Like Post */
wp_enqueue_script(
PASSPORT_THEME_SLUG . '-simple-likes-public-js',
get_template_directory_uri() . '/assets/js/simple-likes-public.js',
array(
'jquery'
),
'0.5',
true
);
/*Simple Like Script*/
wp_localize_script(
PASSPORT_THEME_SLUG . '-simple-likes-public-js',
'simpleLikes',
array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'like' => esc_html__( 'Like', 'passport' ),
'unlike' => esc_html__( 'Unlike', 'passport' )
)
);
/* Typed.js */
wp_enqueue_script(
PASSPORT_THEME_SLUG . '-typed',
get_template_directory_uri() . '/assets/js/typed.js',
array(
'jquery'
),
'1.1.4',
true
);
wp_localize_script(
PASSPORT_THEME_SLUG . '-typed',
'site',
array(
'sitename' => get_bloginfo()
)
);
$facebook_id = get_theme_mod( 'passport_facebook_app_id', '' );
/* Social Media */
wp_enqueue_script(
PASSPORT_THEME_SLUG . '-social_media-js',
get_template_directory_uri().'/assets/js/social-media.js',
array(
'jquery'
),
PASSPORT_VERSION,
true
);
wp_localize_script(
PASSPORT_THEME_SLUG . '-social_media-js',
'facebook',
array(
'app_id' => $facebook_id
),
PASSPORT_VERSION
);
/*Setup*/
wp_register_script(
PASSPORT_THEME_SLUG . '-setup-script-js',
get_template_directory_uri() . '/assets/js/setup.js',
array(
'jquery'
),
PASSPORT_VERSION,
true
);
wp_enqueue_script( PASSPORT_THEME_SLUG . '-setup-script-js' );
/*Slider*/
wp_register_script(
PASSPORT_THEME_SLUG . '-slider-js',
get_template_directory_uri() . '/assets/js/slider.js',
array(
'jquery'
),
PASSPORT_VERSION,
true
);
wp_enqueue_script( PASSPORT_THEME_SLUG . '-slider-js' );
/**
* Front end Styles
*/
/*Bootstrap*/
wp_enqueue_style(
'bootstrap',
get_template_directory_uri() . '/assets/third-party/bootstrap/dist/css/bootstrap.css',
array(),
'3.3.4'
);
/*Google Fonts*/
wp_enqueue_style(
PASSPORT_THEME_SLUG . '-google-fonts',
'https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Handlee',
array(),
PASSPORT_VERSION
);
/* FontAwesome */
wp_enqueue_style(
PASSPORT_THEME_SLUG . '-font-awesome',
get_template_directory_uri() . '/assets/third-party/font-awesome-4.5.0/css/font-awesome.css',
array(),
'4.5.0'
);
/* Owl Carousel */
wp_enqueue_style(
PASSPORT_THEME_SLUG . '-owl-carousel',
get_template_directory_uri() . '/assets/third-party/owl.carousel/assets/owl.carousel.css',
array(),
'2.0.0'
);
/*Typography*/
wp_register_style(
PASSPORT_THEME_SLUG . '-typography',
get_template_directory_uri() . '/assets/css/typography.css',
array(),
PASSPORT_VERSION
);
wp_enqueue_style( PASSPORT_THEME_SLUG . '-typography' );
/*Layout*/
wp_register_style(
PASSPORT_THEME_SLUG . '-layout',
get_template_directory_uri() . '/assets/css/layout.css',
array(),
PASSPORT_VERSION
);
wp_enqueue_style( PASSPORT_THEME_SLUG . '-layout' );
/*Module*/
wp_register_style(
PASSPORT_THEME_SLUG . '-module',
get_template_directory_uri() . '/assets/css/module.css',
array(),
PASSPORT_VERSION
);
wp_enqueue_style( PASSPORT_THEME_SLUG . '-module' );
/* Responsive */
wp_enqueue_style(
PASSPORT_THEME_SLUG . '-responsive',
get_template_directory_uri() . '/assets/css/responsive.css',
array(),
PASSPORT_VERSION
);
}
}
add_action( 'wp_enqueue_scripts', 'passport_adding_scripts' );
/**
* Child theme stylesheet function.
* ------------------------------------------------------------------------
* Load parent stylesheet first, then load active theme stylesheet.
*
*
* @since passport 1.0
*
*/
if( ! function_exists( 'passport_childtheme_style' ) ) {
function passport_childtheme_style() {
if ( is_child_theme() ) {
// load parent stylesheet first if this is a child theme
wp_enqueue_style(
PASSPORT_THEME_SLUG . 'parent-stylesheet',
trailingslashit( get_template_directory_uri() ) . 'style.css',
PASSPORT_VERSION,
false
);
}
// load active theme stylesheet in both cases
wp_enqueue_style(
PASSPORT_THEME_SLUG . '-theme-stylesheet',
get_stylesheet_uri(),
PASSPORT_VERSION,
false
);
}
}
add_action( 'wp_enqueue_scripts', 'passport_childtheme_style' );
/**
* Enqueue the custom style function
* ------------------------------------------------------------------------
* Function to enqueue the custom style.
*
*
* @since passport 1.0
*
*/
if( ! function_exists( 'passport_custom_style' ) ) {
function passport_custom_style() {
/* Custom Inline Style - Please do not delete this file. */
wp_enqueue_style(
PASSPORT_THEME_SLUG . '-custom-style',
get_template_directory_uri() . '/assets/css/custom-style.css',
array(),
PASSPORT_VERSION
);
}
}
add_action( 'wp_enqueue_scripts', 'passport_custom_style' );
/**
* Enqueue the theme customizer function
* ------------------------------------------------------------------------
* Function to enqueue the theme customizer
*
*
* @since passport 1.0
*
*/
if( ! function_exists( 'passport_theme_customizer' ) ) {
function passport_theme_customizer() {
wp_register_script(
PASSPORT_THEME_SLUG . '-theme-customizer',
get_template_directory_uri() . '/assets/js/theme-customizer.js',
array(
'jquery',
'customize-preview'
),
PASSPORT_VERSION,
true
);
wp_enqueue_script( PASSPORT_THEME_SLUG . '-theme-customizer' );
}
}
add_action( 'customize_preview_init', 'passport_theme_customizer' );
/**
* Enqueue the admin script function
* ------------------------------------------------------------------------
* Function to enqueue the admin script and style.
*
*
* @since passport 1.0
*
*/
if( ! function_exists( 'passport_admin_script' ) ) {
function passport_admin_script(){
/*jQuery UI*/
wp_enqueue_style(
'jquery-ui',
get_template_directory_uri() . '/assets/third-party/jquery-ui-1.11.4/jquery-ui.min.css',
array(),
'1.11.4'
);
wp_enqueue_script(
'jquery-ui',
get_template_directory_uri() . '/assets/third-party/jquery-ui-1.11.4/jquery-ui.min.js',
array(
'jquery'
),
'1.11.4',
true
);
/*Media*/
wp_enqueue_media();
wp_enqueue_style( 'thickbox' );
wp_enqueue_script( 'thickbox' );
/* Media Upload */
wp_register_script(
PASSPORT_THEME_SLUG . '-wp-media-upload',
get_template_directory_uri().'/assets/js/wp-media-upload.js',
array(
'jquery',
'thickbox'
),
PASSPORT_VERSION,
true
);
wp_enqueue_script( PASSPORT_THEME_SLUG . '-wp-media-upload' );
/* Color Picker */
wp_enqueue_style( 'wp-color-picker' );
wp_enqueue_script( 'wp-color-picker' );
wp_enqueue_script(
PASSPORT_THEME_SLUG . '-wp-color-picker-settings',
get_template_directory_uri() . '/assets/js/colorpicker.js',
array(
'jquery'
),
'1.11.4',
true
);
/*Google Fonts*/
wp_enqueue_style(
PASSPORT_THEME_SLUG . '-google-fonts',
'https://fonts.googleapis.com/css?family=Roboto+Condensed|Roboto+Mono|Roboto+Slab|Reenie+Beanie|Handlee|Roboto|Pacifico:400,400italic,700,700italic',
array(),
PASSPORT_VERSION
);
/*Admin Script*/
wp_enqueue_script(
PASSPORT_THEME_SLUG . '-admin-script',
get_template_directory_uri() . '/assets/js/admin-script.js',
array(
'jquery',
'jquery-ui',
'wp-color-picker',
PASSPORT_THEME_SLUG . '-wp-color-picker-settings'
),
PASSPORT_VERSION,
true
);
/* Admin */
wp_enqueue_style(
PASSPORT_THEME_SLUG . '-admin',
get_template_directory_uri() . '/assets/css/admin.css',
array(),
PASSPORT_VERSION
);
}
}
add_action( 'admin_enqueue_scripts', 'passport_admin_script' );
/**
* Define Global Variables
* -------------------------------------------------------------------------
*
* @package WordPress
* @subpackage themevilles
* @since themevilles 1.0
*
*/
function passport_global_variables() {
global $passport_number;
global $passport_theme_setting;
global $passport_headline_column;
global $passport_headline_sidebar_position;
global $passport_headline_sidebar_width;
global $passport_front_page_column;
global $passport_blog_content_column;
global $passport_blog_sidebar_position;
global $passport_blog_sidebar_width;
global $passport_page_content_column;
global $passport_page_sidebar_position;
global $passport_page_sidebar_width;
global $passport_post_content_column;
global $passport_post_sidebar_position;
global $passport_post_sidebar_width;
global $passport_footer_column;
$passport_theme_setting = get_theme_mod( 'passport_theme_setting', 'full_width_container' );
$passport_headline_column = get_theme_mod( 'passport_headline_column', 'main_content' );
$passport_headline_sidebar_position = get_theme_mod( 'passport_headline_sidebar_position', 'left' );
$passport_headline_sidebar_width = get_theme_mod( 'passport_headline_sidebar_width', 'sidebar_25' );
$passport_front_page_column = get_theme_mod( 'passport_section_5_settings', '3' );
$passport_blog_content_column = get_theme_mod( 'passport_blog_main_content', 'main_content' );
$passport_blog_sidebar_position = get_theme_mod( 'passport_blog_sidebar_position', 'left' );
$passport_blog_sidebar_width = get_theme_mod( 'passport_blog_sidebar_width', 'sidebar_25' );
$passport_page_content_column = get_theme_mod( 'passport_page_main_content', 'main_content' );
$passport_page_sidebar_position = get_theme_mod( 'passport_page_sidebar_position', 'left' );
$passport_page_sidebar_width = get_theme_mod( 'passport_page_sidebar_width', 'sidebar_25' );
$passport_post_content_column = get_theme_mod( 'passport_post_main_content', 'main_content' );
$passport_post_sidebar_position = get_theme_mod( 'passport_post_sidebar_position', 'left' );
$passport_post_sidebar_width = get_theme_mod( 'passport_post_sidebar_width', 'sidebar_25' );
$passport_footer_column = get_theme_mod( 'passport_footer_column', '3' );
}
add_action( 'after_setup_theme', 'passport_global_variables' );
/**
* Insert Custom Image Sizes function
* ------------------------------------------------------------------------
* Insert Custom Image Sizes in Add Media (Backend)
*
*
* @since passport 1.0
* @Ref site: http://kucrut.org/insert-image-with-custom-size-into-post/
*/
if( ! function_exists( 'passport_insert_custom_image_sizes' ) ) {
function passport_insert_custom_image_sizes( $sizes ) {
global $_wp_additional_image_sizes;
if ( empty( $_wp_additional_image_sizes ) ) {
return $sizes;
}
foreach ( $_wp_additional_image_sizes as $id => $data ) {
if ( ! isset( $sizes[ $id ] ) )
$sizes[ $id ] = ucfirst( str_replace( '-', ' ', $id ) );
}
return $sizes;
}
}
add_filter( 'image_size_names_choose', 'passport_insert_custom_image_sizes' );
/**
*
* Get Image Size function
* -----------------------------------------------------------------------
* Get the available image sizes.
*
*
* @since passport 1.0
*
*/
if( ! function_exists( 'passport_get_image_sizes' ) ) {
function passport_get_image_sizes( $size = '' ) {
global $_wp_additional_image_sizes;
$sizes = array();
$get_intermediate_image_sizes = get_intermediate_image_sizes();
// Create the full array with sizes and crop info
foreach( $get_intermediate_image_sizes as $_size ) {
if ( in_array( $_size, array( 'thumbnail', 'medium', 'medium_large', 'large' ) ) ) {
$sizes[ $_size ]['width'] = get_option( $_size . '_size_w' );
$sizes[ $_size ]['height'] = get_option( $_size . '_size_h' );
$sizes[ $_size ]['crop'] = (bool) get_option( $_size . '_crop' );
} elseif ( isset( $_wp_additional_image_sizes[ $_size ] ) ) {
$sizes[ $_size ] = array(
'width' => $_wp_additional_image_sizes[ $_size ]['width'],
'height' => $_wp_additional_image_sizes[ $_size ]['height'],
'crop' => $_wp_additional_image_sizes[ $_size ]['crop']
);
}
}
// Get only 1 size if found
if ( $size ) {
if( isset( $sizes[ $size ] ) ) {
return $sizes[ $size ];
} else {
return false;
}
}
return $sizes;
}
}
/**
* Default image function.
* ------------------------------------------------------------------------
* Function to call the default image from HOME page.
*
*
* @since passport 1.0
*
*/
add_filter( 'post_thumbnail_html', 'passport_post_image_html', 10, 5 );
if( ! function_exists( 'passport_post_image_html' ) ) {
function passport_post_image_html( $html, $post_id, $post_thumbnail_id, $size, $attr ) {
global $passport_template_name;
global $_wp_additional_image_sizes;
$frontpage_id = get_option( 'page_on_front' );
$attachment_id = get_post_thumbnail_id( $frontpage_id );
if( '' == $html ) {
if ( "template-masonry.php" == $passport_template_name ) {
$image_attributes = wp_get_attachment_image_src( $attachment_id, 'masonry-template-550-550' );
} else {
$image_attributes = wp_get_attachment_image_src( $attachment_id, 'large-image' );
}
if( isset( $_wp_additional_image_sizes[$size] ) ) {
$width = $_wp_additional_image_sizes[$size]['width'];
$height = $_wp_additional_image_sizes[$size]['height'];
}
if( ! empty( $attachment_id) ) {
$html = ' ';
} else {
$html = '';
}
}
return $html;
}
}
/**
* Add Additional Image Size function
* ------------------------------------------------------------------------
* Function to add the additional image size.
*
*
* @since passport 1.0
* @use add_image_size( $name, $width, $height, $crop )
*
*/
if( ! function_exists( 'passport_add_image_size' ) ) {
function passport_add_image_size() {
/* Adds Image Size */
add_image_size( 'menu-80-43.5', 80, 43.5, array( 'center', 'center' ) ); /*Menu - Left, Right*/
add_image_size( 'gallery-228-300', 228, 300, array( 'center', 'center' ) ); /*Five Column Gallery Post Format*/
add_image_size( 'gallery-285-300', 285, 300, array( 'center', 'center' ) ); /*Four Column Gallery Post Format*/
add_image_size( 'gallery-380-300', 380, 300, array( 'center', 'center' ) ); /*Three Column Gallery Post Format*/
add_image_size( 'gallery-570-300', 570, 300, array( 'center', 'center' ) ); /*Two Column Gallery Post Format*/
add_image_size( 'large-image-1349-670', 1349, 670, array( 'center', 'center' ) ); /*Home, Single, Page, Slider Widget, Short Content*/
add_image_size( 'large-image', 1140, 600, array( 'center', 'center' ) ); /*Home, Single, Page, Slider Widget, Short Content*/
add_image_size( 'large-image-855-450', 855, 450, array( 'center', 'center' ) );
add_image_size( 'large-image-760-400', 760, 400, array( 'center', 'center' ) );
add_image_size( 'large-image-756-398', 756.66, 398.23, array( 'center', 'center' ) );
add_image_size( 'large-image-566-298', 566.66, 298.23, array( 'center', 'center' ) );
add_image_size( 'column-image-565-375', 565, 375.92, array( 'center', 'center' ) );
add_image_size( 'column-image-373-196', 373.33, 196.53, array( 'center', 'center' ) );
add_image_size( 'column-image-277-184', 277.5, 184.63, array( 'center', 'center' ) );
add_image_size( 'standard-image', 825, 434, array( 'center', 'center' ) ); /*Front page, Medium image template, search, archive Accordian, etc*/
add_image_size( 'masonry-template-550-550', 550, 550, array( 'center', 'center' ) ); /*Masonry Template*/
add_image_size( 'related-post-276-276', 276.25, 276.25, array( 'center', 'center' )); /*Related-posts-full-width*/
add_image_size( 'related-post-285-190', 285, 190, array( 'center', 'center' ) ); /*Related-posts sidebar 33, 25*/
add_image_size( 'small-140-110', 140, 110, array( 'center', 'center' ) ); /*Widget - post id */
add_image_size( 'small-100-70', 100, 70, array( 'center', 'center' ) ); /*Widget - post-list, post-format-list, post-widget, popular-posts, thumbnail-widget */
add_image_size( 'small-120-70', 120, 70, array( 'center', 'center' ) ); /*Slider Widget*/
add_image_size( 'medium-570-299', 570, 299.98, array( 'center', 'center' ) ); /*Post ID Widget */
add_image_size( 'box-900-507', 900, 507, array( 'center', 'center' ) );/*Box Widget*/
add_image_size( 'box-760-400', 760, 400, array( 'center', 'center' ) ); /*Box Widget*/
add_image_size( 'box-225-169', 225, 169, array( 'center', 'center' ) ); /*Box - Small*/
add_image_size( 'box-240-168', 240, 168, array( 'center', 'center' ) ); /*Box - Small*/
add_image_size( 'carousel-276-276', 276.25, 276.25, array( 'center', 'center' ) ); /*Carousel Slider Widget*/
add_image_size( 'carousel-300-225', 300, 225, array( 'center', 'center' ) ); /*Carousel Slider Widget*/
add_image_size( 'carousel-300-300', 300, 300, array( 'center', 'center' ) ); /*Carousel Slider Widget*/
add_image_size( 'grid-276-276', 276, 276, array( 'center', 'center' ) ); /*Tab Widget*/
add_image_size( 'grid-562-276', 562, 276, array( 'center', 'center' ) ); /*Tab Widget*/
}
}
add_action( 'after_setup_theme', 'passport_add_image_size', 20 );
/**
* Display image function.
* ------------------------------------------------------------------------
* This function uses for displaying the image with the suitable size.
*
*
* @since passport 1.0
*
*/
if ( ! function_exists ( 'passport_display_image' ) ) {
function passport_display_image() {
global $passport_template_name;
global $passport_headline_column;
global $passport_section_settings;
global $passport_post_content_column;
global $passport_post_sidebar_width;
global $passport_page_content_column;
global $passport_page_sidebar_width;
global $passport_blog_content_column;
global $passport_blog_sidebar_width;
global $passport_front_page_column;
global $passport_footer_column;
if( is_front_page() && is_home() ) {
$images = the_post_thumbnail( 'large-image' );
} elseif( is_front_page() && 'sidebar' == $passport_section_settings ) {
$images = the_post_thumbnail( 'large-image-756-398' );
} elseif( is_front_page() && 'main_content' == $passport_section_settings ) {
$images = the_post_thumbnail( 'large-image-756-398' );
} elseif( is_front_page() ) {
$images = the_post_thumbnail( 'large-image' );
} elseif( is_single() && 'sidebar' == $passport_post_content_column && 'sidebar_33' == $passport_post_sidebar_width || is_page() && 'sidebar' == $passport_page_content_column && 'sidebar_33' == $passport_page_sidebar_width ) {
$images = the_post_thumbnail( 'large-image-760-400' );
} elseif( is_single() && 'sidebar' == $passport_post_content_column && 'sidebar_25' == $passport_post_sidebar_width || is_page() && 'sidebar' == $passport_page_content_column && 'sidebar_25' == $passport_page_sidebar_width ) {
$images = the_post_thumbnail( 'large-image-855-450' );
} elseif( is_single() || is_page() ) {
$images = the_post_thumbnail( 'large-image' );
} elseif( "template-masonry.php" == $passport_template_name ) {
$images = the_post_thumbnail( 'masonry-template-550-550' ); //Default:'masonry-image'
} elseif( "template-medium-image.php" == $passport_template_name || is_search() || is_archive() ) {
$images = the_post_thumbnail( 'standard-image' );
} elseif( "template-large-image.php" == $passport_template_name && 'sidebar' == $passport_blog_content_column && 'sidebar_33' == $passport_blog_sidebar_width || is_home() && 'sidebar' == $passport_blog_content_column && 'sidebar_33' == $passport_blog_sidebar_width ) {
$images = the_post_thumbnail( 'large-image-760-400' );
} elseif( "template-large-image.php" == $passport_template_name && 'sidebar' == $passport_blog_content_column && 'sidebar_25' == $passport_blog_sidebar_width || is_home() && 'sidebar' == $passport_blog_content_column && 'sidebar_25' == $passport_blog_sidebar_width ) {
$images = the_post_thumbnail( 'large-image-855-450' );
} elseif( "template-large-image.php" == $passport_template_name || is_home() ) {
$images = the_post_thumbnail( 'large-image' );
} elseif( is_front_page() && '4' == $passport_front_page_column || '4' == $passport_footer_column ) {
$images = the_post_thumbnail( 'column-image-277-184' );
} elseif( is_front_page() && '3' == $passport_front_page_column || '3' == $passport_footer_column ) {
$images = the_post_thumbnail( 'column-image-373-196' );
} elseif( is_front_page() && '2' == $passport_front_page_column || '2' == $passport_footer_column ) {
$images = the_post_thumbnail( 'column-image-565-375' );
} else {
$images = the_post_thumbnail( 'large-image' );
}
return $images;
}
}
/**
* Download image function.
* ------------------------------------------------------------------------
* This function uses for the attachment.php file. There are only three
* standard image size.
*
*
* @since passport 1.0
*
*/
if ( ! function_exists ( 'passport_download_image' ) ) {
function passport_download_image() {
$images = array();
$image_sizes = array( 'thumbnail', 'medium', 'large' );
array_unshift( $image_sizes, 'full' );
foreach( $image_sizes as $image_size ) {
$image = wp_get_attachment_image_src( get_the_ID(), $image_size );
$name = $image_size . ' ( ' . $image[1] . 'x' . $image[2] . ' )';
$images[] = '' . $name . ' ';
}
echo implode( ' | ', $images );
}
}
/**
*
* Short title function
* -----------------------------------------------------------------------
* Limit Post Title by amount of characters
*
*
* @since passport 1.0
* @use strlen() to count the string length
* @use mb_substr (Multibyte String function) to limit the length of the title.
* @You can set $limit in the desirable file.
* @please see the example at the featured-posts-by-category widget.
*/
if ( ! function_exists ( 'passport_short_title' ) ) {
function passport_short_title( $title, $limit ) {
//$limit = 40; /*If you would like to change all short title. Change here*/
$pad="...";
if( strlen( $title ) >= ( $limit+3 ) ) {
$title = mb_substr( $title, 0, $limit ) . $pad;
}
echo $title;
}
}
/**
*
* Customize excerpt word count length
* ------------------------------------------------------------------------
* The excerpt length will be set automatically if there is no
* setting in admin panel.
* For the excerpt in sidebar, you can use the default wordpress setting
* to set the excerpt length. Example: the more tag () or the
* excerpt option.
*
* @since passport 1.0
*
*/
if ( ! function_exists ( 'passport_custom_excerpt_length' ) ) {
function passport_custom_excerpt_length() {
global $passport_template_name;
global $passport_theme_setting;
global $passport_section_settings;
global $passport_sidebar_width;
global $passport_blog_content_column;
global $passport_blog_sidebar_width;
if( ( "template-large-image.php" == $passport_template_name ) ) { // Excerpt - Large image template
return 100;
} elseif( ( "template-masonry.php" == $passport_template_name ) ) { // Excerpt - Masonry template
return 25;
} elseif( ( "template-medium-image.php" == $passport_template_name || is_archive() || is_search() ) && "sidebar" == $passport_blog_content_column && "sidebar_33" == $passport_blog_sidebar_width && has_post_thumbnail() ) { // Excerpt - Medium image template (Size 33)
return 18;
} elseif( ( "template-medium-image.php" == $passport_template_name || is_archive() || is_search() ) && "sidebar" == $passport_blog_content_column && "sidebar_25" == $passport_blog_sidebar_width && has_post_thumbnail() ) { // Excerpt - Medium image template (Size 25)
return 25;
} elseif( ( "template-medium-image.php" == $passport_template_name || is_archive() || is_search() ) && "main_content" == $passport_blog_content_column ) { // Excerpt - Medium image template (Full)
return 65;
} elseif( is_front_page() && 'full_width_container' == $passport_theme_setting ) { //Front page and Full width container
return 65;
} elseif( is_front_page() && 'sidebar' == $passport_section_settings && 'sidebar_33' == $passport_sidebar_width ) { //Front page and sidebar 33
return 35;
} elseif( is_front_page() && 'sidebar' == $passport_section_settings && 'sidebar_25' == $passport_sidebar_width ) { //Front page and sidebar 25
return 30;
} elseif( is_home() ) { //Home
return 100;
} elseif( is_front_page() ) { //Front page
return 30;
} else { //Else
return 55;
}
}
}
add_filter( 'excerpt_length', 'passport_custom_excerpt_length' );
/**
*
* Change Excerpt More Style function.
* Version 2.9 and higher
* ------------------------------------------------------------------------
* This excerpt more function will be used when no excerpt is set in the
* admin panel. It will work with the custom excerpt length function
*
* @since passport 1.0
*
*/
if ( ! function_exists ( 'passport_new_excerpt_more' ) ) {
function passport_new_excerpt_more( $more ) {
return ' ...';
}
}
add_filter( 'excerpt_more', 'passport_new_excerpt_more' );
/**
*
* Custom Excerpt or Content Word Limit
* ------------------------------------------------------------------------
* Set the custom excerpt with the content word limit.
* You can set the continue reading by setting limit lower than the setting in
* passport_custom_excerpt_length function.
* And, you can adjust the continue reading by use the following statement.
*
* @since passport 1.0
* @For linked Continue reading "post title" use:
* @'... Continue reading "'.get_the_title( $post->ID).'" '
* @For linked Continue reading >> use:
* @'... Continue » '
* @You can set $limit in the desirable file.
*/
if ( ! function_exists ( 'passport_excerpt' ) ) {
function passport_excerpt( $limit, $line_breaks = TRUE ) {
global $post;
global $more;
$the_post = get_post( $post->ID ); //Gets post ID
$the_excerpt = $the_post->post_excerpt ? $the_post->post_excerpt : $the_post->post_content; //Gets post_excerpt or post_content to be used as a basis for the excerpt
$the_excerpt = apply_filters( 'the_excerpt', $the_excerpt );
$excerpt = explode( ' ', $the_excerpt, $limit );
if ( count( $excerpt ) >= $limit ) {
array_pop( $excerpt );
$excerpt = implode( " ", $excerpt ).'...';
} else {
$excerpt = implode( " ",$excerpt );
}
$excerpt = preg_replace( '`\[[^\]]*\]`', '', $excerpt );
return $excerpt;
}
}
/**
*
* Modify read more link
* ------------------------------------------------------------------------
* This function is to change more ( ) to the read more button
* It uses for the widget in Show in Post Format.
*
*
* @since passport 1.0
*
*/
if ( ! function_exists ( 'passport_modify_read_more_link' ) ) {
function passport_modify_read_more_link() {
return '
'. esc_html__( 'Read more', 'passport' ) .' ';
}
}
add_filter( 'the_content_more_link', 'passport_modify_read_more_link' );
/**
*
* Link Pages
* ------------------------------------------------------------------------
* Displays page-links for paginated posts.
*
*
* @since passport 1.0
* @uses wp_link_pages( $default ) function.
* @changes $default to change the default usage.
*
*/
$defaults = array(
'before' => '' . esc_html__( 'Pages:', 'passport' ),
'after' => '
',
'link_before' => '',
'link_after' => ' ',
'next_or_number' => 'number',
'separator' => ' ',
'nextpagelink' => esc_html__( 'Next page', 'passport' ),
'previouspagelink' => esc_html__( 'Previous page', 'passport' ),
'pagelink' => '%',
'echo' => 1
);
wp_link_pages( $defaults );
/**
*
* Breadcrumb function
* -----------------------------------------------------------------------
* Get all information, ie. the category, the title, the post type name
* and others, to present in the breadcrumb.
*
*
* @since passport 1.0
*
*/
if ( ! function_exists ( 'passport_the_breadcrumb' ) ) {
function passport_the_breadcrumb() {
global $post;
//Get the category
$categories = wp_get_post_categories( get_the_ID(), array( 'fields' => 'ids' ) );
if( $categories ) {
$sep = ' • ';
$cat_ids = implode( ',' , $categories );
$cats = wp_list_categories( 'title_li=&style=none&echo=0&include='.$cat_ids );
$cats = rtrim( trim( str_replace( ' ', $sep, $cats ) ), $sep );
}
//Get post type object
$post_type_obj = get_post_type_object( get_post_type() );
//Get post type's label
if( ! empty ( $post_type_obj ) ) {
$post_type_title = apply_filters( 'post_type_archive_title', $post_type_obj->labels->name );
$post_type_link = get_post_type_archive_link( strtolower( $post_type_title ) );
}
if ( ! is_home() ) {
echo '';
echo '';
echo esc_html__( 'Home', 'passport' );
echo ' ';
if ( is_category() || is_single() || is_post_type_archive() ) {
if( is_category() ) {
echo '';
echo single_cat_title();
echo ' ';
} elseif ( ! empty ( $cats ) ) {
echo '';
echo $cats;
echo ' ';
} elseif ( ! empty( $post_type_title ) ) {
echo '';
echo '';
echo $post_type_title;
echo ' ';
echo ' ';
}
if ( is_single() ) {
echo '';
the_title();
echo ' ';
}
} elseif ( is_page() ) {
if( $post->post_parent){
$anc = get_post_ancestors( $post->ID );
$title = get_the_title();
foreach ( $anc as $ancestor ) {
$output = ''.get_the_title( $ancestor ).' ';
}
echo $output;
echo ''. $title .' ';
} else {
echo ''.get_the_title().' ';
}
} elseif ( is_tag() ) { echo""; single_tag_title(); echo' ';
} elseif ( is_day() ) { echo''; echo esc_html__( 'Archives for ', 'passport' ); the_time( 'F jS, Y' ); echo' ';
} elseif ( is_month() ) { echo''; echo esc_html__( 'Archives for ', 'passport' ); echo' ';
} elseif ( is_year() ) { echo''; echo esc_html__( 'Archives for ', 'passport' ); the_time( 'Y' ); echo' ';
} elseif ( is_author() ) { echo''; echo esc_html__( 'Author Archives: ', 'passport' ); the_author(); echo' ';
} elseif ( isset( $_GET['paged'] ) && ! empty( $_GET['paged']) ) { echo''; echo esc_html__( 'Blog Archives', 'passport' ); echo' ';
} elseif ( is_search() ) { echo''; echo esc_html__( 'Search Results: ', 'passport' ); echo get_search_query(); echo' ';
}
} echo ' ';
}
}
/**
*
* Allowed Tags Function for Validation On Input
* -----------------------------------------------------------------------
* This is the security function for wp_kses function in metabox. You can
* set the allowed tags for the validation on input here. Most tags are for
* the iframe.
*
* @since passport 1.0
*
*/
if ( ! function_exists ( 'passport_allowed_tags' ) ) {
function passport_allowed_tags() {
global $allowedtags;
$allowedtags['iframe'] = array(
'src' => array(),
'height' => array(),
'width' => array(),
'frameborder' => array(),
'allowfullscreen' => array(),
'marginwidth' => array(),
'marginheight' => array(),
);
return( $allowedtags );
}
}
add_action( 'init', 'passport_allowed_tags' );
/**
*
* Icon Show Function
* -----------------------------------------------------------------------
* Each post format will use the different icons. This function helps to
* specify the correct icon to them.
*
* @since passport 1.0
*
*/
if ( ! function_exists ( 'passport_icon_shows' ) ) {
function passport_icon_shows() {
global $post;
$post_format = get_post_format( $post->ID );
if( false == $post_format ) {
echo ' ';
} elseif( 'aside' == $post_format ) {
echo '';
} elseif( 'link' == $post_format ) {
echo ' ';
} elseif( 'quote' == $post_format ) {
echo ' ';
} elseif( 'image' == $post_format ) {
echo ' ';
} elseif( 'gallery' == $post_format ) {
echo ' ';
} elseif( 'audio' == $post_format ) {
echo ' ';
} elseif( 'video' == $post_format ) {
echo ' ';
}
}
}
// Remove Gallery Styling
if ( ! function_exists ( 'passport_remove_gallery_css' ) ) {
function passport_remove_gallery_css( $css ) {
return preg_replace( "##s", '', $css );
}
}
add_filter( 'gallery_style', 'passport_remove_gallery_css' );
/**
* Manage category columns in the category table and category form function.
* -------------------------------------------------------------------------
* Add featured image column and edit the columns on the current taxonomy.
*
* @package WordPress
* @subpackage passport
* @since Passport 1.0
*
**/
if ( ! function_exists ( 'passport_manage_category_columns' ) ) {
function passport_manage_category_columns( $columns ) {
// only edit the columns on the current taxonomy
if ( ! isset( $_REQUEST['taxonomy'] ) || $_REQUEST['taxonomy'] != 'category' )
return $columns;
// Add 'Featured Image Column'
$columns['featured_image_column'] = esc_html__( 'Featured Image', 'passport' );
return $columns;
}
}
add_filter( 'manage_edit-category_columns', 'passport_manage_category_columns' );
/**
* Put the featured image value in each column.
* -------------------------------------------------------------------------
* Filtering manage_category_custom_column
*
* @since Passport 1.0
*
**/
if ( ! function_exists ( 'passport_manage_category_custom_fields' ) ) {
function passport_manage_category_custom_fields( $deprecated, $column_name, $term_id ) {
$category_id = $term_id;
$category_option = 'category_custom_order_' . $category_id;
$category_img_src = get_option( $category_option );
$category_alt_name = esc_attr( get_cat_name( $category_id ) );
if ( 'featured_image_column' == $column_name ) :
if( ! empty ( $category_img_src ) ) : ?>
term_id;
$category_option = 'category_custom_order_' . $category_id;
$category_img_src = get_option( $category_option );
?>
';
}
}
}
}
add_filter( 'manage_posts_columns', 'passport_columns_head' );
add_action( 'manage_posts_custom_column', 'passport_columns_content', 10, 2 );
/**
* Editor Styles
* ------------------------------------------------------------------------
* Function to enqueue the front-end scrip and style.
*
*
* @since Passport 1.0
* @uses add_editor_style() Links a stylesheet to visual editor
* @uses get_stylesheet_uri() Returns URI of theme stylesheet
*
*/
if ( ! function_exists ( 'passport_custom_editor_styles' ) ) {
function passport_custom_editor_styles() {
add_editor_style( 'assets/css/custom-editor-style.css' );
}
}
add_action( 'admin_init', 'passport_custom_editor_styles' );
/**
* Timeout to WordPress API in update.php
* ------------------------------------------------------------------------
* Increase timeout for API request. This function is to solve timeout requests
* of update.php in admin page.
*
* @since Passport 1.0
* @Ref: https://core.trac.wordpress.org/ticket/27091
*
*/
if ( ! function_exists ( 'passport_increase_timeout_for_api_requests_27091' ) ) {
function passport_increase_timeout_for_api_requests_27091( $r, $url ) {
if ( false !== strpos( $url, '//api.wordpress.org/' ) ) {
$r['timeout'] = 30;
}
return $r;
}
}
add_filter( 'http_request_args', 'passport_increase_timeout_for_api_requests_27091', 10, 2 );
/**
*
* Customize theme
* -----------------------------------------------------------------------
* Be careful! Arrangement of the statement below is very important.
*
*
* @since passport 1.0
*
*/
require( get_template_directory() . '/includes/theme-customizer.php' ); // General Style
require( get_template_directory() . '/includes/custom-setup.php' ); // Custom Set up Style
require( get_template_directory() . '/includes/custom-style.php' ); // Post Format Style
/**
* This file represents an example of the code that themes would use to register
* the required plugins.
*
* It is expected that theme authors would copy and paste this code into their
* functions.php file, and amend to suit.
*
* @see http://tgmpluginactivation.com/configuration/ for detailed documentation.
*
* @package TGM-Plugin-Activation
* @subpackage Example
* @version 2.6.1 for parent theme themevilles for publication on ThemeForest
* @author Thomas Griffin, Gary Jones, Juliette Reinders Folmer
* @copyright Copyright (c) 2011, Thomas Griffin
* @license http://opensource.org/licenses/gpl-2.0.php GPL v2 or later
* @link https://github.com/TGMPA/TGM-Plugin-Activation
*/
/**
* Include the TGM_Plugin_Activation class.
*
* Depending on your implementation, you may want to change the include call:
*
* Parent Theme:
* require_once get_template_directory() . '/includes/class-tgm-plugin-activation.php';
*
* Child Theme:
* require_once get_stylesheet_directory() . '/includes/class-tgm-plugin-activation.php';
*
* Plugin:
* require_once dirname( __FILE__ ) . '/includes/class-tgm-plugin-activation.php';
*/
require_once get_template_directory() . '/includes/class-tgm-plugin-activation.php';
add_action( 'tgmpa_register', 'passport_register_required_plugins' );
/**
* Register the required plugins for this theme.
*
* In this example, we register five plugins:
* - one included with the TGMPA library
* - two from an external source, one from an arbitrary source, one from a GitHub repository
* - two from the .org repo, where one demonstrates the use of the `is_callable` argument
*
* The variables passed to the `tgmpa()` function should be:
* - an array of plugin arrays;
* - optionally a configuration array.
* If you are not changing anything in the configuration array, you can remove the array and remove the
* variable from the function call: `tgmpa( $plugins );`.
* In that case, the TGMPA default settings will be used.
*
* This function is hooked into `tgmpa_register`, which is fired on the WP `init` action on priority 10.
*/
if ( ! function_exists ( 'passport_register_required_plugins' ) ) {
function passport_register_required_plugins() {
/*
* Array of plugin arrays. Required keys are name and slug.
* If the source is NOT from the .org repo, then source is also required.
*/
$plugins = array(
// This is an example of how to include a plugin from the WordPress Plugin Repository.
array(
'name' => 'Email Subscribers', // The plugin name.
'slug' => 'email-subscribers', // The plugin slug (typically the folder name).
'required' => false,
),
array(
'name' => 'Regenerate Thumbnails Plugin',
'slug' => 'regenerate-thumbnails',
'required' => false,
),
);
/*
* Array of configuration settings. Amend each line as needed.
*
* TGMPA will start providing localized text strings soon. If you already have translations of our standard
* strings available, please help us make TGMPA even better by giving us access to these translations or by
* sending in a pull-request with .po file(s) with the translations.
*
* Only uncomment the strings in the config array if you want to customize the strings.
*/
$config = array(
'id' => 'themevilles', // Unique ID for hashing notices for multiple instances of TGMPA.
'default_path' => '', // Default absolute path to bundled plugins.
'menu' => 'tgmpa-install-plugins', // Menu slug.
'has_notices' => true, // Show admin notices or not.
'dismissable' => true, // If false, a user cannot dismiss the nag message.
'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag.
'is_automatic' => false, // Automatically activate plugins after installation or not.
'message' => '', // Message to output right before the plugins table.
);
tgmpa( $plugins, $config );
}
}