Commit inicial - WordPress Análisis de Precios Unitarios

- WordPress core y plugins
- Tema Twenty Twenty-Four configurado
- Plugin allow-unfiltered-html.php simplificado
- .gitignore configurado para excluir wp-config.php y uploads

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2025-11-03 21:04:30 -06:00
commit a22573bf0b
24068 changed files with 4993111 additions and 0 deletions

View File

@@ -0,0 +1,128 @@
<?php
/**
* Class BWFAN_API_Install_Activate_Plugin
*/
class BWFAN_API_Install_Activate_Plugin extends BWFAN_API_Base {
public static $ins;
public static function get_instance() {
if ( null === self::$ins ) {
self::$ins = new self();
}
return self::$ins;
}
public function __construct() {
parent::__construct();
$this->method = WP_REST_Server::CREATABLE;
$this->route = '/plugin/install_and_activate';
}
public function process_api_call() {
// basename of the plugin - plugin_folder/main_file
$plugin = isset( $this->args['plugin'] ) && ! empty( $this->args['plugin'] ) ? $this->args['plugin'] : '';
$pro_plugin = isset( $this->args['plugin_pro'] ) && ! empty( $this->args['plugin_pro'] ) ? $this->args['plugin_pro'] : '';
// actions - install | activate
$action = isset( $this->args['action'] ) && ! empty( $this->args['action'] ) ? $this->args['action'] : '';
$all_plugins = get_plugins();
/** checking for exists wp stmp pro plugin and also when action is activate */
if ( array_key_exists( $pro_plugin, $all_plugins ) && 'wp-mail-smtp/wp_mail_smtp.php' === $plugin && 'activate' === $action ) {
$plugin = $pro_plugin;
}
// plugin - full zip url of the plugin
$plugin_url = isset( $this->args['url'] ) && ! empty( $this->args['url'] ) ? esc_url_raw( wp_unslash( $this->args['url'] ) ) : '';
if ( empty( $action ) ) {
return $this->error_response( __( 'Action is missing : install or activate', 'wp-marketing-automations' ) );
}
return $this->install_or_activate_addon_plugins( $plugin, $plugin_url, $action );
}
public function install_or_activate_addon_plugins( $plugin, $plugin_url, $action ) {
// includes the required files
require_once BWFAN_PLUGIN_DIR . '/includes/plugin_helpers/class-bwfan-plugin-install-skin.php';
require_once BWFAN_PLUGIN_DIR . '/includes/plugin_helpers/class-bwfan-plugin-silent-upgrader.php';
// Do not allow WordPress to search/download translations, as this will break JS output.
remove_action( 'upgrader_process_complete', [ 'Language_Pack_Upgrader', 'async_upgrade' ], 20 );
// Create the plugin upgrader with our custom skin.
$installer = new BWFAN_Plugin_Silent_Upgrader( new BWFAN_Plugin_Install_Skin() );
switch ( $action ) {
case 'install':
$result = $this->install_plugin( $installer, $plugin_url );
break;
case 'activate':
$result = $this->activate_plugin( $plugin );
break;
default:
return $this->success_response( __( 'Undefined error', 'wp-marketing-automations' ) );
}
return $result;
}
public function install_plugin( $installer, $plugin_url ) {
if ( empty( $plugin_url ) ) {
return $this->error_response( __( 'Plugin URL is missing', 'wp-marketing-automations' ) );
}
// Error check.
if ( ! method_exists( $installer, 'install' ) ) {
return $this->error_response( __( 'Some error occurred: install function not found', 'wp-marketing-automations' ) );
}
if ( ! $installer->install( $plugin_url ) ) {
return $this->error_response( __( 'Some error occurred: installation failed', 'wp-marketing-automations' ) );
}
$result['is_installed'] = true;
$result['msg'] = esc_html__( 'Plugin installed', 'wp-marketing-automations' );
$this->response_code = 200;
return $this->success_response( $result );
}
public function activate_plugin( $plugin ) {
if ( empty( $plugin ) ) {
return $this->error_response( __( 'Plugin basename is missing', 'wp-marketing-automations' ) );
}
//Check for permissions.
if ( ! current_user_can( 'activate_plugins' ) ) {
$result['msg'] = esc_html__( 'You don\'t have permission to activate plugin', 'wp-marketing-automations' );
$this->response_code = 200;
return $this->success_response( $result );
}
// Activate the plugin silently.
$activated = activate_plugin( $plugin );
if ( is_wp_error( $activated ) ) {
return $this->error_response( __( 'Some error occurred while activating the plugin', 'wp-marketing-automations' ), $activated );
}
/**
* Fire after plugin activating via the BWFAN installer.
*/
do_action( 'bwfan_addon_plugin_activated', $plugin );
$result['is_activated'] = true;
$result['msg'] = esc_html__( 'Plugin activated', 'wp-marketing-automations' );
$this->response_code = 200;
return $this->success_response( $result );
}
}
BWFAN_API_Loader::register( 'BWFAN_API_Install_Activate_Plugin' );

View File

@@ -0,0 +1,76 @@
<?php
// using wpmailsmtp options class to check the configuration status
use WPMailSMTP\Options;
/**
* Class BWFAN_API_Plugin_Status
*/
class BWFAN_API_Plugin_Status extends BWFAN_API_Base {
public static $ins;
public static function get_instance() {
if ( null === self::$ins ) {
self::$ins = new self();
}
return self::$ins;
}
public function __construct() {
parent::__construct();
$this->method = WP_REST_Server::READABLE;
$this->route = '/plugin/status';
}
/**
* Checking the plugin installation and activation status
*/
public function process_api_call() {
// plugin - plugin_folder/main_file
$plugin = isset( $this->args['plugin'] ) ? $this->args['plugin'] : '';
$pro_plugin = isset( $this->args['plugin_pro'] ) ? $this->args['plugin_pro'] : '';
if ( empty( $plugin ) && empty( $pro_plugin ) ) {
return $this->error_response( __( 'Plugin name is missing', 'wp-marketing-automations' ) );
}
$install_status = false;
$active_status = false;
$configure_status = false;
// fetching all the installed plugins from the site
$all_plugins = get_plugins();
// return with status false if not installed
if ( ! array_key_exists( $plugin, $all_plugins ) && ! array_key_exists( $pro_plugin, $all_plugins ) ) {
return $this->success_response( [
'installed' => $install_status,
'activated' => $active_status,
'configured' => $configure_status
], __( 'Plugin is not installed', 'wp-marketing-automations' ) );
}
$install_status = true;
if ( is_plugin_active( $plugin ) || is_plugin_active( $pro_plugin ) ) {
$active_status = true;
// fetching configure data of wp-mail-smtp
// although class will be available as plugin is activated, but just making sure that no fatal error occurred due to class doesn't exist,
if ( class_exists( 'WPMailSMTP\Options' ) ) {
$default_options = wp_json_encode( Options::get_defaults() );
$current_options = wp_json_encode( Options::init()->get_all() );
// Check if the current settings are the same as the default settings.
if ( $current_options !== $default_options ) {
$configure_status = true;
}
}
}
$this->response_code = 200;
return $this->success_response( [ 'installed' => $install_status, 'activated' => $active_status, 'configured' => $configure_status ], __( 'Plugin status', 'wp-marketing-automations' ) );
}
}
BWFAN_API_Loader::register( 'BWFAN_API_Plugin_Status' );