BP_Compatibility_Integration
Setup the bp compatibility class.
Description
Source
File: bp-integrations/compatibility/bp-compatibility-integration.php
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | class BP_Compatibility_Integration extends BP_Integration { public function __construct() { $this ->start( 'compatibility' , __( 'BuddyPress' , 'buddyboss' ), 'compatibility' , array ( 'required_plugin' => array (), ) ); // Add link to settings page. add_filter( 'plugin_action_links' , array ( $this , 'action_links' ), 11000, 2 ); add_filter( 'network_admin_plugin_action_links' , array ( $this , 'action_links' ), 11000, 2 ); } /** * Change the Third party plugin setting link. * * @param $link * @param $file * * @since BuddyBoss 1.2.0 * * @return array */ public function action_links( $link , $file ) { // Return normal links if not BuddyBoss Platform plugin or it's does not have a setting links if ( plugin_basename( 'buddyboss-platform/bp-loader.php' ) == $file || empty ( $link [ 'settings' ] ) ) { return $link ; } $htmlDom = new DOMDocument; // Parse the HTML of the page using DOMDocument::loadHTML $htmlDom ->loadHTML( htmlentities( $link [ 'settings' ] ) ); // Extract the links from the HTML. $links = $htmlDom ->getElementsByTagName( 'a' ); $extractedLinks = array (); if ( ! empty ( $links ) ) { foreach ( $links as $link_obj ) { $extractedLinks [] = $link_obj ->getAttribute( 'href' ); } } if ( ! empty ( $extractedLinks ) && in_array( bp_get_admin_url( add_query_arg( array ( 'page' => 'bp-settings' ), 'admin.php' ) ), $extractedLinks ) ) { // Add a few links to the existing links array. return array_merge ( $link , array ( 'settings' => '<a href="' . esc_url( bp_get_admin_url( add_query_arg( array ( 'page' => 'bp-integrations' , 'tab' => 'bp-compatibility' ), 'admin.php' ) ) ) . '">' . esc_html__( 'Settings' , 'buddyboss' ) . '</a>' , ) ); } return $link ; } /** * Register admin setting tab, only if Compatibility plugin is disabled * * @since BuddyBoss 1.1.5 */ public function setup_admin_integration_tab() { require_once trailingslashit( $this ->path ) . 'bp-admin-compatibility-tab.php' ; new BP_Compatibility_Admin_Integration_Tab( "bp-{$this->id}" , $this ->name, array ( 'root_path' => $this ->path, 'root_url' => $this ->url, 'required_plugin' => $this ->required_plugin, ) ); } } |
Changelog
Version | Description |
---|---|
BuddyBoss 1.1.5 | Introduced. |
Methods
- __construct
- action_links — Change the Third party plugin setting link.
- setup_admin_integration_tab — Register admin setting tab, only if Compatibility plugin is disabled
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.