Function Reference: geodir_event_default_taxonomies
Summary
This function has not been documented yet.
Source File
geodir_event_default_taxonomies() is located in geodir_event_manager/gdevents-admin/admin_functions.php [Line: 204]
Source Code
function geodir_event_default_taxonomies(){ global $wpdb,$dummy_image_path; $category_array = array('Events'); $last_catid = isset($last_catid) ? $last_catid : ''; $last_term = get_term($last_catid, 'gd_eventcategory'); $uploads = wp_upload_dir(); // Array of key => value pairs for($i=0;$i < count($category_array); $i++) { $parent_catid = 0; if(is_array($category_array[$i])) { $cat_name_arr = $category_array[$i]; for($j=0;$j < count($cat_name_arr);$j++) { $catname = $cat_name_arr[$j]; if(!term_exists( $catname, 'gd_eventcategory' )){ $last_catid = wp_insert_term( $catname, 'gd_eventcategory', $args = array('parent'=>$parent_catid) ); if($j==0) { $parent_catid = $last_catid; } if(geodir_event_dummy_folder_exists()) $dummy_image_url = geodir_event_plugin_url() . "/gdevents-admin/dummy/cat_icon"; else $dummy_image_url = 'http://www.wpgeodirectory.com/dummy_event/cat_icon'; $catname = str_replace(' ', '_', $catname); $uploaded = (array)fetch_remote_file("$dummy_image_url/".$catname.".png"); if(empty($uploaded['error'])) { $new_path = $uploaded['file']; $new_url = $uploaded['url']; } $wp_filetype = wp_check_filetype(basename($new_path), null ); $attachment = array( 'guid' => $uploads['baseurl'] . '/' . basename( $new_path ), 'post_mime_type' => $wp_filetype['type'], 'post_title' => preg_replace('/.[^.]+$/', '', basename($new_path)), 'post_content' => '', 'post_status' => 'inherit' ); $attach_id = wp_insert_attachment( $attachment, $new_path ); // you must first include the image.php file // for the function wp_generate_attachment_metadata() to work require_once(ABSPATH . 'wp-admin/includes/image.php'); $attach_data = wp_generate_attachment_metadata( $attach_id, $new_path ); wp_update_attachment_metadata( $attach_id, $attach_data ); if(!get_tax_meta($last_catid['term_id'], 'ct_cat_icon')) {update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array( 'id' => 'icon', 'src' => $new_url));} } } }else { $catname = $category_array[$i]; if(!term_exists( $catname, 'gd_eventcategory' )){ $last_catid = wp_insert_term( $catname, 'gd_eventcategory' ); if(geodir_event_dummy_folder_exists()) $dummy_image_url = geodir_event_plugin_url() . "/gdevents-admin/dummy/cat_icon"; else $dummy_image_url = 'http://www.wpgeodirectory.com/dummy_event/cat_icon'; $catname = str_replace(' ', '_', $catname); $uploaded = (array) fetch_remote_file("$dummy_image_url/".$catname.".png"); if(empty($uploaded['error'])) { $new_path = $uploaded['file']; $new_url = $uploaded['url']; } $wp_filetype = wp_check_filetype(basename($new_path), null ); $attachment = array( 'guid' => $uploads['baseurl'] . '/' . basename( $new_path ), 'post_mime_type' => $wp_filetype['type'], 'post_title' => preg_replace('/.[^.]+$/', '', basename($new_path)), 'post_content' => '', 'post_status' => 'inherit' ); $attach_id = wp_insert_attachment( $attachment, $new_path ); // you must first include the image.php file // for the function wp_generate_attachment_metadata() to work require_once(ABSPATH . 'wp-admin/includes/image.php'); $attach_data = wp_generate_attachment_metadata( $attach_id, $new_path ); wp_update_attachment_metadata( $attach_id, $attach_data ); if(!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_event')) {update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array( 'id' => $attach_id, 'src' => $new_url), 'gd_event');} } } } }