generated from pascalmartineau/wp-skeleton
feat: initial annonce cpt
All checks were successful
Deploy WordPress and Nuxt / deploy (push) Successful in 55s
All checks were successful
Deploy WordPress and Nuxt / deploy (push) Successful in 55s
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
require_once __DIR__ . '/includes/core/theme-setup.php';
|
require_once __DIR__ . '/includes/core/theme-setup.php';
|
||||||
|
|
||||||
// Custom Post Types
|
// Custom Post Types
|
||||||
|
require_once __DIR__ . '/includes/cpt/listing.php';
|
||||||
require_once __DIR__ . '/includes/cpt/membership.php';
|
require_once __DIR__ . '/includes/cpt/membership.php';
|
||||||
require_once __DIR__ . '/includes/cpt/contributor.php';
|
require_once __DIR__ . '/includes/cpt/contributor.php';
|
||||||
require_once __DIR__ . '/includes/cpt/event.php';
|
require_once __DIR__ . '/includes/cpt/event.php';
|
||||||
|
|||||||
88
wp-content/themes/ccat/includes/cpt/listing.php
Normal file
88
wp-content/themes/ccat/includes/cpt/listing.php
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// Register 'listing' post type
|
||||||
|
add_action( 'init', 'ccat_listing_register_post_type' );
|
||||||
|
function ccat_listing_register_post_type() {
|
||||||
|
register_post_type(
|
||||||
|
'listing',
|
||||||
|
array(
|
||||||
|
'labels' => array(
|
||||||
|
'name' => __( "Listings", 'ccat' ),
|
||||||
|
'menu_name' => __( "Listings", 'ccat' ),
|
||||||
|
'singular_name' => __( "Listing", 'ccat' ),
|
||||||
|
'add_new' => __( "Add New", 'ccat' ),
|
||||||
|
'add_new_item' => __( "Add New Listing", 'ccat' ),
|
||||||
|
'new_item' => __( "New Listing", 'ccat' ),
|
||||||
|
'edit_item' => __( "Edit Listing", 'ccat' ),
|
||||||
|
'view_item' => __( "View Listing", 'ccat' ),
|
||||||
|
'view_items' => __( "View Listings", 'ccat' ),
|
||||||
|
'search_items' => __( "Search Listings", 'ccat' ),
|
||||||
|
'not_found' => __( "No Listings found", 'ccat' ),
|
||||||
|
'not_found_in_trash' => __( "No Listings found in trash", 'ccat' ),
|
||||||
|
'parent_item_colon' => __( "Parent Listing:", 'ccat' ),
|
||||||
|
'all_items' => __( "All Listings", 'ccat' ),
|
||||||
|
'archives' => __( "Listing Archives", 'ccat' ),
|
||||||
|
'attributes' => __( "Listing Attributes", 'ccat' ),
|
||||||
|
'insert_into_item' => __( "Insert into Listing", 'ccat' ),
|
||||||
|
'uploaded_to_this_item' => __( "Uploaded to this Listing", 'ccat' ),
|
||||||
|
'featured_image' => __( "Featured Image", 'ccat' ),
|
||||||
|
'set_featured_image' => __( "Set featured image", 'ccat' ),
|
||||||
|
'remove_featured_image' => __( "Remove featured image", 'ccat' ),
|
||||||
|
'use_featured_image' => __( "Use as featured image", 'ccat' ),
|
||||||
|
'filter_items_list' => __( "Filter Listings list", 'ccat' ),
|
||||||
|
'items_list_navigation' => __( "Listings list navigation", 'ccat' ),
|
||||||
|
'items_list' => __( "Listings list", 'ccat' ),
|
||||||
|
'item_published' => __( "Listing published.", 'ccat' ),
|
||||||
|
'item_published_privately' => __( "Listing published privately.", 'ccat' ),
|
||||||
|
'item_reverted_to_draft' => __( "Listing reverted to draft.", 'ccat' ),
|
||||||
|
'item_scheduled' => __( "Listing scheduled.", 'ccat' ),
|
||||||
|
'item_updated' => __( "Listing updated.", 'ccat' ),
|
||||||
|
),
|
||||||
|
'public' => true,
|
||||||
|
'hierarchical' => false,
|
||||||
|
'show_ui' => true,
|
||||||
|
'show_in_nav_menus' => false,
|
||||||
|
'supports' => array( 'title', 'author', 'revisions' ),
|
||||||
|
'has_archive' => false,
|
||||||
|
'rewrite' => array(
|
||||||
|
'slug' => 'annonce',
|
||||||
|
'with_front' => false,
|
||||||
|
),
|
||||||
|
'query_var' => true,
|
||||||
|
'menu_icon' => 'dashicons-sticky',
|
||||||
|
'show_in_rest' => true,
|
||||||
|
'rest_base' => 'listing',
|
||||||
|
'rest_controller_class' => 'WP_REST_Posts_Controller',
|
||||||
|
'show_in_graphql' => true,
|
||||||
|
'graphql_single_name' => "Annonce",
|
||||||
|
'graphql_plural_name' => "Annonces",
|
||||||
|
'graphql_interfaces' => array( 'Node' ),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Custom 'listing' post updated messages
|
||||||
|
add_filter( 'post_updated_messages', 'ccat_listing_post_updated_messages' );
|
||||||
|
function ccat_listing_post_updated_messages( $messages ) {
|
||||||
|
global $post;
|
||||||
|
$permalink = get_permalink( $post );
|
||||||
|
$preview_post_link_html = sprintf( ' <a target="_blank" href="%1$s">%2$s</a>', esc_url( get_preview_post_link( $post ) ), __( "Preview Listing", 'ccat' ) );
|
||||||
|
$scheduled_post_link_html = sprintf( ' <a target="_blank" href="%1$s">%2$s</a>', esc_url( $permalink ), __( "Preview Listing", 'ccat' ) );
|
||||||
|
$scheduled_date = date_i18n( __( "M j, Y @ H:i", 'ccat' ), strtotime( $post->post_date ) );
|
||||||
|
$view_post_link_html = sprintf( ' <a href="%1$s">%2$s</a>', esc_url( $permalink ), __( "View Listing", 'ccat' ) );
|
||||||
|
$messages['listing'] = array(
|
||||||
|
0 => '',
|
||||||
|
1 => __( "Listing updated.", 'ccat' ) . $view_post_link_html,
|
||||||
|
2 => __( "Custom field updated.", 'ccat' ),
|
||||||
|
3 => __( "Custom field deleted.", 'ccat' ),
|
||||||
|
4 => __( "Listing updated.", 'ccat' ),
|
||||||
|
5 => isset( $_GET['revision'] ) ? sprintf( __( "Listing restored to revision from %s", 'ccat' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
|
||||||
|
6 => __( "Listing published.", 'ccat' ) . $view_post_link_html,
|
||||||
|
7 => __( "Listing saved.", 'ccat' ),
|
||||||
|
8 => __( "Listing submitted.", 'ccat' ) . $preview_post_link_html,
|
||||||
|
9 => sprintf( __( 'Listing scheduled for: %s.' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_post_link_html,
|
||||||
|
10 => __( 'Listing draft updated.' ) . $preview_post_link_html,
|
||||||
|
);
|
||||||
|
|
||||||
|
return $messages;
|
||||||
|
}
|
||||||
@@ -47,7 +47,6 @@ function ccat_location_register_post_type() {
|
|||||||
'rewrite' => array(
|
'rewrite' => array(
|
||||||
'slug' => 'lieu',
|
'slug' => 'lieu',
|
||||||
'with_front' => false,
|
'with_front' => false,
|
||||||
|
|
||||||
),
|
),
|
||||||
'query_var' => true,
|
'query_var' => true,
|
||||||
'menu_icon' => 'dashicons-location',
|
'menu_icon' => 'dashicons-location',
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user