diff --git a/admin/admin.php b/admin/admin.php index b834fdb..64fabdd 100644 --- a/admin/admin.php +++ b/admin/admin.php @@ -32,6 +32,8 @@ function mvp_admin() { 'author' => $_POST['author'], 'author-byline' => $_POST['author-byline'], 'display-copyright' => $_POST['display-copyright'], + 'convert-keywords' => $_POST['convert-keywords'], + 'convert-services' => $_POST['convert-services'], 'subject-type' => $_POST['subject-type'], 'category' => $_POST['category'], ); @@ -48,6 +50,8 @@ function mvp_admin() { 'author' => '', 'author-byline' => '', 'display-copyright' => '', + 'convert-keywords' => '', + 'convert-services' => '', 'subject-type' => '', 'category' => '', ); @@ -187,6 +191,54 @@ function mvp_admin() { +
" . wp_strip_all_tags($obj['associations']['featuremedia']['copyrightnotice']) . "
"; } $guid = wp_strip_all_tags($obj['guid']); @@ -58,10 +58,27 @@ if ($obj['type'] == 'composite') { $author_id = $settings['author']; } - foreach ($obj['service'] as $service) { + if ($settings['convert-keywords'] && $settings['convert-keywords'] == 'on') { + + } + + foreach ($obj['subject'] as $subject) { if ($settings['subject-type'] == 'tags') { - $taxonomyTag[] = wp_strip_all_tags($service['name']); + $taxonomyTag[] = wp_strip_all_tags($subject['name']); } elseif ($settings['subject-type'] == 'categories') { + $categoryExist = $wpdb->get_row("SELECT terms.term_id, term_taxonomy.term_taxonomy_id FROM " . $wpdb->prefix . "terms terms JOIN " . $wpdb->prefix . "term_taxonomy term_taxonomy ON term_taxonomy.term_id = terms.term_id WHERE term_taxonomy.taxonomy = 'category' AND terms.name = '" . wp_strip_all_tags($subject['name']) . "'"); + + if ($categoryExist) { + $taxonomyCategory[] = $categoryExist->term_taxonomy_id; + } else { + $category_id = wp_insert_term(wp_strip_all_tags($subject['name']), 'category'); + $taxonomyCategory[] = $category_id['term_taxonomy_id']; + } + } + } + + if ($settings['convert-services'] == 'on') { + foreach ($obj['service'] as $service) { $categoryExist = $wpdb->get_row("SELECT terms.term_id, term_taxonomy.term_taxonomy_id FROM " . $wpdb->prefix . "terms terms JOIN " . $wpdb->prefix . "term_taxonomy term_taxonomy ON term_taxonomy.term_id = terms.term_id WHERE term_taxonomy.taxonomy = 'category' AND terms.name = '" . wp_strip_all_tags($service['name']) . "'"); if ($categoryExist) {