bbp_form_slug_conflict_check( string $slug, string $default )
Used to check if a Forums slug conflicts with an existing known slug.
Description
Parameters
- $slug
-
(Required)
- $default
-
(Required)
Source
File: bp-forums/admin/settings.php
1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 | 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' => __( 'Posts' , 'buddyboss' ), 'default' => 'post' , 'context' => 'WordPress' ), 'page_base' => array ( 'name' => __( 'Pages' , 'buddyboss' ), 'default' => 'page' , 'context' => 'WordPress' ), 'revision_base' => array ( 'name' => __( 'Revisions' , 'buddyboss' ), 'default' => 'revision' , 'context' => 'WordPress' ), 'attachment_base' => array ( 'name' => __( 'Attachments' , 'buddyboss' ), 'default' => 'attachment' , 'context' => 'WordPress' ), 'nav_menu_base' => array ( 'name' => __( 'Menus' , 'buddyboss' ), 'default' => 'nav_menu_item' , 'context' => 'WordPress' ), // Post Tags 'tag_base' => array ( 'name' => __( 'Tag base' , 'buddyboss' ), 'default' => 'tag' , 'context' => 'WordPress' ), // Post Categories 'category_base' => array ( 'name' => __( 'Category base' , 'buddyboss' ), 'default' => 'category' , 'context' => 'WordPress' ), /** Forums Core ******************************************************/ // Forum archive slug '_bbp_root_slug' => array ( 'name' => __( 'Forums base' , 'buddyboss' ), 'default' => 'forums' , 'context' => 'Forums' ), // Topic archive slug '_bbp_topic_archive_slug' => array ( 'name' => __( 'Discussions base' , 'buddyboss' ), 'default' => 'discussions' , 'context' => 'Forums' ), // Forum slug '_bbp_forum_slug' => array ( 'name' => __( 'Forum slug' , 'buddyboss' ), 'default' => 'forum' , 'context' => 'Forums' ), // Topic slug '_bbp_topic_slug' => array ( 'name' => __( 'Discussion slug' , 'buddyboss' ), 'default' => 'discussion' , 'context' => 'Forums' ), // Reply slug '_bbp_reply_slug' => array ( 'name' => __( 'Reply slug' , 'buddyboss' ), 'default' => 'reply' , 'context' => 'Forums' ), // User profile slug '_bbp_user_slug' => array ( 'name' => __( 'User base' , 'buddyboss' ), 'default' => 'users' , 'context' => 'Forums' ), // View slug '_bbp_view_slug' => array ( 'name' => __( 'View base' , 'buddyboss' ), 'default' => 'view' , 'context' => 'Forums' ), // Topic tag slug '_bbp_topic_tag_slug' => array ( 'name' => __( 'Discussion tag slug' , 'buddyboss' ), 'default' => 'discussion-tag' , 'context' => 'Forums' ), ) ); /** BuddyBoss 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( __( '%s page' , 'buddyboss' ), $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' , 'buddyboss' ), $value [ 'context' ], '<strong>' . $value [ 'name' ] . '</strong>' ); ?></span> <?php endif ; } } |
Changelog
Version | Description |
---|---|
bbPress (r3306) | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.