• Carin

    (@sparksfreebies)


    I tried this in both my child theme and parent theme but html options still show in Editor for Ad Description. Is there a new way?

    add_filter( "adverts_form_load", function( $form ) {
      if( $form["name"] != "advert" ) {
        return $form;
      }
      foreach( $form["field"] as $k => $field ) {
        if( $field["name"] == "post_content" ) {
          $form["field"][$k]["filter"] = array( array( "name" => "strip_tags" ) );
        }
      }
      return $form;
    } );
    add_action( "init", function( ) {
      adverts_form_add_filter( "strip_tags", array( 
        "description" => "strip_tags", 
        "callback" => "strip_tags" 
      ) );
    } );
Viewing 1 replies (of 1 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    the code you pasted only removes the HTML tags from the Ad preview and details page but it does not prevent the user from entering it in the text editor.

    If you would like to disable the text editor and use the textarea field instead then you can do that by modifying the first part of the code to look like this

    
    add_filter( "adverts_form_load", function( $form ) {
      if( $form["name"] != "advert" ) {
        return $form;
      }
      foreach( $form["field"] as $k => $field ) {
        if( $field["name"] == "post_content" ) {
          $form["field"][$k]["mode"] = "plain-text";
          $form["field"][$k]["filter"] = array( array( "name" => "strip_tags" ) );
        }
      }
      return $form;
    } );
    
Viewing 1 replies (of 1 total)

The topic ‘disable html in description’ is closed to new replies.