public
anonymous / my functions.php
Created

  • Download Gist
my functions.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406
<?php
global $avia_config;
if(isset($avia_config['use_child_theme_functions_only'])) return;
 
 
/*
* WPML option:
* Set $decativate_legacy_wpml_handling to "false" if you already set up your page for wpml and it works fine for you as it is.
* If you want more control over the translation set it to "true", you will then be able to create a backend option set for each language
*
*/
$decativate_legacy_wpml_handling = true;
 
 
if($decativate_legacy_wpml_handling == true)
{
/*multi site config file - needs to be loaded before the framework*/
require_once( 'config-wpml/config.php' );
}
 
##################################################################
# AVIA FRAMEWORK by Kriesi
 
# this include calls a file that automatically includes all
# the files within the folder framework and therefore makes
# all functions and classes available for later use
require_once( 'framework/avia_framework.php' );
 
##################################################################
 
 
 
//register additional image thumbnail sizes that should be generated when user uploads an image:
$avia_config['imgSize']['widget'] = array('width'=>36, 'height'=>36 ); // small preview pics eg sidebar news
$avia_config['imgSize']['post-format-image'] = array('width'=>630, 'height'=>999, 'crop'=>false); // big images for post format image and gallery posts
$avia_config['imgSize']['fullsize'] = array('width'=>930, 'height'=>930, 'crop'=>false); // big images for lightbox and portfolio single entries
$avia_config['imgSize']['featured'] = array('width'=>930, 'height'=>340); // images for fullsize pages and fullsize slider
$avia_config['imgSize']['portfolio'] = array('width'=>450, 'height'=>335); // images for portfolio entries (2,3,4 column)
 
//dynamic columns
$avia_config['imgSize']['dynamic_1'] = array('width'=>446, 'height'=>151); // images for 2/4 (aka 1/2) dynamic portfolio columns when using 3 columns
$avia_config['imgSize']['dynamic_2'] = array('width'=>609, 'height'=>210); // images for 2/3 dynamic portfolio columns
$avia_config['imgSize']['dynamic_3'] = array('width'=>688, 'height'=>151); // images for 3/4 dynamic portfolio columns
 
 
 
avia_backend_add_thumbnail_size($avia_config);
 
 
 
 
 
 
##################################################################
# Frontend Stuff necessary for the theme:
##################################################################
 
 
$lang = TEMPLATEPATH . '/lang';
load_theme_textdomain('avia_framework', $lang);
 
 
/* Register frontend javascripts: */
if(!is_admin()){
add_action('init', 'avia_frontend_js');
}
 
if(!function_exists('avia_frontend_js'))
{
function avia_frontend_js()
{
wp_register_script( 'avia-default', AVIA_BASE_URL.'js/avia.js', array('jquery','avia-html5-video'), 1, false );
wp_register_script( 'avia-prettyPhoto', AVIA_BASE_URL.'js/prettyPhoto/js/jquery.prettyPhoto.js', 'jquery', "3.0.1", true);
wp_register_script( 'avia-html5-video', AVIA_BASE_URL.'js/projekktor/projekktor.min.js', 'jquery', "1", true);
wp_register_script( 'adaptavia-slider', AVIA_BASE_URL.'js/adaptavia.js', 'jquery', "1.0.0", true);
}
}
 
 
/* Activate native wordpress navigation menu and register a menu location */
add_theme_support('nav_menus');
$avia_config['nav_menus'] = array('avia' => 'Main Menu', 'avia2'=> 'Sub Menu');
foreach($avia_config['nav_menus'] as $key => $value){ register_nav_menu($key, THEMENAME.' '.$value); }
 
 
//adds the plugin initalization scripts that add styles and functions
require_once( 'config-woocommerce/config.php' ); //woocommerce shop plugin
require_once( 'config-bbpress/config.php' ); //bbpress forum plugin
 
//load some frontend functions in folder include:
 
require_once( 'includes/admin/register-portfolio.php' ); // register custom post types for portfolio entries
require_once( 'includes/admin/register-widget-area.php' ); // register sidebar widgets for the sidebar and footer
require_once( 'css/dynamic-css.php' ); // register the styles for dynamic frontend styling
require_once( 'includes/admin/register-shortcodes.php' ); // register wordpress shortcodes
require_once( 'includes/loop-comments.php' ); // necessary to display the comments properly
require_once( 'includes/helper-slideshow.php' ); // holds the class that generates the 2d & 3d slideshows, as well as feature images
require_once( 'includes/helper-templates.php' ); // holds some helper functions necessary for dynamic templates
require_once( 'includes/admin/compat.php' ); // compatibility functions for 3rd party plugins
require_once( 'includes/admin/register-plugins.php'); // register the plugins we need
 
 
 
 
 
 
 
