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,171 @@
<?php
/** @var int $id */
/** @var array $item */
/** @var string $nonce */
/** @var string $delete_nonce */
/** @var array $targeting */
/** @var array $headers */
/** @var array $mapping */
?>
<?php if ($id) : ?>
<div class="td-webhooks-sidebar-actions" style="float:right; margin-top:10px;">
<form method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>" onsubmit="return confirm('<?php echo esc_js(__('Are you sure you want to delete this webhook?', 'thrive-dash')); ?>');" style="display:inline">
<input type="hidden" name="action" value="td_webhooks_delete" />
<input type="hidden" name="_wpnonce" value="<?php echo esc_attr($delete_nonce); ?>" />
<input type="hidden" name="id" value="<?php echo esc_attr((string) $id); ?>" />
<button type="submit" class="button-link delete" title="<?php echo esc_attr__('Delete webhook', 'thrive-dash'); ?>" style="color:#b32d2e; text-decoration:none;">
<span class="dashicons dashicons-trash"></span>
</button>
</form>
</div>
<?php endif; ?>
<script>
// Enhance headers/body mapping repeaters with add/remove controls
jQuery( function( $ ) {
function addRow( tableSelector, keyName, valueName ) {
var $tbody = $( tableSelector ).find( 'tbody' );
if ( ! $tbody.length ) { return; }
var $tr = $( '<tr/>' );
$tr.append( '<td><input type="text" name="' + keyName + '[]" value="" class="regular-text" /></td>' );
$tr.append( '<td><input type="text" name="' + valueName + '[]" value="" class="regular-text" /></td>' );
$tr.append( '<td><button type="button" class="button link-delete td-webhooks-remove-row" aria-label="Remove row">&times;</button></td>' );
$tbody.append( $tr );
}
// Add header row
$( document ).on( 'click', '#td-webhooks-add-header', function( e ) {
e.preventDefault();
addRow( '#td-webhooks-headers', 'headers[key]', 'headers[value]' );
} );
// Add body mapping row
$( document ).on( 'click', '#td-webhooks-add-mapping', function( e ) {
e.preventDefault();
addRow( '#td-webhooks-body-mapping', 'body_mapping[key]', 'body_mapping[value]' );
} );
// Remove current row
$( document ).on( 'click', '.td-webhooks-remove-row', function( e ) {
e.preventDefault();
$( this ).closest( 'tr' ).remove();
} );
} );
</script>
<form method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>">
<input type="hidden" name="action" value="td_webhooks_save" />
<input type="hidden" name="_wpnonce" value="<?php echo esc_attr($nonce); ?>" />
<input type="hidden" name="id" value="<?php echo esc_attr((string) $id); ?>" />
<table class="form-table">
<tbody>
<tr>
<th scope="row"><label for="name"><?php echo esc_html(__('Name', 'thrive-dash')); ?></label></th>
<td><input type="text" class="regular-text" name="name" id="name" value="<?php echo esc_attr((string) ($item['name'] ?? '')); ?>" /></td>
</tr>
<tr>
<th scope="row"><?php echo esc_html(__('Enabled', 'thrive-dash')); ?></th>
<td><label><input type="checkbox" name="enabled" value="1" <?php echo checked(! empty($item['enabled']), true, false); ?> /> <?php echo esc_html__('Yes', 'thrive-dash'); ?></label></td>
</tr>
<tr>
<th scope="row"><label for="url"><?php echo esc_html(__('Webhook URL', 'thrive-dash')); ?></label></th>
<td><input type="text" class="regular-text" name="url" id="url" value="<?php echo esc_attr((string) ($item['url'] ?? '')); ?>" /></td>
</tr>
<?php $method = strtolower($item['method'] ?? 'post'); ?>
<tr>
<th scope="row"><label for="method"><?php echo esc_html(__('Method', 'thrive-dash')); ?></label></th>
<td>
<select name="method" id="method">
<?php foreach (['post' => 'POST', 'get' => 'GET', 'put' => 'PUT', 'patch' => 'PATCH', 'delete' => 'DELETE'] as $val => $text) : ?>
<option value="<?php echo esc_attr((string) $val); ?>" <?php echo selected((string) $method, (string) $val, false); ?>><?php echo esc_html($text); ?></option>
<?php endforeach; ?>
</select>
</td>
</tr>
<?php $req_format = strtolower($item['request_format'] ?? 'form'); ?>
<tr>
<th scope="row"><label for="request_format"><?php echo esc_html(__('Request Format', 'thrive-dash')); ?></label></th>
<td>
<select name="request_format" id="request_format">
<?php foreach (['form' => 'form', 'json' => 'json', 'xml' => 'xml'] as $val => $text) : ?>
<option value="<?php echo esc_attr((string) $val); ?>" <?php echo selected((string) $req_format, (string) $val, false); ?>><?php echo esc_html($text); ?></option>
<?php endforeach; ?>
</select>
</td>
</tr>
<tr>
<th scope="row"><?php echo esc_html__('Headers', 'thrive-dash'); ?></th>
<td>
<?php $h_count = max(1, count((array) $headers)); ?>
<table class="widefat striped" id="td-webhooks-headers">
<thead>
<tr>
<th style="padding-left: 8px"><?php echo esc_html__('Key', 'thrive-dash'); ?></th>
<th style="padding-left: 8px"><?php echo esc_html__('Value', 'thrive-dash'); ?></th>
<th style="width:100px; padding-left: 8px"><?php echo esc_html__('Actions', 'thrive-dash'); ?></th>
</tr>
</thead>
<tbody>
<?php for ($i = 0; $i < $h_count; $i++) : $k = $headers[$i]['key'] ?? '';
$v = $headers[$i]['value'] ?? ''; ?>
<tr>
<td><input type="text" name="headers[key][]" value="<?php echo esc_attr((string) $k); ?>" class="regular-text" /></td>
<td><input type="text" name="headers[value][]" value="<?php echo esc_attr((string) $v); ?>" class="regular-text" /></td>
<td><button type="button" class="button link-delete td-webhooks-remove-row" aria-label="<?php echo esc_attr__('Remove header row', 'thrive-dash'); ?>">&times;</button></td>
</tr>
<?php endfor; ?>
</tbody>
</table>
<p>
<button type="button" class="button" id="td-webhooks-add-header"><?php echo esc_html__('Add header', 'thrive-dash'); ?></button>
</p>
<p class="description"><?php echo esc_html__('Leave empty key/value rows unused.', 'thrive-dash'); ?></p>
</td>
</tr>
<tr>
<th scope="row"><?php echo esc_html__('Body Mapping', 'thrive-dash'); ?></th>
<td>
<?php $m_count = max(1, count((array) $mapping)); ?>
<table class="widefat striped" id="td-webhooks-body-mapping">
<thead>
<tr>
<th style="padding-left: 8px"><?php echo esc_html__('Key', 'thrive-dash'); ?></th>
<th style="padding-left: 8px"><?php echo esc_html__('Value', 'thrive-dash'); ?></th>
<th style="width:100px; padding-left: 8px"><?php echo esc_html__('Actions', 'thrive-dash'); ?></th>
</tr>
</thead>
<tbody>
<?php for ($i = 0; $i < $m_count; $i++) : $k = $mapping[$i]['key'] ?? '';
$v = $mapping[$i]['value'] ?? ''; ?>
<tr>
<td><input type="text" name="body_mapping[key][]" value="<?php echo esc_attr((string) $k); ?>" class="regular-text" /></td>
<td><input type="text" name="body_mapping[value][]" value="<?php echo esc_attr((string) $v); ?>" class="regular-text" /></td>
<td><button type="button" class="button link-delete td-webhooks-remove-row" aria-label="<?php echo esc_attr__('Remove mapping row', 'thrive-dash'); ?>">&times;</button></td>
</tr>
<?php endfor; ?>
</tbody>
</table>
<p>
<button type="button" class="button" id="td-webhooks-add-mapping"><?php echo esc_html__('Add mapping', 'thrive-dash'); ?></button>
</p>
<p class="description"><?php echo esc_html__('Leave empty key/value rows unused.', 'thrive-dash'); ?></p>
</td>
</tr>
</tbody>
</table>
<?php submit_button($id ? __('Update Webhook', 'thrive-dash') : __('Create Webhook', 'thrive-dash')); ?>
</form>
<?php if ($id) : ?>
<form method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>" onsubmit="return confirm('<?php echo esc_js(__('Are you sure?', 'thrive-dash')); ?>');">
<input type="hidden" name="action" value="td_webhooks_delete" />
<input type="hidden" name="_wpnonce" value="<?php echo esc_attr($delete_nonce); ?>" />
<input type="hidden" name="id" value="<?php echo esc_attr((string) $id); ?>" />
<?php submit_button(__('Delete', 'thrive-dash'), 'delete'); ?>
</form>
<?php endif; ?>

