synchronize category, rename value form
This commit is contained in:
@@ -145,7 +145,7 @@ function mvp_admin() {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">
|
<th scope="row">
|
||||||
<label for="author">Author</label>
|
<label for="author">Default author</label>
|
||||||
</th>
|
</th>
|
||||||
<td>
|
<td>
|
||||||
<select name="author" id="author">
|
<select name="author" id="author">
|
||||||
@@ -217,7 +217,7 @@ function mvp_admin() {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">
|
<th scope="row">
|
||||||
Convert services as Category
|
Import Superdesk categories as Wordpress categories
|
||||||
</th>
|
</th>
|
||||||
<td>
|
<td>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
@@ -265,7 +265,7 @@ function mvp_admin() {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">
|
<th scope="row">
|
||||||
<label for="category">Category</label>
|
<label for="category">Default category</label>
|
||||||
</th>
|
</th>
|
||||||
<td>
|
<td>
|
||||||
<select name="category[]" id="category" multiple>
|
<select name="category[]" id="category" multiple>
|
||||||
|
|||||||
71
autoload.php
71
autoload.php
@@ -26,6 +26,40 @@ if ($obj['type'] == 'text') {
|
|||||||
$guid = wp_strip_all_tags($obj['guid']);
|
$guid = wp_strip_all_tags($obj['guid']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($obj['subject'] as $subject) {
|
||||||
|
if ($settings['subject-type'] == 'tags') {
|
||||||
|
$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) {
|
||||||
|
$taxonomyCategory[] = $categoryExist->term_taxonomy_id;
|
||||||
|
} else {
|
||||||
|
$category_id = wp_insert_term(wp_strip_all_tags($service['name']), 'category');
|
||||||
|
$taxonomyCategory[] = $category_id['term_taxonomy_id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($taxonomyCategory && !empty($taxonomyCategory)) {
|
||||||
|
$category = $taxonomyCategory;
|
||||||
|
} else {
|
||||||
|
$category = $settings['category'];
|
||||||
|
}
|
||||||
|
|
||||||
$sync = $wpdb->get_row("SELECT post_id FROM " . $wpdb->prefix . DB_TABLE_SYNC_POST . " WHERE guid = '" . $guid . "'");
|
$sync = $wpdb->get_row("SELECT post_id FROM " . $wpdb->prefix . DB_TABLE_SYNC_POST . " WHERE guid = '" . $guid . "'");
|
||||||
|
|
||||||
if ($sync) {
|
if ($sync) {
|
||||||
@@ -35,7 +69,8 @@ if ($obj['type'] == 'text') {
|
|||||||
'post_title' => wp_strip_all_tags($obj['headline']),
|
'post_title' => wp_strip_all_tags($obj['headline']),
|
||||||
'post_name' => wp_strip_all_tags($obj['headline']),
|
'post_name' => wp_strip_all_tags($obj['headline']),
|
||||||
'post_content' => $content,
|
'post_content' => $content,
|
||||||
'post_content_filtered' => $content
|
'post_content_filtered' => $content,
|
||||||
|
'post_category' => $category
|
||||||
);
|
);
|
||||||
|
|
||||||
wp_update_post($edit_post);
|
wp_update_post($edit_post);
|
||||||
@@ -81,40 +116,6 @@ if ($obj['type'] == 'text') {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($obj['subject'] as $subject) {
|
|
||||||
if ($settings['subject-type'] == 'tags') {
|
|
||||||
$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) {
|
|
||||||
$taxonomyCategory[] = $categoryExist->term_taxonomy_id;
|
|
||||||
} else {
|
|
||||||
$category_id = wp_insert_term(wp_strip_all_tags($service['name']), 'category');
|
|
||||||
$taxonomyCategory[] = $category_id['term_taxonomy_id'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($taxonomyCategory && !empty($taxonomyCategory)) {
|
|
||||||
$category = $taxonomyCategory;
|
|
||||||
} else {
|
|
||||||
$category = $settings['category'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$postarr = array(
|
$postarr = array(
|
||||||
'post_title' => wp_strip_all_tags($obj['headline']),
|
'post_title' => wp_strip_all_tags($obj['headline']),
|
||||||
'post_name' => wp_strip_all_tags($obj['headline']),
|
'post_name' => wp_strip_all_tags($obj['headline']),
|
||||||
|
|||||||
Reference in New Issue
Block a user