Created
May 1, 2012 15:30
-
-
Save Itachicz11/2568852 to your computer and use it in GitHub Desktop.
This is my function.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/*----------------------- Remowe admin bar --------------------------*/ | |
show_admin_bar( false ); | |
/*----------------------- Include shortcodes --------------------------*/ | |
add_filter('the_content', 'do_shortcode'); | |
include("shortcodes.php"); | |
/*----------------------- Include widgets --------------------------*/ | |
// $temppath = get_template_directory_uri(); | |
// include('/widgets/kontakty.php'); | |
/*----------------------- Add rel="prettyphoto" --------------------------*/ | |
add_filter('the_content', 'addlightboxrel_replace'); | |
function addlightboxrel_replace ($content) | |
{ global $post; | |
$pattern = "/<a(.*?)href=('|\")(.*?).(bmp|gif|jpeg|jpg|png)('|\")(.*?)>/i"; | |
$replacement = '<a$1href=$2$3.$4$5 class="prettyPhoto" rel="prettyPhoto"$6>'; | |
$content = preg_replace($pattern, $replacement, $content); | |
$content = str_replace("%LIGHTID%", $post->ID, $content); | |
return $content; | |
} | |
/*----------------------- Disabling Wordpress wpautop and wptexturize filters. --------------------------*/ | |
function webtreats_formatter($content) { | |
$new_content = ''; | |
/* Matches the contents and the open and closing tags */ | |
$pattern_full = '{(\[raw\].*?\[/raw\])}is'; | |
/* Matches just the contents */ | |
$pattern_contents = '{\[raw\](.*?)\[/raw\]}is'; | |
/* Divide content into pieces */ | |
$pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE); | |
/* Loop over pieces */ | |
foreach ($pieces as $piece) { | |
/* Look for presence of the shortcode */ | |
if (preg_match($pattern_contents, $piece, $matches)) { | |
/* Append to content (no formatting) */ | |
$new_content .= $matches[1]; | |
} else { | |
/* Format and append to content */ | |
$new_content .= wptexturize(wpautop($piece)); | |
} | |
} | |
return $new_content; | |
} | |
// Remove the 2 main auto-formatters | |
remove_filter('the_content', 'wpautop'); | |
remove_filter('the_content', 'wptexturize'); | |
// Before displaying for viewing, apply this function | |
add_filter('the_content', 'webtreats_formatter', 99); | |
add_filter('widget_text', 'webtreats_formatter', 99); | |
/*----------------------- Sidebary --------------------------*/ | |
//Page sidebar | |
if ( function_exists('register_sidebar') ) | |
register_sidebar(array( | |
'name' => 'Page sidebar', | |
'before_widget' => '<div id="widget_box">', | |
'after_widget' => '</div>', | |
'before_title' => '<h3 id="widget-title">', | |
'after_title' => '</h3>', | |
)); | |
//Blog sidebar | |
if ( function_exists('register_sidebar') ) | |
register_sidebar(array( | |
'name' => 'Blog sidebar', | |
'before_widget' => '<div id="widget_box">', | |
'after_widget' => '</div>', | |
'before_title' => '<h3 id="widget-title">', | |
'after_title' => '</h3>', | |
)); | |
//Single post sidebar | |
if ( function_exists('register_sidebar') ) | |
register_sidebar(array( | |
'name' => 'Post sidebar', | |
'before_widget' => '<div id="widget_box">', | |
'after_widget' => '</div>', | |
'before_title' => '<h3 id="widget-title">', | |
'after_title' => '</h3>', | |
)); | |
/*----------------------- Footer sidebars --------------------------*/ | |
//Footer sidebar 1 | |
if ( function_exists('register_sidebar') ) | |
register_sidebar(array( | |
'name' => 'Footer sidebar 1', | |
'before_widget' => '<div id="widget_box">', | |
'after_widget' => '</div>', | |
'before_title' => '<h3 id="widget-title">', | |
'after_title' => '</h3>', | |
)); | |
//Footer sidebar 2 | |
if ( function_exists('register_sidebar') ) | |
register_sidebar(array( | |
'name' => 'Footer sidebar 2', | |
'before_widget' => '<div id="widget_box">', | |
'after_widget' => '</div>', | |
'before_title' => '<h3 id="widget-title">', | |
'after_title' => '</h3>', | |
)); | |
//Footer sidebar 3 | |
if ( function_exists('register_sidebar') ) | |
register_sidebar(array( | |
'name' => 'Footer sidebar 3', | |
'before_widget' => '<div id="widget_box">', | |
'after_widget' => '</div>', | |
'before_title' => '<h3 id="widget-title">', | |
'after_title' => '</h3>', | |
)); | |
//Footer sidebar 4 | |
if ( function_exists('register_sidebar') ) | |
register_sidebar(array( | |
'name' => 'Footer sidebar 4', | |
'before_widget' => '<div id="widget_box">', | |
'after_widget' => '</div>', | |
'before_title' => '<h3 id="widget-title">', | |
'after_title' => '</h3>', | |
)); | |
/*----------------------- Registrování menu --------------------------*/ | |
register_nav_menu( 'primary', 'Hlavní menu' ); | |
$defaults = array( | |
'theme_location' => '', | |
'menu' => '', | |
'container' => 'div', | |
'container_class' => 'menu-{menu slug}-container', | |
'container_id' => '', | |
'menu_class' => 'menu', | |
'menu_id' => '', | |
'echo' => true, | |
'fallback_cb' => 'wp_page_menu', | |
'before' => '', | |
'after' => '', | |
'link_before' => '', | |
'link_after' => '', | |
'items_wrap' => '<ul id=\"%1$s\" class=\"%2$s\">%3$s</ul>', | |
'depth' => 0, | |
'walker' => ''); | |
/*--------------------- Register all scripts ------------------------*/ | |
function register_js() { | |
if (!is_admin()) { | |
wp_deregister_script('jquery'); | |
wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js'); | |
wp_register_script('quicksand', get_template_directory_uri() . '/js/jquery.quicksand.js', 'jquery'); | |
wp_register_script('easing', get_template_directory_uri() . '/js/jquery.easing.1.3.js', 'jquery'); | |
wp_register_script('custom', get_template_directory_uri() . '/js/jquery.custom.js', 'jquery', '1.0', TRUE); | |
wp_register_script('prettyPhoto', get_template_directory_uri() . '/js/jquery.prettyPhoto.js', 'jquery'); | |
wp_register_script('flexslider', get_bloginfo( 'template_directory' ) .'/js/jquery.flexslider.js' ); | |
wp_register_script('bootstrap', get_template_directory_uri() . '/js/bootstrap.js', 'jquery'); | |
wp_register_script('metaboxcustom', get_template_directory_uri() . '/js/custom-js.js', 'jquery', '1.0', TRUE); | |
wp_register_script('jqueryuimin', get_template_directory_uri() . '/js/jquery-ui.min.js', 'jquery', '1.0', TRUE); | |
wp_register_script('otherjs', get_template_directory_uri() . '/js/otherjs.js', 'jquery', '1.0', TRUE); | |
wp_enqueue_script('jquery'); | |
wp_enqueue_script('quicksand'); | |
wp_enqueue_script('prettyPhoto'); | |
wp_enqueue_script('easing'); | |
wp_enqueue_script('custom'); | |
wp_enqueue_script('flexslider'); | |
wp_enqueue_script('bootstrap'); | |
wp_enqueue_script('metaboxcustom'); | |
wp_enqueue_script('jqueryuimin'); | |
wp_enqueue_script('otherjs'); | |
} | |
} | |
add_action('init', 'register_js'); | |
/*--------------------- Register all styles ------------------------*/ | |
function register_styles() | |
{ | |
if (!is_admin()) { | |
wp_register_style('prettyPhoto', get_template_directory_uri() . '/css/prettyPhoto.css'); | |
wp_register_style('bootstrap', get_template_directory_uri() . '/css/bootstrap.css'); | |
wp_register_style('style', get_template_directory_uri() . '/style.css'); | |
wp_register_style('flexslider', get_template_directory_uri() . '/css/flexslider.css'); | |
wp_enqueue_style( 'prettyPhoto'); | |
wp_enqueue_style( 'bootstrap'); | |
wp_enqueue_style( 'style'); | |
wp_enqueue_style( 'flexslider'); | |
} | |
} | |
add_action('init', 'register_styles'); | |
/*--------------------- Vložení porfolio ------------------------*/ | |
// Include the portfolio functionality | |
include("portfolio/portfolio-post-type.php"); | |
/*--------------------- Post types ------------------------*/ | |
// Hlavní články | |
add_action('init', 'hlavni_clanky_register'); | |
function hlavni_clanky_register() { | |
$labels = array( | |
'name' => _x('Hlavní články', 'post type general name'), | |
'singular_name' => _x('Hlavní článek', 'post type singular name'), | |
'add_new' => _x('Přidat nový', 'portfolio item'), | |
'add_new_item' => __('Přidat nový hlavní článek'), | |
'edit_item' => __('Upravit hlavní článek'), | |
'new_item' => __('Nový hlavní článek'), | |
'view_item' => __('Zobrazit hlavní článek'), | |
'search_items' => __('Hledat hlavní článek'), | |
'not_found' => __('Nic nenalezeno'), | |
'not_found_in_trash' => __('Nic nenalezeno v koši'), | |
'parent_item_colon' => '' | |
); | |
$args = array( | |
'labels' => $labels, | |
'public' => true, | |
'publicly_queryable' => true, | |
'show_ui' => true, | |
'query_var' => true, | |
//'menu_icon' => get_stylesheet_directory_uri() . '/article16.png', | |
'rewrite' => true, | |
'capability_type' => 'post', | |
'hierarchical' => false, | |
'menu_position' => 5, | |
'supports' => array('title','editor','thumbnail') | |
); | |
register_post_type( 'hlavni_clanky' , $args ); | |
} | |
/*--------------------- Excerpt ------------------------*/ | |
function my_excerpt($excerpt_length = 55, $id = false, $echo = true) { | |
$text = ''; | |
if($id) { | |
$the_post = & get_post( $my_id = $id ); | |
$text = ($the_post->post_excerpt) ? $the_post->post_excerpt : $the_post->post_content; | |
} else { | |
global $post; | |
$text = ($post->post_excerpt) ? $post->post_excerpt : get_the_content(''); | |
} | |
$text = strip_shortcodes( $text ); | |
$text = apply_filters('the_content', $text); | |
$text = str_replace(']]>', ']]>', $text); | |
$text = strip_tags($text); | |
$excerpt_more = ' ' . '...'; | |
$words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY); | |
if ( count($words) > $excerpt_length ) { | |
array_pop($words); | |
$text = implode(' ', $words); | |
$text = $text . $excerpt_more; | |
} else { | |
$text = implode(' ', $words); | |
} | |
if($echo) | |
echo apply_filters('the_content', $text); | |
else | |
return $text; | |
} | |
function get_my_excerpt($excerpt_length = 55, $id = false, $echo = false) { | |
return my_excerpt($excerpt_length, $id, $echo); | |
} | |
/*--------------------- Metaboxes one ------------------------*/ | |
include_once 'functions/add_meta_box.php'; | |
/*--------------------- Thumbnail sizes ------------------------*/ | |
if ( function_exists( 'add_theme_support' ) ) { // Added in 2.9 | |
add_theme_support( 'post-thumbnails' ); | |
add_image_size( 'homepage-thumbnail', 216, 116, true); // Homepage thumbnail size | |
add_image_size( 'blog_fullwidth', 1158, 320, true); // Blog full width size | |
add_image_size( 'blog_tree_column', 358, 170, true); // Blog tree columns size | |
add_image_size( 'blog_sidebar', 696, 230, true); // Blog with sidebar size | |
add_image_size( 'portfolio_one', 1158, 300, true); // Blog with sidebar size | |
add_image_size( 'portfolio_two', 558, 196, true); // Blog with sidebar size | |
add_image_size( 'portfolio_three', 358, 170, true); // Blog with sidebar size | |
add_image_size( 'portfolio_four', 266, 140, true); // Blog with sidebar size | |
add_image_size( 'recent_post', 50, 50, true); // Blog with sidebar size | |
} | |
// This was not meant not to replace your functions.php file. Just copy and paste the codes below into your own functions.php file. | |
/*-----------------------------------------------------------------------------------*/ | |
// Options Framework | |
/*-----------------------------------------------------------------------------------*/ | |
// Paths to admin functions | |
define('ADMIN_PATH', STYLESHEETPATH . '/admin/'); | |
define('ADMIN_DIR', get_template_directory_uri() . '/admin/'); | |
define('LAYOUT_PATH', ADMIN_PATH . '/layouts/'); | |
// You can mess with these 2 if you wish. | |
$themedata = get_theme_data(STYLESHEETPATH . '/style.css'); | |
define('THEMENAME', $themedata['Name']); | |
define('OPTIONS', 'of_options'); // Name of the database row where your options are stored | |
define('BACKUPS','of_backups'); // Name of the database row for options backup | |
// Build Options | |
require_once (ADMIN_PATH . 'admin-interface.php'); // Admin Interfaces | |
require_once (ADMIN_PATH . 'theme-options.php'); // Options panel settings and custom settings | |
require_once (ADMIN_PATH . 'admin-functions.php'); // Theme actions based on options settings | |
require_once (ADMIN_PATH . 'medialibrary-uploader.php'); // Media Library Uploader |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment