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,173 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-visual-editor
*/
namespace TCB\Notifications;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
class Hooks {
public static function add_actions() {
if ( Main::is_edit_screen() ) {
add_action( 'tcb_main_frame_enqueue', [ __CLASS__, 'main_frame_enqueue' ] );
add_action( 'wp_loaded', [ __CLASS__, 'enqueue_scripts' ] );
add_action( 'tcb_output_components', [ __CLASS__, 'tcb_output_components' ] );
}
add_action( 'tcb_editor_enqueue_scripts', [ __CLASS__, 'editor_enqueue' ] );
add_action( 'wp_footer', [ __CLASS__, 'insert_notification_element' ] );
add_action( 'wp_ajax_notification_update_template', [ __CLASS__, 'update_template' ] );
add_action( 'admin_footer', [ __CLASS__, 'add_global_variables' ] );
}
public static function add_filters() {
add_filter( 'tcb_element_instances', [ __CLASS__, 'tcb_element_instances' ] );
add_filter( 'tcb_has_templates_tab', [ __CLASS__, 'has_templates' ] );
add_filter( 'tve_main_js_dependencies', [ __CLASS__, 'tve_main_js_dependencies' ] );
}
/* ###################################### ACTIONS ###################################### */
/**
* Enqueue scripts in the main frame
*/
public static function main_frame_enqueue() {
tve_dash_enqueue_script( 'tve-notifications-main', tve_editor_js( '/notifications-main.min.js' ), [ 'jquery' ] );
}
/**
* Used to localize the elements (wrapper and message)
*/
public static function enqueue_scripts() {
static::main_frame_enqueue();
$elements = [];
foreach ( Main::$elements as $element ) {
$elements[] = $element->tag();
}
wp_localize_script( 'tve-notifications-main', 'tve_notification', [
'elements' => $elements,
] );
}
/**
* Include the notification controls component
*/
public static function tcb_output_components() {
$path = TVE_TCB_ROOT_PATH . 'inc/views/notifications/components/';
$files = array_diff( scandir( $path ), [ '.', '..' ] );
foreach ( $files as $file ) {
include $path . $file;
}
}
/**
* Enqueue scripts in the editor
*/
public static function editor_enqueue() {
if ( Main::is_edit_screen() ) {
tve_dash_enqueue_script( 'tve-notifications-editor', tve_editor_js( '/notifications-editor.min.js' ), [ 'jquery' ] );
}
}
/**
* Insert the notification in every page
*/
public static function insert_notification_element() {
if ( ! ( Main::is_preview_screen() || Main::is_edit_screen() ) ) {
echo Main::get_notification_content( true, '', false, false );
}
}
/**
* Update notification template with the selected one
*/
public static function update_template() {
$id = filter_input( INPUT_POST, 'post_id', FILTER_SANITIZE_NUMBER_INT );
/* Un-set the previously set template */
$posts = get_posts( [
'post_type' => Post_Type::NAME,
'fields' => 'ids',
] );
if ( ! empty( $posts ) ) {
foreach ( $posts as $key => $postId ) {
update_post_meta( $postId, 'default', 0 );
}
}
/* Set the selected template as default */
update_post_meta( $id, 'default', 1 );
}
/**
* Only load global variables in the Global Elements tab inside the Dashboard
*/
public static function add_global_variables() {
if ( tve_get_current_screen_key() === 'admin_page_tcb_admin_dashboard' ) {
tve_load_global_variables();
}
}
/* ###################################### FILTERS ###################################### */
/**
* Add Notifications elements to the editor
*
* @param array $instances
*
* @return array
*/
public static function tcb_element_instances( $instances ) {
if ( Main::is_edit_screen() || wp_doing_ajax() ) {
$instances = array_merge( $instances, Main::$elements );
}
return $instances;
}
/**
* Remove cloud templates icon from the right sidebar
*
* @param bool $has_templates
*
* @return false
*/
public static function has_templates( $has_templates ) {
if ( Post_Type::is_notification() ) {
$has_templates = false;
}
return $has_templates;
}
/**
* Add notification dependency
*
* @param $dependencies
*
* @return mixed
*/
public static function tve_main_js_dependencies( $dependencies ) {
if ( Main::is_edit_screen() ) {
$dependencies[] = 'tve-notifications-main';
}
return $dependencies;
}
}

View File

@@ -0,0 +1,237 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-visual-editor
*/
namespace TCB\Notifications;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
class Main {
const EDIT_FLAG = 'tve-notifications',
OPTION_NAME = 'tve_notifications_post_id';
public static $elements = [];
public static function init() {
static::includes();
static::register_elements();
Hooks::add_actions();
Hooks::add_filters();
Post_Type::init();
}
public static function includes() {
require_once __DIR__ . '/class-post-type.php';
require_once __DIR__ . '/class-hooks.php';
}
/**
* Load elements needed for the notifications editor
*/
public static function register_elements() {
$path = __DIR__ . '/elements';
$items = array_diff( scandir( $path ), [ '.', '..' ] );
static::$elements = [];
foreach ( $items as $item ) {
$item_path = $path . '/' . $item;
/* if the item is a file, include it */
if ( is_file( $item_path ) && substr( $item_path, - 3 ) === 'php' ) {
$element = include $item_path;
if ( ! empty( $element ) ) {
static::$elements[ $element->tag() ] = $element;
}
}
}
}
public static function title() {
return __( 'Notifications', 'thrive-cb' );
}
/**
* Check if current page is the edit page for the notifications
*
* @return bool
*/
public static function is_edit_screen() {
$is_edit_screen = isset( $_GET[ Main::EDIT_FLAG ] ) || Post_Type::is_notification();
return apply_filters( 'tcb_is_notifications_edit_screen', $is_edit_screen );
}
/**
* Check if current page is the preview page for the notifications
*
* @return bool
*/
public static function is_preview_screen() {
return isset( $_GET['notification-state'] );
}
public static function get_localized_data() {
return [
'notifications_edit_url' => Post_Type::instance()->get_edit_url(),
'notifications_template' => static::get_notification_template_id(),
'notifications_custom_content' => static::get_custom_content(),
];
}
public static function get_notification_post_id() {
return get_option( static::OPTION_NAME, 0 );
}
/**
* Get notification content
*
* @param $should_hide - should be hidden/displayed
* @param $state - what state should be displayed
* @param $is_preview - check if this is the dashboard preview
*
* @return string
*/
public static function get_notification_content( $should_hide, $state, $is_preview, $display_custom ) {
if ( ! $display_custom && static::get_notification_template_id() === 0 ) {
$post_content = static::get_default_content();
} else {
$post_content = static::get_custom_content();
if ( empty( $post_content ) ) {
if ( static::is_preview_screen() || static::is_edit_screen() ) {
$post_content = static::get_default_content( 'custom' );
} else {
$post_content = static::get_default_content();
}
}
/* backwards compatibility for animated class - remove this in a few releases */
$post_content = str_replace( 'notifications-content-wrapper animated', 'notifications-content-wrapper', $post_content );
/* Hide the notification element */
if ( $should_hide && ( ! static::is_edit_screen() || static::is_preview_screen() ) ) {
$post_content = str_replace( 'notifications-content-wrapper', 'notifications-content-wrapper tcb-permanently-hidden', $post_content );
}
/* Change the state to the desired one */
if ( $state ) {
$post_content = preg_replace( '/data-state="[a-z]*"/', 'data-state="' . $state . '"', $post_content );
}
/* For the dashboard preview, remove the position attribute */
if ( $is_preview ) {
$post_content = preg_replace( '/data-position="[a-z]*-[a-z]*"/', '', $post_content );
}
}
tve_parse_events( $post_content );
$post_content = do_shortcode( $post_content );
$css = static::get_notification_meta_style( true, $is_preview );
return $css . $post_content;
}
/**
* Return default notification content
*
* @param string $type
*
* @return false|string
*/
public static function get_default_content( $type = '' ) {
ob_start();
if ( ! empty( $type ) ) {
$type = '-' . $type;
}
include TVE_TCB_ROOT_PATH . 'inc/views/notifications/notification-default' . $type . '-content.php';
return ob_get_clean();
}
public static function get_custom_content() {
$post_id = static::get_notification_post_id();
return get_post_meta( $post_id, 'tve_updated_post', true );
}
public static function is_default_design() {
$post_id = static::get_notification_post_id();
return get_post_meta( $post_id, 'default', true );
}
public static function get_notification_template_id() {
$posts = get_posts( [
'post_type' => Post_Type::NAME,
'meta_query' => [
[
'key' => 'default',
'value' => 1,
],
],
'fields' => 'ids',
] );
if ( ! empty( $posts ) ) {
return $posts[0];
}
return 0;
}
/**
* Get the styling of the notification
*/
public static function get_notification_meta_style( $return = true, $is_preview = false ) {
$post_id = Post_Type::instance()->get_id();
$css = '';
if ( get_the_ID() !== $post_id ) {
$lightspeed_css = \TCB\Lightspeed\Css::get_instance( $post_id );
if ( $is_preview || $lightspeed_css->should_load_optimized_styles() ) {
$css .= $lightspeed_css->get_optimized_styles();
}
$css .= sprintf( '<style type="text/css" id="tve_notification_styles">%s</style>', get_post_meta( $post_id, 'tve_custom_css', true ) );
}
if ( $return ) {
return $css;
}
echo $css;
}
/**
* Get the default styling of the notification
*
* @return false|string
*/
public static function get_notification_default_style() {
ob_start();
include dirname( __DIR__ ) . '/../../editor/css/sass/elements/_notification.scss';
return ob_get_clean();
}
public static function get_default_notification_element() {
$default_html_content = static::get_default_content( 'custom' );
$default_css_content = static::get_notification_default_style();
return [ 'html' => $default_html_content, 'css' => $default_css_content ];
}
}

