/**
* Prevent cloning of the instance of the Singleton instance.
*
* @return void
*/
private function __clone() {}
/**
* Prevent unserializing of the Singleton instance.
*
* @return void
*/
private function __wakeup() {}
Can some one please help me to understand and comprehend these things:
* Prevent cloning of the instance of the Singleton instance.
* Prevent unserializing of the Singleton instance.
What information did you encounter while thinking about it by yourself, by asking the developer of this code snippet and by having a research on this topic? where did you get stuck?
Not exactly. It is so when an HTTP request is made to the folder that file is in without requesting a particular file, that file will be accessed - and output nothing.
This is a security safety measure so that in case “Indexes” is enabled Apache won’t display a list of the files in the folder. (considering WordPress is open source the effort seems rather pointless, meh!)
To reiterate what @Mittineague has already said. It’s pretty much just there to prevent people from snooping around where they shouldn’t be. Since the main plugins don’t really need to be index.php files, it is often used as a safety precaution.
Singletons are very bad practice anyway and it looks like these have been added to slightly mitigate the negative effects of them.
However, this is bad practice in the same way that singletons are in the first place:
An object should not be in control of whether or not it can be cloned, it should be up to the calling code. By including these you make a lot of assumptions about the environment in which the code is running and limit the flexibility of the code in the process.