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,103 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-dashboard
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
/**
* Plugin Upgrader
*
* Used to upgrade a Thrive Plugin to the latest version
*/
class TVD_Plugin_Upgrader extends Plugin_Upgrader {
/**
* Returns the download link from where the plugin should be downloaded
*
* @return string|false
*/
private function get_download_link() {
if ( ! function_exists( 'plugins_api' ) ) {
include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
}
$plugin_information = plugins_api( 'plugin_information', array( 'slug' => $this->skin->plugin ) );
if ( $plugin_information instanceof WP_Error ) {
return false;
}
return filter_var( $plugin_information->download_link, FILTER_VALIDATE_URL );
}
/**
* Downloads the latest Thrive Plugin version.
*
* @param string $plugin Path to the plugin file relative to the plugins directory.
* @param array $args {
* Optional. Other arguments for upgrading a plugin package. Default empty array.
*
* @type bool $clear_update_cache Whether to clear the plugin updates cache if successful.
* Default true.
* }
*
* @return array|bool|\WP_Error
*/
public function get_latest_version( $plugin, $args = array() ) {
$defaults = array(
'clear_update_cache' => true,
);
$parsed_args = wp_parse_args( $args, $defaults );
$this->init();
$this->upgrade_strings();
/**
* Added some custom strings that will replace the default update ones
*/
$this->strings['downloading_package'] = 'Downloading update from Thrive repositories';
$url = $this->get_download_link();
if ( empty( $url ) ) {
return false;
}
add_filter( 'upgrader_pre_install', array( $this, 'deactivate_plugin_before_upgrade' ), 10, 2 );
add_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ), 10, 4 );
$this->run( array(
'package' => $url,
'destination' => WP_PLUGIN_DIR,
'clear_destination' => true,
'clear_working' => true,
'hook_extra' => array(
'plugin' => $plugin,
'type' => 'plugin',
'action' => 'update',
),
) );
// Cleanup our hooks, in case something else does a upgrade on this connection.
remove_filter( 'upgrader_pre_install', array( $this, 'deactivate_plugin_before_upgrade' ) );
remove_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ) );
if ( ! $this->result || is_wp_error( $this->result ) ) {
return $this->result;
}
// Force refresh of plugin update information.
wp_clean_plugins_cache( $parsed_args['clear_update_cache'] );
return true;
}
}

View File

@@ -0,0 +1,92 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-dashboard
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
/**
* Theme Upgrader
*
* Used to upgrade Thrive Theme to the latest version
*/
class TVD_Theme_Upgrader extends Theme_Upgrader {
/**
* Returns the download link from where the plugin should be downloaded
*
* @return string|false
*/
private function get_download_link() {
if ( ! function_exists( 'plugins_api' ) ) {
include_once( ABSPATH . 'wp-admin/includes/theme.php' );
}
$theme_information = themes_api( 'theme_information', array( 'slug' => $this->skin->theme ) );
return filter_var( $theme_information->download_link, FILTER_VALIDATE_URL );
}
/**
* @param string $theme
* @param array $args
*
* @return array|bool|WP_Error
*/
public function get_latest_version( $theme, $args = array() ) {
$defaults = array(
'clear_update_cache' => true,
);
$parsed_args = wp_parse_args( $args, $defaults );
$this->init();
$this->upgrade_strings();
/**
* Added some custom strings that will replace the default update ones
*/
$this->strings['downloading_package'] = 'Downloading update from Thrive repositories';
$url = $this->get_download_link();
if ( empty( $url ) ) {
return false;
}
add_filter( 'upgrader_pre_install', array( $this, 'current_before' ), 10, 2 );
add_filter( 'upgrader_post_install', array( $this, 'current_after' ), 10, 2 );
add_filter( 'upgrader_clear_destination', array( $this, 'delete_old_theme' ), 10, 4 );
$this->run( array(
'package' => $url,
'destination' => get_theme_root(),
'clear_destination' => true,
'clear_working' => true,
'hook_extra' => array(
'theme' => $theme,
'type' => 'theme',
'action' => 'update',
),
) );
remove_filter( 'upgrader_pre_install', array( $this, 'current_before' ) );
remove_filter( 'upgrader_post_install', array( $this, 'current_after' ) );
remove_filter( 'upgrader_clear_destination', array( $this, 'delete_old_theme' ) );
if ( ! $this->result || is_wp_error( $this->result ) ) {
return $this->result;
}
// Force refresh of theme update information.
wp_clean_themes_cache( $parsed_args['clear_update_cache'] );
return true;
}
}

View File

