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,325 @@
<?php // phpcs:ignoreFile
/**
* View for the Settings - AdSense.
*
* @package Advanced_Ads
*/
use AdvancedAds\Utilities\Conditional;
$MAPI = Advanced_Ads_AdSense_MAPI::get_instance();
$options = $this->data->get_options();
$adsense_id = $this->data->get_adsense_id();
$mapi_options = Advanced_Ads_AdSense_MAPI::get_option();
$mapi_account_details = false;
$CID = Advanced_Ads_AdSense_MAPI::CID;
$use_user_app = Advanced_Ads_AdSense_MAPI::use_user_app();
if ( $use_user_app ) {
$CID = ADVANCED_ADS_MAPI_CID;
}
$can_connect = true;
if ( $use_user_app && !( ( defined( 'ADVANCED_ADS_MAPI_CID' ) && '' != ADVANCED_ADS_MAPI_CID ) && ( defined( 'ADVANCED_ADS_MAPI_CIS' ) && '' != ADVANCED_ADS_MAPI_CIS ) ) ) {
$can_connect = false;
}
$has_token = Advanced_Ads_AdSense_MAPI::has_token( $adsense_id );
if ( $has_token && isset( $mapi_options['accounts'][ $adsense_id ]['details'] ) ) {
$mapi_account_details = $mapi_options['accounts'][ $adsense_id ]['details'];
}
$alerts = Advanced_Ads_AdSense_MAPI::get_stored_account_alerts( $adsense_id );
/* translators: 1: opening anchor tag for link to adsense account 2: closing anchor tag for link to adsense account */
$alerts_heading = $adsense_id ? sprintf( esc_html__( 'Warning from your %1$sAdSense account%2$s', 'advanced-ads' ), '<a target="_blank" href="https://www.google.com/adsense/new/u/1/' . esc_html( $adsense_id ) . '/">', '</a>' ) : esc_html__( 'AdSense warnings', 'advanced-ads' );
$alerts_heading = $adsense_id
? wp_kses(
sprintf(
/* translators: 1: opening anchor tag for link to adsense account 2: closing anchor tag for link to adsense account */
__( 'Warning from your %1$sAdSense account%2$s', 'advanced-ads' ),
'<a target="_blank" href="https://www.google.com/adsense/new/u/1/' . $adsense_id . '/">',
'</a>'
),
[
'a' => [
'target' => true,
'href' => true,
],
]
)
: __( 'AdSense warnings', 'advanced-ads' );
$alerts_dismiss = __( 'dismiss', 'advanced-ads' );
$connection_error_messages = Advanced_Ads_AdSense_MAPI::get_connect_error_messages();
$alerts_advads_messages = Advanced_Ads_Adsense_MAPI::get_adsense_alert_messages();
?>
<div id="mapi-account-alerts">
<?php if ( is_array( $alerts ) && isset( $alerts['items'] ) && is_array( $alerts['items'] ) && $alerts['items'] ) : ?>
<h3>
<?php
//phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- already escaped
echo $alerts_heading;
?>
</h3>
<?php foreach ( $alerts['items'] as $alert_id => $alert ) : ?>
<div class="card advads-notice-block advads-error">
<button type="button" class="mapi-dismiss-alert notice-dismiss" data-id="<?php echo esc_attr( $alert_id ); ?>">
<span class="screen-reader-text"><?php echo esc_html( $alerts_dismiss ); ?></span>
</button>
<?php
$internal_id = $alert['id'] ?? str_replace( '-', '_', strtoupper( $alert['type'] ) );
echo wp_kses(
$alerts_advads_messages[ $internal_id ] ?? $alert['message'],
[
'a' => [
'href' => true,
'target' => true,
'class' => true,
],
]
);
?>
</div>
<?php endforeach; ?>
<?php /* translators: %s: date and time of last check in the format set in wp_options */ ?>
<p class="description alignright"><?php printf( __( 'last checked: %s', 'advanced-ads' ), $alerts['lastCheck'] ? esc_html( ( new DateTime( '@' . $alerts['lastCheck'], Advanced_Ads_Utils::get_wp_timezone() ) )->format( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ) ) ) : '-' ); ?></p>
<?php endif; ?>
<?php
if ( ! empty( $mapi_options['connect_error'] ) ) {
$message = isset( $mapi_options['connect_error']['message'] ) ? $mapi_options['connect_error']['message'] : '';
if ( isset( $connection_error_messages[ $mapi_options['connect_error']['reason'] ] ) ) {
$message = $connection_error_messages[ $mapi_options['connect_error']['reason'] ];
}
if ( ! empty( $message ) ) {
echo '<div id="mapi-connect-errors" class="notice error inline"><p class="advads-notice-inline advads-error">';
echo wp_kses( $message, [
'a' => [
'id' => [],
'class' => [],
'href' => [],
'style' => [],
],
'i' => [
'id' => [],
'class' => [],
'style' => [],
],
] );
echo '</p></div>';
}
}
?>
</div>
<div id="full-adsense-settings-div" <?php if ( empty( $adsense_id ) ) echo 'style="display:none"' ?>>
<input type="text" <?php echo $has_token ? 'readonly' : ''; ?> name="<?php echo esc_attr( GADSENSE_OPT_NAME ); ?>[adsense-id]" placeholder="pub-1234567891234567" style="margin-right:.8em" id="adsense-id" size="32" value="<?php echo esc_attr( $adsense_id ); ?>"/>
<?php if ( !empty( $adsense_id ) && !$has_token ) : ?>
<a id="connect-adsense" class="button-primary <?php echo ! Advanced_Ads_Checks::php_version_minimum() ? 'disabled ' : ''; ?>preventDefault" <?php if ( ! $can_connect || ! Advanced_Ads_Checks::php_version_minimum() ) echo 'disabled'; ?>><?php esc_attr_e( 'Connect to AdSense', 'advanced-ads' ) ?></a>
<?php endif; ?>
<?php if ( $has_token ) : ?>
<a id="revoke-token" class="button-secondary preventDefault"><?php esc_attr_e( 'Revoke API acccess', 'advanced-ads' ) ?></a>
<div id="gadsense-freeze-all" style="position:fixed;top:0;bottom:0;right:0;left:0;background-color:rgba(255,255,255,.5);text-align:center;display:none;">
<img alt="..." src="<?php echo ADVADS_BASE_URL . 'admin/assets/img/loader.gif'; ?>" style="margin-top:40vh" />
</div>
<?php endif; ?>
<?php if ( $mapi_account_details ) : ?>
<p class="description"><?php esc_html_e( 'Account holder name', 'advanced-ads' ); echo ': <strong>' . esc_html( $mapi_account_details['name'] ) . '</strong>'; ?></p>
<?php else : ?>
<?php if ( 0 !== strpos( $adsense_id, 'pub-' ) ) : ?>
<p class="advads-notice-inline advads-error"><?php esc_html_e( 'The Publisher ID has an incorrect format. (must start with "pub-")', 'advanced-ads' ); ?></p>
<?php endif; ?>
<?php endif; ?>
</div>
<?php if ( empty( $adsense_id ) ) : ?>
<div id="auto-adsense-settings-div" <?php if ( !empty( $adsense_id ) ) echo 'style="display:none;"' ?>>
<div class="widget-col">
<h3><?php _e( 'Yes, I have an AdSense account', 'advanced-ads' ) ?></h3>
<a id="connect-adsense" class="button-primary <?php echo ! Advanced_Ads_Checks::php_version_minimum() ? 'disabled ' : ''; ?>preventDefault" <?php echo ! Advanced_Ads_Checks::php_version_minimum() ? 'disabled' : ''; ?>><?php _e( 'Connect to AdSense', 'advanced-ads' ) ?></a>
<a id="adsense-manual-config" class="button-secondary preventDefault"><?php _e( 'Configure everything manually', 'advanced-ads' ) ?></a>
</div>
<div class="widget-col">
<h3><?php _e( "No, I still don't have an AdSense account", 'advanced-ads' ) ?></h3>
<a class="button button-secondary" target="_blank" href="<?php echo Advanced_Ads_AdSense_Admin::ADSENSE_NEW_ACCOUNT_LINK; ?>"><?php _e( 'Get a free AdSense account', 'advanced-ads' ); ?></a>
<p>
<?php
printf(
wp_kses(
/* translators: %1$s is an opening a tag, %2$s is the closing one */
__( 'See all %1$srecommended ad networks%2$s.', 'advanced-ads' ),
[
'a' => [
'href' => [],
'target' => [],
],
]
),
'<a href="https://wpadvancedads.com/recommended-ad-networks/?utm_source=advanced-ads&utm_medium=link&utm_campaign=recommendations" target="_blank">',
'</a>'
);
?>
</p>
</div>
</div>
<style type="text/css">
#adsense table h3 {
margin-top: 0;
margin-bottom: .2em;
}
#adsense .form-table tr {
display: none;
}
#adsense .form-table tr:first-of-type {
display: table-row;
}
#auto-adsense-settings-div .widget-col {
float: left;
margin: 0px 5px 5px 0px;
}
#auto-adsense-settings-div:after {
display: block;
content: "";
clear: left;
}
#auto-adsense-settings-div .widget-col:first-child {
margin-right: 20px;
border-right: 1px solid #cccccc;
padding: 0px 20px 0px 0px;
position: relative;
}
#auto-adsense-settings-div .widget-col:first-child:after {
position: absolute;
content: "or";
display: block;
top: 20px;
right: -10px;
background: #ffffff;
color: #cccccc;
font-size: 20px;
}
@media screen and (max-width: 1199px) {
#auto-adsense-settings-div .widget-col { float: none; margin-right: 0; }
#auto-adsense-settings-div .widget-col:first-child { margin: 0px 0px 20px 0px; padding: 0px 0px 20px 0px; border-bottom: 1px solid #cccccc; border-right: 0; }
#auto-adsense-settings-div .widget-col:first-child:after { top: auto; right: auto; bottom: -10px; left: 20px; display: inline-block; padding: 0px 5px 0px 5px; }
}
</style>
<?php
echo "<br/><br/><br/><hr>";
include ADVADS_ABSPATH . 'modules/gadsense/admin/views/auto-ads-video.php';
?><p>
<a href="https://wpadvancedads.com/place-adsense-ad-unit-manually/?utm_source=advanced-ads&utm_medium=link&utm_campaign=adsense-manually" style="text-decoration: none;" target="_blank"><span class="dashicons dashicons-welcome-learn-more"></span>
<?php
esc_attr_e( 'How to choose specific positions for AdSense ad units', 'advanced-ads' ); ?></a>
</p>
<?php
$_notice = 'nl_adsense';
if ( Advanced_Ads_Admin_Notices::get_instance()->can_display( $_notice ) && Conditional::user_can_subscribe( 'nl_first_steps' ) ) {
$box_classes = '!margin-top-4';
$text = sprintf(
/* translators: %s: number of add-ons. */
__( 'Subscribe to our free email course for Google AdSense, receive our newsletter for periodic tutorials, and get %s for Advanced Ads.', 'advanced-ads' ),
'<strong>' . __( '2 free add-ons', 'advanced-ads' ) . '</strong>'
);
include ADVADS_ABSPATH . '/admin/views/notices/inline.php';
}
?>
<?php else : ?>
<p>
<?php
printf(
wp_kses(
/* translators: %1$s is the opening link tag to our manual; %2$s is the appropriate closing link tag; %3$s is the opening link tag to our help forum; %4$s is the appropriate closing link tag */
__( 'Problems with AdSense? Check out the %1$smanual%2$s or %3$sask here%4$s.', 'advanced-ads' ),
[
'a' => [
'href' => [],
'target' => [],
],
]
),
'<a href="https://wpadvancedads.com/adsense-ads/?utm_source=advanced-ads&utm_medium=link&utm_campaign=adsense-manual-check" target="_blank">',
'</a>',
'<a href="https://wordpress.org/support/plugin/advanced-ads/#new-post" target="_blank">',
'</a>'
); ?></p>
<p>
<?php
printf(
wp_kses(
/* translators: %1$s is an opening a tag, %2$s is the closing one */
__( 'See all %1$srecommended ad networks%2$s.', 'advanced-ads' ),
[
'a' => [
'href' => [],
'target' => [],
],
]
),
'<a href="https://wpadvancedads.com/recommended-ad-networks/?utm_source=advanced-ads&utm_medium=link&utm_campaign=recommendations" target="_blank">',
'</a>'
);
?>
</p><?php endif; ?>
<?php if ( ! Advanced_Ads_Checks::php_version_minimum() ) : ?>
<p class="advads-notice-inline advads-error"><?php esc_html_e( 'Can not connect AdSense account. PHP version is too low.', 'advanced-ads' ); ?></p>
<?php endif; ?>
<div id="mapi-alerts-overlay">
<div style="position:relative;text-align:center;display:table;width:100%;height:100%;">
<div style="display:table-cell;vertical-align:middle;">
<img alt="loading" src="<?php echo esc_url( ADVADS_BASE_URL . 'admin/assets/img/loader.gif' ); ?>" />
</div>
</div>
</div>
<script type="text/javascript">
if ( 'undefined' == typeof window.AdsenseMAPI ) {
AdsenseMAPI = {};
}
AdsenseMAPI = Object.assign(
AdsenseMAPI,
<?php
echo wp_json_encode(
[
'alertsMsg' => $alerts_advads_messages,
'alertsHeadingMsg' => $alerts_heading,
'alertsDismissMsg' => wp_kses( $alerts_dismiss, [] ),
]
)
?>
);
</script>
<style type="text/css">
#adsense {
position: relative;
}
#mapi-alerts-overlay {
position:absolute;
top:0;
right:0;
bottom:0;
left:0;
background-color: rgb(255, 255, 255, .90);
display: none;
}
#mapi-account-alerts, #mapi-connect-errors {
margin-bottom: .5em;
}
#dissmiss-connect-error {
cursor: pointer;
}
#gadsense-overlay {
display:none;
background-color:rgba(255,255,255,.5);
position:absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
text-align:center;
}
</style>

