1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15: class Sensei_Theme_Integration_Loader {
16:
17: 18: 19: 20:
21: protected $themes;
22:
23: 24: 25: 26:
27: protected $active_theme;
28:
29: public function __construct() {
30:
31: $this->setup_themes();
32: $this->setup_currently_active_theme();
33:
34: add_action( 'init', array( $this, 'possibly_load_supported_theme_wrappers' ) );
35:
36: }
37:
38: 39: 40: 41: 42:
43: private function setup_themes(){
44:
45: $this->themes = array(
46: 'twentyeleven',
47: 'twentytwelve',
48: 'twentythirteen',
49: 'twentyfourteen',
50: 'twentyfifteen',
51: 'twentysixteen',
52: 'storefront',
53: );
54:
55: }
56:
57: 58: 59: 60: 61:
62: private function setup_currently_active_theme(){
63:
64: $this->active_theme = get_option('template');
65:
66: }
67:
68: 69: 70: 71: 72: 73: 74:
75: public function possibly_load_supported_theme_wrappers(){
76:
77: 78: 79: 80: 81: 82: 83: 84:
85: $load_default_supported_theme_wrappers = apply_filters('sensei_load_default_supported_theme_wrappers', true );
86:
87: if ( in_array( $this->active_theme, $this->themes ) && $load_default_supported_theme_wrappers ) {
88:
89:
90: $supported_theme_class_file = trailingslashit( Sensei()->plugin_path ) . 'includes/theme-integrations/' . $this->active_theme . '.php';
91: $supported_theme_class_name = 'Sensei_'. ucfirst( $this->active_theme );
92:
93:
94: if( ! file_exists( $supported_theme_class_file ) ){
95: return;
96: }
97: include_once( $supported_theme_class_file );
98: include_once( 'twentytwelve.php' );
99:
100: if( ! class_exists( $supported_theme_class_name ) ){
101: return;
102: }
103: $supported_theme = new $supported_theme_class_name;
104:
105:
106: remove_action( 'sensei_before_main_content', array( Sensei()->frontend, 'sensei_output_content_wrapper' ), 10 );
107: remove_action( 'sensei_after_main_content', array( Sensei()->frontend, 'sensei_output_content_wrapper_end' ), 10 );
108:
109:
110: add_action( 'sensei_before_main_content', array( $supported_theme, 'wrapper_start' ), 10 );
111: add_action( 'sensei_after_main_content', array( $supported_theme, 'wrapper_end' ), 10 );
112: }
113: }
114:
115: }