//REMOVE ADMIN BAR show_admin_bar( false ); //DEFINE WOEDPRESS URL:s define( 'HOME_URI', home_url() ); define( 'THEME_URI', get_stylesheet_directory_uri() ); //THEME define( 'THEME_IMAGES', THEME_URI . '/assets/theme/images' ); define( 'THEME_CSS', THEME_URI . '/assets/theme/css' ); define( 'THEME_JS', THEME_URI . '/assets/theme/js' ); define( 'THEME_ASSETS', THEME_URI . '/assets' ); //DASHBOARD define( 'DASHBOARD_IMAGES', THEME_URI . '/assets/dashboard/images' ); define( 'DASHBOARD_CSS', THEME_URI . '/assets/dashboard/css' ); define( 'DASHBOARD_JS', THEME_URI . '/assets/dashboard/js' ); //REMOVE THE WORDPRESS GENERATOR META TAG (WORDPRESS VERSION) remove_action( 'wp_head', 'wp_generator' ); //REMOVE THE "UPGRADE WORDPRESS" NOTIFICATION FROM CLIENT function hide_update_notice_to_all_but_admin_users() { if ( !current_user_can('update_core') ) { remove_action( 'admin_notices', 'update_nag', 3 ); } } add_action( 'admin_head', 'hide_update_notice_to_all_but_admin_users', 1 ); //INIT CUSTOM WYSIWYG "Formats" SECTION if( defaults_settings( "wysiwyg" ) === true ){ function wpb_mce_buttons_3( $buttons ) { array_unshift( $buttons, 'styleselect' ); return $buttons; } add_filter('mce_buttons_3', 'wpb_mce_buttons_3'); } //CCHEK USERS BROWSER function test_browser(){ $firefox = ( preg_match('/Firefox/i',$_SERVER['HTTP_USER_AGENT']) ) ? true : false; $safari = ( preg_match('/Safari/i',$_SERVER['HTTP_USER_AGENT']) ) ? true : false; $chrome = ( preg_match('/Chrome/i',$_SERVER['HTTP_USER_AGENT']) ) ? true : false; $IE6 = ( preg_match('/(?i)msie 6/',$_SERVER['HTTP_USER_AGENT']) ) ? true : false; $IE7 = ( preg_match('/(?i)msie 7/',$_SERVER['HTTP_USER_AGENT']) ) ? true : false; $IE8 = ( preg_match('/(?i)msie 8/',$_SERVER['HTTP_USER_AGENT']) ) ? true : false; $IE9 = ( preg_match('/(?i)msie 9/',$_SERVER['HTTP_USER_AGENT']) ) ? true : false; $IE10 = ( preg_match('/(?i)msie 10/',$_SERVER['HTTP_USER_AGENT']) ) ? true : false; $IE11 = ( preg_match('/(?i)msie 11/',$_SERVER['HTTP_USER_AGENT']) ) ? true : false; $IE12 = ( preg_match('/(?i)msie 12/',$_SERVER['HTTP_USER_AGENT']) ) ? true : false; $browsers = array( 'firefox' => $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/ //ADD'S SUPPORT FOR TITLE TAG function theme_slug_setup() { add_theme_support( 'title-tag' ); } add_action( 'after_setup_theme', 'theme_slug_setup' ); //REMOVE & ADD CLASSES TO BODY function add_and_remove_classes_from_body( $classes ){ $remove = array( 'page', 'home' ); $add = array(); $classes = array_diff( $classes, $remove ); $classes = array_merge( $classes, $add ); return $classes; } add_filter( 'body_class', 'add_and_remove_classes_from_body' ); //REGISTERS NEW MENU LOCATIONS FUNCTION function register_menus( $menu ){ $menus = array(); foreach ( $menu as $value ) { if( !empty($value) ){ $menuSluq = iconv( 'UTF-8','ASCII//TRANSLIT', $value ); $menuSluq = str_replace( ' ', '-', $menuSluq ); $menuSluq = strtolower( $menuSluq ); $menus[$menuSluq] = $value; }else { continue; } } $menus = array_unique(array_filter( $menus )); register_nav_menus( $menus ); } //WORDPRESS REMOVE DRAFT PAGES FROM NAVIGATION function exclude_draft_nav_items( $items, $menu, $args ){ global $wpdb; //ADD YOUR CUSTOM POSTTYPES TO THIS ARRAY $allowed_posttypes = custom_post_types_generalization()['allPosttypes']; $sql = "SELECT ID FROM {$wpdb->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 ); function show_posts_nav() { global $wp_query; return ($wp_query->max_num_pages > 1); } //COUNT LOGIN BACKGROUND IMAGES function countFiles() { $files = glob(__DIR__.'/../../assets/login/images/body-bg-*.jpg'); if ( $files !== false ){ $filecount = count( $files ); return $filecount; }else{ return 1; } } add_action( 'login_head', 'countFiles', 10, 2 ); //CHECK LOGO FILE FORMAT function check_logo_file_type(){ $files = __DIR__.'/../../assets/login/images/logo.'; if( file_exists($files."svg") ){ return "svg"; }elseif( file_exists($files."png") ){ return "png"; }elseif( file_exists($files."jpg") ){ return "jpg"; } } //LOAD CUSTOM CSS AND JAVASCRIPT FILE TO LOGIN PAGE function themeslug_enqueue_style() { wp_enqueue_style( 'logInStyle', get_template_directory_uri() . '/beeworks/login/custom-login-styles.css', false ); } function themeslug_enqueue_script() { wp_enqueue_script( 'jqueryLogIn', 'https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js', false ); wp_enqueue_script( 'logInScript', get_template_directory_uri() . '/beeworks/login/js/custom-login.js', false ); wp_localize_script( 'logInScript', 'customLoginVariables', array( 'themeDIR' => 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'); //ADD EXERPT SUPPORT FOR WORDPRESS PAGES function my_add_excerpts_to_pages() { add_post_type_support( 'page', 'excerpt' ); } add_action( 'init', 'my_add_excerpts_to_pages' ); //LIMIT THE_CONTENT AND STRIP ALL TAGS EXAMPLE: limit_the_content('600', '...', false); function limit_the_content( $lenght = false, $append = '...', $tags = false ) { if( $lenght === false ){ $lenght = defaults_settings('content'); } $content = get_the_content( $before = '', $after = '', FALSE ); if( $tags === false ){ $content = strip_tags( $content ); $content = strip_shortcodes( $content ); } if ( strlen($content) > $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 = '
FROM IMAGES, OBJECS AND iFRAMES function filter_ptags_on_images( $content ) { $content = preg_replace('/