forked from gambitph/Titan-Framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
titan-framework-embedder.php
68 lines (59 loc) · 1.66 KB
/
titan-framework-embedder.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
<?php
/**
* This script is not used within Titan Framework itself.
*
* This script is meant to be used when embedding Titan Framework into your
* theme or plugin.
*
* To embed Titan Framework into your project, copy the whole Titan Framework folder
* into your project, then in your functions.php or main plugin script, do a
* require_once( 'Titan-Framework/titan-framework-embedder.php' );
*
* When done, your project will use the embedded copy of Titan Framework. When the plugin
* version is activated, that one will be used instead.
*
* For more details on embedding, read our docs:
* http://www.titanframework.net/embedding-titan-framework-in-your-project/
*
* @package Titan Framework
*/
if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly.
}
if ( ! class_exists( 'TitanFrameworkEmbedder' ) ) {
/**
* Titan Framework Embedder
*
* @since 1.6
*/
class TitanFrameworkEmbedder {
/**
* Constructor, add hooks for embedding for Titan Framework
*
* @since 1.6
*/
function __construct() {
// Don't do anything when we're activating a plugin to prevent errors
// on redeclaring Titan classes.
if ( is_admin() ) {
if ( ! empty( $_GET['action'] ) && ! empty( $_GET['plugin'] ) ) { // Input var: okay.
if ( 'activate' === $_GET['action'] ) { // Input var: okay.
return;
}
}
}
add_action( 'after_setup_theme', array( $this, 'perform_check' ), 1 );
}
/**
* Uses Titan Framework
*
* @since 1.6
*/
public function perform_check() {
if ( class_exists( 'TitanFramework' ) ) {
return;
}
require_once( 'titan-framework.php' );
}
}
new TitanFrameworkEmbedder();
}