@@ -0,0 +1,62 @@
.puc-debug-bar-panel pre {
margin-top: 0;
}
/* Style the debug data table to match "widefat" table style used by WordPress. */
table.puc-debug-data {
width: 100%;
clear: both;
margin: 0;
border-spacing: 0;
background-color: #f9f9f9;
border-radius: 3px;
border: 1px solid #dfdfdf;
border-collapse: separate;
}
table.puc-debug-data * {
word-wrap: break-word;
}
table.puc-debug-data th {
width: 11em;
padding: 7px 7px 8px;
text-align: left;
font-family: "Georgia", "Times New Roman", "Bitstream Charter", "Times", serif;
font-weight: 400;
font-size: 14px;
line-height: 1.3em;
text-shadow: rgba(255, 255, 255, 0.804) 0 1px 0;
}
table.puc-debug-data td, table.puc-debug-data th {
border-width: 1px 0;
border-style: solid;
border-top-color: #fff;
border-bottom-color: #dfdfdf;
text-transform: none;
}
table.puc-debug-data td {
color: #555;
font-size: 12px;
padding: 4px 7px 2px;
vertical-align: top;
}
.puc-ajax-response {
border: 1px solid #dfdfdf;
border-radius: 3px;
padding: 0.5em;
margin: 5px 0;
background-color: white;
}
.puc-ajax-nonce {
display: none;
}

View File

@@ -0,0 +1,124 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-dashboard
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
if ( ! class_exists( 'PluginUpdateCheckerPanel' ) && class_exists( 'Debug_Bar_Panel' ) ) {
/**
* A Debug Bar panel for the plugin update checker.
*/
class PluginUpdateCheckerPanel extends Debug_Bar_Panel {
/** @var TVE_PluginUpdateChecker */
private $updateChecker;
public function __construct( $updateChecker ) {
$this->updateChecker = $updateChecker;
$title = sprintf(
'<span id="puc-debug-menu-link-%s">PUC (%s)</span>',
esc_attr( $this->updateChecker->slug ),
$this->updateChecker->slug
);
parent::Debug_Bar_Panel( $title );
}
public function render() {
printf(
'<div class="puc-debug-bar-panel" id="puc-debug-bar-panel_%1$s" data-slug="%1$s" data-nonce="%2$s">',
esc_attr( $this->updateChecker->slug ),
esc_attr( wp_create_nonce( 'puc-ajax' ) )
);
$responseBox = '<div class="puc-ajax-response" style="display: none;"></div>';
echo '<h3>Configuration</h3>';
echo '<table class="puc-debug-data">';
$this->row( 'Plugin file', htmlentities( $this->updateChecker->pluginFile ) );
$this->row( 'Slug', htmlentities( $this->updateChecker->slug ) );
$this->row( 'DB option', htmlentities( $this->updateChecker->optionName ) );
$requestInfoButton = function_exists( 'get_submit_button' ) ? get_submit_button( 'Request Info', 'secondary', 'puc-request-info-button', false ) : '';
$this->row( 'Metadata URL', htmlentities( $this->updateChecker->metadataUrl ) . ' ' . $requestInfoButton . $responseBox );
if ( $this->updateChecker->checkPeriod > 0 ) {
$this->row( 'Automatic checks', 'Every ' . $this->updateChecker->checkPeriod . ' hours' );
} else {
$this->row( 'Automatic checks', 'Disabled' );
}
echo '</table>';
echo '<h3>Status</h3>';
echo '<table class="puc-debug-data">';
$state = $this->updateChecker->getUpdateState();
$checkNowButton = function_exists( 'get_submit_button' ) ? get_submit_button( 'Check Now', 'secondary', 'puc-check-now-button', false ) : '';
if ( isset( $state, $state->lastCheck ) ) {
$this->row( 'Last check', $this->formatTimeWithDelta( $state->lastCheck ) . ' ' . $checkNowButton . $responseBox );
} else {
$this->row( 'Last check', 'Never' );
}
$nextCheck = wp_next_scheduled( $this->updateChecker->getCronHookName() );
$this->row( 'Next automatic check', $this->formatTimeWithDelta( $nextCheck ) );
if ( isset( $state, $state->checkedVersion ) ) {
$this->row( 'Checked version', htmlentities( $state->checkedVersion ) );
$this->row( 'Cached update', $state->update );
}
$this->row( 'Update checker class', htmlentities( get_class( $this->updateChecker ) ) );
echo '</table>';
$update = $this->updateChecker->getUpdate();
if ( $update !== null ) {
echo '<h3>An Update Is Available</h3>';
echo '<table class="puc-debug-data">';
$fields = array( 'version', 'download_url', 'slug', 'homepage', 'upgrade_notice' );
foreach ( $fields as $field ) {
$this->row( ucwords( str_replace( '_', ' ', $field ) ), htmlentities( $update->$field ) );
}
echo '</table>';
} else {
echo '<h3>No updates currently available</h3>';
}
echo '</div>';
}
private function formatTimeWithDelta( $unixTime ) {
if ( empty( $unixTime ) ) {
return 'Never';
}
$delta = time() - $unixTime;
$result = human_time_diff( time(), $unixTime );
if ( $delta < 0 ) {
$result = 'after ' . $result;
} else {
$result = $result . ' ago';
}
$result .= ' (' . $this->formatTimestamp( $unixTime ) . ')';
return $result;
}
private function formatTimestamp( $unixTime ) {
return gmdate( 'Y-m-d H:i:s', $unixTime + ( get_option( 'gmt_offset' ) * 3600 ) );
}
private function row( $name, $value ) {
if ( is_object( $value ) || is_array( $value ) ) {
$value = '<pre>' . htmlentities( print_r( $value, true ) ) . '</pre>';
} else if ( $value === null ) {
$value = '<code>null</code>';
}
printf( '<tr><th scope="row">%1$s</th> <td>%2$s</td></tr>', $name, $value );
}
}
}

