Fatal Error Cannot Redeclare Function Wordpress
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about fatal error cannot redeclare php Stack Overflow the company Business Learn more about hiring developers or posting ads with php fatal error cannot redeclare function previously declared us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is
Php Cannot Redeclare Function
a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up “Fatal error: Cannot redeclare
Fatal Error: Cannot Redeclare Wordpress
function(this is exactly how it appears, from the top of my file):
Fatal error: Cannot redeclare add_term_meta() shemzone @shemzone 10 months, 1 week ago Fatal error: Cannot redeclare add_term_meta() (previously declared in /xxx/www/wp-includes/taxonomy.php:1571) in /xxx/www/wp-content/plugins/hide-for-group-roles/index.php on line 939 https://wordpress.org/plugins/hide-for-group-roles/ Viewing
Php Redeclare Function
7 replies - 1 through 7 (of 7 total) shemzone @shemzone override function php 10 months, 1 week ago This should be solved by adding the following on each already existing functions: php cannot redeclare class if (!function_exists('thefunction')) { // ... proceed to declare the function }
Moderator keesiemeijer @keesiemeijer moderator 10 months, 1 week ago I think it would be better to prefix http://stackoverflow.com/questions/1953857/fatal-error-cannot-redeclare-function the meta functions in the plugin. hfgr_add_term_meta() { } eiteews @eiteews 6 months, 4 weeks ago Fact is I cant access my admin because of the error. Suggestions? eiteews @eiteews 6 months, 4 weeks ago I'm trying to find the folder to change it on my ftp but I can't >.< Where is it located? Thanks! shemzone https://wordpress.org/support/topic/fatal-error-cannot-redeclare-add_term_meta/ @shemzone 6 months, 4 weeks ago Hi @eiteews, it's located at /www/wp-content/plugins/hide-for-group-roles Rename the file "index.php" or modify the functions (around line 938) from function [thefunctionname]($term_id, $meta_key, $meta_value, $unique = false) { return add_metadata('taxonomy', $term_id, $meta_key, $meta_value, $unique); } to if (!function_exists('[thefunctionname]')) { function add_term_meta($term_id, $meta_key, $meta_value, $unique = false) { return add_metadata('taxonomy', $term_id, $meta_key, $meta_value, $unique); } } And it's done Shemzone amrit0003 @amrit0003 4 weeks ago i am getting the same type of error for tranposh and freeCDN plugin . Fatal error: Cannot redeclare file_get_html() (previously declared in /home/kings1001/public_html/wp-content/plugins/transposh-translation-filter-for-wordpress/core/shd/simple_html_dom.php:39) in /home/kings1001/public_html/wp-content/plugins/free-cdn/simple_html_dom.php on line 41 I dont know much about programming . I have removed both plugins but still getting this error . Please guide me step by step so that it will be easy for me to understand what to do amrit0003 @amrit0003 4 weeks ago i changed name of function in Plugin to avoid conflict . but Now i am getting this error Warning: require_once(/home/kings1001/public_html/wp-content/plugins/free-cdn/simple_html_dom1.php): failed to open stream: No such file or directory itour help Tour Start here for a quick overview of the site Help Center Detailed answers to http://wordpress.stackexchange.com/questions/141427/fatal-error-cannot-redeclare-when-switching-themes any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more https://digwp.com/2011/11/clean-up-cannot-redeclare-hack/ about hiring developers or posting ads with us WordPress Development Questions Tags Users Badges Unanswered Ask Question _ WordPress Development Stack Exchange is a question cannot redeclare and answer site for WordPress developers and administrators. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top Fatal error: Cannot redeclare when switching themes up vote 1 down fatal error cannot vote favorite I've built a theme from scratch which is named "core". Core has a child theme called "core_child". My child theme works perfectly and only contains the following: /images screenshot.png style.css Today I needed to activate "core" to make some changes. I received the following error upon activation: Fatal error: Cannot redeclare add_slug_body_class() in /Applications/MAMP/htdocs/fresh_install/wp-content/themes/core/functions.php on line 3 The error indicates that I have a functions conflict. This prompted me to open up my functions.php file. I renamed the function add_slug_body_class to body_slug_core and this re-produced the error: Fatal error: Cannot redeclare body_slug_core() in /Applications/MAMP/htdocs/fresh_install/wp-content/themes/core/functions.php on line 3 Here's the function which is causing the problem: // Page slug body class function body_slug_core( $classes ) { global $post; if ( isset( $post ) ) { $classes[] = $post->post_type . '-' . $post->post_name; } return $classes; } add_filter( 'body_class', 'body_slug_core' ); Next I deleted the function completely. This produced the following er
Custom Menus » Clean Up "Cannot redeclare" Hack Posted by Jeff Starr • Updated on September 16th, 2016 One of my clients was hacked with the so-called "Cannot redeclare" hack. It seems closely related to the nefarious TimThumb hack, so if you've been hit by either of these hacks, you should check for the other. Apparently these hacks affect shared servers, so if you host multiple WordPress sites, chances are high that they're all infected. Checking for the "Cannot redeclare" hack The good news is that the hack is easy to diagnose. Just open any page from your site and look for the following PHP error message: Fatal error: Cannot redeclare _765258526() (previously declared in /path/to/www/wp-content/themes/THEME/footer.php(12) : eval()'d code:1) in /path/to/www/index.php(18) : eval()'d code on line 1 PHP errors like this are usually located at the bottom of the web page, but may appear elsewhere or even not all in some cases (i.e., proper configuration). To be certain, scan your server's PHP error logs for the "Cannot redeclare" error string. If you find anything that matches, it's time to fix your site.. About the "Cannot redeclare" hack If your site's been hit with "Cannot redeclare", you're in for a wild clean-up party because it infects every index.php and footer.php file for every WordPress site on the server. For example, my client hosted 11 sites on the same shared account, so multiply that by the number of index and footer files used by WordPress (core files and themes) and you get over 200 hacked files to clean up. Needless to say the client's sites have been moved to a more secure location. Fortunately finding the hacked index files is relatively painless, just search all files on your server for the following phrase: eval(gzun Here is a screenshot showing search results for this phrase: As seen here, the hacked files should be easy to recognize because they: include the eval(gzun search term include long strings of encoded gibberish consist of index.php and footer.php files If your search turns up anything that similar but not quite what we're talking about here, it may or may not be legit. The main thing that we're looking for are the long strings of encoded nonsense. Also, remember to check all sites that you may have on the same server. Once you've isolated the infected files, it's time to clean 'em up.. Removing the "Cannot redeclare" hack Looking at any of the hacked files, you'll find this hideous looking piece of code garbage: