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,90 @@
<?php
/**
* Admin Ad List Table.
*
* @package AdvancedAds\Pro
* @author Advanced Ads <info@wpadvancedads.com>
* @since 2.26.0
*/
namespace AdvancedAds\Pro\Admin;
use AdvancedAds\Abstracts\Ad;
use AdvancedAds\Framework\Interfaces\Integration_Interface;
defined( 'ABSPATH' ) || exit;
/**
* Admin Ad List Table.
*/
class Ad_List_Table implements Integration_Interface {
/**
* Hook into WordPress.
*
* @return void
*/
public function hooks(): void {
add_filter( 'advanced-ads-ad-columns', [ $this, 'add_columns' ] );
add_action( 'advanced-ads-ad-render-columns', [ $this, 'render_columns' ], 10, 2 );
add_filter( 'default_hidden_columns', [ $this, 'set_hidden_columns' ], 10, 2 );
add_filter( 'advanced_ads_optional_filters', [ $this, 'add_optional_filters' ] );
}
/**
* Add columns to view.
*
* @param array $columns columns.
*
* @return array
*/
public function add_columns( array $columns ): array {
$columns['ad_displayonce'] = __( 'Display Once', 'advanced-ads-pro' );
return $columns;
}
/**
* Render columns.
*
* @param string $column column name.
* @param Ad $ad Ad instance.
*
* @return void
*/
public function render_columns( string $column, $ad ): void {
if ( 'ad_displayonce' === $column ) {
$display_once = $ad->get_prop( 'once_per_page' ) ?? false;
include AA_PRO_ABSPATH . 'views/admin/tables/ads/column-displayonce.php';
}
}
/**
* Hidden columns.
*
* @param array $hidden default hidden columns.
* @param WP_Screen $screen current screen.
*
* @return array|mixed
*/
public function set_hidden_columns( $hidden, $screen ) {
if ( isset( $screen->id ) && 'edit-advanced_ads' === $screen->id ) {
$hidden = array_merge( $hidden, [ 'ad_displayonce' ] );
}
return $hidden;
}
/**
* Adds an optional filter to the list of filters.
*
* @param array $optional_filters The array of optional filters.
*
* @return array
*/
public function add_optional_filters( $optional_filters ): array {
$optional_filters['all_displayonce'] = __( 'Display Once', 'advanced-ads-pro' );
return $optional_filters;
}
}

View File

@@ -0,0 +1,136 @@
<?php
/**
* Backend helper for the AdSense fallback
*
* @package AdvancedAds\Pro
* @author Advanced Ads <info@wpadvancedads.com>
*/
namespace AdvancedAds\Pro\Admin;
use AdvancedAds\Options;
use AdvancedAds\Abstracts\Ad;
use AdvancedAds\Framework\Interfaces\Integration_Interface;
/**
* Backend class
*/
class Adsense implements Integration_Interface {
/**
* Hook into WordPress.
*
* @return void
*/
public function hooks(): void {
add_action( 'advanced-ads-gadsense-extra-ad-param', [ $this, 'ad_parameter_setting' ], 10, 3 );
add_action( 'advanced-ads-ad-pre-save', [ $this, 'save_ad_callback' ], 10, 2 );
add_action( 'admin_init', [ $this, 'add_setting_field' ] );
}
/**
* Add setting field on the AdSense tab of the settings page
*
* @return void
*/
public function add_setting_field() {
add_settings_field(
'adsense-fallback',
__( 'Fallback ad/group', 'advanced-ads-pro' ),
[ $this, 'render_adsense_tab_setting' ],
'advanced-ads-adsense-settings-page',
'advanced_ads_adsense_setting_section'
);
}
/**
* Save fallback option when saving the ad
*
* @param Ad $ad the ad.
* @param array $post_data content of $_POST (without the post content).
*
* @return void
*/
public function save_ad_callback( $ad, $post_data ) {
if ( empty( $post_data['adsense_fallback'] ) ) {
return;
}
preg_match( '/^none|default|ad_.+|group_.+|$/', $post_data['adsense_fallback'], $m );
if ( empty( $m[0] ) ) {
return;
}
$ad->set_prop( 'adsense_fallback', $m[0] );
}
/**
* Add fallback settings on the ad edit page
*
* @param array $params extra template parameters.
* @param string $content ad content.
* @param Ad $ad the ad.
*
* @return void
*/
public function ad_parameter_setting( $params, $content, $ad ) {
$this->render_fallback_setting( false, $ad );
}
/**
* Render setting field on the AdSense tab of the settings page
*
* @return void
*/
public function render_adsense_tab_setting() {
$this->render_fallback_setting( true );
}
/**
* Render the fallback setting markup
*
* @param bool $is_global whether it's the global fallback or not.
* @param Ad $ad the adsense ad.
*
* @return void
*/
public function render_fallback_setting( $is_global, $ad = null ) {
$global_fallback = \AdvancedAds\Pro\Adsense::get_global_fallback();
$global_fallback_object = \AdvancedAds\Pro\Adsense::get_global_fallback_object();
$fallback = $is_global ? $global_fallback : \AdvancedAds\Pro\Adsense::get_fallback( $ad );
$cache_busting = Options::instance()->get( 'pro.cache-busting' );
$items = self::get_fallback_items();
require_once AA_PRO_ABSPATH . 'views/admin/tables/ads/adsense-fallback.php';
}
/**
* List of available fallback ad or group for an unfilled AdSense ad
*
* @return array[]
*/
private static function get_fallback_items() {
static $result;
if ( null !== $result ) {
return $result;
}
$result = [
'ads' => [],
'groups' => [],
];
foreach ( wp_advads_get_all_ads() as $ad ) {
if ( ! $ad->is_type( 'adsense' ) && $ad->is_status( 'publish' ) ) {
$result['ads'][ $ad->get_id() ] = $ad;
}
}
foreach ( wp_advads_get_all_groups() as $group ) {
$result['groups'][ $group->get_id() ] = $group;
}
return $result;
}
}

View File

@@ -0,0 +1,107 @@
<?php
/**
* Admin Duplicate Placement.
*
* @package AdvancedAds\Pro
* @author Advanced Ads <info@wpadvancedads.com>
* @since 2.26.0
*/
namespace AdvancedAds\Pro\Admin;
use AdvancedAds\Constants;
use AdvancedAds\Framework\Interfaces\Integration_Interface;
use AdvancedAds\Framework\Utilities\Params;
use AdvancedAds\Utilities\Conditional;
defined( 'ABSPATH' ) || exit;
/**
* Admin Duplicate Placement.
*/
class Duplicate_Placement implements Integration_Interface {
/**
* Admin action
*
* @var string
*/
private const ACTION = 'advanced_ads_duplicate_placement';
/**
* Hook into WordPress.
*
* @return void
*/
public function hooks(): void {
add_filter( 'post_row_actions', [ $this, 'action_link' ], 10, 2 );
add_action( 'admin_action_' . self::ACTION, [ $this, 'duplicate' ] );
}
/**
* Duplicate a placement
*
* @return void
*/
public function duplicate() {
// Early bail!!
$placement_id = Params::get( 'id', 0, FILTER_VALIDATE_INT );
if ( ! $placement_id ) {
return;
}
check_admin_referer( 'duplicate-placement-' . $placement_id );
if ( self::ACTION !== Params::get( 'action' ) || ! Conditional::user_cap( 'advanced_ads_manage_placements' ) ) {
return;
}
$placement = wp_advads_get_placement( $placement_id );
if ( ! $placement && wp_safe_redirect( admin_url( 'edit.php?post_type=advanced_ads_plcmnt' ) ) ) {
exit;
}
$copy_suffix = ' (' . _x( 'copy', 'noun', 'advanced-ads-pro' ) . ' at ' . current_time( 'Y-m-d H:i:s' ) . ')';
$new_placement = clone $placement;
$new_placement->set_id( null ); // reset the ID to save as a new placement.
$new_placement->set_title( $new_placement->get_title() . $copy_suffix );
$new_placement->set_item( '' );
$new_placement->set_prop( 'test_id', null );
$new_id = $new_placement->save();
if ( wp_safe_redirect( admin_url( 'edit.php?post_type=advanced_ads_plcmnt#modal-placement-edit-' . $new_id ) ) ) {
exit;
}
}
/**
* Add duplicate links on placement table
*
* @param array $actions existing actions.
* @param \WP_Post $post the post.
*
* @return array the modified actions list.
*/
public function action_link( $actions, $post ) {
if ( Constants::POST_TYPE_PLACEMENT !== $post->post_type || ! Conditional::user_cap( 'advanced_ads_manage_placements' ) ) {
return $actions;
}
$action = add_query_arg(
[
'action' => self::ACTION,
'id' => $post->ID,
],
admin_url( 'admin.php' )
);
$actions['duplicate-placement'] = sprintf(
'<a href="%s" title="%s">%s</a>',
wp_nonce_url( $action, 'duplicate-placement-' . $post->ID ),
esc_attr__( 'Create a copy of this placement', 'advanced-ads-pro' ),
esc_html__( 'Duplicate', 'advanced-ads-pro' )
);
return $actions;
}
}

