Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
93.48% covered (success)
93.48%
43 / 46
86.67% covered (warning)
86.67%
13 / 15
CRAP
0.00% covered (danger)
0.00%
0 / 1
Creator
95.45% covered (success)
95.45%
42 / 44
86.67% covered (warning)
86.67%
13 / 15
16
0.00% covered (danger)
0.00%
0 / 1
 get_plugin_filename
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 get_name
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 get_title
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 get_description
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 get_long_description
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 get_features
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
 get_tiers
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 get_features_by_tier
n/a
0 / 0
n/a
0 / 0
1
 get_pricing_for_ui
100.00% covered (success)
100.00%
15 / 15
100.00% covered (success)
100.00%
1 / 1
1
 get_manage_url
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 get_wpcom_product_slug
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 get_wpcom_biyearly_product_slug
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 get_wpcom_monthly_product_slug
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 get_paid_bundles_that_include_product
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
 get_paid_plan_product_slugs
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
 is_upgradable
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2/**
3 * Creator product
4 *
5 * @package my-jetpack
6 */
7
8namespace Automattic\Jetpack\My_Jetpack\Products;
9
10use Automattic\Jetpack\My_Jetpack\Product;
11use Automattic\Jetpack\My_Jetpack\Wpcom_Products;
12
13if ( ! defined( 'ABSPATH' ) ) {
14    exit( 0 );
15}
16
17/**
18 * Class responsible for handling the Creator product
19 */
20class 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     * @deprecated 6.10.0
128     *
129     * @return array[] Creator features comparison
130     */
131    public static function get_features_by_tier() {
132        _deprecated_function( __METHOD__, 'jetpack-my-jetpack-6.10.0' );
133
134        return array(
135            array(
136                'name'  => __( 'Import subscribers', 'jetpack-my-jetpack' ),
137                'info'  => array(
138                    'content' => __(
139                        'Import a CSV file of your existing subscribers to be sent your Newsletter.',
140                        'jetpack-my-jetpack'
141                    ),
142                ),
143                'tiers' => array(
144                    self::FREE_TIER_SLUG     => array(
145                        'included'    => true,
146                        'description' => __( '100 subscribers', 'jetpack-my-jetpack' ),
147                    ),
148                    self::UPGRADED_TIER_SLUG => array(
149                        'included'    => true,
150                        'description' => __( 'Unlimited subscribers', 'jetpack-my-jetpack' ),
151                    ),
152                ),
153            ),
154            array(
155                'name'  => __( 'Transaction fees', 'jetpack-my-jetpack' ),
156                'info'  => array(
157                    'content' => __(
158                        '<p>Fees are only collected when you accept payments.</p>
159                        <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>',
160                        'jetpack-my-jetpack'
161                    ),
162                ),
163                'tiers' => array(
164                    self::FREE_TIER_SLUG     => array(
165                        'included'    => true,
166                        'description' => __( '10%', 'jetpack-my-jetpack' ),
167                    ),
168                    self::UPGRADED_TIER_SLUG => array(
169                        'included'    => true,
170                        'description' => __( '2%', 'jetpack-my-jetpack' ),
171                    ),
172                ),
173            ),
174            array(
175                'name'  => __( 'Jetpack Blocks', 'jetpack-my-jetpack' ),
176                'info'  => array(
177                    'content' => __(
178                        '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.',
179                        'jetpack-my-jetpack'
180                    ),
181                ),
182                'tiers' => array(
183                    self::FREE_TIER_SLUG     => array( 'included' => true ),
184                    self::UPGRADED_TIER_SLUG => array( 'included' => true ),
185                ),
186            ),
187            array(
188                'name'  => __( 'Paid content gating', 'jetpack-my-jetpack' ),
189                'info'  => array(
190                    'content' => __(
191                        '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.',
192                        'jetpack-my-jetpack'
193                    ),
194                ),
195                'tiers' => array(
196                    self::FREE_TIER_SLUG     => array( 'included' => true ),
197                    self::UPGRADED_TIER_SLUG => array( 'included' => true ),
198                ),
199            ),
200            array(
201                'name'  => __( 'Paywall access', 'jetpack-my-jetpack' ),
202                'info'  => array(
203                    'content' => __(
204                        'Add a Paywall to your content which lets your visitors read a section of your content before being asked to subscribe to continue reading.',
205                        'jetpack-my-jetpack'
206                    ),
207                ),
208                'tiers' => array(
209                    self::FREE_TIER_SLUG     => array( 'included' => true ),
210                    self::UPGRADED_TIER_SLUG => array( 'included' => true ),
211                ),
212            ),
213            array(
214                'name'  => __( 'Newsletter', 'jetpack-my-jetpack' ),
215                'info'  => array(
216                    'content' => __(
217                        'Start a Newsletter by sending your content as an email newsletter direct to your fans email inboxes.',
218                        'jetpack-my-jetpack'
219                    ),
220                ),
221                'tiers' => array(
222                    self::FREE_TIER_SLUG     => array( 'included' => true ),
223                    self::UPGRADED_TIER_SLUG => array( 'included' => true ),
224                ),
225            ),
226            array(
227                'name'  => __( 'Pay with PayPal', 'jetpack-my-jetpack' ),
228                'info'  => array(
229                    'content' => __(
230                        'Accept payment with PayPal for simple payments like eBooks, courses and more.',
231                        'jetpack-my-jetpack'
232                    ),
233                ),
234                'tiers' => array(
235                    self::FREE_TIER_SLUG     => array( 'included' => false ),
236                    self::UPGRADED_TIER_SLUG => array( 'included' => true ),
237                ),
238            ),
239            array(
240                'name'  => __( 'WordAds', 'jetpack-my-jetpack' ),
241                'info'  => array(
242                    'content' => __(
243                        '<p>WordAds adds advertisements to your website. Start earning from your website traffic.</p>
244                        <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>',
245                        'jetpack-my-jetpack'
246                    ),
247                ),
248                'tiers' => array(
249                    self::FREE_TIER_SLUG     => array( 'included' => false ),
250                    self::UPGRADED_TIER_SLUG => array( 'included' => true ),
251                ),
252            ),
253            array(
254                'name'  => __( 'Dedicated email support', 'jetpack-my-jetpack' ),
255                'info'  => array(
256                    'content' => __(
257                        '<p>Paid customers get dedicated email support from our world-class Happiness Engineers to help with any issue.</p>
258                         <p>All other questions are handled by our team as quickly as we are able to go through the WordPress support forum.</p>',
259                        'jetpack-my-jetpack'
260                    ),
261                ),
262                'tiers' => array(
263                    self::FREE_TIER_SLUG     => array( 'included' => false ),
264                    self::UPGRADED_TIER_SLUG => array( 'included' => true ),
265                ),
266            ),
267        );
268    }
269
270    /**
271     * Get the product princing details
272     *
273     * @return array Pricing details
274     */
275    public static function get_pricing_for_ui() {
276        return array(
277            'tiers' => array(
278                self::FREE_TIER_SLUG     => array(
279                    'available' => true,
280                    'is_free'   => true,
281                ),
282                self::UPGRADED_TIER_SLUG => array_merge(
283                    array(
284                        'available'          => true,
285                        'wpcom_product_slug' => self::UPGRADED_TIER_PRODUCT_SLUG,
286                    ),
287                    Wpcom_Products::get_product_pricing( self::UPGRADED_TIER_PRODUCT_SLUG )
288                ),
289            ),
290        );
291    }
292
293    /**
294     * Get the URL where the user manages the product
295     *
296     * @return ?string
297     */
298    public static function get_manage_url() {
299        return admin_url( 'admin.php?page=jetpack#/settings?term=creator' );
300    }
301
302    /**
303     * Get the WPCOM product slug used to make the purchase
304     *
305     * @return ?string
306     */
307    public static function get_wpcom_product_slug() {
308        return 'jetpack_creator_yearly';
309    }
310
311    /**
312     * Get the WPCOM product slug used to make the purchase
313     *
314     * @return ?string
315     */
316    public static function get_wpcom_biyearly_product_slug() {
317        return 'jetpack_creator_bi_yearly';
318    }
319
320    /**
321     * Get the WPCOM monthly product slug used to make the purchase
322     *
323     * @return ?string
324     */
325    public static function get_wpcom_monthly_product_slug() {
326        return 'jetpack_creator_monthly';
327    }
328
329    /**
330     * Get the product-slugs of the paid bundles/plans that this product/module is included in
331     *
332     * @return array
333     */
334    public static function get_paid_bundles_that_include_product() {
335        return array(
336            'jetpack_complete',
337            'jetpack_complete_monthly',
338            'jetpack_complete_bi-yearly',
339        );
340    }
341
342    /**
343     * Get the product-slugs of the paid plans for this product.
344     * (Do not include bundle plans, unless it's a bundle plan itself).
345     *
346     * @return array
347     */
348    public static function get_paid_plan_product_slugs() {
349        return array(
350            'jetpack_creator_yearly',
351            'jetpack_creator_monthly',
352            'jetpack_creator_bi_yearly',
353        );
354    }
355
356    /**
357     * Checks whether the product can be upgraded - i.e. this shows the /#add-creator interstitial
358     *
359     * @return boolean
360     */
361    public static function is_upgradable() {
362        return ! self::has_paid_plan_for_product();
363    }
364}