View File

@@ -0,0 +1,197 @@
<?php // phpcs:ignoreFile
/**
* Renders the AdSense ad parameters metabox on the ad edit page.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
*
* @var string $unit_type The type of the AdSense unit, e.g. 'responsive'.
* @var string $unit_resize The value of the resize option.
* @var string $unit_id The client ID.
* @var string $unit_code The slot ID.
* @var string $unit_pubid The publisher ID which differs if there comes a different it from the content.
* @var string $json_content The content as JSON.
* @var string $pub_id The publisher ID.
* @var Advanced_Ads_Ad_Type_Adsense $ad The AdSense Ad type.
* @var string $pub_id_errors A string with error messages.
* @var string $content The content.
* @var array $extra_params Filterable extra params that can be passed.
*/
if ( ! defined( 'WPINC' ) ) {
die();
}
$is_responsive = 'responsive' === $unit_type;
$is_link_responsive_unit = 'link-responsive' === $unit_type;
$is_matched_content = 'matched-content' === $unit_type;
$use_manual_css = 'manual' === $unit_resize;
if ( $is_responsive || $is_link_responsive_unit || $is_matched_content ) {
echo '<style> #advanced-ads-ad-parameters-size {display: none;} </style>';
}
$MAPI = Advanced_Ads_AdSense_MAPI::get_instance();
$use_user_app = Advanced_Ads_AdSense_MAPI::use_user_app();
$use_paste_code = true;
$use_paste_code = apply_filters( 'advanced-ads-gadsense-use-pastecode', $use_paste_code );
$db = Advanced_Ads_AdSense_Data::get_instance();
$adsense_id = trim( $db->get_adsense_id() );
$sizing_array = $db->get_responsive_sizing();
$gadsense_options = $db->get_options();
$mapi_options = Advanced_Ads_AdSense_MAPI::get_option();
$mapi_nonce = wp_create_nonce( 'advads-mapi' );
$has_token = Advanced_Ads_AdSense_MAPI::has_token( $adsense_id );
$quota = $MAPI->get_quota();
$mapi_ad_codes = $mapi_options['ad_codes'];
$mapi_ad_codes['length'] = count( $mapi_ad_codes );
?>
<?php if ( $has_token ) : ?>
<script type="text/javascript">
if ( 'undefined' == typeof window.AdsenseMAPI ) {
var AdsenseMAPI = {};
}
AdsenseMAPI.hasToken = true;
AdsenseMAPI.nonce = '<?php echo $mapi_nonce ?>';
//AdsenseMAPI.codes = <?php echo json_encode( $mapi_ad_codes ) ?>;
AdsenseMAPI.quota = <?php echo json_encode( $quota ) ?>;
AdsenseMAPI.pubId = '<?php echo $pub_id ?>';
AdsenseMAPI.adStatus = '<?php echo $ad->get_status() ?>';
AdsenseMAPI.unsupportedUnits = <?php echo wp_json_encode( $mapi_options['unsupported_units'] ); ?>;
</script>
<?php endif; ?>
<script type="text/javascript">
if ( 'undefined' === typeof gadsenseData ) {
window.gadsenseData = {};
}
gadsenseData['pubId'] = '<?php echo $adsense_id; ?>';
gadsenseData['msg'] = {
unknownAd: '<?php esc_attr_e( "The ad details couldn't be retrieved from the ad code", 'advanced-ads' ); ?>',
pubIdMismatch: '<?php esc_attr_e( 'Warning: The AdSense account from this code does not match the one set in the Advanced Ads options.', 'advanced-ads' ); ?>'
};
</script>
<input type="hidden" id="advads-ad-content-adsense" name="advanced_ad[content]" value="<?php echo esc_attr( $json_content ); ?>"/>
<input type="hidden" name="unit_id" id="unit_id" value="<?php echo esc_attr( $unit_id ); ?>"/>
<?php if ( $use_paste_code ) : ?>
<div class="advads-adsense-code" style="display: none;">
<p class="description"><?php _e( 'Copy the ad code from your AdSense account, paste it into the area below and click on <em>Get details</em>.', 'advanced-ads' ); ?></p>
<textarea rows="10" cols="40" class="advads-adsense-content"></textarea>
<button class="button button-primary advads-adsense-submit-code"><?php _e( 'Get details', 'advanced-ads' ); ?></button>&nbsp;&nbsp;
<button class="button button-secondary advads-adsense-close-code"><?php _e( 'cancel', 'advanced-ads' ); ?></button>&nbsp;&nbsp;
<?php if ( ! $has_token ) : ?>
<a style="vertical-align:sub;font-weight:600;font-style:italic;" href="<?php echo admin_url( 'admin.php?page=advanced-ads-settings#top#adsense' ) ?>"><?php _e( 'connect to your AdSense account', 'advanced-ads' ) ?></a>
<?php endif; ?>
<div id="pastecode-msg"></div>
</div>
<?php if ( $has_token && Advanced_Ads_Checks::php_version_minimum() ) {
Advanced_Ads_AdSense_Admin::get_mapi_ad_selector();
}
// the network variable needs to be set for the view to work!
$network = Advanced_Ads_Network_Adsense::get_instance();
include( ADVADS_ABSPATH . '/modules/gadsense/admin/views/external-ads-links.php' );
?>
<?php endif; ?>
<p id="adsense-ad-param-error"></p>
<?php ob_start(); ?>
<label class="label"><?php _e( 'Ad Slot ID', 'advanced-ads' ); ?></label>
<div>
<input type="text" name="unit-code" id="unit-code" value="<?php echo $unit_code; ?>"/>
<input type="hidden" name="advanced_ad[output][adsense-pub-id]" id="advads-adsense-pub-id" value="<?php echo esc_attr( $unit_pubid ); ?>"/>
<?php if ( $unit_pubid ) : ?>
<?php /* translators: %s is the publisher ID. */
printf( __( 'Publisher ID: %s', 'advanced-ads' ), $unit_pubid ); ?>
<?php endif; ?>
<p id="advads-pubid-in-slot" class="advads-notice-inline advads-error"
<?php echo ! ( 0 === strpos( $pub_id, 'pub-' ) && false !== strpos( $unit_code, substr( $pub_id, 4 ) ) ) ? 'style="display:none"' : ''; ?>
><?php _e( 'The ad slot ID is either a number or empty and not the same as the publisher ID.', 'advanced-ads' ) ?></p>
</div>
<hr/>
<?php
$unit_code_markup = ob_get_clean();
echo apply_filters( 'advanced-ads-gadsense-unit-code-markup', $unit_code_markup, $unit_code );
if ( $pub_id_errors ) : ?>
<p>
<span class="advads-notice-inline advads-error">
<?php echo $pub_id_errors; ?>
</span>
<?php /* translators: %s the setting page link */
printf( __( 'Please <a href="%s" target="_blank">change it here</a>.', 'advanced-ads' ), admin_url( 'admin.php?page=advanced-ads-settings#top#adsense' ) ); ?>
</p>
<?php endif; ?>
<label class="label" id="unit-type-block"><?php _e( 'Type', 'advanced-ads' ); ?></label>
<div>
<select name="unit-type" id="unit-type">
<option value="normal" <?php selected( $unit_type, 'normal' ); ?>><?php _e( 'Fixed Size', 'advanced-ads' ); ?></option>
<option value="responsive" <?php selected( $unit_type, 'responsive' ); ?>><?php _e( 'Responsive', 'advanced-ads' ); ?></option>
<option value="matched-content" <?php selected( $unit_type, 'matched-content' ); ?>><?php esc_html_e( 'Multiplex', 'advanced-ads' ); ?></option>
<?php if ( $unit_type === 'link' ) : ?>
<option value="link" <?php selected( $unit_type, 'link' ); ?>><?php _e( 'Link ads', 'advanced-ads' ); ?></option>
<?php endif; ?>
<?php if ( $unit_type === 'link-responsive' ) : ?>
<option value="link-responsive" <?php selected( $unit_type, 'link-responsive' ); ?>><?php _e( 'Link ads (Responsive)', 'advanced-ads' ); ?></option>
<?php endif; ?>
<option value="in-article" <?php selected( $unit_type, 'in-article' ); ?>><?php _e( 'In-article', 'advanced-ads' ); ?></option>
<option value="in-feed" <?php selected( $unit_type, 'in-feed' ); ?>><?php _e( 'In-feed', 'advanced-ads' ); ?></option>
</select>
<a href="https://wpadvancedads.com/google-adsense-ad-formats/?utm_source=advanced-ads&utm_medium=link&utm_campaign=adsense-ad-types" class="advads-manual-link" target="_blank"><?php esc_html_e( 'Manual', 'advanced-ads' ); ?></a>
</div>
<?php if ( in_array( $unit_type, [ 'link', 'link-responsive' ], true ) ) : ?>
<p class="advads-message-warning"><?php esc_html_e( 'Google AdSense deprecated Link Units. Please choose another type.', 'advanced-ads' ); ?>
<a href="https://wpadvancedads.com/adsense-link-units/" target="_blank" rel="noopener">
<?php esc_html_e( 'Learn more', 'advanced-ads' ); ?>
</a>
</p>
<?php endif; ?>
<hr/>
<label class="label" <?php if ( ! $is_responsive || 2 > count( $sizing_array ) ) {
echo 'style="display: none;"';
} ?> id="resize-label"><?php _e( 'Resizing', 'advanced-ads' ); ?></label>
<div <?php if ( ! $is_responsive || 2 > count( $sizing_array ) ) {
echo 'style="display: none;"';
} ?>>
<select name="ad-resize-type" id="ad-resize-type">
<?php foreach ( $sizing_array as $key => $desc ) : ?>
<option value="<?php echo $key; ?>" <?php selected( $key, $unit_resize ); ?>><?php echo $desc; ?></option>
<?php endforeach; ?>
</select>
</div>
<hr>
<label class="label advads-adsense-layout" <?php if ( 'in-feed' !== $unit_type ) {
echo 'style="display: none;"';
} ?> id="advads-adsense-layout"><?php _e( 'Layout', 'advanced-ads' ); ?></label>
<div <?php if ( 'in-feed' !== $unit_type ) {
echo 'style="display: none;"';
} ?>>
<input name="ad-layout" id="ad-layout" value="<?php echo isset( $layout ) ? $layout : ''; ?>"/>
</div>
<hr>
<label class="label advads-adsense-layout-key" <?php if ( 'in-feed' !== $unit_type ) {
echo 'style="display: none;"';
} ?> id="advads-adsense-layout-key"><?php _e( 'Layout-Key', 'advanced-ads' ); ?></label>
<div <?php if ( 'in-feed' !== $unit_type ) {
echo 'style="display: none;"';
} ?>>
<input type="text" name="ad-layout-key" id="ad-layout-key" value="<?php echo $layout_key ?? ''; ?>"/>
</div>
<hr/>
<label class="label clearfix-before" <?php if ( ! $is_responsive ) {
echo 'style="display: none;"';
} ?>><?php _e( 'Clearfix', 'advanced-ads' ); ?></label>
<div class="clearfix-before" <?php if ( ! $is_responsive ) {
echo 'style="display: none;"';
} ?>>
<input type="checkbox" name="advanced_ad[output][clearfix_before]" value="1" <?php checked( ! empty( $options['output']['clearfix_before'] ), true ); ?> />
<p class="description">
<?php _e( 'Enable this if responsive ads cover something on your site.', 'advanced-ads' ); ?>
</p>
</div>
<hr class="clearfix-before" <?php if ( ! $is_responsive ) {
echo 'style="display: none;"';
} ?> />
<?php do_action( 'advanced-ads-gadsense-extra-ad-param', $extra_params, $content, $ad );

