• Meeker

    (@meeker)


    Hi there, I have created a custom options page, however it is stripping all html tags from a wysiwyg editor field:

    require_once('RationalOptionPages.php');
    $pages = array(
        'example'   => array(
            'page_title'    => __( 'Example1', 'example' ),
            'sections'      => array(
                'optionshome'   => array(
                    'title'         => __( 'HomePageOptions', 'example' ),
                    'fields'        => array(
                        ),
                        'examplefieldone'       => array(
                            'title'         => __( 'examplefieldone', 'example' ),
    						'type'	=> 'wp_editor',
                        ),				
                    ),
                ),
            ),
        ),
    );
    $option_page = new RationalOptionPages( $pages );

    Any ideas how to prevent this wysiwyg editor from stripping tags here?

Viewing 1 replies (of 1 total)
  • Thread Starter Meeker

    (@meeker)

    I have discovered that altering RationalOptionPages.php is getting closer. This section cleans up the options page code:

    	protected function sanitize_setting( $page_key, $input ) {
    		$page = $this->pages[ $page_key ];
    		
    		if ( !empty( $page['sections'] ) ) {
    			foreach ( $page['sections'] as $section ) {
    				if ( !empty( $section['fields'] ) ) {
    					foreach ( $section['fields'] as $field ) {
    						switch ( $field['type'] ) {
    							case 'checkbox':
    								if ( empty( $input[ $field['id'] ] ) ) {
    									$input[ $field['id'] ] = false;
    								}
    								break;
    							default:
    								$input[ $field['id'] ] = strip_tags($input[ $field['id'] ]);
    								$input[ $field['id'] ] = esc_attr($input[ $field['id'] ]);								
    						}
    					}
    				}
    			}
    		}
    		
    		return $input;
    	}

    However, if I remove strip_tags, then this does indeed stop the tag stripping, but then substitudes all the tags for special characters as follows:

    1. abc

    Any ideas?

    • This reply was modified 8 years ago by Meeker.
    • This reply was modified 8 years ago by Meeker.
Viewing 1 replies (of 1 total)
  • The topic ‘Stop Options Page stripping tags’ is closed to new replies.