Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
90.00% covered (success)
90.00%
18 / 20
90.00% covered (success)
90.00%
9 / 10
CRAP
0.00% covered (danger)
0.00%
0 / 1
Extras
94.44% covered (success)
94.44%
17 / 18
90.00% covered (success)
90.00%
9 / 10
10.02
0.00% covered (danger)
0.00%
0 / 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%
6 / 6
100.00% covered (success)
100.00%
1 / 1
1
 get_pricing_for_ui
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 is_active
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 is_plugin_installed
100.00% covered (success)
100.00%
1 / 1
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
 activate_plugin
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3 * Extras product
4 *
5 * @package my-jetpack
6 */
7
8namespace Automattic\Jetpack\My_Jetpack\Products;
9
10use Automattic\Jetpack\My_Jetpack\Product;
11use WP_Error;
12
13if ( ! defined( 'ABSPATH' ) ) {
14    exit( 0 );
15}
16
17/**
18 * Class responsible for handling the Extras product.
19 * Extras, so far, could be considered as Jetpack plugin bridge.
20 */
21class Extras extends Product {
22
23    /**
24     * The product slug
25     *
26     * @var string
27     */
28    public static $slug = 'extras';
29
30    /**
31     * The slug of the plugin associated with this product.
32     * Extras, is in short, Jetpack plugin bridge so far.
33     *
34     * @var string
35     */
36    public static $plugin_slug = 'jetpack';
37
38    /**
39     * Whether this product requires a user connection
40     *
41     * @var string
42     */
43    public static $requires_user_connection = false;
44
45    /**
46     * Get the product name
47     *
48     * @return string
49     */
50    public static function get_name() {
51        return 'Extras';
52    }
53
54    /**
55     * Get the product title
56     *
57     * @return string
58     */
59    public static function get_title() {
60        return 'Jetpack Extras';
61    }
62
63    /**
64     * Get the internationalized product description
65     *
66     * @return string
67     */
68    public static function get_description() {
69        return __( 'Basic tools for a successful site', 'jetpack-my-jetpack' );
70    }
71
72    /**
73     * Get the internationalized product long description
74     *
75     * @return string
76     */
77    public static function get_long_description() {
78        return __( "Secure and speed up your site for free with Jetpack's powerful WordPress tools.", 'jetpack-my-jetpack' );
79    }
80
81    /**
82     * Get the internationalized features list
83     *
84     * @return array Boost features list
85     */
86    public static function get_features() {
87        return array(
88            __( 'Speed up your site with optimized images', 'jetpack-my-jetpack' ),
89            __( 'Protect your site against bot attacks', 'jetpack-my-jetpack' ),
90            __( 'Get notifications if your site goes offline', 'jetpack-my-jetpack' ),
91            __( 'Enhance your site with dozens of other features', 'jetpack-my-jetpack' ),
92        );
93    }
94
95    /**
96     * Get the product princing details
97     *
98     * @return array Pricing details
99     */
100    public static function get_pricing_for_ui() {
101        return array(
102            'available' => true,
103            'is_free'   => true,
104        );
105    }
106
107    /**
108     * Checks whether the Product is active.
109     * If Jetpack plugin is active, then Extras will be inactive.
110     *
111     * @return boolean
112     */
113    public static function is_active() {
114        return static::is_jetpack_plugin_active();
115    }
116
117    /**
118     * Checks whether the plugin is installed
119     * If Jetpack plugin is installed, then Extras will be inactive.
120     *
121     * @return boolean
122     */
123    public static function is_plugin_installed() {
124        return static::is_jetpack_plugin_installed();
125    }
126
127    /**
128     * Get the URL where the user manages the product
129     *
130     * @return ?string
131     */
132    public static function get_manage_url() {
133        return admin_url( 'admin.php?page=jetpack' );
134    }
135
136    /**
137     * Activates the Jetpack plugin
138     *
139     * @return null|WP_Error Null on success, WP_Error on invalid file.
140     */
141    public static function activate_plugin() {
142        return activate_plugin( static::get_installed_plugin_filename( 'jetpack' ) );
143    }
144}