Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
52.94% |
9 / 17 |
|
50.00% |
5 / 10 |
CRAP | |
0.00% |
0 / 1 |
| Site_Accelerator | |
53.33% |
8 / 15 |
|
50.00% |
5 / 10 |
23.30 | |
0.00% |
0 / 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% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| get_pricing_for_ui | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| is_active | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| is_plugin_installed | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| get_manage_url | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| activate_plugin | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Feature: Site Accelerator |
| 4 | * |
| 5 | * @package my-jetpack |
| 6 | */ |
| 7 | |
| 8 | namespace Automattic\Jetpack\My_Jetpack\Products; |
| 9 | |
| 10 | use Automattic\Jetpack\My_Jetpack\Module_Product; |
| 11 | use WP_Error; |
| 12 | |
| 13 | if ( ! defined( 'ABSPATH' ) ) { |
| 14 | exit( 0 ); |
| 15 | } |
| 16 | |
| 17 | /** |
| 18 | * Class responsible for handling the Site Accelerator module. |
| 19 | */ |
| 20 | class Site_Accelerator extends Module_Product { |
| 21 | |
| 22 | /** |
| 23 | * The product slug |
| 24 | * |
| 25 | * @var string |
| 26 | */ |
| 27 | public static $slug = 'site-accelerator'; |
| 28 | |
| 29 | /** |
| 30 | * The category of the product |
| 31 | * |
| 32 | * @var string |
| 33 | */ |
| 34 | public static $category = 'performance'; |
| 35 | |
| 36 | /** |
| 37 | * The slug of the plugin associated with this product. |
| 38 | * Site Accelerator is a feature available as part of the Jetpack plugin. |
| 39 | * |
| 40 | * @var string |
| 41 | */ |
| 42 | public static $plugin_slug = self::JETPACK_PLUGIN_SLUG; |
| 43 | |
| 44 | /** |
| 45 | * The Plugin file associated with stats |
| 46 | * |
| 47 | * @var string|null |
| 48 | */ |
| 49 | public static $plugin_filename = self::JETPACK_PLUGIN_FILENAME; |
| 50 | |
| 51 | /** |
| 52 | * The Jetpack module name associated with this product |
| 53 | * |
| 54 | * @var string|null |
| 55 | */ |
| 56 | public static $module_name = 'site-accelerator'; |
| 57 | |
| 58 | /** |
| 59 | * Whether this module is a Jetpack feature |
| 60 | * |
| 61 | * @var boolean |
| 62 | */ |
| 63 | public static $is_feature = true; |
| 64 | |
| 65 | /** |
| 66 | * Whether this product requires a user connection |
| 67 | * |
| 68 | * @var boolean |
| 69 | */ |
| 70 | public static $requires_user_connection = false; |
| 71 | |
| 72 | /** |
| 73 | * Whether this product has a standalone plugin |
| 74 | * |
| 75 | * @var bool |
| 76 | */ |
| 77 | public static $has_standalone_plugin = false; |
| 78 | |
| 79 | /** |
| 80 | * Whether this product has a free offering |
| 81 | * |
| 82 | * @var bool |
| 83 | */ |
| 84 | public static $has_free_offering = true; |
| 85 | |
| 86 | /** |
| 87 | * Whether the product requires a plan to run |
| 88 | * The plan could be paid or free |
| 89 | * |
| 90 | * @var bool |
| 91 | */ |
| 92 | public static $requires_plan = false; |
| 93 | |
| 94 | /** |
| 95 | * Get the product name |
| 96 | * |
| 97 | * @return string |
| 98 | */ |
| 99 | public static function get_name() { |
| 100 | return 'Site Accelerator'; |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * Get the product title |
| 105 | * |
| 106 | * @return string |
| 107 | */ |
| 108 | public static function get_title() { |
| 109 | return 'Site Accelerator'; |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * Get the internationalized product description |
| 114 | * |
| 115 | * @return string |
| 116 | */ |
| 117 | public static function get_description() { |
| 118 | return __( 'Draw your readers from one post to another', 'jetpack-my-jetpack' ); |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * Get the internationalized product long description |
| 123 | * |
| 124 | * @return string |
| 125 | */ |
| 126 | public static function get_long_description() { |
| 127 | return __( 'Draw your readers from one post to another, increasing overall traffic on your site', 'jetpack-my-jetpack' ); |
| 128 | } |
| 129 | |
| 130 | /** |
| 131 | * Get the internationalized feature list |
| 132 | * |
| 133 | * @return array Site Accelerattor features list |
| 134 | */ |
| 135 | public static function get_features() { |
| 136 | return array(); |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * Get the product princing details |
| 141 | * |
| 142 | * @return array Pricing details |
| 143 | */ |
| 144 | public static function get_pricing_for_ui() { |
| 145 | return array( |
| 146 | 'available' => true, |
| 147 | 'is_free' => true, |
| 148 | ); |
| 149 | } |
| 150 | |
| 151 | /** |
| 152 | * Checks whether the Product is active. |
| 153 | * |
| 154 | * @return boolean |
| 155 | */ |
| 156 | public static function is_active() { |
| 157 | return static::is_jetpack_plugin_active(); |
| 158 | } |
| 159 | |
| 160 | /** |
| 161 | * Checks whether the plugin is installed |
| 162 | * |
| 163 | * @return boolean |
| 164 | */ |
| 165 | public static function is_plugin_installed() { |
| 166 | return static::is_jetpack_plugin_installed(); |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * Get the URL where the user manages the product |
| 171 | * |
| 172 | * @return ?string |
| 173 | */ |
| 174 | public static function get_manage_url() { |
| 175 | return admin_url( 'admin.php?page=jetpack#/settings?term=site%20accelerator' ); |
| 176 | } |
| 177 | |
| 178 | /** |
| 179 | * Activates the Jetpack plugin |
| 180 | * |
| 181 | * @return null|WP_Error Null on success, WP_Error on invalid file. |
| 182 | */ |
| 183 | public static function activate_plugin(): ?WP_Error { |
| 184 | $plugin_filename = static::get_installed_plugin_filename( self::JETPACK_PLUGIN_SLUG ); |
| 185 | |
| 186 | if ( $plugin_filename ) { |
| 187 | return activate_plugin( $plugin_filename ); |
| 188 | } |
| 189 | } |
| 190 | } |