array(
'name' => __( 'Initiativpartner' ),
'singular_name' => __( 'Partner' )
),
'public' => true,
'has_archive' => true,
'menu_icon' => 'dashicons-admin-users',
'supports' => array('title', 'editor', 'thumbnail'),
'exlude_from_search' => true
)
);
register_post_type( 'tdas',
array(
'labels' => array(
'name' => __( 'TdA' ),
'singular_name' => __( 'TdA' )
),
'public' => true,
'has_archive' => true,
'menu_icon' => 'dashicons-calendar-alt',
'supports' => array('title', 'editor', 'thumbnail'),
)
);
register_post_type( 'projects',
array(
'labels' => array(
'name' => __( 'Projekte' ),
'singular_name' => __( 'Projekt' )
),
'public' => true,
'has_archive' => true,
'menu_icon' => 'dashicons-calendar-alt',
'supports' => array('title', 'editor', 'thumbnail'),
'rewrite' => array('slug' => 'projekte'),
)
);
}
/** POST META BOX **/
add_action( 'load-post.php', 'ams_post_box_setup' );
add_action( 'load-post-new.php', 'ams_post_box_setup' );
function ams_post_box_setup() {
add_action( 'add_meta_boxes', 'ams_post_box_add' );
add_action( 'save_post', 'ams_post_box_save', 10, 2 );
}
function ams_post_box_add() {
add_meta_box(
'ams_post_box', // Unique ID
esc_html__( 'Post type'), // Title
'ams_post_box', // Callback function
'post', // Admin page (or post type)
'side', // Context
'default' // Priority
);
}
function ams_post_box( $object, $box ) { ?>
ID, 'ams_dual_columns_post', true)) { echo "checked"; } ?> />
ID, 'ams_tda_gallery', true)) { echo "checked"; } ?> />
ID, 'ams_partners', true)) { echo "checked"; } ?> />
ID, 'ams_projects', true)) { echo "checked"; } ?> />
post_type );
if(!current_user_can( $post_type->cap->edit_post, $post_id)) {
return $post_id;
}
foreach($inputs as $input) {
if(isset($_POST[$input]) && !get_post_meta( $post_id, $input, true )) {
add_post_meta( $post_id, $input, true, true );
} else if(!isset($_POST[$input]) && get_post_meta( $post_id, $input, true )) {
delete_post_meta( $post_id, $input);
}
}
}
/** TdA Slider **/
global $tdaSlider; // TODO: remove this
$tdaSlider = array(
"TdA2016" => array(
"url" => "http://www.architekturmachtschule.de/wp-content/uploads/2015/11/",
"tag-der-architektur-2015-01.jpg",
"tag-der-architektur-2015-02.jpg",
"tag-der-architektur-2015-03.jpg",
"tag-der-architektur-2015-04.jpg",
"tag-der-architektur-2015-05.jpg",
"tag-der-architektur-2015-06.jpg",
"tag-der-architektur-2015-07.jpg",
"tag-der-architektur-2015-08.jpg",
"tag-der-architektur-2015-09.jpg",
"tag-der-architektur-2015-10.jpg",
"tag-der-architektur-2015-11.jpg",
"tag-der-architektur-2015-12.jpg",
"tag-der-architektur-2015-13.jpg",
"tag-der-architektur-2015-14.jpg",
"tag-der-architektur-2015-15.jpg",
"tag-der-architektur-2015-16.jpg",
"tag-der-architektur-2015-17.jpg",
"tag-der-architektur-2015-18.jpg",
"tag-der-architektur-2015-19.jpg",
"tag-der-architektur-2015-20.jpg",
"tag-der-architektur-2015-21.jpg",
"tag-der-architektur-2015-22.jpg",
"tag-der-architektur-2015-23.jpg",
"tag-der-architektur-2015-24.jpg",
"tag-der-architektur-2015-25.jpg",
"tag-der-architektur-2015-26.jpg",
"tag-der-architektur-2015-27.jpg",
"tag-der-architektur-2015-28.jpg",
"tag-der-architektur-2015-29.jpg",
"tag-der-architektur-2015-30.jpg",
"tag-der-architektur-2015-31.jpg",
"tag-der-architektur-2015-32.jpg",
"tag-der-architektur-2015-33.jpg",
"tag-der-architektur-2015-34.jpg",
"tag-der-architektur-2015-35.jpg",
"tag-der-architektur-2015-36.jpg",
"tag-der-architektur-2015-37.jpg",
"tag-der-architektur-2015-38.jpg",
"tag-der-architektur-2015-39.jpg",
"tag-der-architektur-2015-40.jpg",
"tag-der-architektur-2015-41.jpg",
"tag-der-architektur-2015-42.jpg",
"tag-der-architektur-2015-43.jpg"
),
);
// [carousel id="TdA2016"]
function carousel_shortcode_func($atts) {
global $tdaSlider;
$a = shortcode_atts( array(
'id' => NULL
), $atts );
if($a['id'] != NULL && array_key_exists($a['id'], $tdaSlider)) {
$slider = $tdaSlider[$a['id']];
$output = '';
foreach($slider as $key => $value) {
if($key == "url") {
continue;
}
$output .= '
' . PHP_EOL;
}
$output .= '
';
return $output;
} else {
return "Wrong Slider ID!";
}
}
add_shortcode('carousel', 'carousel_shortcode_func');
/* TITLE STUFF */
function ams_modify_titles($title, $id = null) {
if(get_post_type() == "tdas") {
return "Tag der Architektur" . preg_replace("/?[a-z0-9]{2,8};/i", "", $title) . " » " . get_bloginfo("name");
}
if(is_front_page()) {
return get_bloginfo("name");
}
return ltrim(preg_replace("/?[a-z0-9]{2,8};/i","", $title)) . " » " . get_bloginfo("name");
}
add_filter( 'wp_title', 'ams_modify_titles', 10, 2 );
?>