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,112 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-visual-editor
*/
namespace TCB\Integrations\SmashBalloon;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
/**
* Class Element
*
* @package TCB\Integrations\SmashBalloon
*/
class Element extends \TCB_Element_Abstract {
/**
* @return string
*/
public function name() {
return __( 'Smash Balloon Social Feed', 'thrive-cb' );
}
/**
* @return string
*/
public function icon() {
return 'smash-balloon';
}
/**
*
* Get element alternate
*
* These are the different keywords to use on the elements' search bar.
*
* @return string
*/
public function alternate() {
return 'smash, balloon, feed, feeds, instagram, facebook, youtube, reviews';
}
/**
* @return string
*/
public function identifier() {
return Main::IDENTIFIER;
}
/**
* @return array
*/
public function own_components() {
$list_feeds = [];
$components = array(
'smash-balloon-options' => array(
'config' => array(
'SmashType' => array(
'config' => [
'default' => '',
'name' => __( 'Type', 'thrive-cb' ),
'options' => Main::sb_available_plugins(),
],
'extends' => 'Select',
),
'SmashFeed' => array(
'config' => [
'default' => '',
'name' => __( 'Feed', 'thrive-cb' ),
'options' => [],
],
'extends' => 'Select',
),
),
),
'layout' => [ 'hidden' => true ],
'responsive' => [ 'hidden' => true ],
'background' => [ 'hidden' => true ],
'typography' => [ 'hidden' => true ],
'borders' => [ 'hidden' => true ],
'animation' => [ 'hidden' => true ],
'shadow' => [ 'hidden' => true ],
'styles-templates' => [ 'hidden' => true ],
);
return $components;
}
/**
* Element category that will be displayed in the sidebar
*
* @return string
*/
public function category() {
return 'Integrations';
}
/**
* Whether or not this element can be edited while under :hover state
*
* @return bool
*/
public function has_hover_state() {
return false;
}
}
return new Element( 'smash-balloon' );

View File

@@ -0,0 +1,147 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-visual-editor
*/
namespace TCB\Integrations\SmashBalloon;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
/**
* Class Hooks
*
* @package TCB\Integrations\SmashBalloon
*/
class Hooks {
public static function add() {
static::add_actions();
static::add_filters();
}
public static function add_actions() {
add_action( 'plugins_loaded', [ __CLASS__, 'tcb_insta_feeds' ] );
add_action( 'tcb_output_components', [ __CLASS__, 'tcb_output_components' ] );
add_action( 'wp_print_footer_scripts', [ __CLASS__, 'wp_print_footer_scripts' ], 9 );
add_action( 'tcb_main_frame_enqueue', [ __CLASS__, 'tcb_main_frame_enqueue' ] );
add_action( 'rest_api_init', [ __CLASS__, 'rest_api_init' ] );
add_action( 'wp_head', [ __CLASS__, 'tcb_main_css_enqueue' ] );
}
public static function add_filters() {
add_filter( 'tcb_element_instances', [ __CLASS__, 'tcb_element_instances' ] );
add_filter( 'tve_main_js_dependencies', [ __CLASS__, 'tve_main_js_dependencies' ] );
add_filter( 'thrive_theme_should_render_shortcode', [ __CLASS__, 'thrive_theme_should_render_shortcode' ], 10, 2 );
}
/**
* Include rendered element so we can use it for drag n drop
*
* @return void
*/
public static function wp_print_footer_scripts() {
if ( TCB_Editor()->is_inner_frame() ) {
$templates = tve_dash_get_backbone_templates( TVE_TCB_ROOT_PATH . 'inc/smash-balloon/views/backbone' );
tve_dash_output_backbone_templates( $templates, 'tve-smash-balloon-' );
}
}
/**
* Add our js file as a dependency for the main file so it loads before
*
* @param $dependencies
*
* @return mixed
*/
public static function tve_main_js_dependencies( $dependencies ) {
$dependencies[] = 'smash-balloon-editor-main';
return $dependencies;
}
/**
* Load our css file(s)
*
* @return void
*/
public static function tcb_main_css_enqueue() {
wp_enqueue_style( 'smash-balloon-editor-css', tve_editor_url() . '/inc/smash-balloon/css/main.css', false, '', '' );
}
/**
* Load our js files
*
* @return void
*/
public static function tcb_main_frame_enqueue() {
wp_enqueue_script( 'smash-balloon-editor-main', tve_editor_url() . '/inc/smash-balloon/js/hooks.js' );
}
/**
* Allow the shortcode to be rendered in the editor
*
* @param $should_render
* @param $shortcode_tag
*
* @return mixed|true
*/
public static function thrive_theme_should_render_shortcode( $should_render, $shortcode_tag ) {
switch ( $shortcode_tag ) {
case 'custom-facebook-feed':
case 'instagram-feed':
case 'custom-twitter-feeds':
case 'youtube-feed':
case 'tiktok-feeds':
case 'sbtt-tiktok':
case 'social-wall':
$should_render = true;
break;
default:
// do nothing
break;
}
return $should_render;
}
/**
* @param $instances
*
* @return mixed
*/
public static function tcb_element_instances( $instances ) {
$element = require_once __DIR__ . '/class-element.php';
$instances[ $element->tag() ] = $element;
return $instances;
}
/**
* Include editor components
*/
public static function tcb_output_components() {
$path = TVE_TCB_ROOT_PATH . 'inc/smash-balloon/views/components/';
$files = array_diff( scandir( $path ), [ '.', '..' ] );
foreach ( $files as $file ) {
include $path . $file;
}
}
/**
* Initialize the rest api class
*/
public static function rest_api_init() {
require_once TVE_TCB_ROOT_PATH . 'inc/smash-balloon/classes/class-rest-api.php';
Rest_Api::register_routes();
}
}

View File

@@ -0,0 +1,337 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-visual-editor
*/
namespace TCB\Integrations\SmashBalloon;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
/**
* Class Main
*
* @package TCB\Integrations\SmashBalloon
*/
class Main {
const IDENTIFIER = '.tcb-smash-balloon';
public static function init() {
if ( static::active() ) {
static::includes();
Hooks::add();
}
// Load Smash Balloon missing scripts
$plugins = static::sb_plugins_info();
if ( $plugins['instagram']['is_active'] ) {
sb_instagram_scripts_enqueue( true );
}
if ( $plugins['youtube']['is_active'] ) {
do_action('sby_enqueue_scripts', true);
}
if ( $plugins['tiktok']['is_active'] ) {
do_action('sbtt_enqueue_scripts', true);
}
if ( $plugins['social-wall']['is_active'] ) {
sbsw_scripts_enqueue( true );
}
}
/**
* @param string $subpath
*
* @return string
*/
public static function get_integration_path( $subpath = '' ) {
return TVE_TCB_ROOT_PATH . 'inc/smash-balloon/' . $subpath;
}
public static function includes() {
$integration_path = static::get_integration_path();
require_once $integration_path . 'classes/class-hooks.php';
}
/**
* Check if the plugin is active
*
* @return bool
*/
public static function active() {
$active_plugins = 0;
foreach ( static::sb_plugins_info() as $key => $plugin ) {
if ( $plugin['is_active'] ) {
$active_plugins += 1;
}
}
return $active_plugins > 0 ? true : false;
}
/**
* List all Smash Balloon plugins
*
* @return array
*/
public static function sb_plugins_list() {
$list = array(
'facebook' => array(
'name' => __( 'Custom Facebook Feed', 'thrive-cb' ),
'value' => 'custom-facebook-feed',
'path' => array(
'free' => 'custom-facebook-feed/custom-facebook-feed.php',
'pro' => 'custom-facebook-feed-pro/custom-facebook-feed.php'
),
),
'instagram' => array(
'name' => __( 'Instagram Feed', 'thrive-cb' ),
'value' => 'instagram-feed',
'path' => array(
'free' => 'instagram-feed/instagram-feed.php',
'pro' => 'instagram-feed-pro/instagram-feed.php'
),
),
'twitter' => array(
'name' => __( 'Custom Twitter Feeds', 'thrive-cb' ),
'value' => 'custom-twitter-feeds',
'path' => array(
'free' => 'custom-twitter-feeds/custom-twitter-feed.php',
'pro' => 'custom-twitter-feeds-pro/custom-twitter-feed.php'
),
),
'youtube' => array(
'name' => __( 'Feeds for YouTube', 'thrive-cb' ),
'value' => 'youtube-feed',
'path' => array(
'free' => 'feeds-for-youtube/youtube-feed.php',
'pro' => 'youtube-feed-pro/youtube-feed.php'
),
),
'tiktok' => array(
'name' => __( 'TikTok Feeds', 'thrive-cb' ),
'value' => 'sbtt-tiktok',
'path' => array(
'free' => 'feeds-for-tiktok/feeds-for-tiktok.php',
'pro' => 'tiktok-feeds-pro/tiktok-feeds-pro.php'
),
),
'social-wall' => array(
'name' => __( 'Social Wall', 'thrive-cb' ),
'value' => 'social-wall',
'path' => array(
'free' => '',
'pro' => 'social-wall/social-wall.php'
),
),
);
return $list;
}
/**
* Get active plugins of Smash Balloon
*
* @return array
*/
public static function sb_plugins_info() {
// WordPress core list of installed plugins
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$list = [];
$installed_plugins = get_plugins();
foreach ( static::sb_plugins_list() as $plugin_key => $plugin_info ) {
$name = $plugin_info['name'];
$value = $plugin_info['value'];
$path = $plugin_info['path'];
$is_installed = isset( $installed_plugins[ $path['pro'] ] ) || isset( $installed_plugins[ $path['free'] ] ) ? true : false;
$is_active = is_plugin_active( $path['pro'] ) || is_plugin_active( $path['free'] ) ? true : false;
$list = array_merge( $list, array(
$plugin_key => array(
'name' => $name,
'value' => $value,
'is_installed' => $is_installed,
'is_active' => $is_active
)
) );
}
return $list;
// Structure example:
// Array( [plugin] => Array( [name] => Plugin Name, [value] => plugin-key, [is_installed] => 1, [is_active] => 0 ) )
}
/**
* List available plugins
*
* @return array
*/
public static function sb_available_plugins() {
$list = [];
$plugins = Main::sb_plugins_info();
// Placeholder
// Fix: Add empty value first in list to solve the control update/change funcs.
$list[] = [
'name' => __( 'Select a plugin', 'thrive-cb' ),
'value' => '',
];
foreach ( $plugins as $key => $plugin ) {
if ( $plugin['is_active'] === TRUE ) {
$list[] = [
'name' => $plugin['name'],
'value' => $plugin['value']
];
}
}
return $list;
}
/**
* List available feeds
*
* @return void
*/
public static function sb_available_feeds( $plugin_name ) {
// Initialize variables
$data = [];
$list = [];
// List SB plugins info
$plugins = Main::sb_plugins_info();
// Define a function to fetch all pages of feeds
function fetch_all_feeds($plugin_name, $page = 1) {
$args = array( 'page' => $page );
$feeds = [];
switch ( $plugin_name ) {
case 'facebook':
$feeds = \CustomFacebookFeed\Builder\CFF_Db::feeds_query( $args );
break;
case 'instagram':
$feeds = \InstagramFeed\Builder\SBI_Db::feeds_query( $args );
break;
case 'twitter':
$feeds = \TwitterFeed\Builder\CTF_Db::feeds_query( $args );
break;
case 'youtube':
$feeds = \SmashBalloon\YouTubeFeed\Builder\SBY_Db::feeds_query( $args );
break;
case 'tiktok':
// Use the original function's method for fetching TikTok feeds
$src = new \SmashBalloon\TikTokFeeds\Common\Database\FeedsTable;
$feeds = $src->get_feeds( $args = array() );
break;
case 'social-wall':
$feeds = \SB\SocialWall\Database::query_feeds( $args );
break;
default:
// Do nothing.
break;
}
return $feeds;
}
// Fetch all pages of feeds for non-TikTok plugins
if ( 'tiktok' !== $plugin_name ) {
$page = 1;
do {
$feeds = fetch_all_feeds( $plugin_name, $page );
if ( !empty( $feeds ) ) {
$data = array_merge( $data, $feeds );
$page++;
} else {
break;
}
} while ( true );
} else {
// Fetch TikTok feeds using the original method
$data = fetch_all_feeds( $plugin_name );
}
// Add an empty value first in the list to solve the control update/change functions
$list[] = [
'name' => __( 'Select a feed', 'thrive-cb' ),
'value' => '',
];
// Add the feeds to the list if the plugin is active
foreach ( $plugins as $key => $plugin ) {
if ( $plugin_name === $key && $plugin['is_active'] ) {
foreach ( $data as $feed ) {
$list[] = [
'name' => $feed['feed_name'],
'value' => $feed['id'],
];
}
}
}
// Return JSON response
if ( !empty( $data ) ) {
wp_send_json_success( $list );
} else {
wp_send_json_error( 'No data available' );
}
}
/**
* Render shortcode
*
* @param array $attr
* @param string $content
*
* @return string
*/
public static function render( $attr = [], $content = '' ) {
if ( ! is_array( $attr ) ) {
$attr = [];
}
$attr = array_map( static function ( $v ) {
return str_replace( [ '|{|', '|}|' ], [ '[', ']' ], esc_attr( $v ) );
}, $attr );
/* Ensure default values */
$attr = array_merge( [
'data-type' => '',
'data-feed' => '',
], $attr );
$classes = array( str_replace( '.', '', static::IDENTIFIER ), THRIVE_WRAPPER_CLASS );
if ( empty( $content ) ) {
$content .= '<div class="tve-smash-balloon">';
$content .= '<div class="tve-smash-balloon__inner">';
$content .= 'Choose your feed type and feed';
$content .= '</div>';
$content .= '</div>';
}
return \TCB_Utils::wrap_content( $content, 'div', '', $classes, $attr );
}
}

View File

@@ -0,0 +1,108 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-visual-editor
*/
namespace TCB\Integrations\SmashBalloon;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
/**
* Class Rest_Api
*
* @package Thrive\Theme\Integrations\SmashBalloon
*/
class Rest_Api {
public static $namespace = 'tcb/v1';
public static $route = '/smash-balloon';
public static function register_routes() {
register_rest_route(
static::$namespace,
static::$route,
[
[
'methods' => \WP_REST_Server::READABLE,
'callback' => [ __CLASS__, 'get_feeds' ],
'permission_callback' => '__return_true',
]
]
);
register_rest_route(
static::$namespace,
static::$route . '/shortcode',
[
[
'methods' => \WP_REST_Server::READABLE,
'callback' => [ __CLASS__, 'shortcode_html' ],
'permission_callback' => '__return_true',
],
]
);
}
/**
* Get the variations of a product
*
* @param \WP_REST_Request $request Full data about the request.
*
* @return \WP_REST_Response
*/
public static function get_feeds( $request ) {
$type = $request->get_param( 'type' );
switch ( $type ) {
case 'custom-facebook-feed':
$feeds = Main::sb_available_feeds( 'facebook' );
break;
case 'instagram-feed':
$feeds = Main::sb_available_feeds( 'instagram' );
break;
case 'custom-twitter-feeds':
$feeds = Main::sb_available_feeds( 'twitter' );
break;
case 'youtube-feed':
$feeds = Main::sb_available_feeds( 'youtube' );
break;
case 'tiktok-feeds':
case 'sbtt-tiktok':
$feeds = Main::sb_available_feeds( 'tiktok' );
break;
case 'social-wall':
$feeds = Main::sb_available_feeds( 'social-wall' );
break;
default:
// Do nothing.
break;
}
return new \WP_REST_Response( $feeds, 200 );
}
/**
* Get the variations of a product
*
* @param \WP_REST_Request $request Full data about the request.
*
* @return \WP_REST_Response
*/
public static function shortcode_html( $request ) {
$shortcode = $request->get_param( 'shortcode' );
$html = do_shortcode( $shortcode );
return new \WP_REST_Response( [ 'html' => $html ], 200 );
}
}