{"id":4502329,"date":"2014-01-14T16:40:29","date_gmt":"2014-01-14T16:40:29","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/fatal-error-cannot-redeclare-14\/"},"modified":"2016-08-21T14:45:12","modified_gmt":"2016-08-21T14:45:12","slug":"fatal-error-cannot-redeclare-14","status":"closed","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/fatal-error-cannot-redeclare-14\/","title":{"rendered":"Fatal error: Cannot redeclare"},"content":{"rendered":"<p>I have a theme file that gets called via ajax and acts as a json service for other pages on the site. When I installed this plugin, the ajax file went all 500 and gave me the message:<\/p>\n<p>Fatal error: Cannot redeclare &lt;function name&gt; (previously declared in (&lt;&#8230;&gt;functions.php:10) in &lt;&#8230;&gt;functions.php on line 30<\/p>\n<p>It turns out, my theme&#8217;s functions.php was being included twice &#8211; once from WordPress and a second time from the plugin.<\/p>\n<p>The problem is in twitter-posts-to-blog.php on the first two lines of code. Changing<\/p>\n<pre><code>require_once &#039;libs\/twitteroauth\/twitteroauth.php&#039;;\nrequire_once &#039;functions.php&#039;;<\/code><\/pre>\n<p>to<\/p>\n<pre><code>$dir = plugin_dir_path( __FILE__ );\nrequire_once($dir.&#039;libs\/twitteroauth\/twitteroauth.php&#039;);\nrequire_once($dir.&#039;functions.php&#039;);<\/code><\/pre>\n<p>resolves the issue.<\/p>\n<p>https:\/\/wordpress.org\/plugins\/twitter-posts-to-blog\/<\/p>\n","protected":false},"template":"","class_list":["post-4502329","topic","type-topic","status-closed","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/4502329","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/4502329\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=4502329"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}