Conditions | 2 |
Paths | 2 |
Total Lines | 24 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
57 | public function search( $key, $query ) |
||
58 | { |
||
59 | $options['key'] = $key; |
||
60 | $options['q'] = $query; |
||
61 | |||
62 | $url = add_query_arg( array( |
||
63 | 'key' => $key, |
||
64 | 'q' => $query, |
||
65 | ), self::API_ROOT ); |
||
66 | |||
67 | $transient_key = 'foogallery-pixabay-' . esc_attr($query); |
||
68 | |||
69 | if ( false === ( $response_data = get_transient( $transient_key ) ) ) { |
||
70 | $response = wp_remote_get( esc_url( $url ) ); |
||
71 | $response_data = wp_remote_retrieve_body( $response ); |
||
72 | |||
73 | $expires = 60 * 60 * 24; //cache for 24 hours |
||
74 | |||
75 | //Cache the result |
||
76 | set_transient( $transient_key, $response_data, $expires ); |
||
77 | } |
||
78 | |||
79 | return json_decode( $response_data, false ); |
||
80 | } |
||
81 | } |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.