-
Notifications
You must be signed in to change notification settings - Fork 2
/
QQ.Utils.php
38 lines (32 loc) · 1.53 KB
/
QQ.Utils.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
Class QQ_Utils {
/**
* qq_warn is an interface to PHP's trigger_error function; it will be used to
* provide users will debugging information about how QQ is functioning
*
* @param string $warning_code a string index that corresponds to warning messages
* in $qq_warnings
*/
public static function warn( $warning_code ) {
$qq_warnings = array(
'EMPTY_SET' => 'QQuery has received data that will return an empty set',
'ARR_CONVERSION' => 'QQuery is attempting to convert an unusual object to an array',
'EMPTY_ARR' => 'QQuery has found or generated an empty array',
'NON_OBJECT_RETURNED' => 'WP_Post has been requested, but WP did not return one',
'PAGING_AND_OFFSET_CONFLICT' => 'Using page and offset properties may product unintended results.',
'META_NOT_FOUND' => 'One of the values you provided to extend() is not supported.',
'TERM_NOT_FOUND' => 'The term or taxonomy you were searching for does not exist.'
);
trigger_error( $qq_warnings[$warning_code], E_USER_WARNING);
}
/**
* Utility method
* @param string $tag_slug a term slug (ex: 'government')
* @return object PHP object with one or more term id, name and slug
*/
public static function get_data_for_term( $term_slug ) {
global $wpdb;
$query = 'SELECT wp_terms.term_id, wp_terms.name, wp_terms.slug, taxonomy FROM wp_terms LEFT JOIN wp_term_taxonomy ON wp_terms.`term_id` = wp_term_taxonomy.term_id WHERE wp_terms.`slug` = "' . $term_slug . '"';
return $wpdb->get_results( $query, OBJECT );
}
}