|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Plugin Name: WP Default Feature Image. |
|
4
|
|
|
* Description: Help you to choose default feature images for any post types, categories, tags,... |
|
5
|
|
|
* Version: 1.0.0 |
|
6
|
|
|
* Author: Duc Bui Quang <[email protected]> |
|
7
|
|
|
* Author URI: https://www.ducbuiquang.com |
|
8
|
|
|
* License: GPLv2+ |
|
9
|
|
|
* Text Domain: wpdfi |
|
10
|
|
|
* |
|
11
|
|
|
|
|
12
|
|
|
WP Default Feature Image is free software: you can redistribute it and/or modify |
|
13
|
|
|
it under the terms of the GNU General Public License as published by |
|
14
|
|
|
the Free Software Foundation, either version 2 of the License, or |
|
15
|
|
|
any later version. |
|
16
|
|
|
|
|
17
|
|
|
WP Default Feature Image is distributed in the hope that it will be useful, |
|
18
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20
|
|
|
GNU General Public License for more details. |
|
21
|
|
|
|
|
22
|
|
|
You should have received a copy of the GNU General Public License |
|
23
|
|
|
along with WP Default Feature Image. If not, see https://www.gnu.org/licenses/gpl-2.0.html. |
|
24
|
|
|
|
|
25
|
|
|
*/ |
|
26
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
define('WPDFI_PLUGIN', __FILE__ ); |
|
|
|
|
|
|
29
|
|
|
define('WPDFI_PLUGIN_BASENAME', plugin_basename( WPDFI_PLUGIN ) ); |
|
|
|
|
|
|
30
|
|
|
define('WPDFI_URL_BASE', plugin_dir_url( WPDFI_PLUGIN) ); |
|
|
|
|
|
|
31
|
|
|
define('WPDFI_DIR_BASE', plugin_dir_path( WPDFI_PLUGIN ) ); |
|
|
|
|
|
|
32
|
|
|
define('WPDFI_ASSETS', WPDFI_URL_BASE . '/assets/' ); |
|
|
|
|
|
|
33
|
|
|
define('WPDFI_TEMPLATES_PATH', WPDFI_DIR_BASE. '/templates/'); |
|
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
require_once WPDFI_DIR_BASE . '/vendor/autoload.php'; |
|
36
|
|
|
|
|
37
|
|
|
use WPDFI\Traits\HasModule; |
|
38
|
|
|
use WPDFI\Traits\Singleton; |
|
39
|
|
|
use WPDFI\PostType; |
|
40
|
|
|
use WPDFI\Taxonomy; |
|
41
|
|
|
use WPDFI\Term; |
|
42
|
|
|
use WPDFI\Ajax; |
|
43
|
|
|
use WPDFI\Admin; |
|
44
|
|
|
use WPDFI\Image; |
|
45
|
|
|
use WPDFI\Layout; |
|
46
|
|
|
use WPDFI\Admin\Notice; |
|
47
|
|
|
|
|
48
|
|
|
final class WPDFI |
|
49
|
|
|
{ |
|
50
|
|
|
use HasModule; |
|
51
|
|
|
use Singleton; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @traitDoc |
|
55
|
|
|
*/ |
|
56
|
|
|
public function initializes() |
|
57
|
|
|
{ |
|
58
|
|
|
$this->loadModules(); |
|
59
|
|
|
|
|
60
|
|
|
Ajax::instance(); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* All WordPress hooks come here |
|
65
|
|
|
* |
|
66
|
|
|
* @since 1.0.0 |
|
67
|
|
|
* @return void |
|
68
|
|
|
*/ |
|
69
|
|
|
public function hooks() |
|
70
|
|
|
{ |
|
71
|
|
|
|
|
72
|
|
|
add_action( 'init', [$this, 'init']); |
|
|
|
|
|
|
73
|
|
|
|
|
74
|
|
|
/* Load all module hooks */ |
|
75
|
|
|
$this->moduleHooks(); |
|
76
|
|
|
|
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* All Install and default settings stuff for this plugin come here. |
|
81
|
|
|
* |
|
82
|
|
|
* @since 1.0.0 |
|
83
|
|
|
* @return void |
|
84
|
|
|
*/ |
|
85
|
|
|
public function install() { |
|
86
|
|
|
|
|
87
|
|
|
$options = get_option('wpdfi-settings'); |
|
|
|
|
|
|
88
|
|
|
if(!$options['options']['status_for_update']) { |
|
|
|
|
|
|
89
|
|
|
$options['options']['status_for_update'] = 'publish'; |
|
90
|
|
|
update_option('wpdfi-settings', $options); |
|
|
|
|
|
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* init actions |
|
97
|
|
|
* |
|
98
|
|
|
* @since 1.0.0 |
|
99
|
|
|
* @return void |
|
100
|
|
|
*/ |
|
101
|
|
|
public function init() |
|
102
|
|
|
{ |
|
103
|
|
|
load_plugin_textdomain('wpdfi', false, WPDFI_DIR_BASE . '/lang/'); |
|
|
|
|
|
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* @traitDoc |
|
108
|
|
|
*/ |
|
109
|
|
|
public function loadModules() { |
|
|
|
|
|
|
110
|
|
|
$modules = [ |
|
111
|
|
|
'templater' => new VA\Templater(WPDFI_TEMPLATES_PATH, 'blade'), |
|
|
|
|
|
|
112
|
|
|
'post_type' => PostType::instance(), |
|
113
|
|
|
'taxonomy' => Taxonomy::instance(), |
|
114
|
|
|
'term' => Term::instance(), |
|
115
|
|
|
'image' => Image::instance(), |
|
116
|
|
|
'layout' => Layout::instance(), |
|
117
|
|
|
'admin_notice' => Notice::instance(), |
|
118
|
|
|
'admin' => Admin::instance() |
|
119
|
|
|
]; |
|
120
|
|
|
|
|
121
|
|
|
foreach($modules as $moduleName => $moduleHandle) { |
|
|
|
|
|
|
122
|
|
|
$this->module($moduleName, $moduleHandle); |
|
|
|
|
|
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
return $this; |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
} |
|
129
|
|
|
/** |
|
130
|
|
|
* Return singleton of WPDFI |
|
131
|
|
|
* |
|
132
|
|
|
* @since 1.0.0 |
|
133
|
|
|
* @return WPDFI Singleton instance of plugin class. |
|
134
|
|
|
*/ |
|
135
|
|
|
function wpdfi() { |
|
136
|
|
|
return WPDFI::instance(); |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
add_action('plugins_loaded', [wpdfi(), 'hooks']); |
|
|
|
|
|
|
140
|
|
|
|
|
141
|
|
|
register_activation_hook(WPDFI_PLUGIN, [wpdfi(), 'install']); |
|
|
|
|
|