//activate framework widgets
register_widget( 'avia_tweetbox');
register_widget( 'avia_newsbox' );
register_widget( 'avia_portfoliobox' );
register_widget( 'avia_socialcount' );
register_widget( 'avia_combo_widget' );
register_widget( 'avia_partner_widget' );
 
 
 
 
//add post format options
add_theme_support( 'post-formats', array('link', 'quote', 'gallery' ) );
 
 
 
 
 
 
######################################################################
# CUSTOM THEME FUNCTIONS
######################################################################
 
 
//call functions for the theme
add_filter('the_content_more_link', 'avia_remove_more_jump_link');
add_post_type_support('page', 'excerpt');
 
 
//allow mp4, webm and ogv file uploads
add_filter('upload_mimes','avia_upload_mimes');
function avia_upload_mimes($mimes){ return array_merge($mimes, array ('mp4' => 'video/mp4', 'ogv' => 'video/ogg', 'webm' => 'video/webm')); }
 
 
//change default thumbnail size on theme activation
add_action('avia_backend_theme_activation', 'avia_set_thumb_size');
function avia_set_thumb_size() {update_option( 'thumbnail_size_h', 80 ); update_option( 'thumbnail_size_w', 80 );}
 
//remove post thumbnails from page and posts
add_theme_support( 'post-thumbnails' );
add_action('posts_selection', 'avia_remove_post_thumbnails');
add_action('init', 'avia_remove_post_thumbnails');
 
 
if(!function_exists('avia_remove_post_thumbnails'))
{
function avia_remove_post_thumbnails()
{
global $post_type;
$remove_when = array('post','page','portfolio','product');
if(is_admin())
{
foreach($remove_when as $remove)
{
if($post_type == $remove || (isset($_GET['post_type']) && $_GET['post_type'] == $remove)) { remove_theme_support( 'post-thumbnails' ); };
}
}
}
}
 
 
 
 
/*advanced title + breadcrumb function*/
if(!function_exists('avia_title'))
{
function avia_title($title = "", $product = "", $meta = true)
{
if(is_object($title)) $title = $title->post_title;
if(!$title) $title = get_the_title(avia_get_the_id());
$extraClass = "";
if(!$meta) $extraClass = "no_padding_title";
echo "<div class='$extraClass title_container extralight-border'>";
echo '<h1 class="page-title meta-color">'.$title.'</h1>';
echo "<div class='title_meta'>";
/*
* display the theme search form
* the tempalte file that is called is searchform.php in case you want to edit it
*/
if($meta === true)
{
echo '<ul class="social_bookmarks">';
do_action('avia_add_social_icon','header');
if($dribbble = avia_get_option('dribbble')) echo "<li class='dribbble'><a href='http://weibo.com/".$dribbble."'>".__('Follow us on dribbble', 'avia_framework')."</a></li>";
if($twitter = avia_get_option('twitter')) echo "<li class='twitter'><a href='http://twitter.com/".$twitter."'>".__('Follow us on Twitter', 'avia_framework')."</a></li>";
if($facebook = avia_get_option('facebook')) echo "<li class='facebook'><a href='".$facebook."'>".__('Join our Facebook Group', 'avia_framework')."</a></li>";
echo ' <li class="rss"><a href="'.avia_get_option('feedburner',get_bloginfo('rss2_url')).'">RSS</a></li>';
echo '<li class="qq"><a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=1253818673&site=qq&menu=yes"><img border="0" src="http://wpa.qq.com/pa?p=2:1253818673:49" alt="点击这里给我发消息" title="点击这里给我发消息"></a></li></ul>';
}
else if(function_exists($meta))
{
$meta();
}
echo "</div>";
echo "</div>";
}
}
 
 
if(!function_exists('avia_flag'))
{
/*crates the hr separator with the colored flag by using divs without images. Therefore complete color customization from the backend is possible */
function avia_flag($text = "", $class = "")
{
$output = "";
$output .= '<div class="hr hr_flag '.$class.'">';
if($text !== false)
{
$output .= ' <div class="primary-background flag">';
$output .= ' <span class="flag-text on-primary-color">'.$text.'</span>';
$output .= ' <span class="flag-diamond site-background"></span>';
$output .= ' <span class="mini-seperator extralight-border"></span>';
$output .= ' </div>';
}
$output .= ' <span class="hr-seperator extralight-border"></span>';
$output .= ' <span class="primary-background seperator-addon"></span>';
$output .= '</div>';
return $output;
}
}
 
 
if(!function_exists('avia_banner'))
{
function avia_banner($position)
{
$extraClass = "";
$output = "";
$cookieHash = "";
$bannerText = avia_get_option('banner');
$cookieName = THEMENAME.'_avia_banner';
$bannerHash = md5($bannerText);
if($position) $extraClass = 'relative_pos';
if(!empty($_COOKIE[$cookieName])) $cookieHash = $_COOKIE[$cookieName];
$output .= "<div class='$extraClass container_wrap info_text_header' id='info_text_header' data-hash='$bannerHash' data-cookiename='$cookieName'><div class='container no_css_transition'>";
if(trim($bannerText) != "" && $bannerHash != $cookieHash)
{
$output .= "<div class='infotext'>$bannerText <a class='close_info_text rounded' href='#close'>".__('close','avia_framework')."</a></div>";
}
$output .= "</div></div>";
echo $output;
}
}
 