View File

@@ -0,0 +1,40 @@
<?php
/** @var array $items */
$edit_url = function( $id ) { return add_query_arg( [ 'page' => 'td_webhooks', 'tab' => 'edit', 'id' => $id ], admin_url( 'admin.php' ) ); };
$logs_url = function( $id ) { return add_query_arg( [ 'page' => 'td_webhooks', 'tab' => 'logs', 'id' => $id ], admin_url( 'admin.php' ) ); };
?>
<table class="widefat fixed striped">
<thead>
<tr>
<th><?php echo esc_html__( 'Name', 'thrive-dash' ); ?></th>
<th><?php echo esc_html__( 'URL', 'thrive-dash' ); ?></th>
<th><?php echo esc_html__( 'Enabled', 'thrive-dash' ); ?></th>
<th><?php echo esc_html__( 'Actions', 'thrive-dash' ); ?></th>
</tr>
</thead>
<tbody>
<?php if ( empty( $items ) ) : ?>
<tr><td colspan="4"><?php echo esc_html__( 'No webhooks found.', 'thrive-dash' ); ?></td></tr>
<?php else : foreach ( $items as $it ) : ?>
<?php $enabled_text = ! empty( $it['enabled'] ) ? __( 'Yes', 'thrive-dash' ) : __( 'No', 'thrive-dash' ); ?>
<tr>
<td><?php echo esc_html( $it['name'] ?? '' ); ?></td>
<td><?php echo esc_html( $it['url'] ?? '' ); ?></td>
<td><?php echo esc_html( $enabled_text ); ?></td>
<td>
<a class="button" href="<?php echo esc_url( $edit_url( $it['id'] ) ); ?>"><?php echo esc_html__( 'Edit', 'thrive-dash' ); ?></a>
<a class="button" href="<?php echo esc_url( $logs_url( $it['id'] ) ); ?>"><?php echo esc_html__( 'Logs', 'thrive-dash' ); ?></a>
<?php $delete_nonce = wp_create_nonce( 'td_webhooks_delete' ); ?>
<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" style="display:inline;margin-left:6px;" onsubmit="return confirm('<?php echo esc_js( __( 'Are you sure?', 'thrive-dash' ) ); ?>');">
<input type="hidden" name="action" value="td_webhooks_delete" />
<input type="hidden" name="_wpnonce" value="<?php echo esc_attr( $delete_nonce ); ?>" />
<input type="hidden" name="id" value="<?php echo esc_attr( (string) $it['id'] ); ?>" />
<button type="submit" class="button delete"><?php echo esc_html__( 'Delete', 'thrive-dash' ); ?></button>
</form>
</td>
</tr>
<?php endforeach; endif; ?>
</tbody>
</table>

