__('Main Menu', 'betheme'), 'footer_menu' => __('Footer Menu', 'betheme') )); /** Add custom theme header, background, post formats, and etc... * http://codex.wordpress.org/Function_Reference/add_theme_support * * */ /* * This theme does not style the visual editor to resemble the theme style, * specifically font, colors, icons, and column width. * Uncomment line below to add your own styles to the editor. */ add_editor_style(array('css/editor-style.css')); // Adds RSS feed links to for posts and comments. add_theme_support('automatic-feed-links'); // Switches 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')); /* * This theme uses a custom image size for featured images, displayed on * "standard" posts and pages. */ add_theme_support('post-thumbnails'); set_post_thumbnail_size(690, 300, true); // This theme uses BigGallery instead of WordPress default gallerys. add_filter('use_default_gallery_style', '__return_false'); // add custom metaboxs and save the data add_action('add_meta_boxes', 'be_add_custom_box'); add_action('save_post', 'be_save_post'); } } /** remove unwanted elements from */ function be_head_cleanup() { remove_action('wp_head', 'rsd_link'); remove_action('wp_head', 'wlwmanifest_link'); remove_action('wp_head', 'index_rel_link'); remove_action('wp_head', 'parent_post_rel_link', 10, 0); remove_action('wp_head', 'start_post_rel_link', 10, 0); remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0); remove_action('wp_head', 'wp_generator'); } add_action('init', 'be_head_cleanup'); /** remove script versions to enable caching */ function be_remove_script_version($src) { $parts = explode('?', $src); return $parts[0]; } add_filter('script_loader_src', 'be_remove_script_version'); add_filter('style_loader_src', 'be_remove_script_version'); /** * register scripts and styles */ function be_register_scripts_and_styles() { if (!is_admin()) { wp_register_style('style', get_stylesheet_uri(), false, '1.0', 'all'); // Compressed all JS files in scripts.min.js for fewer http calls: // load the latest jQuery from theme library // wp_deregister_script('jquery'); // wp_register_script('jquery', get_template_directory_uri() . '/js/jquery.js', false, '2.0.3', true); // or load from Google CDN // wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js', false, false, true); // or load from WP included library wp_register_script('jquery', false, false, false, true); // Read more about wp_register_script at: http://codex.wordpress.org/Function_Reference/wp_register_script wp_register_script('scripts', get_template_directory_uri() . '/js/scripts.min.js', array('jquery'), false, true); wp_register_script('custom', get_template_directory_uri() . '/js/custom.js', array('jquery', 'scripts'), '1.0', true); wp_register_script('comment-reply', false, false, false, true); } } add_action('init', 'be_register_scripts_and_styles'); /** * enqueue scripts */ function be_enqueue_scripts_and_styles() { if (!is_admin()) { wp_enqueue_style('style'); wp_enqueue_script('jquery'); wp_enqueue_script('scripts'); wp_enqueue_script('custom'); if (is_singular() AND comments_open() AND (get_option('thread_comments'))) { wp_enqueue_script('comment-reply'); } } } add_action('wp_enqueue_scripts', 'be_enqueue_scripts_and_styles'); /** * filter p tags */ function filter_ptags_on_images($content) { return preg_replace('/

\s*()?\s*()\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content); } add_filter('the_content', 'filter_ptags_on_images'); // set post excerpt length function be_excerpt_length($length) { return 140; } add_filter('excerpt_length', 'be_excerpt_length'); /** * set continue reading for excerpt */ function be_continue_reading_link() { return '... ', 'after_widget' => '', 'before_title' => '

', 'after_title' => '

', )); } add_action('widgets_init', 'be_widgets_init'); /** * add custom metaboxs */ function be_add_custom_box() { add_meta_box('be_layout_box', __('Post Layout', 'betheme'), 'be_layout_metabox', 'post', 'side', 'core'); add_meta_box('be_layout_box', __('Page Layout', 'betheme'), 'be_layout_metabox', 'page', 'side', 'core'); } /** * post layout box */ function be_layout_metabox($post) { wp_nonce_field('post_layout_nonce', '_wpnonce_post_layout'); $post_layout = get_post_meta($post->ID, 'be_post_layout', true); ?>

