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,59 @@
<?php
/**
* AAWP Compatibility.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
* @since 1.48.2
*/
namespace AdvancedAds\Compatibility;
use AdvancedAds\Abstracts\Ad;
use AdvancedAds\Interfaces\Ad_Interface;
defined( 'ABSPATH' ) || exit;
/**
* AAWP Ad.
*/
class AAWP_Ad extends Ad implements Ad_Interface {
/**
* Prepare output for frontend.
*
* @return string
*/
public function prepare_frontend_output(): string {
$display_variant = $this->get_prop( 'display_variant' );
if ( empty( $display_variant ) ) {
return '';
}
switch ( $display_variant ) {
case 'box':
$next_input = $this->get_prop( 'asin' );
break;
case 'bestseller':
case 'new':
$next_input = $this->get_prop( 'keywords' );
break;
default:
$next_input = '';
}
$template = ! empty( $this->get_prop( 'template' ) ) ? $this->get_prop( 'template' ) : 'default';
$shortcode = '[' . aawp_get_shortcode() . ' ' . $display_variant . '="' . $next_input . '"';
if ( 'bestseller' === $display_variant || 'new' === $display_variant ) {
$shortcode = $shortcode . ' items="' . $this->get_prop( 'items' ) . '"';
}
$shortcode = $shortcode . ' template="' . $template . '"]';
return do_shortcode( $shortcode );
}
}

View File

@@ -0,0 +1,59 @@
<?php
/**
* AAWP Compatibility.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
* @since 1.48.2
*/
namespace AdvancedAds\Compatibility;
use AdvancedAds\Framework\Interfaces\Integration_Interface;
defined( 'ABSPATH' ) || exit;
/**
* AAWP.
*/
class AAWP implements Integration_Interface {
/**
* Hook into WordPress.
*
* @return void
*/
public function hooks(): void {
add_filter( 'advanced-ads-ad-types', [ $this, 'ad_type' ], 30 );
}
/**
* Add AAWP ad type to Advanced Ads.
*
* @param array $types ad types.
*
* @return array
*/
public function ad_type( $types ): array {
if ( isset( $types['aawp'] ) && 'Advanced_Ads_Ad_Type_Abstract' === get_parent_class( $types['aawp'] ) ) {
$advanced_ads_aawp = $types['aawp'];
unset( $types['aawp'] );
ob_start();
$advanced_ads_aawp->render_icon( null );
$icon = ob_get_clean();
$types['aawp'] = [
'id' => 'aawp',
'title' => $advanced_ads_aawp->title,
'description' => $advanced_ads_aawp->description,
'is_upgrade' => false,
'icon' => $icon,
'classname' => AAWP_Ad::class,
'render_parameters' => [ $advanced_ads_aawp, 'render_parameters' ],
];
}
return $types;
}
}

View File