View File

@@ -0,0 +1,113 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-dashboard
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
if ( ! class_exists( 'PucDebugBarPlugin' ) ) {
class PucDebugBarPlugin {
/** @var TVE_PluginUpdateChecker */
private $updateChecker;
public function __construct( $updateChecker ) {
$this->updateChecker = $updateChecker;
add_filter( 'debug_bar_panels', array( $this, 'addDebugBarPanel' ) );
add_action( 'debug_bar_enqueue_scripts', array( $this, 'enqueuePanelDependencies' ) );
add_action( 'wp_ajax_puc_debug_check_now', array( $this, 'ajaxCheckNow' ) );
add_action( 'wp_ajax_puc_debug_request_info', array( $this, 'ajaxRequestInfo' ) );
}
/**
* Register the PUC Debug Bar panel.
*
* @param array $panels
*
* @return array
*/
public function addDebugBarPanel( $panels ) {
require_once dirname( __FILE__ ) . '/debug-bar-panel.php';
if ( current_user_can( 'update_plugins' ) && class_exists( 'PluginUpdateCheckerPanel' ) ) {
$panels[] = new PluginUpdateCheckerPanel( $this->updateChecker );
}
return $panels;
}
/**
* Enqueue our Debug Bar scripts and styles.
*/
public function enqueuePanelDependencies() {
wp_enqueue_style(
'puc-debug-bar-style',
plugins_url( "/css/puc-debug-bar.css", __FILE__ ),
array( 'debug-bar' ),
'20130927'
);
wp_enqueue_script(
'puc-debug-bar-js',
plugins_url( "/js/debug-bar.js", __FILE__ ),
array( 'jquery' ),
'20121026'
);
}
/**
* Run an update check and output the result. Useful for making sure that
* the update checking process works as expected.
*/
public function ajaxCheckNow() {
if ( empty( $_POST['slug'] ) || sanitize_text_field( $_POST['slug'] ) !== $this->updateChecker->slug ) {
return;
}
$this->preAjaxReqest();
$update = $this->updateChecker->checkForUpdates();
if ( $update !== null ) {
echo "An update is available:";
echo '<pre>', htmlentities( print_r( $update, true ) ), '</pre>'; // phpcs:ignore
} else {
echo 'No updates found.';
}
exit;
}
/**
* Request plugin info and output it.
*/
public function ajaxRequestInfo() {
if ( empty( $_POST['slug'] ) || sanitize_text_field( $_POST['slug'] ) !== $this->updateChecker->slug ) {
return;
}
$this->preAjaxReqest();
$info = $this->updateChecker->requestInfo();
if ( $info !== null ) {
echo 'Successfully retrieved plugin info from the metadata URL:';
echo '<pre>', htmlentities( print_r( $info, true ) ), '</pre>'; // phpcs:ignore
} else {
echo 'Failed to retrieve plugin info from the metadata URL.';
}
exit;
}
/**
* Check access permissions and enable error display (for debugging).
*/
private function preAjaxReqest() {
if ( ! current_user_can( 'update_plugins' ) ) {
die( 'Access denied' );
}
check_ajax_referer( 'puc-ajax' );
error_reporting( E_ALL );
@ini_set( 'display_errors', 'On' );
}
}
}

View File

@@ -0,0 +1,25 @@
<div style="margin: 20px auto; width: 911px">
<button id="transient_remove" class="button button-primary"><?php echo esc_html__( 'Remove all transients', 'thrive-dash' ); ?></button>
<hr>
<script type="text/javascript">
( function ( $ ) {
$( '#transient_remove' ).on( 'click', function () {
$.ajax( {
url: ajaxurl,
type: 'post',
data: {
_wpnonce: TVE_Dash_Const.nonce,
action: 'tve_debug_reset_transient'
}
} ).always( function ( response ) {
alert( response );
} )
} )
} )( jQuery )
</script>
<pre><?php print_r( tve_get_debug_data() ); ?></pre>
</div>

