<?php /** * GD Dummy data. * * @since 1.0.0 * @package GeoDirectory */ global $dummy_post_index, $city_bound_lat1, $city_bound_lng1, $city_bound_lat2, $city_bound_lng2; $post_info = array(); $image_array = array(); $post_meta = array(); if (geodir_dummy_folder_exists()) { $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy"; } else { $dummy_image_url = 'http://www.wpgeodirectory.com/dummy'; } switch ($dummy_post_index) { case 1: $image_array[] = "{$dummy_image_url}/a1.jpg"; $image_array[] = "{$dummy_image_url}/a2.jpg"; $image_array[] = "{$dummy_image_url}/a3.jpg"; $image_array[] = "{$dummy_image_url}/a4.jpg"; $image_array[] = "{$dummy_image_url}/a5.jpg"; $image_array[] = "{$dummy_image_url}/a6.jpg"; $image_array[] = "{$dummy_image_url}/a7.jpg"; $image_array[] = "{$dummy_image_url}/a8.jpg"; $image_array[] = "{$dummy_image_url}/a9.jpg"; $image_array[] = "{$dummy_image_url}/a10.jpg"; $image_array[] = "{$dummy_image_url}/a11.jpg"; $post_info[] = array("listing_type" => 'gd_place', "post_title" => 'Franklin Square', "post_desc" => ' <h3> Location </h3>
/** * Default taxonomies * * Adds the default terms for taxonomies - placecategory. Modify at your own risk. * * @since 1.0.0 * @package GeoDirectory * @global object $wpdb WordPress Database object. * @global string $dummy_image_path The dummy image path. */ function geodir_default_taxonomies() { global $wpdb, $dummy_image_path; $category_array = array('Attractions', 'Hotels', 'Restaurants', 'Food Nightlife', 'Festival', 'Videos', 'Feature'); $last_catid = isset($last_catid) ? $last_catid : ''; $last_term = get_term($last_catid, 'gd_placecategory'); $uploads = wp_upload_dir(); // Array of key => value pairs //print_r($uploads) ; 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_placecategory')) { $last_catid = wp_insert_term($catname, 'gd_placecategory', $args = array('parent' => $parent_catid)); if ($j == 0) { $parent_catid = $last_catid; } if (geodir_dummy_folder_exists()) { $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon"; } else { $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/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_place')) { update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => 'icon', 'src' => $new_url), 'gd_place'); } } } } else { $catname = $category_array[$i]; if (!term_exists($catname, 'gd_placecategory')) { $last_catid = wp_insert_term($catname, 'gd_placecategory'); if (geodir_dummy_folder_exists()) { $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon"; } else { $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/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_place')) { update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => $attach_id, 'src' => $new_url), 'gd_place'); } } } } }