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,289 @@
<?php /** @noinspection PhpCSValidationInspection */
/** @noinspection PhpCSValidationInspection */
/** @noinspection PhpCSValidationInspection */
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-dashboard
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
abstract class TVE_Dash_Product_Abstract {
private static $instances = array();
protected $tag;
protected $slug = '';
protected $version = '';
protected $logoUrl;
protected $logoUrlWhite;
protected $title;
protected $description;
protected $productIds;
protected $type;
protected $activated = false;
protected $moreLinks = array();
protected $button = array();
protected $required_data
= array(
'tag',
'logoUrl',
'title',
'description',
'productIds',
'type',
'activated',
);
protected $needs_architect = false;
/**
* Is true if the TAR version is incompatible with the product version
*
* @var bool
*/
protected $incompatible_architect_version = false;
public function __construct( $data = array() ) {
foreach ( $data as $key => $value ) {
$this->{$key} = $value;
}
}
public function localize_data() {
return [
'type' => $this->type,
'tag' => $this->tag,
'slug' => $this->slug,
'title' => $this->title,
'is_activated' => $this->is_activated(),
'capability' => $this->get_cap(),
'has_access' => self::has_access(),
'admin_url' => $this->get_admin_url(),
'version' => $this->version,
];
}
/**
* Check each required data if it's empty
*
* @throws Exception
*/
final public function validate() {
foreach ( $this->required_data as $data ) {
if ( $data === 'productIds' && ! is_array( $this->productIds ) ) {
throw new Exception( "{$data} is not array" );
}
if ( is_null( $this->{$data} ) ) {
throw new Exception( "Field {$data} is empty" );
}
}
}
public function render() {
try {
$this->validate();
} catch ( Exception $exception ) {
require TVE_DASH_PATH . '/templates/product/error.phtml';
return;
}
if ( $this->is_activated() ) {
require TVE_DASH_PATH . '/templates/product/activated.phtml';
return;
}
require TVE_DASH_PATH . '/templates/product/inactive.phtml';
}
public function is_activated() {
if ( $this->activated === true ) {
return true;
}
return TVE_Dash_Product_LicenseManager::getInstance()->itemActivated( $this );
}
public function render_button() {
return sprintf( '<a class="%s" href="%s" target="%s" data-source="%s">%s</a>',
"tvd-waves-effect tvd-waves-light tvd-btn tvd-btn-green tvd-full-btn" . ( $this->button['active'] ? '' : 'tvd-disabled' ) . ' ' . ( ! empty( $this->button['classes'] ) ? $this->button['classes'] : '' ),
$this->button['active'] && ! empty( $this->button['url'] ) ? $this->button['url'] : 'javascript:void(0)',
! empty( $this->button['target'] ) ? $this->button['target'] : '_self',
! empty( $this->button['data-source'] ) ? $this->button['data-source'] : '',
$this->button['label']
);
}
public function render_more_links() {
if ( $this->is_activated() && ! empty( $this->moreLinks ) ) {
$links = '<a class="tvd-dropdown-button tvd-btn-floating tvd-right tvd-card-options" data-constrainwidth="false" data-beloworigin="true" data-alignment="right" data-activates="dropdown-' . $this->tag . '" href="javascript:void(0)"><i class="tvd-icon-more_vert"></i></a>';
$links .= '<ul id="dropdown-' . $this->tag . '" class="tvd-dropdown-content" style="white-space: nowrap; position: absolute; top: 43px; left: 162px; opacity: 1; display: none;">';
foreach ( $this->moreLinks as $link ) {
$icon_class = isset( $link['icon_class'] ) ? $link['icon_class'] : '';
$class = isset( $link['class'] ) ? $link['class'] : '';
$target = isset( $link['target'] ) ? $link['target'] : '_self';
$href = isset( $link['href'] ) ? $link['href'] : '';
$text = isset( $link['text'] ) ? $link['text'] : 'Item';
$links .= "<li><a class='" . $class . "' target='" . $target . "' href='" . $href . "'><i class='" . $icon_class . "'></i>" . $text . "</a></li>";
}
$links .= '</ul>';
return $links;
}
return '';
}
public function get_tag() {
return $this->tag;
}
public function get_slug() {
return $this->slug;
}
public function get_title() {
return $this->title;
}
public function get_logo() {
return $this->logoUrl;
}
public function get_type() {
return $this->type;
}
public function setMoreLinks( $links ) {
$this->moreLinks = $links;
}
public function get_cap() {
return 'tve-use-' . $this->tag;
}
/**
* Checking if the default capabilities were set for the current plugin
*/
public function check_default_cap() {
$admin = get_role( 'administrator' );
$option = $this->tag . '_def_caps_set';
if ( $admin && ! get_option( $option ) && $admin->has_cap( $this->get_cap() ) ) {
update_option( $option, true );
return;
}
if ( ! get_option( $option ) ) {
$editor = get_role( 'editor' );
if ( $admin ) {
$admin->add_cap( $this->get_cap() );
}
if ( $editor ) {
$editor->add_cap( $this->get_cap() );
}
}
}
/**
* Check if the current user has access to the product
*
* @return bool
*/
public static function has_access() {
$product = static::instance()->get_tag();
return apply_filters( 'thrive_has_access_' . $product, current_user_can( static::cap() ) );
}
public static function cap() {
return static::instance()->get_cap();
}
/**
* Make sure that each class is instantiated only once
*
* @return mixed
*/
public static function instance() {
$cls = get_called_class();
if ( ! isset( self::$instances[ $cls ] ) ) {
self::$instances[ $cls ] = new static;
}
return self::$instances[ $cls ];
}
/**
* Whether or not this product has a dependency on TAr
*
* @return bool
*/
public function needs_architect() {
return $this->needs_architect;
}
/**
* Getter for invalid architect version
*
* @return bool
*/
public function get_incompatible_architect_version() {
return $this->incompatible_architect_version;
}
/**
* Returns the product admin URL
*
* @return string
*/
public function get_admin_url() {
return ! empty( $this->button['url'] ) ? $this->button['url'] : '';
}
/**
* Define reset functionality for our products
*
* @return bool
*/
public static function reset_plugin() {
return true;
}
/**
* Returns true if product is ready from TPM point of view
* Used in ThriveApprentice for certificate functionality
*
* @return boolean
*/
public static function is_ready() {
if ( ! TD_TTW_Connection::get_instance()->is_connected() || ! class_exists( 'TPM_Product_List', false ) ) {
return false;
}
$tpm_product = TPM_Product_List::get_instance()->get_product_instance( static::instance()->get_tag() );
return $tpm_product->get_status() === 'ready';
}
}

