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,45 @@
<?php
/**
* Class Google\Site_Kit\Core\Tracking\Feature_Metrics
*
* @package Google\Site_Kit
* @copyright 2025 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://sitekit.withgoogle.com
*/
namespace Google\Site_Kit\Core\Tracking;
/**
* Class managing the collection of site-wide feature metrics.
*
* @since 1.162.0
* @access private
* @ignore
*/
class Feature_Metrics {
/**
* Registers functionality through WordPress hooks.
*
* @since 1.162.0
*/
public function register() {
add_filter(
'googlesitekit_features_request_data',
function ( $body ) {
/**
* Filters feature metrics data sent with the features request.
*
* @since 1.162.0
*
* @param array $feature_metrics Feature metrics tracking data to be sent with the features request.
*/
$feature_metrics = apply_filters( 'googlesitekit_feature_metrics', array() );
$body['feature_metrics'] = $feature_metrics;
return $body;
}
);
}
}

View File

@@ -0,0 +1,35 @@
<?php
/**
* Trait Google\Site_Kit\Core\Tracking\Feature_Metrics_Trait
*
* @package Google\Site_Kit\Core\Tracking
* @copyright 2025 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://sitekit.withgoogle.com
*/
namespace Google\Site_Kit\Core\Tracking;
trait Feature_Metrics_Trait {
/**
* Registers the feature metrics to be tracked.
*
* @since 1.162.0
*
* @return void
*/
public function register_feature_metrics() {
add_filter(
'googlesitekit_feature_metrics',
function ( $feature_metrics ) {
$feature_metrics = array_merge(
is_array( $feature_metrics ) ? $feature_metrics : array(),
$this->get_feature_metrics()
);
return $feature_metrics;
}
);
}
}

View File

@@ -0,0 +1,32 @@
<?php
/**
* Interface Google\Site_Kit\Core\Tracking\Provides_Feature_Metrics
*
* @package Google\Site_Kit\Core\Tracking
* @copyright 2025 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://sitekit.withgoogle.com
*/
namespace Google\Site_Kit\Core\Tracking;
/**
* Interface for any feature that has metrics to be tracked via the
* `site-management/features` endpoint.
*
* @since 1.162.0
* @access private
* @ignore
*/
interface Provides_Feature_Metrics {
/**
* Gets feature metrics to be tracked.
*
* @since 1.162.0
*
* @return array Feature metrics tracking data to be tracked via the
* `site-management/features` endpoint.
*/
public function get_feature_metrics();
}

View File

@@ -0,0 +1,144 @@
<?php
/**
* Class Google\Site_Kit\Core\Tracking\REST_Tracking_Consent_Controller
*
* @package Google\Site_Kit
* @copyright 2021 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://sitekit.withgoogle.com
*/
namespace Google\Site_Kit\Core\Tracking;
use Google\Site_Kit\Core\Permissions\Permissions;
use Google\Site_Kit\Core\REST_API\REST_Route;
use Google\Site_Kit\Core\REST_API\REST_Routes;
use Google\Site_Kit\Core\Util\Method_Proxy_Trait;
use WP_REST_Server;
use WP_REST_Request;
use WP_REST_Response;
/**
* Class managing admin tracking.
*
* @since 1.49.0
* @access private
* @ignore
*/
class REST_Tracking_Consent_Controller {
use Method_Proxy_Trait;
/**
* Tracking_Consent instance.
*
* @since 1.49.0
*
* @var Tracking_Consent
*/
protected $consent;
/**
* Constructor.
*
* @@since 1.49.0
*
* @param Tracking_Consent $tracking_consent Tracking consent instance.
*/
public function __construct( Tracking_Consent $tracking_consent ) {
$this->consent = $tracking_consent;
}
/**
* Registers functionality through WordPress hooks.
*
* @since 1.49.0
*/
public function register() {
add_filter( 'googlesitekit_rest_routes', $this->get_method_proxy( 'get_rest_routes' ) );
add_filter(
'googlesitekit_apifetch_preload_paths',
function ( $routes ) {
return array_merge(
$routes,
array(
'/' . REST_Routes::REST_ROOT . '/core/user/data/tracking',
)
);
}
);
}
/**
* Is tracking active for the current user?
*
* @since 1.49.0
*
* @return bool True if tracking enabled, and False if not.
*/
public function is_active() {
return (bool) $this->consent->get();
}
/**
* Gets tracking routes.
*
* @since 1.49.0
*
* @param array $routes Array of routes.
* @return array Modified array of routes that contains tracking related routes.
*/
private function get_rest_routes( $routes ) {
$can_access_tracking = function () {
return current_user_can( Permissions::VIEW_SPLASH ) || current_user_can( Permissions::VIEW_DASHBOARD );
};
$tracking_callback = function () {
return new WP_REST_Response(
array(
'enabled' => $this->is_active(),
)
);
};
return array_merge(
$routes,
array(
new REST_Route(
'core/user/data/tracking',
array(
array(
'methods' => WP_REST_Server::READABLE,
'callback' => $tracking_callback,
'permission_callback' => $can_access_tracking,
),
array(
'methods' => WP_REST_Server::CREATABLE,
'callback' => function ( WP_REST_Request $request ) use ( $tracking_callback ) {
$data = $request->get_param( 'data' );
$enabled = ! empty( $data['enabled'] );
$this->consent->set( $enabled );
return $tracking_callback( $request );
},
'permission_callback' => $can_access_tracking,
'args' => array(
'data' => array(
'type' => 'object',
'required' => true,
'properties' => array(
'enabled' => array(
'type' => 'boolean',
'required' => true,
),
),
),
),
),
)
),
)
);
}
}

