Plugin Directory

Changeset 2712033


Ignore:
Timestamp:
04/20/2022 08:57:50 AM (4 years ago)
Author:
Genoo
Message:

Release 1.7.32

Location:
wpmktgengine-extension-woocommerce
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • wpmktgengine-extension-woocommerce/tags/1.7.32/includes/activitystream.js

    r2697800 r2712033  
    1 jQuery(document).on("click", ".clickoption", function () {   
     1jQuery(document).on("click", ".clickoption", function () {
     2    var ajaxwoocommerceurl = jQuery(".admininsertvalue").val();
    23    jQuery.ajax({
    34     url: ajaxwoocommerceurl,
     
    2829     });
    2930      });
     31     
     32     
  • wpmktgengine-extension-woocommerce/tags/1.7.32/includes/activitystreamtypes.css

    r2697800 r2712033  
    7272               display: table;
    7373              }
    74    .woo-extension-notification {
    75        float: left;
    76        width: 100%;
    77        height: 64px;
    78    }
     74
    7975   .woo-extension-notification span:first-child {
    8076       float: left;
     
    9187       margin-top: 13px;
    9288   }
     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}
    93105
    94106
  • wpmktgengine-extension-woocommerce/tags/1.7.32/wpmktgengine-woocommerce.php

    r2697831 r2712033  
    66    Author URI: http://www.genoo.com/
    77    Author Email: info@genoo.com
    8     Version: 1.7.31
     8    Version: 1.7.32
    99    License: GPLv2
    1010    WC requires at least: 3.0.0
     
    167167                        $error = curl_error($ch);
    168168                        $errorCode = curl_errno($ch);
    169                     } else {
     169                    }
     170                    else {
     171
    170172                        if (curl_getinfo($ch, CURLINFO_HTTP_CODE) == 202) {
     173
    171174                            // Active whowa whoooaa
     175
    172176                            $active = true;
     177
    173178                            // now, get the lead_type_id
     179
    174180                            $json = json_decode($resp);
     181
    175182                            if (
    176                                 is_object($json) &&
    177                                 isset($json->lead_type_id)
     183
     184                            is_object($json) &&
     185
     186                            isset($json->lead_type_id)
     187
    178188                            ) {
     189
    179190                                $activeLeadType = $json->lead_type_id;
    180191                            }
    181192                        }
    182193                    }
     194
    183195                    curl_close($ch);
    184196                }
    185             } catch (\Exception $e) {
     197            }
     198            catch (\Exception $e) {
     199
    186200                $active = false;
    187201            }
     202
    188203            // Save new value
     204
    189205            update_option('wpmktengine_extension_ecommerce', $active, true);
    190206        }
     207
    191208        // 3. Check if we can activate the plugin after all
     209
    192210        if ($active == false) {
     211
    193212            genoo_wpme_deactivate_plugin(
     213
    194214                $filePlugin,
     215
    195216                'This extension is not allowed as part of your package.'
     217
    196218            );
    197         } else {
     219        }
     220        else {
     221
    198222            // 4. After all we can activate, that's great, lets add those calls
     223
    199224            try {
     225
    200226                $api->setStreamTypes([
     227
    201228                    [
     229
    202230                        'name' => 'viewed product',
     231
    203232                        'description' => '',
     233
    204234                    ],
     235
    205236                    [
     237
    206238                        'name' => 'added product to cart',
     239
    207240                        'description' => '',
     241
    208242                    ],
     243
    209244                    [
     245
    210246                        'name' => 'order completed',
     247
    211248                        'description' => '',
    212249                    ],
     
    217254                    [
    218255                        'name' => 'cart emptied',
     256
    219257                        'description' => '',
     258
    220259                    ],
     260
    221261                    [
     262
    222263                        'name' => 'order refund full',
     264
    223265                        'description' => '',
     266
    224267                    ],
     268
    225269                    [
     270
    226271                        'name' => 'order refund partial',
     272
    227273                        'description' => '',
     274
    228275                    ],
     276
    229277                    [
     278
    230279                        'name' => 'new cart',
     280
    231281                        'description' => '',
     282
    232283                    ],
     284
    233285                    [
     286
    234287                        'name' => 'new order',
     288
    235289                        'description' => '',
     290
    236291                    ],
     292
    237293                    [
     294
    238295                        'name' => 'order cancelled',
     296
    239297                        'description' => '',
     298
    240299                    ],
     300
    241301                    [
     302
    242303                        'name' => 'order refund full',
     304
    243305                        'description' => '',
     306
    244307                    ],
     308
    245309                    [
    246310                        'name' => 'order refund partial',
     
    354418
    355419        if (class_exists('woocommerce') || class_exists('Woocommerce')) {
     420
    356421            /**
    357              * Init redirect
    358              */
     422     * Init redirect
     423     */
     424
     425
    359426
    360427            add_action(
     428
    361429                'admin_init',
     430
    362431                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
    367449                            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
    370459                            ) {
    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
    397467                                    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
    400487                                );
    401488                            }
    402489                        }
     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                        }
    403508                    }
    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
    406533                10,
     534
    407535                1
     536
    408537            );
    409538
     539
     540
    410541            /**
    411              * Add auto-import script
    412              */
     542     * Add auto-import script
     543     */
     544
     545
    413546
    414547            add_action(
     
    35333666
    35343667
     3668
     3669
     3670
     3671add_action('wp_ajax_woocommerce_activity_stream_types', 'woocommerce_activity_stream_types');
     3672
     3673add_action('wp_ajax_woocommerce_delete_plugin_options', 'woocommerce_delete_plugin_options');
     3674
     3675function 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
     3966add_action("plugins_loaded", "woocommerce_update_db_check");
     3967
     3968function 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
     3980function woocommerce_delete_plugin_options()
     3981
     3982{
     3983
     3984    delete_option('plugin_file_updated');
     3985}
     3986function 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
     4011add_action('upgrader_process_complete', 'woocommerce_wp_upgrade_completed', 10, 2);
     4012
     4013function 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 () {   
     1jQuery(document).on("click", ".clickoption", function () {
     2    var ajaxwoocommerceurl = jQuery(".admininsertvalue").val();
    23    jQuery.ajax({
    34     url: ajaxwoocommerceurl,
     
    2829     });
    2930      });
     31     
     32     
  • wpmktgengine-extension-woocommerce/trunk/includes/activitystreamtypes.css

    r2697800 r2712033  
    7272               display: table;
    7373              }
    74    .woo-extension-notification {
    75        float: left;
    76        width: 100%;
    77        height: 64px;
    78    }
     74
    7975   .woo-extension-notification span:first-child {
    8076       float: left;
     
    9187       margin-top: 13px;
    9288   }
     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}
    93105
    94106
  • wpmktgengine-extension-woocommerce/trunk/wpmktgengine-woocommerce.php

    r2697831 r2712033  
    66    Author URI: http://www.genoo.com/
    77    Author Email: info@genoo.com
    8     Version: 1.7.31
     8    Version: 1.7.32
    99    License: GPLv2
    1010    WC requires at least: 3.0.0
     
    167167                        $error = curl_error($ch);
    168168                        $errorCode = curl_errno($ch);
    169                     } else {
     169                    }
     170                    else {
     171
    170172                        if (curl_getinfo($ch, CURLINFO_HTTP_CODE) == 202) {
     173
    171174                            // Active whowa whoooaa
     175
    172176                            $active = true;
     177
    173178                            // now, get the lead_type_id
     179
    174180                            $json = json_decode($resp);
     181
    175182                            if (
    176                                 is_object($json) &&
    177                                 isset($json->lead_type_id)
     183
     184                            is_object($json) &&
     185
     186                            isset($json->lead_type_id)
     187
    178188                            ) {
     189
    179190                                $activeLeadType = $json->lead_type_id;
    180191                            }
    181192                        }
    182193                    }
     194
    183195                    curl_close($ch);
    184196                }
    185             } catch (\Exception $e) {
     197            }
     198            catch (\Exception $e) {
     199
    186200                $active = false;
    187201            }
     202
    188203            // Save new value
     204
    189205            update_option('wpmktengine_extension_ecommerce', $active, true);
    190206        }
     207
    191208        // 3. Check if we can activate the plugin after all
     209
    192210        if ($active == false) {
     211
    193212            genoo_wpme_deactivate_plugin(
     213
    194214                $filePlugin,
     215
    195216                'This extension is not allowed as part of your package.'
     217
    196218            );
    197         } else {
     219        }
     220        else {
     221
    198222            // 4. After all we can activate, that's great, lets add those calls
     223
    199224            try {
     225
    200226                $api->setStreamTypes([
     227
    201228                    [
     229
    202230                        'name' => 'viewed product',
     231
    203232                        'description' => '',
     233
    204234                    ],
     235
    205236                    [
     237
    206238                        'name' => 'added product to cart',
     239
    207240                        'description' => '',
     241
    208242                    ],
     243
    209244                    [
     245
    210246                        'name' => 'order completed',
     247
    211248                        'description' => '',
    212249                    ],
     
    217254                    [
    218255                        'name' => 'cart emptied',
     256
    219257                        'description' => '',
     258
    220259                    ],
     260
    221261                    [
     262
    222263                        'name' => 'order refund full',
     264
    223265                        'description' => '',
     266
    224267                    ],
     268
    225269                    [
     270
    226271                        'name' => 'order refund partial',
     272
    227273                        'description' => '',
     274
    228275                    ],
     276
    229277                    [
     278
    230279                        'name' => 'new cart',
     280
    231281                        'description' => '',
     282
    232283                    ],
     284
    233285                    [
     286
    234287                        'name' => 'new order',
     288
    235289                        'description' => '',
     290
    236291                    ],
     292
    237293                    [
     294
    238295                        'name' => 'order cancelled',
     296
    239297                        'description' => '',
     298
    240299                    ],
     300
    241301                    [
     302
    242303                        'name' => 'order refund full',
     304
    243305                        'description' => '',
     306
    244307                    ],
     308
    245309                    [
    246310                        'name' => 'order refund partial',
     
    354418
    355419        if (class_exists('woocommerce') || class_exists('Woocommerce')) {
     420
    356421            /**
    357              * Init redirect
    358              */
     422     * Init redirect
     423     */
     424
     425
    359426
    360427            add_action(
     428
    361429                'admin_init',
     430
    362431                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
    367449                            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
    370459                            ) {
    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
    397467                                    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
    400487                                );
    401488                            }
    402489                        }
     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                        }
    403508                    }
    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
    406533                10,
     534
    407535                1
     536
    408537            );
    409538
     539
     540
    410541            /**
    411              * Add auto-import script
    412              */
     542     * Add auto-import script
     543     */
     544
     545
    413546
    414547            add_action(
     
    35333666
    35343667
     3668
     3669
     3670
     3671add_action('wp_ajax_woocommerce_activity_stream_types', 'woocommerce_activity_stream_types');
     3672
     3673add_action('wp_ajax_woocommerce_delete_plugin_options', 'woocommerce_delete_plugin_options');
     3674
     3675function 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
     3966add_action("plugins_loaded", "woocommerce_update_db_check");
     3967
     3968function 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
     3980function woocommerce_delete_plugin_options()
     3981
     3982{
     3983
     3984    delete_option('plugin_file_updated');
     3985}
     3986function 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
     4011add_action('upgrader_process_complete', 'woocommerce_wp_upgrade_completed', 10, 2);
     4012
     4013function 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.