View File

@@ -0,0 +1,275 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-dashboard
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
class TVE_Dash_Product_LicenseManager {
const LICENSE_OPTION_NAME = 'thrive_license';
const TCB_TAG = 'tcb';
const TL_TAG = 'tl';
const TCW_TAG = 'tcw';
const ALL_TAG = 'all';
const TU_TAG = 'tu';
const THO_TAG = 'tho';
const TVO_TAG = 'tvo';
const TQB_TAG = 'tqb';
const TCM_TAG = 'tcm';
const TVA_TAG = 'tva';
const TAB_TAG = 'tab';
const TPM_TAG = 'tpm';
const TAG_FOCUS = 'focusblog';
const TAG_LUXE = 'luxe';
const TAG_IGNITION = 'ignition';
const TAG_MINUS = 'minus';
const TAG_SQUARED = 'squared';
const TAG_VOICE = 'voice';
const TAG_PERFORMAG = 'performag';
const TAG_PRESSIVE = 'pressive';
const TAG_STORIED = 'storied';
const TAG_RISE = 'rise';
protected $secret_key = '@#$()%*%$^&*(#@$%@#$%93827456MASDFJIK3245';
protected static $instance;
protected $license_data;
protected $accepted_tags = array();
protected function __construct() {
$this->license_data = get_option( static::LICENSE_OPTION_NAME, array() );
$reflection = new ReflectionClass( $this );
$constants = $reflection->getConstants();
$this->accepted_tags = array();
foreach ( $constants as $name => $value ) {
if ( strpos( $name, 'TAG' ) !== false ) {
$this->accepted_tags [] = $value;
}
}
}
public static function getInstance() {
if ( empty( static::$instance ) ) {
static::$instance = new TVE_Dash_Product_LicenseManager();
}
return static::$instance;
}
/**
* whether or not $tag is a theme tag
* used in backwards-compatible license check
*
* @param string $tag
*
* @return array
*/
public static function isThemeTag( $tag ) {
return in_array( $tag, array(
static::TAG_FOCUS,
static::TAG_IGNITION,
static::TAG_LUXE,
static::TAG_MINUS,
static::TAG_PERFORMAG,
static::TAG_PRESSIVE,
static::TAG_RISE,
static::TAG_SQUARED,
static::TAG_STORIED,
static::TAG_VOICE,
) );
}
/**
* Checks license options
*
* @param string|TVE_Dash_Product_Abstract $item
*
* @return bool
*/
public function itemActivated( $item ) {
if ( $item instanceof TVE_Dash_Product_Abstract ) {
$item = $item->get_tag();
}
if ( function_exists( 'thrive_product_manager' ) ) {
return thrive_product_manager()->itemActivated( $item, $this );
}
if ( $this->isThemeTag( $item ) ) {
$licensed = get_option( 'thrive_license_status', false ) === 'ACTIVE';
} else {
switch ( $item ) {
case static::TCB_TAG:
$licensed = get_option( 'tve_license_status', false ) === 'ACTIVE';
break;
case static::TL_TAG:
$licensed = get_option( 'tve_leads_license_status', false ) === 'ACTIVE';
break;
case static::TCW_TAG:
$licensed = get_option( 'tcw_license_status', false ) === 'ACTIVE';
break;
default:
$licensed = false;
break;
}
}
if ( $licensed === false ) {
$licensed = $this->checkData( $item );
}
return $licensed;
}
/**
* @param $item TVE_Dash_Product_Abstract|string
*
* @return bool
*/
protected function checkData( $item = null ) {
if ( empty( $this->license_data ) || null === $item ) {
return false;
}
if ( in_array( static::ALL_TAG, $this->license_data ) ) {
return true;
}
if ( $item instanceof TVE_Dash_Product_Abstract ) {
$tag = $item->get_tag();
} elseif ( is_string( $item ) ) {
$tag = $item;
}
return isset( $tag ) ? in_array( $tag, $this->license_data ) : false;
}
public function checkLicense( $email, $key, $tag = false ) {
$service_api_url = defined( 'TD_SERVICE_API_URL' ) ? TD_SERVICE_API_URL : 'https://service-api.thrivethemes.com';
$api_url = rtrim($service_api_url, '/') . '/license';
$body = array(
'email' => $email,
'license' => $key,
'site_url' => get_site_url(),
);
if ( $tag !== false ) {
$body['tag'] = $tag;
}
$api_url = add_query_arg( array(
'p' => $this->calc_hash( $body ),
), $api_url );
$_args = array(
'sslverify' => false,
'timeout' => 120,
'headers' => array(
'User-Agent' => 'WordPress',
),
'body' => $body,
);
$licenseValid = wp_remote_post( $api_url, $_args );
$response = array();
if ( is_wp_error( $licenseValid ) ) {
/** @var WP_Error $licenseValid */
/** Couldn't connect to the API URL - possible because wp_remote_get failed for whatever reason. Maybe CURL not activated on server, for instance */
$response['success'] = 0;
$response['reason'] = sprintf( __( "An error occurred while connecting to the license server. Error: %s. Please login to thrivethemes.com, report this error message on the forums and we'll get this sorted for you", 'thrive-dash' ), $licenseValid->get_error_message() );
return $response;
}
$response = @json_decode( $licenseValid['body'], true );
if ( empty( $response ) ) {
$response = new stdClass();
$response['success'] = 0;
$response['reason'] = sprintf( __( "An error occurred while receiving the license status. The response was: %s. Please login to thrivethemes.com, report this error message on the forums and we'll get this sorted for you.", 'thrive-dash' ), $licenseValid['body'] );
return $response;
}
return $response;
}
protected function calc_hash( $data ) {
return md5( $this->secret_key . serialize( $data ) . $this->secret_key );
}
public function activateProducts( &$response ) {
//check success flag
if ( empty( $response['success'] ) ) {
$response['success'] = 0;
$response['reason'] = __( 'Invalid response!', 'thrive-dash' );
return null;
}
//check if products is not empty and is array
if ( empty( $response['products'] ) || ! is_array( $response['products'] ) ) {
$response['success'] = 0;
$response['reason'] = __( 'Invalid products returned from server!', 'thrive-dash' );
return null;
}
foreach ( $response['products'] as $product_tag ) {
if ( ! in_array( $product_tag, $this->accepted_tags ) ) {
$response['success'] = 0;
$response['reason'] = __( 'Products returned from server are not accepted for licensing!', 'thrive-dash' );
return null;
}
}
//do the logic and update the option in DB
if ( in_array( static::ALL_TAG, $response['products'] ) ) {
update_option( static::LICENSE_OPTION_NAME, array( static::ALL_TAG ) );
} else {
$existing = get_option( static::LICENSE_OPTION_NAME, array() );
update_option( static::LICENSE_OPTION_NAME, array_unique( array_merge( $existing, $response['products'] ) ) );
}
return $response;
}
/**
* Based on $text_domain returns a tag associated
*
* @param string $text_domain
*
* @return string
*/
public static function get_product_tag( $text_domain ) {
$mapping = array(
'thrive-cb' => static::TCB_TAG,
'thrive-leads' => static::TL_TAG,
'thrive-clever-widgets' => static::TCW_TAG,
'thrive-ult' => static::TU_TAG,
'thrive-headline' => static::THO_TAG,
'thrive-ovation' => static::TVO_TAG,
'thrive-quiz-builder' => static::TQB_TAG,
'thrive-comments' => static::TCM_TAG,
'thrive-apprentice' => static::TVA_TAG,
'thrive-optimize' => static::TAB_TAG,
'thrive-product-manager' => static::TPM_TAG,
);
return $mapping[ $text_domain ] ?? '';
}
}