1 | <?php |
||
13 | class Jetpack_Memberships { |
||
14 | /** |
||
15 | * CSS class prefix to use in the styling. |
||
16 | * |
||
17 | * @var string |
||
18 | */ |
||
19 | public static $css_classname_prefix = 'jetpack-memberships'; |
||
20 | /** |
||
21 | * Our CPT type for the product (plan). |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | public static $post_type_plan = 'jp_mem_plan'; |
||
26 | /** |
||
27 | * Option that will store currently set up account (Stripe etc) id for memberships. |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | public static $connected_account_id_option_name = 'jetpack-memberships-connected-account-id'; |
||
32 | /** |
||
33 | * Button block type to use. |
||
34 | * |
||
35 | * @var string |
||
36 | */ |
||
37 | private static $button_block_name = 'membership-button'; |
||
38 | /** |
||
39 | * Classic singleton pattern |
||
40 | * |
||
41 | * @var Jetpack_Memberships |
||
42 | */ |
||
43 | private static $instance; |
||
44 | |||
45 | /** |
||
46 | * Jetpack_Memberships constructor. |
||
47 | */ |
||
48 | private function __construct() {} |
||
49 | |||
50 | /** |
||
51 | * The actual constructor initializing the object. |
||
52 | * |
||
53 | * @return Jetpack_Memberships |
||
54 | */ |
||
55 | public static function get_instance() { |
||
63 | /** |
||
64 | * Get the map that defines the shape of CPT post. keys are names of fields and |
||
65 | * 'meta' is the name of actual WP post meta field that corresponds. |
||
66 | * |
||
67 | * @return array |
||
68 | */ |
||
69 | private static function get_plan_property_mapping() { |
||
81 | |||
82 | /** |
||
83 | * Inits further hooks on init hook. |
||
84 | */ |
||
85 | private function register_init_hook() { |
||
88 | |||
89 | /** |
||
90 | * Actual hooks initializing on init. |
||
91 | */ |
||
92 | public function init_hook_action() { |
||
97 | |||
98 | /** |
||
99 | * Sets up the custom post types for the module. |
||
100 | */ |
||
101 | private function setup_cpts() { |
||
134 | |||
135 | /** |
||
136 | * Allows custom post types to be used by REST API. |
||
137 | * |
||
138 | * @param array $post_types - other post types. |
||
139 | * |
||
140 | * @see hook 'rest_api_allowed_post_types' |
||
141 | * @return array |
||
142 | */ |
||
143 | public function allow_rest_api_types( $post_types ) { |
||
148 | |||
149 | /** |
||
150 | * Allows custom meta fields to sync. |
||
151 | * |
||
152 | * @param array $post_meta - previously changet post meta. |
||
153 | * |
||
154 | * @return array |
||
155 | */ |
||
156 | public function allow_sync_post_meta( $post_meta ) { |
||
163 | |||
164 | /** |
||
165 | * This returns meta attribute of passet array. |
||
166 | * Used for array functions. |
||
167 | * |
||
168 | * @param array $map - stuff. |
||
169 | * |
||
170 | * @return mixed |
||
171 | */ |
||
172 | public function return_meta( $map ) { |
||
175 | /** |
||
176 | * Callback that parses the membership purchase shortcode. |
||
177 | * |
||
178 | * @param array $attrs - attributes in the shortcode. `id` here is the CPT id of the plan. |
||
179 | * |
||
180 | * @return string|void |
||
181 | */ |
||
182 | public function render_button( $attrs ) { |
||
249 | |||
250 | /** |
||
251 | * Get current blog id. |
||
252 | * |
||
253 | * @return int |
||
254 | */ |
||
255 | public static function get_blog_id() { |
||
262 | |||
263 | /** |
||
264 | * Get the id of the connected payment acount (Stripe etc). |
||
265 | * |
||
266 | * @return int|void |
||
267 | */ |
||
268 | public static function get_connected_account_id() { |
||
271 | } |
||
272 | Jetpack_Memberships::get_instance(); |
||
273 |