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,21 @@
<?php
/**
* This class represents the "After Content" placement.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
* @since 1.47.0
*/
namespace AdvancedAds\Placements;
use AdvancedAds\Abstracts\Placement;
use AdvancedAds\Interfaces\Placement_Interface;
defined( 'ABSPATH' ) || exit;
/**
* After Content.
*/
class Placement_After_Content extends Placement implements Placement_Interface {
}

View File

@@ -0,0 +1,21 @@
<?php
/**
* This class represents the "Before Content" placement.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
* @since 1.47.0
*/
namespace AdvancedAds\Placements;
use AdvancedAds\Abstracts\Placement;
use AdvancedAds\Interfaces\Placement_Interface;
defined( 'ABSPATH' ) || exit;
/**
* Before Content.
*/
class Placement_Before_Content extends Placement implements Placement_Interface {
}

View File

@@ -0,0 +1,21 @@
<?php
/**
* This class represents the "Content" placement.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
* @since 1.47.0
*/
namespace AdvancedAds\Placements;
use AdvancedAds\Abstracts\Placement;
use AdvancedAds\Interfaces\Placement_Interface;
defined( 'ABSPATH' ) || exit;
/**
* Content.
*/
class Placement_Content extends Placement implements Placement_Interface {
}

View File

@@ -0,0 +1,121 @@
<?php
/**
* The placement factory.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
* @since 1.50.0
*/
namespace AdvancedAds\Placements;
use Exception;
use AdvancedAds\Constants;
use AdvancedAds\Abstracts\Factory;
use AdvancedAds\Abstracts\Placement;
use AdvancedAds\Placements\Placement_Standard;
defined( 'ABSPATH' ) || exit;
/**
* Placements Factory.
*/
class Placement_Factory extends Factory {
/**
* Create an empty placement object
*
* @param string $type Type of placement to create.
*
* @return Placement|bool Placement object or false if the placement type not found.
*/
public function create_placement( $type = 'default' ) {
$placement_type = wp_advads_get_placement_type( $type );
if ( ! $placement_type ) {
return false;
}
$classname = $placement_type->get_classname();
// Create placement.
$placement = new $classname( 0 );
$placement->set_type( $placement_type->get_id() );
return $placement;
}
/**
* Get the placement object.
*
* @param Placement|WP_Post|int|bool $placement_id Placement instance, post instance, numeric or false to use global $post.
* @param string $new_type Change type of placement.
*
* @return Placement|bool Placement object or false if the placement cannot be loaded.
*/
public function get_placement( $placement_id = false, $new_type = '' ) {
$placement_id = $this->get_placement_id( $placement_id );
if ( ! $placement_id ) {
return false;
}
$placement_type = '' !== $new_type ? $new_type : $this->get_placement_type( $placement_id );
$classname = $this->get_classname( wp_advads_get_placement_type_manager(), $placement_type );
try {
return new $classname( $placement_id );
} catch ( Exception $e ) {
return false;
}
return new Placement_Standard();
}
/**
* Get the type of the placement.
*
* @param int $placement_id Placement ID.
*
* @return string The type of the placement.
*/
private function get_placement_type( $placement_id ): string {
// Allow the overriding of the lookup in this function. Return the placement type here.
$override = apply_filters( 'advanced-ads-placement-type', false, $placement_id );
if ( $override ) {
return $override;
}
$options = get_post_meta( $placement_id, 'type', true );
return $options['type'] ?? 'default';
}
/**
* Get the placement ID depending on what was passed.
*
* @param Placement|WP_Post|int|bool $placement Placement instance, post instance, numeric or false to use global $post.
*
* @return int|bool false on failure
*/
private function get_placement_id( $placement ) {
global $post;
if ( false === $placement && isset( $post, $post->ID ) && Constants::POST_TYPE_AD === get_post_type( $post->ID ) ) {
return absint( $post->ID );
}
if ( is_numeric( $placement ) ) {
return $placement;
}
if ( is_a_placement( $placement ) ) {
return $placement->get_id();
}
if ( ! empty( $placement->ID ) ) {
return $placement->ID;
}
return false;
}
}

View File

@@ -0,0 +1,21 @@
<?php
/**
* This class represents the "Footer" placement.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
* @since 1.47.0
*/
namespace AdvancedAds\Placements;
use AdvancedAds\Abstracts\Placement;
use AdvancedAds\Interfaces\Placement_Interface;
defined( 'ABSPATH' ) || exit;
/**
* Footer.
*/
class Placement_Footer extends Placement implements Placement_Interface {
}

View File

@@ -0,0 +1,21 @@
<?php
/**
* This class represents the "Header" placement.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
* @since 1.47.0
*/
namespace AdvancedAds\Placements;
use AdvancedAds\Abstracts\Placement;
use AdvancedAds\Interfaces\Placement_Interface;
defined( 'ABSPATH' ) || exit;
/**
* Header.
*/
class Placement_Header extends Placement implements Placement_Interface {
}

View File

@@ -0,0 +1,426 @@
<?php
/**
* The placement repository.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
* @since 1.50.0
*/
namespace AdvancedAds\Placements;
use WP_Query;
use Exception;
use AdvancedAds\Constants;
use AdvancedAds\Abstracts\Placement;
use AdvancedAds\Utilities\WordPress;
defined( 'ABSPATH' ) || exit;
/**
* Placements Repository.
*/
class Placement_Repository {
/* CRUD Methods ------------------- */
/**
* Create a new placement in the database.
*
* @param Placement $placement Placement object.
*
* @return Placement
*/
public function create( &$placement ): Placement {
$id = wp_insert_post(
apply_filters(
'advanced-ads-new-placement-data',
[
'post_type' => Constants::POST_TYPE_PLACEMENT,
'post_name' => $placement->get_slug(),
'post_status' => $placement->get_status() ? $placement->get_status() : 'publish',
'post_author' => get_current_user_id(),
'post_title' => $placement->get_title() ? $placement->get_title() : __( 'New Placement', 'advanced-ads' ),
'post_content' => $placement->get_content() ? $placement->get_content() : __( 'New placement content goes here', 'advanced-ads' ),
'comment_status' => 'closed',
'ping_status' => 'closed',
]
),
true
);
if ( $id && ! is_wp_error( $id ) ) {
$placement->set_id( $id );
$this->update_post_meta( $placement );
$placement->apply_changes();
}
return $placement;
}
/**
* Read a placement from the database.
*
* @param Placement $placement Placement object.
*
* @throws Exception If invalid placement.
*
* @return void
*/
public function read( &$placement ): void {
$placement->set_defaults();
$post_object = get_post( $placement->get_id() );
if ( ! $placement->get_id() || ! $post_object || Constants::POST_TYPE_PLACEMENT !== $post_object->post_type ) {
throw new Exception( esc_html__( 'Invalid placement.', 'advanced-ads' ) );
}
$placement->set_props(
[
'title' => $post_object->post_title,
'slug' => $post_object->post_name,
'status' => $post_object->post_status,
'content' => $post_object->post_content,
]
);
$this->read_placement_data( $placement );
$placement->set_object_read( true );
}
/**
* Update an existing placement in the database.
*
* @param Placement $placement Placement object.
*
* @return void
*/
public function update( &$placement ): void {
global $wpdb;
$changes = $placement->get_changes();
// Only update the post when the post data changes.
if ( array_intersect( [ 'title', 'status', 'content' ], array_keys( $changes ) ) ) {
$post_data = [
'post_title' => $placement->get_title( 'edit' ),
'post_status' => $placement->get_status( 'edit' ) ? $placement->get_status( 'edit' ) : 'publish',
'post_type' => Constants::POST_TYPE_PLACEMENT,
'post_content' => wp_unslash(
apply_filters(
'content_save_pre',
$placement->get_content( 'edit' )
)
),
];
/**
* When updating this object, to prevent infinite loops, use $wpdb
* to update data, since wp_update_post spawns more calls to the
* save_post action.
*
* This ensures hooks are fired by either WP itself (admin screen save),
* or an update purely from CRUD.
*/
if ( doing_action( 'save_post' ) ) {
$GLOBALS['wpdb']->update( $GLOBALS['wpdb']->posts, $post_data, [ 'ID' => $placement->get_id() ] );
clean_post_cache( $placement->get_id() );
} else {
wp_update_post( array_merge( [ 'ID' => $placement->get_id() ], $post_data ) );
}
} else { // Only update post modified time to record this save event.
$wpdb->update( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
$wpdb->posts,
[
'post_modified' => current_time( 'mysql' ),
'post_modified_gmt' => current_time( 'mysql', 1 ),
],
[
'ID' => $placement->get_id(),
]
);
clean_post_cache( $placement->get_id() );
}
$this->update_post_meta( $placement );
$placement->apply_changes();
}
/**
* Delete an placement from the database.
*
* @param Placement $placement Placement object or id.
* @param bool $force_delete Whether to bypass Trash and force deletion. Default false.
*
* @return void
*/
public function delete( &$placement, $force_delete = false ): void {
// Early bail!!
if ( ! $placement || ! $placement->get_id() ) {
return;
}
if ( $force_delete ) {
wp_delete_post( $placement->get_id(), true );
$placement->set_id( 0 );
} else {
wp_trash_post( $placement->get_id() );
$placement->set_status( 'trash' );
}
}
/* Finder Methods ------------------- */
/**
* Find placement by item id.
*
* Example: Find all placements that are connected to a specific ad.
* In this case $item_id = "ad_1234"
*
* Example: Find all placements that are connected to a specific group.
* In this case $item_id = "group_1234"
*
* @param string $item_id Item id to search for.
*
* @return Placement[]
*/
public function find_by_item_id( $item_id ): array {
$query = new WP_Query(
WordPress::improve_wp_query(
[
'post_type' => Constants::POST_TYPE_PLACEMENT,
'posts_per_page' => -1,
'fields' => 'ids',
'post_status' => 'any',
'meta_query' => [ // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
[
'key' => 'item',
'value' => $item_id,
],
],
]
)
);
$placements = [];
$placement_ids = $query->have_posts() ? $query->posts : [];
foreach ( $placement_ids as $id ) {
$placements[ $id ] = wp_advads_get_placement_by_id( $id );
}
return $placements;
}
/**
* Retrieves placements by type.
*
* This method queries the database to retrieve placements based on their type.
*
* @param string|array $types Placement types to query.
* @param string $output The required return type. One of OBJECT or ids,
* which correspond to an Placement object or an array containing post ids respectively.
*
* @return array An associative array of placement IDs as keys and their corresponding placement objects as values.
*/
public function find_by_types( $types, $output = OBJECT ): array {
$query = new WP_Query(
WordPress::improve_wp_query(
[
'post_type' => Constants::POST_TYPE_PLACEMENT,
'posts_per_page' => -1,
'fields' => 'ids',
'post_status' => 'any',
'meta_query' => [ // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
[
'key' => 'type',
'compare' => 'IN',
'value' => (array) $types,
],
],
]
)
);
$placements = [];
$placement_ids = $query->have_posts() ? $query->posts : [];
if ( 'ids' === $output ) {
return $placement_ids;
}
foreach ( $placement_ids as $id ) {
$placements[ $id ] = wp_advads_get_placement_by_id( $id );
}
return $placements;
}
/**
* Get array of all placements.
*
* @return Placement[]
*/
public function get_all_placements(): array {
static $placements;
if ( null === $placements ) {
$placements = [];
foreach ( $this->get_placements_dropdown() as $id => $placement ) {
$placement_object = wp_advads_get_placement( $id );
if ( false !== $placement_object ) {
$placements[ $id ] = $placement_object;
}
}
}
return $placements;
}
/**
* Get array of all published placements.
*
* @return Placement[]
*/
public function get_all_published(): array {
static $placements;
if ( null === $placements ) {
$placements = [];
foreach ( $this->get_published_ids() as $id ) {
$placement_object = wp_advads_get_placement( $id );
if ( false !== $placement_object ) {
$placements[ $id ] = $placement_object;
}
}
}
return $placements;
}
/**
* Get all placement as ID => Post Title pair.
*
* @return array<int, string>
*/
public function get_placements_dropdown(): array {
static $placement_dropdown;
if ( null === $placement_dropdown ) {
$query = new WP_Query(
WordPress::improve_wp_query(
[
'post_type' => Constants::POST_TYPE_PLACEMENT,
'posts_per_page' => -1,
'post_status' => 'any',
]
)
);
$placement_dropdown = $query->have_posts() ? wp_list_pluck( $query->posts, 'post_title', 'ID' ) : [];
}
return $placement_dropdown;
}
/**
* Get array of all published placements ids.
*
* @return int[]
*/
public function get_published_ids(): array {
static $placement_dropdown;
if ( null === $placement_dropdown ) {
$query = new WP_Query(
WordPress::improve_wp_query(
[
'post_type' => Constants::POST_TYPE_PLACEMENT,
'posts_per_page' => -1,
'post_status' => 'publish',
'fields' => 'ids',
]
)
);
$placement_dropdown = $query->have_posts() ? $query->posts : [];
}
return $placement_dropdown;
}
/* Additional Methods ------------------- */
/**
* Read placement data. Can be overridden by child classes to load other props.
*
* @param Ad $placement Ad object.
*
* @return void
*/
private function read_placement_data( &$placement ): void {
$item = get_post_meta( $placement->get_id(), 'item', true );
$options = get_post_meta( $placement->get_id(), 'options', true );
$type = get_post_meta( $placement->get_id(), 'type', true );
if ( empty( $options ) || ! is_array( $options ) ) {
$options = [];
}
$display_conditions = $options['display'] ?? [];
$visitor_conditions = $options['visitors'] ?? [];
unset( $options['display'], $options['visitors'] );
$placement->set_item( $item );
$placement->set_type( $type ?? 'default' );
$placement->set_props( $options );
$placement->set_display_conditions( $display_conditions );
$placement->set_visitor_conditions( $visitor_conditions );
}
/**
* Update placement data. Can be overridden by child classes to load other props.
*
* @param Placement $placement Placement object.
*
* @return void
*/
private function update_post_meta( &$placement ): void {
do_action( 'advanced-ads-placement-pre-save', $placement );
$meta_keys = $placement->get_data_keys();
$meta_keys = array_combine( $meta_keys, $meta_keys );
$meta_values = [];
foreach ( $meta_keys as $meta_key => $prop ) {
$value = method_exists( $placement, "get_$prop" )
? $placement->{"get_$prop"}( 'edit' )
: $placement->get_prop( $prop, 'edit' );
$value = is_string( $value ) ? wp_slash( $value ) : $value;
switch ( $prop ) {
case 'display':
case 'visitors':
$value = WordPress::sanitize_conditions( $value );
break;
}
$meta_values[ $meta_key ] = $value;
}
$meta_values = array_diff_key(
$meta_values,
[
'type' => true,
'slug' => true,
'item' => true,
]
);
update_post_meta( $placement->get_id(), 'item', $placement->get_item() );
update_post_meta( $placement->get_id(), 'type', $placement->get_type() );
update_post_meta( $placement->get_id(), 'options', $meta_values );
}
}

