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,141 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-dashboard
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
require_once dirname( __FILE__ ) . "/Tve_Dash_Font_Import_Manager_View.php";
require_once dirname( __FILE__ ) . "/Tve_Dash_Font_Import_Manager_Data.php";
if ( class_exists( 'Tve_Dash_Font_Import_Manager' ) ) {
return;
}
class Tve_Dash_Font_Import_Manager {
const OPTION_NAME = 'thrive_custom_font_pack';
protected static $instance;
protected $view;
protected $messages = array();
protected function __construct() {
$this->view = new Tve_Dash_Font_Import_Manager_View( dirname( dirname( __FILE__ ) ) . "/views" );
}
public function mainPage() {
if ( ! empty( $_POST['attachment_id'] ) ) {
$this->handlePost();
}
$font_pack = get_option( static::OPTION_NAME, array() );
if ( ! empty( $font_pack['css_file'] ) ) {
wp_enqueue_style( 'thrive_custom_fonts_manager', $font_pack['css_file'] );
}
$data['font_pack'] = $font_pack;
$data['messages'] = $this->messages;
$this->view->render( 'main', $data );
}
protected function handlePost() {
$handler = new Tve_Dash_Font_Import_Manager_Data();
if ( ! empty( $_POST['attachment_id'] ) && $_POST['attachment_id'] != - 1 ) {
$maybe_zip_file = get_attached_file( absint( $_POST['attachment_id'] ) );
$maybe_zip_url = wp_get_attachment_url( absint( $_POST['attachment_id'] ) );
try {
$new_font_pack = $handler->processZip( $maybe_zip_file, $maybe_zip_url );
$new_font_pack['attachment_id'] = absint( $_POST['attachment_id'] );
update_option( static::OPTION_NAME, $new_font_pack );
$this->messages['success'][] = __( "Font pack saved !", 'thrive-dash' );
} catch ( Exception $e ) {
$this->messages['error'][] = $e->getMessage();
}
} else {
try {
$font_pack = get_option( static::OPTION_NAME, array() );
if ( ! empty( $font_pack['attachment_id'] ) && is_file( $font_pack['zip_path'] ) ) {
$handler->deleteDir( $font_pack['folder'] );
delete_option( static::OPTION_NAME );
}
$this->messages['success'][] = __( "Font pack removed", 'thrive-dash' );
} catch ( Exception $e ) {
$this->messages['error'][] = $e;
}
}
}
public static function getInstance() {
if ( empty( static::$instance ) ) {
static::$instance = new Tve_Dash_Font_Import_Manager();
}
return static::$instance;
}
public static function getImportedFonts() {
$font_pack = get_option( static::OPTION_NAME, array() );
if ( empty( $font_pack ) ) {
return array();
}
$fonts = array();
foreach ( $font_pack['font_families'] as $name ) {
$fonts[] = array(
'family' => $name,
'variants' => array(
'regular',
),
'subsets' => array(
'latin'
)
);
}
return $fonts;
}
public static function getCssFile() {
$font_pack = get_option( static::OPTION_NAME, array() );
if ( empty( $font_pack ) ) {
return null;
}
$css_file = str_replace( array( 'http:', 'https:' ), '', $font_pack['css_file'] );
return $css_file;
}
/**
* @param $font string font-family
*
* @return bool
*/
public static function isImportedFont( $font ) {
$font_pack = get_option( static::OPTION_NAME, array() );
if ( empty( $font_pack ) ) {
return false;
}
return in_array( $font, $font_pack['font_families'] );
}
}
if ( ! class_exists( 'Thrive_Font_Import_Manager' ) ) {
class Thrive_Font_Import_Manager extends Tve_Dash_Font_Import_Manager {
}
}

View File

