generated from pascalmartineau/wp-skeleton
refactor: membership => profile
All checks were successful
Deploy WordPress and Nuxt / deploy (push) Successful in 1m6s
All checks were successful
Deploy WordPress and Nuxt / deploy (push) Successful in 1m6s
This commit is contained in:
@@ -54,8 +54,8 @@ function ccat_listing_register_post_type() {
|
||||
'rest_base' => 'listing',
|
||||
'rest_controller_class' => 'WP_REST_Posts_Controller',
|
||||
'show_in_graphql' => true,
|
||||
'graphql_single_name' => "Annonce",
|
||||
'graphql_plural_name' => "Annonces",
|
||||
'graphql_single_name' => "Listing",
|
||||
'graphql_plural_name' => "Listings",
|
||||
'graphql_interfaces' => array( 'Node' ),
|
||||
)
|
||||
);
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
<?php
|
||||
|
||||
// Register 'membership' post type
|
||||
add_action( 'init', 'ccat_membership_register_post_type' );
|
||||
function ccat_membership_register_post_type() {
|
||||
register_post_type(
|
||||
'membership',
|
||||
array(
|
||||
'labels' => array(
|
||||
'name' => __( "Memberships", 'ccat' ),
|
||||
'menu_name' => __( "Memberships", 'ccat' ),
|
||||
'singular_name' => __( "Membership", 'ccat' ),
|
||||
'add_new' => __( "Add New", 'ccat' ),
|
||||
'add_new_item' => __( "Add New Membership", 'ccat' ),
|
||||
'new_item' => __( "New Membership", 'ccat' ),
|
||||
'edit_item' => __( "Edit Membership", 'ccat' ),
|
||||
'view_item' => __( "View Membership", 'ccat' ),
|
||||
'view_items' => __( "View Memberships", 'ccat' ),
|
||||
'search_items' => __( "Search Memberships", 'ccat' ),
|
||||
'not_found' => __( "No Memberships found", 'ccat' ),
|
||||
'not_found_in_trash' => __( "No Memberships found in trash", 'ccat' ),
|
||||
'parent_item_colon' => __( "Parent Membership:", 'ccat' ),
|
||||
'all_items' => __( "All Memberships", 'ccat' ),
|
||||
'archives' => __( "Membership Archives", 'ccat' ),
|
||||
'attributes' => __( "Membership Attributes", 'ccat' ),
|
||||
'insert_into_item' => __( "Insert into Membership", 'ccat' ),
|
||||
'uploaded_to_this_item' => __( "Uploaded to this Membership", '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 Memberships list", 'ccat' ),
|
||||
'items_list_navigation' => __( "Memberships list navigation", 'ccat' ),
|
||||
'items_list' => __( "Memberships list", 'ccat' ),
|
||||
'item_published' => __( "Membership published.", 'ccat' ),
|
||||
'item_published_privately' => __( "Membership published privately.", 'ccat' ),
|
||||
'item_reverted_to_draft' => __( "Membership reverted to draft.", 'ccat' ),
|
||||
'item_scheduled' => __( "Membership scheduled.", 'ccat' ),
|
||||
'item_updated' => __( "Membership updated.", 'ccat' ),
|
||||
),
|
||||
'public' => true,
|
||||
'hierarchical' => false,
|
||||
'show_ui' => true,
|
||||
'show_in_nav_menus' => false,
|
||||
'supports' => array( 'title', 'thumbnail', 'author', 'revisions' ),
|
||||
'has_archive' => false,
|
||||
'rewrite' => array(
|
||||
'slug' => 'membre',
|
||||
'with_front' => false,
|
||||
|
||||
),
|
||||
'query_var' => true,
|
||||
'menu_icon' => 'dashicons-id',
|
||||
'show_in_rest' => true,
|
||||
'rest_base' => 'membership',
|
||||
'rest_controller_class' => 'WP_REST_Posts_Controller',
|
||||
'show_in_graphql' => true,
|
||||
'graphql_single_name' => "Membership",
|
||||
'graphql_plural_name' => "Memberships",
|
||||
'graphql_interfaces' => array( 'Node' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Custom 'membership' post updated messages
|
||||
add_filter( 'post_updated_messages', 'ccat_membership_post_updated_messages' );
|
||||
function ccat_membership_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 Membership", 'ccat' ) );
|
||||
$scheduled_post_link_html = sprintf( ' <a target="_blank" href="%1$s">%2$s</a>', esc_url( $permalink ), __( "Preview Membership", '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 Membership", 'ccat' ) );
|
||||
$messages['membership'] = array(
|
||||
0 => '',
|
||||
1 => __( "Membership updated.", 'ccat' ) . $view_post_link_html,
|
||||
2 => __( "Custom field updated.", 'ccat' ),
|
||||
3 => __( "Custom field deleted.", 'ccat' ),
|
||||
4 => __( "Membership updated.", 'ccat' ),
|
||||
5 => isset( $_GET['revision'] ) ? sprintf( __( "Membership restored to revision from %s", 'ccat' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
|
||||
6 => __( "Membership published.", 'ccat' ) . $view_post_link_html,
|
||||
7 => __( "Membership saved.", 'ccat' ),
|
||||
8 => __( "Membership submitted.", 'ccat' ) . $preview_post_link_html,
|
||||
9 => sprintf( __( 'Membership scheduled for: %s.' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_post_link_html,
|
||||
10 => __( 'Membership draft updated.' ) . $preview_post_link_html,
|
||||
);
|
||||
|
||||
return $messages;
|
||||
}
|
||||
89
wp-content/themes/ccat/includes/cpt/profile.php
Normal file
89
wp-content/themes/ccat/includes/cpt/profile.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
// Register 'profile' post type
|
||||
add_action( 'init', 'ccat_profile_register_post_type' );
|
||||
function ccat_profile_register_post_type() {
|
||||
register_post_type(
|
||||
'profile',
|
||||
array(
|
||||
'labels' => array(
|
||||
'name' => __( "Profiles", 'ccat' ),
|
||||
'menu_name' => __( "Profiles", 'ccat' ),
|
||||
'singular_name' => __( "Profile", 'ccat' ),
|
||||
'add_new' => __( "Add New", 'ccat' ),
|
||||
'add_new_item' => __( "Add New Profile", 'ccat' ),
|
||||
'new_item' => __( "New Profile", 'ccat' ),
|
||||
'edit_item' => __( "Edit Profile", 'ccat' ),
|
||||
'view_item' => __( "View Profile", 'ccat' ),
|
||||
'view_items' => __( "View Profiles", 'ccat' ),
|
||||
'search_items' => __( "Search Profiles", 'ccat' ),
|
||||
'not_found' => __( "No Profiles found", 'ccat' ),
|
||||
'not_found_in_trash' => __( "No Profiles found in trash", 'ccat' ),
|
||||
'parent_item_colon' => __( "Parent Profile:", 'ccat' ),
|
||||
'all_items' => __( "All Profiles", 'ccat' ),
|
||||
'archives' => __( "Profile Archives", 'ccat' ),
|
||||
'attributes' => __( "Profile Attributes", 'ccat' ),
|
||||
'insert_into_item' => __( "Insert into Profile", 'ccat' ),
|
||||
'uploaded_to_this_item' => __( "Uploaded to this Profile", '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 Profiles list", 'ccat' ),
|
||||
'items_list_navigation' => __( "Profiles list navigation", 'ccat' ),
|
||||
'items_list' => __( "Profiles list", 'ccat' ),
|
||||
'item_published' => __( "Profile published.", 'ccat' ),
|
||||
'item_published_privately' => __( "Profile published privately.", 'ccat' ),
|
||||
'item_reverted_to_draft' => __( "Profile reverted to draft.", 'ccat' ),
|
||||
'item_scheduled' => __( "Profile scheduled.", 'ccat' ),
|
||||
'item_updated' => __( "Profile updated.", 'ccat' ),
|
||||
),
|
||||
'public' => true,
|
||||
'hierarchical' => false,
|
||||
'show_ui' => true,
|
||||
'show_in_nav_menus' => false,
|
||||
'supports' => array( 'title', 'thumbnail', 'author', 'revisions' ),
|
||||
'has_archive' => false,
|
||||
'rewrite' => array(
|
||||
'slug' => 'profil',
|
||||
'with_front' => false,
|
||||
|
||||
),
|
||||
'query_var' => true,
|
||||
'menu_icon' => 'dashicons-id',
|
||||
'show_in_rest' => true,
|
||||
'rest_base' => 'profile',
|
||||
'rest_controller_class' => 'WP_REST_Posts_Controller',
|
||||
'show_in_graphql' => true,
|
||||
'graphql_single_name' => "Profile",
|
||||
'graphql_plural_name' => "Profiles",
|
||||
'graphql_interfaces' => array( 'Node' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Custom 'profile' post updated messages
|
||||
add_filter( 'post_updated_messages', 'ccat_profile_post_updated_messages' );
|
||||
function ccat_profile_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 Profile", 'ccat' ) );
|
||||
$scheduled_post_link_html = sprintf( ' <a target="_blank" href="%1$s">%2$s</a>', esc_url( $permalink ), __( "Preview Profile", '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 Profile", 'ccat' ) );
|
||||
$messages['profile'] = array(
|
||||
0 => '',
|
||||
1 => __( "Profile updated.", 'ccat' ) . $view_post_link_html,
|
||||
2 => __( "Custom field updated.", 'ccat' ),
|
||||
3 => __( "Custom field deleted.", 'ccat' ),
|
||||
4 => __( "Profile updated.", 'ccat' ),
|
||||
5 => isset( $_GET['revision'] ) ? sprintf( __( "Profile restored to revision from %s", 'ccat' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
|
||||
6 => __( "Profile published.", 'ccat' ) . $view_post_link_html,
|
||||
7 => __( "Profile saved.", 'ccat' ),
|
||||
8 => __( "Profile submitted.", 'ccat' ) . $preview_post_link_html,
|
||||
9 => sprintf( __( 'Profile scheduled for: %s.' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_post_link_html,
|
||||
10 => __( 'Profile draft updated.' ) . $preview_post_link_html,
|
||||
);
|
||||
|
||||
return $messages;
|
||||
}
|
||||
Reference in New Issue
Block a user