DefaultFreeExtensions.php
4 weeks ago
EvaluateExtension.php
1 year ago
Init.php
2 years ago
ProcessCoreProfilerPluginInstallOptions.php
1 year ago
RemoteFreeExtensionsDataSourcePoller.php
1 year ago
DefaultFreeExtensions.php
721 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Gets a list of fallback methods if remote fetching is disabled. |
| 4 | */ |
| 5 | |
| 6 | declare( strict_types=1 ); |
| 7 | |
| 8 | namespace Automattic\WooCommerce\Internal\Admin\RemoteFreeExtensions; |
| 9 | |
| 10 | use Automattic\WooCommerce\Admin\Features\PaymentGatewaySuggestions\DefaultPaymentGateways; |
| 11 | |
| 12 | defined( 'ABSPATH' ) || exit; |
| 13 | |
| 14 | |
| 15 | /** |
| 16 | * Default Free Extensions |
| 17 | */ |
| 18 | class DefaultFreeExtensions { |
| 19 | |
| 20 | /** |
| 21 | * Get Woo logo path. |
| 22 | * |
| 23 | * @return string |
| 24 | */ |
| 25 | private static function get_woo_logo() { |
| 26 | return plugins_url( '/assets/images/core-profiler/logo-woo.svg', WC_PLUGIN_FILE ); |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * Get default specs. |
| 31 | * |
| 32 | * @return array Default specs. |
| 33 | */ |
| 34 | public static function get_all() { |
| 35 | $bundles = array( |
| 36 | array( |
| 37 | 'key' => 'obw/basics', |
| 38 | 'title' => __( 'Get the basics', 'woocommerce' ), |
| 39 | 'plugins' => array( |
| 40 | self::get_plugin( 'woocommerce-payments' ), |
| 41 | self::get_plugin( 'woocommerce-shipping' ), |
| 42 | self::get_plugin( 'woocommerce-services:tax' ), |
| 43 | self::get_plugin( 'jetpack' ), |
| 44 | ), |
| 45 | ), |
| 46 | array( |
| 47 | 'key' => 'obw/grow', |
| 48 | 'title' => __( 'Grow your store', 'woocommerce' ), |
| 49 | 'plugins' => array( |
| 50 | self::get_plugin( 'mailpoet' ), |
| 51 | self::get_plugin( 'google-listings-and-ads' ), |
| 52 | self::get_plugin( 'pinterest-for-woocommerce' ), |
| 53 | self::get_plugin( 'facebook-for-woocommerce' ), |
| 54 | ), |
| 55 | ), |
| 56 | array( |
| 57 | 'key' => 'task-list/reach', |
| 58 | 'title' => __( 'Reach out to customers', 'woocommerce' ), |
| 59 | 'plugins' => array( |
| 60 | self::get_plugin( 'mailpoet:alt' ), |
| 61 | // IMPORTANT: Klaviyo needs to be above Mailchimp as per partnership agreement. |
| 62 | // P2 for context: pdibGW-3XM-p2. |
| 63 | self::get_plugin( 'klaviyo:alt' ), |
| 64 | self::get_plugin( 'mailchimp-for-woocommerce' ), |
| 65 | ), |
| 66 | ), |
| 67 | array( |
| 68 | 'key' => 'task-list/grow', |
| 69 | 'title' => __( 'Grow your store', 'woocommerce' ), |
| 70 | 'plugins' => array( |
| 71 | self::get_plugin( 'google-listings-and-ads:alt' ), |
| 72 | self::get_plugin( 'tiktok-for-business' ), |
| 73 | self::get_plugin( 'pinterest-for-woocommerce:alt' ), |
| 74 | self::get_plugin( 'facebook-for-woocommerce:alt' ), |
| 75 | ), |
| 76 | ), |
| 77 | array( |
| 78 | 'key' => 'obw/core-profiler', |
| 79 | 'title' => __( 'Grow your store', 'woocommerce' ), |
| 80 | 'plugins' => self::with_core_profiler_fields( |
| 81 | array( |
| 82 | self::get_plugin( 'woocommerce-payments' ), |
| 83 | self::get_plugin( 'woocommerce-shipping' ), |
| 84 | self::get_plugin( 'woocommerce-shipstation-integration' ), |
| 85 | self::get_plugin( 'packlink-pro-shipping' ), |
| 86 | self::get_plugin( 'jetpack' ), |
| 87 | self::get_plugin( 'pinterest-for-woocommerce' ), |
| 88 | self::get_plugin( 'mailpoet' ), |
| 89 | self::get_plugin( 'klaviyo' ), |
| 90 | self::get_plugin( 'google-listings-and-ads' ), |
| 91 | self::get_plugin( 'woocommerce-services:tax' ), |
| 92 | self::get_plugin( 'tiktok-for-business' ), |
| 93 | self::get_plugin( 'snapchat-for-woocommerce' ), |
| 94 | self::get_plugin( 'reddit-for-woocommerce' ), |
| 95 | ) |
| 96 | ), |
| 97 | ), |
| 98 | ); |
| 99 | |
| 100 | $bundles = wp_json_encode( $bundles ); |
| 101 | return json_decode( $bundles ); |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * Get the plugin arguments by slug. |
| 106 | * |
| 107 | * @param string $slug Slug. |
| 108 | * @return array |
| 109 | */ |
| 110 | public static function get_plugin( $slug ) { |
| 111 | $plugins = array( |
| 112 | 'google-listings-and-ads' => array( |
| 113 | 'min_php_version' => '7.4', |
| 114 | 'name' => __( 'Google for WooCommerce', 'woocommerce' ), |
| 115 | 'description' => sprintf( |
| 116 | /* translators: 1: opening product link tag. 2: closing link tag */ |
| 117 | __( 'Drive sales with %1$sGoogle for WooCommerce%2$s', 'woocommerce' ), |
| 118 | '<a href="https://woocommerce.com/products/google-listings-and-ads" target="_blank">', |
| 119 | '</a>' |
| 120 | ), |
| 121 | 'image_url' => plugins_url( '/assets/images/onboarding/google.svg', WC_PLUGIN_FILE ), |
| 122 | 'manage_url' => 'admin.php?page=wc-admin&path=%2Fgoogle%2Fstart', |
| 123 | 'is_built_by_wc' => true, |
| 124 | 'is_visible' => array( |
| 125 | array( |
| 126 | 'type' => 'not', |
| 127 | 'operand' => array( |
| 128 | array( |
| 129 | 'type' => 'plugins_activated', |
| 130 | 'plugins' => array( 'google-listings-and-ads' ), |
| 131 | ), |
| 132 | ), |
| 133 | ), |
| 134 | ), |
| 135 | ), |
| 136 | 'google-listings-and-ads:alt' => array( |
| 137 | 'name' => __( 'Google for WooCommerce', 'woocommerce' ), |
| 138 | 'description' => __( 'Reach more shoppers and drive sales for your store. Integrate with Google to list your products for free and launch paid ad campaigns.', 'woocommerce' ), |
| 139 | 'image_url' => plugins_url( '/assets/images/onboarding/google.svg', WC_PLUGIN_FILE ), |
| 140 | 'manage_url' => 'admin.php?page=wc-admin&path=%2Fgoogle%2Fstart', |
| 141 | 'is_built_by_wc' => true, |
| 142 | ), |
| 143 | 'facebook-for-woocommerce' => array( |
| 144 | 'name' => __( 'Facebook for WooCommerce', 'woocommerce' ), |
| 145 | 'description' => __( 'List products and create ads on Facebook and Instagram with <a href="https://woocommerce.com/products/facebook/">Facebook for WooCommerce</a>', 'woocommerce' ), |
| 146 | 'image_url' => plugins_url( '/assets/images/onboarding/facebook.png', WC_PLUGIN_FILE ), |
| 147 | 'manage_url' => 'admin.php?page=wc-facebook', |
| 148 | 'is_visible' => false, |
| 149 | 'is_built_by_wc' => false, |
| 150 | ), |
| 151 | 'facebook-for-woocommerce:alt' => array( |
| 152 | 'name' => __( 'Facebook for WooCommerce', 'woocommerce' ), |
| 153 | 'description' => __( 'List products and create ads on Facebook and Instagram.', 'woocommerce' ), |
| 154 | 'image_url' => plugins_url( '/assets/images/onboarding/facebook.png', WC_PLUGIN_FILE ), |
| 155 | 'manage_url' => 'admin.php?page=wc-facebook', |
| 156 | 'is_visible' => false, |
| 157 | 'is_built_by_wc' => false, |
| 158 | ), |
| 159 | 'pinterest-for-woocommerce' => array( |
| 160 | 'name' => __( 'Pinterest for WooCommerce', 'woocommerce' ), |
| 161 | 'description' => __( 'Get your products in front of Pinners searching for ideas and things to buy.', 'woocommerce' ), |
| 162 | 'image_url' => plugins_url( '/assets/images/onboarding/pinterest.png', WC_PLUGIN_FILE ), |
| 163 | 'manage_url' => 'admin.php?page=wc-admin&path=%2Fpinterest%2Flanding', |
| 164 | 'is_visible' => true, |
| 165 | 'is_built_by_wc' => true, |
| 166 | 'min_php_version' => '7.3', |
| 167 | ), |
| 168 | 'pinterest-for-woocommerce:alt' => array( |
| 169 | 'name' => __( 'Pinterest for WooCommerce', 'woocommerce' ), |
| 170 | 'description' => __( 'Get your products in front of Pinterest users searching for ideas and things to buy. Get started with Pinterest and make your entire product catalog browsable.', 'woocommerce' ), |
| 171 | 'image_url' => plugins_url( '/assets/images/onboarding/pinterest.png', WC_PLUGIN_FILE ), |
| 172 | 'manage_url' => 'admin.php?page=wc-admin&path=%2Fpinterest%2Flanding', |
| 173 | 'is_built_by_wc' => true, |
| 174 | ), |
| 175 | 'mailpoet' => array( |
| 176 | 'name' => __( 'MailPoet', 'woocommerce' ), |
| 177 | 'description' => __( 'Create and send purchase follow-up emails, newsletters, and promotional campaigns straight from your dashboard.', 'woocommerce' ), |
| 178 | 'image_url' => plugins_url( '/assets/images/onboarding/mailpoet.png', WC_PLUGIN_FILE ), |
| 179 | 'manage_url' => 'admin.php?page=mailpoet-newsletters', |
| 180 | 'is_visible' => array( |
| 181 | array( |
| 182 | 'type' => 'option', |
| 183 | 'option_name' => 'woocommerce_remote_variant_assignment', |
| 184 | 'value' => array( 1, 84 ), // 70% segment with klaviyo |
| 185 | 'default' => false, |
| 186 | 'operation' => 'range', |
| 187 | ), |
| 188 | ), |
| 189 | 'is_built_by_wc' => true, |
| 190 | ), |
| 191 | 'kliken-ads-pixel-for-meta' => array( |
| 192 | 'name' => __( 'Meta Ads & Pixel for WooCommerce', 'woocommerce' ), |
| 193 | 'description' => __( 'Sync your store catalog, set up pixel tracking, and run targeted ad campaigns.', 'woocommerce' ), |
| 194 | 'image_url' => plugins_url( '/assets/images/onboarding/kliken.svg', WC_PLUGIN_FILE ), |
| 195 | 'manage_url' => 'admin.php?page=kliken-ads-pixel-for-meta', |
| 196 | 'is_visible' => false, |
| 197 | ), |
| 198 | 'mailchimp-for-woocommerce' => array( |
| 199 | 'name' => __( 'Mailchimp', 'woocommerce' ), |
| 200 | 'description' => __( 'Send targeted campaigns, recover abandoned carts and much more with Mailchimp.', 'woocommerce' ), |
| 201 | 'image_url' => plugins_url( '/assets/images/onboarding/mailchimp-for-woocommerce.png', WC_PLUGIN_FILE ), |
| 202 | 'manage_url' => 'admin.php?page=mailchimp-woocommerce', |
| 203 | 'is_built_by_wc' => false, |
| 204 | ), |
| 205 | 'klaviyo' => array( |
| 206 | 'name' => __( 'Klaviyo', 'woocommerce' ), |
| 207 | 'description' => __( 'Grow and retain customers with email, SMS, automations, and a consolidated view of customer interactions.', 'woocommerce' ), |
| 208 | 'image_url' => plugins_url( '/assets/images/onboarding/klaviyo.png', WC_PLUGIN_FILE ), |
| 209 | 'manage_url' => 'admin.php?page=klaviyo_settings', |
| 210 | 'is_visible' => array( |
| 211 | array( |
| 212 | 'type' => 'option', |
| 213 | 'option_name' => 'woocommerce_remote_variant_assignment', |
| 214 | 'value' => array( 85, 120 ), // 30% segment with mailpoet |
| 215 | 'default' => false, |
| 216 | 'operation' => 'range', |
| 217 | ), |
| 218 | ), |
| 219 | 'is_built_by_wc' => false, |
| 220 | ), |
| 221 | 'klaviyo:alt' => array( |
| 222 | 'name' => __( 'Klaviyo', 'woocommerce' ), |
| 223 | 'description' => __( 'Grow and retain customers with intelligent, impactful email and SMS marketing automation and a consolidated view of customer interactions.', 'woocommerce' ), |
| 224 | 'image_url' => plugins_url( '/assets/images/onboarding/klaviyo.png', WC_PLUGIN_FILE ), |
| 225 | 'manage_url' => 'admin.php?page=klaviyo_settings', |
| 226 | 'is_built_by_wc' => false, |
| 227 | ), |
| 228 | 'woocommerce-payments' => array( |
| 229 | 'name' => __( 'WooPayments', 'woocommerce' ), |
| 230 | 'image_url' => plugins_url( '/assets/images/onboarding/wcpay.svg', WC_PLUGIN_FILE ), |
| 231 | 'description' => sprintf( |
| 232 | /* translators: 1: opening product link tag. 2: closing link tag */ |
| 233 | __( 'Accept credit cards and other popular payment methods with %1$sWooPayments%2$s', 'woocommerce' ), |
| 234 | '<a href="https://woocommerce.com/products/woocommerce-payments" target="_blank">', |
| 235 | '</a>' |
| 236 | ), |
| 237 | 'is_visible' => array( |
| 238 | array( |
| 239 | 'type' => 'base_location_country', |
| 240 | 'value' => array( |
| 241 | 'US', |
| 242 | 'PR', |
| 243 | 'AU', |
| 244 | 'CA', |
| 245 | 'DE', |
| 246 | 'ES', |
| 247 | 'FR', |
| 248 | 'GB', |
| 249 | 'IE', |
| 250 | 'IT', |
| 251 | 'NZ', |
| 252 | 'AT', |
| 253 | 'BE', |
| 254 | 'NL', |
| 255 | 'PL', |
| 256 | 'PT', |
| 257 | 'CH', |
| 258 | 'HK', |
| 259 | 'SG', |
| 260 | 'CY', |
| 261 | 'DK', |
| 262 | 'EE', |
| 263 | 'FI', |
| 264 | 'GR', |
| 265 | 'LU', |
| 266 | 'LT', |
| 267 | 'LV', |
| 268 | 'NO', |
| 269 | 'MT', |
| 270 | 'SI', |
| 271 | 'SK', |
| 272 | 'BG', |
| 273 | 'CZ', |
| 274 | 'HR', |
| 275 | 'HU', |
| 276 | 'RO', |
| 277 | 'SE', |
| 278 | 'JP', |
| 279 | 'AE', |
| 280 | ), |
| 281 | 'operation' => 'in', |
| 282 | ), |
| 283 | DefaultPaymentGateways::get_rules_for_cbd( false ), |
| 284 | ), |
| 285 | 'is_built_by_wc' => true, |
| 286 | 'min_wp_version' => '5.9', |
| 287 | ), |
| 288 | 'woocommerce-shipping' => array( |
| 289 | 'name' => __( 'WooCommerce Shipping', 'woocommerce' ), |
| 290 | 'image_url' => self::get_woo_logo(), |
| 291 | 'description' => sprintf( |
| 292 | /* translators: 1: opening product link tag. 2: closing link tag */ |
| 293 | __( 'Print shipping labels with %1$sWooCommerce Shipping%2$s', 'woocommerce' ), |
| 294 | '<a href="https://woocommerce.com/products/shipping" target="_blank">', |
| 295 | '</a>' |
| 296 | ), |
| 297 | 'is_visible' => array( |
| 298 | array( |
| 299 | 'type' => 'base_location_country', |
| 300 | 'value' => 'US', |
| 301 | 'operation' => '=', |
| 302 | ), |
| 303 | array( |
| 304 | 'type' => 'or', |
| 305 | 'operands' => array( |
| 306 | array( |
| 307 | array( |
| 308 | 'type' => 'option', |
| 309 | 'transformers' => array( |
| 310 | array( |
| 311 | 'use' => 'dot_notation', |
| 312 | 'arguments' => array( |
| 313 | 'path' => 'product_types', |
| 314 | ), |
| 315 | ), |
| 316 | array( |
| 317 | 'use' => 'count', |
| 318 | ), |
| 319 | ), |
| 320 | 'option_name' => 'woocommerce_onboarding_profile', |
| 321 | 'value' => 1, |
| 322 | 'default' => array(), |
| 323 | 'operation' => '!=', |
| 324 | ), |
| 325 | ), |
| 326 | array( |
| 327 | array( |
| 328 | 'type' => 'option', |
| 329 | 'transformers' => array( |
| 330 | array( |
| 331 | 'use' => 'dot_notation', |
| 332 | 'arguments' => array( |
| 333 | 'path' => 'product_types.0', |
| 334 | ), |
| 335 | ), |
| 336 | ), |
| 337 | 'option_name' => 'woocommerce_onboarding_profile', |
| 338 | 'value' => 'downloads', |
| 339 | 'default' => '', |
| 340 | 'operation' => '!=', |
| 341 | ), |
| 342 | ), |
| 343 | ), |
| 344 | ), |
| 345 | ), |
| 346 | 'is_built_by_wc' => true, |
| 347 | ), |
| 348 | 'woocommerce-services:tax' => array( |
| 349 | 'name' => __( 'WooCommerce Tax', 'woocommerce' ), |
| 350 | 'image_url' => self::get_woo_logo(), |
| 351 | 'description' => sprintf( |
| 352 | /* translators: 1: opening product link tag. 2: closing link tag */ |
| 353 | __( 'Get automated sales tax with %1$sWooCommerce Tax%2$s', 'woocommerce' ), |
| 354 | '<a href="https://woocommerce.com/products/tax" target="_blank">', |
| 355 | '</a>' |
| 356 | ), |
| 357 | 'is_visible' => array( |
| 358 | self::get_rules_for_wcservices_tax_countries(), |
| 359 | ), |
| 360 | 'is_built_by_wc' => true, |
| 361 | ), |
| 362 | 'jetpack' => array( |
| 363 | 'name' => __( 'Jetpack', 'woocommerce' ), |
| 364 | 'image_url' => plugins_url( '/assets/images/onboarding/jetpack.svg', WC_PLUGIN_FILE ), |
| 365 | 'description' => sprintf( |
| 366 | /* translators: 1: opening product link tag. 2: closing link tag */ |
| 367 | __( 'Enhance speed and security with %1$sJetpack%2$s', 'woocommerce' ), |
| 368 | '<a href="https://woocommerce.com/products/jetpack" target="_blank">', |
| 369 | '</a>' |
| 370 | ), |
| 371 | 'is_visible' => array( |
| 372 | array( |
| 373 | 'type' => 'not', |
| 374 | 'operand' => array( |
| 375 | array( |
| 376 | 'type' => 'plugins_activated', |
| 377 | 'plugins' => array( 'jetpack' ), |
| 378 | ), |
| 379 | ), |
| 380 | ), |
| 381 | ), |
| 382 | 'is_built_by_wc' => false, |
| 383 | 'min_wp_version' => '6.0', |
| 384 | ), |
| 385 | 'mailpoet:alt' => array( |
| 386 | 'name' => __( 'MailPoet', 'woocommerce' ), |
| 387 | 'description' => __( 'Create and send purchase follow-up emails, newsletters, and promotional campaigns straight from your dashboard.', 'woocommerce' ), |
| 388 | 'image_url' => plugins_url( '/assets/images/onboarding/mailpoet.png', WC_PLUGIN_FILE ), |
| 389 | 'manage_url' => 'admin.php?page=mailpoet-newsletters', |
| 390 | 'is_built_by_wc' => true, |
| 391 | ), |
| 392 | 'tiktok-for-business' => array( |
| 393 | 'name' => __( 'TikTok for WooCommerce', 'woocommerce' ), |
| 394 | 'image_url' => plugins_url( '/assets/images/onboarding/tiktok.svg', WC_PLUGIN_FILE ), |
| 395 | 'description' => |
| 396 | __( 'Grow your online sales by promoting your products on TikTok to over one billion monthly active users around the world.', 'woocommerce' ), |
| 397 | 'manage_url' => 'admin.php?page=tiktok', |
| 398 | 'is_visible' => array( |
| 399 | array( |
| 400 | 'type' => 'base_location_country', |
| 401 | 'value' => array( |
| 402 | 'US', |
| 403 | 'CA', |
| 404 | 'MX', |
| 405 | 'AT', |
| 406 | 'BE', |
| 407 | 'CZ', |
| 408 | 'DK', |
| 409 | 'FI', |
| 410 | 'FR', |
| 411 | 'DE', |
| 412 | 'GR', |
| 413 | 'HU', |
| 414 | 'IE', |
| 415 | 'IT', |
| 416 | 'NL', |
| 417 | 'PL', |
| 418 | 'PT', |
| 419 | 'RO', |
| 420 | 'ES', |
| 421 | 'SE', |
| 422 | 'GB', |
| 423 | 'CH', |
| 424 | 'NO', |
| 425 | 'AU', |
| 426 | 'NZ', |
| 427 | 'SG', |
| 428 | 'MY', |
| 429 | 'PH', |
| 430 | 'ID', |
| 431 | 'VN', |
| 432 | 'TH', |
| 433 | 'KR', |
| 434 | 'IL', |
| 435 | 'AE', |
| 436 | 'RU', |
| 437 | 'UA', |
| 438 | 'TR', |
| 439 | 'SA', |
| 440 | 'BR', |
| 441 | 'JP', |
| 442 | ), |
| 443 | 'operation' => 'in', |
| 444 | ), |
| 445 | ), |
| 446 | 'is_built_by_wc' => false, |
| 447 | ), |
| 448 | 'tiktok-for-business:alt' => array( |
| 449 | 'name' => __( 'TikTok for WooCommerce', 'woocommerce' ), |
| 450 | 'image_url' => plugins_url( '/assets/images/onboarding/tiktok.svg', WC_PLUGIN_FILE ), |
| 451 | 'description' => sprintf( |
| 452 | /* translators: 1: opening product link tag. 2: closing link tag */ |
| 453 | __( 'Create ad campaigns and reach one billion global users with %1$sTikTok for WooCommerce%2$s', 'woocommerce' ), |
| 454 | '<a href="https://woocommerce.com/products/tiktok-for-woocommerce" target="_blank">', |
| 455 | '</a>' |
| 456 | ), |
| 457 | 'manage_url' => 'admin.php?page=tiktok', |
| 458 | 'is_built_by_wc' => false, |
| 459 | 'is_visible' => false, |
| 460 | ), |
| 461 | 'snapchat-for-woocommerce' => array( |
| 462 | 'name' => __( 'Snapchat Ads', 'woocommerce' ), |
| 463 | 'description' => __( 'Reach an untapped audience on Snapchat and drive more sales.', 'woocommerce' ), |
| 464 | 'image_url' => plugins_url( '/assets/images/core-profiler/logo-snapchat.svg', WC_PLUGIN_FILE ), |
| 465 | 'manage_url' => 'admin.php?page=wc-admin&path=%2Fsnapchat%2Fstart', |
| 466 | 'is_built_by_wc' => true, |
| 467 | 'is_visible' => true, |
| 468 | ), |
| 469 | 'reddit-for-woocommerce' => array( |
| 470 | 'name' => __( 'Reddit Ads', 'woocommerce' ), |
| 471 | 'description' => __( 'Seamlessly sync your products and start Reddit Ads.', 'woocommerce' ), |
| 472 | 'image_url' => plugins_url( '/assets/images/core-profiler/logo-reddit.svg', WC_PLUGIN_FILE ), |
| 473 | 'manage_url' => 'admin.php?page=wc-admin&path=%2Freddit%2Fsetup', |
| 474 | 'is_built_by_wc' => true, |
| 475 | 'is_visible' => true, |
| 476 | ), |
| 477 | 'woocommerce-shipstation-integration' => array( |
| 478 | 'name' => __( 'ShipStation', 'woocommerce' ), |
| 479 | 'image_url' => plugins_url( '/assets/images/core-profiler/logo-shipstation.svg', WC_PLUGIN_FILE ), |
| 480 | 'manage_url' => 'admin.php?page=shipstation', |
| 481 | 'is_visible' => array( |
| 482 | array( |
| 483 | 'type' => 'base_location_country', |
| 484 | 'value' => array( 'CA', 'GB', 'AU', 'NZ' ), |
| 485 | 'operation' => 'in', |
| 486 | ), |
| 487 | ), |
| 488 | 'is_built_by_wc' => true, |
| 489 | ), |
| 490 | 'packlink-pro-shipping' => array( |
| 491 | 'name' => __( 'Packlink', 'woocommerce' ), |
| 492 | 'image_url' => plugins_url( '/assets/images/core-profiler/logo-packlink.svg', WC_PLUGIN_FILE ), |
| 493 | 'manage_url' => 'admin.php?page=packlink-pro-shipping', |
| 494 | 'is_visible' => array( |
| 495 | array( |
| 496 | 'type' => 'base_location_country', |
| 497 | 'value' => array( 'FR', 'ES', 'IT', 'DE', 'NL', 'AT', 'BE', 'IE', 'PT' ), |
| 498 | 'operation' => 'in', |
| 499 | ), |
| 500 | ), |
| 501 | 'is_built_by_wc' => false, |
| 502 | ), |
| 503 | ); |
| 504 | |
| 505 | $plugin = $plugins[ $slug ]; |
| 506 | $plugin['key'] = $slug; |
| 507 | |
| 508 | return $plugin; |
| 509 | } |
| 510 | |
| 511 | /** |
| 512 | * Decorate plugin data with core profiler fields. |
| 513 | * |
| 514 | * - Updated description for the core-profiler. |
| 515 | * - Adds learn_more_link and label. |
| 516 | * - Adds install_priority, which is used to sort the plugins. The value is determined by the plugin size. Lower = smaller. |
| 517 | * |
| 518 | * @param array $plugins Array of plugins. |
| 519 | * |
| 520 | * @return array |
| 521 | */ |
| 522 | public static function with_core_profiler_fields( array $plugins ) { |
| 523 | $_plugins = array( |
| 524 | 'woocommerce-payments' => array( |
| 525 | /* translators: %s: Payment provider name. */ |
| 526 | 'label' => sprintf( __( 'Get paid with %s', 'woocommerce' ), 'WooPayments' ), |
| 527 | 'image_url' => self::get_woo_logo(), |
| 528 | 'description' => __( "Securely accept payments and manage payment activity straight from your store's dashboard", 'woocommerce' ), |
| 529 | 'learn_more_link' => 'https://woocommerce.com/products/woocommerce-payments?utm_source=storeprofiler&utm_medium=product&utm_campaign=freefeatures', |
| 530 | 'install_priority' => 5, |
| 531 | 'requires_jpc' => true, |
| 532 | ), |
| 533 | 'woocommerce-shipping' => array( |
| 534 | 'label' => __( 'Save on shipping with WooCommerce Shipping', 'woocommerce' ), |
| 535 | 'image_url' => self::get_woo_logo(), |
| 536 | 'description' => __( 'Print discounted USPS, UPS, and DHL labels', 'woocommerce' ), |
| 537 | 'learn_more_link' => 'https://woocommerce.com/woocommerce-shipping?utm_source=storeprofiler&utm_medium=product&utm_campaign=freefeatures', |
| 538 | 'install_priority' => 3, |
| 539 | ), |
| 540 | 'jetpack' => array( |
| 541 | 'label' => __( 'Protect your store and your shoppers with Jetpack', 'woocommerce' ), |
| 542 | 'image_url' => plugins_url( '/assets/images/core-profiler/logo-jetpack.svg', WC_PLUGIN_FILE ), |
| 543 | 'description' => __( 'Keep your store online with full security and backups', 'woocommerce' ), |
| 544 | 'learn_more_link' => 'https://woocommerce.com/products/jetpack?utm_source=storeprofiler&utm_medium=product&utm_campaign=freefeatures', |
| 545 | 'install_priority' => 8, |
| 546 | 'requires_jpc' => true, |
| 547 | ), |
| 548 | 'pinterest-for-woocommerce' => array( |
| 549 | 'label' => __( 'Showcase your products with Pinterest', 'woocommerce' ), |
| 550 | 'image_url' => plugins_url( '/assets/images/core-profiler/logo-pinterest.svg', WC_PLUGIN_FILE ), |
| 551 | 'description' => __( 'Get your products in front of a highly engaged audience.', 'woocommerce' ), |
| 552 | 'learn_more_link' => 'https://woocommerce.com/products/pinterest-for-woocommerce?utm_source=storeprofiler&utm_medium=product&utm_campaign=freefeatures', |
| 553 | 'install_priority' => 2, |
| 554 | ), |
| 555 | 'kliken-ads-pixel-for-meta' => array( |
| 556 | 'label' => __( 'Grow your business with Facebook and Instagram', 'woocommerce' ), |
| 557 | 'image_url' => plugins_url( '/assets/images/core-profiler/logo-kliken.svg', WC_PLUGIN_FILE ), |
| 558 | 'description' => __( 'Sync your store catalog, set up pixel tracking, and run targeted ad campaigns.', 'woocommerce' ), |
| 559 | 'learn_more_link' => 'https://woocommerce.com/products/meta-ads-and-pixel?utm_source=storeprofiler&utm_medium=product&utm_campaign=freefeatures', |
| 560 | 'install_priority' => 2, |
| 561 | ), |
| 562 | 'mailpoet' => array( |
| 563 | 'label' => __( 'Reach your customers with MailPoet', 'woocommerce' ), |
| 564 | 'image_url' => plugins_url( '/assets/images/core-profiler/logo-mailpoet.svg', WC_PLUGIN_FILE ), |
| 565 | 'description' => __( 'Send purchase follow-up emails, newsletters, and promotional campaigns.', 'woocommerce' ), |
| 566 | 'learn_more_link' => 'https://woocommerce.com/products/mailpoet?utm_source=storeprofiler&utm_medium=product&utm_campaign=freefeatures', |
| 567 | 'install_priority' => 7, |
| 568 | ), |
| 569 | 'klaviyo' => array( |
| 570 | 'label' => __( 'Klaviyo', 'woocommerce' ), |
| 571 | 'image_url' => plugins_url( '/assets/images/onboarding/klaviyo.png', WC_PLUGIN_FILE ), |
| 572 | 'description' => __( 'Grow and retain customers with email, SMS, automations, and a consolidated view of customer interactions.', 'woocommerce' ), |
| 573 | 'learn_more_link' => 'https://woocommerce.com/products/klaviyo-for-woocommerce?utm_source=storeprofiler&utm_medium=product&utm_campaign=freefeatures', |
| 574 | 'install_priority' => 7, |
| 575 | ), |
| 576 | 'tiktok-for-business' => array( |
| 577 | 'label' => __( 'Create ad campaigns with TikTok', 'woocommerce' ), |
| 578 | 'image_url' => plugins_url( '/assets/images/core-profiler/logo-tiktok.png', WC_PLUGIN_FILE ), |
| 579 | 'description' => __( 'Create advertising campaigns and reach one billion global users.', 'woocommerce' ), |
| 580 | 'learn_more_link' => 'https://woocommerce.com/products/tiktok-for-woocommerce?utm_source=storeprofiler&utm_medium=product&utm_campaign=freefeatures', |
| 581 | 'install_priority' => 1, |
| 582 | ), |
| 583 | 'google-listings-and-ads' => array( |
| 584 | 'label' => __( 'Drive sales with Google for WooCommerce', 'woocommerce' ), |
| 585 | 'image_url' => plugins_url( '/assets/images/core-profiler/logo-google.svg', WC_PLUGIN_FILE ), |
| 586 | 'description' => __( 'Reach millions of active shoppers across Google with free product listings and ads.', 'woocommerce' ), |
| 587 | 'learn_more_link' => 'https://woocommerce.com/products/google-listings-and-ads?utm_source=storeprofiler&utm_medium=product&utm_campaign=freefeatures', |
| 588 | 'install_priority' => 6, |
| 589 | ), |
| 590 | 'snapchat-for-woocommerce' => array( |
| 591 | 'label' => __( 'Find New Customers with Snapchat Ads', 'woocommerce' ), |
| 592 | 'image_url' => plugins_url( '/assets/images/core-profiler/logo-snapchat.svg', WC_PLUGIN_FILE ), |
| 593 | 'description' => __( 'Reach an untapped audience on Snapchat and drive more sales.', 'woocommerce' ), |
| 594 | 'learn_more_link' => 'https://woocommerce.com/products/snapchat/?utm_source=storeprofiler&utm_medium=product&utm_campaign=freefeatures', |
| 595 | 'install_priority' => 1, |
| 596 | ), |
| 597 | 'reddit-for-woocommerce' => array( |
| 598 | 'label' => __( 'Find New Customers with Reddit Ads', 'woocommerce' ), |
| 599 | 'image_url' => plugins_url( '/assets/images/core-profiler/logo-reddit.svg', WC_PLUGIN_FILE ), |
| 600 | 'description' => __( 'Seamlessly sync your products and start Reddit Ads.', 'woocommerce' ), |
| 601 | 'learn_more_link' => 'https://woocommerce.com/products/reddit/?utm_source=storeprofiler&utm_medium=product&utm_campaign=freefeatures', |
| 602 | 'install_priority' => 1, |
| 603 | ), |
| 604 | 'woocommerce-shipstation-integration' => array( |
| 605 | 'label' => __( 'Print discounted shipping labels with ShipStation', 'woocommerce' ), |
| 606 | 'image_url' => plugins_url( '/assets/images/core-profiler/logo-shipstation.svg', WC_PLUGIN_FILE ), |
| 607 | 'description' => __( 'Automate your order fulfillment and save on top carriers', 'woocommerce' ), |
| 608 | 'learn_more_link' => 'https://wordpress.org/plugins/woocommerce-shipstation-integration/', |
| 609 | 'install_priority' => 3, |
| 610 | ), |
| 611 | 'packlink-pro-shipping' => array( |
| 612 | 'label' => __( 'Print discounted shipping labels with Packlink', 'woocommerce' ), |
| 613 | 'image_url' => plugins_url( '/assets/images/core-profiler/logo-packlink.svg', WC_PLUGIN_FILE ), |
| 614 | 'description' => __( 'Automate your order fulfillment and save on top carriers', 'woocommerce' ), |
| 615 | 'learn_more_link' => 'https://wordpress.org/plugins/packlink-pro-shipping/', |
| 616 | 'install_priority' => 3, |
| 617 | ), |
| 618 | 'woocommerce-services:tax' => array( |
| 619 | 'label' => __( 'Get automated tax rates with WooCommerce Tax', 'woocommerce' ), |
| 620 | 'image_url' => self::get_woo_logo(), |
| 621 | 'description' => __( 'Automatically calculate how much sales tax should be collected – by city, country, or state.', 'woocommerce' ), |
| 622 | 'learn_more_link' => 'https://woocommerce.com/products/tax?utm_source=storeprofiler&utm_medium=product&utm_campaign=freefeatures', |
| 623 | 'install_priority' => 4, |
| 624 | ), |
| 625 | ); |
| 626 | |
| 627 | $_plugins['woocommerce-shipping']['is_visible'] = array( |
| 628 | array( |
| 629 | 'type' => 'base_location_country', |
| 630 | 'value' => 'US', |
| 631 | 'operation' => '=', |
| 632 | ), |
| 633 | ); |
| 634 | |
| 635 | $_plugins['woocommerce-services:tax']['is_visible'] = array( |
| 636 | self::get_rules_for_wcservices_tax_countries(), |
| 637 | ); |
| 638 | |
| 639 | // TikTok and Pinterest share a single spot with 1/2 rotation each. |
| 640 | $_plugins['tiktok-for-business']['is_visible'] = array( |
| 641 | array( |
| 642 | 'type' => 'option', |
| 643 | 'option_name' => 'woocommerce_remote_variant_assignment', |
| 644 | 'value' => array( 1, 60 ), |
| 645 | 'default' => false, |
| 646 | 'operation' => 'range', |
| 647 | ), |
| 648 | ); |
| 649 | |
| 650 | $_plugins['pinterest-for-woocommerce']['is_visible'] = array( |
| 651 | array( |
| 652 | 'type' => 'option', |
| 653 | 'option_name' => 'woocommerce_remote_variant_assignment', |
| 654 | 'value' => array( 61, 120 ), |
| 655 | 'default' => false, |
| 656 | 'operation' => 'range', |
| 657 | ), |
| 658 | ); |
| 659 | |
| 660 | $remove_plugins_activated_rule = function ( $is_visible ) { |
| 661 | $is_visible = array_filter( |
| 662 | array_map( |
| 663 | function ( $rule ) { |
| 664 | if ( is_object( $rule ) || ! isset( $rule['operand'] ) ) { |
| 665 | return $rule; |
| 666 | } |
| 667 | |
| 668 | return array_filter( |
| 669 | $rule['operand'], |
| 670 | function ( $operand ) { |
| 671 | return 'plugins_activated' !== $operand['type']; |
| 672 | } |
| 673 | ); |
| 674 | }, |
| 675 | $is_visible |
| 676 | ) |
| 677 | ); |
| 678 | |
| 679 | return empty( $is_visible ) ? true : $is_visible; |
| 680 | }; |
| 681 | |
| 682 | foreach ( $plugins as &$plugin ) { |
| 683 | if ( isset( $_plugins[ $plugin['key'] ] ) ) { |
| 684 | $plugin = array_merge( $plugin, $_plugins[ $plugin['key'] ] ); |
| 685 | |
| 686 | if ( isset( $plugin['is_visible'] ) && is_array( $plugin['is_visible'] ) ) { |
| 687 | $plugin['is_visible'] = $remove_plugins_activated_rule( $plugin['is_visible'] ); |
| 688 | } |
| 689 | } |
| 690 | } |
| 691 | |
| 692 | return $plugins; |
| 693 | } |
| 694 | |
| 695 | /** |
| 696 | * Returns the country restrictions for use in the `is_visible` key for |
| 697 | * recommending the tax functionality of WooCommerce Shipping & Tax. |
| 698 | * |
| 699 | * @return array |
| 700 | */ |
| 701 | private static function get_rules_for_wcservices_tax_countries() { |
| 702 | return array( |
| 703 | 'type' => 'base_location_country', |
| 704 | 'operation' => 'in', |
| 705 | 'value' => array( |
| 706 | 'US', |
| 707 | 'FR', |
| 708 | 'GB', |
| 709 | 'DE', |
| 710 | 'CA', |
| 711 | 'AU', |
| 712 | 'GR', |
| 713 | 'BE', |
| 714 | 'PT', |
| 715 | 'DK', |
| 716 | 'SE', |
| 717 | ), |
| 718 | ); |
| 719 | } |
| 720 | } |
| 721 |