Passed
Pull Request — master (#48)
by
unknown
04:00
created

WC_Pagantis_Ajax::add_ajax_events()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 8
c 1
b 0
f 0
nc 3
nop 0
dl 0
loc 12
rs 10
1
<?php
2
3
if (! defined('ABSPATH')) {
4
    exit;
5
}
6
7
class WC_Pagantis_Ajax extends WC_AJAX
0 ignored issues
show
Bug introduced by
The type WC_AJAX was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
{
9
10
    /**
11
     * Hook in ajax handlers.
12
     */
13
    public static function init()
14
    {
15
        self::add_ajax_events();
16
    }
17
18
    /**
19
     * Hook in methods - uses WordPress ajax handlers (admin-ajax).
20
     *
21
     * @see WC_AJAX
22
     */
23
    public static function add_ajax_events()
24
    {
25
        $ajax_events = array('pagantis_checkout');
26
        foreach ($ajax_events as $ajax_event => $nopriv) {
27
            add_action('wp_ajax_woocommerce_' . $ajax_event, array(__CLASS__, $ajax_event));
0 ignored issues
show
Bug introduced by
The function add_action was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

27
            /** @scrutinizer ignore-call */ 
28
            add_action('wp_ajax_woocommerce_' . $ajax_event, array(__CLASS__, $ajax_event));
Loading history...
28
            if ($nopriv) {
29
                add_action(
30
                    'wp_ajax_nopriv_woocommerce_' . $ajax_event,
31
                    array(__CLASS__, $ajax_event)
32
                );
33
                // WC AJAX can be used for frontend ajax requests.
34
                add_action('wc_ajax_' . $ajax_event, array(__CLASS__, $ajax_event));
35
            }
36
        }
37
    }
38
39
40
    /**
41
     * Check for WC Ajax request and fire action.
42
     */
43
    public static function pagantis_checkout()
44
    {
45
    }
46
}
47
48
WC_Pagantis_Ajax::init();
49