View File

@@ -0,0 +1,37 @@
<?php
/**
* AdSense report markup.
*
* @var Advanced_Ads_AdSense_Report $this report instance.
* @var array $report_domains domain names included in the report.
* @var string $report_filter ad unit or domain name to filter the output with.
* @var array $sums daily sums of earnings.
* @var string $earning_cells markup for each earning period.
*/
$time_zone = Advanced_Ads_Utils::get_wp_timezone();
$data_timestamp = date_create( '@' . $this->get_data()->get_timestamp() );
$data_timestamp->setTimezone( $time_zone );
?>
<div class="advads-flex">
<?php echo wp_kses_post( $earning_cells ); ?>
<div class="advads-flex1 advads-stats-box">
<?php if ( $this->type === 'domain' ) : // Adds the dropdown list of domain names. ?>
<div class="advads-stats-dd-container">
<div class="advads-stats-dd-button"><span class="dashicons dashicons-admin-multisite"></span>
<div class="advads-stats-dd-items">
<div class="advads-stats-dd-item<?php echo in_array( $report_filter, [ '*', '' ], true ) ? ' current-filter' : ''; ?>" data-domain="*">
<?php esc_html_e( 'All', 'advanced-ads' ); ?>
</div><!-- .advads-stats-dd-item -->
<?php foreach ( $report_domains as $domain_name ) : ?>
<div class="advads-stats-dd-item<?php echo ( $domain_name === $report_filter ) ? ' current-filter' : ''; ?>" data-domain="<?php echo esc_attr( $domain_name ); ?>">
<?php echo esc_html( $domain_name ); ?>
</div><!-- .advads-stats-dd-item -->
<?php endforeach; ?>
</div><!-- .advads-stats-dd-items -->
</div><!-- .advads-stats-dd-button -->
</div><!-- .advads-stats-dd-container -->
<?php endif; ?>
<div class="advads-stats-age"><?php echo esc_html( $data_timestamp->format( get_option( 'time_format' ) ) ); ?></div>
</div><!-- .advads-stats-box-->
</div><!-- .advads-flex -->

