-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwp-think-framework.php
74 lines (60 loc) · 1.91 KB
/
wp-think-framework.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
if ( ! defined( 'ABSPATH' ) ) {
http_response_code( 403 ) && wp_die( 'Access forbidden' );
}
require __DIR__ . '/utility/autoload.php';
/* @const string version of framework */
define( 'THINK_FRAMEWORK_VERSION', '1.14.x' );
if ( ! class_exists( 'Think_Framework' ) ) {
/**
* Framework installer.
*
* Class Think_Framework
*/
final class Think_Framework {
use Think_Singleton;
/** Think_Framework constructor */
private function __construct() {
/* Define constants path and uri */
define( 'THINK_FRAMEWORK_PATH', $this->get_path() );
define( 'THINK_FRAMEWORK_URI', $this->get_uri() );
/* Autoload components */
require __DIR__ . '/contracts/autoload.php';
require __DIR__ . '/exceptioons/autoload.php';
require __DIR__ . '/support/autoload.php';
require __DIR__ . '/inputs/autoload.php';
require __DIR__ . '/customizer/autoload.php';
require __DIR__ . '/metabox/autoload.php';
require __DIR__ . '/options/autoload.php';
add_action( 'after_setup_theme', [ $this, 'multi_language_support' ] );
}
/** Add multi language support */
public function multi_language_support() {
$mo_file_path = THINK_FRAMEWORK_PATH . '/languages/' . get_locale() . '.mo';
load_textdomain( 'wp-think-framework', $mo_file_path );
}
/**
* Get Think_Framework uri.
*
* @return mixed
*/
public function get_uri() {
// Get correct URL and path to wp-content
$content_url = untrailingslashit( dirname( dirname( get_stylesheet_directory_uri() ) ) );
$content_dir = untrailingslashit( WP_CONTENT_DIR );
// Fix path on Windows
$dir = wp_normalize_path( dirname( __FILE__ ) );
$content_dir = wp_normalize_path( $content_dir );
$uri = str_replace( $content_dir, $content_url, $dir );
return $uri;
}
/**
* Get Think_Framework path.
*
* @return string
*/
public function get_path() {
return trailingslashit( dirname( __FILE__ ) );
}
}
}