max_num_pages > 1) : ?>
', esc_url(get_permalink()), esc_attr(get_the_time()), esc_attr(get_the_date('c')), esc_html(get_the_date()) ); $author = sprintf('', esc_url(get_author_posts_url(get_the_author_meta('ID'))), esc_attr(sprintf(__('View all posts by %s', 'betheme'), get_the_author())), get_the_author() ); // Translators: 1 is category, 2 is tag, 3 is the date and 4 is the author's name. $utility_text = ""; if ($categories_list) { $utility_text .= __(' %1$s ', 'betheme'); } if ($tag_list) { $utility_text .= __(' %2$s ', 'betheme'); } $utility_text .= __(' %3$s %4$s', 'betheme'); printf( $utility_text, $categories_list, $tag_list, $date, $author ); } endif; if (!function_exists('be_comments')) { function be_comments($comment, $args, $depth) { $GLOBALS['comment'] = $comment; $tag = ( 'div' === $args['style'] ) ? 'div' : 'li'; ?> < id="comment-" >
'div-comment', 'depth' => $depth, 'max_depth' => $args['max_depth']))); ?>
'main_menu', 'theme_location' => 'main_menu', 'container' => 'nav', 'depth' => 2, 'fallback_cb' => 'be_menu_fallback', 'container_id' => 'nav' )); } function be_footer_menu() { $walker = new be_footer_menu_walker; wp_nav_menu(array( 'menu' => 'footer_menu', 'theme_location' => 'footer_menu', 'container' => 'nav', 'container_id' => 'footer-nav', 'depth' => 1, 'fallback_cb' => 'be_menu_fallback', 'walker' => $walker )); } function be_menu_fallback() { return wp_nav_menu(array( 'theme_location' => 'main_menu', 'container' => 'nav', 'depth' => 2, 'container_id' => 'nav' )); } class be_footer_menu_walker extends Walker_Nav_Menu { function start_lvl(&$output, $depth = 0, $args = array()) { if ($depth != 0) return; } function end_lvl(&$output, $depth = 0, $args = array()) { if ($depth != 0) return; } function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { if ($depth != 0) return; global $wp_query; $indent = ( $depth ) ? str0_repeat("\t", $depth) : ''; $class_names = join(' ', apply_filters( 'nav_menu_css_class', array_filter( empty($item->classes) ? array() : (array) $item->classes), $item)); $output .= $indent . '
  • '; $attributes = !empty($item->attr_title) ? ' title="' . esc_attr($item->attr_title) . '"' : ''; $attributes .=!empty($item->target) ? ' target="' . esc_attr($item->target) . '"' : ''; $attributes .=!empty($item->xfn) ? ' rel="' . esc_attr($item->xfn) . '"' : ''; $attributes .=!empty($item->url) ? ' href="' . esc_attr($item->url) . '"' : ''; $item_output = $args->before; $item_output .= ''; $item_output .= $args->link_before . apply_filters('the_title', $item->title, $item->ID) . $args->link_after; $item_output .= ''; $item_output .= $args->after; $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args); } function end_el(&$output, $item, $depth = 0, $args = array()) { if ($depth != 0) return; $output .= "
  • \n"; } } /** * Big Gallery replaces WordPress default gallery */ function be_big_gallery($output, $attr) { global $post; static $instance = 0; $instance++; // Allow plugins/themes to override the default gallery template. // $output = apply_filters('post_gallery', '', $attr); if ($output != '') return $output; // We're trusting author input, so let's at least make sure it looks like a valid orderby statement if (isset($attr['orderby'])) { $attr['orderby'] = sanitize_sql_orderby($attr['orderby']); if (!$attr['orderby']) unset($attr['orderby']); } extract(shortcode_atts(array( 'order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'gallerytag' => 'ul', 'itemtag' => 'li', 'captiontag' => 'p', 'size' => 'full', 'include' => '', 'exclude' => '' ), $attr)); $id = intval($id); if ('RAND' == $order) $orderby = 'none'; if (!empty($include)) { $include = preg_replace('/[^0-9,]+/', '', $include); $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby)); $attachments = array(); foreach ($_attachments as $key => $val) { $attachments[$val->ID] = $_attachments[$key]; } } elseif (!empty($exclude)) { $exclude = preg_replace('/[^0-9,]+/', '', $exclude); $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby)); } else { $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby)); } if (empty($attachments)) return ''; if (is_feed()) { $output = "\n"; foreach ($attachments as $att_id => $attachment) $output .= wp_get_attachment_link($att_id, $size, true) . "\n"; return $output; } $itemtag = tag_escape($itemtag); $captiontag = tag_escape($captiontag); $selector = "gallery-{$instance}"; $gallery_div = "\n\t\t<{$gallerytag} id='$selector' class='gallery galleryid-{$id} be-slider'>"; $output = apply_filters('big_gallery', $gallery_div); $i = 0; foreach ($attachments as $id => $attachment) { // No link to Attachment photo $link = wp_get_attachment_image($id, 'full'); // Link to Attachement photo // $link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false); ++$i; $output .= "\n\t\t\t<{$itemtag} class='gallery-item"; ($i == 1) ? $output .= " active" : ""; $output .= "'>"; $output .= "\n\t\t\t\t$link\n"; if ($captiontag && trim($attachment->post_excerpt)) { $output .= "\t\t\t\t<{$captiontag} class='be-caption be-bottom'>" . wptexturize($attachment->post_excerpt) . "\n"; } $output .= "\t\t\t"; } $output .= "\n\t\t\n\t\t"; return $output; } add_filter("post_gallery", "be_big_gallery", 10, 2); /** * A simple button shortcode, with option to pass link and additional class * [button link="http://bigemployee.com/" class="big"]Big Employee[/button] * Output: * Big Employee */ function be_add_shortcode_button($atts, $content = null) { extract( shortcode_atts( array( 'link' => '#', 'class' => 'button', ), $atts)); $content = parse_shortcode_content($content); return be_render_button($content, $link, false, $class); } function be_render_button($content = 'new link', $link = '#', $echo = true, $class = 'button') { $class = strip_tags(trim($class)); if (strpos($class, 'button') === FALSE) { $class = 'button ' . $class; } if (!$echo) return '' . do_shortcode($content) . ''; echo '' . do_shortcode($content) . ''; } add_shortcode('button', 'be_add_shortcode_button');