bbp_form_slug_conflict_check( string $slug, string $default )
Used to check if a bbPress slug conflicts with an existing known slug.
Description Description
Parameters Parameters
- $slug
-
(Required)
- $default
-
(Required)
Source Source
File: includes/admin/settings.php
function bbp_form_slug_conflict_check( $slug, $default ) { // Only set the slugs once ver page load static $the_core_slugs = array(); // Get the form value $this_slug = bbp_get_form_option( $slug, $default, true ); if ( empty( $the_core_slugs ) ) { // Slugs to check $core_slugs = apply_filters( 'bbp_slug_conflict_check', array( /** WordPress Core ****************************************************/ // Core Post Types 'post_base' => array( 'name' => esc_html__( 'Posts', 'bbpress' ), 'default' => 'post', 'context' => 'WordPress' ), 'page_base' => array( 'name' => esc_html__( 'Pages', 'bbpress' ), 'default' => 'page', 'context' => 'WordPress' ), 'revision_base' => array( 'name' => esc_html__( 'Revisions', 'bbpress' ), 'default' => 'revision', 'context' => 'WordPress' ), 'attachment_base' => array( 'name' => esc_html__( 'Attachments', 'bbpress' ), 'default' => 'attachment', 'context' => 'WordPress' ), 'nav_menu_base' => array( 'name' => esc_html__( 'Menus', 'bbpress' ), 'default' => 'nav_menu_item', 'context' => 'WordPress' ), // Post Tags 'tag_base' => array( 'name' => esc_html__( 'Tag base', 'bbpress' ), 'default' => 'tag', 'context' => 'WordPress' ), // Post Categories 'category_base' => array( 'name' => esc_html__( 'Category base', 'bbpress' ), 'default' => 'category', 'context' => 'WordPress' ), /** bbPress Core ******************************************************/ // Forum archive slug '_bbp_root_slug' => array( 'name' => esc_html__( 'Forums base', 'bbpress' ), 'default' => 'forums', 'context' => 'bbPress' ), // Topic archive slug '_bbp_topic_archive_slug' => array( 'name' => esc_html__( 'Topics base', 'bbpress' ), 'default' => 'topics', 'context' => 'bbPress' ), // Forum slug '_bbp_forum_slug' => array( 'name' => esc_html__( 'Forum slug', 'bbpress' ), 'default' => 'forum', 'context' => 'bbPress' ), // Topic slug '_bbp_topic_slug' => array( 'name' => esc_html__( 'Topic slug', 'bbpress' ), 'default' => 'topic', 'context' => 'bbPress' ), // Reply slug '_bbp_reply_slug' => array( 'name' => esc_html__( 'Reply slug', 'bbpress' ), 'default' => 'reply', 'context' => 'bbPress' ), // Edit slug '_bbp_edit_slug' => array( 'name' => esc_html__( 'Edit slug', 'bbpress' ), 'default' => 'edit', 'context' => 'bbPress' ), // User profile slug '_bbp_user_slug' => array( 'name' => esc_html__( 'User base', 'bbpress' ), 'default' => 'users', 'context' => 'bbPress' ), // View slug '_bbp_view_slug' => array( 'name' => esc_html__( 'View base', 'bbpress' ), 'default' => 'view', 'context' => 'bbPress' ), // Topic tag slug '_bbp_topic_tag_slug' => array( 'name' => esc_html__( 'Topic tag slug', 'bbpress' ), 'default' => 'topic-tag', 'context' => 'bbPress' ), ) ); /** BuddyPress Core *******************************************************/ if ( defined( 'BP_VERSION' ) ) { $bp = buddypress(); // Loop through root slugs and check for conflict if ( ! empty( $bp->pages ) ) { foreach ( $bp->pages as $page => $page_data ) { $page_base = $page . '_base'; $page_title = sprintf( esc_html__( '%s page', 'bbpress' ), $page_data->title ); $core_slugs[ $page_base ] = array( 'name' => $page_title, 'default' => $page_data->slug, 'context' => 'BuddyPress' ); } } } // Set the static $the_core_slugs = apply_filters( 'bbp_slug_conflict', $core_slugs ); } // Loop through slugs to check foreach ( $the_core_slugs as $key => $value ) { // Get the slug $slug_check = bbp_get_form_option( $key, $value['default'], true ); // Compare if ( ( $slug !== $key ) && ( $slug_check === $this_slug ) ) : ?> <span class="attention"><?php printf( esc_html__( 'Possible %1$s conflict: %2$s', 'bbpress' ), $value['context'], '<strong>' . $value['name'] . '</strong>' ); ?></span> <?php endif; } }
Changelog Changelog
Version | Description |
---|---|
2.0.0 | Introduced. |