View File

@@ -0,0 +1,16 @@
<div id="advads-auto-ads-links">
<a id="advads-auto-ads-video-link" style="cursor: pointer;">
<span class="dashicons dashicons-format-video"></span>&nbsp;<?php
esc_attr_e( 'How to enable Auto ads in 30 seconds (video tutorial)', 'advanced-ads' ); ?>
</a>
</div>
<script>
(function ($) {
var $videoLink = $('#advads-auto-ads-video-link');
$videoLink.click(function () {
$('<br class="clear"/><br/><iframe src="https://player.vimeo.com/video/381874350" width="640" height="360" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>').appendTo('#advads-auto-ads-links');
$(this).remove();
})
.children('.dashicons').css('line-height', $videoLink.css('line-height'));
})(jQuery)
</script>

View File

@@ -0,0 +1,11 @@
<?php printf(
wp_kses(
/* translators: 1: the plugin name that is managing the Auto ads code. */
__( 'Advanced Ads detected that <strong>%s</strong> is managing the Auto ads code and will therefore not add it.', 'advanced-ads' ),
[
'strong' => [],
]
),
'Borlabs Cookies'
);

View File

@@ -0,0 +1,148 @@
<?php
/**
* HTML markup for AdSense connection modal frame.
*
* @package AdvancedAds
*/
use AdvancedAds\Framework\Utilities\Params;
use AdvancedAds\Utilities\Conditional;
$data_obj = Advanced_Ads_AdSense_Data::get_instance();
$options = $data_obj->get_options();
$nonce = wp_create_nonce( 'advads-mapi' );
$cid = Advanced_Ads_AdSense_MAPI::CID;
$use_user_app = Advanced_Ads_AdSense_MAPI::use_user_app();
if ( $use_user_app ) {
$cid = ADVANCED_ADS_MAPI_CID;
}
$state = [
'api' => 'adsense',
'nonce' => $nonce,
'return_url' => admin_url( 'admin.php?page=advanced-ads-settings&oauth=1#top#adsense' ),
];
$connection_error_messages = Advanced_Ads_AdSense_MAPI::get_connect_error_messages();
$auth_url = 'https://accounts.google.com/o/oauth2/v2/auth?scope=' .
rawurlencode( 'https://www.googleapis.com/auth/adsense.readonly' ) .
'&client_id=' . $cid .
'&redirect_uri=' . rawurlencode( Advanced_Ads_AdSense_MAPI::REDIRECT_URI ) .
'&state=' . rawurlencode( base64_encode( wp_json_encode( $state ) ) ) . // phpcs:ignore
'&access_type=offline&include_granted_scopes=true&prompt=consent&response_type=code';
$_get = wp_unslash( $_GET );
if ( '1' === Params::get( 'oauth' ) && 'adsense' === Params::get( 'api' ) ) : ?>
<?php if ( isset( $_get['nonce'] ) && false !== wp_verify_nonce( $_get['nonce'], 'advads-mapi' ) ) : ?>
<?php if ( isset( $_get['code'] ) && Conditional::user_can( 'advanced_ads_manage_options' ) ) : ?>
<input type="hidden" id="advads-adsense-oauth-code" value="<?php echo esc_attr( urldecode( $_get['code'] ) ); ?>" />
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
<div id="gadsense-modal" data-return="<?php echo ESC_ATTR( admin_url( 'admin.php?page=advanced-ads-settings&oauth=1#top#adsense' ) ); ?>">
<div id="gadsense-modal-outer">
<div id="gadsense-modal-inner">
<div id="gadsense-modal-content">
<div class="gadsense-modal-content-inner" data-content="confirm-code">
<i class="dashicons dashicons-dismiss"></i>
<h2><?php esc_html_e( 'Processing authorization', 'advanced-ads' ); ?></h2>
<div class="gadsense-overlay">
<img alt="..." src="<?php echo esc_url( ADVADS_BASE_URL ); ?>admin/assets/img/loader.gif" style="margin-top:3em" />
</div>
</div>
<div class="gadsense-modal-content-inner" data-content="error" style="display:none;">
<i class="dashicons dashicons-dismiss"></i>
<h3><?php esc_html_e( 'Cannot access your account information.', 'advanced-ads' ); ?></h3>
<p class="error-message advads-notice-inline advads-error"></p>
<p class="error-description" style="font-size:1.1em;"></p>
</div>
<div class="gadsense-modal-content-inner" data-content="account-selector" style="display:none;">
<i class="dashicons dashicons-dismiss"></i>
<h3><?php esc_html_e( 'Please select an account', 'advanced-ads' ); ?></h3>
<p>
<select id="mapi-select-account">
</select>
</p>
<p><button class="button-primary"><?php esc_html_e( 'Use this account', 'advanced-ads' ); ?></button></p>
<input type="hidden" class="token-data" value="" />
<input type="hidden" class="accounts-details" value="" />
<div class="gadsense-overlay">
<img alt="..." src="<?php echo esc_url( ADVADS_BASE_URL ); ?>admin/assets/img/loader.gif" style="margin-top:3em" />
</div>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
if ( 'undefined' == typeof window.AdsenseMAPI ) {
AdsenseMAPI = {};
}
AdsenseMAPI.nonce = '<?php echo wp_strip_all_tags( $nonce ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>';
AdsenseMAPI.oAuth2 = '<?php echo wp_strip_all_tags( $auth_url ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>';
AdsenseMAPI.connectErrorMsg = <?php echo wp_json_encode( $connection_error_messages ); ?>;
</script>
<style type="text/css">
.gadsense-overlay {
display:none;
background-color:rgba(255,255,255,.5);
position:absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
text-align:center;
}
#gadsense-modal {
display: none;
background-color: rgba(0,0,0,.5);
position:fixed;
top:0;
left:0;
right:0;
bottom:0;
}
#gadsense-modal-outer {
position: relative;
width: 60%;
height: 100%;
<?php if ( is_rtl() ) : ?>
margin-right: 20%;
<?php else : ?>
margin-left: 20%;
<?php endif; ?>
}
#gadsense-modal-inner {
display: table;
width: 100%;
height: 100%;
}
#gadsense-modal-content {
display: table-cell;
vertical-align: middle;
}
.gadsense-modal-content-inner {
padding: 1em;
background-color: #f0f0f0;
position: relative;
border: 3px solid #808b94;
}
.gadsense-modal-content-inner .dashicons-dismiss {
background-color: #fff;
border-radius: 100%;
cursor: pointer;
top: -.5em;
<?php if ( is_rtl() ) : ?>
left: -.5em;
<?php else : ?>
right: -.5em;
<?php endif; ?>
position: absolute;
z-index: 2;
}
</style>