if(!function_exists('avia_shop_banner'))
{
function avia_shop_banner()
{
$pos = false;
$output = "";
$sub = $cart = $menu = "";
if(avia_woocommerce_enabled())
{
# $sub = $cart = avia_woocommerce_cart_dropdown();
}
$sub .= "<div class='sub_menu'>";
$args = array('theme_location'=>'avia2', 'fallback_cb' => '', 'echo' => 0);
if(avia_woocommerce_enabled()) $args['fallback_cb'] ='avia_shop_nav';
$menu = wp_nav_menu($args);
$sub .= $menu;
$sub .= "</div>";
$output .= "<div class='container_wrap info_text_header' id='shop_header'><div class='container'>";
if($cart || $menu)
{
$output .= $sub;
}
else
{
$pos = true;
}
$output .= "</div></div>";
echo $output;
return $pos;
}
}
 
 
 
//set post excerpt to be visible on theme acivation in user backend
add_action('avia_backend_theme_activation', 'avia_show_menu_description');
 
if(!function_exists('avia_show_menu_description'))
{
function avia_show_menu_description()
{
global $current_user;
get_currentuserinfo();
$old_meta_data = $meta_data = get_user_meta($current_user->ID, 'metaboxhidden_page', true);
if(is_array($meta_data) && isset($meta_data[0]))
{
$key = array_search('postexcerpt', $meta_data);
if($key !== false)
{
unset($meta_data[$key]);
update_user_meta( $current_user->ID, 'metaboxhidden_page', $meta_data, $old_meta_data );
}
}
else
{
update_user_meta( $current_user->ID, 'metaboxhidden_page', array('postcustom', 'commentstatusdiv', 'commentsdiv', 'slugdiv', 'authordiv', 'revisionsdiv') );
}
}
}
 
 
 
 
//import the dynamic frontpage template on theme installation
 
add_action('avia_backend_theme_activation', 'avia_default_dynamics');
add_action('avia_ajax_reset_options_page', 'avia_default_dynamics');
 
if(!function_exists('avia_default_dynamics'))
{
function avia_default_dynamics()
{
global $avia;
$firstInstall = get_option($avia->option_prefix.'_dynamic_elements');
 
if(empty($firstInstall))
{
$custom_export = "dynamic_elements";
require_once AVIA_PHP . 'inc-avia-importer.php';
if(isset($_GET['page']) && $_GET['page'] == 'templates')
{
wp_redirect( $_SERVER['REQUEST_URI'] );
exit();
}
}
}
}
 
 
 
 
/*wordpress 3.4 changed 404 check - this is the mod for the avia framework to operate*/
function avia_disable_404( $query = false ) {
 
global $avia_config, $wp_query;
if(!isset($avia_config['first_query_run']) && is_front_page() && is_paged())
{
$wp_query->is_paged = false;
$avia_config['first_query_run'] = true;
add_action( 'wp', 'avia_enable_404' );
}
}
 
function avia_enable_404() {
 
global $wp_query;
$wp_query->is_paged = true;
}
 
add_action( 'pre_get_posts', 'avia_disable_404' ,1 ,10000);
 
function wpr_authorNotification($post_id) {
$post = get_post($post_id);
$author = get_userdata($post->post_author);
 
$message = __('Hi ','avia_framework').$author->display_name.",".__('Your post, ','avia_framework').$post->post_title.__('has just been published. Well done!','avia_framework');
wp_mail($author->user_email, __("Your article is online",'avia_framework'), $message);
}
add_action('publish_post', 'wpr_authorNotification');
 
function my_login_redirect($redirect_to, $request){
if( empty( $redirect_to ) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url() )
return home_url("/index.php");
else
return $redirect_to;
}
add_filter("login_redirect", "my_login_redirect", 10, 3);
 
function my_function_admin_bar(){
return false;
}
add_filter( 'show_admin_bar' , 'my_function_admin_bar');

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.