@@ -0,0 +1,111 @@
<?php
/**
* This class is responsible for fixing compatibility issues in admin area.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
* @since 1.48.2
*/
namespace AdvancedAds\Compatibility;
use AdvancedAds\Constants;
use AdvancedAds\Utilities\Conditional;
use AdvancedAds\Framework\Interfaces\Integration_Interface;
defined( 'ABSPATH' ) || exit;
/**
* Admin Compatibility.
*/
class Admin_Compatibility implements Integration_Interface {
/**
* Hook into WordPress.
*
* @return void
*/
public function hooks(): void {
add_action( 'admin_enqueue_scripts', [ $this, 'dequeue_jnews_style' ], 100 );
add_action( 'quads_meta_box_post_types', [ $this, 'fix_wpquadspro_issue' ], 11 );
add_filter( 'wpml_admin_language_switcher_active_languages', [ $this, 'wpml_language_switcher' ] );
// Hide from WPML translation settings.
if ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
add_filter( 'get_translatable_documents', [ $this, 'wpml_hide_from_translation' ], 10, 1 );
}
}
/**
* Fixes a WP QUADS PRO compatibility issue
* they inject their ad optimization meta box into our ad page, even though it is not a public post type
* using they filter, we remove AA from the list of post types they inject this box into
*
* @param array $allowed_post_types Array of allowed post types.
*
* @return array
*/
public function fix_wpquadspro_issue( $allowed_post_types ): array {
unset( $allowed_post_types['advanced_ads'] );
return $allowed_post_types;
}
/**
* Dequeue J-NEWS styles to prevent layout issues.
*
* @return void
*/
public function dequeue_jnews_style(): void {
if ( ! Conditional::is_screen_advanced_ads() || ! defined( 'JNEWS_THEME_URL' ) ) {
return;
}
wp_dequeue_style( 'jnews-admin' );
}
/**
* Show only all languages in language switcher on Advanced Ads pages if ads and groups are translated
*
* @param array $active_languages languages that can be used in language switcher.
*
* @return array
*/
public function wpml_language_switcher( $active_languages ): array {
global $sitepress;
$screen = get_current_screen();
// Are we on group edit page and ad group translations are disabled.
if ( isset( $screen->id ) && 'advanced-ads_page_advanced-ads-groups' === $screen->id ) {
$translatable_taxonomies = $sitepress->get_translatable_taxonomies();
if ( ! is_array( $translatable_taxonomies ) || ! in_array( 'advanced_ads_groups', $translatable_taxonomies, true ) ) {
return [];
}
}
// If ad post type is translatable.
if ( isset( $screen->id ) && in_array( $screen->id, [ 'edit-advanced_ads', 'advanced_ads' ], true ) ) {
$translatable_documents = $sitepress->get_translatable_documents();
if ( empty( $translatable_documents['advanced_ads'] ) ) {
return [];
}
}
return $active_languages;
}
/**
* Hide post type from WPML translatable documents.
*
* @param array $documents Array of translatable documents.
*
* @return array Modified array.
*/
public function wpml_hide_from_translation( $documents ): array {
if ( isset( $documents[ Constants::POST_TYPE_PLACEMENT ] ) ) {
unset( $documents[ Constants::POST_TYPE_PLACEMENT ] );
}
return $documents;
}
}

View File

@@ -0,0 +1,157 @@
<?php
/**
* Integrates Advanced Ads capabilities with third party role manager plugins.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
* @since 1.50.0
*/
namespace AdvancedAds\Compatibility;
use AdvancedAds\Constants;
use AdvancedAds\Installation\Capabilities;
use AdvancedAds\Framework\Interfaces\Integration_Interface;
defined( 'ABSPATH' ) || exit;
/**
* Capability Manager.
*
* Integrates with: Members
* Integrates with: User Role Editor
* Integrates with: PublishPress Capabilities
*/
class Capability_Manager implements Integration_Interface {
/**
* Group name.
*
* @var string
*/
const GROUP = 'advanced-ads';
/**
* Capability manager.
*
* @var Capabilities
*/
private $capability_manager = null;
/**
* Hook into WordPress.
*
* @return void
*/
public function hooks(): void {
$this->capability_manager = new Capabilities();
// Integrates with: Members.
add_action( 'members_register_caps', [ $this, 'register_members_caps' ] );
add_action( 'members_register_cap_groups', [ $this, 'register_members_groups' ] );
// Integrates with: User Role Editor.
add_filter( 'ure_capabilities_groups_tree', [ $this, 'register_ure_groups' ] );
add_filter( 'ure_custom_capability_groups', [ $this, 'register_ure_caps' ], 10, 2 );
// Integrates with: PublishPress Capabilities.
add_filter( 'cme_plugin_capabilities', [ $this, 'register_publishpress_caps' ] );
}
/**
* Get the name of the integration.
*
* @return string
*/
public function get_name(): string {
return __( 'Advanced Ads', 'advanced-ads' );
}
/**
* Register Members groups.
*
* @return void
*/
public function register_members_groups(): void {
members_register_cap_group(
self::GROUP,
[
'label' => $this->get_name(),
'priority' => 10,
'icon' => 'dashicons-editor-textcolor',
'caps' => array_keys( $this->capability_manager->get_capabilities() ),
]
);
// Remove post types groups.
members_unregister_cap_group( 'type-' . Constants::POST_TYPE_AD );
members_unregister_cap_group( 'type-' . Constants::POST_TYPE_PLACEMENT );
}
/**
* Register members capabilities.
*
* @return void
*/
public function register_members_caps(): void {
$capabilities = $this->capability_manager->get_capabilities();
foreach ( $capabilities as $cap => $label ) {
members_register_cap(
$cap,
[
'label' => $label,
'group' => self::GROUP,
]
);
}
}
/**
* Register URE groups.
*
* @param array $groups Groups.
*
* @return array
*/
public function register_ure_groups( array $groups ): array {
$groups = (array) $groups;
$groups[ self::GROUP ] = [
'caption' => $this->get_name(),
'parent' => 'custom',
'level' => 2,
];
return $groups;
}
/**
* Register URE capabilities.
*
* @param array $groups Current capability groups.
* @param string $cap_id Capability identifier.
*
* @return array
*/
public function register_ure_caps( $groups, $cap_id ): array {
if ( array_key_exists( $cap_id, $this->capability_manager->get_capabilities() ) ) {
$groups = (array) $groups;
$groups[] = self::GROUP;
}
return $groups;
}
/**
* Register PublishPress capabilities.
*
* @param array $caps Capabilities.
*
* @return array
*/
public function register_publishpress_caps( array $caps ): array {
$caps[ $this->get_name() ] = array_keys( $this->capability_manager->get_capabilities() );
return $caps;
}
}

