-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustom-post-type-plus.php
116 lines (95 loc) · 3.15 KB
/
custom-post-type-plus.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
/**
* Plugin Name: Custom Post Type Plus
* Plugin URI: https://motopress.com
* Description: This plugin lets you add several custom post types in your WordPress.
* Version: 1.1.2
* Author: MotoPress
* Author URI: https://motopress.com
* Text Domain: custom-post-type-plus
* Domain Path: /languages
*/
if ( !class_exists('Custom_Post_Type_Plus') ) :
class Custom_Post_Type_Plus
{
/**
* The single instance of the class.
*/
private static $_instance = null;
/**
* Main Custom_Post_Type_Plus Instance.
*
* @see custom_post_type_plus_instance()
* @return Custom_Post_Type_Plus - Main instance.
*/
public static function instance()
{
if (is_null(self::$_instance)) {
self::$_instance = new self();
}
return self::$_instance;
}
public function __construct()
{
/*
* Path to classes folder in Plugin
*/
define('CUSTOM_POST_TYPE_PLUS_PATH', plugin_dir_path(__FILE__) );
define('CUSTOM_POST_TYPE_PLUS_INCLUDES_PATH', plugin_dir_path(__FILE__) . 'includes/');
define('CUSTOM_POST_TYPE_PLUS_PLUGIN_URL', plugin_dir_url(__FILE__));
$this->include_files();
add_action('plugins_loaded', array($this, 'plugins_loaded'));
add_action('init', array($this, 'maybe_flush_rewrite_rules'));
}
/**
* Load plugin textdomain.
*
* @access public
* @return void
*/
public function plugins_loaded()
{
load_plugin_textdomain('custom-post-type-plus', false, basename(dirname(__FILE__)) . '/languages/');
}
public function include_files()
{
include CUSTOM_POST_TYPE_PLUS_PATH . 'functions.php';
/*
* Include Custom Post Types
*/
include CUSTOM_POST_TYPE_PLUS_INCLUDES_PATH . 'base.php';
include CUSTOM_POST_TYPE_PLUS_INCLUDES_PATH . 'team.php';
include CUSTOM_POST_TYPE_PLUS_INCLUDES_PATH . 'portfolio.php';
include CUSTOM_POST_TYPE_PLUS_INCLUDES_PATH . 'testimonial.php';
include CUSTOM_POST_TYPE_PLUS_INCLUDES_PATH . 'activity.php';
include CUSTOM_POST_TYPE_PLUS_INCLUDES_PATH . 'amenity.php';
}
public static function activation() {
update_option( 'custom_post_type_plus_flush_rewrite_rules', '1' );
}
public function maybe_flush_rewrite_rules() {
if ( get_option( 'custom_post_type_plus_flush_rewrite_rules', '0' ) === '1' ) {
flush_rewrite_rules();
delete_option('custom_post_type_plus_flush_rewrite_rules');
}
}
public static function get_default_template() {
return 'templates/default.php';
}
}
/**
* Main instance of Custom_Post_Type_Plus_Instance.
*
* @since
* @return Custom_Post_Type_Plus
*/
function custom_post_type_plus_instance()
{
return Custom_Post_Type_Plus::instance();
}
/*
* Global for backwards compatibility.
*/
$GLOBALS['custom_post_type_plus_instance'] = custom_post_type_plus_instance();
register_activation_hook( __FILE__, array( 'Custom_Post_Type_Plus', 'activation' ) );
endif;