Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/24/2023 09:37:44 AM (14 months ago)
Author:
imath
Message:

Use a custom post type instead of the page post type for directories

  • The buddypress post type is now the one used for the BP component

directory page.

  • Introduce the bp_core_set_unique_directory_page_slug() function to

make sure there is no conflict with an existing WP page when setting the
BP Component directory page post_name.

  • Introduce the bp_restricted custom status. We'll be able to use it for

future visibility features.

  • Deprecate the Admin Slugs screen and corresponding functions
  • Bump raw_db_version to 13422 (the first commit about merging BP

Rewrites).

  • Add an update function to update the post type of the existing BP

component directory pages and potential WP Nav Menus including these.

Props r-a-y, johnjamesjacoby, boonebgorges

Closes https://github.com/buddypress/buddypress/pull/67
See #4954

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/classes/class-bp-core.php

    r13414 r13431  
    324324     * Set up post types.
    325325     *
    326      * @since BuddyPress (2.4.0)
     326     * @since 2.4.0
     327     * @since 12.0.0 Registers the 'buddypress' post type for component directories.
    327328     */
    328329    public function register_post_types() {
    329 
    330         // Emails
     330        // Component directories.
     331        if ( (int) get_current_blog_id() === bp_get_post_type_site_id() ) {
     332            register_post_type(
     333                'buddypress',
     334                array(
     335                    'label'               => _x( 'BuddyPress Directories', 'Post Type label', 'buddypress' ),
     336                    'labels'              => array(
     337                        'singular_name' => _x( 'BuddyPress Directory', 'Post Type singular name', 'buddypress' ),
     338                    ),
     339                    'description'         => __( 'The BuddyPress Post Type used for component directories.', 'buddypress' ),
     340                    'public'              => false,
     341                    'hierarchical'        => true,
     342                    'exclude_from_search' => true,
     343                    'publicly_queryable'  => false,
     344                    'show_ui'             => false,
     345                    'show_in_nav_menus'   => true,
     346                    'show_in_rest'        => false,
     347                    'supports'            => array( 'title' ),
     348                    'has_archive'         => false,
     349                    'rewrite'             => false,
     350                    'query_var'           => false,
     351                    'delete_with_user'    => false,
     352                )
     353            );
     354        }
     355
     356        // Emails.
    331357        if ( bp_is_root_blog() && ! is_network_admin() ) {
    332358            register_post_type(
     
    357383
    358384        parent::register_post_types();
     385    }
     386
     387    /**
     388     * Set up the component post statuses.
     389     *
     390     * @since 12.0.0
     391     */
     392    public function register_post_statuses() {
     393        register_post_status(
     394            'bp_restricted',
     395            array(
     396                'label'    => _x( 'Restricted to members', '`buddypress` post type post status', 'buddypress' ),
     397                'public'   => false,
     398                'internal' => true,
     399            )
     400        );
     401
     402        parent::register_post_statuses();
    359403    }
    360404
Note: See TracChangeset for help on using the changeset viewer.