View File

@@ -0,0 +1,263 @@
<?php
/**
* Compatibility Compatibility.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
* @since 1.48.2
*/
namespace AdvancedAds\Compatibility;
use Exception;
use ReflectionClass;
use AdvancedAds\Utilities\Data;
use AdvancedAds\Framework\Utilities\Str;
use AdvancedAds\Framework\Interfaces\Integration_Interface;
defined( 'ABSPATH' ) || exit;
/**
* Compatibility Compatibility.
*/
class Compatibility implements Integration_Interface {
/**
* Hook into WordPress.
*
* @return void
*/
public function hooks(): void {
if ( is_admin() ) {
( new Admin_Compatibility() )->hooks();
}
add_filter( 'wpseo_sitemap_entry', [ $this, 'wpseo_noindex_ad_attachments' ], 10, 3 );
add_filter( 'mailpoet_newsletter_shortcode', [ $this, 'mailpoet_ad_shortcode' ] );
if ( defined( 'ELEMENTOR_VERSION' ) ) {
add_filter( 'advanced-ads-placement-content-injection-xpath', [ $this, 'elementor_content_injection' ] );
}
if ( defined( 'BORLABS_COOKIE_VERSION' ) ) {
add_filter( 'advanced-ads-can-display-ads-in-header', [ $this, 'borlabs_cookie_can_add_auto_ads' ], 10 );
}
}
/**
* WordPress SEO: remove attachments attached to ads from `/attachment-sitemap.xml`.
*
* @param array $url Array of URL parts.
* @param string $type URL type.
* @param object $post WP_Post object of attachment.
*
* @return array|bool Unmodified array of URL parts or false to remove URL.
*/
public function wpseo_noindex_ad_attachments( $url, $type, $post ) {
if ( 'post' !== $type ) {
return $url;
}
$ad_ids = Data::get_ads_ids();
if ( isset( $post->post_parent ) && in_array( $post->post_parent, $ad_ids, true ) ) {
return false;
}
return $url;
}
/**
* Display an ad or ad group in a newsletter created by MailPoet.
*
* Usage:
* [custom:ad:123] to display ad with the ID 123
* [custom:ad_group:345] to display ad group with the ID 345
*
* @param string $shortcode Shortcode that placed the ad.
*
* @return string
*/
public function mailpoet_ad_shortcode( $shortcode ): string {
// Display an ad group.
if ( sscanf( $shortcode, '[custom:ad_group:%d]', $id ) === 1 ) {
$ad_group = wp_advads_get_group( $id );
return ( $ad_group && $ad_group->is_type( [ 'default', 'ordered' ] ) )
? get_the_group( $ad_group )
: '';
}
// Display individual ad.
if ( sscanf( $shortcode, '[custom:ad:%d]', $id ) === 1 ) {
$ad = wp_advads_get_ad( $id );
if ( $ad && $ad->is_type( [ 'plain', 'image' ] ) ) {
$ad_content = get_the_ad( $ad );
// Add responsive styles for email compatibility.
if ( $ad->is_type( 'image' ) ) {
return str_replace(
'<img',
'<img style="max-width: 100%; height: auto; display: block;"',
$ad_content
);
}
return $ad_content;
}
return '';
}
return $shortcode;
}
/**
* Modify xPath expression for Elementor plugin.
* The plugin does not wrap newly created text in 'p' tags.
*
* @param string $tag Xpath tag.
*
* @return string
*/
public function elementor_content_injection( $tag ): string {
// 'p' or 'div.elementor-widget-text-editor' without nested 'p'
if ( 'p' === $tag ) {
$tag = "*[self::p or self::div[@class and contains(concat(' ', normalize-space(@class), ' '), ' elementor-widget-text-editor ') and not(descendant::p)]]";
}
return $tag;
}
/**
* Check if Adsense Auto ads code can be added to the header.
*
* @param bool $can_display If the ad can be displayed.
*
* @return bool
*/
public function borlabs_cookie_can_add_auto_ads( $can_display ): bool {
if ( ! $can_display ) {
return false;
}
return ! self::borlabs_cookie_adsense_auto_ads_code_exists();
}
/**
* Thrive Theme Builder Check if placements of type other than `header` can be injected during `wp_head` action.
*/
public static function can_inject_during_wp_head() {
if ( did_action( 'before_theme_builder_template_render' ) && ! did_action( 'after_theme_builder_template_render' ) ) {
return true;
}
return false;
}
/**
* Check if Adsense Auto ads code is added by the Borlabs Cookie plugin.
*
* This allows to prevent the "Only one 'enable_page_level_ads' allowed per page" error
* that makes impossible to close the "Privacy Preference" window created by the "Borlabs Cookie" plugin.
*
* @return bool
*/
public static function borlabs_cookie_adsense_auto_ads_code_exists(): bool {
static $result = null;
if ( null !== $result ) {
return $result;
}
$all_cookies = self::borlabs_get_cookies();
if ( empty( $all_cookies ) ) {
$result = false;
return $result;
}
foreach ( $all_cookies as $cookie_group_data ) {
if ( self::is_marketing_cookie( $cookie_group_data ) ) {
foreach ( $cookie_group_data->cookies as $cookie_data ) {
if ( self::is_adsense_cookie( $cookie_data ) ) {
$opt_in_js = $cookie_data->opt_in_js;
}
}
}
}
if ( empty( $opt_in_js ) ) {
$result = false;
return $result;
}
$result = preg_match( '/<script[^>]+data-ad-client/', $opt_in_js ) || false !== strpos( $opt_in_js, 'enable_page_level_ads:' );
return $result;
}
/**
* Get cookies from borlabs plugin
*
* @return bool|array
*/
private static function borlabs_get_cookies() {
// Early bail!!
if ( ! class_exists( '\BorlabsCookie\Cookie\Frontend\Cookies' ) ) {
return false;
}
$all_cookies = [];
try {
$refl_cookies = new ReflectionClass( '\BorlabsCookie\Cookie\Frontend\Cookies' );
if ( $refl_cookies->hasMethod( 'getInstance' ) && $refl_cookies->hasMethod( 'getAllCookieGroups' ) ) {
$instance = $refl_cookies->getMethod( 'getInstance' );
$cookie_groups = $refl_cookies->getMethod( 'getAllCookieGroups' );
if ( $instance->isPublic() && $instance->isStatic() && $cookie_groups->isPublic() ) {
$all_cookies = \BorlabsCookie\Cookie\Frontend\Cookies::getInstance()->getAllCookieGroups();
}
}
} catch ( Exception $e ) {
return false;
}
return $all_cookies;
}
/**
* Is cookie is of marketing and has data
*
* @param mixed $cookie Cookie to check.
*
* @return bool
*/
private static function is_marketing_cookie( $cookie ): bool {
if (
! empty( $cookie->group_id ) &&
'marketing' === $cookie->group_id &&
! empty( $cookie->cookies )
) {
return true;
}
return false;
}
/**
* Is cookie is of marketing and has data
*
* @param mixed $cookie Cookie to check.
*
* @return bool
*/
private static function is_adsense_cookie( $cookie ): bool {
if (
! empty( $cookie->cookie_id ) &&
'google-adsense' === $cookie->cookie_id &&
! empty( $cookie->opt_in_js )
) {
return true;
}
return false;
}
}

View File

@@ -0,0 +1,115 @@
<?php
/**
* Compatibility Inline JS.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
* @since 1.48.2
*/
namespace AdvancedAds\Compatibility;
use AdvancedAds\Framework\Interfaces\Integration_Interface;
defined( 'ABSPATH' ) || exit;
/**
* Compatibility Inline JS.
*/
class Inline_JS implements Integration_Interface {
/**
* Array that holds strings that should not be optimized by other plugins.
*
* @var array
*/
private $inline_js;
/**
* Hook into WordPress.
*
* @return void
*/
public function hooks(): void {
$this->critical_inline_js();
add_filter( 'rocket_delay_js_exclusions', [ $this, 'rocket_exclude_inline_js' ] );
add_filter( 'rocket_excluded_inline_js_content', [ $this, 'rocket_exclude_inline_js' ] );
add_filter( $this->get_cmplz_hook(), [ $this, 'complianz_exclude_inline_js' ], 10, 2 );
}
/**
* Prevent the 'advanced_ads_ready' function declaration from being merged with other JS
* and outputted into the footer. This is needed because WP Rocket does not output all
* the code that depends on this function into the footer.
*
* @param array $exclusions Patterns to match in inline JS content.
*
* @return array
*/
public function rocket_exclude_inline_js( $exclusions ): array {
return array_merge( $exclusions, $this->inline_js );
}
/**
* Prevent Complianz from suppressing our head inline script.
*
* @param string $classname The class Complianz adds to the script, `cmplz-script` for prevented scripts, `cmplz-native` for allowed.
* @param string $total_match The script string.
*
* @return string
*/
public function complianz_exclude_inline_js( $classname, $total_match ) {
// Early bail!!
if ( 'cmplz-native' === $classname ) {
return $classname;
}
foreach ( $this->inline_js as $critical_inline_js ) {
if ( false !== strpos( $total_match, $critical_inline_js ) ) {
return 'cmplz-native';
}
}
return $classname;
}
/**
* Get an array of strings to exclude when plugins "optimize" JS.
*
* @return void
*/
private function critical_inline_js(): void {
$frontend_prefix = wp_advads()->get_frontend_prefix();
$default = [
sprintf( 'id="%sready"', $frontend_prefix ),
];
/**
* Filters an array of strings of (inline) JavaScript "identifiers" that should not be "optimized"/delayed etc.
*
* @param array $default Array of excluded patterns.
*/
$exclusions = apply_filters( 'advanced-ads-compatibility-critical-inline-js', $default, $frontend_prefix );
if ( ! is_array( $exclusions ) ) {
$exclusions = $default;
}
$this->inline_js = $exclusions;
}
/**
* Get cmplz hook by version
*
* @return string
*/
private function get_cmplz_hook(): string {
$complianz_version = get_option( 'cmplz-current-version', false );
if ( $complianz_version && version_compare( $complianz_version, '6.0.0', '>=' ) ) {
return 'cmplz_service_category';
}
return 'cmplz_script_class';
}
}

View File

@@ -0,0 +1,88 @@
<?php
/**
* Peepso Compatibility.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
* @since 1.48.2
*/
namespace AdvancedAds\Compatibility;
use AdvancedAds\Abstracts\Ad;
use AdvancedAds\Interfaces\Ad_Interface;
defined( 'ABSPATH' ) || exit;
/**
* Peepso Ad.
*/
class Peepso_Ad extends Ad implements Ad_Interface {
/**
* Prepare output for frontend.
*
* @return string
*/
public function prepare_frontend_output(): string {
$content = $this->get_content();
$image_url = wp_get_attachment_image_url( $this->get_prop( 'image_id' ), 'full' );
$image_url = $image_url[0] ?? null;
$avatar_url = wp_get_attachment_image_url( $this->get_prop( 'avatar_id' ), 'full' );
$avatar_url = $avatar_url[0] ?? null;
$url = $this->get_url() ?? '#';
$title = $this->get_title() ?? '';
$title_override = $this->get_prop( 'title_override' ) ?? '';
if ( $title_override && '' !== $title_override ) {
$title = $title_override;
}
ob_start();
?>
<div class="ps-post__header">
<?php if ( $avatar_url ) : ?>
<a class="ps-avatar ps-avatar--post" target="_blank" href="<?php echo esc_url( $url ); ?>">
<img src="<?php echo esc_url( $avatar_url ); ?>" alt="" />
</a>
<?php endif; ?>
<div class="ps-post__meta">
<div class="ps-post__title">
<a target="_blank" href="<?php echo esc_url( $url ); ?>">
<?php echo $title; // phpcs:ignore ?>
</a>
</div>
<div class="ps-post__info">
<?php
if ( \PeepSo::get_option( 'advancedads_stream_sponsored_mark', 0 ) ) {
echo \PeepSo::get_option( 'advancedads_stream_sponsored_text' ); // phpcs:ignore
}
?>
</div>
</div>
</div>
<div class="ps-post__body">
<div class="ps-post__content">
<?php
$content = $this->get_content();
$allow_tags = \PeepSo::get_option_new( 'advanced_ads_allow_all_tags' );
echo $allow_tags
? $content // phpcs:ignore
: wpautop( strip_tags( $content, \PeepSoAdvancedAdsAdTypePeepSo::get_allowed_html() ) ); // phpcs:ignore
?>
</div>
<?php if ( $image_url ) : ?>
<a target="_blank" class="ps-advads__image" href="<?php echo esc_url( $url ); ?>">
<img src="<?php echo esc_url( $image_url ); ?>" alt="" />
</a>
<?php endif; ?>
</div>
<?php
return ob_get_clean();
}
}

