1 | <?php |
||||
2 | /** |
||||
3 | * Helper functions |
||||
4 | * |
||||
5 | * @package lsx_wetu_importer |
||||
6 | * @author LightSpeed |
||||
7 | * @license GPL-2.0+ |
||||
8 | * @link |
||||
9 | * @copyright 2019 LightSpeed |
||||
10 | **/ |
||||
11 | |||||
12 | /** |
||||
13 | * Gets the settings |
||||
14 | * |
||||
15 | * @return array |
||||
16 | */ |
||||
17 | function lsx_wetu_get_options() { |
||||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||||
18 | $options = get_option( 'lsx_wetu_importer_settings', array() ); |
||||
19 | if ( empty( $options ) ) { |
||||
0 ignored issues
–
show
|
|||||
20 | // Check for any previous options. |
||||
21 | $temp_options = get_option( '_lsx-to_settings', false ); |
||||
22 | if ( false !== $temp_options && isset( $temp_options['lsx-wetu-importer'] ) && ! empty( $temp_options['lsx-wetu-importer'] ) ) { |
||||
0 ignored issues
–
show
|
|||||
23 | $options = $temp_options['lsx-wetu-importer']; |
||||
24 | } |
||||
0 ignored issues
–
show
|
|||||
25 | if ( false !== $temp_options && isset( $temp_options['api']['wetu_api_key'] ) && '' !== $temp_options['api']['wetu_api_key'] ) { |
||||
0 ignored issues
–
show
|
|||||
26 | $options['api_key'] = $temp_options['api']['wetu_api_key']; |
||||
27 | } |
||||
28 | } |
||||
0 ignored issues
–
show
|
|||||
29 | return $options; |
||||
30 | } |
||||
0 ignored issues
–
show
|
|||||
31 | |||||
32 | /** |
||||
33 | * Get the post count. |
||||
34 | * |
||||
35 | * @param string $post_type |
||||
0 ignored issues
–
show
|
|||||
36 | * @param string $post_status |
||||
0 ignored issues
–
show
|
|||||
37 | * @return void |
||||
0 ignored issues
–
show
|
|||||
38 | */ |
||||
39 | function lsx_wetu_get_post_count( $post_type = '', $post_status = '' ) { |
||||
40 | global $wpdb; |
||||
41 | $count = '0'; |
||||
42 | if ( '' !== $post_type && '' !== $post_status ) { |
||||
0 ignored issues
–
show
|
|||||
43 | $result = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(`ID`) FROM $wpdb->posts WHERE `post_status` = '%s' AND `post_type` = '%s'", array( trim( $post_status ), $post_type ) ) ); |
||||
0 ignored issues
–
show
|
|||||
44 | if ( false !== $result && '' !== $result ) { |
||||
0 ignored issues
–
show
|
|||||
45 | if ( 'tour' === $post_type ) { |
||||
0 ignored issues
–
show
|
|||||
46 | $wetu_tours = get_transient( 'lsx_ti_tours' ); |
||||
47 | if ( false !== $wetu_tours ) { |
||||
0 ignored issues
–
show
|
|||||
48 | $results = $wpdb->get_results( $wpdb->prepare( "SELECT `ID` FROM $wpdb->posts WHERE `post_status` = '%s' AND `post_type` = '%s'", array( trim( $post_status ), $post_type ) ) ); |
||||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 7 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. ![]() |
|||||
49 | $result_count = 0; |
||||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. ![]() |
|||||
50 | $tour_wetu_ids = array(); |
||||
51 | foreach ( $wetu_tours as $wetu_tour ) { |
||||
0 ignored issues
–
show
|
|||||
52 | $tour_wetu_ids[] = $wetu_tour['identifier']; |
||||
53 | } |
||||
54 | |||||
55 | if ( ! empty( $results ) ) { |
||||
0 ignored issues
–
show
|
|||||
56 | foreach ( $results as $tour ) { |
||||
0 ignored issues
–
show
|
|||||
57 | $current_wetu_id = get_post_meta( $tour->ID, 'lsx_wetu_id', true ); |
||||
58 | if ( in_array( $current_wetu_id, $tour_wetu_ids ) ) { |
||||
0 ignored issues
–
show
|
|||||
59 | $result_count++; |
||||
60 | } |
||||
61 | } |
||||
62 | } |
||||
0 ignored issues
–
show
|
|||||
63 | $result = $result_count; |
||||
64 | } else { |
||||
65 | $result = 0; |
||||
66 | } |
||||
67 | } |
||||
0 ignored issues
–
show
|
|||||
68 | $count = $result; |
||||
69 | } |
||||
70 | } |
||||
0 ignored issues
–
show
|
|||||
71 | return $count; |
||||
72 | } |
||||
0 ignored issues
–
show
|
|||||
73 | |||||
74 | /** |
||||
75 | * Returns the wetu queue count. |
||||
76 | * |
||||
77 | * @param string $post_type |
||||
0 ignored issues
–
show
|
|||||
78 | * @return void |
||||
0 ignored issues
–
show
|
|||||
79 | */ |
||||
80 | function lsx_wetu_get_queue_count( $post_type = '' ) { |
||||
81 | $count = '0'; |
||||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 10 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. ![]() |
|||||
82 | $queued_imports = get_option( 'lsx_wetu_importer_que', array() ); |
||||
83 | if ( isset( $queued_imports[ $post_type ] ) ) { |
||||
0 ignored issues
–
show
|
|||||
84 | $count = count( $queued_imports[ $post_type ] ); |
||||
85 | } |
||||
0 ignored issues
–
show
|
|||||
86 | return $count; |
||||
87 | } |
||||
0 ignored issues
–
show
|
|||||
88 | |||||
89 | /** |
||||
90 | * Returns the wetu tour count. |
||||
91 | * |
||||
92 | * @param string $post_type |
||||
0 ignored issues
–
show
|
|||||
93 | * @return void |
||||
0 ignored issues
–
show
|
|||||
94 | */ |
||||
95 | function lsx_wetu_get_tour_count( $post_type = '' ) { |
||||
96 | $count = '0'; |
||||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. ![]() |
|||||
97 | $wetu_tours = get_transient( 'lsx_ti_tours', array() ); |
||||
0 ignored issues
–
show
The call to
get_transient() has too many arguments starting with array() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above. ![]() |
|||||
98 | if ( ! empty( $wetu_tours ) ) { |
||||
0 ignored issues
–
show
|
|||||
99 | $count = count( $wetu_tours ); |
||||
100 | } |
||||
0 ignored issues
–
show
|
|||||
101 | return $count; |
||||
102 | } |
||||
0 ignored issues
–
show
|
|||||
103 |