• Resolved tritongr

    (@tritongr)


    Hi

    Thank you again for this so useful/easy/free plugin for quizes.

    I saw some relative posts where you mention restricted use of html tags because of security issues but finally allow some tags like sub sup… for answers.

    Here are my 2 questions/requests:

    • Is it possible to enter br (brake line) html tag on header/question?
    • Is it possible to enter superscript sup html tag on header/question?

    I need html coding on question not on answers.

    This is just a question and not crucial request.

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Harmonic Design

    (@harmonic_design)

    Hi tritongr,
    The “question” uses WordPress’ sanitize_text_field() function, meaning that it strips all tags for security. However, it uses the default get_the_title() function to display. What this means is that when it saves a title, it strips out any tags, but when it displays the title, it will only strip out things that you cannot use in a post or page title.

    STEP 1: test!
    I don’t have time to test myself right now (and cannot remember off hand what tags WordPress allows by default), but first, create a normal post or page, and set the title of that post or page to something that uses <br/> and <sup> tags. Preview the post or page and see how the title displays. If WordPress strips out those tags, then I’m afraid we might be out of luck for an “easy” solution. If, however, WordPress does not strip the tags, then there is an easy (and temporary) solution for you below.

    STEP 2: modify!
    If you are comfortable editing some code, you can edit one line of the /includes/functions.php file to get this working for you until I code in a permanent solution. Just please note that the following removes sanitation for the question title – so be careful about what you use as titles and make sure only people you absolutely trust have access.

    Line 491
    $title = sanitize_text_field($_POST['title']);
    becomes
    $title = $_POST['title'];

    That’s it! It should for you now.

    Thread Starter tritongr

    (@tritongr)

    Everything worked!

    Your answers are always clear and easy to follow.

    After changing the 491 line as you suggested, I was able to enter <br />, <sup> and <u> tags in the question area.

    Thank you!

    Thread Starter tritongr

    (@tritongr)

    Allow me a relative question.

    Do you think it is possible to inject/concatenate somehow somewhere near the question_id the <span style="color:red;"> or in css, in order to have the question’s hash and number in red?

    Thanks

    Plugin Author Harmonic Design

    (@harmonic_design)

    I got you friend!

    Add the following jQuery and CSS to the footer of your site.

    
    <script>
    jQuery(document).ready(function() {
      jQuery(".hdq_question h3").each(function() {
        let hdq_title = jQuery(this).html();
        hdq_title = hdq_title.split("#");
        if (hdq_title.length === 1) {
          // question as a title
          hdq_title = hdq_title[0];
        } else {
          // numbered question
          hdq_title = hdq_title.join("#");
          hdq_title = hdq_title.split(" ");
          let hdq_title_new =
            '<span class = "hdq_question_tile_number">' + hdq_title[0] + "</span> ";
          hdq_title.shift();
          hdq_title = hdq_title.join(" ");
          hdq_title = hdq_title_new + hdq_title;
        }
        jQuery(this).html(hdq_title);
      });
    });
    </script>
    <style>.hdq_question_tile_number {color:red}</style>
    
    Thread Starter tritongr

    (@tritongr)

    This is magic!

    Yes now all numbering is red.

    This is really premium level support

    Thanks a lot!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘html tags’ is closed to new replies.