Changeset 2712033
- Timestamp:
- 04/20/2022 08:57:50 AM (4 years ago)
- Location:
- wpmktgengine-extension-woocommerce
- Files:
-
- 6 edited
- 1 copied
-
tags/1.7.32 (copied) (copied from wpmktgengine-extension-woocommerce/trunk)
-
tags/1.7.32/includes/activitystream.js (modified) (2 diffs)
-
tags/1.7.32/includes/activitystreamtypes.css (modified) (2 diffs)
-
tags/1.7.32/wpmktgengine-woocommerce.php (modified) (5 diffs)
-
trunk/includes/activitystream.js (modified) (2 diffs)
-
trunk/includes/activitystreamtypes.css (modified) (2 diffs)
-
trunk/wpmktgengine-woocommerce.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wpmktgengine-extension-woocommerce/tags/1.7.32/includes/activitystream.js
r2697800 r2712033 1 jQuery(document).on("click", ".clickoption", function () { 1 jQuery(document).on("click", ".clickoption", function () { 2 var ajaxwoocommerceurl = jQuery(".admininsertvalue").val(); 2 3 jQuery.ajax({ 3 4 url: ajaxwoocommerceurl, … … 28 29 }); 29 30 }); 31 32 -
wpmktgengine-extension-woocommerce/tags/1.7.32/includes/activitystreamtypes.css
r2697800 r2712033 72 72 display: table; 73 73 } 74 .woo-extension-notification { 75 float: left; 76 width: 100%; 77 height: 64px; 78 } 74 79 75 .woo-extension-notification span:first-child { 80 76 float: left; … … 91 87 margin-top: 13px; 92 88 } 89 90 .woo-extension-notification { 91 float: left; 92 width: 96%; 93 } 94 .woo-extension-notification span { 95 float: left; 96 width: calc(100% - 150px); 97 } 98 .woo-extension-notification span.action-button-area { 99 float: left; 100 width: 150px; 101 } 102 .woo-extension-notification span.action-button-area a.clickoption { 103 min-width: 120px; 104 } 93 105 94 106 -
wpmktgengine-extension-woocommerce/tags/1.7.32/wpmktgengine-woocommerce.php
r2697831 r2712033 6 6 Author URI: http://www.genoo.com/ 7 7 Author Email: info@genoo.com 8 Version: 1.7.3 18 Version: 1.7.32 9 9 License: GPLv2 10 10 WC requires at least: 3.0.0 … … 167 167 $error = curl_error($ch); 168 168 $errorCode = curl_errno($ch); 169 } else { 169 } 170 else { 171 170 172 if (curl_getinfo($ch, CURLINFO_HTTP_CODE) == 202) { 173 171 174 // Active whowa whoooaa 175 172 176 $active = true; 177 173 178 // now, get the lead_type_id 179 174 180 $json = json_decode($resp); 181 175 182 if ( 176 is_object($json) && 177 isset($json->lead_type_id) 183 184 is_object($json) && 185 186 isset($json->lead_type_id) 187 178 188 ) { 189 179 190 $activeLeadType = $json->lead_type_id; 180 191 } 181 192 } 182 193 } 194 183 195 curl_close($ch); 184 196 } 185 } catch (\Exception $e) { 197 } 198 catch (\Exception $e) { 199 186 200 $active = false; 187 201 } 202 188 203 // Save new value 204 189 205 update_option('wpmktengine_extension_ecommerce', $active, true); 190 206 } 207 191 208 // 3. Check if we can activate the plugin after all 209 192 210 if ($active == false) { 211 193 212 genoo_wpme_deactivate_plugin( 213 194 214 $filePlugin, 215 195 216 'This extension is not allowed as part of your package.' 217 196 218 ); 197 } else { 219 } 220 else { 221 198 222 // 4. After all we can activate, that's great, lets add those calls 223 199 224 try { 225 200 226 $api->setStreamTypes([ 227 201 228 [ 229 202 230 'name' => 'viewed product', 231 203 232 'description' => '', 233 204 234 ], 235 205 236 [ 237 206 238 'name' => 'added product to cart', 239 207 240 'description' => '', 241 208 242 ], 243 209 244 [ 245 210 246 'name' => 'order completed', 247 211 248 'description' => '', 212 249 ], … … 217 254 [ 218 255 'name' => 'cart emptied', 256 219 257 'description' => '', 258 220 259 ], 260 221 261 [ 262 222 263 'name' => 'order refund full', 264 223 265 'description' => '', 266 224 267 ], 268 225 269 [ 270 226 271 'name' => 'order refund partial', 272 227 273 'description' => '', 274 228 275 ], 276 229 277 [ 278 230 279 'name' => 'new cart', 280 231 281 'description' => '', 282 232 283 ], 284 233 285 [ 286 234 287 'name' => 'new order', 288 235 289 'description' => '', 290 236 291 ], 292 237 293 [ 294 238 295 'name' => 'order cancelled', 296 239 297 'description' => '', 298 240 299 ], 300 241 301 [ 302 242 303 'name' => 'order refund full', 304 243 305 'description' => '', 306 244 307 ], 308 245 309 [ 246 310 'name' => 'order refund partial', … … 354 418 355 419 if (class_exists('woocommerce') || class_exists('Woocommerce')) { 420 356 421 /** 357 * Init redirect 358 */ 422 * Init redirect 423 */ 424 425 359 426 360 427 add_action( 428 361 429 'admin_init', 430 362 431 function () { 363 if (get_option('WPME_WOOCOMMERCE_JUST_ACTIVATED', false)) { 364 delete_option('WPME_WOOCOMMERCE_JUST_ACTIVATED'); 365 if (!isset($_GET['activate-multi'])) { 366 // Get if it's WPME or Genoo and find the link redirect 432 433 if (get_option('WPME_WOOCOMMERCE_JUST_ACTIVATED', false)) { 434 435 delete_option('WPME_WOOCOMMERCE_JUST_ACTIVATED'); 436 437 if (!isset($_GET['activate-multi'])) { 438 439 // Get if it's WPME or Genoo and find the link redirect 440 441 if ( 442 443 class_exists('\Genoo\Api') && 444 445 class_exists('\Genoo\RepositorySettings') 446 447 ) { 448 367 449 if ( 368 class_exists('\Genoo\Api') && 369 class_exists('\Genoo\RepositorySettings') 450 451 class_exists('\WPME\ApiFactory') && 452 453 class_exists( 454 455 '\WPME\RepositorySettingsFactory' 456 457 ) 458 370 459 ) { 371 if ( 372 class_exists('\WPME\ApiFactory') && 373 class_exists( 374 '\WPME\RepositorySettingsFactory' 375 ) 376 ) { 377 \WPMKTENGINE\Wordpress\Redirect::code( 378 302 379 )->to( 380 admin_url( 381 'admin.php?page=GenooTools&run=WPME_WOOCOMMERCE_JUST_ACTIVATED' 382 ) 383 ); 384 } else { 385 // depre 386 \Genoo\Wordpress\Redirect::code(302)->to( 387 admin_url( 388 'admin.php?page=GenooTools&run=WPME_WOOCOMMERCE_JUST_ACTIVATED' 389 ) 390 ); 391 } 392 } elseif ( 393 class_exists('\WPMKTENGINE\Api') && 394 class_exists('\WPMKTENGINE\RepositorySettings') 395 ) { 396 \WPMKTENGINE\Wordpress\Redirect::code(302)->to( 460 461 \WPMKTENGINE\Wordpress\Redirect::code( 462 463 302 464 465 )->to( 466 397 467 admin_url( 398 'admin.php?page=WPMKTENGINETools&run=WPME_WOOCOMMERCE_JUST_ACTIVATED' 399 ) 468 469 'admin.php?page=GenooTools&run=WPME_WOOCOMMERCE_JUST_ACTIVATED' 470 471 ) 472 473 ); 474 } 475 else { 476 477 // depre 478 479 \Genoo\Wordpress\Redirect::code(302)->to( 480 481 admin_url( 482 483 'admin.php?page=GenooTools&run=WPME_WOOCOMMERCE_JUST_ACTIVATED' 484 485 ) 486 400 487 ); 401 488 } 402 489 } 490 elseif ( 491 492 class_exists('\WPMKTENGINE\Api') && 493 494 class_exists('\WPMKTENGINE\RepositorySettings') 495 496 ) { 497 498 \WPMKTENGINE\Wordpress\Redirect::code(302)->to( 499 500 admin_url( 501 502 'admin.php?page=WPMKTENGINETools&run=WPME_WOOCOMMERCE_JUST_ACTIVATED' 503 504 ) 505 506 ); 507 } 403 508 } 404 405 }, 509 } 510 511 512 513 wp_enqueue_style( 514 515 'activitystyle', 516 517 plugins_url('/includes/activitystreamtypes.css', __FILE__) 518 519 ); 520 521 522 523 wp_enqueue_script( 524 525 'activity-script', 526 527 plugins_url('/includes/activitystream.js', __FILE__, [], '1.0.0', true) 528 529 ); 530 } 531 , 532 406 533 10, 534 407 535 1 536 408 537 ); 409 538 539 540 410 541 /** 411 * Add auto-import script 412 */ 542 * Add auto-import script 543 */ 544 545 413 546 414 547 add_action( … … 3533 3666 3534 3667 3668 3669 3670 3671 add_action('wp_ajax_woocommerce_activity_stream_types', 'woocommerce_activity_stream_types'); 3672 3673 add_action('wp_ajax_woocommerce_delete_plugin_options', 'woocommerce_delete_plugin_options'); 3674 3675 function woocommerce_activity_stream_types() 3676 3677 { 3678 3679 if ( 3680 3681 class_exists("\WPME\ApiFactory") && 3682 3683 class_exists("\WPME\RepositorySettingsFactory") 3684 3685 ) { 3686 3687 $activate = true; 3688 3689 $repo = new \WPME\RepositorySettingsFactory(); 3690 3691 $api = new \WPME\ApiFactory($repo); 3692 3693 if (class_exists("\Genoo\Api")) { 3694 3695 $isGenoo = true; 3696 } 3697 } 3698 elseif ( 3699 3700 class_exists("\Genoo\Api") && 3701 3702 class_exists("\Genoo\RepositorySettings") 3703 3704 ) { 3705 3706 $activate = true; 3707 3708 $repo = new \Genoo\RepositorySettings(); 3709 3710 $api = new \Genoo\Api($repo); 3711 3712 $isGenoo = true; 3713 } 3714 elseif ( 3715 3716 class_exists("\WPMKTENGINE\Api") && 3717 3718 class_exists("\WPMKTENGINE\RepositorySettings") 3719 3720 ) { 3721 3722 $activate = true; 3723 3724 $repo = new \WPMKTENGINE\RepositorySettings(); 3725 3726 $api = new \WPMKTENGINE\Api($repo); 3727 } 3728 3729 try { 3730 $api->setStreamTypes([ 3731 3732 [ 3733 3734 'name' => 'viewed product', 3735 3736 'description' => '', 3737 3738 ], 3739 3740 [ 3741 3742 'name' => 'added product to cart', 3743 3744 'description' => '', 3745 3746 ], 3747 3748 [ 3749 3750 'name' => 'order completed', 3751 3752 'description' => '', 3753 3754 ], 3755 3756 [ 3757 3758 'name' => 'order canceled', 3759 3760 'description' => '', 3761 3762 ], 3763 3764 [ 3765 3766 'name' => 'cart emptied', 3767 3768 'description' => '', 3769 3770 ], 3771 3772 [ 3773 3774 'name' => 'order refund full', 3775 3776 'description' => '', 3777 3778 ], 3779 3780 [ 3781 3782 'name' => 'order refund partial', 3783 3784 'description' => '', 3785 3786 ], 3787 3788 [ 3789 3790 'name' => 'new cart', 3791 3792 'description' => '', 3793 3794 ], 3795 3796 [ 3797 3798 'name' => 'new order', 3799 3800 'description' => '', 3801 3802 ], 3803 3804 [ 3805 3806 'name' => 'order cancelled', 3807 3808 'description' => '', 3809 3810 ], 3811 3812 [ 3813 3814 'name' => 'order refund full', 3815 3816 'description' => '', 3817 3818 ], 3819 3820 [ 3821 3822 'name' => 'order refund partial', 3823 3824 'description' => '', 3825 3826 ], 3827 3828 [ 3829 3830 'name' => 'upsell purchased', 3831 3832 'description' => 'Upsell Purchased', 3833 3834 ], 3835 3836 [ 3837 3838 'name' => 'order payment declined', 3839 3840 'description' => '', 3841 3842 ], 3843 3844 [ 3845 3846 'name' => 'completed order', 3847 3848 'description' => '', 3849 3850 ], 3851 3852 [ 3853 3854 'name' => 'subscription started', 3855 3856 'description' => '', 3857 3858 ], 3859 3860 [ 3861 3862 'name' => 'subscription payment', 3863 3864 'description' => '', 3865 3866 ], 3867 3868 [ 3869 3870 'name' => 'subscription renewal', 3871 3872 'description' => '', 3873 3874 ], 3875 3876 [ 3877 3878 'name' => 'subscription reactivated', 3879 3880 'description' => '', 3881 3882 ], 3883 3884 [ 3885 3886 'name' => 'subscription payment declined', 3887 3888 'description' => '', 3889 3890 ], 3891 3892 [ 3893 3894 'name' => 'subscription payment cancelled', 3895 3896 'description' => '', 3897 3898 ], 3899 3900 [ 3901 3902 'name' => 'subscription expired', 3903 3904 'description' => '', 3905 3906 ], 3907 3908 [ 3909 3910 'name' => 'sub renewal failed', 3911 3912 'description' => '', 3913 3914 ], 3915 3916 [ 3917 3918 'name' => 'sub payment failed', 3919 3920 'description' => '', 3921 3922 ], 3923 3924 [ 3925 3926 'name' => 'subscription on hold', 3927 3928 'description' => '', 3929 3930 ], 3931 3932 [ 3933 3934 'name' => 'cancelled order', 3935 3936 'description' => '', 3937 3938 ], 3939 3940 [ 3941 3942 'name' => 'subscription cancelled', 3943 3944 'description' => '', 3945 3946 ], 3947 3948 [ 3949 3950 'name' => 'Subscription Pending Cancellation', 3951 3952 'description' => '', 3953 3954 ], 3955 3956 ]); 3957 3958 } 3959 catch (\Exception $e) { 3960 3961 // Decide later Sub Renewal Failed 3962 3963 } 3964 } 3965 3966 add_action("plugins_loaded", "woocommerce_update_db_check"); 3967 3968 function woocommerce_update_db_check() 3969 3970 { 3971 3972 $option_value = get_option("plugin_file_updated"); 3973 3974 if ($option_value == "yes") { 3975 3976 add_action("admin_notices", "sample_admin_notice_woocommerce_success"); 3977 } 3978 } 3979 3980 function woocommerce_delete_plugin_options() 3981 3982 { 3983 3984 delete_option('plugin_file_updated'); 3985 } 3986 function woocommerce_wp_upgrade_completed($upgrader_object, $options) 3987 { 3988 3989 // The path to our plugin's main file 3990 3991 $our_plugin = plugin_basename(__FILE__); 3992 3993 // If an update has taken place and the updated type is plugins and the plugins element exists 3994 3995 if ($options['action'] == 'update' && $options['type'] == 'plugin' && isset($options['plugins'])) { 3996 3997 // Iterate through the plugins being updated and check if ours is there 3998 3999 foreach ($options['plugins'] as $plugin) { 4000 4001 if ($plugin == $our_plugin) { 4002 4003 // Your action if it is your plugin 4004 4005 update_option("plugin_file_updated", "yes"); 4006 } 4007 } 4008 } 4009 } 4010 4011 add_action('upgrader_process_complete', 'woocommerce_wp_upgrade_completed', 10, 2); 4012 4013 function sample_admin_notice_woocommerce_success() 4014 4015 { 4016 4017 ?> 4018 4019 <div class="notice notice-success is-dismissible woo-extension-notification"> 4020 4021 <input type="hidden" class="admininsertvalue" value="<?php echo admin_url( 4022 4023 'admin-ajax.php' 4024 4025 ); ?>" /> 4026 4027 <span> 4028 <p><b>WooCommerce - WPMktgEngine | Genoo Extension update required</b></p> 4029 <p>WooCommerce extension has been updated. Update the woocommerce extension activity stream types.</p> 4030 </span> 4031 4032 <span class="action-button-area"> 4033 4034 <a class="clickoption button button-primary">Update Database</a> 4035 4036 </span> 4037 4038 </div> 4039 4040 <?php 4041 4042 } -
wpmktgengine-extension-woocommerce/trunk/includes/activitystream.js
r2697800 r2712033 1 jQuery(document).on("click", ".clickoption", function () { 1 jQuery(document).on("click", ".clickoption", function () { 2 var ajaxwoocommerceurl = jQuery(".admininsertvalue").val(); 2 3 jQuery.ajax({ 3 4 url: ajaxwoocommerceurl, … … 28 29 }); 29 30 }); 31 32 -
wpmktgengine-extension-woocommerce/trunk/includes/activitystreamtypes.css
r2697800 r2712033 72 72 display: table; 73 73 } 74 .woo-extension-notification { 75 float: left; 76 width: 100%; 77 height: 64px; 78 } 74 79 75 .woo-extension-notification span:first-child { 80 76 float: left; … … 91 87 margin-top: 13px; 92 88 } 89 90 .woo-extension-notification { 91 float: left; 92 width: 96%; 93 } 94 .woo-extension-notification span { 95 float: left; 96 width: calc(100% - 150px); 97 } 98 .woo-extension-notification span.action-button-area { 99 float: left; 100 width: 150px; 101 } 102 .woo-extension-notification span.action-button-area a.clickoption { 103 min-width: 120px; 104 } 93 105 94 106 -
wpmktgengine-extension-woocommerce/trunk/wpmktgengine-woocommerce.php
r2697831 r2712033 6 6 Author URI: http://www.genoo.com/ 7 7 Author Email: info@genoo.com 8 Version: 1.7.3 18 Version: 1.7.32 9 9 License: GPLv2 10 10 WC requires at least: 3.0.0 … … 167 167 $error = curl_error($ch); 168 168 $errorCode = curl_errno($ch); 169 } else { 169 } 170 else { 171 170 172 if (curl_getinfo($ch, CURLINFO_HTTP_CODE) == 202) { 173 171 174 // Active whowa whoooaa 175 172 176 $active = true; 177 173 178 // now, get the lead_type_id 179 174 180 $json = json_decode($resp); 181 175 182 if ( 176 is_object($json) && 177 isset($json->lead_type_id) 183 184 is_object($json) && 185 186 isset($json->lead_type_id) 187 178 188 ) { 189 179 190 $activeLeadType = $json->lead_type_id; 180 191 } 181 192 } 182 193 } 194 183 195 curl_close($ch); 184 196 } 185 } catch (\Exception $e) { 197 } 198 catch (\Exception $e) { 199 186 200 $active = false; 187 201 } 202 188 203 // Save new value 204 189 205 update_option('wpmktengine_extension_ecommerce', $active, true); 190 206 } 207 191 208 // 3. Check if we can activate the plugin after all 209 192 210 if ($active == false) { 211 193 212 genoo_wpme_deactivate_plugin( 213 194 214 $filePlugin, 215 195 216 'This extension is not allowed as part of your package.' 217 196 218 ); 197 } else { 219 } 220 else { 221 198 222 // 4. After all we can activate, that's great, lets add those calls 223 199 224 try { 225 200 226 $api->setStreamTypes([ 227 201 228 [ 229 202 230 'name' => 'viewed product', 231 203 232 'description' => '', 233 204 234 ], 235 205 236 [ 237 206 238 'name' => 'added product to cart', 239 207 240 'description' => '', 241 208 242 ], 243 209 244 [ 245 210 246 'name' => 'order completed', 247 211 248 'description' => '', 212 249 ], … … 217 254 [ 218 255 'name' => 'cart emptied', 256 219 257 'description' => '', 258 220 259 ], 260 221 261 [ 262 222 263 'name' => 'order refund full', 264 223 265 'description' => '', 266 224 267 ], 268 225 269 [ 270 226 271 'name' => 'order refund partial', 272 227 273 'description' => '', 274 228 275 ], 276 229 277 [ 278 230 279 'name' => 'new cart', 280 231 281 'description' => '', 282 232 283 ], 284 233 285 [ 286 234 287 'name' => 'new order', 288 235 289 'description' => '', 290 236 291 ], 292 237 293 [ 294 238 295 'name' => 'order cancelled', 296 239 297 'description' => '', 298 240 299 ], 300 241 301 [ 302 242 303 'name' => 'order refund full', 304 243 305 'description' => '', 306 244 307 ], 308 245 309 [ 246 310 'name' => 'order refund partial', … … 354 418 355 419 if (class_exists('woocommerce') || class_exists('Woocommerce')) { 420 356 421 /** 357 * Init redirect 358 */ 422 * Init redirect 423 */ 424 425 359 426 360 427 add_action( 428 361 429 'admin_init', 430 362 431 function () { 363 if (get_option('WPME_WOOCOMMERCE_JUST_ACTIVATED', false)) { 364 delete_option('WPME_WOOCOMMERCE_JUST_ACTIVATED'); 365 if (!isset($_GET['activate-multi'])) { 366 // Get if it's WPME or Genoo and find the link redirect 432 433 if (get_option('WPME_WOOCOMMERCE_JUST_ACTIVATED', false)) { 434 435 delete_option('WPME_WOOCOMMERCE_JUST_ACTIVATED'); 436 437 if (!isset($_GET['activate-multi'])) { 438 439 // Get if it's WPME or Genoo and find the link redirect 440 441 if ( 442 443 class_exists('\Genoo\Api') && 444 445 class_exists('\Genoo\RepositorySettings') 446 447 ) { 448 367 449 if ( 368 class_exists('\Genoo\Api') && 369 class_exists('\Genoo\RepositorySettings') 450 451 class_exists('\WPME\ApiFactory') && 452 453 class_exists( 454 455 '\WPME\RepositorySettingsFactory' 456 457 ) 458 370 459 ) { 371 if ( 372 class_exists('\WPME\ApiFactory') && 373 class_exists( 374 '\WPME\RepositorySettingsFactory' 375 ) 376 ) { 377 \WPMKTENGINE\Wordpress\Redirect::code( 378 302 379 )->to( 380 admin_url( 381 'admin.php?page=GenooTools&run=WPME_WOOCOMMERCE_JUST_ACTIVATED' 382 ) 383 ); 384 } else { 385 // depre 386 \Genoo\Wordpress\Redirect::code(302)->to( 387 admin_url( 388 'admin.php?page=GenooTools&run=WPME_WOOCOMMERCE_JUST_ACTIVATED' 389 ) 390 ); 391 } 392 } elseif ( 393 class_exists('\WPMKTENGINE\Api') && 394 class_exists('\WPMKTENGINE\RepositorySettings') 395 ) { 396 \WPMKTENGINE\Wordpress\Redirect::code(302)->to( 460 461 \WPMKTENGINE\Wordpress\Redirect::code( 462 463 302 464 465 )->to( 466 397 467 admin_url( 398 'admin.php?page=WPMKTENGINETools&run=WPME_WOOCOMMERCE_JUST_ACTIVATED' 399 ) 468 469 'admin.php?page=GenooTools&run=WPME_WOOCOMMERCE_JUST_ACTIVATED' 470 471 ) 472 473 ); 474 } 475 else { 476 477 // depre 478 479 \Genoo\Wordpress\Redirect::code(302)->to( 480 481 admin_url( 482 483 'admin.php?page=GenooTools&run=WPME_WOOCOMMERCE_JUST_ACTIVATED' 484 485 ) 486 400 487 ); 401 488 } 402 489 } 490 elseif ( 491 492 class_exists('\WPMKTENGINE\Api') && 493 494 class_exists('\WPMKTENGINE\RepositorySettings') 495 496 ) { 497 498 \WPMKTENGINE\Wordpress\Redirect::code(302)->to( 499 500 admin_url( 501 502 'admin.php?page=WPMKTENGINETools&run=WPME_WOOCOMMERCE_JUST_ACTIVATED' 503 504 ) 505 506 ); 507 } 403 508 } 404 405 }, 509 } 510 511 512 513 wp_enqueue_style( 514 515 'activitystyle', 516 517 plugins_url('/includes/activitystreamtypes.css', __FILE__) 518 519 ); 520 521 522 523 wp_enqueue_script( 524 525 'activity-script', 526 527 plugins_url('/includes/activitystream.js', __FILE__, [], '1.0.0', true) 528 529 ); 530 } 531 , 532 406 533 10, 534 407 535 1 536 408 537 ); 409 538 539 540 410 541 /** 411 * Add auto-import script 412 */ 542 * Add auto-import script 543 */ 544 545 413 546 414 547 add_action( … … 3533 3666 3534 3667 3668 3669 3670 3671 add_action('wp_ajax_woocommerce_activity_stream_types', 'woocommerce_activity_stream_types'); 3672 3673 add_action('wp_ajax_woocommerce_delete_plugin_options', 'woocommerce_delete_plugin_options'); 3674 3675 function woocommerce_activity_stream_types() 3676 3677 { 3678 3679 if ( 3680 3681 class_exists("\WPME\ApiFactory") && 3682 3683 class_exists("\WPME\RepositorySettingsFactory") 3684 3685 ) { 3686 3687 $activate = true; 3688 3689 $repo = new \WPME\RepositorySettingsFactory(); 3690 3691 $api = new \WPME\ApiFactory($repo); 3692 3693 if (class_exists("\Genoo\Api")) { 3694 3695 $isGenoo = true; 3696 } 3697 } 3698 elseif ( 3699 3700 class_exists("\Genoo\Api") && 3701 3702 class_exists("\Genoo\RepositorySettings") 3703 3704 ) { 3705 3706 $activate = true; 3707 3708 $repo = new \Genoo\RepositorySettings(); 3709 3710 $api = new \Genoo\Api($repo); 3711 3712 $isGenoo = true; 3713 } 3714 elseif ( 3715 3716 class_exists("\WPMKTENGINE\Api") && 3717 3718 class_exists("\WPMKTENGINE\RepositorySettings") 3719 3720 ) { 3721 3722 $activate = true; 3723 3724 $repo = new \WPMKTENGINE\RepositorySettings(); 3725 3726 $api = new \WPMKTENGINE\Api($repo); 3727 } 3728 3729 try { 3730 $api->setStreamTypes([ 3731 3732 [ 3733 3734 'name' => 'viewed product', 3735 3736 'description' => '', 3737 3738 ], 3739 3740 [ 3741 3742 'name' => 'added product to cart', 3743 3744 'description' => '', 3745 3746 ], 3747 3748 [ 3749 3750 'name' => 'order completed', 3751 3752 'description' => '', 3753 3754 ], 3755 3756 [ 3757 3758 'name' => 'order canceled', 3759 3760 'description' => '', 3761 3762 ], 3763 3764 [ 3765 3766 'name' => 'cart emptied', 3767 3768 'description' => '', 3769 3770 ], 3771 3772 [ 3773 3774 'name' => 'order refund full', 3775 3776 'description' => '', 3777 3778 ], 3779 3780 [ 3781 3782 'name' => 'order refund partial', 3783 3784 'description' => '', 3785 3786 ], 3787 3788 [ 3789 3790 'name' => 'new cart', 3791 3792 'description' => '', 3793 3794 ], 3795 3796 [ 3797 3798 'name' => 'new order', 3799 3800 'description' => '', 3801 3802 ], 3803 3804 [ 3805 3806 'name' => 'order cancelled', 3807 3808 'description' => '', 3809 3810 ], 3811 3812 [ 3813 3814 'name' => 'order refund full', 3815 3816 'description' => '', 3817 3818 ], 3819 3820 [ 3821 3822 'name' => 'order refund partial', 3823 3824 'description' => '', 3825 3826 ], 3827 3828 [ 3829 3830 'name' => 'upsell purchased', 3831 3832 'description' => 'Upsell Purchased', 3833 3834 ], 3835 3836 [ 3837 3838 'name' => 'order payment declined', 3839 3840 'description' => '', 3841 3842 ], 3843 3844 [ 3845 3846 'name' => 'completed order', 3847 3848 'description' => '', 3849 3850 ], 3851 3852 [ 3853 3854 'name' => 'subscription started', 3855 3856 'description' => '', 3857 3858 ], 3859 3860 [ 3861 3862 'name' => 'subscription payment', 3863 3864 'description' => '', 3865 3866 ], 3867 3868 [ 3869 3870 'name' => 'subscription renewal', 3871 3872 'description' => '', 3873 3874 ], 3875 3876 [ 3877 3878 'name' => 'subscription reactivated', 3879 3880 'description' => '', 3881 3882 ], 3883 3884 [ 3885 3886 'name' => 'subscription payment declined', 3887 3888 'description' => '', 3889 3890 ], 3891 3892 [ 3893 3894 'name' => 'subscription payment cancelled', 3895 3896 'description' => '', 3897 3898 ], 3899 3900 [ 3901 3902 'name' => 'subscription expired', 3903 3904 'description' => '', 3905 3906 ], 3907 3908 [ 3909 3910 'name' => 'sub renewal failed', 3911 3912 'description' => '', 3913 3914 ], 3915 3916 [ 3917 3918 'name' => 'sub payment failed', 3919 3920 'description' => '', 3921 3922 ], 3923 3924 [ 3925 3926 'name' => 'subscription on hold', 3927 3928 'description' => '', 3929 3930 ], 3931 3932 [ 3933 3934 'name' => 'cancelled order', 3935 3936 'description' => '', 3937 3938 ], 3939 3940 [ 3941 3942 'name' => 'subscription cancelled', 3943 3944 'description' => '', 3945 3946 ], 3947 3948 [ 3949 3950 'name' => 'Subscription Pending Cancellation', 3951 3952 'description' => '', 3953 3954 ], 3955 3956 ]); 3957 3958 } 3959 catch (\Exception $e) { 3960 3961 // Decide later Sub Renewal Failed 3962 3963 } 3964 } 3965 3966 add_action("plugins_loaded", "woocommerce_update_db_check"); 3967 3968 function woocommerce_update_db_check() 3969 3970 { 3971 3972 $option_value = get_option("plugin_file_updated"); 3973 3974 if ($option_value == "yes") { 3975 3976 add_action("admin_notices", "sample_admin_notice_woocommerce_success"); 3977 } 3978 } 3979 3980 function woocommerce_delete_plugin_options() 3981 3982 { 3983 3984 delete_option('plugin_file_updated'); 3985 } 3986 function woocommerce_wp_upgrade_completed($upgrader_object, $options) 3987 { 3988 3989 // The path to our plugin's main file 3990 3991 $our_plugin = plugin_basename(__FILE__); 3992 3993 // If an update has taken place and the updated type is plugins and the plugins element exists 3994 3995 if ($options['action'] == 'update' && $options['type'] == 'plugin' && isset($options['plugins'])) { 3996 3997 // Iterate through the plugins being updated and check if ours is there 3998 3999 foreach ($options['plugins'] as $plugin) { 4000 4001 if ($plugin == $our_plugin) { 4002 4003 // Your action if it is your plugin 4004 4005 update_option("plugin_file_updated", "yes"); 4006 } 4007 } 4008 } 4009 } 4010 4011 add_action('upgrader_process_complete', 'woocommerce_wp_upgrade_completed', 10, 2); 4012 4013 function sample_admin_notice_woocommerce_success() 4014 4015 { 4016 4017 ?> 4018 4019 <div class="notice notice-success is-dismissible woo-extension-notification"> 4020 4021 <input type="hidden" class="admininsertvalue" value="<?php echo admin_url( 4022 4023 'admin-ajax.php' 4024 4025 ); ?>" /> 4026 4027 <span> 4028 <p><b>WooCommerce - WPMktgEngine | Genoo Extension update required</b></p> 4029 <p>WooCommerce extension has been updated. Update the woocommerce extension activity stream types.</p> 4030 </span> 4031 4032 <span class="action-button-area"> 4033 4034 <a class="clickoption button button-primary">Update Database</a> 4035 4036 </span> 4037 4038 </div> 4039 4040 <?php 4041 4042 }
Note: See TracChangeset
for help on using the changeset viewer.