WordPress.org

Forums

Theme Check - eval() is not allowed (2 posts)

  1. v123shine
    Member
    Posted 1 year ago #

    I want to submit my theme to the wordpress directory but they don't allow because I got this error.

    WARNING: Found eval in the file tm_tagline_widget.php. eval() is not allowed.
    Line 37: eval('?>'.$text);

    This is line 37 code content:

    function widget( $args, $instance ) {
        extract($args);
    
        $title = apply_filters( 'widget_title', empty($instance['title']) ? '' : $instance['title'], $instance );
        $tm_bigtagline = htmlspecialchars_decode( $instance[ 'tm_bigtagline' ] );
        $tm_tagline_desctext = htmlspecialchars_decode( $instance[ 'tm_tagline_desctext' ] );
        $text = apply_filters( 'widget_tagline_tmfilter', $instance['text'], $instance );
    
        echo $before_widget;
        if ( !empty( $title ) ) { echo $before_title . $title . $after_title; }
            ob_start();
            eval('?>'.$text);
            $text = ob_get_contents();
            ob_end_clean();
            ?>
            <div class="tmmyid_tagline_list"><?php echo $instance['filter'] ? wpautop($text) : $text; ?></div>
        <?php
        echo $after_widget;
    }

    Can someone help me, Please!

  2. catacaustic
    very awesome
    Posted 1 year ago #

    That warning is pretty self-evident. Remove the eval() statement.

    I have to say, in the context of what you're doing there I can't see what it's actually used for. What's the value for $text when you're trying to eval() it?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags