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,191 @@
<?php
/**
* The class is responsible for adding widget in the WordPress admin area.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
* @since 1.48.0
*/
namespace AdvancedAds\Modules\OneClick\Admin;
use AdvancedAds\Utilities\WordPress;
use AdvancedAds\Modules\OneClick\Helpers;
use AdvancedAds\Modules\OneClick\Options;
use AdvancedAds\Framework\Interfaces\Integration_Interface;
defined( 'ABSPATH' ) || exit;
/**
* Admin.
*/
class Admin implements Integration_Interface {
/**
* Hook into WordPress
*
* @return void
*/
public function hooks(): void {
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] );
add_action( 'advanced-ads-overview-widgets-after', [ $this, 'add_metabox' ] );
}
/**
* Enqueue scripts
*
* @param string $hook current page hook.
*
* @return void
*/
public function enqueue( $hook ): void {
if ( 'toplevel_page_advanced-ads' !== $hook ) {
return;
}
$config = Options::pubguru_config();
wp_advads()->registry->enqueue_script( 'oneclick-onboarding' );
wp_advads()->json->add(
'oneclick',
[
'security' => wp_create_nonce( 'pubguru_oneclick_security' ),
'isConnected' => false !== Options::pubguru_config(),
'btnCancel' => __( 'Cancel', 'advanced-ads' ),
'btnClose' => __( 'Close', 'advanced-ads' ),
'btnContinue' => __( 'Continue', 'advanced-ads' ),
'btnRetry' => __( 'Retry', 'advanced-ads' ),
'siteDomain' => WordPress::get_site_domain(),
'spinner' => ADVADS_BASE_URL . 'admin/assets/img/loader.gif',
'addonRow' => [
'icon' => ADVADS_BASE_URL . 'assets/img/add-ons/aa-addons-icons-m2pg.svg',
'title' => __( 'MonetizeMore & PubGuru Integration', 'advanced-ads' ),
'content' => __( 'Enables MonetizeMore users to link their settings with the PubGuru insights & analytics dashboard.', 'advanced-ads' ),
'connect' => __( 'Connect now', 'advanced-ads' ),
'disconnect' => __( 'Disconnect now', 'advanced-ads' ),
],
'metabox' => [
'title' => __( 'MonetizeMore & PubGuru Integration', 'advanced-ads' ),
'visitText' => __( 'Visit the MonetizeMore website to learn about PubGuru', 'advanced-ads' ),
'visitLink' => 'https://www.monetizemore.com/solutions/pubguru',
],
'step1' => [
'title' => __( 'Onboarding Step 1 of 3, Consent and Privacy Policy', 'advanced-ads' ),
'content' => sprintf(
wp_kses_post(
/* translators: %s link to privacy policy */
__( 'This form is designed exclusively for MonetizeMore customers who wish to integrate Advanced Ads with their PubGuru Dashboard. In alignment with our <a href="%s">Privacy Policy</a>, no information other than your domain name is exchanged, and Advanced Ads does not engage in any tracking activities.', 'advanced-ads' )
),
'https://wpadvancedads.com/privacy-policy/'
),
'agreeText' => __( 'I agree to share my domain name to facilitate the connection with my PubGuru account.', 'advanced-ads' ),
'btnAgree' => __( 'Connect with PubGuru', 'advanced-ads' ),
],
'step2' => [
'title' => __( 'Onboarding Step 2 of 3, Connecting to PubGuru', 'advanced-ads' ),
'loading' => __( 'Fetching your domain information from PubGuru, please wait...', 'advanced-ads' ),
'notRegistered' => __( 'The domain &ldquo;{0}&rdquo; is not registered with PubGuru', 'advanced-ads' ),
'content' => sprintf(
/* translators: %1$s is contact link, %2$s is email link */
__( 'If you are on a domain &ldquo;unknow&rdquo; to PubGuru, e.g., a staging site, please indicate the domain that you registered with PubGuru. If you need assistance, please <a href="%1$s">click here to contact PubGuru support</a> or <a href="%2$s">send an email to support@monetizemore.com</a>.', 'advanced-ads' ),
'https://www.monetizemore.com/contact/',
'mailto:support@monetizemore.com'
),
'inputLabel' => __( 'Registered domain', 'advanced-ads' ),
'serverError' => __( 'The onboarding process has encountered an error: &ldquo;{0}&rdquo;', 'advanced-ads' ),
'serverContent' => sprintf(
/* translators: %1$s is contact link, %2$s is email link */
__( 'Please wait a few minutes and try again. If you need assistance, please <a href="%1$s">click here to contact PubGuru support</a> or <a href="%2$s">send an email to support@monetizemore.com</a>.', 'advanced-ads' ),
'https://www.monetizemore.com/contact/',
'mailto:support@monetizemore.com'
),
],
'step3' => [
'title' => __( 'Onboarding Step 3 of 3, Test and Finalize Ad Unit Import', 'advanced-ads' ),
'yourDomain' => __( 'Your domain &ldquo;{0}&rdquo; is connected to PubGuru.', 'advanced-ads' ),
'btnImport' => __( 'Import PubGuru Ad Units', 'advanced-ads' ),
'importContent' => wp_kses_post(
join(
'',
[
'<p>' . __( 'This step is entirely optional. Your PubGuru configuration shows the following available ad units', 'advanced-ads' ) . '</p>',
'<ul class="list-disc ml-4">',
'<li>' . __( '3 In-Content Ads', 'advanced-ads' ) . '</li>',
'<li>' . __( '1 Leaderboard Ad', 'advanced-ads' ) . '</li>',
'</ul>',
'<p>' . __( 'You will be able to preview the ad units injections on a test page before and there is a rollback option after the import.', 'advanced-ads' ) . '</p>',
]
)
),
'previewContent' => __( 'You may preview or change the test page for the ad units&rsquo; injections, or finalize the PubGuru Ad Unit import.', 'advanced-ads' ),
'finalContent' => sprintf(
/* translators: %s rollback page link */
__( 'You have successfully imported your PubGuru Ad Units. If necessary, use the <a href="%s">Rollback Tool</a> to revert your ad setup to a previous state.', 'advanced-ads' ),
esc_url( admin_url( 'admin.php?page=advanced-ads-tools#import-history' ) )
),
],
'settings' => [
'title' => __( 'General Settings', 'advanced-ads' ),
'help' => sprintf(
/* translators: %1$s is contact link, %2$s is email link */
__( 'If you need assistance, please <a href="%1$s">click here to contact PubGuru support</a> or <a href="%2$s">send an email to support@monetizemore.com</a>.', 'advanced-ads' ),
'https://www.monetizemore.com/contact/',
'mailto:support@monetizemore.com'
),
'headerBidding' => __( 'Activate PubGuru Header Bidding', 'advanced-ads' ),
'activateTags' => __( 'Activate Tag Conversion', 'advanced-ads' ),
'trafficCop' => __( 'Activate Traffic Cop Invalid Traffic Protection', 'advanced-ads' ),
'trafficCopTrial' => __( '7 Days Trial', 'advanced-ads' ),
'adsTxt' => sprintf(
/* translators: %s is link to PubGuru */
__( 'Redirect ads.txt calls to the <a href="%s" target="_blank" rel="noreferrer">PubGuru platform</a>', 'advanced-ads' ),
'https://app.pubguru.com/ads-txt'
),
'scriptLocation' => __( 'Move the PubGuru Header Bidding script to the footer. <span class="muted">Keep this option disabled to maximize revenue. Only enable it if PageSpeed is your priority.</span>', 'advanced-ads' ),
'onlyPreview' => __( '(Only enabled on Preview Page)', 'advanced-ads' ),
],
'options' => [
'headerBidding' => Options::module( 'header_bidding' ),
'headerBiddingAtBody' => Options::module( 'header_bidding_at_body' ),
'adsTxt' => Options::module( 'ads_txt' ),
'trafficCop' => Options::module( 'traffic_cop' ),
'tagConversion' => Options::module( 'tag_conversion' ),
'connectedDomain' => $config['domain'] ?? '',
'selectedMethod' => $config['method'] ?? 'page',
'selectedPage' => $config['page'] ?? 0,
'selectedPageTitle' => isset( $config['page'] ) ? get_the_title( $config['page'] ) : '',
'hasTrafficCop' => Helpers::has_traffic_cop( $config ),
],
'modal' => [
'title' => __( 'Import PubGuru Ad Units', 'advanced-ads' ),
'btnSave' => __( 'Close and update preview', 'advanced-ads' ),
'btnFinal' => __( 'Finalize ad unit import', 'advanced-ads' ),
'btnUpdate' => __( 'Update preview', 'advanced-ads' ),
'btnGoto' => __( 'Go to the preview', 'advanced-ads' ),
'labelImport' => __( 'Import method', 'advanced-ads' ),
'labelSpecificPage' => __( 'Preview ad units on specific page', 'advanced-ads' ),
'labelFinalImport' => __( 'Finalize ad units import', 'advanced-ads' ),
'descFinalImport' => join(
'',
[
'<ul class="list-disc ml-2">',
'<li>' . __( 'Your existing ads and placements will be set to &lsquo;Draft&rsquo; mode', 'advanced-ads' ) . '</li>',
'<li>' . __( 'Your PubGuru ad units will be imported as suitable ads and placements, and published right away', 'advanced-ads' ) . '</li>',
'</ul>',
'<p>' . __( 'You can manually republish specific ads and placements or fully rollback at any time.', 'advanced-ads' ) . '</p>',
]
),
],
]
);
}
/**
* Add metabox
*
* @return void
*/
public function add_metabox(): void {
echo '<div id="advads-oneclick-app"></div>';
}
}

View File

@@ -0,0 +1,261 @@
<?php
/**
* The class is responsible for ajax functionality.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
* @since 1.48.0
*/
namespace AdvancedAds\Modules\OneClick\Admin;
use WP_Error;
use AdvancedAds\Utilities\WordPress;
use AdvancedAds\Modules\OneClick\Helpers;
use AdvancedAds\Modules\OneClick\Options;
use AdvancedAds\Framework\Utilities\Params;
use AdvancedAds\Modules\OneClick\AdsTxt\Detector;
use AdvancedAds\Framework\Interfaces\Integration_Interface;
use AdvancedAds\Importers\Api_Ads;
defined( 'ABSPATH' ) || exit;
/**
* Ajax.
*/
class Ajax implements Integration_Interface {
/**
* API URL
*
* Production: https://app.pubguru.com
* Development: https://new-stagingtools5.pubguru.com
*
* @var string
*/
const API_URL = 'https://app.pubguru.com/';
/**
* Hook into WordPress
*
* @return void
*/
public function hooks(): void {
add_action( 'init', [ $this, 'init' ] );
add_action( 'wp_ajax_search_posts', [ $this, 'search_posts' ] );
add_action( 'wp_ajax_pubguru_connect', [ $this, 'pubguru_connect' ] );
add_action( 'wp_ajax_pubguru_disconnect', [ $this, 'pubguru_disconnect' ] );
add_action( 'wp_ajax_pubguru_module_change', [ $this, 'module_status_changed' ] );
add_action( 'wp_ajax_pubguru_backup_ads_txt', [ $this, 'backup_ads_txt' ] );
add_action( 'wp_ajax_update_oneclick_preview', [ $this, 'update_oneclick_preview' ] );
}
/**
* Init hook
*
* @return void
*/
public function init(): void {
if ( Params::get( 'refresh_ads', false, FILTER_VALIDATE_BOOLEAN ) ) {
$config = $this->pubguru_api_connect();
if ( is_wp_error( $config ) ) {
wp_die(
$config->get_error_message(), // phpcs:ignore
esc_html__( 'Refreshing PubGuru Ads', 'advanced-ads' ),
$config->get_error_data() // phpcs:ignore
);
}
}
}
/**
* PubGuru Connect
*
* @return void
*/
public function pubguru_connect(): void {
check_ajax_referer( 'pubguru_oneclick_security', 'nonce' );
$config = $this->pubguru_api_connect();
if ( is_wp_error( $config ) ) {
wp_send_json(
[
'success' => false,
'code' => $config->get_error_code(),
'message' => $config->get_error_message(),
],
$config->get_error_data()
);
}
// Default module enabled.
Options::module( 'header_bidding', true );
wp_send_json_success(
[
'message' => esc_html__( 'We have successfully migrated your MonetizeMore PubGuru Ad Units to your WordPress site. The existing placements and ads have been paused.', 'advanced-ads' ),
'hasTrafficCop' => Helpers::has_traffic_cop( $config ),
]
);
}
/**
* PubGuru Disconnect
*
* @return void
*/
public function pubguru_disconnect(): void {
check_ajax_referer( 'pubguru_oneclick_security', 'nonce' );
Options::pubguru_config( 'delete' );
wp_send_json_success(
[
'message' => esc_html__( 'PubGuru successfully disconnected.', 'advanced-ads' ),
]
);
}
/**
* Handle module status changes
*
* @return void
*/
public function module_status_changed(): void {
check_ajax_referer( 'pubguru_oneclick_security', 'security' );
$module = Params::post( 'module', [] );
$status = Params::post( 'status', false, FILTER_VALIDATE_BOOLEAN );
Options::module( $module, $status );
$data = apply_filters( 'pubguru_module_status_changed', [], $module, $status );
wp_send_json_success( $data );
}
/**
* Handle module status changes
*
* @return void
*/
public function backup_ads_txt(): void {
check_ajax_referer( 'pubguru_oneclick_security', 'security' );
$result = ( new Detector() )->backup_file();
if ( false === $result ) {
$notice = sprintf(
'<div class="flex items-center">'
/* translators: 1 is the opening link to the Advanced Ads website, 2 the closing link */
. __( 'The backup of your ads.txt file has failed. Please ensure that a manual backup is created You can find detailed instructions on how to manually back up your ads.txt file in the manual. %1$sManual%2$s', 'advanced-ads' ) // phpcs:ignore
. '</div>',
'<a href="https://wpadvancedads.com/manual/ads-txt/?utm_source=advanced-ads&utm_medium=link&utm_campaign=notice-ads-txt-oci#Manual_backup_of_the_adstxt_file" target="_blank" class="button button-link ml-auto mr-2">',
'</a>'
);
wp_send_json_error( $notice );
}
$notice = sprintf(
'<div class="flex items-center">%s</div>',
esc_html__( 'File successfully backed up.', 'advanced-ads' )
);
wp_send_json_success( $notice );
}
/**
* Search posts
*
* @return void
*/
public function search_posts(): void {
global $wpdb;
check_ajax_referer( 'pubguru_oneclick_security', 'security' );
$search = Params::get( 'q', '' );
$results = $wpdb->get_results(
$wpdb->prepare(
"SELECT ID, post_title FROM {$wpdb->posts}
WHERE post_title LIKE %s
AND post_status = 'publish'
AND post_type IN ('post', 'page')",
'%' . $wpdb->esc_like( $search ) . '%'
)
);
$posts = [];
foreach ( $results as $result ) {
$posts[] = [
'id' => $result->ID,
'text' => $result->post_title,
];
}
wp_send_json( $posts );
}
/**
* Update OneClick preview
*
* @return void
*/
public function update_oneclick_preview(): void {
check_ajax_referer( 'pubguru_oneclick_security', 'security' );
$method = Params::post( 'method', 'page' );
$page = Params::post( 'page', 0, FILTER_VALIDATE_INT );
$config = Options::pubguru_config();
$config['method'] = $method;
$config['page'] = $page;
Options::pubguru_config( $config );
// Importer.
$importer = new Api_Ads();
$importer->import();
wp_send_json_success();
}
/**
* Fetch config from PubGuru api
*
* @return WP_Error|array
*/
private function pubguru_api_connect() {
$domain = Params::post( 'testDomain' ) ? Params::post( 'testDomain' ) : WordPress::get_site_domain();
$domain = str_replace( 'www.', '', $domain );
$response = wp_remote_get(
self::API_URL . 'domain_configs/?domain=' . $domain,
[
'timeout' => 30,
'sslverify' => false,
]
);
$response_code = wp_remote_retrieve_response_code( $response );
if ( 200 !== $response_code ) {
return new WP_Error(
'connect_error',
esc_html__( 'An error has occurred please try again.', 'advanced-ads' ),
$response_code
);
}
$config = json_decode( wp_remote_retrieve_body( $response ), true );
if ( 'error' === $config['status'] ) {
return new WP_Error(
'domain_not_found',
'Connection with PubGuru & MonetizeMore was unsuccessful. Please <a href="https://www.monetizemore.com/contact/">click here</a> to contact MonetizeMore Support or email us at <a href="mailto:support@monetizemore.com">support@monetizemore.com</a>',
201
);
}
$config['domain'] = $domain;
Options::pubguru_config( $config );
return $config;
}
}

View File

@@ -0,0 +1,4 @@
<?php
/**
* Silence is golden.
*/