-
Notifications
You must be signed in to change notification settings - Fork 0
/
wp-cli.php
139 lines (123 loc) · 3.12 KB
/
wp-cli.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
/**
* Plugin Name: WP CLI
* Plugin URI: https://github.com/chintalp0910
* Description: WP CLI custom command
* Version: 1.0.0
* Author: ChintalP
* Author URI: https://github.com/chintalp0910
* Text Domain: wpcli
* Domain Path: /languages/
*
* @package WP CLI
*/
/**
* Exit if accessed directly
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Basic plugin definitions
*
* @package WP CLI
* @since 1.0.0
*/
if ( ! defined( 'WPCLI_DIR' ) ) {
define( 'WPCLI_DIR', dirname( __FILE__ ) ); // Plugin dir.
}
if ( ! defined( 'WPCLI_VERSION' ) ) {
define( 'WPCLI_VERSION', '1.0.0' ); // Plugin Version.
}
if ( ! defined( 'WPCLI_URL' ) ) {
define( 'WPCLI_URL', plugin_dir_url( __FILE__ ) ); // Plugin url.
}
if ( ! defined( 'WPCLI_INC_DIR' ) ) {
define( 'WPCLI_INC_DIR', WPCLI_DIR . '/includes' ); // Plugin include dir.
}
if ( ! defined( 'WPCLI_INC_URL' ) ) {
define( 'WPCLI_INC_URL', WPCLI_URL . 'includes' ); // Plugin include url.
}
if ( ! defined( 'WPCLI_PLUGIN_BASENAME' ) ) {
define( 'WPCLI_PLUGIN_BASENAME', basename( WPCLI_DIR ) ); // Plugin base name.
}
/**
* Load Text Domain
*
* This gets the plugin ready for translation.
*
* @package WP CLI
* @since 1.0.0
*/
/**
* Load Text Domain
*
* This gets the plugin ready for translation.
*
* @package WP Custom Post Type
* @since 1.0.0
*/
function wpcli_load_textdomain() {
// Set filter for plugin's languages directory.
$wpcli_lang_dir = dirname( plugin_basename( __FILE__ ) ) . '/languages/';
$wpcli_lang_dir = apply_filters( 'wpcli_languages_directory', $wpcli_lang_dir );
// Traditional WordPress plugin locale filter.
$locale = apply_filters( 'plugin_locale', get_locale(), 'wpcli' );
$mofile = sprintf( '%1$s-%2$s.mo', 'wpcli', $locale );
// Setup paths to current locale file.
$mofile_local = $wpcli_lang_dir . $mofile;
$mofile_global = WP_LANG_DIR . '/' . WPCLI_PLUGIN_BASENAME . '/' . $mofile;
if ( file_exists( $mofile_global ) ) {
load_textdomain( 'wpcli', $mofile_global );
} elseif ( file_exists( $mofile_local ) ) {
load_textdomain( 'wpcli', $mofile_local );
} else { // Load the default language files.
load_plugin_textdomain( 'wpcli', false, $wpcli_lang_dir );
}
}
/**
* Plugin Setup Activation hook call back
*
* Initial setup of the plugin setting default options
* and database tables creations.
*
* @package WP CLI
* @since 1.0.0
*/
function wpcli_install() {
global $wpdb;
}
/**
* Plugin Setup (On Deactivation)
*
* Does the drop tables in the database and
* delete plugin options.
*
* @package WP CLI
* @since 1.0.0
*/
function wpcli_uninstall() {
global $wpdb;
}
/**
* Load Plugin
*
* Handles to load plugin after
* dependent plugin is loaded
* successfully
*
* @package WP CLI
* @since 1.0.0
*/
function wpcli_plugin_loaded() {
// load first plugin text domain.
wpcli_load_textdomain();
}
// add action to load plugin.
add_action( 'plugins_loaded', 'wpcli_plugin_loaded' );
// Global variables.
global $wpcli_public;
// Public class handles most of public functionalities of plugin.
require_once WPCLI_INC_DIR . '/class-wpcli-public.php';
$wpcli_public = new Wpcli_Public();
$wpcli_public->add_hooks();