PluginProbe
Members – Membership & User Role Editor Plugin / 3.2.26
Members – Membership & User Role Editor Plugin v3.2.26
3.2.25 3.2.26 3.2.24 3.2.23 3.2.22 3.2.21 trunk 0.1 0.1.1 0.2 0.2.1 0.2.2 0.2.3 0.2.4 0.2.5 1.0.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.1.3 2.0.0 2.0.1 2.0.2 All 66 releases
members / admin / class-addon.php

class-addon.php in Members – Membership & User Role Editor Plugin 3.2.26, at admin/class-addon.php

180 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Class for handling an add-on object.
4 *
5 * @package Members
6 * @subpackage Admin
7 * @author The MemberPress Team
8 * @copyright Copyright (c) 2009 - 2018, The MemberPress Team
9 * @link https://members-plugin.com/
10 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
11 */
12 namespace Members;
13
14 defined('ABSPATH') || exit;
15 /**
16 * Add-on object class.
17 *
18 * @since 2.0.0
19 * @access public
20 */
21 final class Addon {
22
23 /**
24 * Name/ID for the addon.
25 *
26 * @since 2.0.0
27 * @access protected
28 * @var string
29 */
30 public $name = '';
31
32 /**
33 * Title of the add-on.
34 *
35 * @since 2.0.0
36 * @access protected
37 * @var string
38 */
39 public $title = '';
40
41 /**
42 * Short description of the add-on.
43 *
44 * @since 2.0.0
45 * @access protected
46 * @var string
47 */
48 public $excerpt = '';
49
50 /**
51 * URL where the add-on can be found.
52 *
53 * @since 2.0.0
54 * @access protected
55 * @var string
56 */
57 public $url = 'https://members-plugin.com/';
58
59 /**
60 * Add-on ZIP file URL.
61 *
62 * @since 2.0.0
63 * @access protected
64 * @var string
65 */
66 public $download_url = '';
67
68 /**
69 * Alternate purchase URL.
70 *
71 * @since 2.0.0
72 * @access protected
73 * @var string
74 */
75 public $purchase_url = '';
76
77 /**
78 * URL for a 128x128 (size used by WordPress.org) icon image.
79 *
80 * @since 2.0.0
81 * @access protected
82 * @var string
83 */
84 public $icon_url = '';
85
86 /**
87 * Add-on plugin's author URL.
88 *
89 * @since 2.0.0
90 * @access protected
91 * @var string
92 */
93 public $author_url = '';
94
95 /**
96 * Add-on plugin's author display name.
97 *
98 * @since 2.0.0
99 * @access protected
100 * @var string
101 */
102 public $author_name = '';
103
104 /**
105 * Rating for the add-on. This is the total rating based on a 5-star rating system.
106 * It will be divided by the rating count, so both must be supplied.
107 *
108 * @since 2.0.0
109 * @access protected
110 * @var int
111 */
112 public $rating = '';
113
114 /**
115 * Number of ratings.
116 *
117 * @since 2.0.0
118 * @access protected
119 * @var int
120 */
121 public $rating_count = 0;
122
123 /**
124 * Number of active installs. Note that this will be displayed with a `+` at
125 * the end, such as `100,000+`. Exact counts are necessary. Just a round number.
126 *
127 * @since 2.0.0
128 * @access protected
129 * @var string
130 */
131 public $install_count = 0;
132
133 public $is_memberpress = false;
134
135 /**
136 * Magic method to use in case someone tries to output the object as a string.
137 * We'll just return the name.
138 *
139 * @since 2.0.0
140 * @access public
141 * @return string
142 */
143 public function __toString() {
144 return $this->name;
145 }
146
147 /**
148 * Register a new object.
149 *
150 * @since 2.0.0
151 * @access public
152 * @param string $name
153 * @param array $args {
154 * @type string $label Internationalized text label.
155 * @type string $icon Dashicon icon in the form of `dashicons-icon-name`.
156 * @type array $caps Array of capabilities in the addon.
157 * @type bool $merge_added Whether to merge this caps into the added caps array.
158 * @type bool $diff_added Whether to remove previously-added caps from this addon.
159 * }
160 * @return void
161 */
162 public function __construct( $name, $args = array() ) {
163
164 foreach ( array_keys( get_object_vars( $this ) ) as $key ) {
165
166 if ( isset( $args[ $key ] ) ) {
167 $this->$key = $args[ $key ];
168 }
169 }
170
171 $this->name = sanitize_key( $name );
172
173 $this->is_memberpress = isset( $args['is_memberpress'] ) && true === $args['is_memberpress'];
174
175 if ( ! $this->icon_url ) {
176 $this->icon_url = members_plugin()->uri . 'img/icon-addon.png';
177 }
178 }
179 }
180