View File

@@ -0,0 +1,21 @@
<?php
/**
* This class represents the "Sidebar Widget" placement.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
* @since 1.47.0
*/
namespace AdvancedAds\Placements;
use AdvancedAds\Abstracts\Placement;
use AdvancedAds\Interfaces\Placement_Interface;
defined( 'ABSPATH' ) || exit;
/**
* Sidebar Widget.
*/
class Placement_Sidebar_Widget extends Placement implements Placement_Interface {
}

View File

@@ -0,0 +1,21 @@
<?php
/**
* This class represents the "Standard" placement.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
* @since 1.47.0
*/
namespace AdvancedAds\Placements;
use AdvancedAds\Abstracts\Placement;
use AdvancedAds\Interfaces\Placement_Interface;
defined( 'ABSPATH' ) || exit;
/**
* Standard.
*/
class Placement_Standard extends Placement implements Placement_Interface {
}

View File

@@ -0,0 +1,99 @@
<?php
/**
* Placements types manager..
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
* @since 1.47.0
*/
namespace AdvancedAds\Placements;
use AdvancedAds\Abstracts\Types;
use AdvancedAds\Placements\Types\Footer;
use AdvancedAds\Placements\Types\Header;
use AdvancedAds\Placements\Types\Content;
use AdvancedAds\Placements\Types\Unknown;
use AdvancedAds\Interfaces\Placement_Type;
use AdvancedAds\Placements\Types\Standard;
use AdvancedAds\Placements\Types\After_Content;
use AdvancedAds\Placements\Types\Before_Content;
use AdvancedAds\Placements\Types\Sidebar_Widget;
defined( 'ABSPATH' ) || exit;
/**
* Placements Types.
*/
class Placement_Types extends Types {
/**
* Hook to filter types.
*
* @var string
*/
protected $hook = 'advanced-ads-placement-types';
/**
* Class for unknown type.
*
* @var string
*/
protected $type_unknown = Unknown::class;
/**
* Type interface to check.
*
* @var string
*/
protected $type_interface = Placement_Type::class;
/**
* Register default types.
*
* @return void
*/
protected function register_default_types(): void {
$this->register_type( After_Content::class );
$this->register_type( Before_Content::class );
$this->register_type( Content::class );
$this->register_type( Footer::class );
$this->register_type( Header::class );
$this->register_type( Sidebar_Widget::class );
$this->register_type( Standard::class );
}
/**
* Get type order weight
*
* @return array
*/
public function get_order_list(): array {
$orders = [];
foreach ( $this->get_types() as $type ) {
$orders[ $type->get_id() ] = $type->get_order();
}
asort( $orders );
return $orders;
}
/**
* Get type dropdown options
*
* @return array
*/
public function get_dropdown_options(): array {
$options = [];
foreach ( $this->get_types() as $type ) {
$options[ $type->get_id() ] = $type->get_title();
}
asort( $options );
return $options;
}
}

View File

@@ -0,0 +1,54 @@
<?php
/**
* This class is responsible to hold all the Placements functionality.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
* @since 1.47.0
*/
namespace AdvancedAds\Placements;
use AdvancedAds\Framework\Interfaces\Initializer_Interface;
defined( 'ABSPATH' ) || exit;
/**
* Placements.
*/
class Placements implements Initializer_Interface {
/**
* Hold factory instance
*
* @var Placement_Factory
*/
public $factory = null;
/**
* Hold repository instance
*
* @var Placement_Repository
*/
public $repository = null;
/**
* Hold types manager
*
* @var Placement_Types
*/
public $types = null;
/**
* Runs this initializer.
*
* @return void
*/
public function initialize(): void {
$this->factory = new Placement_Factory();
$this->types = new Placement_Types();
$this->repository = new Placement_Repository();
$this->types->hooks();
}
}

View File

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

View File

@@ -0,0 +1,101 @@
<?php
/**
* This class represents the "After Content" placement type.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
* @since 1.47.0
*/
namespace AdvancedAds\Placements\Types;
use AdvancedAds\Abstracts\Placement_Type as Base;
use AdvancedAds\Interfaces\Placement_Type;
use AdvancedAds\Placements\Placement_After_Content;
defined( 'ABSPATH' ) || exit;
/**
* Type After Content.
*/
class After_Content extends Base implements Placement_Type {
/**
* Get the unique identifier (ID) of the placement type.
*
* @return string The unique ID of the placement type.
*/
public function get_id(): string {
return 'post_bottom';
}
/**
* Get the class name of the object as a string.
*
* @return string
*/
public function get_classname(): string {
return Placement_After_Content::class;
}
/**
* Get the title or name of the placement type.
*
* @return string The title of the placement type.
*/
public function get_title(): string {
return __( 'After Content', 'advanced-ads' );
}
/**
* Get a description of the placement type.
*
* @return string The description of the placement type.
*/
public function get_description(): string {
return __( 'Injected after the post content.', 'advanced-ads' );
}
/**
* Check if this placement type requires premium.
*
* @return bool True if premium is required; otherwise, false.
*/
public function is_premium(): bool {
return false;
}
/**
* Get the URL for upgrading to this placement type.
*
* @return string The upgrade URL for the placement type.
*/
public function get_image(): string {
return ADVADS_BASE_URL . 'admin/assets/img/placements/content-after.png';
}
/**
* Get order number for this placement type.
*
* @return int The order number.
*/
public function get_order(): int {
return 15;
}
/**
* Get options for this placement type.
*
* @return array The options array.
*/
public function get_options(): array {
return $this->apply_filter_on_options(
[
'show_position' => true,
'show_lazy_load' => true,
'uses_the_content' => true,
'amp' => true,
]
);
}
}

