-
-
Save tommcfarlin/e27db4b35ff6ed7fba3b506dccb8ad2d to your computer and use it in GitHub Desktop.
[WordPress] Singletons in WordPress, Revisited
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Date_Formatter { | |
public static function get() { | |
$default_format = 'm/d/Y'; | |
$format = get_option( 'yhd_directory_importer', false ); | |
if ( false === $format ) { | |
return $default_format; | |
} | |
$format = $format['date']; | |
$format = | |
( isset( $format ) && isset( $format['format'] ) ) ? | |
$format['format'] : | |
$default_format; | |
return $format; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Date_Formatter { | |
private static $instance; | |
private function __construct() { | |
} | |
private static function get_instance() { | |
if ( null === self::$instance ) { | |
self::$instance = new self; | |
} | |
return self::$instance; | |
} | |
public static function get() { | |
self::get_instance(); | |
$default_format = 'm/d/Y'; | |
$format = get_option( 'yhd_directory_importer', false ); | |
if ( false === $format ) { | |
return $default_format; | |
} | |
$format = $format['date']; | |
$format = | |
( isset( $format ) && isset( $format['format'] ) ) ? | |
$format['format'] : | |
$default_format; | |
return $format; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment