| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'ABSPATH' ) ) { |
| 4 |
exit; |
| 5 |
} |
| 6 |
|
| 7 |
if ( ! class_exists( 'MywpShortcodeInit' ) ) : |
| 8 |
|
| 9 |
final class MywpShortcodeInit { |
| 10 |
|
| 11 |
private static $instance; |
| 12 |
|
| 13 |
private function __construct() {} |
| 14 |
|
| 15 |
public static function get_instance() { |
| 16 |
|
| 17 |
if ( !isset( self::$instance ) ) { |
| 18 |
|
| 19 |
self::$instance = new self(); |
| 20 |
|
| 21 |
} |
| 22 |
|
| 23 |
return self::$instance; |
| 24 |
|
| 25 |
} |
| 26 |
|
| 27 |
private function __clone() {} |
| 28 |
|
| 29 |
private function __wakeup() {} |
| 30 |
|
| 31 |
public static function init() { |
| 32 |
|
| 33 |
add_action( 'mywp_plugins_loaded' , array( __CLASS__ , 'plugins_loaded_include_modules' ) , 20 ); |
| 34 |
add_action( 'mywp_after_setup_theme' , array( __CLASS__ , 'after_setup_theme_include_modules' ) , 20 ); |
| 35 |
|
| 36 |
add_action( 'mywp_init' , array( __CLASS__ , 'regist_shortcode' ) ); |
| 37 |
|
| 38 |
} |
| 39 |
|
| 40 |
public static function plugins_loaded_include_modules() { |
| 41 |
|
| 42 |
$dir = MYWP_PLUGIN_PATH . 'shortcode/modules/'; |
| 43 |
|
| 44 |
$includes = array( |
| 45 |
'comment_count' => $dir . 'mywp.shortcode.module.comment_count.php', |
| 46 |
'post' => $dir . 'mywp.shortcode.module.post.php', |
| 47 |
'site' => $dir . 'mywp.shortcode.module.site.php', |
| 48 |
'theme' => $dir . 'mywp.shortcode.module.theme.php', |
| 49 |
'toolbar_item' => $dir . 'mywp.shortcode.module.toolbar_item.php', |
| 50 |
'update_count' => $dir . 'mywp.shortcode.module.update_count.php', |
| 51 |
'url' => $dir . 'mywp.shortcode.module.url.php', |
| 52 |
'user' => $dir . 'mywp.shortcode.module.user.php', |
| 53 |
); |
| 54 |
|
| 55 |
$includes = apply_filters( 'mywp_shortcode_plugins_loaded_include_modules' , $includes ); |
| 56 |
|
| 57 |
MywpApi::require_files( $includes ); |
| 58 |
|
| 59 |
} |
| 60 |
|
| 61 |
public static function after_setup_theme_include_modules() { |
| 62 |
|
| 63 |
$includes = array(); |
| 64 |
|
| 65 |
$includes = apply_filters( 'mywp_shortcode_after_setup_theme_include_modules' , $includes ); |
| 66 |
|
| 67 |
MywpApi::require_files( $includes ); |
| 68 |
|
| 69 |
} |
| 70 |
|
| 71 |
public static function regist_shortcode() { |
| 72 |
|
| 73 |
$shortcodes = MywpShortcode::get_shortcodes(); |
| 74 |
|
| 75 |
if( empty( $shortcodes ) ) { |
| 76 |
|
| 77 |
return false; |
| 78 |
|
| 79 |
} |
| 80 |
|
| 81 |
foreach( $shortcodes as $shotecode => $function ) { |
| 82 |
|
| 83 |
add_shortcode( $shotecode , $function , 11 , 3 ); |
| 84 |
|
| 85 |
} |
| 86 |
|
| 87 |
} |
| 88 |
|
| 89 |
} |
| 90 |
|
| 91 |
endif; |
| 92 |
|