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,14 @@
<?php
/**
* Module backend main file
*
* @package AdvancedAds\Pro\Modules\BuddyPress
* @author Advanced Ads <info@wpadvancedads.com>
*/
// Stop if BuddyPress isn't activated.
if ( ! class_exists( 'BuddyPress', false ) ) {
return;
}
( new AdvancedAds\Pro\Modules\BuddyPress\Admin() )->hooks();

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -0,0 +1,25 @@
/**
* Renders a html field corresponding to the currently selected field type.
*/
jQuery( document ).on( 'change', '.advads-pro-buddyboss-xprofile-field-type', function() {
const $self = jQuery( this ),
$loading = jQuery( '<span class="advads-loader"></span>' );
// Replace the dynamic field with the loader.
$self.parent().nextAll( '.advanced-ads-buddyboss-xprofile-dynamic-field' ).replaceWith( $loading );
jQuery.ajax( {
type: 'POST',
url: ajaxurl,
data: {
action: 'advads-pro-buddyboss-render-xprofile-field',
field_name: $self.data( 'field-name' ),
field_type: $self.find( 'option:selected' ).data( 'field-type' ),
nonce: advadsglobal.ajax_nonce
},
} ).done( function ( data ) {
$loading.replaceWith( data );
} ).fail( function ( jqXHR, textStatus, errorThrown ) {
$loading.replaceWith( textStatus + ': ' + errorThrown );
} );
} );

View File

@@ -0,0 +1,156 @@
<?php
/**
* BuddyPress module admin
*
* @package AdvancedAds\Pro\Modules\BuddyPress
* @author Advanced Ads <info@wpadvancedads.com>
*/
namespace AdvancedAds\Pro\Modules\BuddyPress;
use AdvancedAds\Abstracts\Placement;
use AdvancedAds\Utilities\Conditional;
use AdvancedAds\Framework\Utilities\Params;
use AdvancedAds\Framework\Interfaces\Integration_Interface;
defined( 'ABSPATH' ) || exit;
/**
* Class Admin
*/
class Admin implements Integration_Interface {
/**
* Hook into WordPress.
*
* @return void
*/
public function hooks(): void {
add_action( 'advanced-ads-placement-options-after', [ $this, 'placement_options' ], 10, 2 );
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_admin_scripts' ] );
add_action( 'wp_ajax_advads-pro-buddyboss-render-xprofile-field', [ $this, 'render_xprofile_field_ajax' ] );
}
/**
* Register options for the BuddyPress placement
*
* @param string $slug placement slug.
* @param Placement $placement the placement.
*
* @return void
*/
public function placement_options( $slug, $placement ) {
if ( $placement->is_type( 'buddypress' ) ) {
$placement_options = $placement->get_data();
$buddypress_positions = $this->get_buddypress_hooks();
$current = BuddyPress::get_hook_from_placement_options( $placement );
$activity_type = $placement_options['activity_type'] ?? 'any';
$hook_repeat = ! empty( $placement_options['hook_repeat'] );
$index = ( isset( $placement_options['pro_buddypress_pages_index'] ) ) ? \Advanced_Ads_Pro_Utils::absint( $placement_options['pro_buddypress_pages_index'], 1 ) : 1;
require AA_PRO_ABSPATH . 'modules/buddypress/views/position-option.php';
}
}
/**
* Load the hooks relevant for BuddyPress/BuddyBoss
*
* @return array list of hooks for BuddyPress depending on the BP theme
*/
public function get_buddypress_hooks() {
if ( ! BuddyPress::is_legacy_theme() ) {
return [
__( 'Activity Entry', 'advanced-ads-pro' ) => [
'bp_after_activity_entry' => 'after activity entry',
],
];
}
// Return legacy hooks.
return [
__( 'Activity Entry', 'advanced-ads-pro' ) => [
'bp_before_activity_entry' => 'before activity entry',
'bp_activity_entry_content' => 'activity entry content',
'bp_after_activity_entry' => 'after activity entry',
'bp_before_activity_entry_comments' => 'before activity entry comments',
'bp_activity_entry_comments' => 'activity entry comments',
'bp_after_activity_entry_comments' => 'after activity entry comments',
],
__( 'Group List', 'advanced-ads-pro' ) => [
'bp_directory_groups_item' => 'directory groups item',
],
__( 'Member List', 'advanced-ads-pro' ) => [
'bp_directory_members_item' => 'directory members item',
],
];
}
/**
* Enqueue admin scripts.
*/
public function enqueue_admin_scripts() {
if ( ! Conditional::is_screen_advanced_ads() ) {
return;
}
wp_enqueue_script( 'advanced-ads-pro/buddyboss-admin', plugin_dir_url( __FILE__ ) . 'assets/js/admin.js', [ 'jquery' ], AAP_VERSION, true );
}
/**
* Renders a html field corresponding to the currently selected field type.
*/
public function render_xprofile_field_ajax() {
check_ajax_referer( 'advanced-ads-admin-ajax-nonce', 'nonce' );
$field_name = Params::post( 'field_name' );
$field_type = Params::post( 'field_type' );
if (
! Conditional::user_can( 'advanced_ads_edit_ads' )
|| ! $field_name || ! $field_type
) {
die;
}
self::render_xprofile_field(
preg_replace( '/[^a-z0-9\[\]]/', '', $field_name ),
preg_replace( '/[^a-z0-9]/', '', $field_type ),
''
);
die;
}
/**
* Renders a html field corresponding to the currently selected field type.
*
* @param string $name Field name.
* @param string $field_type type Field type.
* @param string $value Field value.
*/
public static function render_xprofile_field( $name, $field_type, $value = '' ) {
if ( function_exists( 'bp_get_active_member_types' ) && BuddyPress::FIELD_MEMBERTYPES === $field_type ) {
$bp_active_member_types = \bp_get_active_member_types();
if ( ! empty( $bp_active_member_types ) ) {
printf(
'<select name="%s[value]" class="advanced-ads-buddyboss-xprofile-dynamic-field">',
esc_attr( $name )
);
foreach ( $bp_active_member_types as $bp_active_member_type ) {
printf(
'<option value="%s"%s>%s</option>',
esc_attr( $bp_active_member_type ),
selected( $bp_active_member_type, (int) $value, false ),
esc_attr( get_post_meta( $bp_active_member_type, '_bp_member_type_label_singular_name', true ) )
);
}
echo '</select>';
}
} else {
printf(
'<input type="text" name="%s[value]" value="%s" class="advanced-ads-buddyboss-xprofile-dynamic-field">',
esc_attr( $name ),
esc_attr( $value )
);
}
}
}

View File

@@ -0,0 +1,481 @@
<?php
/**
* BuddyPress module
*
* @package AdvancedAds\Pro\Modules\BuddyPress
* @author Advanced Ads <info@wpadvancedads.com>
*/
namespace AdvancedAds\Pro\Modules\BuddyPress;
use AdvancedAds\Abstracts\Placement;
use AdvancedAds\Framework\Interfaces\Integration_Interface;
defined( 'ABSPATH' ) || exit;
/**
* Class BuddyPress
*/
class BuddyPress implements Integration_Interface {
/**
* Member Types xprofile field type.
*/
const FIELD_MEMBERTYPES = 'membertypes';
/**
* Textbox xprofile field type.
*/
const FIELD_TEXTBOX = 'textbox';
/**
* Hook into WordPress.
*
* @return void
*/
public function hooks(): void {
add_action( 'init', [ $this, 'init' ], 31 );
add_filter( 'advanced-ads-visitor-conditions', [ $this, 'visitor_conditions' ] );
add_filter( 'advanced-ads-display-conditions', [ $this, 'display_conditions' ] );
}
/**
* Get all placements
*
* @return Placement[]
*/
private function get_all_placements() {
static $placements;
if ( null !== $placements ) {
return $placements;
}
$placements = wp_advads_get_all_placements();
return $placements;
}
/**
* Register relevant hooks
*/
public function init() {
$placements = $this->get_all_placements();
foreach ( $placements as $placement ) {
if ( ! $placement->is_type( 'buddypress' ) ) {
continue;
}
$hook = self::get_hook_from_placement_options( $placement );
add_action( $hook, [ $this, 'execute_hook' ] );
}
}
/**
* Execute frontend hooks
*/
public function execute_hook() {
$placements = $this->get_all_placements();
// Look for the current hook in the placements.
$hook = current_filter();
foreach ( $placements as $id => $placement ) {
$hook_from_option = self::get_hook_from_placement_options( $placement );
if ( ! $placement->is_type( 'buddypress' ) || $hook !== $hook_from_option ) {
continue;
}
$index = Max( 1, (int) $placement->get_prop( 'pro_buddypress_pages_index' ) );
$did_action = did_action( $hook );
if ( $did_action !== $index && ( $placement->get_prop( 'hook_repeat' ) || 0 !== $did_action % $index ) ) {
continue;
}
if ( ! self::is_legacy_theme() && $placement->get_prop( 'activity_type' ) && ! $this->is_activity_type( $placement->get_prop( 'activity_type' ) ) ) {
continue;
}
the_ad_placement( $id );
}
}
/**
* Add visitor condition for BuddyPress profile fields
*
* @param array $conditions visitor conditions of the main plugin.
*
* @return array $conditions new global visitor conditions
*/
public function visitor_conditions( $conditions ) {
// Stop if BuddyPress isn't activated.
if ( ! class_exists( 'BuddyPress', false ) || ! function_exists( 'bp_profile_get_field_groups' ) ) {
return $conditions;
}
$conditions['buddypress_profile_field'] = [
'label' => __( 'BuddyPress profile field', 'advanced-ads-pro' ),
'description' => __( 'Display ads based on BuddyPress profile fields.', 'advanced-ads-pro' ),
'metabox' => [ self::class, 'xprofile_metabox' ],
'check' => [ self::class, 'check_xprofile' ],
'passive_info' => [
'hash_fields' => 'field',
'remove' => 'login',
'function' => [ self::class, 'get_passive' ],
],
];
// Update condition labels when BuddyBoss is used.
if ( self::is_buddyboss() ) {
$conditions['buddypress_profile_field']['label'] = __( 'BuddyBoss profile field', 'advanced-ads-pro' );
$conditions['buddypress_profile_field']['description'] = __( 'Display ads based on BuddyBoss profile fields.', 'advanced-ads-pro' );
}
return $conditions;
}
/**
* Frontend check for the xprofile condition
*
* @param array $options condition options.
*
* @return bool
*/
public static function check_xprofile( $options = [] ) {
if ( ! isset( $options['operator'] ) || ! isset( $options['value'] ) || ! isset( $options['field'] ) ) {
return true;
}
$user_id = get_current_user_id();
$operator = $options['operator'];
$value = trim( $options['value'] );
$field = (int) $options['field'];
if ( ! $user_id ) {
return true;
}
$profile = self::get_profile_field_data( $field, $user_id );
$trimmed_options = [
'operator' => $operator,
'value' => $value,
];
if ( is_array( $profile ) ) {
// Multi fields (checkboxes, dropdowns, etc).
$positive_operator = in_array( $options['operator'], [ 'contain', 'start', 'end', 'match', 'regex' ], true );
if ( ! $profile ) {
return ! $positive_operator;
}
foreach ( $profile as $profile_item ) {
$condition = \Advanced_Ads_Visitor_Conditions::helper_check_string( $profile_item, $trimmed_options );
if (
// If operator is positive, check if at least one string returns `true`.
( $positive_operator && $condition )
// If operator is negative, check if all strings return `true`.
|| ( ! $positive_operator && ! $condition )
) {
break;
}
}
return $condition;
}
// Single fields.
return \Advanced_Ads_Visitor_Conditions::helper_check_string( $profile, $trimmed_options );
}
/**
* Get information to use in passive cache-busting.
*
* @param array $options condition options.
*/
public static function get_passive( $options = [] ) {
if ( ! isset( $options['field'] ) ) {
return;
}
$field = (int) $options['field'];
$user_id = get_current_user_id();
if ( ! $user_id ) {
return;
}
$profile = self::get_profile_field_data( $field, $user_id );
return [
'field' => $options['field'],
'data' => $profile,
];
}
/**
* Get profile field data.
*
* @param int $field Field ID.
* @param int $user_id ID of the user to get field data for.
*
* @return string[]|string
*/
private static function get_profile_field_data( $field, $user_id ) {
if (
! function_exists( 'bp_get_member_type' )
|| ! function_exists( 'bp_get_profile_field_data' )
) {
return [];
}
// Process the "membertypes" field (BuddyBoss).
if (
function_exists( 'bp_get_xprofile_member_type_field_id' )
&& \bp_get_xprofile_member_type_field_id() === $field
&& function_exists( 'bp_member_type_post_by_type' )
) {
$member_types = \bp_get_member_type( $user_id, false );
if ( ! is_array( $member_types ) ) {
return [];
}
return array_map(
function ( $member_type ) {
return \bp_member_type_post_by_type( $member_type );
},
$member_types
);
}
// Process fields other than the "membertypes".
return \bp_get_profile_field_data(
[
'field' => $field,
'user_id' => $user_id,
]
);
}
/**
* Render xprofile visitor condition option
*
* @param array $options condition options.
* @param int $index index of the option.
* @param string $form_name name of the form.
*/
public static function xprofile_metabox( $options, $index = 0, $form_name = '' ) {
if ( ! isset( $options['type'] ) || '' === $options['type'] ) {
return;
}
$type_options = \Advanced_Ads_Visitor_Conditions::get_instance()->conditions;
if ( ! isset( $type_options[ $options['type'] ] ) ) {
return;
}
$groups = \bp_profile_get_field_groups();
$name = \Advanced_Ads_Pro_Module_Advanced_Visitor_Conditions::get_form_name_with_index( $form_name, $index );
$value = isset( $options['value'] ) ? $options['value'] : '';
$field = isset( $options['field'] ) ? (int) $options['field'] : -1;
$value = $options['value'] ?? '';
$operator = $options['operator'] ?? 'is_equal';
$current_field_type = self::get_current_field_type( $field );
require AA_PRO_ABSPATH . 'modules/buddypress/views/xprofile-condition.php';
}
/**
* Get current field type.
*
* @param int $field Field ID.
*
* @return string
*/
private static function get_current_field_type( $field ) {
if ( ! function_exists( 'bp_get_xprofile_member_type_field_id' ) ) {
return self::FIELD_TEXTBOX;
}
if ( \bp_get_xprofile_member_type_field_id() === $field ) {
return self::FIELD_MEMBERTYPES;
}
$groups = \bp_profile_get_field_groups();
return $groups[0]->fields[0]->type ?? self::FIELD_TEXTBOX;
}
/**
* Add display condition for BuddyBoss groups.
*
* @param array $conditions Display conditions of the main plugin.
*
* @return array $conditions New display conditions.
*/
public function display_conditions( $conditions ) {
// Stop if BuddyBoss isn't activated.
if ( ! class_exists( 'BuddyPress', false ) || ! function_exists( 'groups_get_groups' ) ) {
return $conditions;
}
$conditions['buddypress_group'] = [
'label' => __( 'BuddyPress group', 'advanced-ads-pro' ),
'description' => __( 'Display ads based on existing BuddyPress groups.', 'advanced-ads-pro' ),
'metabox' => [ self::class, 'group_metabox' ],
'check' => [ self::class, 'group_check' ],
'options' => [
'global' => false,
],
'helplink' => 'https://wpadvancedads.com/manual/buddyboss-ads/?utm_source=advanced-ads?utm_medium=link&utm_campaign=condition-buddyboss-group',
];
if ( self::is_buddyboss() ) {
$conditions['buddypress_group']['label'] = __( 'BuddyBoss group', 'advanced-ads-pro' );
$conditions['buddypress_group']['description'] = __( 'Display ads based on existing BuddyBoss groups.', 'advanced-ads-pro' );
}
return $conditions;
}
/**
* Callback to display metabox for the BuddyBoss group condition.
*
* @param array $options Options of the condition.
* @param int $index Index of the condition.
* @param string $form_name Name of the form, falls back to class constant.
*/
public static function group_metabox( $options, $index = 0, $form_name = '' ) {
if ( ! isset( $options['type'] ) || '' === $options['type'] ) {
return;
}
$type_options = \Advanced_Ads_Display_Conditions::get_instance()->conditions;
if ( ! isset( $type_options[ $options['type'] ] ) ) {
return;
}
// Get values and select operator based on previous settings.
$operator = ( isset( $options['operator'] ) && 'is_not' === $options['operator'] ) ? 'is_not' : 'is';
$values = ( isset( $options['value'] ) && is_array( $options['value'] ) ) ? array_map( 'absint', $options['value'] ) : [];
// Form name basis.
$name = \Advanced_Ads_Display_Conditions::get_form_name_with_index( $form_name, $index );
$rand = md5( $name );
// Load operator template.
include ADVADS_ABSPATH . 'admin/views/conditions/condition-operator.php';
$groups = self::get_buddypress_group_list();
include AA_PRO_ABSPATH . 'modules/buddypress/views/display-condition-group.php';
include ADVADS_ABSPATH . 'admin/views/conditions/not-selected.php';
?>
<p class="description">
<?php esc_html_e( 'Display ads based on existing BuddyBoss groups.', 'advanced-ads-pro' ); ?>
<a href="https://wpadvancedads.com/manual/buddyboss-ads/?utm_source=advanced-ads?utm_medium=link&utm_campaign=condition-buddyboss-group" class="advads-manual-link" target="_blank">
<?php esc_html_e( 'Manual', 'advanced-ads-pro' ); ?>
</a>
</p>
</div>
<?php
}
/**
* Get the list of BuddyBoss groups.
*
* @return array.
*/
public static function get_buddypress_group_list() {
$list = [];
$groups = \groups_get_groups( [ 'per_page' => -1 ] );
if ( ! isset( $groups['groups'] ) || ! is_array( $groups['groups'] ) ) {
return $list;
}
foreach ( $groups['groups'] as $group ) {
if ( isset( $group->id, $group->name ) ) {
$list[ $group->id ] = $group->name;
}
}
return $list;
}
/**
* Check BuddyBoss group display condition in frontend.
*
* @param array $options options of the condition.
*
* @return bool True if can be displayed.
*/
public static function group_check( $options = [] ) {
if ( ! isset( $options['value'] ) || ! is_array( $options['value'] ) || ! function_exists( 'bp_get_current_group_id' ) ) {
return true;
}
$operator = isset( $options['operator'] ) && 'is_not' === $options['operator'] ? 'is_not' : 'is';
return \Advanced_Ads_Display_Conditions::can_display_ids( \bp_get_current_group_id(), $options['value'], $operator );
}
/**
* Check if we are using BuddyPress legacy theme
*
* @return bool 1 if the site uses the legacy theme
*/
public static function is_legacy_theme() {
return function_exists( 'bp_get_theme_package_id' ) && 'legacy' === \bp_get_theme_package_id();
}
/**
* Return the hook from the selected option
* the legacy method used another format, the new version stores the hooks in the option
*
* @param Placement $placement the placement.
*
* @return string hook name
*/
public static function get_hook_from_placement_options( $placement ) {
$hook = $placement->get_prop( 'buddypress_hook' ) ?? 'bp_after_activity_entry';
if ( empty( $hook ) ) {
return 'bp_after_activity_entry';
}
// This accounts for previous versions of the add-on.
return ( 'bp_' !== substr( $hook, 0, 3 ) )
? str_replace( ' ', '_', 'bp_' . $hook )
: $hook;
}
/**
* Check if BuddyBoss is installed instead of BuddyPress
*
* @return bool true if BuddyBoss is installed and used instead of BuddyPress
*/
public static function is_buddyboss() {
return defined( 'BP_PLATFORM_VERSION' );
}
/**
* Check if passed activity type matches current activity type.
*
* @param string $activity_type Activity type to check.
*
* @return bool
*/
private function is_activity_type( $activity_type ) {
switch ( $activity_type ) {
case 'sitewide':
return ! function_exists( 'bp_is_activity_directory' ) || \bp_is_activity_directory();
case 'group':
return ! function_exists( 'bp_is_group_activity' ) || \bp_is_group_activity();
case 'member':
return ! function_exists( 'bp_is_user_activity' ) || \bp_is_user_activity();
default:
return true;
}
}
}