View File

@@ -0,0 +1,131 @@
<?php
/**
* Admin Groups Listing Page.
*
* @package AdvancedAds\Pro
* @author Advanced Ads <info@wpadvancedads.com>
* @since 2.26.0
*/
namespace AdvancedAds\Pro\Admin;
use AdvancedAds\Constants;
use AdvancedAds\Abstracts\Group;
use AdvancedAds\Framework\Utilities\Params;
use AdvancedAds\Framework\Interfaces\Integration_Interface;
defined( 'ABSPATH' ) || exit;
/**
* Duplicate Group.
*/
class Group_Duplication implements Integration_Interface {
private const DUPLICATE_ACTION_NAME = 'advanced_ads_duplicate_group';
/**
* Hook into WordPress.
*
* @return void
*/
public function hooks(): void {
add_filter( Constants::TAXONOMY_GROUP . '_row_actions', [ $this, 'render_row_actions' ], 10, 2 );
add_action( 'admin_action_' . self::DUPLICATE_ACTION_NAME, [ $this, 'duplicate_group' ] );
}
/**
* Renders the row actions for a group.
*
* @param array $actions An array of row actions.
* @param Group $group The group object.
*
* @return array The modified array of row actions.
*/
public function render_row_actions( $actions, $group ): array {
$actions = $this->render_duplicate_link( $actions, $group );
return $actions;
}
/**
* Renders the duplicate link for a group.
*
* This function checks if the current user has the permission to edit the group.
* If the user has the permission, it generates a duplicate link for the group.
* The link allows the user to create a copy of the group.
*
* @param array $actions An array of row actions for the group.
* @param Group $group The group object.
*
* @return array The updated array of actions with the duplicate link.
*/
public function render_duplicate_link( $actions, $group ): array {
if ( ! Group::can_current_user_edit_group() ) {
return $actions;
}
$action = add_query_arg(
[
'action' => self::DUPLICATE_ACTION_NAME,
'group_id' => $group->get_id(),
],
admin_url( 'admin.php' )
);
$actions['duplicate-group'] = sprintf(
'<a href="%s" title="%s">%s</a>',
wp_nonce_url( $action, 'duplicate-group-' . $group->get_id() ),
esc_attr__( 'Create a copy of this group', 'advanced-ads-pro' ),
esc_html__( 'Duplicate', 'advanced-ads-pro' )
);
return $actions;
}
/**
* Duplicate a group.
*
* This method duplicates a group by creating a copy of it with a "(copy)" suffix in the title.
* If the duplication is successful, the user is redirected to the edit page of the new group.
* If the duplication fails, the user is redirected to the groups listing page.
*
* @since 2.26.0
*/
public function duplicate_group(): void {
// Early bail!!
$group_id = Params::get( 'group_id', 0, FILTER_VALIDATE_INT );
if ( ! $group_id ) {
return;
}
check_admin_referer( 'duplicate-group-' . $group_id );
if (
self::DUPLICATE_ACTION_NAME !== Params::get( 'action' ) ||
! Group::can_current_user_edit_group()
) {
return;
}
$group = wp_advads_get_group( $group_id );
if ( ! $group && wp_safe_redirect( admin_url( 'admin.php?page=advanced-ads-groups' ) ) ) {
exit;
}
$copy_suffix = ' (' . _x( 'copy', 'noun', 'advanced-ads-pro' ) . ' at ' . current_time( 'Y-m-d H:i:s' ) . ')';
$new_group = clone $group;
$new_group->set_id( null ); // reset the ID to save as a new group.
$new_group->set_name( $new_group->get_name() . $copy_suffix );
$new_group_id = $new_group->save();
// Set the taxonomy relationships on the new object.
$ad_ids = get_objects_in_term( $group_id, Constants::TAXONOMY_GROUP );
foreach ( $ad_ids as $ad_id ) {
wp_set_object_terms( $ad_id, $new_group_id, Constants::TAXONOMY_GROUP, true );
}
if ( wp_safe_redirect( $new_group->get_edit_link() ) ) {
exit;
}
}
}

