}
exit;
}
+ public function getCategoryId( $category )
+ {
+ $category_id = $this->wpdb->get_var(
+ $this->wpdb->prepare(
+ "SELECT id
+ FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "categories
+ WHERE name = %d",
+ $category
+ )
+ );
+ if ( $category_id ) {
+ return $category_id;
+ } else {
+ $this->wpdb->insert(
+ GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'categories',
+ array(
+ 'name' => $category,
+ 'parent' => 0
+ ),
+ array(
+ '%s',
+ '%d'
+ )
+ );
+ $category_id = $this->wpdb->insert_id;
+ return $category_id;
+ }
+ }
public function clearData()
{
$this->wpdb->query( "DELETE FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "events" );
$old_image = $this->wpdb->get_var(
$this->wpdb->prepare(
"SELECT image
- FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "
+ FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "events
WHERE id = %d",
$event_id
)
// generate the slug name for this new event
$event_abstract = new GlmDataEvents( $this->wpdb, $this->config );
$event_abstract->updateSlug( $event_id );
+
+ // Categories
+ if ( isset( $event['CATEGORIES'] ) ) {
+ $category_data = explode( ',', $event['CATEGORIES'] );
+ foreach ( $category_data as $category ) {
+ $this->wpdb->insert(
+ GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'event_categories',
+ array(
+ 'event' => $event_id,
+ 'category' => $this->getCategoryId( $category )
+ ),
+ '%d'
+ );
+ }
+ }
// Location Data
if ( isset( $event['LOCATION'] ) ) {
$location_data = explode( ',', str_replace( '\\', '', $event['LOCATION'] ) );