mehrshaddarzi / wp-trait

Fast and standard development of WordPress plugins
MIT License
15 stars 5 forks source link

Update Model.php #61

Closed midweste closed 7 months ago

midweste commented 7 months ago

Check to see if arg[1] exists to avoid warning of index not existing

I had a set of actions that were defined as follows:

    public $actions = [
        'init' => 'actions_init',
        'woocommerce_loaded' => 'actions_woocommerce_loaded',
        'woocommerce_archive_description' => 'actions_woocommerce_archive_description',
        'pre_get_posts' => ['actions_pre_get_posts'],
        'woocommerce_process_shop_coupon_meta' => ['actions_woocommerce_process_shop_coupon_meta', PHP_INT_MAX, 2],
    ];

The pre_get_posts action was triggering a warning for $arg[1] not being present. I likely had previously defined the priority but later removed it leaving just the action in an array, but without a priority