------------------------------------------------------------------------------*/ remove_action('wp_head', 'rsd_link'); remove_action('wp_head', 'wp_generator'); remove_action('wp_head', 'feed_links', 2); remove_action('wp_head', 'index_rel_link'); remove_action('wp_head', 'wlwmanifest_link'); remove_action('wp_head', 'feed_links_extra', 3); remove_action('wp_head', 'start_post_rel_link', 10, 0); remove_action('wp_head', 'parent_post_rel_link', 10, 0); remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0); remove_action('wp_head', 'print_emoji_detection_script', 7); remove_action('wp_print_styles', 'print_emoji_styles'); remove_action('admin_print_scripts', 'print_emoji_detection_script' ); remove_action('admin_print_styles', 'print_emoji_styles' ); remove_action('wp_head', 'wp_generator' ); //////////////////////////////////////////////////////////////////////////////// //MENUS AND NAVIGATION //////////////////////////////////////////////////////////////////////////////// /* ENABLE WP_NAV_MENU() ------------------------------------------------------------------------------*/ add_theme_support('menus'); /* CREATE A BOOTSTRAP MENU WALKER ------------------------------------------------------------------------------*/ class Bootstrap_Nav_Walker extends Walker_Nav_Menu { function start_lvl(&$output, $depth = 0, $args = array()) { $output .= "\n
    \n"; } function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { $item_html = ''; parent::start_el($item_html, $item, $depth, $args); if ( $item->is_dropdown && $depth === 0 ) { $item_html = str_replace( '', ' ', $item_html ); } $output .= $item_html; } function display_element($element, &$children_elements, $max_depth, $depth = 0, $args, &$output) { if ( $element->current ) $element->classes[] = 'active'; $element->is_dropdown = !empty( $children_elements[$element->ID] ); if ( $element->is_dropdown ) { if ( $depth === 0 ) { $element->classes[] = 'dropdown'; } elseif ( $depth === 1 ) { // Extra level of dropdown menu, // as seen in http://twitter.github.com/bootstrap/components.html#dropdowns $element->classes[] = 'dropdown-submenu'; } } parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output); } } //Deletes all CSS classes and id's, except for those listed in the array below function si_custom_wp_nav_menu($var) { return is_array($var) ? array_intersect($var, array( //List of allowed menu classes 'dropdown', 'menu-item', 'current_page_item', 'current_page_parent', 'current_page_ancestor', 'first', 'last', 'vertical', 'horizontal', 'homelink' ) ) : ''; } add_filter('nav_menu_css_class', 'si_custom_wp_nav_menu'); add_filter('nav_menu_item_id', 'si_custom_wp_nav_menu'); add_filter('page_css_class', 'si_custom_wp_nav_menu'); //Replaces "current-menu-item" with "active" function si_current_to_active($text){ $replace = array( //List of menu item classes that should be changed to "active" 'current_page_item' => 'active', 'current_page_parent' => 'active', 'current_page_ancestor' => 'active', ); $text = str_replace(array_keys($replace), $replace, $text); return $text; } add_filter ('wp_nav_menu','si_current_to_active'); //////////////////////////////////////////////////////////////////////////////// //CATEGORIES AND TAXONOMIES //////////////////////////////////////////////////////////////////////////////// /* EXCLUDE CATEGORIES FROM SHOWING ------------------------------------------------------------------------------*/ function si_excluded_category($excludedcats = array()){ $count = 0; $categories = get_the_category(); foreach($categories as $category) { $count++; if ( !in_array($category->cat_ID, $excludedcats) ) { echo '' . $category->name.''; if( $count != count($categories) ){ echo ", "; } } } } //////////////////////////////////////////////////////////////////////////////// //POST AND PAGES FUNCTIONS //////////////////////////////////////////////////////////////////////////////// /* A FUNCTION TO CHECK IF A PAGE IS A SUBPAGE OF AN OTHER SUBPAGE GIVEN AN ID ------------------------------------------------------------------------------*/ function si_is_subpage( $iID = null ){ global $post, $wpdb; if ( is_page() && isset( $post->post_parent ) != 0 ) { $aParent = $wpdb->get_row( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE ID = %d AND post_type = 'page' LIMIT 1", $post->post_parent ) ); if ( is_int( $iID ) > 0 ) if ( $aParent->ID == $iID ) return true; else return false; else if ( $aParent->ID ) return true; else return false; } else { return false; } } /* CHECK IF A CUSTOM POST TYPE HAS ANY CHILDREN / SUBPAGES ------------------------------------------------------------------------------*/ function si_has_children($post_type, $post_id) { $children = get_children(array('post_type'=> $post_type,'post_parent' => $post_id)); if( count( $children ) != 0 ) {return true; } // Has Children else {return false; } // No children } /* DISPLAY THIS PAGE OR CUSTOM POST TYPE PARENT ------------------------------------------------------------------------------*/ function si_display_parent_post(){ global $post; if ($post->post_parent){ $ancestors=get_post_ancestors($post->ID); $root=count($ancestors)-1; $parent = $ancestors[$root]; } else { $parent = $post->ID; } if($post->ID != $parent){ echo ''.get_the_title($parent).''; } } //////////////////////////////////////////////////////////////////////////////// // WIDGETS //////////////////////////////////////////////////////////////////////////////// add_filter('widget_text', 'do_shortcode'); //////////////////////////////////////////////////////////////////////////////// // CONTENT //////////////////////////////////////////////////////////////////////////////// /* ALLOW IFRAME ELEMENTS ------------------------------------------------------------------------------*/ function si_add_iframe($initArray) { $initArray['extended_valid_elements'] = "iframe[id|class|title|style|align|frameborder|height|longdesc|marginheight|marginwidth|name|scrolling|src|width]"; return $initArray; } add_filter('tiny_mce_before_init', 'si_add_iframe'); /* ADD EXCEPTS TO PAGES ------------------------------------------------------------------------------*/ add_action( 'init', 'si_add_excerpts_to_pages' ); function si_add_excerpts_to_pages() { add_post_type_support( 'page', 'excerpt' ); } /* SPLIT CONTENT IN TWO COLUMNS ------------------------------------------------------------------------------*/ //usage // split content into array // $content = split_content(); // output first content section in column1 // echo '
    ', array_shift($content), '
    '; // output remaining content sections in column2 // echo '
    ', implode($content), '
    '; function si_split_content() { global $more; $more = true; $content = preg_split('/<\/span>/i', get_the_content('more')); // first content section in column1 $content_col_1 = array_shift($content); // remaining content sections in column2 if (!empty($content)) $content_col_2 = implode($content); $content_col_1 = apply_filters('the_content', $content_col_1); $content_col_2 = apply_filters('the_content', $content_col_2); return array($content_col_1, $content_col_2); } /* SPLIT THE SHORTCODE GALLERY FROM THE CONTENT ------------------------------------------------------------------------------*/ function si_strip_shortcode_gallery( $content ) { preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); if ( ! empty( $matches ) ) { foreach ( $matches as $shortcode ) { if ( 'gallery' === $shortcode[2] ) { $pos = strpos( $content, $shortcode[0] ); if( false !== $pos ) { return substr_replace( $content, '', $pos, strlen( $shortcode[0] ) ); } } } } return $content; } /* LIMIT WORDS FOR EXCERPTS CONTENT AND MORE ------------------------------------------------------------------------------*/ //usage echo si_limit_words(get_the_excerpt(), '41'); function si_limit_words($string, $word_limit) { $words = explode(' ', $string); $excerpt= implode(' ', array_slice($words, 0, $word_limit)); $striptags = strip_tags($excerpt); return strip_shortcodes( $striptags ); } /* GET EXCERPT BY ID ------------------------------------------------------------------------------*/ function si_get_excerpt_by_id($post_id, $excerpt_length){ $the_post = get_post($post_id); //Gets post ID $the_excerpt = $the_post->post_content; //Gets post_content to be used as a basis for the excerpt //$excerpt_length = 35; //Sets excerpt length by word count $the_excerpt = wp_strip_all_tags(strip_shortcodes($the_excerpt)); //Strips tags and images $the_excerpt = str_replace("\r", "", $the_excerpt); $the_excerpt = str_replace("\n", "", $the_excerpt); $words = explode(' ', $the_excerpt, $excerpt_length + 1); if(count($words) > $excerpt_length) : array_pop($words); array_push($words, '...'); $the_excerpt = implode(' ', $words); endif; return $the_excerpt; } //////////////////////////////////////////////////////////////////////////////// // ANTISPAM //////////////////////////////////////////////////////////////////////////////// /* ADD ANTISPAMBOT TO TIMYMCE EMAILS ------------------------------------------------------------------------------*/ /* Usage (on the HTML tab, not the visual editor) [email address="you@emailcompany.com"] */ function si_antispambot($attr) { extract( shortcode_atts( array( 'address' => '', ), $attr ) ); $email = ''; $email .= antispambot($attr['address']); $email .= ''; return $email; } add_shortcode('email', 'si_antispambot'); //////////////////////////////////////////////////////////////////////////////// //IMAGES //////////////////////////////////////////////////////////////////////////////// /* ADD THEME POST-THUMBNAILS ------------------------------------------------------------------------------*/ add_theme_support( 'post-thumbnails' ); add_theme_support('thumbnail', array('post','pages')); /* REMOVE WIDTH AND HEIGHT FROM IMAGES INSERTED TO EDITOR ------------------------------------------------------------------------------*/ add_filter( 'post_thumbnail_html', 'si_remove_width_attribute', 10 ); add_filter( 'image_send_to_editor', 'si_remove_width_attribute', 10 ); function si_remove_width_attribute( $html ) { $html = preg_replace( '/(width|height)="\d*"\s/', "", $html ); return $html; } /* GET FIRST IMAGE ------------------------------------------------------------------------------*/ function si_get_first_image() { global $post, $posts; $first_img = ''; ob_start(); ob_end_clean(); $transformed_content = apply_filters('the_content',$post->post_content); $output = preg_match_all('//i', $transformed_content, $matches); $first_img = $matches [1] [0]; if(empty($first_img)){ //Defines a default image $first_img = ""; } return ''; } //////////////////////////////////////////////////////////////////////////////// // CONTACT FORM 7 FIX //////////////////////////////////////////////////////////////////////////////// /* CONTACT FORM 7 FIX FOR FIREFOX DATE FIELD ------------------------------------------------------------------------------*/ add_filter( 'wpcf7_support_html5_fallback', '__return_true' ); //////////////////////////////////////////////////////////////////////////////// // USERS //////////////////////////////////////////////////////////////////////////////// /* CHECKS IF A PARTICULAR USER HAS A ROLE. ------------------------------------------------------------------------------*/ function si_check_user_role( $role, $user_id = null ) { if ( is_numeric( $user_id ) ) $user = get_userdata( $user_id ); else $user = wp_get_current_user(); if ( empty( $user ) ) return false; return in_array( $role, (array) $user->roles ); } //////////////////////////////////////////////////////////////////////////////// // ADMINISTRATION //////////////////////////////////////////////////////////////////////////////// /* HIDE FROM MENU FOR SUBSCRIBERS ------------------------------------------------------------------------------*/ add_action( 'admin_menu', 'si_remove_menus_subscribers', 999 ); function si_remove_menus_subscribers() { global $current_user; $current_user = wp_get_current_user(); $current_user_id = $current_user->ID; // get the user ID if($current_user_id != '2' ) { remove_submenu_page( 'index.php', 'my-sites.php' ); remove_menu_page( 'index.php', 'my-sites.php' ); remove_menu_page( 'plugins.php'); remove_menu_page( 'options-general.php'); remove_menu_page( 'tools.php'); remove_menu_page( 'link-manager.php'); //remove_menu_page( 'edit.php'); //remove_menu_page( 'edit.php?post_type=epixeiriseis' ); // http://www.sydmeen.gr/wp-admin/edit.php?post_type=epixeiriseis remove_submenu_page( 'users.php','import-users-from-csv'); remove_submenu_page( 'users.php','ProfileBuilderOptionsAndSettings'); remove_submenu_page( 'themes.php','customize.php'); remove_submenu_page( 'themes.php', 'theme-editor.php'); remove_submenu_page( 'themes.php', 'themes.php' ); remove_submenu_page( 'themes.php','themetester-config'); remove_menu_page( 'edit-comments.php' ); remove_menu_page( 'upload.php' ); remove_submenu_page( 'upload.php','wp-smushit-bulk'); remove_menu_page( 'wp-dbmanager/database-manager.php' ); remove_menu_page( 'edit.php?post_type=acf' ); remove_menu_page( 'wpseo_dashboard' ); remove_menu_page( 'wpcf7' ); } } /* RE-ORDERS TABS IN THE WORDPRESS ADMIN MENU ------------------------------------------------------------------------------*/ function si_custom_menu_order($menu_ord) { global $current_user; $current_user = wp_get_current_user(); $current_user_id = $current_user->ID; // get the user ID if($current_user_id != '2' ) { if (!$menu_ord) return true; return array( 'index.php', 'edit.php?post_type=page', 'edit.php?post_type=team', 'edit.php' ); } } add_filter('custom_menu_order', 'si_custom_menu_order'); add_filter('menu_order', 'si_custom_menu_order'); /* REMOVE FROM ADMIN BAR ------------------------------------------------------------------------------*/ function si_admin_bar() { global $current_user; $current_user = wp_get_current_user(); $current_user_id = $current_user->ID; // get the user ID if($current_user_id != '2' ) { global $wp_admin_bar; //$wp_admin_bar->remove_node('wp-logo'); $wp_admin_bar->remove_node('about'); $wp_admin_bar->remove_node('wporg'); $wp_admin_bar->remove_node('documentation'); $wp_admin_bar->remove_node('support-forums'); $wp_admin_bar->remove_node('feedback'); // $wp_admin_bar->remove_node('view-site'); $wp_admin_bar->remove_node('comments'); $wp_admin_bar->remove_node('updates'); $wp_admin_bar->remove_node('wpseo-menu'); } } add_action( 'wp_before_admin_bar_render', 'si_admin_bar' ); /* DISABLE WORDPRESS ADMIN BAR FOR ALL USERS BUT ADMINS. ------------------------------------------------------------------------------*/ // Disable Admin Bar for everyone if (!function_exists('si_disable_admin_bar')) { function si_disable_admin_bar() { // for the admin page remove_action('admin_footer', 'wp_admin_bar_render', 1000); // for the front-end remove_action('wp_footer', 'wp_admin_bar_render', 1000); // css override for the admin page function remove_admin_bar_style_backend() { echo ''; } add_filter('admin_head','remove_admin_bar_style_backend'); // css override for the frontend function remove_admin_bar_style_frontend() { echo ''; } add_filter('wp_head','remove_admin_bar_style_frontend', 99); } } add_action('init','si_disable_admin_bar'); add_action( 'wp_print_styles', 'si_deregister_admin_styles', 100 ); function si_deregister_admin_styles() { wp_deregister_style( 'wp-admin' ); } /* REMOVE UPDATE NAG ------------------------------------------------------------------------------*/ add_action('admin_menu','si_wp_hide_nag'); function si_wp_hide_nag() { remove_action( 'admin_notices', 'update_nag', 3 ); } /* ADD CUSTOM CSS TO AMMIN TO HIDE UNWANTED ELEMENTS ------------------------------------------------------------------------------*/ add_action('admin_head', 'si_wpadmin_css'); function si_wpadmin_css() { echo ''; } //////////////////////////////////////////////////////////////////////////////// // THEME FUNCTIONS //////////////////////////////////////////////////////////////////////////////// /* REGISTER SIDEBARS ------------------------------------------------------------------------------*/ register_sidebar( array( 'id' => 'left-sidebar', 'name' => __( 'Left Sidebar'), 'class' => 'widget', 'before_title' => '

    ', 'after_title' => '

    ', 'before_widget' => '
    ', 'after_widget' => '
    ', ) ); /* THIS IS THE END*/ /* * 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', 'gallery', 'caption' ) ); //////////////////////////////////////////////////////////////////////////////// //ENQUEUE STYLES AND SCRIPTS //////////////////////////////////////////////////////////////////////////////// function si_enqueue_scripts() { /* Enqueue Scripts */ wp_deregister_script( 'jquery' ); wp_enqueue_script( 'jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', false, null, true); //wp_enqueue_script( 'jquery', get_template_directory_uri() . '/assets/js/jquery.min.js', false, null, true); wp_deregister_script( 'bootstrap' ); wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/bootstrap/js/bootstrap.min.js', false, null, true); wp_deregister_script( 'ieviewportbugworkaround' ); wp_enqueue_script( 'ieviewportbugworkaround', get_template_directory_uri() . '/assets/js/ie10-viewport-bug-workaround.js', false, null, true); wp_deregister_script( 'viewportchecker' ); wp_enqueue_script( 'viewportchecker', get_template_directory_uri() . '/assets/js/viewportchecker.js', false, null, true); wp_deregister_script( 'googlemap' ); wp_enqueue_script( 'googlemap', 'https://maps.googleapis.com/maps/api/js?key=AIzaSyAwV_bZDd6paPc3zEbOphTccyIbA9MA1dc&callback=initMap', false, null, true); wp_deregister_script( 'jscookie' ); wp_enqueue_script( 'jscookie', 'https://cdn.jsdelivr.net/npm/js-cookie@2.2.0/src/js.cookie.min.js', false, null, true); wp_deregister_script( 'touchSwipe' ); wp_enqueue_script( 'touchSwipe', 'https://cdnjs.cloudflare.com/ajax/libs/jquery.touchswipe/1.6.4/jquery.touchSwipe.min.js', false, null, true); wp_deregister_script( 'easing' ); wp_enqueue_script( 'easing', 'https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js', false, null, true); wp_deregister_script( 'totop' ); wp_enqueue_script( 'totop', get_template_directory_uri() . '/assets/js/totop.js', false, null, true); wp_deregister_script( 'featherlight' ); wp_enqueue_script( 'featherlight', 'http://cdn.rawgit.com/noelboss/featherlight/1.7.9/release/featherlight.min.js', false, null, true); wp_deregister_script( 'featherlightgallery' ); wp_enqueue_script( 'featherlightgallery', 'http://cdn.rawgit.com/noelboss/featherlight/1.7.9/release/featherlight.gallery.min.js', false, null, true); wp_deregister_script( 'thememain' ); wp_enqueue_script( 'thememain', get_template_directory_uri() . '/thememain.js', false, null, true); /* Enqueue Styles */ wp_deregister_style( 'bootstrap' ); wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/bootstrap/css/bootstrap.css', false, null, 'all'); wp_deregister_style( 'fontawesome' ); wp_enqueue_style( 'fontawesome', 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css', false, null, 'all'); wp_deregister_style( 'featherlightcss' ); wp_enqueue_style( 'featherlight', 'http://cdn.rawgit.com/noelboss/featherlight/1.7.9/release/featherlight.min.css', false, null, 'all'); wp_deregister_style( 'featherlightgallerycss' ); wp_enqueue_style( 'featherlightgallery', 'http://cdn.rawgit.com/noelboss/featherlight/1.7.9/release/featherlight.gallery.min.css', false, null, 'all'); wp_deregister_style( 'style' ); wp_enqueue_style( 'style', get_bloginfo('stylesheet_url'), false, null, 'all'); } add_action( 'wp_enqueue_scripts', 'si_enqueue_scripts' ); function si_add_defer_attribute($tag, $handle) { // add script handles to the array below $scripts_to_defer = array('googlemap'); foreach($scripts_to_defer as $defer_script) { if ($defer_script === $handle) { return str_replace(' src', ' defer src', $tag); } } return $tag; } add_filter('script_loader_tag', 'si_add_defer_attribute', 10, 2); function si_add_async_attribute($tag, $handle) { // add script handles to the array below $scripts_to_async = array('googlemap'); foreach($scripts_to_async as $async_script) { if ($async_script === $handle) { return str_replace(' src', ' async src', $tag); } } return $tag; } add_filter('script_loader_tag', 'si_add_async_attribute', 10, 2); ?>