Commit inicial powerservice
This commit is contained in:
+229
@@ -0,0 +1,229 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin Name: Alcastromol | Functions WP | Oxygen 6.1.1 | Tailwindcss v3 DF
|
||||
* Plugin URI: https://alcastromol.com/
|
||||
* Description: Funciones personalizadas y Tailwind v3. Oxygen es opcional.
|
||||
* Version: 3.2.0
|
||||
* Author: Alejandro Castro Molina
|
||||
* Author URI: https://alcastromol.com/
|
||||
* License: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
if (!defined('ABSPATH')) {
|
||||
exit; // Seguridad
|
||||
}
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Constantes del plugin
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
define('ALCASTROMOL_PLUGIN_PATH', plugin_dir_path(__FILE__));
|
||||
define('ALCASTROMOL_PLUGIN_URL', plugin_dir_url(__FILE__));
|
||||
define('ALCASTROMOL_PLUGIN_VERSION', '3.2.0');
|
||||
define('ALCASTROMOL_OXYGEN_ENABLED_OPTION', 'alcastromol_oxygen_enabled');
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Integración opcional con Oxygen
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
function alcastromol_is_oxygen_installed() {
|
||||
|
||||
if (defined('BREAKDANCE_MODE') && BREAKDANCE_MODE === 'oxygen') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (defined('CT_VERSION')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$plugins = (array) get_option('active_plugins', []);
|
||||
|
||||
if (in_array('oxygen/plugin.php', $plugins, true)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (is_multisite()) {
|
||||
$network = (array) get_site_option('active_sitewide_plugins', []);
|
||||
if (isset($network['oxygen/plugin.php'])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
function alcastromol_get_oxygen_option() {
|
||||
|
||||
$saved = get_option(ALCASTROMOL_OXYGEN_ENABLED_OPTION, null);
|
||||
|
||||
if ($saved === null) {
|
||||
return alcastromol_is_oxygen_installed() ? '1' : '0';
|
||||
}
|
||||
|
||||
return $saved === '1' ? '1' : '0';
|
||||
|
||||
}
|
||||
|
||||
function alcastromol_is_oxygen_enabled() {
|
||||
|
||||
return alcastromol_get_oxygen_option() === '1' && alcastromol_is_oxygen_installed();
|
||||
|
||||
}
|
||||
|
||||
add_action('plugins_loaded', 'alcastromol_check_oxygen');
|
||||
|
||||
function alcastromol_check_oxygen() {
|
||||
|
||||
if (alcastromol_is_oxygen_enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (alcastromol_get_oxygen_option() === '1' && !alcastromol_is_oxygen_installed()) {
|
||||
add_action('admin_notices', function () {
|
||||
echo '<div class="notice notice-warning">
|
||||
<p><strong>Alcastromol Functions:</strong> Oxygen no está instalado. Tailwind v3 funciona de forma independiente. Puedes activar Oxygen más tarde desde Tailwind → Modo.</p>
|
||||
</div>';
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Función segura para cargar archivos
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
function alcastromol_require($file) {
|
||||
|
||||
$path = ALCASTROMOL_PLUGIN_PATH . $file;
|
||||
|
||||
if (file_exists($path)) {
|
||||
require_once $path;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Limpieza de WordPress / Oxygen
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
alcastromol_require('functions/clear-header.php');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Insertar código en HEAD
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
alcastromol_require('functions/insert-code-header.php');
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Insertar código en FOOTER (opcional)
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// alcastromol_require('functions/insert-code-footer.php');
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Funciones del Admin
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| - Desactivar actualizaciones automáticas
|
||||
| - Desactivar pantalla completa del editor
|
||||
| - Limpiar admin bar
|
||||
| - Categorías y tags en media
|
||||
|
|
||||
*/
|
||||
|
||||
alcastromol_require('functions/admin/admin.php');
|
||||
alcastromol_require('functions/admin/admin-comments.php');
|
||||
|
||||
register_activation_hook(__FILE__, 'alcastromol_setup_comment_settings');
|
||||
|
||||
function alcastromol_cleanup_options() {
|
||||
delete_option('alcastromol_comments_done');
|
||||
}
|
||||
|
||||
alcastromol_require('functions/admin/admin-permalinks.php');
|
||||
|
||||
register_activation_hook(__FILE__, 'alcastromol_setup_permalinks');
|
||||
|
||||
alcastromol_require('functions/admin/admin-general.php');
|
||||
|
||||
register_activation_hook(__FILE__, 'alcastromol_setup_general_settings');
|
||||
|
||||
register_deactivation_hook(__FILE__, 'alcastromol_cleanup_options');
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| TailwindCSS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// Agregar CSS
|
||||
alcastromol_require('functions/tailwindcss/tailwindcss.php');
|
||||
|
||||
// Sistema de cache para Tailwind
|
||||
alcastromol_require('functions/tailwindcss/cache-system.php');
|
||||
|
||||
// Integración administrativa, acciones por entrada y barra superior
|
||||
alcastromol_require('functions/tailwindcss/admin-integration.php');
|
||||
|
||||
// permitir clases de tailwind dentro de oxygen
|
||||
/**==============================================
|
||||
* *
|
||||
* \wp-content\plugins\oxygen\builder\dist\js\app-DSmHGY7G.js
|
||||
*
|
||||
* / BUSCA esto
|
||||
* if(!ro(n)){Bs.log.message(uo(S(`"%s" is not a valid class name.`),n));return}
|
||||
// CAMBIA por esto
|
||||
* if(!e||!String(e).trim()){Bs.log.message(uo(S(`"%s" is not a valid class name.`),n));return}
|
||||
*
|
||||
* Buscar ------
|
||||
* for(let t of e)if(!ro(`.${t}`)){this.errorMessage=S(`Invalid class name`);return}
|
||||
*
|
||||
* Cambia por:
|
||||
*
|
||||
* for(let t of e)if(!t||!String(t).trim()){this.errorMessage=S(`Invalid class name`);return}
|
||||
*
|
||||
*
|
||||
* \wp-content\plugins\oxygen\builder\dist\js\store-BBZRLWAp.js
|
||||
*
|
||||
* Buscar
|
||||
* function G9(e){return/^-?[.]+[_a-zA-Z]+[_a-zA-Z0-9-]*$/.test(e)}
|
||||
*
|
||||
* CAmbiar por
|
||||
*
|
||||
* function G9(e){return typeof e==`string`&&e.startsWith(`.`)&&e.length>1}
|
||||
*
|
||||
*
|
||||
*=============================================**/
|
||||
/**
|
||||
* Reemplaza el bundle JS de Oxygen por una copia parchada
|
||||
* para permitir clases con : y [].
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Plugins requeridos (TGM Plugin Activation)
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
alcastromol_require('required-plugins/class-tgm-plugin-activation.php');
|
||||
alcastromol_require('required-plugins/plugins.php');
|
||||
Reference in New Issue
Block a user