function custom_login_redirect() { return '/wp-admin/edit.php?post_type=page'; } function reorder_menu( $__return_true ) { return array( 'index.php', // Dashboard 'edit.php?post_type=page', // Pages 'edit.php', // Posts 'upload.php', // Media 'themes.php', // Appearance 'separator1', // --Space-- 'edit-comments.php', // Comments 'users.php', // Users 'separator2', // --Space-- 'plugins.php', // Plugins 'tools.php', // Tools 'options-general.php', // Settings ); } function remove_menu() { remove_menu_page( 'index.php' ); //Dashboard remove_menu_page( 'jetpack' ); //Jetpack remove_menu_page( 'edit.php' ); //Posts // remove_menu_page( 'upload.php' ); //Media // remove_menu_page( 'edit.php?post_type=page' ); //Pages remove_menu_page( 'edit-comments.php' ); //Comments //remove_menu_page( 'themes.php' ); //Appearance remove_menu_page( 'plugins.php' ); //Plugins // remove_menu_page( 'users.php' ); //Users remove_menu_page( 'tools.php' ); //Tools remove_menu_page( 'options-general.php' ); //Settings } function hide_editor() { $template_file = $template_file = basename( get_page_template() ); //if ( $template_file !== 'page-about.php' ) { remove_post_type_support('page', 'editor'); //} } function remove_width_attribute( $html ) { $html = preg_replace( '/(width|height)="\d*"\s/', "", $html ); return $html; } function tmg__menu_atts( $atts, $item, $args ) { $atts['data-id'] = get_post_meta( $item->ID, '_menu_item_object_id', true ); return $atts; } function enqueue_scripts( $hook ) { //if( 'index.php' != $hook ) { // Only applies to dashboard panel //return; //} //wp_enqueue_script( 'ajax-script', plugins_url( '/js/my_query.js', __FILE__ ), array('jquery') ); //wp_enqueue_script( 'f-script', get_template_directory_uri() . '/js/f.js' ); wp_enqueue_script( 'f-script', get_template_directory_uri() . '/js/f.min.js' ); // in JavaScript, object properties are accessed as ajax_object.ajax_url, ajax_object.we_value wp_localize_script( 'f-script', 'ajax_object', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) ); } function load_search() { $query = $_POST['query']; $args = array( 'post_type' => 'page', 'post_status' => 'publish', 'posts_per_page' => -1, 'order' => 'ASC', 'orderby' => 'menu_order', 's' => $query ); $search = new WP_Query( $args ); ob_start(); if ( $search->have_posts() ) : while ( $search->have_posts() ) : $search->the_post(); // get depth $postid = get_the_ID(); $depth = ( $postid == get_option('page_on_front') ) ? -1 : 0; while ( $postid > 0 ) { $postid = get_post_ancestors( $postid ); $postid = $postid[0]; $depth++; } if ( $depth > 2 ) { if ( $depth == 3 ) { } } else { // no results } ?>
endwhile; else : // no results endif; wp_reset_postdata(); die(); } function get_sibling_link( $link ) { global $post; $siblings = get_pages('sort_column=menu_order&child_of='.$post->post_parent.'&parent='.$post->post_parent); // no siblings if ( count( $siblings ) == 1 ) { return false; } foreach ( $siblings as $key => $sibling ){ if ( $post->ID == $sibling->ID ) { $current_id = $key; } } $closest = [ 'before' => get_permalink( $siblings[$current_id-1]->ID ), 'after' => get_permalink( $siblings[$current_id+1]->ID ) ]; if ( $siblings[$current_id-1]->ID == '' ) { $closest['before'] = get_permalink( $siblings[count($siblings)-1]->ID ); } if ( $siblings[$current_id+1]->ID == '' ) { $closest['after'] = get_permalink( $siblings[0]->ID ); } if ( $link == 'before' || $link == 'after' ) { echo $closest[$link]; } else { return $closest; } } // add id to wordpress generated menus add_filter( 'nav_menu_link_attributes', 'tmg__menu_atts', 10, 3 ); // when login to admin, show pages add_action('login_redirect', 'custom_login_redirect'); // reorder admin left navigation elements add_filter( 'custom_menu_order', 'reorder_menu' ); add_filter( 'menu_order', 'reorder_menu' ); // remove admin left navigation elements add_action( 'admin_menu', 'remove_menu' ); // hide admin editor on pages add_action( 'admin_head', 'hide_editor' ); // show menu under appearance add_theme_support( 'menus'); // enabled thumbnails for posts add_theme_support( 'post-thumbnails' ); // add scripts add_action( 'wp_enqueue_scripts', 'enqueue_scripts' ); // remove width height posts add_filter( 'post_thumbnail_html', 'remove_width_attribute', 10 ); add_filter( 'image_send_to_editor', 'remove_width_attribute', 10 ); // ajax: search add_action( 'wp_ajax_load_search', 'load_search' ); add_action( 'wp_ajax_nopriv_load_search', 'load_search' ); ?> /* Template Name: Project */ get_header(); ?>echo $textcounter; ?>/ echo $total; ?> the_title(); ?>
if ( $video ) { ?> Unmute } ?>