View File

@@ -0,0 +1,239 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-visual-editor
*/
namespace TCB\Notifications;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
class Post_Type {
const NAME = 'tve_notifications';
/**
* @var Post_Type
*/
private static $_instance;
/**
* @var \WP_Post
*/
private $post;
/**
* @var \WP_Post
*/
private $ID;
/**
* Post_Type constructor.
*
* @param \WP_Post $post
*/
public function __construct( $post ) {
$this->post = $post;
$this->ID = $post->ID;
}
public static function init() {
static::register_post_type();
add_filter( 'tve_dash_exclude_post_types_from_index', [ __CLASS__, 'exclude_from_index' ] );
add_filter( 'tcb_post_types', [ __CLASS__, 'allow_tcb_edit' ] );
add_filter( 'tcb_custom_post_layouts', [ __CLASS__, 'notifications_layout' ], 10, 3 );
add_filter( 'thrive_theme_allow_body_class', [ __CLASS__, 'theme_body_class' ], 99, 1 );
add_filter( 'thrive_theme_ignore_post_types', [ __CLASS__, 'ignore_post_type' ] );
}
public static function register_post_type() {
if ( post_type_exists( static::NAME ) ) {
return;
}
register_post_type(
static::NAME,
[
'public' => isset( $_GET[ TVE_EDITOR_FLAG ] ),
'publicly_queryable' => is_user_logged_in(),
'query_var' => false,
'exclude_from_search' => true,
'rewrite' => false,
'_edit_link' => 'post.php?post=%d',
'map_meta_cap' => true,
'label' => Main::title(),
'capabilities' => [
'edit_others_posts' => 'tve-edit-cpt',
'edit_published_posts' => 'tve-edit-cpt',
],
'show_in_nav_menus' => false,
'show_in_menu' => false,
'show_in_rest' => true,
'has_archive' => false,
] );
}
/**
* Don't index this post type
*
* @param $post_types
*
* @return mixed
*/
public static function exclude_from_index( $post_types ) {
$post_types[] = static::NAME;
return $post_types;
}
/**
* Allow tcb to edit the notification element
*
* @param $post_types
*
* @return mixed
*/
public static function allow_tcb_edit( $post_types ) {
if ( static::is_notification() ) {
if ( ! isset( $post_types['force_whitelist'] ) ) {
$post_types['force_whitelist'] = [];
}
$post_types['force_whitelist'][] = static::NAME;
}
return $post_types;
}
/**
* Insert the custom layout for the notifications editor
*
* @param $layouts
* @param $post_id
* @param $post_type
*
* @return mixed
*/
public static function notifications_layout( $layouts, $post_id, $post_type ) {
if ( $post_type === static::NAME ) {
$file_path = TVE_TCB_ROOT_PATH . 'inc/views/notifications/notifications-editor.php';
$layouts['notification_template'] = $file_path;
}
return $layouts;
}
/**
* Prevent adding ttb classes while editing symbols
*
* @param $allow_theme_classes
*
* @return false
*/
public static function theme_body_class( $allow_theme_classes ) {
if ( static::is_notification() ) {
$allow_theme_classes = false;
}
return $allow_theme_classes;
}
/**
* Do not create theme template for the notifications post type
*
* @param $post_types
*
* @return mixed
*/
public static function ignore_post_type( $post_types ) {
$post_types[] = 'tve_notifications';
return $post_types;
}
/**
* Return an instance of the post that edits the notifications
*
* @return Post_Type|null
*/
public static function instance() {
if ( static::$_instance !== null ) {
return static::$_instance;
}
if ( Main::is_edit_screen() ) {
$post = get_post();
return new self( $post );
}
$posts = get_posts( [
'post_type' => static::NAME,
] );
// Return null on frontend if no posts exist
if ( empty( $posts ) && ! is_admin() ) {
return null;
}
$post = empty( $posts ) ? static::create_default() : $posts[0];
return new self( $post );
}
/**
* Create and return the default notifications post
*
* @return array|\WP_Post|null
*/
public static function create_default() {
$default = [
'post_title' => Main::title(),
'post_type' => static::NAME,
'post_status' => 'publish',
'meta_input' => [
'default' => '0',
],
];
$post_id = wp_insert_post( $default );
update_option( Main::OPTION_NAME, $post_id );
return get_post( $post_id );
}
/**
* Get edit url for the notifications page
*
* @return string
*/
public function get_edit_url() {
return tcb_get_editor_url( $this->ID );
}
public function get_id() {
return $this->ID;
}
/**
* Check if we're on a notification post type
*
* @return bool
*/
public static function is_notification() {
$post_type = get_post_type();
if ( empty( $post_type ) && is_admin() && isset( $_GET['post'] ) ) {
$post_type = get_post_type( $_GET['post'] );
}
return $post_type === static::NAME;
}
}