View File

@@ -0,0 +1,101 @@
<?php
/**
* This class represents the "Before Content" placement type.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
* @since 1.47.0
*/
namespace AdvancedAds\Placements\Types;
use AdvancedAds\Abstracts\Placement_Type as Base;
use AdvancedAds\Interfaces\Placement_Type;
use AdvancedAds\Placements\Placement_Before_Content;
defined( 'ABSPATH' ) || exit;
/**
* Type Before Content.
*/
class Before_Content extends Base implements Placement_Type {
/**
* Get the unique identifier (ID) of the placement type.
*
* @return string The unique ID of the placement type.
*/
public function get_id(): string {
return 'post_top';
}
/**
* Get the class name of the object as a string.
*
* @return string
*/
public function get_classname(): string {
return Placement_Before_Content::class;
}
/**
* Get the title or name of the placement type.
*
* @return string The title of the placement type.
*/
public function get_title(): string {
return __( 'Before Content', 'advanced-ads' );
}
/**
* Get a description of the placement type.
*
* @return string The description of the placement type.
*/
public function get_description(): string {
return __( 'Injected before the post content.', 'advanced-ads' );
}
/**
* Check if this placement type requires premium.
*
* @return bool True if premium is required; otherwise, false.
*/
public function is_premium(): bool {
return false;
}
/**
* Get the URL for upgrading to this placement type.
*
* @return string The upgrade URL for the placement type.
*/
public function get_image(): string {
return ADVADS_BASE_URL . 'admin/assets/img/placements/content-before.png';
}
/**
* Get order number for this placement type.
*
* @return int The order number.
*/
public function get_order(): int {
return 5;
}
/**
* Get options for this placement type.
*
* @return array The options array.
*/
public function get_options(): array {
return $this->apply_filter_on_options(
[
'show_position' => true,
'show_lazy_load' => true,
'uses_the_content' => true,
'amp' => true,
]
);
}
}

