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