This commit is contained in:
Filip Penkava
2017-04-12 11:45:41 +02:00
parent dfc39c44ca
commit 229b85424c
2 changed files with 59 additions and 0 deletions

View File

@@ -44,6 +44,9 @@ function superdesk_admin() {
'copyrightholder-image' => $_POST['copyrightholder-image'], 'copyrightholder-image' => $_POST['copyrightholder-image'],
'copyrightnotice-image' => $_POST['copyrightnotice-image'], 'copyrightnotice-image' => $_POST['copyrightnotice-image'],
'separator-located' => $_POST['separator-located'], 'separator-located' => $_POST['separator-located'],
'convert-slugline' => $_POST['convert-slugline'],
'slugline-separator' => $_POST['slugline-separator'],
'slugline-ignored' => $_POST['slugline-ignored'],
); );
update_option('superdesk_settings', $settings); update_option('superdesk_settings', $settings);
} else if (get_option('superdesk_settings')) { } else if (get_option('superdesk_settings')) {
@@ -68,6 +71,9 @@ function superdesk_admin() {
'copyrightholder-image' => '', 'copyrightholder-image' => '',
'copyrightnotice-image' => '', 'copyrightnotice-image' => '',
'separator-located' => '', 'separator-located' => '',
'convert-slugline' => '',
'slugline-separator' => '',
'slugline-ignored' => '',
); );
} }
$statuses = array( $statuses = array(
@@ -393,6 +399,46 @@ function superdesk_admin() {
<input type="text" name="separator-located" id="separator-located" class="regular-text" value="<?php echo($settings['separator-located']); ?>"> <input type="text" name="separator-located" id="separator-located" class="regular-text" value="<?php echo($settings['separator-located']); ?>">
</td> </td>
</tr> </tr>
<tr>
<th scope="row">
Convert slugline keywords into WP tags
</th>
<td>
<fieldset>
<label for="convert-slugline-off">
<input type="radio" name="convert-slugline" id="convert-slugline-off" value="off"<?php
if ($settings['convert-slugline'] == 'off') {
echo(' checked');
}
?>> off
</label>
<br>
<label for="convert-slugline-on">
<input type="radio" name="convert-slugline" id="convert-slugline-on" value="on"<?php
if ($settings['convert-slugline'] == 'on') {
echo(' checked');
}
?>> on
</label>
</fieldset>
</td>
</tr>
<tr>
<th scope="row">
<label for="slugline-separator">Slugline value separator</label>
</th>
<td>
<input type="text" name="slugline-separator" id="slugline-separator" class="regular-text" value="<?php echo($settings['slugline-separator']); ?>">
</td>
</tr>
<tr>
<th scope="row">
<label for="slugline-ignored">Keywords to be ignored</label>
</th>
<td>
<input type="text" name="slugline-ignored" id="slugline-ignored" class="regular-text" value="<?php echo($settings['slugline-ignored']); ?>">
</td>
</tr>
</tbody> </tbody>
</table> </table>
<p class="submit"> <p class="submit">

View File

@@ -40,6 +40,19 @@ if ($obj['type'] == 'text') {
} }
} }
if ($settings['convert-slugline'] && $settings['convert-slugline'] == 'on') {
if (isset($obj['slugline']) && !empty($obj['slugline'])) {
$ignoreKeywords = explode(',', $settings['slugline-ignored']);
$tmpKeywords = explode($settings['slugline-separator'], $obj['slugline']);
foreach ($tmpKeywords as $word) {
if (!in_array($word, $ignoreKeywords)) {
$taxonomyTag[] = $word;
}
}
}
}
foreach ($obj['subject'] as $subject) { foreach ($obj['subject'] as $subject) {
if ($settings['subject-type'] == 'tags') { if ($settings['subject-type'] == 'tags') {
$taxonomyTag[] = wp_strip_all_tags($subject['name']); $taxonomyTag[] = wp_strip_all_tags($subject['name']);