is_mobile = apply_filters( 'fastfood_filter_is_mobile', $this->device_detect() ); // check if is mobile browser
add_action( 'template_redirect', array( $this, 'init' ) ); // mobile support
add_action( 'after_setup_theme', array( $this, 'setup' ) ); // Tell WordPress to run setup() when the 'after_setup_theme' hook is run.
add_action( 'widgets_init', array( $this, 'widget_area_init' ) ); // Register sidebars by running widget_area_init() on the widgets_init hook
add_action( 'fastfood_hook_change_view' , array( $this, 'change_view_link' ) );
}
function get_option ( $option ) {
return fastfood_get_opt( $option );
}
// mobile detect
function device_detect() {
if ( is_admin() || is_feed() ) return false;
// #1 check: mobile support is off (via options)
if ( ! $this->get_option( 'fastfood_mobile_css' ) ) return false;
// #2 check: mobile override, the user clicked the "switch to desktop/mobile" link. a cookie will be set
if ( isset( $_GET['mobile_override'] ) ) {
if ( md5( $_GET['mobile_override'] ) == '532c28d5412dd75bf975fb951c740a30' ) { // 'mobile'
setcookie( "mobile_override", "mobile", time()+(60*60*24*30*12) );
return true;
} else {
setcookie( "mobile_override", "desktop", time()+(60*60*24*30*12) );
return false;
}
}
// #3 check: the cookie is already set
if (isset( $_COOKIE["mobile_override"]) ) {
if ( md5( $_COOKIE["mobile_override"] ) == '532c28d5412dd75bf975fb951c740a30' ) { // 'mobile'
return true;
} else {
return false;
}
}
// #4 check: search for a mobile user agent
if ( !isset( $_SERVER['HTTP_USER_AGENT']) ) return false;
$invalids = array( '+', '*', '?', '^', '$', '(', ')', '[', ']', '&', '*', '%', '/', "'", '"', '<', '>', '\\' );
// get only 128 characters and delete characters not needed
$user_agent = str_replace( $invalids,' ',substr( $_SERVER['HTTP_USER_AGENT'],0,128) );
if ( $this->get_option( 'fastfood_mobile_css' ) && preg_match( '/(ipad|ipod|iphone|android|opera mini|blackberry|palm|symbian|palm os|palm|hiptop|avantgo|plucker|xiino|blazer|elaine|iris|3g_t|windows ce|opera mobi|windows ce; smartphone;|windows ce; iemobile|mini 9.5|vx1000|lge |m800|e860|u940|ux840|compal|wireless| mobi|ahong|lg380|lgku|lgu900|lg210|lg47|lg920|lg840|lg370|sam-r|mg50|s55|g83|t66|vx400|mk99|d615|d763|el370|sl900|mp500|samu3|samu4|vx10|xda_|samu5|samu6|samu7|samu9|a615|b832|m881|s920|n210|s700|c-810|_h797|mob-x|sk16d|848b|mowser|s580|r800|471x|v120|rim8|c500foma:|160x|x160|480x|x640|t503|w839|i250|sprint|w398samr810|m5252|c7100|mt126|x225|s5330|s820|htil-g1|fly v71|s302|-x113|novarra|k610i|-three|8325rc|8352rc|sanyo|vx54|c888|nx250|n120|mtk |c5588|s710|t880|c5005|i;458x|p404i|s210|c5100|teleca|s940|c500|s590|foma|samsu|vx8|vx9|a1000|_mms|myx|a700|gu1100|bc831|e300|ems100|me701|me702m-three|sd588|s800|8325rc|ac831|mw200|brew |d88|htc\/|htc_touch|355x|m50|km100|d736|p-9521|telco|sl74|ktouch|m4u\/|me702|8325rc|kddi|phone|lg |sonyericsson|samsung|240x|x320|vx10|nokia|sony cmd|motorola|up.browser|up.link|mmp|symbian|smartphone|midp|wap|vodafone|o2|pocket|kindle|mobile|psp|treo)/i' , $user_agent ) ) { // there were other words for mobile detecting but this is enought ;-)
return true;
} else {
return false;
}
}
function init () {
global $content_width;
if ( ! $this->is_mobile ) return;
add_action( 'wp_enqueue_scripts', array( $this, 'stylesheet' ) );
add_action( 'fastfood_mobile_hook_comments_before', array( $this, 'comments_navigation' ) );
add_action( 'fastfood_mobile_hook_comments_after', array( $this, 'comments_navigation' ) );
add_action( 'fastfood_mobile_hook_entry_before', array( $this, 'posts_navigation' ) );
add_action( 'fastfood_mobile_hook_entry_after', array( $this, 'posts_navigation' ) );
add_action( 'fastfood_mobile_hook_entry_after', array( $this, 'page_hierarchy' ) );
add_action( 'fastfood_mobile_hook_content_before', array( $this, 'search_reminder' ) );
add_action( 'fastfood_mobile_hook_content_after', array( $this, 'indexes_navigation' ) );
add_action( 'comment_form_before', array( $this, 'enqueue_comments_reply' ) );
add_filter( 'user_contactmethods', array( $this, 'new_contactmethods' ),10,1 );
add_filter( 'widget_tag_cloud_args', array( $this, 'tag_cloud_filter' ), 90 );
add_filter( 'widget_categories_args', array( $this, 'widget_categories_filter' ), 90 );
add_filter( 'wp_list_categories', array( $this, 'list_categories_filter' ), 90 );
add_filter( 'widget_archives_args', array( $this, 'widget_archives_filter' ), 90 );
add_filter( 'widget_pages_args', array( $this, 'widget_pages_filter' ), 90 );
add_filter( 'body_class' , array( $this, 'body_classes' ) );
add_filter( 'post_class' , array( $this, 'post_classes' ) );
add_filter( 'fastfood_mobile_filter_seztitle' , array( $this, 'get_seztitle' ) );
add_filter( 'comment_form_default_fields' , array( $this, 'comments_form_fields' ), 90 );
add_filter( 'comment_form_defaults' , array( $this, 'comment_form_defaults' ), 90 );
add_filter( 'fastfood_filter_taxomony_separator' , array( $this, 'taxomony_separator' ) );
// Set the content width
$content_width = 300;
if ( is_page() )
if ( is_front_page() )
locate_template( array( 'mobile/loop-front-page-mobile.php' ), true, false );
else
locate_template( array( 'mobile/loop-single-mobile.php' ), true, false );
elseif ( is_single() )
locate_template( array( 'mobile/loop-single-mobile.php' ), true, false );
else
locate_template( array( 'mobile/loop-index-mobile.php' ), true, false );
exit;
}
function setup() {
register_nav_menus( array( 'mobile' => __( 'Navigation Menu for mobiles
only supports the first level of hierarchy', 'fastfood' ) ) );
}
function widget_area_init() {
// Area 0, in the tbm sidebar.
register_sidebar( array(
'name' => __( 'Mobile Widget Area', 'fastfood' ),
'id' => 'tbm-widget-area',
'description' => '',
'before_widget' => '