View File

@@ -0,0 +1,31 @@
<?php /** @var array $rows */ ?>
<h2><?php echo esc_html__( 'Logs', 'thrive-dash' ); ?></h2>
<table class="widefat fixed striped">
<thead>
<tr>
<th><?php echo esc_html__( 'Time', 'thrive-dash' ); ?></th>
<th><?php echo esc_html__( 'Status', 'thrive-dash' ); ?></th>
<th><?php echo esc_html__( 'Duration (ms)', 'thrive-dash' ); ?></th>
<th><?php echo esc_html__( 'Details', 'thrive-dash' ); ?></th>
</tr>
</thead>
<tbody>
<?php if ( empty( $rows ) ) : ?>
<tr><td colspan="4"><?php echo esc_html__( 'No logs yet.', 'thrive-dash' ); ?></td></tr>
<?php else : foreach ( $rows as $row ) : ?>
<tr>
<td><?php echo esc_html( $row['timestamp'] ?? '' ); ?></td>
<td><?php echo esc_html( (string) ( $row['status_code'] ?? '' ) ); ?></td>
<td><?php echo esc_html( (string) ( $row['duration_ms'] ?? '' ) ); ?></td>
<td>
<details>
<summary><?php echo esc_html__( 'View', 'thrive-dash' ); ?></summary>
<pre><?php echo esc_html( print_r( $row, true ) ); ?></pre>
</details>
</td>
</tr>
<?php endforeach; endif; ?>
</tbody>
</table>