I have this issue, where I have made a function on my wordpress website (under Theme Functions.php), which then uses a shortcode to present on the front end. Now, I want to obfuscate the shortcode, as it contains some info which I do not want displayed. I am able to complete the obfuscation, but when I copy and paste it into the page of my website, it displays as the shortcode, meaning that the shortcode does not "execute".

Here is my function:

function question_func_wpse_88192($atts, $content = null ){
extract( shortcode_atts( array(
    'text' => '',
    'answer' => '',
    'message' => 'Right answer!',
    'messageid' => 'message', 
), $atts ) );

// format input:

// inline js:

// html output:
$output  = "<div class=\"question\">";
$output .= "<span class=\"question_text\">".$text."</span>";
$output .= "<input type=\"text\" class=\"question_input\"";
$output .= " onkeyup=\"".$onkeyup."\" />";
$output .= "<span id=\"".$messageid."\" class=\"question_message\" style=\"display:none;\">".$message."</span>";
$output .= "</div>";

return $output;

Here is my shortcode:

[question text="What has four legs?" answer="Horse" message="Right answer!" 
messageid="message1" ]

Is there a way to obfuscate this shortcode without making it not function like it would without obfuscation? If not, is there a way where I can do a textbox validation (like a PHP form?). I need to have a textbox, which if some value is inputted, with result in either an error message, or a correct message.

Thanks, and if any clarification is needed, just ask!


Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.