View File

@@ -0,0 +1,118 @@
<?php
/**
* Class Google\Site_Kit\Core\Tracking\Tracking
*
* @package Google\Site_Kit
* @copyright 2021 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://sitekit.withgoogle.com
*/
namespace Google\Site_Kit\Core\Tracking;
use Google\Site_Kit\Context;
use Google\Site_Kit\Core\Admin\Screen;
use Google\Site_Kit\Core\Admin\Screens;
use Google\Site_Kit\Core\Storage\User_Options;
use Google\Site_Kit\Core\Util\Method_Proxy_Trait;
/**
* Class managing admin tracking.
*
* @since 1.49.0
* @access private
* @ignore
*/
final class Tracking {
use Method_Proxy_Trait;
const TRACKING_ID = 'G-EQDN3BWDSD';
/**
* Screens instance.
*
* @since 1.49.0
*
* @var Screens
*/
protected $screens;
/**
* Tracking_Consent instance.
*
* @since 1.49.0
*
* @var Tracking_Consent
*/
protected $consent;
/**
* REST_Tracking_Consent_Controller instance.
*
* @since 1.49.0
*
* @var REST_Tracking_Consent_Controller
*/
private $rest_controller;
/**
* Constructor.
*
* @since 1.49.0
*
* @param Context $context Context instance.
* @param User_Options $user_options Optional. User_Options instance. Default is a new instance.
* @param Screens $screens Optional. Screens instance. Default is a new instance.
*/
public function __construct(
Context $context,
?User_Options $user_options = null,
?Screens $screens = null
) {
$user_options = $user_options ?: new User_Options( $context );
$this->screens = $screens ?: new Screens( $context );
$this->consent = new Tracking_Consent( $user_options );
$this->rest_controller = new REST_Tracking_Consent_Controller( $this->consent );
}
/**
* Registers functionality through WordPress hooks.
*
* @since 1.49.0
*/
public function register() {
$this->consent->register();
$this->rest_controller->register();
add_filter( 'googlesitekit_inline_tracking_data', $this->get_method_proxy( 'inline_js_tracking_data' ) );
}
/**
* Is tracking active for the current user?
*
* @since 1.49.0
*
* @return bool True if tracking enabled, and False if not.
*/
public function is_active() {
return (bool) $this->consent->get();
}
/**
* Adds / modifies tracking relevant data to pass to JS.
*
* @since 1.78.0
*
* @param array $data Inline JS data.
* @return array Filtered $data.
*/
private function inline_js_tracking_data( $data ) {
global $hook_suffix;
$data['isSiteKitScreen'] = $this->screens->get_screen( $hook_suffix ) instanceof Screen;
$data['trackingEnabled'] = $this->is_active();
$data['trackingID'] = self::TRACKING_ID;
return $data;
}
}

View File

@@ -0,0 +1,63 @@
<?php
/**
* Class Google\Site_Kit\Core\Tracking\Tracking_Consent
*
* @package Google\Site_Kit\Core\Tracking
* @copyright 2021 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://sitekit.withgoogle.com
*/
namespace Google\Site_Kit\Core\Tracking;
use Google\Site_Kit\Core\Storage\User_Setting;
/**
* Class managing a user's anonymous usage tracking consent.
*
* @since 1.49.0
* @access private
* @ignore
*/
class Tracking_Consent extends User_Setting {
/**
* The user option name for this setting.
*
* @var string
*/
const OPTION = 'googlesitekit_tracking_optin';
/**
* Gets the value of the setting.
*
* @since 1.49.0
*
* @return bool Whether the current user has consented to anonymous tracking.
*/
public function get() {
return (bool) $this->user_options->get( static::OPTION );
}
/**
* Gets the expected value type.
*
* @since 1.49.0
*
* @return string The type name.
*/
protected function get_type() {
return 'boolean';
}
/**
* Gets the default value.
*
* @since 1.49.0
*
* @return bool The default value.
*/
protected function get_default() {
return false;
}
}