$firefox, 'safari' => $safari, 'chrome' => $chrome, 'IE6' => $IE6, 'IE7' => $IE7, 'IE8' => $IE8, 'IE9' => $IE9, 'IE10' => $IE10, 'IE11' => $IE11, 'IE12' => $IE12 ); $browsersResult = array(); foreach ( $browsers as $key => $value ) { if( $value === false OR $value === null ){ continue; } $browsersResult[$key] = [$value]; } return $browsersResult; } //IF FIREFOX VERSION IS LOWER THAN 36 $firefox_versio_ok = ( $firefox AND $browser_ver['version'] <= 35 ) ? true : false; //CHECK TAHT BROWSER DETECT FILES ARE LOADED if( !class_exists('Mobile_Detect') ) { require __DIR__ . '/../autoload/Mobile_Detect.php'; } if( !class_exists('Browser') ) { require __DIR__ . '/../autoload/Browser_Detect.php'; } //https://github.com/cbschuld/Browser.php //INSANTIATE MOBILE DETECTION (http://mobiledetect.net/ prefix}posts WHERE (post_status='draft' OR post_status='pending') AND ID=%d && post_type=%s"; foreach ( $items as $k => $item ) { if( in_array($item->object, $allowed_posttypes) ) { $query = $wpdb->prepare( $sql, $item->object_id, $item->object ); $result = $wpdb->get_var( $query ); if( $result ) unset( $items[$k] ); } } return $items; } add_filter( 'wp_get_nav_menu_items', 'exclude_draft_nav_items', 10, 3 ); //ADD CUSTOM CLASSES TO MENU ITEMS function nav_menu_item_parent_classing( $classes, $item ){ global $wpdb; if( in_array('current-menu-item', $item->classes) ){ array_push( $classes, "active" ); } // if($item->title == "Etusivu"){ // array_push( $classes, "Etusivu22" ); // } return $classes; } add_filter( "nav_menu_css_class", "nav_menu_item_parent_classing", 10, 2 );max_num_pages > 1); } get_template_directory_uri(), 'siteURL' => home_url(), 'loginBackgroundImagesCount' => countFiles(), 'logoFormat' => check_logo_file_type(), )); } add_action( 'login_enqueue_scripts', 'themeslug_enqueue_style', 10 ); add_action( 'login_enqueue_scripts', 'themeslug_enqueue_script', 1 ); //REMOVE WRONG WP LOGIN SHAKE EFFECT function my_login_head() { remove_action( 'login_head', 'wp_shake_js', 12 ); } add_action( 'login_head', 'my_login_head' ); // First, create a function that includes the path to your favicon function add_favicon_to_admin() { $favicon_url = get_stylesheet_directory_uri() . '/favicon.ico'; echo ''; } add_action('login_head', 'add_favicon_to_admin'); add_action('admin_head', 'add_favicon_to_admin'); $lenght AND strpos( $content, ' ', $lenght ) !== false ) { echo rtrim( substr( $content, 0, strpos( $content, ' ', $lenght ) )) . $append; } else { echo $content; } } //LIMIT THE_TITLE AND STRIP ALL TAGS EXAMPLE: limit_the_title('40', '...'); function limit_the_title( $lenght = false, $append = '...', $tags = false ) { if($lenght === false){ $lenght = defaults_settings('title'); } $title = get_the_title( $before = '', $after = '', FALSE ); if( $tags === false ){ $title = strip_tags( $title ); $content = strip_shortcodes( $content ); } if ( strlen($title) > $lenght AND strpos( $title, ' ', $lenght ) !== false ) { echo rtrim(substr( $title, 0, $lenght )) . $append; } else { echo $title; } } //LIMIT THE_EXCERPT AND STRIP ALL TAGS EXAMPLE: limit_the_excerp('600', '...', false); function limit_the_excerpt( $lenght = false, $append = '...', $tags = false ) { if( $lenght === false ){ $lenght = defaults_settings( 'excerpt' ); } $excerpt = get_the_excerpt( $before = '', $after = '', FALSE ); if( $tags === false ){ $excerpt = strip_tags( $excerpt ); $excerpt = strip_shortcodes( $excerpt ); } if ( strlen( $excerpt ) > $lenght AND strpos( $excerpt, ' ', $lenght ) !== false ) { echo rtrim( substr( $excerpt, 0, strpos( $excerpt, ' ', $lenght ) )) . $append; } else { echo $excerpt; } } //WRAP IFRAME IN: .iframe-container function custom_oembed_filter( $html, $url, $attr, $post_ID ) { $return = '
' . $html . '
'; return $return; } add_filter( 'embed_oembed_html', 'custom_oembed_filter', 10, 4 ) ; //REMOVE AUTOTAGS ("p") FROM EXCERPT remove_filter( 'the_excerpt', 'wpautop' ); //INCLUDE CUSTOM POST TYPE IN MAIN QUERY function add_custom_post_type_to_query( $query ) { if ( $query->is_archive() && $query->is_main_query() AND !is_admin() ) { $psotTypes = array( 'post' ); $psotTypesLoad = custom_post_types_generalization()['customPosttypes']; $mergePostTypes = array_merge( $psotTypes, $psotTypesLoad ); $query->set( 'post_type', $mergePostTypes ); } } add_action( 'pre_get_posts', 'add_custom_post_type_to_query' ); //HUMAN READABLE DATES function human_readable_dates( $postDate = null ){ //SET CORRECT TIMEZONE date_default_timezone_set('Europe/Helsinki'); //IF POST HAS NO DATE if( $postDate === null ){ return " "; } //VARIABLES $postDate = (string) $postDate; //09-09-2016 07:19:54 //DATETIME INSTANES $currentDate = new DateTime; $date = new DateTime($postDate); //DATETIME DIFFERENCE $difference = $currentDate->diff($date); $unit = 'Second'; $count = $difference->s; //SWITCH CASEs switch(true){ case $difference->y > 0: $unit = 'year'; $count = $difference->y; break; case $difference->m > 0: $unit = 'month'; $count = $difference->m; break; case $difference->d > 0: $unit = 'day'; $count = $difference->d; break; case $difference->h > 0: $unit = 'hour'; $count = $difference->h; break; case $difference->i > 0: $unit = 'minute'; $count = $difference->i; break; } if($count === 0){$count = 1;} if($count !== 1){$unit .= 's';} $inversion = ($difference->invert === 0) ? 'from now' : 'ago'; //RETURN VALUE return "{$count} {$unit} {$inversion}"; } //DETERMINATE READING TIME OF POST function reading_time( $characterCount = null ){ $characterCount = strlen(wp_strip_all_tags(strip_shortcodes($characterCount))); if($characterCount <= 500){ $time = "< 1"; }elseif ($characterCount <= 1500){ $time = "3"; }elseif ($characterCount <= 3000){ $time = "5"; }elseif ($characterCount <= 7000){ $time = "7"; }elseif ($characterCount <= 10000){ $time = "10"; }elseif ($characterCount <= 16000){ $time = "15"; }elseif ($characterCount <= 25000){ $time = "20"; }elseif ($characterCount >= 25000){ $time = "20+"; } return $time; } //POST VIEW COUNTER $user = wp_get_current_user(); $allowed_roles = array( 'editor', 'administrator', 'author', 'one_quart_admin', 'one_quart_editor' ); if( defaults_settings('post_views') === true AND !array_intersect( $allowed_roles, $user->roles ) ) { function bees_post_views( $postID ){ if( is_single() AND !empty( $GLOBALS['post'] ) ) { if ( $GLOBALS['post']->ID == get_the_ID() ) { $postID = get_the_ID(); $metaKey = 'bees_post_views'; $views = get_post_meta( $postID, $metaKey, true ); $count = ( empty($views) ? 1 : $views ); $count++; update_post_meta( $postID, $metaKey, $count ); } }else{ return; } } remove_filter( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 ); add_action( 'wp_head', 'bees_post_views' ); } //GET POSTS ALL IMAGE ATTACHMENTS function get_post_attachments( $id ){ $images = get_children( array( 'post_parent' => $id, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', )); //$images = get_attached_media( 'image', $id ); return $images; } FROM IMAGES, OBJECS AND iFRAMES function filter_ptags_on_images( $content ) { $content = preg_replace('/

\s*()?\s*()\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content); $content = preg_replace('/

\s*(*.<\/object>)\s*<\/p>/iU', '\1', $content); return preg_replace('/

\s*(