View File

@@ -0,0 +1,101 @@
<?php
/**
* This class represents the "Content" placement type.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
* @since 1.47.0
*/
namespace AdvancedAds\Placements\Types;
use AdvancedAds\Abstracts\Placement_Type as Base;
use AdvancedAds\Interfaces\Placement_Type;
use AdvancedAds\Placements\Placement_Content;
defined( 'ABSPATH' ) || exit;
/**
* Type Content.
*/
class Content extends Base implements Placement_Type {
/**
* Get the unique identifier (ID) of the placement type.
*
* @return string The unique ID of the placement type.
*/
public function get_id(): string {
return 'post_content';
}
/**
* Get the class name of the object as a string.
*
* @return string
*/
public function get_classname(): string {
return Placement_Content::class;
}
/**
* Get the title or name of the placement type.
*
* @return string The title of the placement type.
*/
public function get_title(): string {
return __( 'Content', 'advanced-ads' );
}
/**
* Get a description of the placement type.
*
* @return string The description of the placement type.
*/
public function get_description(): string {
return __( 'Injected into the content. You can choose the paragraph after which the ad content is displayed.', 'advanced-ads' );
}
/**
* Check if this placement type requires premium.
*
* @return bool True if premium is required; otherwise, false.
*/
public function is_premium(): bool {
return false;
}
/**
* Get the URL for upgrading to this placement type.
*
* @return string The upgrade URL for the placement type.
*/
public function get_image(): string {
return ADVADS_BASE_URL . 'admin/assets/img/placements/content-within.png';
}
/**
* Get order number for this placement type.
*
* @return int The order number.
*/
public function get_order(): int {
return 10;
}
/**
* Get options for this placement type.
*
* @return array The options array.
*/
public function get_options(): array {
return $this->apply_filter_on_options(
[
'show_position' => true,
'show_lazy_load' => true,
'uses_the_content' => true,
'amp' => true,
]
);
}
}

View File

@@ -0,0 +1,94 @@
<?php
/**
* This class represents the "Footer" placement type.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
* @since 1.47.0
*/
namespace AdvancedAds\Placements\Types;
use AdvancedAds\Abstracts\Placement_Type as Base;
use AdvancedAds\Interfaces\Placement_Type;
use AdvancedAds\Placements\Placement_Footer;
defined( 'ABSPATH' ) || exit;
/**
* Type Footer.
*/
class Footer extends Base implements Placement_Type {
/**
* Get the unique identifier (ID) of the placement type.
*
* @return string The unique ID of the placement type.
*/
public function get_id(): string {
return 'footer';
}
/**
* Get the class name of the object as a string.
*
* @return string
*/
public function get_classname(): string {
return Placement_Footer::class;
}
/**
* Get the title or name of the placement type.
*
* @return string The title of the placement type.
*/
public function get_title(): string {
return __( 'Footer Code', 'advanced-ads' );
}
/**
* Get a description of the placement type.
*
* @return string The description of the placement type.
*/
public function get_description(): string {
return __( 'Injected in Footer (before closing &lt;/body&gt; Tag).', 'advanced-ads' );
}
/**
* Check if this placement type requires premium.
*
* @return bool True if premium is required; otherwise, false.
*/
public function is_premium(): bool {
return false;
}
/**
* Get the URL for upgrading to this placement type.
*
* @return string The upgrade URL for the placement type.
*/
public function get_image(): string {
return ADVADS_BASE_URL . 'admin/assets/img/placements/footer.png';
}
/**
* Get order number for this placement type.
*
* @return int The order number.
*/
public function get_order(): int {
return 35;
}
/**
* Get options for this placement type.
*
* @return array The options array.
*/
public function get_options(): array {
return $this->apply_filter_on_options( [ 'amp' => true ] );
}
}