View File

@@ -0,0 +1,14 @@
<?php
/**
* Module main file
*
* @package AdvancedAds\Pro\Modules\BuddyPress
* @author Advanced Ads <info@wpadvancedads.com>
*/
// Stop if BuddyPress isn't activated.
if ( ! class_exists( 'BuddyPress', false ) ) {
return;
}
( new AdvancedAds\Pro\Modules\BuddyPress\BuddyPress() )->hooks();

View File

@@ -0,0 +1,26 @@
<?php
/**
* Templace for the Group display condition.
*
* @var array $groups List of BuddyBoss groups.
* @var array $values Selected groups.
* @var string $rand Unique identifier of the current metabox.
* @var string $name Form name attribute.
*/
?>
<input type="hidden" name="<?php echo esc_attr( $name ); ?>[type]" value="<?php echo esc_attr( $options['type'] ); ?>"/>
<div class="advads-conditions-single advads-buttonset">
<?php
foreach ( $groups as $_group_id => $_group_name ) {
$_val = in_array( $_group_id, $values, true ) ? 1 : 0;
$_label = sprintf( '%s (%s)', $_group_name, $_group_id );
$field_id = "advads-conditions-$_group_id-$rand";
?>
<label class="button" for="<?php echo esc_attr( $field_id ); ?>"><?php echo esc_html( $_label ); ?></label><input
type="checkbox"
id="<?php echo esc_attr( $field_id ); ?>"
name="<?php echo esc_attr( $name ); ?>[value][]" <?php checked( $_val, 1 ); ?>
value="<?php echo esc_attr( $_group_id ); ?>">
<?php
}

