Changeset 63 for trunk/blocks
- Timestamp:
- Jan 6, 2009, 1:18:31 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/blocks/block_common.php
r35 r63 21 21 function dropdown_cats_options($sort_column = 'ID', $sort_order = 'asc', $selected=array()) 22 22 { 23 global $wpdb, $wp_query, $wp_rewrite, $wp_roles; 24 25 $path = dirname(dirname(__FILE__)) . '/'; 26 if (file_exists($path . 'wp-load.php')) { 27 require_once $path . 'wp-load.php'; 23 $mydirpath = dirname(dirname(__FILE__)); 24 $mydirname = basename( dirname( dirname( __FILE__ ) ) ) ; 25 if ($mydirname == 'wordpress'){ 26 $wp_prefix = 'wp_'; 28 27 } else { 29 require_once $path . 'wp-config.php';28 $wp_prefix = $mydirname . '_'; 30 29 } 31 30 $xoopsDB =& Database::getInstance(); 32 31 $myts =& MyTextSanitizer::getInstance(); 33 32 $selected = is_array($selected)?$selected:array($selected); 34 33 $sort_column = 'cat_'.$sort_column; 34 include $mydirpath.'/wp-includes/version.php'; 35 35 if ($wp_db_version < 6124) { 36 $db_xpress_categories = $xoopsDB->prefix($wp_prefix . 'categories'); 36 37 $query = " 37 38 SELECT cat_ID, cat_name, category_nicename,category_parent 38 FROM $ wpdb->categories39 FROM $db_xpress_categories 39 40 WHERE cat_ID > 0 40 41 "; 41 $query .= " ORDER BY $sort_column $sort_order";42 $query .= " ORDER BY $sort_column $sort_order"; 42 43 43 44 } else { 45 $db_xpress_terms = $xoopsDB->prefix($wp_prefix . 'terms'); 46 $db_xpress_term_taxonomy = $xoopsDB->prefix($wp_prefix . 'term_taxonomy'); 44 47 $query = " 45 SELECT $ wpdb->terms.term_id as cat_ID , $wpdb->terms.name as cat_name , $wpdb->term_taxonomy.taxonomy46 FROM $ wpdb->terms LEFT JOIN $wpdb->term_taxonomy ON $wpdb->terms.term_id = $wpdb->term_taxonomy.term_id47 WHERE $ wpdb->term_taxonomy.taxonomy = 'category'48 SELECT $db_xpress_terms.term_id as cat_ID , $db_xpress_terms.name as cat_name , $db_xpress_term_taxonomy.taxonomy 49 FROM $db_xpress_terms LEFT JOIN $db_xpress_term_taxonomy ON $db_xpress_terms.term_id = $db_xpress_term_taxonomy.term_id 50 WHERE $db_xpress_term_taxonomy.taxonomy = 'category' 48 51 "; 49 52 $query .= " ORDER BY $sort_column $sort_order"; 50 53 } 51 52 $categories = $wpdb->get_results($query);53 if ($categories){54 foreach ($categories as $category) {55 $cat_ name = apply_filters('list_cats', $category->cat_name, $category);56 echo "\t<option value=\"".$cat egory->cat_ID."\"";57 if (in_array($cat egory->cat_ID, $selected))54 $res = $xoopsDB->query($query, 0, 0); 55 if ($res !== false){ 56 while($row = $xoopsDB->fetchArray($res)){ 57 $cat_name = $row['cat_name']; 58 $cat_ID = $row['cat_ID']; 59 echo "\t<option value=\"".$cat_ID."\""; 60 if (in_array($cat_ID, $selected)) 58 61 echo ' selected="selected"'; 59 62 echo '>';
Note: See TracChangeset
for help on using the changeset viewer.