View File

@@ -0,0 +1,88 @@
<?php
/**
* Bulk edit for placements
*
* @package AdvancedAds\Pro
* @author Advanced Ads <info@wpadvancedads.com>
*/
namespace AdvancedAds\Pro\Admin\Placements;
use AdvancedAds\Options;
use AdvancedAds\Abstracts\Placement;
use AdvancedAds\Framework\Utilities\Params;
use AdvancedAds\Framework\Interfaces\Integration_Interface;
defined( 'ABSPATH' ) || exit;
/**
* Placements Bulk Edit.
*/
class Bulk_Edit implements Integration_Interface {
/**
* Hook into WordPress.
*
* @return void
*/
public function hooks(): void {
add_action( 'advanced-ads-placement-bulk-edit-fields', [ $this, 'add_bulk_edit_fields' ] );
add_filter( 'advanced-ads-placement-bulk-edit-has-change', [ $this, 'bulk_edit_has_changes' ] );
add_filter( 'advanced-ads-placement-bulk-edit-save', [ $this, 'save_bulk_edit' ] );
}
/**
* Add the bulk edit inputs
*
* @return void
*/
public function add_bulk_edit_fields(): void {
include_once AA_PRO_ABSPATH . 'views/admin/placements/bulk-edit.php';
}
/**
* Check if bulk edit fields have changes.
*
* @param bool $has_change whether some ads have been changed.
*
* @return bool
*/
public function bulk_edit_has_changes( $has_change ): bool {
$cache_busting = Params::get( 'cache_busting' );
$lazy_loading = Params::get( 'lazy_loading' );
$cache_busting_empty = Params::get( 'cache_busting_empty' );
if ( ! empty( $cache_busting ) || ! empty( $lazy_loading ) || ! empty( $cache_busting_empty ) ) {
$has_change = true;
}
return $has_change;
}
/**
* Save changes made during bulk edit
*
* @param Placement $placement current placement being saved.
*
* @return Placement
*/
public function save_bulk_edit( $placement ): Placement {
$cache_busting = Params::get( 'cache_busting' );
$lazy_loading = Params::get( 'lazy_loading' );
$cache_busting_empty = Params::get( 'cache_busting_empty', false, FILTER_VALIDATE_BOOLEAN );
if ( ! empty( $cache_busting ) ) {
$placement->set_prop( 'cache-busting', $cache_busting );
}
if ( ! empty( $lazy_loading ) ) {
$placement->set_prop( 'lazy_load', $lazy_loading );
}
if ( ! empty( $cache_busting_empty ) ) {
$placement->set_prop( 'cache_busting_empty', 1 === $cache_busting_empty );
}
return $placement;
}
}