-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbp-activity-as-shortcode.php
More file actions
119 lines (100 loc) · 2.12 KB
/
bp-activity-as-shortcode.php
File metadata and controls
119 lines (100 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
/**
* Plugin Name: BuddyPress Activity ShortCode
* Description: Embed activity stream in page/post using shortcode
* Author: BuddyDev
* Plugin URI: https://buddydev.com/plugins/bp-activity-shortcode/
* Author URI: https://buddydev.com/
* Version: 1.1.9
* License: GPL
*/
// exit if access directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Helper class.
*/
/**
* Class BD_Activity_Stream_Shortcodes_Helper
*
* @property-read string $url plugin url.
* @property-read string $path plugin path.
*/
class BD_Activity_Stream_Shortcodes_Helper {
/**
* Singleton instance.
*
* @var BD_Activity_Stream_Shortcodes_Helper
*/
private static $instance;
/**
* Plugin absolute path
*
* @var string
*/
private $path;
/**
* Plugin directory url
*
* @var string
*/
private $url;
/**
* Constructor
*/
private function __construct() {
$this->path = plugin_dir_path( __FILE__ );
$this->url = plugin_dir_url( __FILE__ );
$this->setup();
}
/**
* Get Instance
*
* @return BD_Activity_Stream_Shortcodes_Helper
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Accessor.
*
* @param string $name property name.
*
* @return mixed
*/
public function __get( $name ) {
return isset( $this->{$name} ) ? $this->{$name}: null;
}
/**
* Callback to buddypress actions
*/
public function setup() {
add_action( 'bp_loaded', array( $this, 'load' ) );
add_action( 'bp_enqueue_scripts', array( $this, 'load_assets' ) );
}
/**
* Load plugin files
*/
public function load() {
$files = array(
'core/class-bpas-shortcode-util.php',
'core/class-bpas-ajax-handler.php',
'core/class-bpas-shortcode-helper.php',
);
foreach ( $files as $file ) {
require_once $this->path . $file;
}
}
/**
* Load plugin assets
*/
public function load_assets() {
wp_register_script( 'bpas-loadmore-js', $this->url . 'assets/js/bpas-loadmore.js', array( 'jquery' ) );
wp_enqueue_script( 'bpas-loadmore-js' );
}
}
BD_Activity_Stream_Shortcodes_Helper::get_instance();