View File

@@ -0,0 +1,52 @@
jQuery(function($) {
function runAjaxAction(button, action) {
button = $(button);
var panel = button.closest('.puc-debug-bar-panel');
var responseBox = button.closest('td').find('.puc-ajax-response');
responseBox.text('Processing...').show();
$.post(
ajaxurl,
{
action : action,
slug : panel.data('slug'),
_wpnonce: panel.data('nonce')
},
function(data) {
responseBox.html(data);
},
'html'
);
}
$('.puc-debug-bar-panel input[name="puc-check-now-button"]').click(function() {
runAjaxAction(this, 'puc_debug_check_now');
return false;
});
$('.puc-debug-bar-panel input[name="puc-request-info-button"]').click(function() {
runAjaxAction(this, 'puc_debug_request_info');
return false;
});
// Debug Bar uses the panel class name as part of its link and container IDs. This means we can
// end up with multiple identical IDs if more than one plugin uses the update checker library.
// Fix it by replacing the class name with the plugin slug.
var panels = $('#debug-menu-targets').find('.puc-debug-bar-panel');
panels.each(function(index) {
var panel = $(this);
var slug = panel.data('slug');
var target = panel.closest('.debug-menu-target');
//Change the panel wrapper ID.
target.attr('id', 'debug-menu-target-puc-' + slug);
//Change the menu link ID as well and point it at the new target ID.
$('#puc-debug-menu-link-' + panel.data('slug'))
.closest('.debug-menu-link')
.attr('id', 'debug-menu-link-puc-' + slug)
.attr('href', '#' + target.attr('id'));
});
});

View File

@@ -0,0 +1,39 @@
( function ( $ ) {
$( function () {
var $div = $( '.theme-overlay' ),
html = $div.html();
setInterval( function () {
var newhtml = $div.html();
if ( html !== newhtml ) {
checkForThriveTheme();
html = newhtml;
}
}, 500 );
if ( $( '.theme-overlay .theme-name' ).text().includes( TVD_STABLE_THEME.name ) ) {
checkForThriveTheme();
}
/**
* Checks if the active theme is ThriveTheme
*/
function checkForThriveTheme() {
if ( tvdIsThriveTheme() && $( '.tvd-switch-stable-theme' ).length === 0 ) {
$( '.theme-wrap' ).find( '.theme-actions' ).append( TVD_STABLE_THEME.link_html );
}
}
/**
* Checks if the theme in the lightbox is the thrive-theme
*
* @returns {boolean}
*/
function tvdIsThriveTheme() {
return location.search.includes( 'thrive-theme' );
}
} );
} )( jQuery );

View File

@@ -0,0 +1,43 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-dashboard
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
?>
<div class="tvd-row">
<div class="tvd-col tvd-s12">
<h1>Switch the update channel</h1>
</div>
</div>
<div class="tvd-row">
<div class="tvd-col tvd-s12">
<span>This will download on your site the beta version of Thrive Suite products</span>
</div>
</div>
<div class="tvd-row">
<div class="tvd-col tvd-s12">
<div class="tvd-switch">
<label>
Beta
<input type="checkbox" class="tvd-toggle-input" <?php checked( 'beta', tvd_get_update_channel() ); ?>>
<span class="tvd-lever"></span>
</label>
</div>
</div>
</div>
<script type="text/javascript">
( function ( $ ) {
$( '.tvd-toggle-input' ).on( 'change', function ( event ) {
wp.ajax.post( {
_wpnonce: TVE_Dash_Const.nonce,
value: event.currentTarget.checked ? 'beta' : 'stable',
action: 'tve_update_settings'
} );
} )
} )( jQuery )
</script>

View File

@@ -0,0 +1,32 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-dashboard
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
if ( ! isset( $defaults ) || empty( $args ) || ! is_array( $args ) ) {
return;
}
?>
<form name="check_for_rollbacks" class="rollback-form" action="<?php echo admin_url( '/index.php' ); ?>">
<div>
<h1><?php echo esc_html( $args['name'] ); ?> version: <?php echo esc_html( $args['current_version'] ); ?></h1>
</div>
<div>
<p>Are you sure you want to switch to the stable version?</p>
</div>
<div class="wpr-submit-wrap">
<input type="submit" value="Switch to stable version" class="button-primary"/>
<input type="hidden" name="tvd_channel" value="tvd_switch_to_stable_channel"/>
<?php foreach ( $defaults as $name => $default_value ) : ?>
<input type="hidden" name="<?php echo $name; ?>" value="<?php echo esc_html( $args[ $name ] ); ?>"/>
<?php endforeach; ?>
<input type="button" value="No, stay on this version" class="button-secondary" onclick="location.href='<?php echo wp_get_referer(); ?>';"/>
</div>
</form>