View File

@@ -0,0 +1,94 @@
<?php
/**
* This class represents the "Header" placement type.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
* @since 1.47.0
*/
namespace AdvancedAds\Placements\Types;
use AdvancedAds\Abstracts\Placement_Type as Base;
use AdvancedAds\Interfaces\Placement_Type;
use AdvancedAds\Placements\Placement_Header;
defined( 'ABSPATH' ) || exit;
/**
* Type Header.
*/
class Header extends Base implements Placement_Type {
/**
* Get the unique identifier (ID) of the placement type.
*
* @return string The unique ID of the placement type.
*/
public function get_id(): string {
return 'header';
}
/**
* Get the class name of the object as a string.
*
* @return string
*/
public function get_classname(): string {
return Placement_Header::class;
}
/**
* Get the title or name of the placement type.
*
* @return string The title of the placement type.
*/
public function get_title(): string {
return __( 'Header Code', 'advanced-ads' );
}
/**
* Get a description of the placement type.
*
* @return string The description of the placement type.
*/
public function get_description(): string {
return __( 'Injected in Header (before closing &lt;/head&gt; Tag, often not visible).', 'advanced-ads' );
}
/**
* Check if this placement type requires premium.
*
* @return bool True if premium is required; otherwise, false.
*/
public function is_premium(): bool {
return false;
}
/**
* Get the URL for upgrading to this placement type.
*
* @return string The upgrade URL for the placement type.
*/
public function get_image(): string {
return ADVADS_BASE_URL . 'admin/assets/img/placements/header.png';
}
/**
* Get order number for this placement type.
*
* @return int The order number.
*/
public function get_order(): int {
return 30;
}
/**
* Get options for this placement type.
*
* @return array The options array.
*/
public function get_options(): array {
return $this->apply_filter_on_options( [] );
}
}

View File

@@ -0,0 +1,100 @@
<?php
/**
* This class represents the "Sidebar Widget" placement type.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
* @since 1.47.0
*/
namespace AdvancedAds\Placements\Types;
use AdvancedAds\Abstracts\Placement_Type as Base;
use AdvancedAds\Interfaces\Placement_Type;
use AdvancedAds\Placements\Placement_Sidebar_Widget;
defined( 'ABSPATH' ) || exit;
/**
* Type Sidebar Widget.
*/
class Sidebar_Widget extends Base implements Placement_Type {
/**
* Get the unique identifier (ID) of the placement type.
*
* @return string The unique ID of the placement type.
*/
public function get_id(): string {
return 'sidebar_widget';
}
/**
* Get the class name of the object as a string.
*
* @return string
*/
public function get_classname(): string {
return Placement_Sidebar_Widget::class;
}
/**
* Get the title or name of the placement type.
*
* @return string The title of the placement type.
*/
public function get_title(): string {
return __( 'Sidebar Widget', 'advanced-ads' );
}
/**
* Get a description of the placement type.
*
* @return string The description of the placement type.
*/
public function get_description(): string {
return __( 'Create a sidebar widget with an ad. Can be placed and used like any other widget.', 'advanced-ads' );
}
/**
* Check if this placement type requires premium.
*
* @return bool True if premium is required; otherwise, false.
*/
public function is_premium(): bool {
return false;
}
/**
* Get the URL for upgrading to this placement type.
*
* @return string The upgrade URL for the placement type.
*/
public function get_image(): string {
return ADVADS_BASE_URL . 'admin/assets/img/placements/widget.png';
}
/**
* Get order number for this placement type.
*
* @return int The order number.
*/
public function get_order(): int {
return 20;
}
/**
* Get options for this placement type.
*
* @return array The options array.
*/
public function get_options(): array {
return $this->apply_filter_on_options(
[
'show_position' => true,
'show_lazy_load' => true,
'amp' => true,
]
);
}
}

