Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // CUSTOM POST TYPE - SLIDE
- add_action( 'init', 'create_slide' );
- function create_slide() {
- $args = array(
- 'labels' => array(
- 'name' => _x( 'Slide', 'post type general name' ),
- 'singular_name' => _x( 'Slide', 'post type singular name' ),
- 'add_new' => __( 'Aggiungi nuovo' ),
- 'add_new_item' => __( 'Aggiungi nuovo Slide'),
- 'edit_item' => __( 'Modifica slide'),
- 'new_item' => __( 'Nuovo slide' ),
- 'view_item' => __( 'Vedi slide' ),
- 'search_items' => __( 'Cerca'. $name ),
- 'not_found' => __( 'Nessun slide trovato'),
- 'not_found_in_trash' => __( 'Non ci sono ' . $name . ' slide nel Cestino' ),
- 'parent_item_colon' => ''
- ),
- 'public' => true,
- 'publicly_queryable' => true,
- 'show_ui' => true,
- 'show_in_menu' => true,
- 'query_var' => true,
- 'rewrite' => true,
- 'menu_icon' => get_bloginfo('template_directory') . '/images/iconslide16.png', // Icon Path
- 'capability_type' => 'post',
- 'has_archive' => true,
- 'hierarchical' => false,
- 'menu_position' => null,
- //'taxonomy' => array (''),
- 'supports' => array(
- 'title',
- 'editor',
- 'thumbnail',
- //'comments', // pannello commenti
- //'excerpt', // pannello riassunto
- //'author', // pannello autore
- //'custom-fields' // pannello custom fields
- )
- );
- register_post_type( 'slide', $args );
- }
- // ICON
- add_action( 'admin_head', 'wpt_slide_icons' );
- function wpt_slide_icons() {
- ?>
- <style type="text/css" media="screen">
- #icon-edit.icon32-posts-slide {background: url(<?php bloginfo('template_directory') ?>/images/iconslide32.png) no-repeat;}
- </style>
- <?php }
- //------enable post thumbnail preview for custom columns
- if ( !function_exists('fb_AddThumbColumn') && function_exists('add_theme_support') ) {
- // for post and investments
- function fb_AddThumbColumn($cols) {
- $cols['thumbnail'] = __('Thumbnail');
- return $cols;
- }
- function fb_AddThumbValue($column_name, $post_id) {
- $width = (int) 100;
- $height = (int) 100;
- if ( 'thumbnail' == $column_name ) {
- // thumbnail of WP 2.9
- $thumbnail_id = get_post_meta( $post_id, '_thumbnail_id', true );
- // image from gallery
- $attachments = get_children( array('post_parent' => $post_id, 'post_type' => 'attachment', 'post_mime_type' => 'image') );
- if ($thumbnail_id)
- $thumb = wp_get_attachment_image( $thumbnail_id, array($width, $height), true );
- elseif ($attachments) {
- foreach ( $attachments as $attachment_id => $attachment ) {
- $thumb = wp_get_attachment_image( $attachment_id, array($width, $height), true );
- }
- }
- if ( isset($thumb) && $thumb ) {
- echo $thumb;
- } else {
- echo __('None');
- }
- }
- }
- // for posts
- add_filter( 'manage_posts_columns', 'fb_AddThumbColumn' );
- add_action( 'manage_posts_custom_column', 'fb_AddThumbValue', 10, 2 );
- // for investments
- add_filter( 'manage_slide_columns', 'fb_AddThumbColumn' );
- add_action( 'manage_slide_custom_column', 'fb_AddThumbValue', 10, 2 );
- }
- // CUSTOM THUMBNAILS - miniatura immagine in evidenza
- add_theme_support( 'post-thumbnails', array( 'post' ) ); // post
- add_theme_support( 'post-thumbnails', array( 'page' ) ); //pagine
- add_theme_support( 'post-thumbnails', array( 'slide' ) );
- // enqueue script cycle
- add_action( 'wp_enqueue_scripts', 'slide_libs' );
- function slide_libs()
- {
- wp_enqueue_script('camera', get_template_directory_uri(). '/camera/scripts/camera.min.js');
- wp_register_script('camera', get_template_directory_uri() . '/camera/scripts/camera.min.js');
- wp_enqueue_script('easing', get_template_directory_uri(). '/camera/scripts/jquery.easing.1.3.js');
- wp_register_script('easing', get_template_directory_uri() . '/camera/scripts/jquery.easing.1.3.js');
- wp_enqueue_script('cameramobile', get_template_directory_uri(). '/camera/scripts/jquery.mobile.customized.min.js');
- wp_register_script('cameramobile', get_template_directory_uri() . '/camera/scripts/jquery.mobile.customized.min.js');
- wp_enqueue_style('camera', get_template_directory_uri(). '/camera/css/camera.css');
- wp_register_style('camera', get_template_directory_uri() . '/camera/css/camera.css');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement