Plugin Directory

Changeset 2919893


Ignore:
Timestamp:
05/31/2023 10:28:57 PM (3 years ago)
Author:
notifyevents
Message:

Adding WooCommerce product manipulation event support.

Location:
notify-events/trunk
Files:
6 added
10 edited

Legend:

Unmodified
Added
Removed
  • notify-events/trunk/controllers/EventController.php

    r2383243 r2919893  
    3636    public function action_create()
    3737    {
    38         /** @var Event $event_class */
     38        /** @var Event|string $event_class */
    3939        $event_class = wp_unslash($_GET['event']);
    4040
  • notify-events/trunk/models/Core.php

    r2882680 r2919893  
    160160            /** @var Module $module_b */
    161161
    162             return $module_a::module_order() > $module_b::module_order();
     162            return ($module_a::module_order() > $module_b::module_order()) ? 1 : -1;
    163163        });
    164164
     
    173173    {
    174174        if (!array_key_exists($module_name, $this->_modules)) {
    175             wp_die(__('Can\'t find %s module'), $module_name);
     175            wp_die(__('Can\'t find module: ') . $module_name);
    176176        }
    177177
  • notify-events/trunk/models/Model.php

    r2856139 r2919893  
    342342    protected function rule_each($attribute, $value, array $params)
    343343    {
    344         if (!is_array($value)) {
     344        if (!is_array($value) && !empty($value)) {
    345345            $message = array_key_exists('message', $params) ? $params['message'] : __('Value must be array', WPNE);
    346346
  • notify-events/trunk/modules/woocommerce/models/WooCommerce.php

    r2432603 r2919893  
    99use notify_events\modules\woocommerce\models\events\product\NoStock;
    1010use notify_events\modules\woocommerce\models\events\product\OnBackorder;
     11use notify_events\modules\woocommerce\models\events\product\ProductAdded;
     12use notify_events\modules\woocommerce\models\events\product\ProductApproved;
     13use notify_events\modules\woocommerce\models\events\product\ProductCustom;
     14use notify_events\modules\woocommerce\models\events\product\ProductPending;
     15use notify_events\modules\woocommerce\models\events\product\ProductPublished;
    1116
    1217/**
     
    5964            ],
    6065            __('Product', WPNE) => [
     66                ProductAdded::class,
     67                ProductPublished::class,
     68                ProductPending::class,
     69                ProductApproved::class,
     70                ProductCustom::class,
     71                OnBackorder::class,
     72            ],
     73            __('Stock', WPNE) => [
    6174                LowStock::class,
    6275                NoStock::class,
    63                 OnBackorder::class,
    6476            ],
    6577        ];
  • notify-events/trunk/modules/wordpress/models/events/post/PostCustom.php

    r2532490 r2919893  
    1818 * @property int    $channel_id
    1919 * @property string $post_type
     20 * @property bool   $post_is_status_changed
     21 * @property string $post_old_status
    2022 * @property string $post_status
    2123 */
     
    4345    public static function handle($new_status, $old_status, $post)
    4446    {
    45         if ($new_status == $old_status) {
    46             return;
    47         }
    48 
    4947        $author = get_userdata($post->post_author);
    5048        $editor = get_userdata(get_post_meta($post->ID, '_edit_last', true));
     
    6563                ],
    6664                [
     65                    'key'     => '_wpne_post_is_status_changed',
     66                    'value'   => (int)($old_status != $new_status),
     67                ],
     68                [
     69                    'key'     => '_wpne_post_old_status',
     70                    'value'   => serialize($old_status),
     71                    'compare' => 'LIKE'
     72                ],
     73                [
    6774                    'key'     => '_wpne_post_status',
    68                     'value'   => serialize($post->post_status),
     75                    'value'   => serialize($new_status),
    6976                    'compare' => 'LIKE'
    7077                ],
     
    8895        return array_merge(parent::fields(), [
    8996            'post_type',
     97            'post_is_status_changed',
     98            'post_old_status',
    9099            'post_status',
    91100        ]);
     
    99108        return array_merge(parent::rules(), [
    100109            'post_type' => [
    101                 ['required'],
    102110                ['each', 'rules' => [
    103111                    ['string'],
     
    105113                ]],
    106114            ],
     115            'post_is_status_changed' => [
     116                ['boolean'],
     117            ],
     118            'post_old_status' => [
     119                ['each', 'rules' => [
     120                    ['string'],
     121                    ['in', 'range' => array_keys(self::post_status_list())],
     122                ]],
     123            ],
    107124            'post_status' => [
    108                 ['required'],
    109125                ['each', 'rules' => [
    110126                    ['string'],
  • notify-events/trunk/modules/wordpress/views/event/post_custom.php

    r2532490 r2919893  
    4242                'items' => $event::post_type_list(),
    4343            ], false) ?>
     44            <?= $this->render('form/_checkbox', [
     45                'model' => $event,
     46                'title' => __('Is Status Changed', WPNE),
     47                'field' => 'post_is_status_changed',
     48            ], false) ?>
    4449            <?= $this->render('form/_multi_select', [
    4550                'model' => $event,
    46                 'title' => __('Post Status', WPNE),
     51                'title' => __('Old Type', WPNE),
     52                'field' => 'post_old_status',
     53                'items' => $event::post_status_list(),
     54            ], false) ?>
     55            <?= $this->render('form/_multi_select', [
     56                'model' => $event,
     57                'title' => __('Status', WPNE),
    4758                'field' => 'post_status',
    4859                'items' => $event::post_status_list(),
  • notify-events/trunk/notify-events.php

    r2882680 r2919893  
    66Author: Notify.Events
    77Author URI: https://notify.events/
    8 Version: 1.3.3
     8Version: 1.4.0
    99License: GPL-2.0
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    1515use notify_events\models\Core;
    1616use notify_events\modules\contact_form_7\models\ContactForm7;
     17use notify_events\modules\easy_digital_downloads\models\EasyDigitalDownloads;
    1718use notify_events\modules\ninja_forms\models\NinjaForms;
    1819use notify_events\modules\woocommerce\models\WooCommerce;
     
    5657        NinjaForms::register();
    5758    }
     59
     60    if (Core::is_plugin_active('easy-digital-downloads/easy-digital-downloads.php')) {
     61        EasyDigitalDownloads::register();
     62    }
    5863});
  • notify-events/trunk/readme.txt

    r2882680 r2919893  
    44Requires at least: 5.3
    55Requires PHP: 5.6
    6 Tested up to: 6.2
    7 Stable tag: 1.3.3
     6Tested up to: 6.2.1
     7Stable tag: 1.4.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    4343    * Order Status Change
    4444* Product
     45    * Product Added
     46    * Product Published
     47    * Product Sent for Review
     48    * Product Approved
     49    * Product Custom Event
    4550    * Low Stock
    4651    * Out Of Stock
     
    8388
    8489== Changelog ==
     90
     91= 1.4.0 =
     92Adding WooCommerce product manipulation event support.
    8593
    8694= 1.3.0 =
  • notify-events/trunk/views/event/form/_multi_select.php

    r2532490 r2919893  
    1414?>
    1515
     16<style>
     17    .checkbox-list {
     18        border: 1px solid #c3c4c7;
     19        border-radius: 4px;
     20        padding: 0 4px;
     21        max-height: 150px;
     22        overflow-y: auto;
     23    }
     24    .checkbox-list label {
     25        display: block;
     26        margin: 4px 0;
     27    }
     28</style>
     29
    1630<tr class="wpne-form-group <?= $model->has_error($field) ? 'wpne-has-error' : '' ?>">
    1731    <th scope="row"><?= $title ?></th>
    1832    <td>
    19         <?php foreach ($items as $key => $title) { ?>
    20             <label>
    21                 <input type="checkbox" name="form[<?= $field ?>][]" value="<?= $key ?>" <?= in_array($key, (array)$model->{$field}) ? 'checked' : '' ?>>
    22                 <?= esc_html($title) ?>
    23             </label><br>
    24         <?php } ?>
     33        <div class="checkbox-list">
     34            <?php foreach ($items as $key => $title) { ?>
     35                <label>
     36                    <input type="checkbox" name="form[<?= $field ?>][]" value="<?= $key ?>" <?= in_array($key, (array)$model->{$field}) ? 'checked' : '' ?>>
     37                    <?= esc_html($title) ?>
     38                </label>
     39            <?php } ?>
     40        </div>
    2541        <?php if ($model->has_error($field)) { ?>
    2642            <div class="wpne-error"><?= esc_html($model->get_error($field)) ?></div>
  • notify-events/trunk/views/event/index.php

    r2532490 r2919893  
    1515?>
    1616
    17 <style type="text/css">
     17<style>
    1818    .column-enabled {
    1919        width: 10%;
     
    3434        flex-wrap: wrap;
    3535    }
    36     .event-list .button {
    37         width: 30%;
    38         margin: 2px;
     36    .event-list .event-list-item {
     37        width: 33.33%;
     38        padding: 2px;
     39        box-sizing: border-box;
     40    }
     41    .event-list .event-list-item .button {
     42        width: 100%;
    3943    }
    4044    .contact_us {
     
    4953    <?php $events->display() ?>
    5054
    51     <div id="wpne-event-create" class="wpne-modal-form" data-title="<?= esc_attr(__('Select event type', WPNE)) ?>" data-width="500" data-height="400">
     55    <div id="wpne-event-create" class="wpne-modal-form" data-title="<?= esc_attr(__('Select event type', WPNE)) ?>" data-width="650" data-height="400">
    5256        <div class="module-list">
    5357            <?php foreach ($modules as $module) { ?>
     
    6266                                <div class="event-list">
    6367                                    <?php foreach ($events as $event) { ?>
    64                                         <?= Html::a($event::event_title(), [
    65                                             'controller' => 'event',
    66                                             'action'     => 'create',
    67                                             'event'      => rawurlencode($event),
    68                                         ], [
    69                                             'class' => 'button',
    70                                         ]) ?>
     68                                        <div class="event-list-item">
     69                                            <?= Html::a($event::event_title(), [
     70                                                'controller' => 'event',
     71                                                'action'     => 'create',
     72                                                'event'      => rawurlencode($event),
     73                                            ], [
     74                                                'class' => 'button',
     75                                            ]) ?>
     76                                        </div>
    7177                                    <?php } ?>
    7278                                </div>
Note: See TracChangeset for help on using the changeset viewer.