I uploaded to a WordPress site (3.3.1) a plugin that works perfectly in my other sites (3.3.1 and 3.4), but when try to activate it I get Fatal Error. When I go to check the plugin's main file content to do some changes and identify the error I detect that at the end of my code appears some random code from my file repeated.
If I edit it and save again another random code is placed at the end of the file again.
Any suggestion will be appreciated, even if are suggestions to do more research about it. I really don't know what to check for this issue.
Edition to add information requested:
I test deactivating all the plugins and with Twenty Eleven theme and I obtain the same behaviour
Example of the random code added
<?php
/*
Plugin Name: My plugin
Description: desc
Version: 1.0
*/
/**
* Version of WordPress
* @global string $wp_version
*/
global $wp_version;
$exit_msg = __('This plugin require WordPress 3.1 or newer','seo-pressor').'. <a href="http://codex.wordpress.org/Upgrading_WordPress">'.__('Please update','seo-pressor').'</a>';
if (version_compare($wp_version, "3.1", "<")) {
exit($exit_msg);
}
// Avoid name collisions.
if (!class_exists('WPPostsRateKeys')) {
class WPPostsRateKeys
{
(... long piece of code ...)
}
}
// create new instance of the class
$WPPostsRateKeys = new WPPostsRateKeys();
if (isset($WPPostsRateKeys)) {
// register the activation function by passing the reference to our instance
register_activation_hook(__FILE__, array(&$WPPostsRateKeys, 'install'));
register_deactivation_hook(__FILE__, array(&$WPPostsRateKeys, 'uninstall'));
}][
As you can see at the end was added the "][" that make my code fail.
Another information: when I open my text file using WordPress edit plugin file feature I see the random code at the end that will make my code file, but if I open the same file with the cPanel file manager this utility ask me for the encoding first (assign the file UTF-8) and opens it without any extra code added at the end. Anyway the activation of the plugin continue failing in WordPress due to this extra code.
I already save my files as FTP-8 without BOM and follow all the suggestions from http://www.toddlahman.com/the-plugin-generated-x-characters-of-unexpected-output-during-activation and doesn't works.
When in the WordPress editor I open the file the random text appears but when I open the same file using my FTP client the random text doesn't appears.
How do I need to code or save my PHP file so it works correctly?
Thanks in advanced Leticia