"; } // init theme function this_theme_setup() { global $content_width; $content_width=800; add_theme_support('post-thumbnails'); set_post_thumbnail_size(266, 1000, false); add_image_size('mini_thumb', 60, 40, false); add_image_size('very_large', 1600, 1600, false); // use different titles remove_filter( 'wp_title', 'boilerplate_filter_wp_title', 10, 2 ); add_filter( 'wp_title', 'custom_page_titles', 10, 2 ); // remove double jquery // if ( !is_admin() ) { // wp_deregister_script('jquery'); // } } add_action( 'init', 'this_theme_setup' ); // disable autosave function disable_autosave() { wp_deregister_script( 'autosave' ); } add_action( 'admin_init', 'disable_autosave' ); // modify mime types of uploader function add_webm_mime_for_upload($mimes) { // for checking: get_allowed_mime_types() $mimes = array_merge($mimes, array( 'webm' => 'video/webm', 'ai' => 'application/illustrator' )); unset($mimes['tif|tiff']); unset($mimes['bmp']); return $mimes; } add_filter('upload_mimes', 'add_webm_mime_for_upload'); // fix links from local vs online version function localhost_to_online_hyperlinks( $content ) { // localhost -> online $content=str_ireplace("http://plansandpolitics.dev", "http://www.plansandpolitics.com/", $content); return $content; } function online_to_localhost_hyperlinks( $content ) { // online -> localhost $content=str_ireplace("http://www.plansandpolitics.com/", "http://plansandpolitics.dev", $content); return $content; } if (!IS_LOCAL_SITE_VERSION) { add_filter('the_content', 'localhost_to_online_hyperlinks' ); } else { add_filter('the_content', 'online_to_localhost_hyperlinks' ); } /* ------------------------------------------------------------------------------------------ BOILERPLATE OVERRIDE ------------------------------------------------------------------------------------------ */ function boilerplate_setup() { add_theme_support( 'automatic-feed-links' ); register_nav_menus( array( 'primary' => __( 'Primary Navigation', 'boilerplate' ), ) ); remove_filter( 'get_the_excerpt', 'boilerplate_custom_excerpt_more' ); remove_filter( 'excerpt_more', 'boilerplate_auto_excerpt_more' ); add_editor_style(); add_filter( 'mce_css', 'add_custom_mce_styles' ); } function custom_page_titles( $title, $separator ) { global $paged, $page; if ( is_feed() ) { // Don't affect wp_title() calls in feeds. return $title; } if (is_home()) { return "Plans & Politics"; } $temp=trim(str_replace($separator, "", $title)); // get rid of seperator in the first place $title = get_bloginfo( 'name', 'display' ); if ($temp!="") { $title.= " $separator ".$temp; } if ( $paged >= 2 || $page >= 2 ) { $title .= " ".sprintf( __( '%s', 'boilerplate' ), max( $paged, $page ) ); } return $title; } /* ------------------------------------------------------------------------------------------ CUSTOMIZE TINYMCE ------------------------------------------------------------------------------------------ */ // add_editor_style() doesn't work, always includes parent css function add_custom_mce_styles() { $custom_css=CHILD_TEMPLATE_DIRECTORY."/css/custom-editor-style.".JS_CSS_VERSION.".css"; return $custom_css; } if ( ! function_exists( 'myCustomTinyMCE' ) ) : function myCustomTinyMCE($init) { $init['theme_advanced_styles'] = 'Don\'t split in columns=dontsplit'; return $init; } endif; add_filter('tiny_mce_before_init', 'myCustomTinyMCE' ); /* ------------------------------------------------------------------------------------------ CUSTOMIZE ADMIN ------------------------------------------------------------------------------------------ */ // rename "posts" -> news function change_post_menu_label() { global $menu; global $submenu; $menu[5][0] = 'News'; $submenu['edit.php'][5][0] = 'News'; $submenu['edit.php'][10][0] = 'Add News'; $submenu['edit.php'][16][0] = 'News Tags'; echo ''; } function change_post_object_label() { global $wp_post_types; $labels = &$wp_post_types['post']->labels; $labels->name = 'News'; $labels->singular_name = 'News'; $labels->add_new = 'Add News'; $labels->add_new_item = 'Add News'; $labels->edit_item = 'Edit News'; $labels->new_item = 'News'; $labels->view_item = 'View News'; $labels->search_items = 'Search News'; $labels->not_found = 'No News found'; $labels->not_found_in_trash = 'No News found in Trash'; } add_action( 'init', 'change_post_object_label' ); add_action( 'admin_menu', 'change_post_menu_label' ); // remove uneccesary menus function remove_menus () { global $menu; $restricted = array(__('Links'), __('News'), __('Comments'), __('Media')); // __('Tools') end ($menu); while (prev($menu)){ $value = explode(' ',$menu[key($menu)][0]); if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);} } } add_action('admin_menu', 'remove_menus'); // add extra stylesheet for admin function my_admin_head() { echo ''; } add_action('admin_head', 'my_admin_head'); // bye Howdy add_action( 'admin_bar_menu', 'wp_admin_bar_my_custom_account_menu', 11 ); function wp_admin_bar_my_custom_account_menu( $wp_admin_bar ) { $user_id = get_current_user_id(); $current_user = wp_get_current_user(); $profile_url = get_edit_profile_url( $user_id ); if ( 0 != $user_id ) { $avatar = get_avatar( $user_id, 28 ); $howdy = sprintf( __('Welcome, %1$s'), $current_user->display_name ); $class = empty( $avatar ) ? '' : 'with-avatar'; $wp_admin_bar->add_menu( array( 'id' => 'my-account', 'parent' => 'top-secondary', 'title' => $howdy . $avatar, 'href' => $profile_url, 'meta' => array( 'class' => $class ), ) ); } } // exchange logo function custom_loginlogo_url($url) { global $THE_THEME_DIR; return "http://www.plansandpolitics.com"; } add_filter( 'login_headerurl', 'custom_loginlogo_url' ); function my_custom_login_logo() { echo ''; } add_action('login_head', 'my_custom_login_logo'); function disable_password_reset() { return false; } add_filter( 'allow_password_reset', 'disable_password_reset' ); function remove_lostpassword_text ( $text ) { if ($text == 'Lost your password?'){ $text = '';} return $text; } add_filter( 'gettext', 'remove_lostpassword_text' ); function remove_back_to_blog() { echo "\n"; } add_action ('login_head', 'remove_back_to_blog' ); /* ------------------------------------------------------------------------------------------ THEME PART HELPER FUNCTION, USED FOR PARTIALS ------------------------------------------------------------------------------------------ */ /** * PP Get Template Part * * An alternative to the native WP function `get_template_part` * * @see PHP class Pp_ThemeView * @param string $file The file path, relative to theme root * @param array $args The arguments to pass to this file. Optional. * Default empty array. * * @return string The HTML from $file */ if( ! function_exists('pp_get_template_part') ){ function pp_get_template_part($file, $args = array()){ $template = new Pp_ThemeView($file, $args); $template->render(); } } /* ------------------------------------------------------------------------------------------ DESIGN STUDIO (COURSES) ------------------------------------------------------------------------------------------ */ function create_courses_post_type() { register_post_type( 'pp_courses', array( 'labels' => array( 'name' => __( 'Design Studio' ), 'singular_name' => __( 'Design Studio' ) ), 'public' => true, 'has_archive' => true, 'menu_position' => 2, 'show_in_nav_menus' => true, 'rewrite' => array('slug' => 'design-studio'), 'supports' => array('title', 'custom-fields', 'editor', 'thumbnail' ) ) ); } add_action( 'init', 'create_courses_post_type' ); // courses overview in admin function courses_edit_columns($columns){ $columns = array( "cb" => "", "title" => "Course", "course_abbr" => "Abbreviation", "course_year" => "Year", "poster_image" => "Image", "id" => "ID", ); return $columns; } add_filter("manage_edit-pp_courses_columns", "courses_edit_columns"); /* ------------------------------------------------------------------------------------------ OPTION SEMINAR ------------------------------------------------------------------------------------------ */ function create_option_seminar_post_type() { register_post_type( 'pp_option_seminar', array( 'labels' => array( 'name' => __( 'Option Seminar' ), 'singular_name' => __( 'Option Seminar' ) ), 'public' => true, 'has_archive' => true, 'show_in_nav_menus' => true, 'menu_position' => 3, 'rewrite' => array('slug' => 'option-seminar'), 'supports' => array('title', 'custom-fields', 'editor', 'thumbnail' ) ) ); } add_action( 'init', 'create_option_seminar_post_type' ); // option_seminar overview in admin function option_seminar_edit_columns($columns){ $columns = array( "cb" => "", "title" => "Option Seminar / Wahlfach", "event_date" => "Date", "poster_image" => "Image", "id" => "ID", ); return $columns; } add_filter("manage_edit-pp_option_seminar_columns", "option_seminar_edit_columns"); /* ------------------------------------------------------------------------------------------ LECTURES ------------------------------------------------------------------------------------------ */ function create_lectures_post_type() { register_post_type( 'pp_lectures', array( 'labels' => array( 'name' => __( 'Lectures' ), 'singular_name' => __( 'Lecture' ) ), 'public' => true, 'has_archive' => true, 'show_in_nav_menus' => true, 'menu_position' => 4, 'rewrite' => array('slug' => 'lectures'), 'supports' => array('title', 'custom-fields', 'editor', 'thumbnail' ) ) ); } add_action( 'init', 'create_lectures_post_type' ); // lectures overview in admin function lectures_edit_columns($columns){ $columns = array( "cb" => "", "title" => "Lecture", "event_date" => "Date", "poster_image" => "Image", "id" => "ID", ); return $columns; } add_filter("manage_edit-pp_lectures_columns", "lectures_edit_columns"); /* ------------------------------------------------------------------------------------------ SEMINAR WEEK ------------------------------------------------------------------------------------------ */ function create_seminar_week_post_type() { register_post_type( 'pp_seminar_week', array( 'labels' => array( 'name' => __( 'Seminar week' ), 'singular_name' => __( 'Semniar week' ) ), 'public' => true, 'has_archive' => true, 'show_in_nav_menus' => true, 'menu_position' => 5, 'rewrite' => array('slug' => 'seminar-week'), 'supports' => array('title', 'custom-fields', 'editor', 'thumbnail' ) ) ); } add_action( 'init', 'create_seminar_week_post_type' ); // lectures overview in admin function seminar_week_edit_columns($columns){ $columns = array( "cb" => "", "title" => "Seminar", "event_date" => "Date", "poster_image" => "Image", "id" => "ID", ); return $columns; } add_filter("manage_edit-pp_seminar_week_columns", "seminar_week_edit_columns"); /* ------------------------------------------------------------------------------------------ MASTER THESIS ------------------------------------------------------------------------------------------ */ function create_master_thesis_post_type() { register_post_type( 'pp_master_thesis', array( 'labels' => array( 'name' => __( 'Master thesis' ), 'singular_name' => __( 'Master thesis' ) ), 'public' => true, 'has_archive' => true, 'show_in_nav_menus' => true, 'menu_position' => 6, 'rewrite' => array('slug' => 'master-thesis'), 'supports' => array('title', 'custom-fields', 'editor', 'thumbnail' ) ) ); } add_action( 'init', 'create_master_thesis_post_type' ); // master_thesis overview in admin function master_thesis_edit_columns($columns){ $columns = array( "cb" => "", "title" => "Project", "date" => "Date", "project_image" => "Images", "id" => "ID", ); return $columns; } add_filter("manage_edit-pp_master_thesis_columns", "master_thesis_edit_columns"); /* ------------------------------------------------------------------------------------------ PROJECTS ------------------------------------------------------------------------------------------ */ function create_projects_post_type() { register_post_type( 'pp_projects', array( 'labels' => array( 'name' => __( 'Research projects' ), 'singular_name' => __( 'Project' ) ), 'public' => true, 'has_archive' => true, 'show_in_nav_menus' => true, 'menu_position' => 7, 'rewrite' => array('slug' => 'projects'), 'supports' => array('title', 'custom-fields', 'editor', 'thumbnail' ) ) ); } add_action( 'init', 'create_projects_post_type' ); // projects overview in admin function projects_edit_columns($columns){ $columns = array( "cb" => "", "title" => "Project", "date" => "Date", "project_image" => "Images", "id" => "ID", ); return $columns; } add_filter("manage_edit-pp_projects_columns", "projects_edit_columns"); /* ------------------------------------------------------------------------------------------ STUDENT PROJECTS ------------------------------------------------------------------------------------------ */ function create_student_projects_post_type() { register_post_type( 'pp_student_projects', array( 'labels' => array( 'name' => __( 'Student projects' ), 'singular_name' => __( 'Project' ) ), 'public' => true, 'has_archive' => true, 'show_in_nav_menus' => true, 'menu_position' => 8, 'rewrite' => array('slug' => 'student-projects'), 'supports' => array('title', 'custom-fields', 'editor', 'thumbnail' ) ) ); } add_action( 'init', 'create_student_projects_post_type' ); // projects overview in admin function student_projects_edit_columns($columns){ $columns = array( "cb" => "", "title" => "Project", "date" => "Date", "project_image" => "Images", "id" => "ID", ); return $columns; } add_filter("manage_edit-pp_student_projects_columns", "student_projects_edit_columns"); /* ------------------------------------------------------------------------------------------ RULES ------------------------------------------------------------------------------------------ */ function create_rule_post_type() { register_post_type( 'pp_rule', array( 'labels' => array( 'name' => __( 'Rules' ), 'singular_name' => __( 'Rule' ) ), 'public' => true, 'has_archive' => true, 'hierarchical' => true, 'show_in_nav_menus' => true, 'menu_position' => 9, 'rewrite' => array('slug' => 'rules'), 'supports' => array('title', 'custom-fields', 'editor', 'thumbnail' ) ) ); } add_action( 'init', 'create_rule_post_type' ); // projects overview in admin function rule_edit_columns($columns){ $columns = array( "cb" => "", "title" => "Rule", "rule_details" => "Details", "rule_scale" => "Scale", "rule_motivation" => "Motivation", "rule_kind_of" => "Kind of Rule", "rule_domain" => "Domain", "rule_images" => "Images" ); return $columns; } add_filter("manage_edit-pp_rule_columns", "rule_edit_columns"); // add Taxononomy Icons function rules_edit_columns($columns){ unset($columns['slug']); $columns['tax_icon'] = 'Icon'; $columns['tax_ai'] = 'Vektor'; return $columns; } // add Scale taxonomy add_action('init', 'ini_scale_tax'); function ini_scale_tax() { register_taxonomy( "rule_scale", array("pp_rule"), array("hierarchical" => true, "label" => "Scale", "singular_label" => "Scale", "rewrite" => true) ); } function rules_scale_edit_columns($columns){ unset($columns['slug']); $columns['short_title'] = 'Short title'; return $columns; } add_filter("manage_edit-rule_scale_columns", "rules_scale_edit_columns"); // add the Icon column // display the short title function rule_scale_custom_column( $value, $column, $term_id){ if ($column=="short_title") { echo get_field('short_title', 'rule_scale_'.$term_id); } } add_action("manage_rule_scale_custom_column", "rule_scale_custom_column", 10, 3); // add Motivation taxonomy add_action('init', 'ini_motivation_tax'); function ini_motivation_tax() { register_taxonomy( "rule_motivation", array("pp_rule"), array("hierarchical" => true, "label" => "Motivation", "singular_label" => "Motivation", "rewrite" => true) ); } add_filter("manage_edit-rule_motivation_columns", "rules_edit_columns"); // add the Icon column // display the Icon function rule_motivation_custom_column( $value, $column, $term_id){ if ($column=="tax_icon") { $img=get_field('icon', 'rule_motivation_'.$term_id); echo ""; } if ($column=="tax_ai") { $vektor=get_field('vektor', 'rule_motivation_'.$term_id); if ($vektor) { echo "√"; } else { echo "—"; } } } add_action("manage_rule_motivation_custom_column", "rule_motivation_custom_column", 10, 3); // add Kind of Rule taxonomy add_action('init', 'ini_kind_of_rule_tax'); function ini_kind_of_rule_tax() { register_taxonomy( "rule_kind_of", array("pp_rule"), array("hierarchical" => true, "label" => "Kind of Rule", "singular_label" => "Kind of Rule", "rewrite" => true) ); } add_filter("manage_edit-rule_kind_of_columns", "rules_edit_columns"); // add the Icon column // display the Icon function rule_kind_of_custom_column( $value, $column, $term_id){ if ($column=="tax_icon") { $img=get_field('icon', 'rule_kind_of_'.$term_id); echo ""; } if ($column=="tax_ai") { $vektor=get_field('vektor', 'rule_kind_of_'.$term_id); if ($vektor) { echo "√"; } else { echo "—"; } } } add_action("manage_rule_kind_of_custom_column", "rule_kind_of_custom_column", 10, 3); // add Domain taxonomy add_action('init', 'ini_domain_tax'); function ini_domain_tax() { register_taxonomy( "rule_domain", array("pp_rule"), array("hierarchical" => true, "label" => "Domain", "singular_label" => "Domain", "rewrite" => true) ); } add_filter("manage_edit-rule_domain_columns", "rules_edit_columns"); // add the Icon column // display the Icon function rule_domain_custom_column( $value, $column, $term_id){ if ($column=="tax_icon") { $img=get_field('icon', 'rule_domain_'.$term_id); echo ""; } if ($column=="tax_ai") { $vektor=get_field('vektor', 'rule_domain_'.$term_id); if ($vektor) { echo "√"; } else { echo "—"; } } } add_action("manage_rule_domain_custom_column", "rule_domain_custom_column", 10, 3); /* ------------------------------------------------------------------------------------------ PUBLICATIONS ------------------------------------------------------------------------------------------ */ function create_publications_post_type() { register_post_type( 'pp_publications', array( 'labels' => array( 'name' => __( 'Publications' ), 'singular_name' => __( 'Publication' ) ), 'public' => true, 'has_archive' => true, 'menu_position' => 5, 'rewrite' => array('slug' => 'publications'), 'supports' => array('title', 'custom-fields', 'editor', 'thumbnail' ) ) ); } add_action( 'init', 'create_publications_post_type' ); // events overview in admin function publications_edit_columns($columns){ $columns = array( "cb" => "", "title" => "Publication", "date" => "Date", "publication_images" => "Images", "id" =>"ID", ); return $columns; } add_filter("manage_edit-pp_publications_columns", "publications_edit_columns"); /* ------------------------------------------------------------------------------------------ ORDER EVENTS BY DATE OF EVENT ------------------------------------------------------------------------------------------ */ add_action( 'pre_get_posts', 'event_column_orderby' ); function event_column_orderby( $query ) { // if(!is_admin() ) { // return; // } // $orderby = $query->get( 'orderby'); // if ( 'event_date' == $orderby ) { // $query->set('meta_key','date'); // $query->set('post_type','pp_events'); // $query->set('orderby','meta_value_num'); // $query->set('order','ASC'); // } //var_dump($query); if( is_admin() ) { return $query; } if (isset($query->query_vars['post_type']) && 'pp_events' == $query->query_vars['post_type']) { $query->set('orderby', 'meta_value_num'); $query->set('meta_key', 'date'); $query->set('order', 'DESC'); // //$query->set('post_type','pp_events'); // $query->set('meta_key','date'); // $query->set('orderby','meta_value_num'); // $query->set('order','DESC'); } return $query; } /* ------------------------------------------------------------------------------------------ EVENTS ------------------------------------------------------------------------------------------ */ function create_events_post_type() { register_post_type( 'pp_events', array( 'labels' => array( 'name' => __( 'Events' ), 'singular_name' => __( 'Event' ) ), 'public' => true, 'has_archive' => true, 'menu_position' => 5, 'rewrite' => array('slug' => 'events'), 'supports' => array('title', 'custom-fields', 'editor', 'thumbnail' ) ) ); } add_action( 'init', 'create_events_post_type' ); // events overview in admin function events_edit_columns($columns){ $columns = array( "cb" => "", "title" => "Event", "event_date" => "Date", "poster_image" => "Image", "id" => "ID", ); return $columns; } add_filter("manage_edit-pp_events_columns", "events_edit_columns"); /* ------------------------------------------------------------------------------------------ CUSTOM COLUMNS ------------------------------------------------------------------------------------------ */ // for custom post types function custom_columns($column){ global $post; switch ($column) { /* ------------------------------------------ ID ------------------------------------------ */ case "id": echo $post->ID; break; /* ------------------------------------------ Projects ------------------------------------------ */ case "project_image": $custom = custom_get_post_thumb($post->ID, 'mini_thumb'); if ($custom!="") { echo ""; } $rows = get_field('images'); if ($rows) { $all_project_images=array(); foreach($rows as $row) { $all_project_images[]=$row['image']; } if (count($all_project_images)>0) { for ($i=0; $i"; } } else { echo "—"; } } else { echo "—"; } break; /* ------------------------------------------ Rules ------------------------------------------ */ case "rule_details": $rule_abbreviation=trim(get_field('rule_abbreviation')); if ($rule_abbreviation!="") { echo $rule_abbreviation."
\n"; } $creator_of_rule=trim(get_field('creator_of_rule')); if ($creator_of_rule!="") { echo $creator_of_rule."
\n"; } $location_text=trim(get_field('location_text')); if ($location_text!="") { echo $location_text."
\n"; } $rows = get_field('cities'); if ($rows) { foreach ($rows as $row) { $city=$row['city']; $geolocation=$row['geolocation']; if ($city!="") { echo "
".$city; if ($geolocation!="") { echo "
".$geolocation."
"; } else { echo "
"; } } } } break; case "rule_scale": $terms = get_the_terms( $post->ID, 'rule_scale' ); if ( $terms && ! is_wp_error( $terms ) ) { $temp = array(); foreach ( $terms as $term ) { $temp[] = "slug."\">".$term->name.""; } if (count($temp)>0) { $temp = join( ", ", $temp ); echo $temp; } else { echo "—"; } } else { echo "—"; } break; case "rule_motivation": $terms = get_the_terms( $post->ID, 'rule_motivation' ); if ( $terms && ! is_wp_error( $terms ) ) { $temp = array(); foreach ( $terms as $term ) { $temp[] = "slug."\">".$term->name.""; } if (count($temp)>0) { $temp = join( ", ", $temp ); echo $temp; } else { echo "—"; } } else { echo "—"; } break; case "rule_kind_of": $terms = get_the_terms( $post->ID, 'rule_kind_of' ); if ( $terms && ! is_wp_error( $terms ) ) { $temp = array(); foreach ( $terms as $term ) { $temp[] = "slug."\">".$term->name.""; } if (count($temp)>0) { $temp = join( ", ", $temp ); echo $temp; } else { echo "—"; } } else { echo "—"; } break; case "rule_domain": $terms = get_the_terms( $post->ID, 'rule_domain' ); if ( $terms && ! is_wp_error( $terms ) ) { $temp = array(); foreach ( $terms as $term ) { $temp[] = "slug."\">".$term->name.""; } if (count($temp)>0) { $temp = join( ", ", $temp ); echo $temp; } else { echo "—"; } } else { echo "—"; } break; case "rule_images": $custom = custom_get_post_thumb($post->ID, 'thumbnail'); if ($custom!="") { echo ""; } $rows = get_field('images'); if ($rows) { $all_project_images=array(); foreach($rows as $row) { $all_project_images[]=$row['image']; } if (count($all_project_images)>0) { for ($i=0; $i"; } } } break; /* ------------------------------------------ Courses ------------------------------------------ */ case "poster_image": $custom = custom_get_post_thumb($post->ID, 'mini_thumb'); if ($custom!="") { echo ""; } break; case "course_year": $temp=trim(get_field('year')); if ($temp!="") { echo $temp; } else { echo "—"; } break; case "course_abbr": $temp=trim(get_field('abbreviation')); if ($temp!="") { echo $temp; } else { echo "—"; } break; /* ------------------------------------------ Events ------------------------------------------ */ case "event_date": $temp=date('d.m.y', strtotime(trim(get_field('date')))); if ($temp!="") { echo ""; echo $temp; echo "\n"; } else { echo "—"; } break; /* ------------------------------------------ Publications ------------------------------------------ */ case "publication_images": $custom = custom_get_post_thumb($post->ID, 'mini_thumb'); if ($custom!="") { echo ""; } $rows = get_field('images'); if ($rows) { $all_project_images=array(); foreach($rows as $row) { $all_project_images[]=$row['image']; } if (count($all_project_images)>0) { for ($i=0; $i"; } } else { echo "—"; } } else { echo "—"; } break; } } add_action("manage_posts_custom_column", "custom_columns"); // Style custom column ID size add_action('admin_head', 'id_width'); function id_width() { echo ''; } /* ------------------------------------------------------------------------------------------ POSTS/PAGES CUSTOM COLUMNS ------------------------------------------------------------------------------------------ */ // remove from "posts" section function remove_post_columns($defaults) { unset($defaults['author']); unset($defaults['comments']); //unset($defaults['categories']); //unset($defaults['tags']); //$defaults['image'] = 'Image in overview'; return $defaults; } add_filter('manage_posts_columns', 'remove_post_columns'); // remove from "pages" section function remove_page_columns($defaults) { unset($defaults['author']); unset($defaults['comments']); unset($defaults['date']); return $defaults; } add_filter('manage_edit-page_columns', 'remove_page_columns'); /* ------------------------------------------------------------------------------------------ RSS ------------------------------------------------------------------------------------------ */ // show post thumbnails in feeds function diw_post_thumbnail_feeds($content) { global $post; if(has_post_thumbnail($post->ID)) { $content = '
' . get_the_post_thumbnail($post->ID) . '
' . $content; } return $content; } add_filter('the_excerpt_rss', 'diw_post_thumbnail_feeds'); add_filter('the_content_feed', 'diw_post_thumbnail_feeds'); /* ------------------------------------------------------------------------------------------ iOS ------------------------------------------------------------------------------------------ */ function detect_iphone($iphone) { global $is_iphone; if($is_iphone) $iphone[] = 'iOS'; return $iphone; } add_filter('body_class','detect_iphone'); /* ------------------------------------------------------------------------------------------ ADD CUSTOM POST TYPES TO MENU EDITOR ------------------------------------------------------------------------------------------ */ add_action('admin_head-nav-menus.php', 'wpclean_add_metabox_menu_posttype_archive'); function wpclean_add_metabox_menu_posttype_archive() { add_meta_box('wpclean-metabox-nav-menu-posttype', 'Custom Post Type Archives', 'wpclean_metabox_menu_posttype_archive', 'nav-menus', 'side', 'default'); } function wpclean_metabox_menu_posttype_archive() { $post_types = get_post_types(array('show_in_nav_menus' => true, 'has_archive' => true), 'object'); if ($post_types) : $items = array(); $loop_index = 999999; foreach ($post_types as $post_type) { $item = new stdClass(); $loop_index++; $item->object_id = $loop_index; $item->db_id = 0; $item->object = 'post_type_' . $post_type->query_var; $item->menu_item_parent = 0; $item->type = 'custom'; $item->title = $post_type->labels->name; $item->url = get_post_type_archive_link($post_type->query_var); $item->target = ''; $item->attr_title = ''; $item->classes = array(); $item->xfn = ''; $items[] = $item; } $walker = new Walker_Nav_Menu_Checklist(array()); echo '
'; echo '
'; echo '
    '; echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $items), 0, (object) array('walker' => $walker)); echo '