View File

@@ -0,0 +1,59 @@
<?php
/**
* Render position option for the BuddyPress Content placement
*
* @package AdvancedAds\Pro
* @author Advanced Ads <info@wpadvancedads.com>
*
* @var string $placement_slug slug of the placement
* @var array $buddypress_positions available positions (hooks)
* @var string $current currently selected position
* @var int $index value of index option
* @var string $activity_type Activity Type
* @var bool $hook_repeat Whether to repeat the hook
*/
use AdvancedAds\Pro\Modules\BuddyPress\BuddyPress;
?>
<div class="advads-option">
<span><?php esc_html_e( 'position', 'advanced-ads-pro' ); ?></span>
<div>
<?php if ( BuddyPress::is_legacy_theme() ) : ?>
<select name="advads[placements][options][buddypress_hook]">
<?php foreach ( $buddypress_positions as $_group => $_positions ) : ?>
<optgroup label="<?php echo esc_html( $_group ); ?>">
<?php foreach ( $_positions as $_position_key => $_position_title ) : ?>
<option value="<?php echo esc_attr( $_position_key ); ?>" <?php selected( $_position_key, $current ); ?>><?php echo esc_html( $_position_title ); ?></option>
<?php endforeach; ?>
</optgroup>
<?php endforeach; ?>
</select>
<?php endif; ?>
<p>
<?php
printf(
/* translators: %s is an HTML input element. */
esc_html__( 'Inject after %s. entry', 'advanced-ads-pro' ),
'<input type="number" required="required" min="1" name="advads[placements][options][pro_buddypress_pages_index]" value="' . absint( $index ) . '"/>'
);
?>
</p>
<p>
<label><input type="checkbox" name="advads[placements][options][hook_repeat]" value="1" <?php checked( $hook_repeat ); ?>><?php esc_html_e( 'repeat the position', 'advanced-ads-pro' ); ?></label>
</p>
</div>
</div>
<?php if ( ! BuddyPress::is_legacy_theme() ) : ?>
<div class="advads-option">
<span><?php esc_html_e( 'Stream', 'advanced-ads-pro' ); ?></span>
<div class="advads-buddypress-placement-activity">
<label><input name="advads[placements][options][activity_type]" value="any" type="radio" <?php checked( $activity_type, 'any' ); ?>><?php esc_html_e( 'any', 'advanced-ads-pro' ); ?></label>
<label><input name="advads[placements][options][activity_type]" value="sitewide" type="radio" <?php checked( $activity_type, 'sitewide' ); ?>><?php esc_html_e( 'activity stream', 'advanced-ads-pro' ); ?></label>
<label><input name="advads[placements][options][activity_type]" value="group" type="radio" <?php checked( $activity_type, 'group' ); ?>><?php esc_html_e( 'group feed', 'advanced-ads-pro' ); ?></label>
<label><input name="advads[placements][options][activity_type]" value="member" type="radio" <?php checked( $activity_type, 'member' ); ?>><?php esc_html_e( 'member timeline', 'advanced-ads-pro' ); ?></label>
</div>
</div>
<?php endif; ?>