View File

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

View File

@@ -0,0 +1,60 @@
<?php
/**
* WARNING: be careful when modifying the DOM of this document!
* there are some jquery calls that rely on this structure!
*
* @package AdvancedAds
*/
$is_account_connected = $network->is_account_connected();
?>
<p>
<span class="mapi-insert-code">
<a href="#">
<?php
printf(
/* translators: 1: The name of an ad network. */
esc_html__( 'Insert new %1$s code', 'advanced-ads' ),
esc_html( $network->get_display_name() )
);
?>
</a>
</span>
<?php if ( Advanced_Ads_Checks::php_version_minimum() ) : ?>
<?php if ( $is_account_connected ) : ?>
<span class="mapi-open-selector">
<span class="mapi-optional-or"><?php esc_html_e( 'or', 'advanced-ads' ); ?></span>
<a href="#" class="prevent-default"><?php esc_html_e( 'Get ad code from your linked account', 'advanced-ads' ); ?></a>
</span>
<?php if ( $network->supports_manual_ad_setup() ) : ?>
<span class="mapi-close-selector-link">
<?php esc_html_e( 'or', 'advanced-ads' ); ?><a href="#" class="prevent-default">
<?php
printf(
/* translators: 1: The name of an ad network. */
esc_html__( 'Set up %1$s code manually', 'advanced-ads' ),
esc_html( $network->get_display_name() )
);
?>
</a>
</span>
<?php endif; ?>
<?php else : ?>
<?php
esc_html_e( 'or', 'advanced-ads' );
$connect_link_label = sprintf(
/* translators: 1: The name of an ad network. */
esc_html__( 'Connect to %1$s', 'advanced-ads' ),
esc_html( $network->get_display_name() )
);
?>
<a href="<?php echo esc_url( $network->get_settings_href() ); ?>" style="padding:0 10px;font-weight:bold;"><?php echo esc_html( $connect_link_label ); ?></a>
<?php endif; ?>
<?php endif; ?>
</p>
<?php if ( $is_account_connected && ! Advanced_Ads_Checks::php_version_minimum() ) : ?>
<p class="advads-notice-inline advads-error"><?php esc_html_e( 'Can not connect AdSense account. PHP version is too low.', 'advanced-ads' ); ?></p>
<?php
endif;

