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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,60 @@
<?php
/**
* Divi admin integration.
*
* @package RankMath
* @subpackage RankMath\Core
* @author Rank Math <support@rankmath.com>
*/
namespace RankMath\Divi;
use RankMath\Traits\Hooker;
defined( 'ABSPATH' ) || exit;
/**
* Divi class.
*/
class Divi_Admin {
use Hooker;
/**
* Class constructor.
*/
public function __construct() {
$this->init();
}
/**
* Intialize Divi admin.
*/
public function init() {
$screen = get_current_screen();
if ( 'toplevel_page_et_divi_options' === $screen->id ) {
$this->action( 'admin_enqueue_scripts', 'enqueue_divi_admin_scripts' );
}
}
/**
* Enqueue scripts for Divi admin options screen.
*/
public function enqueue_divi_admin_scripts() {
wp_enqueue_script(
'rank-math-divi-admin',
rank_math()->plugin_url() . 'includes/3rdparty/divi/assets/js/divi-admin.js',
[
'jquery',
'react',
'react-dom',
'wp-components',
'wp-element',
'wp-i18n',
'wp-polyfill',
],
rank_math()->version,
true
);
}
}

View File

@@ -0,0 +1,379 @@
<?php
/**
* Divi integration.
*
* @since 0.9.0
* @package RankMath
* @subpackage RankMath\Core
* @author Rank Math <support@rankmath.com>
*/
namespace RankMath\Divi;
use RankMath\KB;
use RankMath\Helper;
use RankMath\Helpers\Editor;
use RankMath\Helpers\Str;
use RankMath\Schema\DB as Schema_DB;
use RankMath\Schema\Admin as Schema_Admin;
use RankMath\Traits\Hooker;
use RankMath\Admin\Metabox\Screen;
use WP_Dependencies;
defined( 'ABSPATH' ) || exit;
/**
* Divi class.
*/
class Divi {
use Hooker;
/**
* Screen object.
*
* @var Screen
*/
private $screen;
/**
* Class constructor.
*/
public function __construct() {
$this->action( 'wp', 'init' );
}
/**
* Intialize.
*/
public function init() {
if ( ! $this->can_add_seo_tab() ) {
return;
}
$this->screen = new Screen();
$this->screen->load_screen( 'post' );
$this->action( 'template_redirect', 'set_window_lodash', 0 );
$this->action( 'wp_enqueue_scripts', 'register_rankmath_react' );
$this->action( 'wp_enqueue_scripts', 'add_json_data', 0 );
$this->action( 'wp_footer', 'footer_enqueue_scripts', 11 );
remove_action( 'wp_footer', [ rank_math()->json, 'output' ], 0 );
add_action( 'wp_footer', [ rank_math()->json, 'output' ], 11 );
$this->filter( 'script_loader_tag', 'add_et_tag', 10, 3 );
}
/**
* Set the global lodash variable.
*
* Lodash's `noConflict` would prevent UnderscoreJS from taking over the underscore (_)
* global variable. Because Underscore.js will later also be assigned to the underscore (_)
* global this function should run as early as possible.
*/
public function set_window_lodash() {
wp_register_script( 'rm-set-window-lodash', '', [ 'lodash' ], rank_math()->version, false );
wp_enqueue_script( 'rm-set-window-lodash' );
wp_add_inline_script(
'rm-set-window-lodash',
join(
"\r\n ",
[
'window.isLodash = function() {',
"if ( typeof window._ !== 'function' || typeof window._.forEach !== 'function' ) {",
'return false;',
'}',
'var isLodash = true;',
'window._.forEach(',
"[ 'cloneDeep', 'at', 'add', 'ary', 'attempt' ],",
'function( fn ) {',
"if ( isLodash && typeof window._[ fn ] !== 'function' ) {",
'isLodash = false;',
'}',
'}',
');',
'return isLodash;',
'}',
'if ( window.isLodash() ) { window.lodash = window._.noConflict(); }',
]
)
);
}
/**
* Register RankMath React and ReactDOM.
*
* Registers the native WP version of react with a custom handle for use in the
* RankMath module. Divi builder dequeues and deregisters native WP react scripts
* and replaces them with their own copy of React. Their copy might not be of the
* same version as the one RankMath requires.
*/
public function register_rankmath_react() {
$path = site_url( '/wp-includes/js/dist/vendor/' );
$suffix = wp_scripts_get_suffix();
wp_register_script( 'rm-react', "{$path}react{$suffix}.js", [ 'wp-polyfill', 'react' ], '16.13.1', true );
wp_register_script( 'rm-react-dom', "{$path}react-dom{$suffix}.js", [ 'rm-react', 'react-dom' ], '16.13.1', true );
}
/**
* Add JSON data.
*/
public function add_json_data() {
$this->maybe_load_editor_deps();
if ( Helper::has_cap( 'onpage_snippet' ) ) {
// Schema.
$schemas = $this->get_schema_data( get_the_ID() );
Helper::add_json( 'schemas', $schemas );
Helper::add_json( 'customSchemaImage', esc_url( rank_math()->plugin_url() . 'includes/modules/schema/assets/img/custom-schema-builder.jpg' ) );
// Trends.
$trends_upgrade_link = KB::get( 'pro', 'Divi General Tab Trends' );
Helper::add_json( 'trendsUpgradeLink', esc_url_raw( $trends_upgrade_link ) );
Helper::add_json( 'trendsPreviewImage', esc_url( rank_math()->plugin_url() . 'assets/admin/img/trends-preview.jpg' ) );
}
Helper::add_json(
'api',
[
'root' => esc_url_raw( get_rest_url() ),
'nonce' => ( wp_installing() && ! is_multisite() ) ? '' : wp_create_nonce( 'wp_rest' ),
]
);
Helper::add_json(
'keywordsApi',
[
'url' => 'https://api.rankmath.com/ltkw/v1/',
]
);
Helper::add_json( 'links', KB::get_links() );
Helper::add_json(
'validationl10n',
[
'regexErrorDefault' => __( 'Please use the correct format.', 'rank-math' ),
'requiredErrorDefault' => __( 'This field is required.', 'rank-math' ),
'emailErrorDefault' => __( 'Please enter a valid email address.', 'rank-math' ),
'urlErrorDefault' => __( 'Please enter a valid URL.', 'rank-math' ),
]
);
Helper::add_json( 'capitalizeTitle', Helper::get_settings( 'titles.capitalize_titles' ) );
Helper::add_json( 'blogName', get_bloginfo( 'name' ) );
if ( is_admin_bar_showing() && Helper::has_cap( 'admin_bar' ) ) {
Helper::add_json( 'objectID', get_the_ID() );
Helper::add_json( 'objectType', 'post' );
}
}
/**
* Enqueue scripts.
*/
public function footer_enqueue_scripts() {
/**
* Allow other plugins to enqueue/dequeue admin styles or scripts before plugin assets.
*/
$this->do_action( 'admin/before_editor_scripts' );
$divi_deps = [
'jquery',
'lodash',
'rm-react',
'rm-react-dom',
'rm-set-window-lodash',
'et-dynamic-asset-helpers',
'wp-api-fetch',
'wp-block-editor',
'wp-components',
'wp-compose',
'wp-core-data',
'wp-data',
'wp-element',
'wp-hooks',
'wp-media-utils',
'wp-wordcount',
'rank-math-analyzer',
'rank-math-app',
];
if ( is_admin_bar_showing() && Helper::has_cap( 'admin_bar' ) ) {
wp_enqueue_style( 'rank-math', rank_math()->assets() . 'css/rank-math.css', null, rank_math()->version );
wp_enqueue_script( 'rank-math', rank_math()->assets() . 'js/rank-math.js', [ 'jquery' ], rank_math()->version, true );
}
wp_enqueue_style( 'rank-math-common', rank_math()->plugin_url() . 'assets/admin/css/common.css', null, rank_math()->version );
wp_enqueue_style( 'wp-components' );
wp_enqueue_style( 'rank-math-editor', rank_math()->plugin_url() . 'includes/3rdparty/divi/assets/css/divi.css', [], rank_math()->version );
wp_register_script( 'rank-math-analyzer', rank_math()->plugin_url() . 'assets/admin/js/analyzer.js', null, rank_math()->version, true );
wp_enqueue_script( 'rank-math-editor', rank_math()->plugin_url() . 'includes/3rdparty/divi/assets/js/divi.js', $divi_deps, rank_math()->version, true );
wp_enqueue_script( 'rank-math-divi-iframe', rank_math()->plugin_url() . 'includes/3rdparty/divi/assets/js/divi-iframe.js', [ 'jquery', 'lodash' ], rank_math()->version, true );
wp_set_script_translations( 'rank-math-app', 'seo-by-rank-math', rank_math()->plugin_dir() . 'languages/' );
wp_set_script_translations( 'rank-math-divi-iframe', 'seo-by-rank-math', rank_math()->plugin_dir() . 'languages/' );
wp_set_script_translations( 'rank-math-editor', 'seo-by-rank-math', rank_math()->plugin_dir() . 'languages/' );
wp_set_script_translations( 'rank-math-analyzer', 'seo-by-rank-math', rank_math()->plugin_dir() . 'languages/' );
if ( Helper::is_module_active( 'rich-snippet' ) ) {
wp_enqueue_style( 'rank-math-schema', rank_math()->plugin_url() . 'includes/modules/schema/assets/css/schema.css', [ 'wp-components' ], rank_math()->version );
wp_enqueue_script( 'rank-math-schema', rank_math()->plugin_url() . 'includes/modules/schema/assets/js/schema-gutenberg.js', [ 'rank-math-editor' ], rank_math()->version, true );
wp_set_script_translations( 'rank-math-schema', 'seo-by-rank-math', rank_math()->plugin_dir() . 'languages/' );
}
rank_math()->variables->setup();
rank_math()->variables->setup_json();
$this->screen->localize();
$this->print_react_containers();
/**
* Allow other plugins to enqueue/dequeue admin styles or scripts after plugin assets.
*/
$this->do_action( 'admin/editor_scripts', $this->screen );
}
/**
* Add et attributes to script tags.
*
* @param string $tag The <script> tag for the enqueued script.
* @param string $handle The script's registered handle.
*
* @return string
*/
public function add_et_tag( $tag, $handle ) {
$script_handles = [
'rm-react',
'rm-react-dom',
'lodash',
'moment',
'rank-math',
'rank-math-analyzer',
'rank-math-schema',
'rank-math-editor',
'rank-math-content-ai',
'rank-math-app',
// Scripts required by pro version.
'wp-plugins',
'jquery-ui-autocomplete',
'rank-math-pro-editor',
'rank-math-schema-pro',
'rank-math-pro-schema-filters',
'rank-math-pro-news',
];
$exclude_handles = [
'wp-util',
'wp-backbone',
'wp-plupload',
'wp-mediaelement',
'wp-color-picker',
'wp-color-picker-alpha',
'wp-embed',
'wp-hooks',
];
if ( in_array( $handle, $exclude_handles, true ) ) {
return $tag;
}
if ( Str::starts_with( 'wp-', $handle ) || in_array( $handle, $script_handles, true ) ) {
// These tags load in parent window only, not in Divi iframe.
$tag = preg_replace(
'/<script\b(?![^>]*\bclass=)([^>]*)>/i',
'<script class="et_fb_ignore_iframe"$1>',
$tag
);
}
return $tag;
}
/**
* Print React containers onto the screen.
*/
public function print_react_containers() {
echo '<div id="rank-math-rm-app-root" class="et_fb_ignore_iframe"></div>';
echo '<div id="rank-math-rm-settings-bar-root" class="et_fb_ignore_iframe"></div>';
}
/**
* Can add SEO in Divi Page Builder.
*
* @return bool
*/
private function can_add_seo_tab() {
if (
! Helper::is_divi_frontend_editor() ||
! defined( 'ET_BUILDER_PRODUCT_VERSION' ) ||
! version_compare( '4.9.2', ET_BUILDER_PRODUCT_VERSION, 'le' )
) {
return false;
}
/**
* Filter to show/hide SEO Tab in Divi Editor.
*/
if ( ! $this->do_filter( 'divi/add_seo_tab', true ) ) {
return false;
}
$post_type = get_post_type();
if ( $post_type && ! Helper::get_settings( 'titles.pt_' . $post_type . '_add_meta_box' ) ) {
return false;
}
return Editor::can_add_editor();
}
/**
* Get Schema Data.
*
* @param int $post_id Post ID.
*
* @return array $schemas Schema Data.
*/
private function get_schema_data( $post_id ) {
$schemas = Schema_DB::get_schemas( $post_id );
if ( ! empty( $schemas ) || metadata_exists( 'post', $post_id, 'rank_math_rich_snippet' ) ) {
return $schemas;
}
$post_type = get_post_type( $post_id );
$default_type = ucfirst( Helper::get_default_schema_type( $post_id ) );
if ( ! $default_type ) {
return [];
}
$schemas['new-9999'] = [
'@type' => $default_type,
'metadata' => [
'title' => Helper::sanitize_schema_title( $default_type ),
'type' => 'template',
'shortcode' => uniqid( 's-' ),
'isPrimary' => true,
],
];
return $schemas;
}
/**
* Ensures required dependencies are loaded when toolbar is hidden.
*
* @return void
*/
private function maybe_load_editor_deps() {
if ( is_admin_bar_showing() ) {
return;
}
Helper::add_json( 'security', wp_create_nonce( 'rank-math-ajax-nonce' ) );
Helper::add_json( 'restNonce', ( wp_installing() && ! is_multisite() ) ? '' : wp_create_nonce( 'wp_rest' ) );
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,218 @@
<?php
/**
* Elementor integration.
*
* @since 0.9.0
* @package RankMath
* @subpackage RankMath\Core
* @author Rank Math <support@rankmath.com>
*/
namespace RankMath\Elementor;
use RankMath\Helper;
use RankMath\Traits\Hooker;
use RankMath\Helpers\Editor;
defined( 'ABSPATH' ) || exit;
/**
* Elementor class.
*/
class Elementor {
use Hooker;
/**
* Class constructor.
*/
public function __construct() {
$this->action( 'init', 'init' );
$this->filter( 'rank_math/frontend/robots', 'robots' );
$this->filter( 'rank_math/frontend/disable_integration', 'disable_frontend_integration' );
}
/**
* Intialize.
*/
public function init() {
if ( ! $this->can_add_seo_tab() ) {
return;
}
$this->action( 'elementor/editor/before_enqueue_scripts', 'enqueue' );
add_action( 'elementor/editor/footer', [ rank_math()->json, 'output' ], 0 );
$this->action( 'elementor/editor/footer', 'start_capturing', 0 );
$this->action( 'elementor/editor/footer', 'end_capturing', 999 );
$this->filter( 'rank_math/sitemap/content_before_parse_html_images', 'apply_builder_in_content', 10, 2 );
}
/**
* Disable frontend integration on Elementor Maintenance page.
*
* @since 1.0.91
*
* @param boolean $value Whether to run the frontend integration.
*/
public function disable_frontend_integration( $value ) {
$mode = get_option( 'elementor_maintenance_mode_mode' );
if ( ! in_array( $mode, [ 'maintenance', 'coming_soon' ], true ) ) {
return $value;
}
if ( ! get_option( 'elementor_maintenance_mode_template_id' ) ) {
return $value;
}
$exclude_mode = get_option( 'elementor_maintenance_mode_exclude_mode', [] );
if ( 'logged_in' === $exclude_mode && is_user_logged_in() ) {
return $value;
}
if ( 'custom' !== $exclude_mode ) {
return true;
}
$exclude_roles = get_option( 'elementor_maintenance_mode_exclude_roles', [] );
$user = wp_get_current_user();
$user_roles = $user->roles;
if ( is_multisite() && is_super_admin() ) {
$user_roles[] = 'super_admin';
}
$compare_roles = array_intersect( $user_roles, $exclude_roles );
return ! empty( $compare_roles ) ? $value : true;
}
/**
* Start capturing buffer.
*/
public function start_capturing() {
ob_start();
}
/**
* End capturing buffer and add button.
*/
public function end_capturing() {
$output = \ob_get_clean();
$search = '/(<(div|button) class="elementor-component-tab elementor-panel-navigation-tab" data-tab="global">.*<\/(div|button)>)/m';
$replace = '${1}<${2} class="elementor-component-tab elementor-panel-navigation-tab" data-tab="rank-math">SEO</${2}>';
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- This comes from the output buffer, escaping it would break the output.
echo \preg_replace(
$search,
$replace,
$output
);
}
/**
* Enqueue scripts.
*/
public function enqueue() {
$deps = [
'wp-core-data',
'wp-components',
'wp-block-editor',
'wp-element',
'wp-data',
'wp-api-fetch',
'wp-media-utils',
'site-health',
'rank-math-analyzer',
'backbone-marionette',
'elementor-common-modules',
'rank-math-app',
];
if ( wp_script_is( 'elementor-v2-editor-app-bar', 'registered' ) ) {
$deps[] = 'elementor-v2-editor-app-bar';
}
$mode = \Elementor\Core\Settings\Manager::get_settings_managers( 'editorPreferences' )->get_model()->get_settings( 'ui_theme' );
wp_deregister_style( 'rank-math-editor' );
wp_enqueue_style( 'wp-components' );
wp_enqueue_style( 'site-health' );
wp_enqueue_style( 'rank-math-editor', rank_math()->plugin_url() . 'includes/3rdparty/elementor/assets/css/elementor.css', [ 'rank-math-common' ], rank_math()->version );
$media_query = '';
$dark_styles = $this->do_filter(
'elementor/dark_styles',
[
'rank-math-elementor-dark' => rank_math()->plugin_url() . 'includes/3rdparty/elementor/assets/css/elementor-dark.css',
]
);
if ( 'light' !== $mode ) {
$media_query = 'auto' === $mode ? '(prefers-color-scheme: dark)' : 'all';
foreach ( $dark_styles as $handle => $src ) {
wp_enqueue_style( $handle, $src, [], rank_math()->version, $media_query );
}
}
Helper::add_json( 'elementorDarkMode', $dark_styles );
wp_enqueue_script( 'rank-math-editor', rank_math()->plugin_url() . 'includes/3rdparty/elementor/assets/js/elementor.js', $deps, rank_math()->version, true );
rank_math()->variables->setup();
rank_math()->variables->setup_json();
}
/**
* Filters the post content before it is parsed for Sitmeap images..
* Used to apply the Elementor page editor on the post content.
*
* @since 1.0.38
*
* @param string $content The post content.
* @param int $post_id The post ID.
*
* @return string The post content.
*/
public function apply_builder_in_content( $content, $post_id ) {
if ( \Elementor\Plugin::$instance->db->is_built_with_elementor( $post_id ) ) {
return \Elementor\Plugin::$instance->frontend->get_builder_content( $post_id );
}
return $content;
}
/**
* Add SEO tab in Elementor Page Builder.
*
* @return bool
*/
private function can_add_seo_tab() {
/**
* Filter to show/hide SEO Tab in the Elementor Editor.
*/
if ( ! $this->do_filter( 'elementor/add_seo_tab', true ) ) {
return false;
}
$post_type = isset( $_GET['post'] ) ? get_post_type( absint( $_GET['post'] ) ) : '';
if ( $post_type && ! Helper::get_settings( 'titles.pt_' . $post_type . '_add_meta_box' ) ) {
return false;
}
return Editor::can_add_editor();
}
/**
* Change robots for Elementor Templates pages
*
* @param array $robots Array of robots to sanitize.
*
* @return array Modified robots.
*/
public function robots( $robots ) {
if ( is_singular( 'elementor_library' ) ) {
$robots['index'] = 'noindex';
$robots['follow'] = 'nofollow';
}
return $robots;
}
}

View File

@@ -0,0 +1,141 @@
<?php
/**
* Loco Translate inline i18n helper for injecting translations without JSON files.
*
* @since 1.0.256
* @package RankMath
* @subpackage RankMath\Core
* @author Rank Math <support@rankmath.com>
*/
namespace RankMath\ThirdParty\Loco;
use RankMath\Traits\Hooker;
use RankMath\Helper;
use RankMath\Helpers\Str;
defined( 'ABSPATH' ) || exit;
/**
* Loco_I18n_Inline class.
*/
class Loco_I18n_Inline {
use Hooker;
/**
* Class constructor.
*/
public function __construct() {
$this->action( 'rank-math/admin_enqueue_scripts', 'inject_settings_locale' );
}
/**
* Inject inline JED locale for settings screens when Loco is active.
*/
public function inject_settings_locale() {
// Load translations from all Loco locations (Customization, System, Author).
$json = $this->get_jed_json( 'rank-math', false );
if ( empty( $json ) ) {
return;
}
$inline = sprintf(
'try{if(window.wp&&wp.i18n&&wp.i18n.setLocaleData){wp.i18n.setLocaleData(%s,"rank-math");var __rm=wp.i18n.getLocaleData&&wp.i18n.getLocaleData("rank-math");if(__rm){wp.i18n.setLocaleData(__rm,"seo-by-rank-math");}}}catch(e){}',
$json
);
wp_add_inline_script( 'common', $inline, 'before' );
}
/**
* Build a JED locale JSON from the best available MO/PO for the current locale.
*
* @param string $domain Text domain (e.g. 'rank-math').
* @param bool $loco_only Whether to restrict to Loco-managed files only.
* @return string JSON string suitable for wp.i18n.setLocaleData(), or empty string.
*/
private function get_jed_json( $domain, $loco_only = true ) {
$locale = get_user_locale();
$file = $this->find_translation_file( $domain, $locale, $loco_only );
if ( ! $file ) {
return '';
}
return $this->build_jed_json( $file, $domain, $locale );
}
/**
* Build JED JSON from translation file.
*
* @param string $file Path to MO or PO file.
* @param string $domain Text domain.
* @param string $locale Locale.
* @return string JSON string or false.
*/
private function build_jed_json( $file, $domain, $locale ) {
require_once ABSPATH . WPINC . '/pomo/mo.php';
require_once ABSPATH . WPINC . '/pomo/po.php';
$translations = Str::ends_with( '.mo', $file ) ? new \MO() : new \PO();
if ( ! $translations->import_from_file( $file ) ) {
return false;
}
$data = [
'' => [
'domain' => $domain,
'lang' => $locale,
],
];
if ( ! empty( $translations->headers['plural-forms'] ) ) {
$data['']['plural-forms'] = $translations->headers['plural-forms'];
}
foreach ( $translations->entries as $entry ) {
if ( empty( $entry->translations ) ) {
continue;
}
$key = empty( $entry->context ) ? $entry->singular : $entry->context . "\004" . $entry->singular;
$data[ $key ] = $entry->translations;
}
return wp_json_encode( $data );
}
/**
* Find translation file for domain/locale.
*
* @param string $domain Text domain.
* @param string $locale Locale.
* @param bool $loco_only Restrict to Loco files only.
* @return string|false File path or false.
*/
private function find_translation_file( $domain, $locale, $loco_only ) {
$paths = [];
// 1) Loco "Customization" location.
$paths[] = WP_CONTENT_DIR . '/languages/loco/plugins/' . $domain . '-' . $locale . '.mo';
$paths[] = WP_CONTENT_DIR . '/languages/loco/plugins/' . $domain . '-' . $locale . '.po';
// 2) Loco "System" location (global WP languages dir).
if ( ! $loco_only ) {
$paths[] = WP_LANG_DIR . '/plugins/' . $domain . '-' . $locale . '.mo';
$paths[] = WP_LANG_DIR . '/plugins/' . $domain . '-' . $locale . '.po';
}
// 3) Loco "Author" location (plugin bundled languages directory).
$paths[] = RANK_MATH_PATH . 'languages/' . $domain . '-' . $locale . '.mo';
$paths[] = RANK_MATH_PATH . 'languages/' . $domain . '-' . $locale . '.po';
foreach ( $paths as $path ) {
if ( is_file( $path ) && is_readable( $path ) ) {
return $path;
}
}
return false;
}
}