{"action":"created","issue":{"url":"https://api.github.com/repos/WPupdatePHP/wp-update-php/issues/6","labels_url":"https://api.github.com/repos/WPupdatePHP/wp-update-php/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/WPupdatePHP/wp-update-php/issues/6/comments","events_url":"https://api.github.com/repos/WPupdatePHP/wp-update-php/issues/6/events","html_url":"https://github.com/WPupdatePHP/wp-update-php/issues/6","id":57604722,"number":6,"title":"Wrap in a `class_exists` to avoid fatals","user":{"login":"johnbillion","id":208434,"avatar_url":"https://avatars.githubusercontent.com/u/208434?v=3","gravatar_id":"","url":"https://api.github.com/users/johnbillion","html_url":"https://github.com/johnbillion","followers_url":"https://api.github.com/users/johnbillion/followers","following_url":"https://api.github.com/users/johnbillion/following{/other_user}","gists_url":"https://api.github.com/users/johnbillion/gists{/gist_id}","starred_url":"https://api.github.com/users/johnbillion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnbillion/subscriptions","organizations_url":"https://api.github.com/users/johnbillion/orgs","repos_url":"https://api.github.com/users/johnbillion/repos","events_url":"https://api.github.com/users/johnbillion/events{/privacy}","received_events_url":"https://api.github.com/users/johnbillion/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-02-13T14:29:29Z","updated_at":"2015-03-24T20:42:10Z","closed_at":"2015-03-16T07:46:50Z","body":"If two plugins both include this class, then you have a bigger problem than minimum PHP versions. The class should be wrapped in a `class_exists( 'WPUpdatePhp' )` check."},"comment":{"url":"https://api.github.com/repos/WPupdatePHP/wp-update-php/issues/comments/85684696","html_url":"https://github.com/WPupdatePHP/wp-update-php/issues/6#issuecomment-85684696","issue_url":"https://api.github.com/repos/WPupdatePHP/wp-update-php/issues/6","id":85684696,"user":{"login":"pderksen","id":79667,"avatar_url":"https://avatars.githubusercontent.com/u/79667?v=3","gravatar_id":"","url":"https://api.github.com/users/pderksen","html_url":"https://github.com/pderksen","followers_url":"https://api.github.com/users/pderksen/followers","following_url":"https://api.github.com/users/pderksen/following{/other_user}","gists_url":"https://api.github.com/users/pderksen/gists{/gist_id}","starred_url":"https://api.github.com/users/pderksen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pderksen/subscriptions","organizations_url":"https://api.github.com/users/pderksen/orgs","repos_url":"https://api.github.com/users/pderksen/repos","events_url":"https://api.github.com/users/pderksen/events{/privacy}","received_events_url":"https://api.github.com/users/pderksen/received_events","type":"User","site_admin":false},"created_at":"2015-03-24T20:42:10Z","updated_at":"2015-03-24T20:42:10Z","body":"```\r\nif ( class_exists( 'WPUpdatePhp' ) ) {\r\n  return;\r\n}\r\n```\r\n\r\nThe above works in my tests involving 2 plugins that include the same library, but I had several customers get the error message \"Fatal error: Cannot redeclare class WPUpdatePhp\" with the same 2 plugins.\r\n\r\nNot sure why I couldn't repeat it myself, but I think this check isn't stable enough.\r\n\r\nWith other similar class checks such as my plugins using the Stripe PHP library or EDD software licensing, I elect to do it like this from the init code:\r\n\r\n```\r\nif ( ! class_exists( 'WPUpdatePhp' ) ) {\r\n\trequire_once( 'libraries/WPUpdatePhp.php' );\r\n}\r\n```\r\n\r\nor simply wrap the whole class in a class_exists check above the class file (instead of using return):\r\n\r\n```\r\nif ( ! class_exists( 'WPUpdatePhp' ) ) {\r\n\tclass WPUpdatePhp {\r\n\t\t/* Class code here... */\r\n\t}\r\n}\r\n```\r\n\r\nI'm fine by either method.\r\n"}}