| 1 |
<?php |
| 2 |
/** |
| 3 |
* Friends Shortcodes |
| 4 |
* |
| 5 |
* This contains the functions for shortcodes. |
| 6 |
* |
| 7 |
* @package Friends |
| 8 |
*/ |
| 9 |
|
| 10 |
namespace Friends; |
| 11 |
|
| 12 |
/** |
| 13 |
* This is the class for the Friends Plugin shortcodes. |
| 14 |
* |
| 15 |
* @since 0.8 |
| 16 |
* |
| 17 |
* @package Friends |
| 18 |
* @author Alex Kirk |
| 19 |
*/ |
| 20 |
class Shortcodes { |
| 21 |
/** |
| 22 |
* Contains a reference to the Friends class. |
| 23 |
* |
| 24 |
* @var Friends |
| 25 |
*/ |
| 26 |
private $friends = null; |
| 27 |
|
| 28 |
/** |
| 29 |
* Constructor |
| 30 |
* |
| 31 |
* @param Friends $friends A reference to the Friends object. |
| 32 |
*/ |
| 33 |
public function __construct( Friends $friends ) { |
| 34 |
$this->friends = $friends; |
| 35 |
$this->register_shortcodes(); |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* Register the WordPress shortcodes |
| 40 |
*/ |
| 41 |
private function register_shortcodes() { |
| 42 |
add_shortcode( 'only-friends', '__return_empty_string' ); // deprecated after removal of friendships. |
| 43 |
add_shortcode( 'not-friends', '__return_empty_string' ); // deprecated after removal of friendships. |
| 44 |
add_shortcode( 'friends-list', '__return_empty_string' ); // deprecated after removal of friendships. |
| 45 |
add_shortcode( 'friends-count', array( $this, 'friends_count_shortcode' ) ); |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* Display the number of your friends. |
| 50 |
* |
| 51 |
* @return string The content to be output. |
| 52 |
*/ |
| 53 |
public function friends_count_shortcode() { |
| 54 |
$friends = User_Query::all_subscriptions(); |
| 55 |
return $friends->get_total(); |
| 56 |
} |
| 57 |
} |
| 58 |
|