@@ -0,0 +1,145 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-dashboard
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
if ( class_exists( 'Tve_Dash_Font_Import_Manager_Data' ) ) {
return;
}
class Tve_Dash_Font_Import_Manager_Data {
protected $zip_contents = array(
'stylesheet.css'
);
public function processZip( $zip_file, $zip_url ) {
$clean_filename = $this->validateZip( $zip_file );
//Step 1: make sure the destination folder exists
$font_dir_path = dirname( $zip_file ) . '/' . $clean_filename;
//Step 1.1 prepare the filesystem
$extra = array(
'attachment_id',
);
$credentials = request_filesystem_credentials( admin_url( "admin.php?page=tve_dash_font_import_manager" ), '', false, false, $extra );
if ( ! $credentials ) {
//show FTP form
die;
}
if ( ! WP_Filesystem( $credentials ) ) {
throw new Exception( "Invalid credentials" );
}
$result = unzip_file( $zip_file, $font_dir_path );
if ( is_wp_error( $result ) ) {
throw new Exception( 'Error (unzip): ' . $result->get_error_message() );
}
//Step 3: process the zip
//check for selection.json file to be able to check the font family from within it
$this->checkExtractedFiles( $font_dir_path );
//Step 4: extract the font families from css file
$font_families = $this->extractFontFamilies( $font_dir_path . '/stylesheet.css' );
$data = array(
'folder' => $font_dir_path,
'css_file' => dirname( $zip_url ) . '/' . $clean_filename . '/stylesheet.css',
'font_families' => $font_families,
'zip_url' => $zip_url,
'zip_path' => $zip_file,
'filename' => basename( $zip_file )
);
return $data;
}
public function extractFontFamilies( $file ) {
if ( ! is_file( $file ) ) {
throw new Exception( $file . " cannot be found to apply changes on it !" );
}
$content = file_get_contents( $file );
$pattern = "/font-family: '(.*)'/";
preg_match_all( $pattern, $content, $matches );
if ( empty( $matches[1] ) ) {
throw new Exception( "No font family font" );
}
return $matches[1];
}
public function checkExtractedFiles( $dir, $specific_files = array() ) {
if ( empty( $dir ) ) {
throw new Exception( 'Empty folder' );
}
if ( ! is_array( $specific_files ) ) {
$specific_files = array( $specific_files );
}
$files_to_check = array_intersect( $this->zip_contents, $specific_files );
if ( empty( $files_to_check ) ) {
$files_to_check = $this->zip_contents;
}
foreach ( $files_to_check as $expected_file ) {
if ( ! is_file( $dir . '/' . $expected_file ) ) {
throw new Exception( 'Could not find the following file inside the archive: ' . $expected_file );
}
}
}
public function validateZip( $file ) {
if ( empty( $file ) || ! is_file( $file ) ) {
throw new Exception( 'Invalid or empty file' );
}
$info = wp_check_filetype( $file );
if ( strtolower( $info['ext'] ) !== 'zip' ) {
throw new Exception( 'The selected file is not a zip archive' );
}
return trim( str_replace( $info['ext'], '', basename( $file ) ), '/. ' );
}
public function deleteDir( $dirPath ) {
if ( ! is_dir( $dirPath ) ) {
throw new InvalidArgumentException( "$dirPath must be a directory" );
}
if ( substr( $dirPath, strlen( $dirPath ) - 1, 1 ) != '/' ) {
$dirPath .= '/';
}
$files = glob( $dirPath . '*', GLOB_MARK );
foreach ( $files as $file ) {
if ( is_dir( $file ) ) {
static::deleteDir( $file );
} else {
unlink( $file );
}
}
return rmdir( $dirPath );
}
}
if ( ! class_exists( 'Thrive_Font_Import_Manager' ) ) {
class Thrive_Font_Import_Manager extends Tve_Dash_Font_Import_Manager_Data {
}
}

View File

@@ -0,0 +1,61 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-dashboard
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
if ( class_exists( 'Tve_Dash_Font_Import_Manager_View' ) ) {
return;
}
class Tve_Dash_Font_Import_Manager_View {
protected $path;
protected $data = array();
public function __construct( $path ) {
$path = rtrim( $path, "/" );
$this->path = $path;
}
public function render( $file, $data = array() ) {
if ( strpos( $file, '.php' ) === false ) {
$file .= '.php';
}
if ( ! is_file( $this->path . '/' . $file ) ) {
echo sprintf( esc_html__( "No template found for %s", 'thrive-dash' ), esc_html( $file ) );
return;
}
if ( ! is_array( $data ) ) {
$data = array( 'data' => $data );
}
if ( ! empty( $data ) ) {
$this->data = array_merge_recursive( $this->data, $data );
}
include $this->path . "/" . $file;
}
public function __get( $key ) {
return isset( $this->data[ $key ] ) ? $this->data[ $key ] : null;
}
public function __set( $key, $value ) {
$this->data[ $key ] = $value;
}
}
if ( ! class_exists( 'Thrive_Font_Import_Manager_View' ) ) {
class Thrive_Font_Import_Manager_View extends Tve_Dash_Font_Import_Manager_View {
}
}