View File

@@ -0,0 +1,138 @@
<?php
/**
* AdSense ad units table.
*
* @var bool $closeable
* @var bool $use_dashicons
* @var Advanced_Ads_Network_Adsense $network
* @var array $ad_units
* @var bool $display_slot_id
* @var string $pub_id
*
* @package AdvancedAds
*/
global $external_ad_unit_id, $closeable, $display_slot_id;
if ( ! isset( $hide_idle_ads ) ) {
$hide_idle_ads = true;
}
if ( ! isset( $ad_units ) ) {
$ad_units = [];
}
?>
<div id="mapi-wrap" class="aa-select-list">
<?php if ( $closeable ) : ?>
<button type="button" id="mapi-close-selector" class="notice-dismiss"></button>
<?php endif; ?>
<i id="mapi-archived-ads" title="<?php esc_attr_e( 'Hide archived ads', 'advanced-ads' ); ?>" data-alt-title="<?php esc_attr_e( 'Show archived ads', 'advanced-ads' ); ?>" class="dashicons dashicons-hidden"></i>
<i class="aa-select-list-update dashicons dashicons-update mapiaction" data-mapiaction="updateList" style="color:#0085ba;cursor:pointer;font-size:20px;" title="<?php esc_attr_e( 'Update the ad units list', 'advanced-ads' ); ?>"></i>
<div id="mapi-loading-overlay" class="aa-select-list-loading-overlay">
<img alt="..." src="<?php echo esc_url( ADVADS_BASE_URL . 'admin/assets/img/loader.gif' ); ?>" style="margin-top:8em;" />
</div>
<div id="mapi-table-wrap" class="aa-select-list-table-wrap">
<table class="widefat striped">
<thead>
<tr>
<th><?php esc_html_e( 'Name', 'advanced-ads' ); ?></th>
<?php if ( $display_slot_id ) : ?>
<th><?php echo esc_html_x( 'Slot ID', 'AdSense ad', 'advanced-ads' ); ?></th>
<?php endif; ?>
<th><?php echo esc_html_x( 'Type', 'AdSense ad', 'advanced-ads' ); ?></th>
<th><?php esc_html_e( 'Size', 'advanced-ads' ); ?></th>
</tr>
</thead>
<tbody>
<?php if ( empty( $ad_units ) ) : ?>
<tr id="mapi-notice-noads">
<td colspan="5" style="text-align:center;">
<?php esc_attr_e( 'No ad units found', 'advanced-ads' ); ?>
<button type="button" class="mapiaction icon-button" data-mapiaction="updateList">
<?php esc_attr_e( 'Update the ad units list', 'advanced-ads' ); ?>
<i class="dashicons dashicons-update" style="color:#0085ba;font-size:20px;"></i>
</button>
</td>
</tr>
<?php
else :
// Force a refresh the first time the ad list is opened after an update.
echo ! isset( $ad_units[0]->raw['nameV2'] ) ? '<input type="hidden" id="mapi-force-v2-list-update" value="" />' : '';
foreach ( $ad_units as $ad_unit ) {
$ad_unit->is_supported = $network->is_supported( $ad_unit );
}
$sorted_adunits = Advanced_Ads_Ad_Network_Ad_Unit::sort_ad_units( $ad_units, $external_ad_unit_id );
?>
<?php foreach ( $sorted_adunits as $unit ) : ?>
<tr <?php echo 'ARCHIVED' === $unit->raw['status'] ? 'data-archived="1"' : ''; ?> class="advads-clickable-row mapiaction" data-mapiaction="getCode" data-slotid="<?php echo esc_attr( $unit->id ); ?>" data-active="<?php echo esc_attr( $unit->active ); ?>">
<td><?php echo esc_html( $unit->name ); ?></td>
<?php if ( $display_slot_id ) : ?>
<td class="unitcode">
<?php
echo '<span>' . esc_html( $unit->slot_id ) . '</span>';
echo 'ARCHIVED' === $unit->raw['status'] ? '&nbsp;<code>' . esc_html__( 'Archived', 'advanced-ads' ) . '</code>' : '';
?>
</td>
<?php endif; ?>
<td class="unittype">
<?php if ( $unit->is_supported ) : ?>
<?php if ( ! empty( $unit->code ) ) : ?>
<?php echo esc_attr( Advanced_Ads_AdSense_MAPI::format_ad_data( $unit, 'type' ) ); ?>
<?php else : ?>
<button type="button" class="button-secondary button-small" title="<?php esc_attr_e( 'Get the code for this ad', 'advanced-ads' ); ?>">
<span style="line-height: 26px;" class="dashicons dashicons-update"></span> <?php esc_html_e( 'Load', 'advanced-ads' ); ?>
</button>
<?php endif; ?>
<?php elseif ( empty( $unit->code ) ) : ?>
<span class="dashicons dashicons-warning" title="<?php esc_attr_e( 'Ad can\'t be imported, click for details', 'advanced-ads' ); ?>"></span>
<?php endif; ?>
</td>
<td class="unitsize">
<?php echo esc_attr( Advanced_Ads_AdSense_MAPI::format_ad_data( $unit, 'size' ) ); ?>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
<p class="advads-notice-inline advads-error" id="remote-ad-code-error" style="display:none;"><strong><?php esc_attr_e( 'Unrecognized ad code', 'advanced-ads' ); ?></strong></p>
<p class="advads-error-message" id="remote-ad-code-msg"></p>
</div>
<div style="display:none;" id="remote-ad-unsupported-ad-type">
<h3 class="advads-notice-inline advads-error">
<?php esc_html_e( 'This ad type can currently not be imported from AdSense.', 'advanced-ads' ); ?>
</h3>
<p>
<?php esc_html_e( 'You can proceed with one of the following solutions', 'advanced-ads' ); ?>:
</p>
<ul>
<li>
<?php
/* Translators: 1: opening tag for AdSense account link 2: opening tag for a link to insert ad code 3: closing a tag */
printf( esc_html__( '%1$sCopy the code from your AdSense account%3$s and %2$sinsert a new AdSense code here%3$s.', 'advanced-ads' ), '<a href="https://www.google.com/adsense/new/u/0/' . esc_attr( $pub_id ) . '/myads/units" target="_blank">', '<a href="#" class="mapi-insert-code prevent-default">', '</a>' );
?>
</li>
<li>
<?php
/* Translators: 1: opening tag for a link to create an ad manually 2: closing a tag */
printf(
wp_kses(
/* translators: 1: opening tag for a link to create an ad manually 2: closing tag */
__( '%1$sCreate an AdSense code manually%2$s: Select the <em>Normal</em> or <em>Responsive</em> type and the size.', 'advanced-ads' ),
[
'em' => [],
'strong' => [],
]
),
'<a href="#" class="mapi-close-selector-link prevent-default">',
'</a>'
);
?>
</li>
<li>
<?php esc_html_e( 'Choose a different ad from your AdSense account above.', 'advanced-ads' ); ?>
</li>
</ul>
</div>

View File

@@ -0,0 +1,15 @@
<?php
/**
* Option to enable AdSense Auto ads on AMP pages
* located under Advanced Ads > Settings > AdSense > Auto ads
*
* @var string $option_name name of the option.
* @var bool $auto_ads_enabled true if the AMP Auto ads option is enabled.
*/
?>
<p>
<label>
<input type="checkbox" name="<?php echo esc_attr( $option_name ); ?>[auto_ads_enabled]" value="1" <?php checked( $auto_ads_enabled ); ?>/>
<?php esc_html_e( 'Enable AMP Auto ads', 'advanced-ads' ); ?>
</label>
</p>