Plugins bloques actualizados
This commit is contained in:
@@ -124,11 +124,16 @@ final class Bloques_Transicion {
|
||||
public function admin_assets($hook) {
|
||||
$screen = get_current_screen();
|
||||
|
||||
// Solo cargar en páginas del plugin
|
||||
if ($screen && (
|
||||
strpos($screen->id, 'bloques') !== false ||
|
||||
in_array($screen->post_type, ['actuacion', 'recurso_bloques', 'evento_bloques'])
|
||||
)) {
|
||||
if (!$screen) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Cargar en páginas del plugin y también en editor de entradas (post)
|
||||
$is_bloques_page = strpos($screen->id, 'bloques') !== false ||
|
||||
in_array($screen->post_type, ['actuacion', 'recurso_bloques', 'evento_bloques']);
|
||||
$is_post_editor = $screen->post_type === 'post' && in_array($hook, ['post.php', 'post-new.php']);
|
||||
|
||||
if ($is_bloques_page || $is_post_editor) {
|
||||
wp_enqueue_style(
|
||||
'bloques-admin',
|
||||
BLOQUES_PLUGIN_URL . 'assets/css/admin.css',
|
||||
@@ -143,6 +148,25 @@ final class Bloques_Transicion {
|
||||
BLOQUES_VERSION,
|
||||
true
|
||||
);
|
||||
|
||||
// Datos para el JS del admin
|
||||
if ($is_post_editor) {
|
||||
// Obtener los IDs de las categorías "bloques-en-transicion" y "bloques"
|
||||
$bloques_cat_ids = [];
|
||||
$bloques_cat = get_term_by('slug', 'bloques-en-transicion', 'category');
|
||||
if ($bloques_cat) {
|
||||
$bloques_cat_ids[] = $bloques_cat->term_id;
|
||||
}
|
||||
$bloques_cat2 = get_term_by('slug', 'bloques', 'category');
|
||||
if ($bloques_cat2) {
|
||||
$bloques_cat_ids[] = $bloques_cat2->term_id;
|
||||
}
|
||||
|
||||
wp_localize_script('bloques-admin', 'bloquesAdminData', [
|
||||
'isPostEditor' => true,
|
||||
'bloquesCatIds' => $bloques_cat_ids,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user