add convert subject, copyrightnotice
This commit is contained in:
@@ -32,6 +32,8 @@ function mvp_admin() {
|
|||||||
'author' => $_POST['author'],
|
'author' => $_POST['author'],
|
||||||
'author-byline' => $_POST['author-byline'],
|
'author-byline' => $_POST['author-byline'],
|
||||||
'display-copyright' => $_POST['display-copyright'],
|
'display-copyright' => $_POST['display-copyright'],
|
||||||
|
'convert-keywords' => $_POST['convert-keywords'],
|
||||||
|
'convert-services' => $_POST['convert-services'],
|
||||||
'subject-type' => $_POST['subject-type'],
|
'subject-type' => $_POST['subject-type'],
|
||||||
'category' => $_POST['category'],
|
'category' => $_POST['category'],
|
||||||
);
|
);
|
||||||
@@ -48,6 +50,8 @@ function mvp_admin() {
|
|||||||
'author' => '',
|
'author' => '',
|
||||||
'author-byline' => '',
|
'author-byline' => '',
|
||||||
'display-copyright' => '',
|
'display-copyright' => '',
|
||||||
|
'convert-keywords' => '',
|
||||||
|
'convert-services' => '',
|
||||||
'subject-type' => '',
|
'subject-type' => '',
|
||||||
'category' => '',
|
'category' => '',
|
||||||
);
|
);
|
||||||
@@ -187,6 +191,54 @@ function mvp_admin() {
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">
|
||||||
|
Convert slugline keywords into WP tags
|
||||||
|
</th>
|
||||||
|
<td>
|
||||||
|
<fieldset>
|
||||||
|
<label for="off">
|
||||||
|
<input type="radio" name="convert-keywords" id="off" value="off"<?php
|
||||||
|
if ($settings['convert-keywords'] == 'off') {
|
||||||
|
echo(' checked');
|
||||||
|
}
|
||||||
|
?>> off
|
||||||
|
</label>
|
||||||
|
<br>
|
||||||
|
<label for="on">
|
||||||
|
<input type="radio" name="convert-keywords" id="on" value="on"<?php
|
||||||
|
if ($settings['convert-keywords'] == 'on') {
|
||||||
|
echo(' checked');
|
||||||
|
}
|
||||||
|
?>> on
|
||||||
|
</label>
|
||||||
|
</fieldset>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">
|
||||||
|
Convert services as Category
|
||||||
|
</th>
|
||||||
|
<td>
|
||||||
|
<fieldset>
|
||||||
|
<label for="off">
|
||||||
|
<input type="radio" name="convert-services" id="off" value="off"<?php
|
||||||
|
if ($settings['convert-services'] == 'off') {
|
||||||
|
echo(' checked');
|
||||||
|
}
|
||||||
|
?>> off
|
||||||
|
</label>
|
||||||
|
<br>
|
||||||
|
<label for="on">
|
||||||
|
<input type="radio" name="convert-services" id="on" value="on"<?php
|
||||||
|
if ($settings['convert-services'] == 'on') {
|
||||||
|
echo(' checked');
|
||||||
|
}
|
||||||
|
?>> on
|
||||||
|
</label>
|
||||||
|
</fieldset>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">
|
<th scope="row">
|
||||||
Import Superdesk subjects as
|
Import Superdesk subjects as
|
||||||
|
|||||||
29
autoload.php
29
autoload.php
@@ -5,8 +5,8 @@ require_once '../../../wp-load.php';
|
|||||||
$json = file_get_contents('php://input');
|
$json = file_get_contents('php://input');
|
||||||
//$json = file_get_contents('log.txt');
|
//$json = file_get_contents('log.txt');
|
||||||
|
|
||||||
//file_put_contents('log.txt', $json . "\n\n", FILE_APPEND);
|
file_put_contents('log.txt', $json . "\n\n", FILE_APPEND);
|
||||||
//die();
|
|
||||||
$obj = json_decode($json, true);
|
$obj = json_decode($json, true);
|
||||||
|
|
||||||
if ($obj['type'] == 'composite') {
|
if ($obj['type'] == 'composite') {
|
||||||
@@ -16,8 +16,8 @@ if ($obj['type'] == 'composite') {
|
|||||||
if ($obj['pubstatus'] == 'usable') {
|
if ($obj['pubstatus'] == 'usable') {
|
||||||
$content = $obj['description_html'] . "<!--more-->" . $obj['body_html'];
|
$content = $obj['description_html'] . "<!--more-->" . $obj['body_html'];
|
||||||
|
|
||||||
if ($settings['display-copyright'] == "on") {
|
if ($settings['display-copyright'] == "on" && isset($obj['associations']['featuremedia']['copyrightnotice'])) {
|
||||||
$content.= ""; // $obj['copyrightnotice']
|
$content.= "<p>" . wp_strip_all_tags($obj['associations']['featuremedia']['copyrightnotice']) . "</p>";
|
||||||
}
|
}
|
||||||
|
|
||||||
$guid = wp_strip_all_tags($obj['guid']);
|
$guid = wp_strip_all_tags($obj['guid']);
|
||||||
@@ -58,10 +58,27 @@ if ($obj['type'] == 'composite') {
|
|||||||
$author_id = $settings['author'];
|
$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') {
|
if ($settings['subject-type'] == 'tags') {
|
||||||
$taxonomyTag[] = wp_strip_all_tags($service['name']);
|
$taxonomyTag[] = wp_strip_all_tags($subject['name']);
|
||||||
} elseif ($settings['subject-type'] == 'categories') {
|
} 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']) . "'");
|
$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) {
|
if ($categoryExist) {
|
||||||
|
|||||||
Reference in New Issue
Block a user