View File

@@ -0,0 +1,76 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-visual-editor
*/
namespace TCB\Notifications;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
/**
* Class Notification_Message
*
* @package TCB\Notifications
*/
class Notification_Message extends \TCB_Element_Abstract {
/**
* Name of the element
*
* @return string
*/
public function name() {
return __( 'Notification message', 'thrive-cb' );
}
/**
* WordPress element identifier
*
* @return string
*/
public function identifier() {
return '.notifications-content .thrv-notification_message';
}
public function own_components() {
$components = $this->general_components();
/* Remove suffix so that the settings apply on the correct element*/
foreach ( $components['typography']['config'] as $control => $config ) {
if ( in_array( $control, [ 'css_suffix', 'css_prefix' ] ) ) {
continue;
}
$components['typography']['config'][ $control ]['css_suffix'] = [ '' ];
}
$components['notification_message'] = $components['typography'];
$components['typography'] = [ 'hidden' => true ];
return $components;
}
public function category() {
return static::get_thrive_advanced_label();
}
public function has_hover_state() {
return true;
}
/**
* Return icon class needed for display in menu
*
* @return string
*/
public function icon() {
return 'notification-message';
}
}
return new Notification_Message( 'notification_message' );

View File

@@ -0,0 +1,214 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-visual-editor
*/
namespace TCB\Notifications;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
/**
* Class Content_Wrapper
*
* @package TCB\Notifications
*/
class Notifications_Content_Wrapper extends \TCB_Cloud_Template_Element_Abstract {
/**
* Name of the element
*
* @return string
*/
public function name() {
return __( 'Notification', 'thrive-cb' );
}
/**
* WordPress element identifier
*
* @return string
*/
public function identifier() {
return '.notifications-content-wrapper';
}
public function own_components() {
$components = parent::own_components();
$components['animation'] = [ 'hidden' => true ];
$components['typography'] = [ 'hidden' => true ];
$components['layout']['disabled_controls'] = [ 'Alignment', 'Display', '.tve-advanced-controls' ];
/* only apply the styles to the currently visible notification state */
$components['layout']['config'] = [ 'to' => '.notifications-content:visible' ];
$components['background']['config'] = [ 'to' => '.notifications-content:visible' ];
$components['borders']['config'] = [ 'to' => '.notifications-content:visible' ];
$components['shadow']['config'] = [ 'to' => '.notifications-content:visible' ];
$components['notification'] = [
'config' => [
'DisplayPosition' => [
'config' => [
'name' => __( 'Display position', 'thrive-cb' ),
'large_buttons' => true,
'buttons' => [
[
'text' => '',
'value' => 'top-left',
],
[
'text' => '',
'value' => 'top-center',
],
[
'text' => '',
'value' => 'top-right',
],
[
'text' => '',
'value' => 'middle-left',
],
[
'text' => '',
'value' => 'middle-center',
],
[
'text' => '',
'value' => 'middle-right',
],
[
'text' => '',
'value' => 'bottom-left',
],
[
'text' => '',
'value' => 'bottom-center',
],
[
'text' => '',
'value' => 'bottom-right',
],
],
],
'extends' => 'ButtonGroup',
],
'VerticalSpacing' => [
'config' => [
'name' => __( 'Top spacing', 'thrive-cb' ),
'min' => '0',
'default' => '50',
'um' => [ 'px' ],
],
'extends' => 'Input',
],
'HorizontalSpacing' => [
'config' => [
'name' => __( 'Side spacing', 'thrive-cb' ),
'min' => '0',
'default' => '50',
'um' => [ 'px' ],
],
'extends' => 'Input',
],
'AnimationDirection' => [
'config' => [
'name' => __( 'Animation direction', 'thrive-cb' ),
'default' => 'down',
'options' => [
[
'value' => 'none',
'name' => __( 'No animation', 'thrive-cb' ),
],
[
'value' => 'down',
'name' => __( 'Down', 'thrive-cb' ),
],
[
'value' => 'up',
'name' => __( 'Up', 'thrive-cb' ),
],
[
'value' => 'right',
'name' => __( 'Right', 'thrive-cb' ),
],
[
'value' => 'left',
'name' => __( 'Left', 'thrive-cb' ),
],
],
],
'extends' => 'Select',
],
'AnimationTime' => [
'config' => [
'min' => '0',
'max' => '10',
'default' => '3',
'step' => '0.1',
'label' => __( 'Show for (s)', 'thrive-cb' ),
'um' => [ 's' ],
],
'extends' => 'Slider',
],
'MaximumWidth' => [
'config' => [
'min' => '100',
'max' => '2000',
'default' => '200',
'label' => __( 'Maximum Width', 'thrive-cb' ),
'um' => [ 'px' ],
],
'extends' => 'Slider',
],
'MinimumHeight' => [
'config' => [
'min' => '1',
'max' => '1000',
'default' => '200',
'label' => __( 'Minimum Height', 'thrive-cb' ),
'um' => [ 'px' ],
],
'extends' => 'Slider',
],
'VerticalPosition' => [
'config' => [
'name' => __( 'Content Align', 'thrive-cb' ),
'buttons' => [
[
'icon' => 'top',
'value' => 'flex-start',
],
[
'icon' => 'vertical',
'value' => 'center',
],
[
'icon' => 'bot',
'value' => 'flex-end',
],
],
],
'extends' => 'ButtonGroup',
],
],
];
return $components;
}
public function hide() {
return true;
}
/**
* @return bool
*/
public function is_placeholder() {
return false;
}
}
return new Notifications_Content_Wrapper( 'notification' );