buddyboss.php
71 lines
| 1 | <?php |
| 2 | /** |
| 3 | * BuddyBoss integration class file |
| 4 | * |
| 5 | * @package SureTriggers |
| 6 | * @since 1.0.0 |
| 7 | */ |
| 8 | |
| 9 | namespace SureTriggers\Integrations\BuddyBoss; |
| 10 | |
| 11 | use SureTriggers\Controllers\IntegrationsController; |
| 12 | use SureTriggers\Integrations\Integrations; |
| 13 | use SureTriggers\Traits\SingletonLoader; |
| 14 | |
| 15 | /** |
| 16 | * Class BuddyBoss |
| 17 | * |
| 18 | * @package SureTriggers\Integrations\BuddyBoss |
| 19 | */ |
| 20 | class BuddyBoss extends Integrations { |
| 21 | |
| 22 | use SingletonLoader; |
| 23 | |
| 24 | /** |
| 25 | * ID of the integration |
| 26 | * |
| 27 | * @var string |
| 28 | */ |
| 29 | protected $id = 'BuddyBoss'; |
| 30 | |
| 31 | /** |
| 32 | * BuddyBoss constructor. |
| 33 | */ |
| 34 | public function __construct() { |
| 35 | $this->name = __( 'BuddyBoss', 'suretriggers' ); |
| 36 | parent::__construct(); |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Check if content has links. |
| 41 | * |
| 42 | * @param string $content content. |
| 43 | * @return array|string |
| 44 | */ |
| 45 | public static function st_content_has_links( $content ) { |
| 46 | // Define a regular expression pattern to match URLs. |
| 47 | $pattern = '/<a\b[^>]*href=["\']([^"\'#]+)/i'; |
| 48 | |
| 49 | // Use preg_match_all to find all links in the content. |
| 50 | preg_match_all( $pattern, $content, $matches ); |
| 51 | |
| 52 | // Return the array of matched links. |
| 53 | return $matches[1]; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Check plugin is installed. |
| 58 | * |
| 59 | * @return bool |
| 60 | */ |
| 61 | public function is_plugin_installed() { |
| 62 | if ( function_exists( 'buddypress' ) && isset( buddypress()->buddyboss ) && buddypress()->buddyboss ) { |
| 63 | return true; |
| 64 | } else { |
| 65 | return false; |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | IntegrationsController::register( BuddyBoss::class ); |
| 71 |