-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathclass-virtual-widgets-repository.php
89 lines (79 loc) · 1.7 KB
/
class-virtual-widgets-repository.php
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
<?php
/**
* Implementation of virtual widget repository.
*
* @package categoryposts.
*
* @since 4.7
*/
namespace categoryPosts;
// Don't call the file directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class that implement a simple repository for the virtual widgets representing
* actuall shortcode and widgets
*
* @since 4.7
*/
class Virtual_Widgets_Repository {
/**
* Collection of objects representing shortcodes.
*
* @var array
*
* @since 4.7
*/
private static $shortcodeCollection = array();
/**
* Collection of objects representing widgets.
*
* @var array
*
* @since 4.7
*/
private static $widgetCollection = array();
/**
* Add a virtual widget representing a shortcode to the repository
*
* @param string $index A name to identify the specific shortcode.
* @param Virtual_Widget $widget The virtual widget for it.
*
* @since 4.7
*/
public function addShortcode( $index, $widget ) {
self::$shortcodeCollection[ $index ] = $widget;
}
/**
* Get all the virtual widgets representing actual shortcodes
*
* @return array
*
* @since 4.7
*/
public function getShortcodes() {
return self::$shortcodeCollection;
}
/**
* Add a virtual widget representing awidget to the repository
*
* @param string $index A name to identify the specific widget.
* @param Virtual_Widget $widget The virstual widget for it.
*
* @since 4.7
*/
public function addWidget( $index, $widget ) {
self::$widgetCollection[ $index ] = $widget;
}
/**
* Get all the virtual widgets representing actual widgets
*
* @return array
*
* @since 4.7
*/
public function getWidgets() {
return self::$widgetCollection;
}
}