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