Advertisement
salvatorifabio

function-custom-post-slide-camera

Jun 4th, 2013
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.41 KB | None | 0 0
  1. <?php
  2. // CUSTOM POST TYPE - SLIDE
  3. add_action( 'init', 'create_slide' );
  4. function create_slide() {
  5. $args = array(
  6. 'labels' => array(
  7. 'name' => _x( 'Slide', 'post type general name' ),
  8. 'singular_name' => _x( 'Slide', 'post type singular name' ),
  9. 'add_new' => __( 'Aggiungi nuovo' ),
  10. 'add_new_item' => __( 'Aggiungi nuovo Slide'),
  11. 'edit_item' => __( 'Modifica slide'),
  12. 'new_item' => __( 'Nuovo slide' ),
  13. 'view_item' => __( 'Vedi slide' ),
  14. 'search_items' => __( 'Cerca'. $name ),
  15. 'not_found' => __( 'Nessun slide trovato'),
  16. 'not_found_in_trash' => __( 'Non ci sono ' . $name . ' slide nel Cestino' ),
  17. 'parent_item_colon' => ''
  18. ),
  19. 'public' => true,
  20. 'publicly_queryable' => true,
  21. 'show_ui' => true,
  22. 'show_in_menu' => true,
  23. 'query_var' => true,
  24. 'rewrite' => true,
  25. 'menu_icon' => get_bloginfo('template_directory') . '/images/iconslide16.png', // Icon Path
  26. 'capability_type' => 'post',
  27. 'has_archive' => true,
  28. 'hierarchical' => false,
  29. 'menu_position' => null,
  30. //'taxonomy' => array (''),
  31. 'supports' => array(
  32. 'title',
  33. 'editor',
  34. 'thumbnail',
  35. //'comments', // pannello commenti
  36. //'excerpt', // pannello riassunto
  37. //'author', // pannello autore
  38. //'custom-fields' // pannello custom fields
  39. )
  40. );
  41.  
  42. register_post_type( 'slide', $args );
  43. }
  44. // ICON
  45. add_action( 'admin_head', 'wpt_slide_icons' );
  46.  
  47. function wpt_slide_icons() {
  48. ?>
  49. <style type="text/css" media="screen">
  50. #icon-edit.icon32-posts-slide {background: url(<?php bloginfo('template_directory') ?>/images/iconslide32.png) no-repeat;}
  51. </style>
  52.  
  53. <?php }
  54.  
  55.  
  56. //------enable post thumbnail preview for custom columns
  57. if ( !function_exists('fb_AddThumbColumn') && function_exists('add_theme_support') ) {
  58.  
  59. // for post and investments
  60.  
  61. function fb_AddThumbColumn($cols) {
  62. $cols['thumbnail'] = __('Thumbnail');
  63. return $cols;
  64. }
  65.  
  66. function fb_AddThumbValue($column_name, $post_id) {
  67.  
  68. $width = (int) 100;
  69. $height = (int) 100;
  70.  
  71.  
  72. if ( 'thumbnail' == $column_name ) {
  73. // thumbnail of WP 2.9
  74. $thumbnail_id = get_post_meta( $post_id, '_thumbnail_id', true );
  75. // image from gallery
  76. $attachments = get_children( array('post_parent' => $post_id, 'post_type' => 'attachment', 'post_mime_type' => 'image') );
  77. if ($thumbnail_id)
  78. $thumb = wp_get_attachment_image( $thumbnail_id, array($width, $height), true );
  79. elseif ($attachments) {
  80. foreach ( $attachments as $attachment_id => $attachment ) {
  81. $thumb = wp_get_attachment_image( $attachment_id, array($width, $height), true );
  82. }
  83. }
  84. if ( isset($thumb) && $thumb ) {
  85. echo $thumb;
  86. } else {
  87. echo __('None');
  88. }
  89. }
  90. }
  91.  
  92. // for posts
  93. add_filter( 'manage_posts_columns', 'fb_AddThumbColumn' );
  94. add_action( 'manage_posts_custom_column', 'fb_AddThumbValue', 10, 2 );
  95.  
  96. // for investments
  97. add_filter( 'manage_slide_columns', 'fb_AddThumbColumn' );
  98. add_action( 'manage_slide_custom_column', 'fb_AddThumbValue', 10, 2 );
  99. }
  100.  
  101. // CUSTOM THUMBNAILS - miniatura immagine in evidenza
  102. add_theme_support( 'post-thumbnails', array( 'post' ) ); // post
  103. add_theme_support( 'post-thumbnails', array( 'page' ) ); //pagine
  104. add_theme_support( 'post-thumbnails', array( 'slide' ) );
  105.  
  106. // enqueue script cycle
  107. add_action( 'wp_enqueue_scripts', 'slide_libs' );
  108. function slide_libs()
  109. {
  110.  
  111. wp_enqueue_script('camera', get_template_directory_uri(). '/camera/scripts/camera.min.js');
  112. wp_register_script('camera', get_template_directory_uri() . '/camera/scripts/camera.min.js');
  113.  
  114. wp_enqueue_script('easing', get_template_directory_uri(). '/camera/scripts/jquery.easing.1.3.js');
  115. wp_register_script('easing', get_template_directory_uri() . '/camera/scripts/jquery.easing.1.3.js');
  116.  
  117. wp_enqueue_script('cameramobile', get_template_directory_uri(). '/camera/scripts/jquery.mobile.customized.min.js');
  118. wp_register_script('cameramobile', get_template_directory_uri() . '/camera/scripts/jquery.mobile.customized.min.js');
  119.  
  120. wp_enqueue_style('camera', get_template_directory_uri(). '/camera/css/camera.css');
  121. wp_register_style('camera', get_template_directory_uri() . '/camera/css/camera.css');
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement