InstalledExtensions.php
2 years ago
MarketingCampaign.php
1 year ago
MarketingCampaignType.php
3 years ago
MarketingChannelInterface.php
3 years ago
MarketingChannels.php
3 years ago
Price.php
3 years ago
InstalledExtensions.php
634 lines
| 1 | <?php |
| 2 | /** |
| 3 | * InstalledExtensions class file. |
| 4 | */ |
| 5 | |
| 6 | namespace Automattic\WooCommerce\Admin\Marketing; |
| 7 | |
| 8 | use Automattic\WooCommerce\Admin\PluginsHelper; |
| 9 | |
| 10 | /** |
| 11 | * Installed Marketing Extensions class. |
| 12 | */ |
| 13 | class InstalledExtensions { |
| 14 | |
| 15 | /** |
| 16 | * Gets an array of plugin data for the "Installed marketing extensions" card. |
| 17 | * |
| 18 | * Valid extensions statuses are: installed, activated, configured |
| 19 | */ |
| 20 | public static function get_data() { |
| 21 | $data = []; |
| 22 | |
| 23 | $automatewoo = self::get_automatewoo_extension_data(); |
| 24 | $aw_referral = self::get_aw_referral_extension_data(); |
| 25 | $aw_birthdays = self::get_aw_birthdays_extension_data(); |
| 26 | $mailchimp = self::get_mailchimp_extension_data(); |
| 27 | $facebook = self::get_facebook_extension_data(); |
| 28 | $pinterest = self::get_pinterest_extension_data(); |
| 29 | $google = self::get_google_extension_data(); |
| 30 | $amazon_ebay = self::get_amazon_ebay_extension_data(); |
| 31 | $mailpoet = self::get_mailpoet_extension_data(); |
| 32 | $klaviyo = self::get_klaviyo_extension_data(); |
| 33 | $creative_mail = self::get_creative_mail_extension_data(); |
| 34 | $tiktok = self::get_tiktok_extension_data(); |
| 35 | $jetpack_crm = self::get_jetpack_crm_extension_data(); |
| 36 | $zapier = self::get_zapier_extension_data(); |
| 37 | $salesforce = self::get_salesforce_extension_data(); |
| 38 | $vimeo = self::get_vimeo_extension_data(); |
| 39 | $trustpilot = self::get_trustpilot_extension_data(); |
| 40 | |
| 41 | if ( $automatewoo ) { |
| 42 | $data[] = $automatewoo; |
| 43 | } |
| 44 | |
| 45 | if ( $aw_referral ) { |
| 46 | $data[] = $aw_referral; |
| 47 | } |
| 48 | |
| 49 | if ( $aw_birthdays ) { |
| 50 | $data[] = $aw_birthdays; |
| 51 | } |
| 52 | |
| 53 | if ( $mailchimp ) { |
| 54 | $data[] = $mailchimp; |
| 55 | } |
| 56 | |
| 57 | if ( $facebook ) { |
| 58 | $data[] = $facebook; |
| 59 | } |
| 60 | |
| 61 | if ( $pinterest ) { |
| 62 | $data[] = $pinterest; |
| 63 | } |
| 64 | |
| 65 | if ( $google ) { |
| 66 | $data[] = $google; |
| 67 | } |
| 68 | |
| 69 | if ( $amazon_ebay ) { |
| 70 | $data[] = $amazon_ebay; |
| 71 | } |
| 72 | |
| 73 | if ( $mailpoet ) { |
| 74 | $data[] = $mailpoet; |
| 75 | } |
| 76 | |
| 77 | if ( $klaviyo ) { |
| 78 | $data[] = $klaviyo; |
| 79 | } |
| 80 | |
| 81 | if ( $creative_mail ) { |
| 82 | $data[] = $creative_mail; |
| 83 | } |
| 84 | |
| 85 | if ( $tiktok ) { |
| 86 | $data[] = $tiktok; |
| 87 | } |
| 88 | |
| 89 | if ( $jetpack_crm ) { |
| 90 | $data[] = $jetpack_crm; |
| 91 | } |
| 92 | |
| 93 | if ( $zapier ) { |
| 94 | $data[] = $zapier; |
| 95 | } |
| 96 | |
| 97 | if ( $salesforce ) { |
| 98 | $data[] = $salesforce; |
| 99 | } |
| 100 | |
| 101 | if ( $vimeo ) { |
| 102 | $data[] = $vimeo; |
| 103 | } |
| 104 | |
| 105 | if ( $trustpilot ) { |
| 106 | $data[] = $trustpilot; |
| 107 | } |
| 108 | |
| 109 | return $data; |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * Get allowed plugins. |
| 114 | * |
| 115 | * @return array |
| 116 | */ |
| 117 | public static function get_allowed_plugins() { |
| 118 | return [ |
| 119 | 'automatewoo', |
| 120 | 'mailchimp-for-woocommerce', |
| 121 | 'creative-mail-by-constant-contact', |
| 122 | 'facebook-for-woocommerce', |
| 123 | 'pinterest-for-woocommerce', |
| 124 | 'google-listings-and-ads', |
| 125 | 'hubspot-for-woocommerce', |
| 126 | 'woocommerce-amazon-ebay-integration', |
| 127 | 'mailpoet', |
| 128 | ]; |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * Get AutomateWoo extension data. |
| 133 | * |
| 134 | * @return array|bool |
| 135 | */ |
| 136 | protected static function get_automatewoo_extension_data() { |
| 137 | $slug = 'automatewoo'; |
| 138 | |
| 139 | if ( ! PluginsHelper::is_plugin_installed( $slug ) ) { |
| 140 | return false; |
| 141 | } |
| 142 | |
| 143 | $data = self::get_extension_base_data( $slug ); |
| 144 | $data['icon'] = WC_ADMIN_IMAGES_FOLDER_URL . '/marketing/automatewoo.svg'; |
| 145 | |
| 146 | if ( 'activated' === $data['status'] && function_exists( 'AW' ) ) { |
| 147 | $data['settingsUrl'] = admin_url( 'admin.php?page=automatewoo-settings' ); |
| 148 | $data['docsUrl'] = 'https://automatewoo.com/docs/'; |
| 149 | $data['status'] = 'configured'; // Currently no configuration step. |
| 150 | } |
| 151 | |
| 152 | return $data; |
| 153 | } |
| 154 | |
| 155 | /** |
| 156 | * Get AutomateWoo Refer a Friend extension data. |
| 157 | * |
| 158 | * @return array|bool |
| 159 | */ |
| 160 | protected static function get_aw_referral_extension_data() { |
| 161 | $slug = 'automatewoo-referrals'; |
| 162 | |
| 163 | if ( ! PluginsHelper::is_plugin_installed( $slug ) ) { |
| 164 | return false; |
| 165 | } |
| 166 | |
| 167 | $data = self::get_extension_base_data( $slug ); |
| 168 | $data['icon'] = WC_ADMIN_IMAGES_FOLDER_URL . '/marketing/automatewoo.svg'; |
| 169 | |
| 170 | if ( 'activated' === $data['status'] ) { |
| 171 | $data['docsUrl'] = 'https://automatewoo.com/docs/refer-a-friend/'; |
| 172 | $data['status'] = 'configured'; |
| 173 | if ( function_exists( 'AW_Referrals' ) ) { |
| 174 | $data['settingsUrl'] = admin_url( 'admin.php?page=automatewoo-settings&tab=referrals' ); |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | return $data; |
| 179 | } |
| 180 | |
| 181 | /** |
| 182 | * Get AutomateWoo Birthdays extension data. |
| 183 | * |
| 184 | * @return array|bool |
| 185 | */ |
| 186 | protected static function get_aw_birthdays_extension_data() { |
| 187 | $slug = 'automatewoo-birthdays'; |
| 188 | |
| 189 | if ( ! PluginsHelper::is_plugin_installed( $slug ) ) { |
| 190 | return false; |
| 191 | } |
| 192 | |
| 193 | $data = self::get_extension_base_data( $slug ); |
| 194 | $data['icon'] = WC_ADMIN_IMAGES_FOLDER_URL . '/marketing/automatewoo.svg'; |
| 195 | |
| 196 | if ( 'activated' === $data['status'] ) { |
| 197 | $data['docsUrl'] = 'https://automatewoo.com/docs/getting-started-with-birthdays/'; |
| 198 | $data['status'] = 'configured'; |
| 199 | if ( function_exists( 'AW_Birthdays' ) ) { |
| 200 | $data['settingsUrl'] = admin_url( 'admin.php?page=automatewoo-settings&tab=birthdays' ); |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | return $data; |
| 205 | } |
| 206 | |
| 207 | /** |
| 208 | * Get MailChimp extension data. |
| 209 | * |
| 210 | * @return array|bool |
| 211 | */ |
| 212 | protected static function get_mailchimp_extension_data() { |
| 213 | $slug = 'mailchimp-for-woocommerce'; |
| 214 | |
| 215 | if ( ! PluginsHelper::is_plugin_installed( $slug ) ) { |
| 216 | return false; |
| 217 | } |
| 218 | |
| 219 | $data = self::get_extension_base_data( $slug ); |
| 220 | $data['icon'] = WC_ADMIN_IMAGES_FOLDER_URL . '/marketing/mailchimp.svg'; |
| 221 | |
| 222 | if ( 'activated' === $data['status'] && function_exists( 'mailchimp_is_configured' ) ) { |
| 223 | $data['docsUrl'] = 'https://mailchimp.com/help/connect-or-disconnect-mailchimp-for-woocommerce/'; |
| 224 | $data['settingsUrl'] = admin_url( 'admin.php?page=mailchimp-woocommerce' ); |
| 225 | |
| 226 | if ( mailchimp_is_configured() ) { |
| 227 | $data['status'] = 'configured'; |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | return $data; |
| 232 | } |
| 233 | |
| 234 | /** |
| 235 | * Get Facebook extension data. |
| 236 | * |
| 237 | * @return array|bool |
| 238 | */ |
| 239 | protected static function get_facebook_extension_data() { |
| 240 | $slug = 'facebook-for-woocommerce'; |
| 241 | |
| 242 | if ( ! PluginsHelper::is_plugin_installed( $slug ) ) { |
| 243 | return false; |
| 244 | } |
| 245 | |
| 246 | $data = self::get_extension_base_data( $slug ); |
| 247 | $data['icon'] = WC_ADMIN_IMAGES_FOLDER_URL . '/marketing/facebook-icon.svg'; |
| 248 | |
| 249 | if ( 'activated' === $data['status'] && function_exists( 'facebook_for_woocommerce' ) ) { |
| 250 | $integration = facebook_for_woocommerce()->get_integration(); |
| 251 | |
| 252 | if ( $integration->is_configured() ) { |
| 253 | $data['status'] = 'configured'; |
| 254 | } |
| 255 | |
| 256 | $data['settingsUrl'] = facebook_for_woocommerce()->get_settings_url(); |
| 257 | $data['docsUrl'] = facebook_for_woocommerce()->get_documentation_url(); |
| 258 | } |
| 259 | |
| 260 | return $data; |
| 261 | } |
| 262 | |
| 263 | /** |
| 264 | * Get Pinterest extension data. |
| 265 | * |
| 266 | * @return array|bool |
| 267 | */ |
| 268 | protected static function get_pinterest_extension_data() { |
| 269 | $slug = 'pinterest-for-woocommerce'; |
| 270 | |
| 271 | if ( ! PluginsHelper::is_plugin_installed( $slug ) ) { |
| 272 | return false; |
| 273 | } |
| 274 | |
| 275 | $data = self::get_extension_base_data( $slug ); |
| 276 | $data['icon'] = WC_ADMIN_IMAGES_FOLDER_URL . '/marketing/pinterest.svg'; |
| 277 | |
| 278 | $data['docsUrl'] = 'https://woocommerce.com/document/pinterest-for-woocommerce/?utm_medium=product'; |
| 279 | |
| 280 | if ( 'activated' === $data['status'] && class_exists( 'Pinterest_For_Woocommerce' ) ) { |
| 281 | $pinterest_onboarding_completed = Pinterest_For_Woocommerce()::is_setup_complete(); |
| 282 | if ( $pinterest_onboarding_completed ) { |
| 283 | $data['status'] = 'configured'; |
| 284 | $data['settingsUrl'] = admin_url( 'admin.php?page=wc-admin&path=/pinterest/settings' ); |
| 285 | } else { |
| 286 | $data['settingsUrl'] = admin_url( 'admin.php?page=wc-admin&path=/pinterest/landing' ); |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | return $data; |
| 291 | } |
| 292 | |
| 293 | /** |
| 294 | * Get Google extension data. |
| 295 | * |
| 296 | * @return array|bool |
| 297 | */ |
| 298 | protected static function get_google_extension_data() { |
| 299 | $slug = 'google-listings-and-ads'; |
| 300 | |
| 301 | if ( ! PluginsHelper::is_plugin_installed( $slug ) ) { |
| 302 | return false; |
| 303 | } |
| 304 | |
| 305 | $data = self::get_extension_base_data( $slug ); |
| 306 | $data['icon'] = WC_ADMIN_IMAGES_FOLDER_URL . '/marketing/google.svg'; |
| 307 | |
| 308 | if ( 'activated' === $data['status'] && function_exists( 'woogle_get_container' ) && class_exists( '\Automattic\WooCommerce\GoogleListingsAndAds\MerchantCenter\MerchantCenterService' ) ) { |
| 309 | |
| 310 | $merchant_center = woogle_get_container()->get( \Automattic\WooCommerce\GoogleListingsAndAds\MerchantCenter\MerchantCenterService::class ); |
| 311 | |
| 312 | if ( $merchant_center->is_setup_complete() ) { |
| 313 | $data['status'] = 'configured'; |
| 314 | $data['settingsUrl'] = admin_url( 'admin.php?page=wc-admin&path=/google/settings' ); |
| 315 | } else { |
| 316 | $data['settingsUrl'] = admin_url( 'admin.php?page=wc-admin&path=/google/start' ); |
| 317 | } |
| 318 | |
| 319 | $data['docsUrl'] = 'https://woocommerce.com/document/google-listings-and-ads/?utm_medium=product'; |
| 320 | } |
| 321 | |
| 322 | return $data; |
| 323 | } |
| 324 | |
| 325 | /** |
| 326 | * Get Amazon / Ebay extension data. |
| 327 | * |
| 328 | * @return array|bool |
| 329 | */ |
| 330 | protected static function get_amazon_ebay_extension_data() { |
| 331 | $slug = 'woocommerce-amazon-ebay-integration'; |
| 332 | |
| 333 | if ( ! PluginsHelper::is_plugin_installed( $slug ) ) { |
| 334 | return false; |
| 335 | } |
| 336 | |
| 337 | $data = self::get_extension_base_data( $slug ); |
| 338 | $data['icon'] = WC_ADMIN_IMAGES_FOLDER_URL . '/marketing/amazon-ebay.svg'; |
| 339 | |
| 340 | if ( 'activated' === $data['status'] && class_exists( '\CodistoConnect' ) ) { |
| 341 | |
| 342 | $codisto_merchantid = get_option( 'codisto_merchantid' ); |
| 343 | |
| 344 | // Use same check as codisto admin tabs. |
| 345 | if ( is_numeric( $codisto_merchantid ) ) { |
| 346 | $data['status'] = 'configured'; |
| 347 | } |
| 348 | |
| 349 | $data['settingsUrl'] = admin_url( 'admin.php?page=codisto-settings' ); |
| 350 | $data['docsUrl'] = 'https://woocommerce.com/document/multichannel-for-woocommerce-google-amazon-ebay-walmart-integration/?utm_medium=product'; |
| 351 | } |
| 352 | |
| 353 | return $data; |
| 354 | } |
| 355 | |
| 356 | /** |
| 357 | * Get MailPoet extension data. |
| 358 | * |
| 359 | * @return array|bool |
| 360 | */ |
| 361 | protected static function get_mailpoet_extension_data() { |
| 362 | $slug = 'mailpoet'; |
| 363 | |
| 364 | if ( ! PluginsHelper::is_plugin_installed( $slug ) ) { |
| 365 | return false; |
| 366 | } |
| 367 | |
| 368 | $data = self::get_extension_base_data( $slug ); |
| 369 | $data['icon'] = WC_ADMIN_IMAGES_FOLDER_URL . '/marketing/mailpoet.svg'; |
| 370 | |
| 371 | if ( 'activated' === $data['status'] && class_exists( '\MailPoet\API\API' ) ) { |
| 372 | $mailpoet_api = \MailPoet\API\API::MP( 'v1' ); |
| 373 | |
| 374 | if ( ! method_exists( $mailpoet_api, 'isSetupComplete' ) || $mailpoet_api->isSetupComplete() ) { |
| 375 | $data['status'] = 'configured'; |
| 376 | $data['settingsUrl'] = admin_url( 'admin.php?page=mailpoet-settings' ); |
| 377 | } else { |
| 378 | $data['settingsUrl'] = admin_url( 'admin.php?page=mailpoet-newsletters' ); |
| 379 | } |
| 380 | |
| 381 | $data['docsUrl'] = 'https://kb.mailpoet.com/'; |
| 382 | $data['supportUrl'] = 'https://www.mailpoet.com/support/'; |
| 383 | } |
| 384 | |
| 385 | return $data; |
| 386 | } |
| 387 | |
| 388 | /** |
| 389 | * Get Klaviyo extension data. |
| 390 | * |
| 391 | * @return array|bool |
| 392 | */ |
| 393 | protected static function get_klaviyo_extension_data() { |
| 394 | $slug = 'klaviyo'; |
| 395 | |
| 396 | if ( ! PluginsHelper::is_plugin_installed( $slug ) ) { |
| 397 | return false; |
| 398 | } |
| 399 | |
| 400 | $data = self::get_extension_base_data( $slug ); |
| 401 | $data['icon'] = plugins_url( 'assets/images/marketing/klaviyo.png', WC_PLUGIN_FILE ); |
| 402 | |
| 403 | if ( 'activated' === $data['status'] ) { |
| 404 | $klaviyo_options = get_option( 'klaviyo_settings' ); |
| 405 | if ( isset( $klaviyo_options['klaviyo_public_api_key'] ) ) { |
| 406 | $data['status'] = 'configured'; |
| 407 | } |
| 408 | |
| 409 | $data['settingsUrl'] = admin_url( 'admin.php?page=klaviyo_settings' ); |
| 410 | } |
| 411 | |
| 412 | return $data; |
| 413 | } |
| 414 | |
| 415 | /** |
| 416 | * Get Creative Mail for WooCommerce extension data. |
| 417 | * |
| 418 | * @return array|bool |
| 419 | */ |
| 420 | protected static function get_creative_mail_extension_data() { |
| 421 | $slug = 'creative-mail-by-constant-contact'; |
| 422 | |
| 423 | if ( ! PluginsHelper::is_plugin_installed( $slug ) ) { |
| 424 | return false; |
| 425 | } |
| 426 | |
| 427 | $data = self::get_extension_base_data( $slug ); |
| 428 | $data['icon'] = WC_ADMIN_IMAGES_FOLDER_URL . '/marketing/creative-mail-by-constant-contact.png'; |
| 429 | |
| 430 | if ( 'activated' === $data['status'] && class_exists( '\CreativeMail\Helpers\OptionsHelper' ) ) { |
| 431 | if ( ! method_exists( '\CreativeMail\Helpers\OptionsHelper', 'get_instance_id' ) || \CreativeMail\Helpers\OptionsHelper::get_instance_id() !== null ) { |
| 432 | $data['status'] = 'configured'; |
| 433 | $data['settingsUrl'] = admin_url( 'admin.php?page=creativemail_settings' ); |
| 434 | } else { |
| 435 | $data['settingsUrl'] = admin_url( 'admin.php?page=creativemail' ); |
| 436 | } |
| 437 | |
| 438 | $data['docsUrl'] = 'https://app.creativemail.com/kb/help/WooCommerce'; |
| 439 | $data['supportUrl'] = 'https://app.creativemail.com/kb/help/'; |
| 440 | } |
| 441 | |
| 442 | return $data; |
| 443 | } |
| 444 | |
| 445 | /** |
| 446 | * Get TikTok for WooCommerce extension data. |
| 447 | * |
| 448 | * @return array|bool |
| 449 | */ |
| 450 | protected static function get_tiktok_extension_data() { |
| 451 | $slug = 'tiktok-for-business'; |
| 452 | |
| 453 | if ( ! PluginsHelper::is_plugin_installed( $slug ) ) { |
| 454 | return false; |
| 455 | } |
| 456 | |
| 457 | $data = self::get_extension_base_data( $slug ); |
| 458 | $data['icon'] = WC_ADMIN_IMAGES_FOLDER_URL . '/marketing/tiktok.jpg'; |
| 459 | |
| 460 | if ( 'activated' === $data['status'] ) { |
| 461 | if ( false !== get_option( 'tt4b_access_token' ) ) { |
| 462 | $data['status'] = 'configured'; |
| 463 | } |
| 464 | |
| 465 | $data['settingsUrl'] = admin_url( 'admin.php?page=tiktok' ); |
| 466 | $data['docsUrl'] = 'https://woocommerce.com/document/tiktok-for-woocommerce/'; |
| 467 | $data['supportUrl'] = 'https://ads.tiktok.com/athena/user-feedback/?identify_key=6a1e079024806640c5e1e695d13db80949525168a052299b4970f9c99cb5ac78'; |
| 468 | } |
| 469 | |
| 470 | return $data; |
| 471 | } |
| 472 | |
| 473 | /** |
| 474 | * Get Jetpack CRM for WooCommerce extension data. |
| 475 | * |
| 476 | * @return array|bool |
| 477 | */ |
| 478 | protected static function get_jetpack_crm_extension_data() { |
| 479 | $slug = 'zero-bs-crm'; |
| 480 | |
| 481 | if ( ! PluginsHelper::is_plugin_installed( $slug ) ) { |
| 482 | return false; |
| 483 | } |
| 484 | |
| 485 | $data = self::get_extension_base_data( $slug ); |
| 486 | $data['icon'] = WC_ADMIN_IMAGES_FOLDER_URL . '/marketing/jetpack-crm.png'; |
| 487 | |
| 488 | if ( 'activated' === $data['status'] ) { |
| 489 | $data['status'] = 'configured'; |
| 490 | $data['settingsUrl'] = admin_url( 'admin.php?page=zerobscrm-plugin-settings' ); |
| 491 | $data['docsUrl'] = 'https://kb.jetpackcrm.com/'; |
| 492 | $data['supportUrl'] = 'https://kb.jetpackcrm.com/crm-support/'; |
| 493 | } |
| 494 | |
| 495 | return $data; |
| 496 | } |
| 497 | |
| 498 | /** |
| 499 | * Get WooCommerce Zapier extension data. |
| 500 | * |
| 501 | * @return array|bool |
| 502 | */ |
| 503 | protected static function get_zapier_extension_data() { |
| 504 | $slug = 'woocommerce-zapier'; |
| 505 | |
| 506 | if ( ! PluginsHelper::is_plugin_installed( $slug ) ) { |
| 507 | return false; |
| 508 | } |
| 509 | |
| 510 | $data = self::get_extension_base_data( $slug ); |
| 511 | $data['icon'] = WC_ADMIN_IMAGES_FOLDER_URL . '/marketing/zapier.png'; |
| 512 | |
| 513 | if ( 'activated' === $data['status'] ) { |
| 514 | $data['status'] = 'configured'; |
| 515 | $data['settingsUrl'] = admin_url( 'admin.php?page=wc-settings&tab=wc_zapier' ); |
| 516 | $data['docsUrl'] = 'https://docs.om4.io/woocommerce-zapier/'; |
| 517 | } |
| 518 | |
| 519 | return $data; |
| 520 | } |
| 521 | |
| 522 | /** |
| 523 | * Get Salesforce extension data. |
| 524 | * |
| 525 | * @return array|bool |
| 526 | */ |
| 527 | protected static function get_salesforce_extension_data() { |
| 528 | $slug = 'integration-with-salesforce'; |
| 529 | |
| 530 | if ( ! PluginsHelper::is_plugin_installed( $slug ) ) { |
| 531 | return false; |
| 532 | } |
| 533 | |
| 534 | $data = self::get_extension_base_data( $slug ); |
| 535 | $data['icon'] = WC_ADMIN_IMAGES_FOLDER_URL . '/marketing/salesforce.jpg'; |
| 536 | |
| 537 | if ( 'activated' === $data['status'] && class_exists( '\Integration_With_Salesforce_Admin' ) ) { |
| 538 | if ( ! method_exists( '\Integration_With_Salesforce_Admin', 'get_connection_status' ) || \Integration_With_Salesforce_Admin::get_connection_status() ) { |
| 539 | $data['status'] = 'configured'; |
| 540 | } |
| 541 | |
| 542 | $data['settingsUrl'] = admin_url( 'admin.php?page=integration-with-salesforce' ); |
| 543 | $data['docsUrl'] = 'https://woocommerce.com/document/salesforce-integration/'; |
| 544 | $data['supportUrl'] = 'https://wpswings.com/submit-query/'; |
| 545 | } |
| 546 | |
| 547 | return $data; |
| 548 | } |
| 549 | |
| 550 | /** |
| 551 | * Get Vimeo extension data. |
| 552 | * |
| 553 | * @return array|bool |
| 554 | */ |
| 555 | protected static function get_vimeo_extension_data() { |
| 556 | $slug = 'vimeo'; |
| 557 | |
| 558 | if ( ! PluginsHelper::is_plugin_installed( $slug ) ) { |
| 559 | return false; |
| 560 | } |
| 561 | |
| 562 | $data = self::get_extension_base_data( $slug ); |
| 563 | $data['icon'] = WC_ADMIN_IMAGES_FOLDER_URL . '/marketing/vimeo.png'; |
| 564 | |
| 565 | if ( 'activated' === $data['status'] && class_exists( '\Tribe\Vimeo_WP\Vimeo\Vimeo_Auth' ) ) { |
| 566 | if ( method_exists( '\Tribe\Vimeo_WP\Vimeo\Vimeo_Auth', 'has_access_token' ) ) { |
| 567 | $vimeo_auth = new \Tribe\Vimeo_WP\Vimeo\Vimeo_Auth(); |
| 568 | if ( $vimeo_auth->has_access_token() ) { |
| 569 | $data['status'] = 'configured'; |
| 570 | } |
| 571 | } else { |
| 572 | $data['status'] = 'configured'; |
| 573 | } |
| 574 | |
| 575 | $data['settingsUrl'] = admin_url( 'options-general.php?page=vimeo_settings' ); |
| 576 | $data['docsUrl'] = 'https://woocommerce.com/document/vimeo/'; |
| 577 | $data['supportUrl'] = 'https://vimeo.com/help/contact'; |
| 578 | } |
| 579 | |
| 580 | return $data; |
| 581 | } |
| 582 | |
| 583 | /** |
| 584 | * Get Trustpilot extension data. |
| 585 | * |
| 586 | * @return array|bool |
| 587 | */ |
| 588 | protected static function get_trustpilot_extension_data() { |
| 589 | $slug = 'trustpilot-reviews'; |
| 590 | |
| 591 | if ( ! PluginsHelper::is_plugin_installed( $slug ) ) { |
| 592 | return false; |
| 593 | } |
| 594 | |
| 595 | $data = self::get_extension_base_data( $slug ); |
| 596 | $data['icon'] = WC_ADMIN_IMAGES_FOLDER_URL . '/marketing/trustpilot.png'; |
| 597 | |
| 598 | if ( 'activated' === $data['status'] ) { |
| 599 | $data['status'] = 'configured'; |
| 600 | $data['settingsUrl'] = admin_url( 'admin.php?page=woocommerce-trustpilot-settings-page' ); |
| 601 | $data['docsUrl'] = 'https://woocommerce.com/document/trustpilot-reviews/'; |
| 602 | $data['supportUrl'] = 'https://support.trustpilot.com/hc/en-us/requests/new'; |
| 603 | } |
| 604 | |
| 605 | return $data; |
| 606 | } |
| 607 | |
| 608 | |
| 609 | /** |
| 610 | * Get an array of basic data for a given extension. |
| 611 | * |
| 612 | * @param string $slug Plugin slug. |
| 613 | * |
| 614 | * @return array|false |
| 615 | */ |
| 616 | protected static function get_extension_base_data( $slug ) { |
| 617 | $status = PluginsHelper::is_plugin_active( $slug ) ? 'activated' : 'installed'; |
| 618 | $plugin_data = PluginsHelper::get_plugin_data( $slug ); |
| 619 | |
| 620 | if ( ! $plugin_data ) { |
| 621 | return false; |
| 622 | } |
| 623 | |
| 624 | return [ |
| 625 | 'slug' => $slug, |
| 626 | 'status' => $status, |
| 627 | 'name' => $plugin_data['Name'], |
| 628 | 'description' => html_entity_decode( wp_trim_words( $plugin_data['Description'], 20 ) ), |
| 629 | 'supportUrl' => 'https://woocommerce.com/my-account/create-a-ticket/?utm_medium=product', |
| 630 | ]; |
| 631 | } |
| 632 | |
| 633 | } |
| 634 |