240,
'width' => 240,
'flex-height' => true,
) );
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 1200, 9999 );
register_nav_menus( array(
'primary' => __( 'Primary Menu', 'limelight-core' ),
'social' => __( 'Social Links Menu', 'limelight-core' ),
) );
add_theme_support( 'html5', array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
) );
add_theme_support( 'post-formats', array(
'aside',
'image',
'video',
'quote',
'link',
'gallery',
'status',
'audio',
'chat',
) );
add_editor_style( array( 'css/editor-style.css', limelight_core_fonts_url() ) );
add_theme_support( 'customize-selective-refresh-widgets' );
}
endif;
add_action( 'after_setup_theme', 'limelight_core_setup' );
function limelight_core_content_width() {
$GLOBALS['content_width'] = apply_filters( 'limelight_core_content_width', 840 );
}
add_action( 'after_setup_theme', 'limelight_core_content_width', 0 );
function limelight_core_widgets_init() {
register_sidebar( array(
'name' => __( 'Sidebar', 'limelight-core' ),
'id' => 'sidebar-1',
'description' => __( 'Add widgets here to appear in your sidebar.', 'limelight-core' ),
'before_widget' => '',
'before_title' => '
',
) );
register_sidebar( array(
'name' => __( 'Content Bottom 1', 'limelight-core' ),
'id' => 'sidebar-2',
'description' => __( 'Appears at the bottom of the content on posts and pages.', 'limelight-core' ),
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => __( 'Content Bottom 2', 'limelight-core' ),
'id' => 'sidebar-3',
'description' => __( 'Appears at the bottom of the content on posts and pages.', 'limelight-core' ),
'before_widget' => '',
'before_title' => '',
) );
}
add_action( 'widgets_init', 'limelight_core_widgets_init' );
function limelight_get_version() {
$theme = wp_get_theme( 'limelight-core' );
return $theme->get( 'Version' );
}
if ( ! function_exists( 'limelight_core_fonts_url' ) ) :
function limelight_core_fonts_url() {
$fonts_url = '';
$fonts = array();
$subsets = 'latin,latin-ext';
if ( 'off' !== _x( 'on', 'Merriweather font: on or off', 'limelight-core' ) ) {
$fonts[] = 'Merriweather:400,700,900,400italic,700italic,900italic';
}
if ( 'off' !== _x( 'on', 'Montserrat font: on or off', 'limelight-core' ) ) {
$fonts[] = 'Montserrat:400,700';
}
if ( 'off' !== _x( 'on', 'Inconsolata font: on or off', 'limelight-core' ) ) {
$fonts[] = 'Inconsolata:400';
}
if ( $fonts ) {
$fonts_url = add_query_arg( array(
'family' => urlencode( implode( '|', $fonts ) ),
'subset' => urlencode( $subsets ),
), 'https://fonts.googleapis.com/css' );
}
return $fonts_url;
}
endif;
function limelight_core_javascript_detection() {
echo "\n";
}
add_action( 'wp_head', 'limelight_core_javascript_detection', 0 );
function limelight_core_scripts() {
wp_enqueue_style( 'limelight-core-fonts', limelight_core_fonts_url(), array(), null );
wp_enqueue_style( 'genericons', get_template_directory_uri() . '/genericons/genericons.css', array(), '3.4.1' );
wp_enqueue_style( 'limelight-core-style', get_stylesheet_uri() );
wp_enqueue_style( 'limelight-core-ie', get_template_directory_uri() . '/css/ie.css', array( 'limelight-core-style' ), limelight_get_version() );
wp_enqueue_style( 'limelight-core-ie7', get_template_directory_uri() . '/css/ie7.css', array( 'limelight-core-style' ), limelight_get_version() );
wp_enqueue_style( 'limelight-core-ie8', get_template_directory_uri() . '/css/ie8.css', array( 'limelight-core-style' ), limelight_get_version() );
wp_enqueue_script( 'limelight-core-html5', get_template_directory_uri() . '/js/html5.js', array(), limelight_get_version() );
wp_enqueue_script( 'limelight-core-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), limelight_get_version(), true );
wp_style_add_data( 'limelight-core-ie8', 'conditional', 'lt IE 9' );
wp_style_add_data( 'limelight-core-ie', 'conditional', 'lt IE 10' );
wp_style_add_data( 'limelight-core-ie7', 'conditional', 'lt IE 8' );
wp_script_add_data( 'limelight-core-html5', 'conditional', 'lt IE 9' );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
if ( is_singular() && wp_attachment_is_image() ) {
wp_enqueue_script( 'limelight-core-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), limelight_get_version() );
}
wp_enqueue_script( 'limelight-core-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), limelight_get_version(), true );
wp_localize_script( 'limelight-core-script', 'screenReaderText', array(
'expand' => __( 'expand child menu', 'limelight-core' ),
'collapse' => __( 'collapse child menu', 'limelight-core' ),
) );
}
add_action( 'wp_enqueue_scripts', 'limelight_core_scripts' );
function limelight_core_body_classes( $classes ) {
if ( get_background_image() ) {
$classes[] = 'custom-background-image';
}
if ( is_multi_author() ) {
$classes[] = 'group-blog';
}
if ( ! is_active_sidebar( 'sidebar-1' ) ) {
$classes[] = 'no-sidebar';
}
if ( ! is_singular() ) {
$classes[] = 'hfeed';
}
return $classes;
}
add_filter( 'body_class', 'limelight_core_body_classes' );
function limelight_core_hex2rgb( $color ) {
$color = trim( $color, '#' );
if ( strlen( $color ) === 3 ) {
$r = hexdec( substr( $color, 0, 1 ) . substr( $color, 0, 1 ) );
$g = hexdec( substr( $color, 1, 1 ) . substr( $color, 1, 1 ) );
$b = hexdec( substr( $color, 2, 1 ) . substr( $color, 2, 1 ) );
} else if ( strlen( $color ) === 6 ) {
$r = hexdec( substr( $color, 0, 2 ) );
$g = hexdec( substr( $color, 2, 2 ) );
$b = hexdec( substr( $color, 4, 2 ) );
} else {
return array();
}
return array( 'red' => $r, 'green' => $g, 'blue' => $b );
}
require get_template_directory() . '/inc/template-tags.php';
require get_template_directory() . '/inc/customizer.php';
function limelight_core_content_image_sizes_attr( $sizes, $size ) {
$width = $size[0];
840 <= $width && $sizes = '(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px';
if ( 'page' === get_post_type() ) {
840 > $width && $sizes = '(max-width: ' . $width . 'px) 85vw, ' . $width . 'px';
} else {
840 > $width && 600 <= $width && $sizes = '(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px';
600 > $width && $sizes = '(max-width: ' . $width . 'px) 85vw, ' . $width . 'px';
}
return $sizes;
}
add_filter( 'wp_calculate_image_sizes', 'limelight_core_content_image_sizes_attr', 10 , 2 );
function limelight_core_post_thumbnail_sizes_attr( $attr, $attachment, $size ) {
if ( 'post-thumbnail' === $size ) {
is_active_sidebar( 'sidebar-1' ) && $attr['sizes'] = '(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 60vw, (max-width: 1362px) 62vw, 840px';
! is_active_sidebar( 'sidebar-1' ) && $attr['sizes'] = '(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 88vw, 1200px';
}
return $attr;
}
add_filter( 'wp_get_attachment_image_attributes', 'limelight_core_post_thumbnail_sizes_attr', 10 , 3 );
function limelight_core_widget_tag_cloud_args( $args ) {
$args['largest'] = 1;
$args['smallest'] = 1;
$args['unit'] = 'em';
return $args;
}
add_filter( 'widget_tag_cloud_args', 'limelight_core_widget_tag_cloud_args' );
function limelight_get_string( $method = '', $args = array() ) {
ob_start();
call_user_func_array( $method, $args );
return ob_get_clean();
}
function limelight_core_breadcrumb() {
$sep = ' / ';
$html = array();
if ( ! is_front_page() ) {
$html[] = 'Home';
if ( is_single() ) {
$title = limelight_get_string( 'the_title' );
}
if ( is_page() ) {
$title = limelight_get_string( 'the_title' );
}
foreach ( wp_get_post_categories( get_the_ID() ) as $category => $id ) {
$cat = get_category( $id );
$cat_data[] = array(
'name' => $cat->name,
'link' => get_category_link( $id ),
'id' => $id,
);
}
if ( ! is_page() ) {
foreach ( array_reverse( $cat_data ) as $data ) {
$html[] = "{$sep}
{$data['name']}";
}
}
if ( $title ) {
$html[] = "{$sep}{$title}";
}
$html[] = '
';
}
echo implode( "\n", $html );
}
function limelight_core_remove_admin_logo( $wp_admin_bar ) {
if ( get_option( 'hide_wp_logos' ) ){ $wp_admin_bar->remove_node( 'wp-logo' ); }
}
add_action( 'admin_bar_menu', 'limelight_core_remove_admin_logo', 999 );
function limelight_core_remove_footer_admin () {
if ( get_option( 'hide_wp_logos' ) ){ echo ''; }
}
add_filter( 'admin_footer_text', 'limelight_core_remove_footer_admin' );
function limelight_core_menu_additions( $items, $args ) {
$items .= '' . __( 'Home', 'limelight-core' ) . '';
$items .= '' . __( 'Shop', 'limelight-core' ) . '';
$items .= '' . __( 'Blog', 'limelight-core' ) . '';
$items .= '' . __( 'Cart', 'limelight-core' ) . '';
if ( is_user_logged_in() ) {
$items .= '' . __( 'My Account', 'limelight-core' ) . '';
$items .= '' . __( 'Log Out', 'limelight-core' ) . '';
} else {
$items .= '' . __( 'Login', 'limelight-core' ) . '';
$items .= '' . __( 'Join Now', 'limelight-core' ) . '';
}
return $items;
}
add_filter( 'wp_nav_menu_items', 'limelight_core_menu_additions', 10, 2 );
function your_theme_enqueue_scripts() {
wp_enqueue_style( 'font-awesome', get_template_directory_uri() . '/css/font-awesome.min.css', array(), '4.7.0' );
wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css' );
wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js' );
}
add_action( 'wp_enqueue_scripts', 'your_theme_enqueue_scripts' );
function limelight_core_hide_membership_pages()
{
if ( ( is_page( 'My Account' ) || is_page( 'Order History' ) ) && ! is_user_logged_in() )
{
wp_redirect( home_url( '/user-register/' ) );
exit();
}
}
add_action( 'template_redirect', 'limelight_core_hide_membership_pages' );
function limelight_add_taxonomies_to_pages() {
register_taxonomy_for_object_type( 'post_tag', 'products' );
register_taxonomy_for_object_type( 'category', 'products' );
}
add_action( 'init', 'limelight_add_taxonomies_to_pages' );
function limelight_core_redirect_404() {
if ( is_404() ) {
wp_redirect( home_url() );
}
}
add_action( 'template_redirect', 'limelight_core_redirect_404' );
//category images
define('CATEGORY_IMAGE_PLACEHOLDER', get_template_directory_uri() . "/assets/placeholder.png");
function z_init() {
$z_taxonomies = get_taxonomies();
if ( is_array( $z_taxonomies ) ) {
$zci_options = get_option( 'zci_options' );
if ( empty( $zci_options['excluded_taxonomies'] ) )
$zci_options['excluded_taxonomies'] = array();
foreach ( $z_taxonomies as $z_taxonomy ) {
if ( in_array( $z_taxonomy, $zci_options['excluded_taxonomies'] ) )
continue;
add_action( $z_taxonomy . '_add_form_fields', 'z_add_texonomy_field' );
add_action( $z_taxonomy . '_edit_form_fields', 'z_edit_texonomy_field' );
add_filter( 'manage_edit-' . $z_taxonomy . '_columns', 'z_taxonomy_columns' );
add_filter( 'manage_' . $z_taxonomy . '_custom_column', 'z_taxonomy_column', 10, 3 );
}
}
}
add_action( 'admin_init', 'z_init' );
function z_add_style() {
echo '';
}
function z_add_texonomy_field() {
if ( get_bloginfo( 'version' ) >= 3.5)
wp_enqueue_media();
else {
wp_enqueue_style( 'thickbox' );
wp_enqueue_script( 'thickbox' );
}
echo '
' . z_script();
}
function z_edit_texonomy_field( $taxonomy ) {
if ( get_bloginfo( 'version' ) >= 3.5 )
wp_enqueue_media();
else {
wp_enqueue_style( 'thickbox' );
wp_enqueue_script( 'thickbox' );
}
if ( z_taxonomy_image_url( $taxonomy->term_id, NULL, TRUE ) == CATEGORY_IMAGE_PLACEHOLDER )
$image_url = "";
else
$image_url = z_taxonomy_image_url( $taxonomy->term_id, NULL, TRUE );
echo '
|
|
' . z_script();
}
function z_script() {
return '';
}
add_action( 'edit_term','z_save_taxonomy_image' );
add_action( 'create_term','z_save_taxonomy_image' );
function z_save_taxonomy_image( $term_id ) {
if ( isset( $_POST['taxonomy_image'] ) )
update_option( 'z_taxonomy_image' . $term_id, $_POST['taxonomy_image'], NULL );
}
function z_get_attachment_id_by_url( $image_src ) {
global $wpdb;
$query = $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE guid = %s", $image_src );
$id = $wpdb->get_var( $query );
return ( ! empty( $id ) ) ? $id : NULL;
}
function z_taxonomy_image_url( $term_id = NULL, $size = 'full', $return_placeholder = FALSE ) {
if ( ! $term_id ) {
if ( is_category() )
$term_id = get_query_var('cat');
elseif ( is_tag() )
$term_id = get_query_var('tag_id');
elseif ( is_tax() ) {
$current_term = get_term_by( 'slug', get_query_var('term'), get_query_var('taxonomy') );
$term_id = $current_term->term_id;
}
}
$taxonomy_image_url = get_option('z_taxonomy_image' . $term_id);
if ( ! empty( $taxonomy_image_url ) ) {
$attachment_id = z_get_attachment_id_by_url( $taxonomy_image_url );
if( ! empty( $attachment_id ) ) {
$taxonomy_image_url = wp_get_attachment_image_src( $attachment_id, $size );
$taxonomy_image_url = $taxonomy_image_url[0];
}
}
if ($return_placeholder)
return ($taxonomy_image_url != '') ? $taxonomy_image_url : CATEGORY_IMAGE_PLACEHOLDER;
else
return $taxonomy_image_url;
}
function z_quick_edit_custom_box( $column_name, $screen, $name ) {
if ( $column_name == 'thumb' )
echo '';
}
/**
* Thumbnail column added to category admin.
*
* @access public
* @param mixed $columns
* @return void
*/
function z_taxonomy_columns( $columns ) {
$new_columns = array();
$new_columns['cb'] = $columns['cb'];
$new_columns['thumb'] = __( 'Image', 'limelight-core' );
unset( $columns['cb'] );
return array_merge( $new_columns, $columns );
}
/**
* Thumbnail column value added to category admin.
*
* @access public
* @param mixed $columns
* @param mixed $column
* @param mixed $id
* @return void
*/
function z_taxonomy_column( $columns, $column, $id ) {
if ( $column == 'thumb' )
$columns = '';
return $columns;
}
//change 'insert into post' to 'use this image'
function z_change_insert_button_text( $safe_text, $text ) {
return str_replace( "Insert into Post", "Use this image", $text );
}
//style the image in category list
if ( strpos( $_SERVER['SCRIPT_NAME'], 'edit-tags.php' ) > 0 ) {
add_action( 'admin_head', 'z_add_style' );
add_action( 'quick_edit_custom_box', 'z_quick_edit_custom_box', 10, 3 );
add_filter( "attribute_escape", "z_change_insert_button_text", 10, 2 );
}
//register plugin settings
function z_register_settings() {
register_setting( 'zci_options', 'zci_options', 'z_options_validate' );
add_settings_section( 'zci_settings', __( 'Categories Images settings', 'limelight-core' ), 'z_section_text', 'zci-options' );
add_settings_field( 'z_excluded_taxonomies', __( 'Excluded Taxonomies', 'limelight-core' ), 'z_excluded_taxonomies', 'zci-options', 'zci_settings' );
}
//display taxonomy image for the given term_id
function z_taxonomy_image( $term_id = NULL, $size = 'full', $attr = NULL, $echo = TRUE ) {
if ( ! $term_id ) {
if ( is_category() )
$term_id = get_query_var( 'cat' );
elseif ( is_tag() )
$term_id = get_query_var( 'tag_id' );
elseif ( is_tax() ) {
$current_term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
$term_id = $current_term->term_id;
}
}
$taxonomy_image_url = get_option( 'z_taxonomy_image' . $term_id );
if( ! empty( $taxonomy_image_url ) ) {
$attachment_id = z_get_attachment_id_by_url( $taxonomy_image_url );
if( ! empty( $attachment_id) )
$taxonomy_image = wp_get_attachment_image( $attachment_id, $size, FALSE, $attr );
else {
$image_attr = '';
if(is_array($attr)) {
if( ! empty($attr['class']) )
$image_attr .= ' class="'.$attr['class'] . '" ';
if( ! empty($attr['alt']) )
$image_attr .= ' alt="'.$attr['alt'] . '" ';
if( ! empty($attr['width']) )
$image_attr .= ' width="'.$attr['width'] . '" ';
if( ! empty($attr['height']) )
$image_attr .= ' height="'.$attr['height'] . '" ';
if( ! empty($attr['title']) )
$image_attr .= ' title="'.$attr['title'] . '" ';
}
$taxonomy_image = '';
}
}
if ( $echo )
echo $taxonomy_image;
else
return $taxonomy_image;
}
//getting limelight-core
function get_categories_with_images($post_id,$separator ){
//first get all categories of that post
$post_categories = wp_get_post_categories( $post_id );
$cats = array();
foreach($post_categories as $c){
$cat = get_category( $c );
$cat_data = get_option("category_$c");
//and then i just display my category image if it exists
$cat_image = '';
if (isset($cat_data['img'])){
$cat_image = '';
}
$cats[] = $cat_image . '' .$cat->name .'';
}
return implode($separator , $cats);
}
function limelight_theme_options_create_menu(){
add_theme_page(
__( 'LimeLight Core', 'limelight-core' ),
__( 'LimeLight Core Settings', 'limelight-core' ),
__( 'manage_options', 'limelight-core' ),
__( 'Theme Settings', 'limelight-core' ),
'limelight_theme_options_page'
);
add_action( 'admin_init', 'limelight_theme_options_settings' );
}
add_action( 'admin_menu', 'limelight_theme_options_create_menu' );
function limelight_theme_options_settings() {
register_setting( 'limelight-theme-settings', 'hero_image_1' );
register_setting( 'limelight-theme-settings', 'hero_image_2' );
register_setting( 'limelight-theme-settings', 'hero_image_3' );
register_setting( 'limelight-theme-settings', 'hero_image_4' );
register_setting( 'limelight-theme-settings', 'hero_image_5' );
register_setting( 'limelight-theme-settings', 'hero_link_1' );
register_setting( 'limelight-theme-settings', 'hero_link_2' );
register_setting( 'limelight-theme-settings', 'hero_link_3' );
register_setting( 'limelight-theme-settings', 'hero_link_4' );
register_setting( 'limelight-theme-settings', 'hero_link_5' );
register_setting( 'limelight-theme-settings', 'header_color' );
register_setting( 'limelight-theme-settings', 'link_color' );
register_setting( 'limelight-theme-settings', 'per_page' );
register_setting( 'limelight-theme-settings', 'home_per_cat' );
register_setting( 'limelight-theme-settings', 'home_comments' );
register_setting( 'limelight-theme-settings', 'home_posts' );
register_setting( 'limelight-theme-settings', 'grid_layout' );
register_setting( 'limelight-theme-settings', 'home_cat_1' );
register_setting( 'limelight-theme-settings', 'home_cat_2' );
register_setting( 'limelight-theme-settings', 'home_cat_3' );
register_setting( 'limelight-theme-settings', 'hide_wp_logos' );
register_setting( 'limelight-theme-settings', 'remove_powered_by' );
}
function limelight_theme_options_page() {
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( __( 'You do not have sufficient permissions to access this page.', 'limelight-core' ) );
}
?>
Configure Your LimeLight Core Theme Here...
set( 'posts_per_page', get_option( 'per_page' ) );
}
}
return $query;
}
add_action( 'pre_get_posts', 'limelight_posts_per_page' );
function limelight_core_activate() {
//DEFAULTS
//theme settings
update_option( 'hero_image_1', home_url() . '/wp-content/themes/limelight-core/assets/hero01.png' );
update_option( 'hero_image_2', home_url() . '/wp-content/themes/limelight-core/assets/hero02.png' );
update_option( 'hero_image_3', home_url() . '/wp-content/themes/limelight-core/assets/hero03.png' );
update_option( 'hero_image_4', home_url() . '/wp-content/themes/limelight-core/assets/hero04.png' );
update_option( 'hero_image_5', home_url() . '/wp-content/themes/limelight-core/assets/hero05.png' );
update_option( 'hero_link_1', '/shop/gourmet-coffee' );
update_option( 'hero_link_2', '/advanced-one-click-checkout/' );
update_option( 'hero_link_3', '/shop/organic-sugar/' );
update_option( 'hero_link_4', '/blog/' );
update_option( 'hero_link_5', '/shop/merchandise/' );
update_option( 'home_cat_1', 'Gourmet Coffee' );
update_option( 'home_cat_2', 'Organic Sugar' );
update_option( 'home_cat_3', 'Merchandise' );
update_option( 'home_comments', '1' );
update_option( 'home_posts', '1' );
update_option( 'home_per_cat', '4' );
update_option( 'grid_layout', '4' );
update_option( 'per_page', '8' );
update_option( 'hide_wp_logos', '1' );
//image sizes
update_option( 'medium_size_w', '400' );
update_option( 'medium_size_h', '400' );
update_option( 'uploads_use_yearmonth_folders', '0' );
//user registration
update_option( 'users_can_register', '1' );
//widgets
update_option( 'sidebars_widgets', array() );
//comments
//permalinks
update_option( 'permalink_structure', '/%postname%/' );
//navigation menu
$menuname = 'Primary Menu';
$bpmenulocation = 'primary';
$menu_exists = wp_get_nav_menu_object( $menuname );
if( ! $menu_exists ) {
$menu_id = wp_create_nav_menu( $menuname );
//build menu better later
/*
wp_update_nav_menu_item( $menu_id, 0, array(
'menu-item-title' => __('Home'),
'menu-item-classes' => 'home',
'menu-item-url' => home_url( '/' ),
'menu-item-status' => 'publish',
) );
*/
}
if( ! has_nav_menu( $bpmenulocation ) ) {
$locations = get_theme_mod( 'nav_menu_locations' );
$locations[$bpmenulocation] = $menu_id;
set_theme_mod( 'nav_menu_locations', $locations );
}
//home + blog pages setup
$homepage = get_page_by_title( 'Home' );
$blogpage = get_page_by_title( 'Blog' );
if ( $homepage )
{
update_option( 'page_on_front', $homepage->ID );
update_option( 'show_on_front', 'page' );
}
if ( $blogpage )
{
update_option( 'page_for_posts', $blogpage->ID );
}
}
add_action('after_switch_theme', 'limelight_core_activate');
?>