PluginProbe
Friends / trunk
Friends vtrunk
4.3.1 4.3.0 4.2.2 4.2.1 4.2.0 4.1.0 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9.0 2.9.1 2.9.2 All 87 releases
friends / includes / class-shortcodes.php

class-shortcodes.php in Friends trunk, at includes/class-shortcodes.php

58 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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