View File

@@ -0,0 +1,221 @@
<?php
/**
* Peepso Compatibility.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
* @since 1.48.2
*/
namespace AdvancedAds\Compatibility;
use AdvancedAds\Framework\Interfaces\Integration_Interface;
defined( 'ABSPATH' ) || exit;
/**
* Peepso.
*
* phpcs:disable WordPress.WP.I18n.TextDomainMismatch
* phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
*/
class Peepso implements Integration_Interface {
/**
* Object.
*
* @var object
*/
private $object = null;
/**
* Hook into WordPress.
*
* @return void
*/
public function hooks(): void {
add_filter( 'advanced-ads-ad-types', [ $this, 'ad_type' ], 100 );
add_filter( 'advanced-ads-placement-types', [ $this, 'placement_type' ], 25 );
}
/**
* Add Peepso placement type to Advanced Ads.
*
* @param array $types placement types.
*
* @return array
*/
public function placement_type( $types ): array {
if ( class_exists( 'PeepSoAdvancedAdsPlugin' ) ) {
$types['peepso_stream'] = [
'title' => __( 'PeepSo Stream', 'peepso-advanced-ads' ),
'description' => __( 'Display this ad in PeepSo Stream', 'advanced-ads' ),
'image' => ADVADS_BASE_URL . 'assets/img/placement-types/peepso-stream-placement.png',
'is_premium' => false,
];
}
return $types;
}
/**
* Add Peepso ad type to Advanced Ads.
*
* @param array $types ad types.
*
* @return array
*/
public function ad_type( $types ): array {
if ( class_exists( 'PeepSoAdvancedAdsPlugin' ) && isset( $types['peepso'] ) && 'Advanced_Ads_Ad_Type_Abstract' === get_parent_class( $types['peepso'] ) ) {
$this->object = $types['peepso'];
unset( $types['peepso'] );
$types['peepso'] = [
'id' => 'peepso',
'title' => $this->object->title,
'description' => $this->object->description,
'is_upgrade' => false,
'classname' => Peepso_Ad::class,
'render_parameters' => [ $this, 'render_parameters' ],
];
}
return $types;
}
/**
* Render Peepso parameters.
*
* @param AD $ad Ad object.
*
* @return void
*/
public function render_parameters( $ad ) {
$content = $ad->get_content();
$title_override = $ad->get_prop( 'title_override' ) ?? '';
$image_id = $ad->get_prop( 'image_id' ) ?? '';
$avatar_id = $ad->get_prop( 'avatar_id' ) ?? '';
$url = $ad->get_url() ?? '#';
?>
<script type="text/javascript">
jQuery(function( $ ) {
$('#advanced-ads-ad-parameters-size').prev('span').hide();
});
</script>
<style type="text/css">
#advads-image-preview img, #advads-avatar-preview img{
padding:2px;
border:solid 1px #aaaaaa;
}
#advads-image-preview {
width:500px;
}
#advads-avatar-preview img {
height: auto;
max-width: 128px;
max-heigth:128px;
width: 100%;
}
#advanced-ads-ad-parameters-size {
display:none;
}
.description {
color:#aaaaaa;
}
</style>
<!-- Avatar -->
<h1>
<?php esc_html_e( 'Avatar', 'peepso-advanced-ads' ); ?>
<button href="#" class="advads_avatar_upload button button-secondary" type="button" data-uploader-title="<?php esc_html_e( 'Insert File', 'peepso-advanced-ads' ); ?>" data-uploader-button-text="<?php esc_html_e( 'Insert', 'peepso-advanced-ads' ); ?>" onclick="return false;">
<?php esc_html_e( 'Change', 'peepso-advanced-ads' ); ?>
</button>
</h1>
<div class="description">
<?php esc_html_e( 'The uploaded image should be square and at least 128x128 pixels.', 'peepso-advanced-ads' ); ?>
</div>
<div id="advads-avatar-preview">
<?php echo $this->object->image_tag( $avatar_id ); ?>
</div>
<input type="hidden" name="advanced_ad[output][avatar_id]" value="<?php echo $avatar_id; ?>" id="advads-avatar-id"/>
<br class="clear" />
<hr>
<!-- Title Override -->
<h1>
<?php esc_html_e( 'Title override', 'peepso-advanced-ads' ); ?>
</h1>
<div class="description">
<?php esc_html_e( 'Optional. If nothing is provided, the general ad title will be used.', 'peepso-advanced-ads' ); ?>
</div>
<input type="text" size="64" maxlength=="128" id="advanced_ad[output][title_override]" name="advanced_ad[output][title_override]" value="<?php echo ( $title_override ); ?>" />
<!-- Content -->
<h1>
<?php esc_html_e( 'Content', 'peepso-advanced-ads' ); ?>
</h1>
<div class="description">
<?php
$description = __( 'Supported HTML tags:', 'peepso-advanced-ads' ) . ' <pre style="display:inline-block;margin:0;">' . htmlspecialchars( \PeepSoAdvancedAdsAdTypePeepSo::get_allowed_html() ) . '</pre>';
if ( \PeepSo::get_option_new( 'advanced_ads_allow_all_tags' ) ) {
$description = __( 'All HTML tag enabled, proceed with extreme care', 'peepso-advanced-ads' );
}
echo $description;
?>
</div>
<textarea id="advads-content-plain" cols="100" rows="10" name="advanced_ad[content]"><?php echo esc_textarea( $content ); ?></textarea>
<br class="clear" />
<hr>
<!-- Image -->
<h1>
<?php esc_html_e( 'Image', 'peepso-advanced-ads' ); ?>
<button href="#" class="advads_image_upload button button-secondary" type="button" data-uploader-title="<?php esc_html_e( 'Insert File', 'peepso-advanced-ads' ); ?>" data-uploader-button-text="<?php esc_html_e( 'Insert', 'peepso-advanced-ads' ); ?>" onclick="return false;">
<?php esc_html_e( 'Change', 'peepso-advanced-ads' ); ?>
</button>
</h1>
<div class="description">
<?php esc_html_e( 'Image will be displayed at full width of your Community stream (depending on theme, layout and screen size). For best results use an image at least 1000 pixels wide.', 'peepso-advanced-ads' ); ?>
</div>
<div id="advads-image-preview">
<?php echo $this->object->image_tag( $image_id ); ?>
</div>
<input type="hidden" name="advanced_ad[output][image_id]" value="<?php echo $image_id; ?>" id="advads-image-id"/>
<br class="clear" />
<hr>
<h1>
<?php esc_html_e( 'URL', 'peepso-advanced-ads' ); ?>
</h1>
<div class="description">
<?php esc_html_e( 'Clicking the image, avatar or title will open the link in a new window/tab. ', 'peepso-advanced-ads' ); ?>
</div>
<input type="url" name="advanced_ad[url]" id="advads-url" value="<?php echo $url; ?>"/>
<br class="clear" />
<?php
}
}