View File

@@ -0,0 +1,75 @@
<?php
/**
* Render xprofile visitor condition settions.
*
* @package AdvancedAds\Pro\Modules\BuddyPress
* @author Advanced Ads <info@wpadvancedads.com>
*
* @var string $name Base name of the setting.
* @var array $options Condition options.
* @var array $groups BuddyPress field groups.
* @var int $field Field option.
* @var string $value Value option.
* @var array $type_options Options for the condition type.
* @var string $current_field_type Current field type.
*/
use AdvancedAds\Pro\Modules\BuddyPress\BuddyPress;
$manual_link = BuddyPress::is_buddyboss()
? 'https://wpadvancedads.com/manual/buddyboss-ads/?utm_source=advanced-ads&utm_medium=link&utm_campaign=condition-buddyboss-profile-fields'
: 'https://wpadvancedads.com/ads-on-buddypress-pages/?utm_source=advanced-ads&utm_medium=link&utm_campaign=condition-buddypress-profile-fields';
?><input type="hidden" name="<?php echo esc_attr( $name ); ?>[type]" value="<?php echo esc_attr( $options['type'] ); ?>"/>
<?php
if ( $groups ) :
?>
<div class="advads-conditions-select-wrap">
<select class="advads-pro-buddyboss-xprofile-field-type" data-field-name="<?php echo esc_attr( $name ); ?>" name="<?php echo esc_attr( $name ); ?>[field]">
<?php
foreach ( $groups as $_group ) :
?>
<optgroup label="<?php echo esc_html( $_group->name ); ?>">
<?php
if ( $_group->fields ) {
foreach ( $_group->fields as $_field ) :
$field_type = self::FIELD_MEMBERTYPES === $_field->type ? self::FIELD_MEMBERTYPES : self::FIELD_TEXTBOX;
?>
<option value="<?php echo esc_attr( $_field->id ); ?>" data-field-type="<?php echo esc_attr( $field_type ); ?>" <?php selected( $field, $_field->id ); ?>>
<?php echo esc_html( $_field->name ); ?>
</option>
<?php
endforeach;
}
?>
</optgroup>
<?php
endforeach;
?>
</select>
</div>
<?php
else :
?>
<p class="advads-notice-inline advads-error">
<?php
/* translators: "profile fields" relates to BuddyPress profile fields */
esc_html_e( 'No profile fields found', 'advanced-ads-pro' );
?>
</p>
<?php
endif;
if ( 0 <= version_compare( ADVADS_VERSION, '1.9.1' ) ) {
include ADVADS_ABSPATH . 'admin/views/ad-conditions-string-operators.php';
}
AdvancedAds\Pro\Modules\BuddyPress\Admin::render_xprofile_field( $name, $current_field_type, $value );
?>
<br class="clear" />
<br />
<p class="description">
<?php echo esc_html( $type_options[ $options['type'] ]['description'] ); ?>
<a href="<?php echo esc_url( $manual_link ); ?>" class="advads-manual-link" target="_blank"><?php esc_html_e( 'Manual', 'advanced-ads-pro' ); ?></a>
</p>