/** * Kick off the class if it hasn't been instantiated. * * There is a lot of information about the Singleton design pattern * and singleton implementations for WordPress and plugins. I am not (at all!) * an expert on this and may very well be instantiating Subtitles in the * wrong way. If there's a better way to do this, or if it's not necessary * to use this design pattern with the plugin, please let me know. The reason * I've done it this way is because plugins should never be instantiated twice * in WordPress. In general, I assume that this won't happen under normal circumstances, * but using this design pattern ensures that if someone tries to instantiate * Subtitles twice, then it won't be possible to do so. * * For more reading, see the following links. * * @link http://en.wikipedia.org/wiki/Singleton_pattern * @link http://hardcorewp.com/2013/using-singleton-classes-for-wordpress-plugins/ * @link http://eamann.com/tech/the-case-for-singletons/ * @link http://www.toppa.com/2013/the-case-against-singletons-in-wordpress/ * @link http://eamann.com/tech/making-singletons-safe-in-php/ * * @staticvar Singleton $instance The Singleton instance of this class. * @return Singleton The Singleton instance of this class. * @access public * @static * * @since 1.0.0 */ public static function getinstance() { if (!self::$instance) { self::$instance = new Subtitles(); } return self::$instance; }