'; echo '
'; echo '
'; echo '

'; echo ''; echo ''; echo ''; echo ''; echo '

'; endif; } /* ------------------------------------------------------------------------------------------ FRONTEND FUNCTIONS ------------------------------------------------------------------------------------------ */ function url_to_abs_image($url) { $url=str_ireplace("http://plansandpolitics.com/", ABSPATH, $url); $url=str_ireplace("http://www.plansandpolitics.com/", ABSPATH, $url); $url=str_ireplace("http://lehnerer.arch.ethz.ch/", ABSPATH, $url); $url=str_ireplace("http://www.lehnerer.arch.ethz.ch/", ABSPATH, $url); $url=str_ireplace("http://localhost/plans_and_politics/", ABSPATH, $url); $url=str_ireplace("http://plansandp.soflomo.com/", ABSPATH, $url); $url=str_ireplace("http://plansandpolitics.dev", ABSPATH, $url); return $url; } function custom_get_post_thumb($pid, $size){ $image_id = get_post_thumbnail_id($pid); $image_url = wp_get_attachment_image_src($image_id,$size); return $image_url[0]; } function custom_get_post_thumb_caption($pid) { $image_id = get_post_thumbnail_id($pid); $image = get_posts(array('p' => $image_id, 'post_type' => 'attachment')); if ($image && isset($image[0])) { return $image[0]->post_excerpt; } } function custom_get_post_thumb_and_dimensions($pid, $size){ $image_id = get_post_thumbnail_id($pid); $image_url = wp_get_attachment_image_src($image_id,$size); return $image_url; // is array [0]=url, [1]=width, [2]=height } function find_array_pos($arr, $el) { // finds the position of an element in an array $am=count($arr); $pos=-1; for ($i=0; $i<$am; $i++) { if ($arr[$i]==$el) { $pos=$i; break; } } return $pos; } ?>