View File

@@ -0,0 +1,100 @@
<?php
/**
* This class represents the "Standard" placement type.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
* @since 1.47.0
*/
namespace AdvancedAds\Placements\Types;
use AdvancedAds\Abstracts\Placement_Type as Base;
use AdvancedAds\Interfaces\Placement_Type;
use AdvancedAds\Placements\Placement_Standard;
defined( 'ABSPATH' ) || exit;
/**
* Type Standard.
*/
class Standard extends Base implements Placement_Type {
/**
* Get the unique identifier (ID) of the placement type.
*
* @return string The unique ID of the placement type.
*/
public function get_id(): string {
return 'default';
}
/**
* Get the class name of the object as a string.
*
* @return string
*/
public function get_classname(): string {
return Placement_Standard::class;
}
/**
* Get the title or name of the placement type.
*
* @return string The title of the placement type.
*/
public function get_title(): string {
return __( 'Manual Placement', 'advanced-ads' );
}
/**
* Get a description of the placement type.
*
* @return string The description of the placement type.
*/
public function get_description(): string {
return __( 'Manual placement to use as function or shortcode.', 'advanced-ads' );
}
/**
* Check if this placement type requires premium.
*
* @return bool True if premium is required; otherwise, false.
*/
public function is_premium(): bool {
return false;
}
/**
* Get the URL for upgrading to this placement type.
*
* @return string The upgrade URL for the placement type.
*/
public function get_image(): string {
return ADVADS_BASE_URL . 'admin/assets/img/placements/manual.png';
}
/**
* Get order number for this placement type.
*
* @return int The order number.
*/
public function get_order(): int {
return 25;
}
/**
* Get options for this placement type.
*
* @return array The options array.
*/
public function get_options(): array {
return $this->apply_filter_on_options(
[
'show_position' => true,
'show_lazy_load' => true,
'amp' => true,
]
);
}
}

View File

@@ -0,0 +1,112 @@
<?php
/**
* This class represents the "Unknown" placement type.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
* @since 1.47.0
*/
namespace AdvancedAds\Placements\Types;
use AdvancedAds\Abstracts\Placement_Type as Base;
use AdvancedAds\Interfaces\Placement_Type;
use AdvancedAds\Placements\Placement_Standard;
defined( 'ABSPATH' ) || exit;
/**
* Placements Types Unknown.
*/
class Unknown extends Base implements Placement_Type {
/**
* Hold type data.
*
* @var array
*/
private $data = [];
/**
* The constructor.
*
* @param array $data Array of type data.
*/
public function __construct( array $data ) {
$this->data = $data;
}
/**
* Get the unique identifier (ID) of the placement type.
*
* @return string The unique ID of the placement type.
*/
public function get_id(): string {
return $this->data['id'] ?? 'default';
}
/**
* Get the class name of the object as a string.
*
* @return string
*/
public function get_classname(): string {
return $this->data['classname'] ?? Placement_Standard::class;
}
/**
* Get the title or name of the placement type.
*
* @return string The title of the placement type.
*/
public function get_title(): string {
return $this->data['title'] ?? __( 'Unknown type', 'advanced-ads' );
}
/**
* Get a description of the placement type.
*
* @return string The description of the placement type.
*/
public function get_description(): string {
return $this->data['description'] ?? __( 'No description', 'advanced-ads' );
}
/**
* Check if this placement type requires premium.
*
* @return bool True if premium is required; otherwise, false.
*/
public function is_premium(): bool {
return boolval( $this->data['is_premium'] ?? true );
}
/**
* Get order number for this placement type.
*
* @return int The order number.
*/
public function get_order(): int {
return $this->data['order'] ?? 100;
}
/**
* Get options for this placement type.
*
* @return array The options array.
*/
public function get_options(): array {
return $this->apply_filter_on_options( $this->data['options'] ?? [] );
}
/**
* Get the URL for upgrading to this placement type.
*
* @return string The upgrade URL for the placement type.
*/
public function get_image(): string {
$fallback = ADVADS_BASE_URL . 'admin/assets/img/placements/manual.png';
return $this->data['image'] ?? $fallback;
}
}