array(
'name' => 'Pdf',
'add_new' => 'Ajouter',
'add_new_item' => 'Ajouter',
'edit' => 'Editer',
'edit_item' => 'Editer un Pdf',
'new_item' => 'Nouveau Pdf',
'view' => 'Voir le Pdf',
'view_item' => 'Voir le Pdf',
'search_items' => 'Rechercher Pdf',
'not_found' => 'Aucun PDF trouvé',
'not_found_in_trash' => 'Aucun PDF trouvé dans la Corbeille',
),
'description' => 'Pdf récent',
'public' => true,
'show_ui' => true,
'exclude_from_search' => true,
'supports' => array( 'title', 'excerpt', 'thumbnail', ),
'has_archive' => 'Pdf', // The archive slug
'rewrite' => array( 'slug' => 'Pdf' ),
));
}
/**
* Custom "Pdf" post type metabox
*/
/**
* Adds the Pdf meta box for the Pdf post type
*/
function csn_pdf_meta() {
add_meta_box( 'csn_pdf_meta_box', 'Pdf Settings', 'csn_pdf_meta_display', 'pdf', 'normal', 'high' );
}
add_action( 'add_meta_boxes', 'csn_pdf_meta' );
/**
* Displays the Pdf meta box
*/
function csn_pdf_meta_display( $object, $box ) {
// Setup some default values
$defaults = array(
'file' => '',
'code' => ''
// Add more!
);
// Get the post meta
$Pdf = get_post_meta( $object->ID, 'Pdf', true );
// Merge them
$Pdf = wp_parse_args( $Pdf, $defaults );
?>
post_type == 'revision' ) return;
/* Get the post type object. */
$post_type = get_post_type_object( $post->post_type );
/* Check if the current user has permission to edit the post. */
if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) )
return $post_id;
/**
* Add the Pdf meta
*/
$codeu = esc_url_raw( $_POST['Pdf-file'] );
$codef = '[pdfic]'.$codeu.'[pdfic]';
update_post_meta( $post_id, 'Pdf', array(
'file' => esc_url_raw( $_POST['Pdf-file'] ),
'postid' => absint( $_POST['Pdf-postid'] ),
'code' => $codef,
// Add your own if you've added fields
) );
// Seperate the Pdf count and "hide" from the rest
update_post_meta( $post_id, 'Pdf_count', absint( $_POST['Pdf-count'] ) );
update_post_meta( $post_id, '_hide_Pdf', ( $_POST['Pdf-hide'] == 1 ? 1 : 0 ) );
}
add_action( 'save_post', 'csn_pdf_meta_save', 10, 2 );
/**
* Adds the script needed for the file upload
*/
function pdf_metabox_script() {
$screen = get_current_screen();
// Make sure we are on the Pdf screen
if ( isset( $screen->post_type ) && $screen->post_type == 'pdf' ) : ?>
post_type == 'pdf' )
wp_enqueue_script( 'jayj-Pdf-upload', get_stylesheet_directory_uri() . '/admin/upload.js', array( 'jquery' ), null, true );
}
add_action( 'admin_enqueue_scripts', 'pdf_metabox_enqueue_script' );
*/
add_filter('manage_edit-pdf_columns', 'pdf_cpt_columns');
add_action('manage_pdf_posts_custom_column', 'pdf_cpt_custom_column', 10, 2);
function pdf_cpt_columns($defaults) {
$defaults['file'] = 'Code pour un article';
return $defaults;
}
function pdf_cpt_custom_column($column_name, $post_id) {
if ( 'code' === $column_name ) {
if ( $Pdf = get_post_meta( $post_id, 'Pdf', true ) ) {
printf( '[pdfic href="%s"]', $Pdf );
} else {
echo ' - ';
}
}
?>