Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
96.11% |
173 / 180 |
|
62.50% |
10 / 16 |
CRAP | |
0.00% |
0 / 1 |
| Creator | |
96.63% |
172 / 178 |
|
62.50% |
10 / 16 |
16 | |
0.00% |
0 / 1 |
| get_plugin_filename | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| get_name | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_title | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_description | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| get_long_description | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| get_features | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
| get_tiers | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| get_features_by_tier | |
100.00% |
134 / 134 |
|
100.00% |
1 / 1 |
1 | |||
| get_pricing_for_ui | |
100.00% |
15 / 15 |
|
100.00% |
1 / 1 |
1 | |||
| get_manage_url | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_wpcom_product_slug | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_wpcom_biyearly_product_slug | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_wpcom_monthly_product_slug | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_paid_bundles_that_include_product | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
| get_paid_plan_product_slugs | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
| is_upgradable | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Creator product |
| 4 | * |
| 5 | * @package my-jetpack |
| 6 | */ |
| 7 | |
| 8 | namespace Automattic\Jetpack\My_Jetpack\Products; |
| 9 | |
| 10 | use Automattic\Jetpack\My_Jetpack\Product; |
| 11 | use Automattic\Jetpack\My_Jetpack\Wpcom_Products; |
| 12 | |
| 13 | if ( ! defined( 'ABSPATH' ) ) { |
| 14 | exit( 0 ); |
| 15 | } |
| 16 | |
| 17 | /** |
| 18 | * Class responsible for handling the Creator product |
| 19 | */ |
| 20 | class Creator extends Product { |
| 21 | |
| 22 | const FREE_TIER_SLUG = 'free'; |
| 23 | const UPGRADED_TIER_SLUG = 'upgraded'; |
| 24 | const UPGRADED_TIER_PRODUCT_SLUG = 'jetpack_creator_yearly'; |
| 25 | |
| 26 | /** |
| 27 | * The product slug |
| 28 | * |
| 29 | * @var string |
| 30 | */ |
| 31 | public static $slug = 'creator'; |
| 32 | |
| 33 | /** |
| 34 | * The slug of the plugin associated with this product - Creator functionalities are part of Jetpack's main plugin |
| 35 | * |
| 36 | * @var string |
| 37 | */ |
| 38 | public static $plugin_slug = self::JETPACK_PLUGIN_SLUG; |
| 39 | |
| 40 | /** |
| 41 | * Get the plugin filename - ovewrite it and return Jetpack's |
| 42 | * |
| 43 | * @return ?string |
| 44 | */ |
| 45 | public static function get_plugin_filename() { |
| 46 | return self::JETPACK_PLUGIN_FILENAME; |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Whether this product requires a user connection |
| 51 | * |
| 52 | * @var string |
| 53 | */ |
| 54 | public static $requires_user_connection = false; |
| 55 | |
| 56 | /** |
| 57 | * Whether this product has a free offering |
| 58 | * |
| 59 | * @var bool |
| 60 | */ |
| 61 | public static $has_free_offering = true; |
| 62 | |
| 63 | /** |
| 64 | * Get the product name |
| 65 | * |
| 66 | * @return string |
| 67 | */ |
| 68 | public static function get_name() { |
| 69 | return 'Creator'; |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Get the product title |
| 74 | * |
| 75 | * @return string |
| 76 | */ |
| 77 | public static function get_title() { |
| 78 | return 'Jetpack Creator'; |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * Get the internationalized product description |
| 83 | * |
| 84 | * @return string |
| 85 | */ |
| 86 | public static function get_description() { |
| 87 | return __( 'Get more subscribers and keep them engaged with our creator tools', 'jetpack-my-jetpack' ); |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * Get the internationalized product long description |
| 92 | * |
| 93 | * @return string |
| 94 | */ |
| 95 | public static function get_long_description() { |
| 96 | return __( 'Craft stunning content, boost your subscriber base, and monetize your audience with subscriptions.', 'jetpack-my-jetpack' ); |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Get the internationalized features list |
| 101 | * |
| 102 | * @return array Features list |
| 103 | */ |
| 104 | public static function get_features() { |
| 105 | return array( |
| 106 | __( 'Create content that stands out', 'jetpack-my-jetpack' ), |
| 107 | __( 'Grow your subscribers through our creator network and tools', 'jetpack-my-jetpack' ), |
| 108 | __( 'Monetize your online presence and earn from your website', 'jetpack-my-jetpack' ), |
| 109 | ); |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * Get the product's available tiers |
| 114 | * |
| 115 | * @return string[] Slugs of the available tiers |
| 116 | */ |
| 117 | public static function get_tiers() { |
| 118 | return array( |
| 119 | self::UPGRADED_TIER_SLUG, |
| 120 | self::FREE_TIER_SLUG, |
| 121 | ); |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Get the internationalized comparison of free vs upgraded features |
| 126 | * |
| 127 | * @return array[] Protect features comparison |
| 128 | */ |
| 129 | public static function get_features_by_tier() { |
| 130 | return array( |
| 131 | array( |
| 132 | 'name' => __( 'Import subscribers', 'jetpack-my-jetpack' ), |
| 133 | 'info' => array( |
| 134 | 'content' => __( |
| 135 | 'Import a CSV file of your existing subscribers to be sent your Newsletter.', |
| 136 | 'jetpack-my-jetpack' |
| 137 | ), |
| 138 | ), |
| 139 | 'tiers' => array( |
| 140 | self::FREE_TIER_SLUG => array( |
| 141 | 'included' => true, |
| 142 | 'description' => __( '100 subscribers', 'jetpack-my-jetpack' ), |
| 143 | ), |
| 144 | self::UPGRADED_TIER_SLUG => array( |
| 145 | 'included' => true, |
| 146 | 'description' => __( 'Unlimited subscribers', 'jetpack-my-jetpack' ), |
| 147 | ), |
| 148 | ), |
| 149 | ), |
| 150 | array( |
| 151 | 'name' => __( 'Transaction fees', 'jetpack-my-jetpack' ), |
| 152 | 'info' => array( |
| 153 | 'content' => __( |
| 154 | '<p>Fees are only collected when you accept payments.</p> |
| 155 | <p>Fees are based on the Jetpack plan you have and are calculated as a percentage of your revenue from 10% on the Free plan to 2% on the Creator plan (plus Stripe fees).</p>', |
| 156 | 'jetpack-my-jetpack' |
| 157 | ), |
| 158 | ), |
| 159 | 'tiers' => array( |
| 160 | self::FREE_TIER_SLUG => array( |
| 161 | 'included' => true, |
| 162 | 'description' => __( '10%', 'jetpack-my-jetpack' ), |
| 163 | ), |
| 164 | self::UPGRADED_TIER_SLUG => array( |
| 165 | 'included' => true, |
| 166 | 'description' => __( '2%', 'jetpack-my-jetpack' ), |
| 167 | ), |
| 168 | ), |
| 169 | ), |
| 170 | array( |
| 171 | 'name' => __( 'Jetpack Blocks', 'jetpack-my-jetpack' ), |
| 172 | 'info' => array( |
| 173 | 'content' => __( |
| 174 | 'Jetpack has over 40 Gutenberg blocks to help you with your content creation, such as displaying your podcasts, showing different content to repeat visitors, creating contact forms and many more.', |
| 175 | 'jetpack-my-jetpack' |
| 176 | ), |
| 177 | ), |
| 178 | 'tiers' => array( |
| 179 | self::FREE_TIER_SLUG => array( 'included' => true ), |
| 180 | self::UPGRADED_TIER_SLUG => array( 'included' => true ), |
| 181 | ), |
| 182 | ), |
| 183 | array( |
| 184 | 'name' => __( 'Paid content gating', 'jetpack-my-jetpack' ), |
| 185 | 'info' => array( |
| 186 | 'content' => __( |
| 187 | 'Lock your content behind a paid content block. To access the content, readers will need to pay a one-time fee or a recurring subscription.', |
| 188 | 'jetpack-my-jetpack' |
| 189 | ), |
| 190 | ), |
| 191 | 'tiers' => array( |
| 192 | self::FREE_TIER_SLUG => array( 'included' => true ), |
| 193 | self::UPGRADED_TIER_SLUG => array( 'included' => true ), |
| 194 | ), |
| 195 | ), |
| 196 | array( |
| 197 | 'name' => __( 'Paywall access', 'jetpack-my-jetpack' ), |
| 198 | 'info' => array( |
| 199 | 'content' => __( |
| 200 | 'Add a Paywall to your content which lets your visitors read a section of your content before being asked to subscribe to continue reading.', |
| 201 | 'jetpack-my-jetpack' |
| 202 | ), |
| 203 | ), |
| 204 | 'tiers' => array( |
| 205 | self::FREE_TIER_SLUG => array( 'included' => true ), |
| 206 | self::UPGRADED_TIER_SLUG => array( 'included' => true ), |
| 207 | ), |
| 208 | ), |
| 209 | array( |
| 210 | 'name' => __( 'Newsletter', 'jetpack-my-jetpack' ), |
| 211 | 'info' => array( |
| 212 | 'content' => __( |
| 213 | 'Start a Newsletter by sending your content as an email newsletter direct to your fans email inboxes.', |
| 214 | 'jetpack-my-jetpack' |
| 215 | ), |
| 216 | ), |
| 217 | 'tiers' => array( |
| 218 | self::FREE_TIER_SLUG => array( 'included' => true ), |
| 219 | self::UPGRADED_TIER_SLUG => array( 'included' => true ), |
| 220 | ), |
| 221 | ), |
| 222 | array( |
| 223 | 'name' => __( 'Pay with PayPal', 'jetpack-my-jetpack' ), |
| 224 | 'info' => array( |
| 225 | 'content' => __( |
| 226 | 'Accept payment with PayPal for simple payments like eBooks, courses and more.', |
| 227 | 'jetpack-my-jetpack' |
| 228 | ), |
| 229 | ), |
| 230 | 'tiers' => array( |
| 231 | self::FREE_TIER_SLUG => array( 'included' => false ), |
| 232 | self::UPGRADED_TIER_SLUG => array( 'included' => true ), |
| 233 | ), |
| 234 | ), |
| 235 | array( |
| 236 | 'name' => __( 'WordAds', 'jetpack-my-jetpack' ), |
| 237 | 'info' => array( |
| 238 | 'content' => __( |
| 239 | '<p>WordAds adds advertisements to your website. Start earning from your website traffic.</p> |
| 240 | <p>Over 50 internet advertisers — including Google AdSense & Adx, AppNexus, Amazon A9, AOL Marketplace, Yahoo, Criteo, and more — bid to display ads in WordAds spots.</p>', |
| 241 | 'jetpack-my-jetpack' |
| 242 | ), |
| 243 | ), |
| 244 | 'tiers' => array( |
| 245 | self::FREE_TIER_SLUG => array( 'included' => false ), |
| 246 | self::UPGRADED_TIER_SLUG => array( 'included' => true ), |
| 247 | ), |
| 248 | ), |
| 249 | array( |
| 250 | 'name' => __( 'Dedicated email support', 'jetpack-my-jetpack' ), |
| 251 | 'info' => array( |
| 252 | 'content' => __( |
| 253 | '<p>Paid customers get dedicated email support from our world-class Happiness Engineers to help with any issue.</p> |
| 254 | <p>All other questions are handled by our team as quickly as we are able to go through the WordPress support forum.</p>', |
| 255 | 'jetpack-my-jetpack' |
| 256 | ), |
| 257 | ), |
| 258 | 'tiers' => array( |
| 259 | self::FREE_TIER_SLUG => array( 'included' => false ), |
| 260 | self::UPGRADED_TIER_SLUG => array( 'included' => true ), |
| 261 | ), |
| 262 | ), |
| 263 | ); |
| 264 | } |
| 265 | |
| 266 | /** |
| 267 | * Get the product princing details |
| 268 | * |
| 269 | * @return array Pricing details |
| 270 | */ |
| 271 | public static function get_pricing_for_ui() { |
| 272 | return array( |
| 273 | 'tiers' => array( |
| 274 | self::FREE_TIER_SLUG => array( |
| 275 | 'available' => true, |
| 276 | 'is_free' => true, |
| 277 | ), |
| 278 | self::UPGRADED_TIER_SLUG => array_merge( |
| 279 | array( |
| 280 | 'available' => true, |
| 281 | 'wpcom_product_slug' => self::UPGRADED_TIER_PRODUCT_SLUG, |
| 282 | ), |
| 283 | Wpcom_Products::get_product_pricing( self::UPGRADED_TIER_PRODUCT_SLUG ) |
| 284 | ), |
| 285 | ), |
| 286 | ); |
| 287 | } |
| 288 | |
| 289 | /** |
| 290 | * Get the URL where the user manages the product |
| 291 | * |
| 292 | * @return ?string |
| 293 | */ |
| 294 | public static function get_manage_url() { |
| 295 | return admin_url( 'admin.php?page=jetpack#/settings?term=creator' ); |
| 296 | } |
| 297 | |
| 298 | /** |
| 299 | * Get the WPCOM product slug used to make the purchase |
| 300 | * |
| 301 | * @return ?string |
| 302 | */ |
| 303 | public static function get_wpcom_product_slug() { |
| 304 | return 'jetpack_creator_yearly'; |
| 305 | } |
| 306 | |
| 307 | /** |
| 308 | * Get the WPCOM product slug used to make the purchase |
| 309 | * |
| 310 | * @return ?string |
| 311 | */ |
| 312 | public static function get_wpcom_biyearly_product_slug() { |
| 313 | return 'jetpack_creator_bi_yearly'; |
| 314 | } |
| 315 | |
| 316 | /** |
| 317 | * Get the WPCOM monthly product slug used to make the purchase |
| 318 | * |
| 319 | * @return ?string |
| 320 | */ |
| 321 | public static function get_wpcom_monthly_product_slug() { |
| 322 | return 'jetpack_creator_monthly'; |
| 323 | } |
| 324 | |
| 325 | /** |
| 326 | * Get the product-slugs of the paid bundles/plans that this product/module is included in |
| 327 | * |
| 328 | * @return array |
| 329 | */ |
| 330 | public static function get_paid_bundles_that_include_product() { |
| 331 | return array( |
| 332 | 'jetpack_complete', |
| 333 | 'jetpack_complete_monthly', |
| 334 | 'jetpack_complete_bi-yearly', |
| 335 | ); |
| 336 | } |
| 337 | |
| 338 | /** |
| 339 | * Get the product-slugs of the paid plans for this product. |
| 340 | * (Do not include bundle plans, unless it's a bundle plan itself). |
| 341 | * |
| 342 | * @return array |
| 343 | */ |
| 344 | public static function get_paid_plan_product_slugs() { |
| 345 | return array( |
| 346 | 'jetpack_creator_yearly', |
| 347 | 'jetpack_creator_monthly', |
| 348 | 'jetpack_creator_bi_yearly', |
| 349 | ); |
| 350 | } |
| 351 | |
| 352 | /** |
| 353 | * Checks whether the product can be upgraded - i.e. this shows the /#add-creator interstitial |
| 354 | * |
| 355 | * @return boolean |
| 356 | */ |
| 357 | public static function is_upgradable() { |
| 358 | return ! self::has_paid_plan_for_product(); |
| 359 | } |
| 360 | } |