@@ -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