View File

@@ -0,0 +1,50 @@
#thrive-fonts-list .thrive-labels,
#thrive-fonts-list .thrive-content {
float: left;
}
#thrive-fonts-list .thrive-labels {
width: 20%;
}
#thrive-fonts-list .thrive-head {
font-size: 120%;
font-weight: bold;
}
.tve-dash-font-preview {
font-size: 24px!important;
}
.font-import-manager-messages {
padding: 20px 0 10px 0;
}
.font-import-manager-messages div.error,
.font-import-manager-messages div.updated {
margin: 0;
}
.font-import-manager-messages div.error p {
color: #dd3d36;
}
@import url(//fonts.googleapis.com/css?family=Source+Sans+Pro:400,300,700,300italic);
.font-manager-import-settings {
background: #fff;
border: 1px solid #E1E1E1;
margin: 0 20px 0 0;
padding: 25px;
color: #323232;
font-family: 'Source Sans Pro', sans-serif;
}
.font-manager-import-settings h3 {
border-bottom: 1px solid #e1e1e1;
font-weight: 300;
font-style: italic;
font-size: 25px;
padding-bottom: 10px;
padding-top: 0px;
margin: 0;
}

View File

@@ -0,0 +1,32 @@
<form action="" method="post" style="margin-top: 10px">
<div class="tvd-row">
<div class="tvd-col tvd-s12 tvd-m2 tvd-l1">
<?php echo esc_html__( "Upload Fonts", 'thrive-dash' ) ?>
</div>
<div class="tvd-col tvd-s12 tvd-m10 tvd-l11">
<a class="tvd-waves-effect tvd-waves-light tvd-btn-small tvd-btn-green" id="thrive_upload" href="javascript:void(0)">
<i class="tvd-icon-plus"></i> <?php echo esc_html__( "Upload", 'thrive-dash' ) ?>
</a>
<a class="tvd-waves-effect tvd-waves-light tvd-btn-small tvd-btn-red" id="thrive_remove" href="javascript:void(0)">
<i class="tvd-icon-remove"></i> <?php echo esc_html__( "Remove", 'thrive-dash' ) ?>
</a>
<input type="text" id="thrive_attachment_name" readonly="readonly" value="<?php echo ! empty( $this->font_pack['filename'] ) ? esc_attr( $this->font_pack['filename'] ) : '' ?>">
<input type="hidden" id="thrive_attachment_id" name="attachment_id"/>
</div>
</div>
<div class="tvd-row">
<div class="tvd-col tvd-s12 tvd-m2 tvd-l1">
<?php echo esc_html__( "Save options", 'thrive-dash' ) ?>
</div>
<div class="tvd-col tvd-s12 tvd-m10 tvd-l11">
<input type="submit" value="<?php echo esc_html__( "Save and Generate Fonts", 'thrive-dash' ) ?>" class="tvd-waves-effect tvd-waves-light tvd-btn-small tvd-btn-blue"/>
</div>
</div>
</form>

View File

@@ -0,0 +1,36 @@
(function ($) {
$(function () {
var $upload = $("#thrive_upload"),
$remove = $("#thrive_remove"),
wp_file_frame = null,
$input = $("#thrive_attachment_name"),
$input_id = $("#thrive_attachment_id");
$upload.click(function (event) {
event.preventDefault();
if (wp_file_frame) {
wp_file_frame.open();
return false;
}
wp_file_frame = wp.media.frames.file_frame = wp.media({
title: 'Upload .zip fonts files',
button: {
text: 'Use file'
},
multiple: false
});
wp_file_frame.on("select", function () {
var attachment = wp_file_frame.state().get('selection').first().toJSON();
$input.val(attachment.filename);
$input_id.val(attachment.id);
});
wp_file_frame.open();
});
$remove.click(function () {
$input.val('');
$input_id.val(-1);
});
});
})(jQuery);

View File

@@ -0,0 +1,68 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-dashboard
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
/** @var $this Tve_Dash_Font_Import_Manager_View */
?>
<?php if ( $this->messages ) : ?>
<?php $this->render( 'messages' ) ?>
<?php endif; ?>
<table class="options_table">
<tr>
<td class="thrive_options_branding" colspan="2">
<img class="thrive_admin_logo" src="<?php echo esc_url( TVE_DASH_URL . '/css/images/thrive-logo.png' ); ?>" alt="">
</td>
</tr>
</table>
<div class="font-manager-import-settings" style="width: auto;">
<h3><?php echo esc_html__( "Font Import Manager", 'thrive-dash' ) ?></h3>
<p><?php echo wp_kses_post( sprintf( __( "Thrive Themes integrates with %s so that you can upload your own font files for use in your web site.", 'thrive-dash' ), '<a target="_blank" href="//www.fontsquirrel.com/">Font Squirrel</a>' ) ); ?></p>
<h4><?php echo esc_html__( "Follow these steps to import custom fonts into your site:", 'thrive-dash' ) ?></h4>
<ol>
<li><?php echo wp_kses_post( sprintf( __( "Download one or more fonts from one of the many font libraries on the web. These files should be ttf or otf format. One such font library is: %s", 'thrive-dash' ), '<a target="_blank" href="//dafont.com">www.dafont.com</a>' ) ); ?></li>
<li><?php echo wp_kses_post( sprintf( __( "Once downloaded to your computer, you can then upload each font to the Font Squirrel generator tool here: %s", 'thrive-dash' ), '<a target="_blank" href="//www.fontsquirrel.com/tools/webfont-generator">www.fontsquirrel.com/tools/webfont-generator</a>' ) ); ?></li>
<li><?php echo esc_html__( "Once all your font files are uploaded, you can download the .zip file that is produced to your computer", 'thrive-dash' ) ?></li>
<li><?php echo esc_html__( 'Upload this file to your site using the "Upload" button below and then click the "Save and Generate Fonts" button', 'thrive-dash' ) ?></li>
<li><?php echo esc_html__( "Once generated, your fonts will immediately become accessible from the font manager", 'thrive-dash' ) ?></li>
</ol>
<h3><?php echo esc_html__( "Import Fonts", 'thrive-dash' ) ?></h3>
<?php $this->render( 'form' ); ?>
<h3><?php echo esc_html__( "Your Custom Fonts", 'thrive-dash' ) ?></h3>
<?php if ( $this->font_pack && $this->font_pack['font_families'] ) : ?>
<div class="tvd-row">
<h4 class="tvd-col tvd-m3"><?php echo esc_html__( "Name", 'thrive-dash' ) ?></h4>
<div class="tvd-col tvd-m9"><?php echo esc_html__( "Preview", 'thrive-dash' ) ?></div>
</div>
<?php foreach ( $this->font_pack['font_families'] as $family ) : ?>
<div class="tvd-row">
<h4 class="tvd-col tvd-m3">
<p><?php echo esc_html( $family ) ?></p>
</h4>
<div class="tvd-col tvd-m9 tve-dash-font-preview" style="font-family: '<?php echo esc_attr( $family ); ?>'">
Grumpy wizards make toxic brew for the evil Queen and Jack.
</div>
</div>
<?php endforeach; ?>
<?php else : ?>
<p><?php echo esc_html__( "No custom fonts added", 'thrive-dash' ) ?></p>
<?php endif; ?>
<a class="tvd-waves-effect tvd-waves-light tvd-btn-small tvd-btn-gray" href="<?php echo esc_url( admin_url( 'admin.php?page=tve_dash_font_manager' ) ); ?>">
<?php echo esc_html__( "Return to Font Manager", 'thrive-dash' ) ?>
</a>
<div class="clear"></div>
</div>

View File

@@ -0,0 +1,17 @@
<div class="font-import-manager-messages">
<?php if ( isset( $this->messages['error'] ) && count( $this->messages['error'] ) ) : ?>
<?php foreach ( $this->messages['error'] as $error ) : ?>
<div class="error">
<p><?php echo esc_html( $error ); ?></p>
</div>
<?php endforeach; ?>
<?php endif; ?>
<?php if ( isset( $this->messages['success'] ) && count( $this->messages['success'] ) ) : ?>
<?php foreach ( $this->messages['success'] as $success ) : ?>
<div class="updated">
<p><?php echo esc_html( $success ); ?></p>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>