Skip to content

Commit dd901fd

Browse files
committed
Special chars fix. Closes #1 and #3.
1 parent be5e310 commit dd901fd

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

wordpress-custom-fields-permalink-plugin.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ class CustomFieldsPermalink {
1212

1313
const PARAM_CUSTOMFIELD_KEY = 'custom_field_key';
1414
const PARAM_CUSTOMFIELD_VALUE = 'custom_field_value';
15+
16+
public static $checkCustomFieldValue = false;
1517

1618
public static function linkPost($permalink, $post, $leavename) {
1719
return self::linkRewriteFields($permalink, $post);
@@ -31,7 +33,11 @@ public static function linkRewriteFieldsExtract($post, $fieldName) {
3133
if(!isset($postMeta[$fieldName]))
3234
return '';
3335

34-
return implode('', $postMeta[$fieldName]);
36+
$value = implode('', $postMeta[$fieldName]);
37+
38+
$value = sanitize_title($value);
39+
40+
return $value;
3541
}
3642

3743
public static function registerExtraQueryVars($value) {
@@ -43,8 +49,12 @@ public static function processRequest($value) {
4349
// additional parameters added to Wordpress
4450
// Main Loop query
4551
$value['meta_key'] = $value[self::PARAM_CUSTOMFIELD_KEY];
46-
$value['meta_value'] = $value[self::PARAM_CUSTOMFIELD_VALUE];
47-
52+
53+
// do not check field's value for this moment
54+
if(true === self::$checkCustomFieldValue) {
55+
$value['meta_value'] = $value[self::PARAM_CUSTOMFIELD_VALUE];
56+
}
57+
4858
// remove temporary injected parameters
4959
unset($value[self::PARAM_CUSTOMFIELD_KEY], $value[self::PARAM_CUSTOMFIELD_VALUE]);
5060

0 commit comments

Comments
 (0)