0

I opened a similar topic, but since it is a little confusing, I decided to create a new topic to clarify more. i run the website and i found the errors seems like: Notice: attribute_escape is deprecated since version 2.8! Use esc_attr() instead. in C:\xampp\htdocs\website\wp-includes\functions.php on line 2638 I search and i found some useful information like : When do I need to use esc_attr when using WordPress internal functions , but sorry i am not undearstand.. The errors are in the post title. for example, this is my code of the index.php. Where exactly are the errors?

<?php get_header(); ?>          
    <div id="main" class="container_12">    
        <div id="content" class="grid_9 alpha">                 
            <?php query_posts( 'posts_per_page=6' );?>      
            <?php if (have_posts()) : while (have_posts()) : the_post(); ?>     
                <div class="post" id="post-<?php the_ID();?>">          
                    <h2><a href="<?php the_permalink() ?>" <?php the_title_attribute(); ?>"> 
                    <?php the_title(); ?> </a></h2>         
                    <?php if(is_sticky()):?> <article id="sticky_post"><div class="sticky-title"><h2>Welocome</h2></div></article> 
                    <?php endif;?>                                                                          
                    <?php if( in_array( $post->ID, array(354) ) )                   
                    {echo get_the_content();}                       
                    else 
                    {echo get_excerpt();}?>
                    <div id="more" class="container_12">                    
                    <p class="read-more"></p>  </div>                                                       
                <div class="dots"> <img src="<?php echo get_bloginfo('template_directory'); ?>/images/dots.png" border="0" /></div>                             
                </div> <!-- end class post -->                      
            <?php endwhile; ?>                      
            <?php else : ?>     
            <h2> Not found </h2>        
            <p> Sorry but you are looking for something that isn't here. </p>       
        </div><!--content-->                    
    <?php endif; ?>                             
    </div><!--header_container-->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
1
  • 1
    What Theme are you using? Do you get the deprecated notice if you switch to Twenty Twelve? Do you get the deprecated notice if you disable all Plugins? Commented Feb 20, 2013 at 2:52

2 Answers 2

0

Deprecation is...

status applied to features, characteristics, or practices to indicate that they should be avoided, typically because they have been superseded.

In other words, attribute_escape has been replaced by esc_attr.

Any time you use a deprecated function WordPress triggers the error you're seeing. Somewhere in your codebase a deprecated function is being used.

To fix the error, you need to locate where attribute_escape is in your code. It won't be in the WordPress core as deprecated function calls are removed.

So, search your entire wp-content directory for attribute_escape. When you find it, replace it with esc_attr. I would use the command like ack-grep for this.

$ cd /path/to/your/wordpress/install/wp-content
$ ack-grep attribute_escape

But any filesystem search will probably work just fine.

1
  • Thanks for the help! @Chip Bennett this theme is mine, i build itfrom scratch. I use only two plugins, when i switch to Twenty Twelve Theme, i don't have any message/error. I'll check the solution that you suggest to me.
    – user24259
    Commented Feb 20, 2013 at 10:57
0

ohh. @chrisguitarguy i can't install the ack-grep, I had to look in manual mode. The problem was in functions.php particular:

<?php

function the_title_trim($title) {
        $title = attribute_escape($title);
        $findthese = array(
                '#Protected:#',
                '#Private:#'
        );
        $replacewith = array(
                '', // What to replace "Protected:" with
                '' // What to replace "Private:" with
        );
        $title = preg_replace($findthese, $replacewith, $title);
        return $title;
}
add_filter('the_title', 'the_title_trim');

?>

and replaced with :

<?php

function the_title_trim($title) {
        $title = esc_attr($title);
        $findthese = array(
                '#Protected:#',
                '#Private:#'
        );
        $replacewith = array(
                '', // What to replace "Protected:" with
                '' // What to replace "Private:" with
        );
        $title = preg_replace($findthese, $replacewith, $title);
        return $title;
}
add_filter('the_title', 'the_title_trim');

?>

And finally works!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.