1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Plugin Name: WP Default Feature Image. |
4
|
|
|
* Description: Help you choose your default thumbnail for 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: GNUv3 |
9
|
|
|
* Text Domain: wpdfi |
10
|
|
|
*/ |
11
|
|
|
define('WPDFI_PLUGIN', __FILE__ ); |
|
|
|
|
12
|
|
|
define('WPDFI_PLUGIN_BASENAME', plugin_basename( WPDFI_PLUGIN ) ); |
|
|
|
|
13
|
|
|
define('WPDFI_URL_BASE', plugin_dir_url( WPDFI_PLUGIN) ); |
|
|
|
|
14
|
|
|
define('WPDFI_DIR_BASE', plugin_dir_path( WPDFI_PLUGIN ) ); |
|
|
|
|
15
|
|
|
define('WPDFI_ASSETS', WPDFI_URL_BASE . '/assets/' ); |
|
|
|
|
16
|
|
|
define('WPDFI_TEMPLATES_PATH', WPDFI_DIR_BASE. '/templates/'); |
|
|
|
|
17
|
|
|
|
18
|
|
|
require_once WPDFI_DIR_BASE . '/vendor/autoload.php'; |
19
|
|
|
|
20
|
|
|
use WPDFI\Traits\HasModule; |
21
|
|
|
use WPDFI\Traits\Singleton; |
|
|
|
|
22
|
|
|
use WPDFI\PostType; |
23
|
|
|
use WPDFI\Taxonomy; |
24
|
|
|
use WPDFI\Term; |
25
|
|
|
use WPDFI\Ajax; |
26
|
|
|
use WPDFI\Admin; |
27
|
|
|
use WPDFI\Image; |
28
|
|
|
use WPDFI\Layout; |
29
|
|
|
use WPDFI\Admin\Notice; |
30
|
|
|
|
31
|
|
|
final class WPDFI |
32
|
|
|
{ |
33
|
|
|
use HasModule; |
34
|
|
|
use Singleton; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @traitDoc |
38
|
|
|
*/ |
39
|
|
|
public function initializes() |
40
|
|
|
{ |
41
|
|
|
$this->loadModules(); |
42
|
|
|
|
43
|
|
|
Ajax::instance(); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* All WordPress hooks come here |
48
|
|
|
* |
49
|
|
|
* @since 1.0.0 |
50
|
|
|
* @return void |
51
|
|
|
*/ |
52
|
|
|
public function hooks() |
53
|
|
|
{ |
54
|
|
|
|
55
|
|
|
add_action( 'init', [$this, 'init']); |
|
|
|
|
56
|
|
|
|
57
|
|
|
/* Load all module hooks */ |
58
|
|
|
$this->moduleHooks(); |
59
|
|
|
|
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* All Install and default settings stuff for this plugin come here. |
64
|
|
|
* |
65
|
|
|
* @since 1.0.0 |
66
|
|
|
* @return void |
67
|
|
|
*/ |
68
|
|
|
public function install() { |
69
|
|
|
|
70
|
|
|
$options = get_option('wpdfi-settings'); |
|
|
|
|
71
|
|
|
if(!$options['options']['status_for_update']) { |
|
|
|
|
72
|
|
|
$options['options']['status_for_update'] = 'publish'; |
73
|
|
|
update_option('wpdfi-settings', $options); |
|
|
|
|
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* init actions |
80
|
|
|
* |
81
|
|
|
* @since 1.0.0 |
82
|
|
|
* @return void |
83
|
|
|
*/ |
84
|
|
|
public function init() |
85
|
|
|
{ |
86
|
|
|
load_plugin_textdomain('wpdfi', false, WPDFI_DIR_BASE . '/lang/'); |
|
|
|
|
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @traitDoc |
91
|
|
|
*/ |
92
|
|
|
public function loadModules() { |
|
|
|
|
93
|
|
|
$modules = [ |
94
|
|
|
'templater' => new VA\Templater(WPDFI_TEMPLATES_PATH, 'blade'), |
|
|
|
|
95
|
|
|
'post_type' => PostType::instance(), |
96
|
|
|
'taxonomy' => Taxonomy::instance(), |
97
|
|
|
'term' => Term::instance(), |
98
|
|
|
'image' => Image::instance(), |
99
|
|
|
'layout' => Layout::instance(), |
100
|
|
|
'admin_notice' => Notice::instance(), |
101
|
|
|
'admin' => Admin::instance() |
102
|
|
|
]; |
103
|
|
|
|
104
|
|
|
foreach($modules as $moduleName => $moduleHandle) { |
|
|
|
|
105
|
|
|
$this->module($moduleName, $moduleHandle); |
|
|
|
|
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
return $this; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
} |
112
|
|
|
/** |
113
|
|
|
* Return singleton of WPDFI |
114
|
|
|
* |
115
|
|
|
* @since 1.0.0 |
116
|
|
|
* @return WPDFI Singleton instance of plugin class. |
117
|
|
|
*/ |
118
|
|
|
function wpdfi() { |
119
|
|
|
return WPDFI::instance(); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
add_action('plugins_loaded', [wpdfi(), 'hooks']); |
|
|
|
|
123
|
|
|
|
124
|
|
|
register_activation_hook(WPDFI_PLUGIN, [wpdfi(), 'install']); |
|
|
|
|