| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377 | <?php/** * Twenty Fourteen functions and definitions * Set up the theme and provides some helper functions, which are used in the * theme as custom template tags. Others are attached to action and filter * hooks in WordPress to change core functionality. * When using a child theme you can override certain functions (those wrapped * in a function_exists() call) by defining them first in your child theme's * functions.php file. The child theme's functions.php file is included before * the parent theme's file, so the child theme functions would be used. * @link http://codex.wordpress.org/Theme_Development * @link http://codex.wordpress.org/Child_Themes * Functions that are not pluggable (not wrapped in function_exists()) are * instead attached to a filter or action hook. * For more information on hooks, actions, and filters, * @link http://codex.wordpress.org/Plugin_API * @package WordPress * @subpackage Twenty_Fourteen * @since Twenty Fourteen 1.0 *//** * Set up the content width value based on the theme's design. * @see twentyfourteen_content_width() * @since Twenty Fourteen 1.0 */if ( ! isset( $content_width ) ) {	$content_width = 474;}if ( ! function_exists( 'twentyfourteen_setup' ) ) :/** * Twenty Fourteen setup. * Set up theme defaults and registers support for various WordPress features. * Note that this function is hooked into the after_setup_theme hook, which * runs before the init hook. The init hook is too late for some features, such * as indicating support post thumbnails. * @since Twenty Fourteen 1.0 */function twentyfourteen_setup() {	// Add RSS feed links to <head> for posts and comments.	add_theme_support( 'automatic-feed-links' );	// Enable support for Post Thumbnails, and declare two sizes.	add_theme_support( 'post-thumbnails' );	set_post_thumbnail_size( 672, 372, true );	add_image_size( 'twentyfourteen-full-width', 1038, 576, true );	// This theme uses wp_nav_menu() in two locations.	register_nav_menus( array(		'primary'   => __( 'Top primary menu', 'twentyfourteen' ),		'secondary' => __( 'Secondary menu in left sidebar', 'twentyfourteen' ),	) );	/*	 * 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',	) );}endif; // twentyfourteen_setupadd_action( 'after_setup_theme', 'twentyfourteen_setup' );/** * Enqueue scripts and styles for the front end. * @since Twenty Fourteen 1.0 * @return void */function twentyfourteen_scripts() {	// Load our main stylesheet.	wp_enqueue_style( 'twentyfourteen-style', get_stylesheet_uri() );	// Load the Internet Explorer specific stylesheet.	wp_enqueue_style( 'twentyfourteen-ie', get_template_directory_uri() . '/css/ie.css', array( 'twentyfourteen-style' ), '20131205' );	wp_style_add_data( 'twentyfourteen-ie', 'conditional', 'lt IE 9' );	if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); }	wp_enqueue_script( 'twentyfourteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20131209', true );}add_action( 'wp_enqueue_scripts', 'twentyfourteen_scripts' );/** * Extend the default WordPress body classes. * Adds body classes to denote: * 1. Single or multiple authors. * 2. Presence of header image. * 3. Index views. * 4. Full-width content layout. * 5. Presence of footer widgets. * 6. Single views. * 7. Featured content layout. * @since Twenty Fourteen 1.0 * @param array $classes A list of existing body class values. * @return array The filtered body class list. */function twentyfourteen_body_classes( $classes ) {	if ( is_multi_author() ) {		$classes[] = 'group-blog';	}	if ( is_archive() || is_search() || is_home() ) {		$classes[] = 'list-view';	}	if ( is_singular() && ! is_front_page() ) {		$classes[] = 'singular';	}	return $classes;}add_filter( 'body_class', 'twentyfourteen_body_classes' );/** * Extend the default WordPress post classes. * Adds a post class to denote: * Non-password protected page with a post thumbnail. * @since Twenty Fourteen 1.0 * @param array $classes A list of existing post class values. * @return array The filtered post class list. */function twentyfourteen_post_classes( $classes ) {	if ( ! post_password_required() && has_post_thumbnail() ) {		$classes[] = 'has-post-thumbnail';	}	return $classes;}add_filter( 'post_class', 'twentyfourteen_post_classes' );/** * Create a nicely formatted and more specific title element text for output * in head of document, based on current view. * @since Twenty Fourteen 1.0 * @param string $title Default title text for current view. * @param string $sep Optional separator. * @return string The filtered title. */function twentyfourteen_wp_title( $title, $sep ) {	global $paged, $page;	if ( is_feed() ) {		return $title;	}	// Add the site name.	$title .= get_bloginfo( 'name' );	// Add the site description for the home/front page.	$site_description = get_bloginfo( 'description', 'display' );	if ( $site_description && ( is_home() || is_front_page() ) ) {		$title = "$title $sep $site_description";	}	// Add a page number if necessary.	if ( $paged >= 2 || $page >= 2 ) {		$title = "$title $sep " . sprintf( __( 'Page %s', 'twentyfourteen' ), max( $paged, $page ) );	}	return $title;}add_filter( 'wp_title', 'twentyfourteen_wp_title', 10, 2 );function basic_template_scripts() {    wp_deregister_script( 'jquery' ); // jQuery    wp_register_script( 'jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js' );    wp_enqueue_script( 'jquery' );    wp_deregister_script( 'jquery-ui' ); // jQuery UI    wp_register_script( 'jquery-ui', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js', array( 'jquery' ) );    wp_enqueue_script( 'jquery-ui' );    wp_deregister_script( 'nivoslider' ); // nivoSlider    wp_register_script( 'nivoslider', get_bloginfo('template_directory') . '/js/jquery.nivo.slider.pack.js', array( 'jquery' ) );    wp_enqueue_script( 'nivoslider' );    wp_deregister_script( 'climatecontrol-js' ); // Example    wp_register_script( 'climatecontrol-js', get_bloginfo('template_directory') . '/js/climatecontrol.js', array( 'jquery' ) );    wp_enqueue_script( 'climatecontrol-js' );	wp_register_style('nivoslider-css', get_bloginfo('template_directory') . '/css/nivo-slider.css');	wp_enqueue_style('nivoslider-css');}    add_action('wp_enqueue_scripts', 'basic_template_scripts');/* Limit string by words not characters */function limit_words($string, $word_limit) { $words = explode(" ",$string); return implode(" ",array_splice($words,0,$word_limit)); }function remove_menus () {	global $menu;	$restricted = array(__('Links'), __('Comments'));	end ($menu);	while (prev($menu)){		$value = explode(' ',$menu[key($menu)][0]);		if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}	}}add_action('admin_menu', 'remove_menus');add_action("login_head", "my_login_head");function my_login_head() {    echo "     <style>    body.login #login h1 a {        background: url('".get_bloginfo('template_url')."/images/logo_login.png') no-repeat scroll center top transparent;        height: 181px;        width: 269px;		padding:0 25px;    }    </style>    ";}add_filter( 'login_headerurl', 'w4_login_headerurl');function w4_login_headerurl(){    return home_url('/');}function columns_one_third( $atts, $content = null ) { return '<div class="one_third">' . do_shortcode($content) . '</div>'; } add_shortcode('one_third', 'columns_one_third');function columns_one_third_last( $atts, $content = null ) { return '<div class="one_third last">' . do_shortcode($content) . '</div><div class="clearboth"></div>'; } add_shortcode('one_third_last', 'columns_one_third_last');function columns_two_third( $atts, $content = null ) { return '<div class="two_third">' . do_shortcode($content) . '</div>'; } add_shortcode('two_third', 'columns_two_third');function columns_two_third_last( $atts, $content = null ) { return '<div class="two_third last">' . do_shortcode($content) . '</div><div class="clearboth"></div>'; } add_shortcode('two_third_last', 'columns_two_third_last');function columns_one_half( $atts, $content = null ) { return '<div class="one_half">' . do_shortcode($content) . '</div>'; } add_shortcode('one_half', 'columns_one_half');function columns_one_half_last( $atts, $content = null ) { return '<div class="one_half last">' . do_shortcode($content) . '</div><div class="clearboth"></div>'; } add_shortcode('one_half_last', 'columns_one_half_last');function columns_one_fourth( $atts, $content = null ) { return '<div class="one_fourth">' . do_shortcode($content) . '</div>'; } add_shortcode('one_fourth', 'columns_one_fourth');function columns_one_fourth_last( $atts, $content = null ) { return '<div class="one_fourth last">' . do_shortcode($content) . '</div><div class="clearboth"></div>'; } add_shortcode('one_fourth_last', 'columns_one_fourth_last');function columns_three_fourth( $atts, $content = null ) { return '<div class="three_fourth">' . do_shortcode($content) . '</div>'; } add_shortcode('three_fourth', 'columns_three_fourth');function columns_three_fourth_last( $atts, $content = null ) { return '<div class="three_fourth last">' . do_shortcode($content) . '</div><div class="clearboth"></div>'; } add_shortcode('three_fourth_last', 'columns_three_fourth_last');function columns_one_fifth( $atts, $content = null ) { return '<div class="one_fifth">' . do_shortcode($content) . '</div>'; } add_shortcode('one_fifth', 'columns_one_fifth');function columns_one_fifth_last( $atts, $content = null ) { return '<div class="one_fifth last">' . do_shortcode($content) . '</div><div class="clearboth"></div>'; } add_shortcode('one_fifth_last', 'columns_one_fifth_last');function columns_two_fifth( $atts, $content = null ) { return '<div class="two_fifth">' . do_shortcode($content) . '</div>'; } add_shortcode('two_fifth', 'columns_two_fifth');function columns_two_fifth_last( $atts, $content = null ) { return '<div class="two_fifth last">' . do_shortcode($content) . '</div><div class="clearboth"></div>'; } add_shortcode('two_fifth_last', 'columns_two_fifth_last');function columns_three_fifth( $atts, $content = null ) { return '<div class="three_fifth">' . do_shortcode($content) . '</div>'; } add_shortcode('three_fifth', 'columns_three_fifth');function columns_three_fifth_last( $atts, $content = null ) { return '<div class="three_fifth last">' . do_shortcode($content) . '</div><div class="clearboth"></div>'; } add_shortcode('three_fifth_last', 'columns_three_fifth_last');function columns_four_fifth( $atts, $content = null ) { return '<div class="four_fifth">' . do_shortcode($content) . '</div>'; } add_shortcode('four_fifth', 'columns_four_fifth');function columns_four_fifth_last( $atts, $content = null ) { return '<div class="four_fifth last">' . do_shortcode($content) . '</div><div class="clearboth"></div>'; } add_shortcode('four_fifth_last', 'columns_four_fifth_last');function columns_one_sixth( $atts, $content = null ) { return '<div class="one_sixth">' . do_shortcode($content) . '</div>'; } add_shortcode('one_sixth', 'columns_one_sixth');function columns_one_sixth_last( $atts, $content = null ) { return '<div class="one_sixth last">' . do_shortcode($content) . '</div><div class="clearboth"></div>'; } add_shortcode('one_sixth_last', 'columns_one_sixth_last');function columns_five_sixth( $atts, $content = null ) { return '<div class="five_sixth">' . do_shortcode($content) . '</div>'; } add_shortcode('five_sixth', 'columns_five_sixth');function columns_five_sixth_last( $atts, $content = null ) { return '<div class="five_sixth last">' . do_shortcode($content) . '</div><div class="clearboth"></div>'; } add_shortcode('five_sixth_last', 'columns_five_sixth_last');function columns_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-formattersremove_filter('the_content', 'wpautop');remove_filter('the_content', 'wptexturize');// Before displaying for viewing, apply this functionadd_filter('the_content', 'columns_formatter', 99);add_filter('widget_text', 'columns_formatter', 99);/* Pagination as found here: http://design.sparklette.net/teaches/how-to-add-wordpress-pagination-without-a-plugin/ */function pagination($pages = '', $range = 4){       $showitems = ($range * 2)+1;        global $paged;     if(empty($paged)) $paged = 1;      if($pages == '') {         global $wp_query;         $pages = $wp_query->max_num_pages;         if(!$pages) { $pages = 1; }     }         if(1 != $pages)     {         echo "<div class=\"pagination\"><span>Page ".$paged." of ".$pages."</span>";         if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>« First</a>";         if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>‹ Previous</a>";          for ($i=1; $i <= $pages; $i++) {             if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems )) {                 echo ($paged == $i)? "<span class=\"current\">".$i."</span>":"<a href='".get_pagenum_link($i)."' class=\"inactive\">".$i."</a>";             }         }          if ($paged < $pages && $showitems < $pages) echo "<a href=\"".get_pagenum_link($paged + 1)."\">Next ›</a>";           if ($paged < $pages-1 &&  $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>Last »</a>";         echo "</div>\n";     }}/* Added by https://davidawindham.com *//******************************************** * Functions to clean up code output*********************************************//**************** * remove unnecessary items from the head*****************/remove_action('wp_head', 'index_rel_link' );remove_action('wp_head', 'rel_canonical');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_shortlink_wp_head', 10, 0 );remove_action('wp_head', 'parent_post_rel_link', 10, 0 );remove_action('wp_head', 'rsd_link');remove_action('wp_head', 'wlwmanifest_link');remove_action('wp_head', 'wp_generator');remove_action('wp_head', 'feed_links_extra', 3 );remove_action('wp_head', 'feed_links', 2 );remove_action('wp_head', 'wp_oembed_add_discovery_links', 10, 0 );remove_action('wp_head', 'wp_oembed_add_host_js', 10, 0 );/**************** * remove versions (?v=1.0.4 etc.) from javascript and css*****************/add_filter( 'style_loader_src', 'srh_remove_wp_ver_css_js', 9999 );add_filter( 'script_loader_src', 'srh_remove_wp_ver_css_js', 9999 );function srh_remove_wp_ver_css_js( $src ) {    if ( strpos( $src, 'ver=' ) )        $src = remove_query_arg( 'ver', $src );    return $src;}/**************** * disable emojis*****************/add_action( 'init', 'disable_emojis' );function disable_emojis_tinymce( $plugins ) {  if ( is_array( $plugins ) ) {    return array_diff( $plugins, array( 'wpemoji' ) );  } else {    return array();  }}function disable_emojis() {	remove_action( 'wp_head', 'print_emoji_detection_script', 7 );	remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );	remove_action( 'wp_print_styles', 'print_emoji_styles' );	remove_action( 'admin_print_styles', 'print_emoji_styles' );	remove_filter( 'the_content_feed', 'wp_staticize_emoji' );	remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );	remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );	add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' );}add_action('init','avia_remove_debug');function avia_remove_debug(){	remove_action('wp_head','avia_debugging_info',1000);	remove_action('admin_print_scripts','avia_debugging_info',1000);}
 |