-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwp-debug.php
More file actions
276 lines (246 loc) · 8.02 KB
/
wp-debug.php
File metadata and controls
276 lines (246 loc) · 8.02 KB
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
<?php
/**
* Plugin Name: WordPress debug
* Plugin URI: https://www.joseconti.com/
* Description: Muestra herramientas para debug.
* Version: 0.0.1
* Author: José Conti
* Author URI: https://www.joseconti.com/
* Tested up to: 5.1
* WC requires at least: 3.0
* WC tested up to: 3.6
* Woo: XXXXXXXXXXXXXXXXXXXXXXXXX
* Text Domain: wp-debug
* Domain Path: /languages/
* Requires PHP: 5.6.0
* Copyright: (C) 2019 José Conti
* License: GNU General Public License v3.0
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
define( 'WPDEBUG_VERSION', '0.0.1' );
define( 'WPDEBUG_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
define( 'WPDEBUG_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'WP_DEBUG_DB_VERSION', '1.0.0' );
/**
* Plugns loaded.
*/
function wp_debug_init() {
load_plugin_textdomain( 'wp-debug', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
// if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) ) {
// include_once WPDEBUG_PLUGIN_PATH . 'core/load-woocommerce-functions.php';
// }
}
add_action( 'plugins_loaded', 'wp_debug_init', 11 );
/*
if ( is_plugin_active( 'js_composer/js_composer.php' ) ) {
require_once WPDEBUG_PLUGIN_PATH . 'includes/wp-backery.php';
}
*/
require_once WPDEBUG_PLUGIN_PATH . 'classes/class-wp-debug-global.php';
// require_once WPDEBUG_PLUGIN_PATH . 'classes/class-wp-debug-users.php';
require_once WPDEBUG_PLUGIN_PATH . 'core/menu/menu.php';
require_once WPDEBUG_PLUGIN_PATH . 'core/notice/notices.php';
require_once WPDEBUG_PLUGIN_PATH . 'core/cpt/cpt.php';
// require_once WPDEBUG_PLUGIN_PATH . 'core/menu/multisite.php';
// require_once WPDEBUG_PLUGIN_PATH . 'core/shortcode/shortcode.php';
require_once WPDEBUG_PLUGIN_PATH . 'includes/elementor-load.php';
require_once WPDEBUG_PLUGIN_PATH . 'includes/action-scheduler/action-scheduler.php';
require_once WPDEBUG_PLUGIN_PATH . 'includes/acciones-programadas.php';
/**
* Global function.
*
* @return Wp_Debug_Global
*/
function wpdebug() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
return new Wp_Debug_Global();
}
/**
* Add data to tables.
*/
require_once WPDEBUG_PLUGIN_PATH . 'core/installer.php';
// register_activation_hook( __FILE__, 'wp_debug_create_tables_hook' );
// register_activation_hook( __FILE__, 'wp_debug_add_data_to_tables_hook' );
// register_activation_hook( __FILE__, 'wp_debug_create_upload_folder_hook' );
// register_activation_hook( __FILE__, 'wp_debug_add_avanced_settings_preset' );
/**
* Add current screen to admin bar.
*/
function wp_debug_add_current_screen_to_admin_bar() {
global $wp_admin_bar;
if ( is_admin() ) {
$screen = get_current_screen();
$activated = wpdebug()->get_option( 'wpdebug_activate_page_menubar_field' );
if ( $activated && '1' === $activated ) {
$wp_admin_bar->add_menu(
array(
'id' => 'wp-debug-add-current-screen-to-admin-bar',
'parent' => 'top-secondary',
'title' => esc_html__( 'Screen: ', 'wp-debug' ) . $screen->id,
)
);
}
}
}
add_action( 'admin_bar_menu', 'wp_debug_add_current_screen_to_admin_bar' );
/**
* Get parent page.
*/
function wp_debug_get_parent_page() {
$wp_debug_parent = basename( $_SERVER['SCRIPT_NAME'] );
return $wp_debug_parent;
}
/**
* Welcome splash.
*/
function wp_debug_welcome_splash() {
$wp_debug_parent = wp_debug_get_parent_page();
if ( get_option( 'wp-debug-version' ) === WPDEBUG_VERSION ) {
return;
} elseif ( 'update.php' === $wp_debug_parent || 'update-core.php' === $wp_debug_parent || 'plugins.php' === $wp_debug_parent ) {
return;
} else {
update_option( 'wp-debug-version', WPDEBUG_VERSION );
$wp_debug_redirect = esc_url( admin_url( add_query_arg( array( 'page' => 'wpdebug_about_page' ), 'admin.php' ) ) );
wp_safe_redirect( $wp_debug_redirect );
exit;
}
}
add_action( 'admin_init', 'wp_debug_welcome_splash', 1 );
/**
* Add styles.
*
* @param string $hook Page.
*/
function wp_debug_about_styles_css( $hook ) {
global $wpdebugabout;
if ( $wpdebugabout !== $hook ) {
return;
} else {
wp_register_style( 'wpdebugAboutCSS', WPDEBUG_PLUGIN_URL . 'assets/css/wpdebug-about.css', array(), esc_html( WPDEBUG_VERSION ) );
wp_enqueue_style( 'wpdebugAboutCSS' );
}
}
add_action( 'admin_enqueue_scripts', 'wp_debug_about_styles_css' );
/**
* Add scripts.
*/
function wp_debug_add_text_storefront_post_content_before() {
_e( 'Esto está sobre la entrada', 'wp-debug' );
}
add_action( 'storefront_post_content_before', 'wp_debug_add_text_storefront_post_content_before' );
/**
* Add scripts.
*/
function wp_debug_anadir_golger_analytics() {
echo '<!-- Esto lo añade mi plugin -->';
?>
<script>
</script>
<?php
echo '<!-- Fin de lo añade mi plugin -->';
}
add_action( 'wp_footer', 'wp_debug_anadir_golger_analytics' );
function wp_debug_modify_login_title( $login_title, $title ) {
$login_title = 'Nuevo título de página de login';
return $login_title;
}
add_filter( 'login_title', 'wp_debug_modify_login_title', 10, 2 );
function wp_debug_update_url( $url ) {
$url = 'https://cursojc.com/';
return $url;
}
add_filter( 'login_headerurl', 'wp_debug_update_url' );
// Ejemplo printf + wp_kses + esc_url.
/*
$guias = 'https://redsys.joseconti.com/guias/';
$faq = 'https://redsys.joseconti.com/redsys-for-woocommerce/';
$ticket = 'https://woocommerce.com/my-account/tickets/';
printf(
wp_kses(
'<div class="redsysnotice">
<span class="dashicons dashicons-welcome-learn-more redsysnotice-dash"></span>
<span class="redsysnotice__content">' .
// translators: Links to Jose Conti Redsys website Guides, Faq and Suport tickets.
__( 'For Redsys Help: Check the website <a href="%1$s" target="_blank" rel="noopener">Guides</a> for setup <a href="%2$s" target="_blank" rel="noopener">FAQ page</a> for working problems, or open a <a href="%3$s" target="_blank" rel="noopener"> Ticket</a> for support', 'wp-debug' ) . '<span></div>',
array(
'a' => array(
'href' => array(),
'target' => array(),
'rel' => array(),
),
'div' => array(
'class' => array(),
),
'span' => array(
'class' => array(),
),
)
),
esc_url( $guias ),
esc_url( $faq ),
esc_url( $ticket )
);
*/
add_action( 'init', 'wp_debug_add_custom_role', 11 );
function wp_debug_add_custom_role() {
add_role(
'cpt_perfil',
__( 'Perfil CPT' ),
array(
'edit_cpt' => true,
'read_cpt' => true,
'delete_cpt' => true,
'edit_cpt' => true,
'edit_others_cpt' => true,
'publish_cpt' => true,
'read_private_cpt' => true,
'upload_files' => true,
)
);
// remove_role( 'cpt_perfil' );
}
function wp_debug_imagen_visa_mastercard_enqueue() {
wp_enqueue_script(
'imagen-visa-mastercard-script',
plugins_url( 'build/index.js', __FILE__ ),
array( 'wp-blocks', 'wp-element', 'wp-editor' ),
filemtime( plugin_dir_path( __FILE__ ) . 'build/index.js' ),
true
);
wp_localize_script(
'imagen-visa-mastercard-script',
'imagenVisaMastercard',
array( 'pluginUrl' => plugins_url( '/', __FILE__ ) )
);
}
add_action( 'enqueue_block_editor_assets', 'wp_debug_imagen_visa_mastercard_enqueue' );
function wp_debug_create_block_wp_debug_block_init() {
register_block_type( __DIR__ . '/build' );
}
add_action( 'init', 'wp_debug_create_block_wp_debug_block_init' );
// Creación de un cron job.
/*
function wp_debug_cron_schedules( $schedules ) {
if ( ! isset( $schedules['5min'] ) ) {
$schedules['5min'] = array(
'interval' => 5 * 60,
'display' => __( 'Once every 5 minutes', 'wp-debug' ),
);
}
if ( ! isset( $schedules['30min'] ) ) {
$schedules['30min'] = array(
'interval' => 30 * 60,
'display' => __( 'Once every 30 minutes', 'wp-debug' ),
);
}
return $schedules;
}
add_filter( 'cron_schedules', 'wp_debug_cron_schedules' );
if ( ! wp_next_scheduled( 'wp_debug_task_hook' ) ) {
wp_schedule_event( time(), '5min', 'wp_debug_task_hook' );
}
add_action( 'wp_debug_task_hook', 'wp_debug_task_function' );
function wp_debug_task_function() {
esc_html_e( 'I have been called to action. I will do the same next week', 'wp-debug' );
}
*/