';
return $content;
}
/**
* Add fields to the Text/Code meta box.
*
* @return void
*/
public function adcmdrtextcode_meta_box() {
$this->metaitem_adcontent_textarea();
}
/**
* Add fields to the Rich Content meta box.
*
* @return void
*/
public function adcmdrrichcontent_meta_box() {
$this->metaitem_adcontent_richcontent();
}
/**
* Add fields to the Rich Content meta box.
*
* @return void
*/
public function adcmdradsense_meta_box() {
$pub_id = AdSense::instance()->current_adsense_publisher_id();
$is_adsense_connected = AdminAdsense::instance()->has_access_token( $pub_id );
$this->metaitem_adsense_connect( $is_adsense_connected, $pub_id );
$this->metaitem_adsense_meta( $is_adsense_connected, $pub_id );
}
/**
* Add fields to the Expirations meta box.
*
* @return void
*/
public function adcmdrexpirations_meta_box() {
$this->metaitem_expire_datetime();
$this->metaitem_expire_stats();
}
/**
* Add fields to the Reports meta box.
*
* @return void
*/
public function adcmdrreport_meta_box() {
$this->metaitem_tracking();
}
/**
* Add fields to the Override meta box.
*
* @return void
*/
public function adcmdroverride_meta_box() {
$this->metaitem_donottrack();
}
/**
* Add fields to the Layout meta box.
*
* @return void
*/
public function adcmdrlayout_meta_box() {
$this->info( __( "Apply layout settings to an individual ad. If this ad is used in a group, some of these settings will be ignored in favor of the group's layout.", 'ad-commander' ) );
$this->metaitem_ad_label();
$this->metaitem_responsive_adimages();
$this->metaitem_float();
$this->metaitem_margin();
$this->metaitem_custom_classes();
}
/**
* Add fields to the Targeting meta box.
*
* @return void
*/
public function adcmdrtargeting_meta_box() {
$this->metaitem_targeting();
}
/**
* Add fields to the Advanced meta box.
*
* @return void
*/
public function adcmdradvanced_meta_box() {
$this->metaitem_disable_consent();
$this->metaitem_additional_code();
}
/**
* Meta item for connecting adsense
*
* @param mixed $is_adsense_connected If AdSense is currently connected.
* @param mixed $global_publisher_id If we have a publisher ID.
*/
private function metaitem_adsense_connect( $is_adsense_connected, $global_publisher_id ) {
if ( ! $is_adsense_connected && ! $global_publisher_id ) :
?>
info( esc_html__( 'AdSense is not yet configured. Connect your site to AdSense or specify a publisher ID to build ads manually. Alternatively, you can paste your ad code below. Settings must be configured by an administrator.', 'ad-commander' ), array( 'classes' => 'adcmdr-metaitem__warning' ) ); ?>
' . esc_html( $ad_pub_id_message ) . '';
if ( $ad_pub_id !== $global_publisher_id ) {
$message .= ' ' . __( 'The publisher ID for this ad does not match the publisher ID from settings. If this is unintentional, delete this ad and create a new one or update your publisher ID in settings.', 'ad-commander' ) . '';
}
$this->message( $message );
}
$this->wo_meta->input( 'adsense_ad_pub_id', $ad_pub_id, 'hidden' );
?>
required_pro_version_message( '1.2.0', true );
$this->wo_meta->label( 'max_displays_per_view', __( 'Max Displays Per Page Load', 'ad-commander' ) . ( ! ProBridge::instance()->is_pro_loaded() ? ProBridge::instance()->pro_label( true ) : '' ) );
$this->wo_meta->input( 'max_displays_per_view', $this->wo_meta->get_value( $this->current_meta(), 'max_displays_per_view' ), 'number', array( 'disabled' => ! ProBridge::instance()->is_pro_loaded() ) );
Doc::doc_link( 'max_displays_per_view' );
$this->message( __( 'Example: Set to 1 to only display this ad once per page load. 0 or blank for unlimited displays.', 'ad-commander' ) );
?>
info( __( 'Only display this ad if certain conditions are met.', 'ad-commander' ) );
$this->metaitem_maxdisplays();
$this->admin_targeting()->metaitem_targeting( $this->wo_meta->get_value( $this->current_meta(), 'content_conditions' ), false, 'content', AdCommander::posttype_ad() );
$this->admin_targeting()->metaitem_targeting( $this->wo_meta->get_value( $this->current_meta(), 'visitor_conditions' ), false, 'visitor', AdCommander::posttype_ad() );
}
/**
* HTML/fields for Display Size meta.
*
* @return string
*/
private function metaitem_display_size() {
return '
' . $this->message( __( 'Theme styles may override these settings.', 'ad-commander' ), array(), array( 'display' => false ) );
}
/**
* HTML/fields for Additional Code meta.
*/
private function metaitem_additional_code() {
?>
info( __( 'Javascript and CSS allowed (must include style or script tags). Use with caution and test your ad display and tracking.', 'ad-commander' ) );
Doc::doc_link( 'custom_code' );
?>
wo_meta->label( 'disable_consent', __( 'Disable Consent Requirement', 'ad-commander' ) );
$this->wo_meta->checkbox( 'disable_consent', $this->wo_meta->get_value( $this->current_meta(), 'disable_consent' ) );
$this->wo_meta->label( 'disable_consent', __( 'Ignore site-wide setting and disable consent requirement for this ad.', 'ad-commander' ) );
$this->message( __( 'Note that this setting will be ignored if ad is used in a group or insert. You must disable consent for the entire group or insert instead.', 'ad-commander' ) );
?>
is_pro_loaded();
$classes = array( 'expire_datetime', 'group' );
if ( $disabled ) {
$classes[] = 'disabled';
} else {
$info = __( "Expired ads will move to Draft status. Leave values blank to disable a feature. To schedule a start date, edit this Ad post's Publish date and time in the Publish settings.", 'ad-commander' );
$this->info( $info );
}
Doc::doc_link( 'expiring_ads' );
$this->message( __( 'Expire ad at the below date and time. Both must be specified.', 'ad-commander' ) );
?>
is_pro_loaded();
$disabled_c = false;
$disabled_i = false;
$click_disabled = '';
$imp_disabled = '';
if ( ! $disabled ) {
if ( ! Tracking::instance()->should_track_local( 'clicks', false ) ) {
$disabled_c = true;
$click_disabled = __( 'Local click tracking is disabled.', 'ad-commander' );
}
if ( ! Tracking::instance()->should_track_local( 'impressions', false ) ) {
$disabled_i = true;
$imp_disabled = __( 'Local impression tracking is disabled.', 'ad-commander' );
}
if ( $this->wo_meta->get_value( $this->current_meta(), 'donottrack_c' ) ) {
$disabled_c = true;
if ( ! $click_disabled ) {
$click_disabled = __( 'Local click tracking is disabled for this ad.', 'ad-commander' );
}
}
if ( $this->wo_meta->get_value( $this->current_meta(), 'donottrack_i' ) ) {
$disabled_i = true;
if ( ! $imp_disabled ) {
$imp_disabled = __( 'Local impression tracking is disabled for this ad', 'ad-commander' );
}
}
}
$classes = array( 'expire_stats', 'divide' );
if ( $disabled ) {
$classes[] = 'disabled';
}
?>
info( implode( ' ', $disabled_message ), 'adcmdr-metaitem__warning' );
}
$this->message( __( 'Expire ad if it meets or exceeds either of these statistics.', 'ad-commander' ) );
?>
wo_meta->checkbox( 'clickfraud_disable', $this->wo_meta->get_value( $this->current_meta(), 'clickfraud_disable' ) );
$this->wo_meta->label( 'clickfraud_disable', __( 'Continue to display this ad after Click Fraud is detected.', 'ad-commander' ) );
?>
';
return $html;
}
/**
* HTML/fields for Content ad meta.
*/
private function metaitem_adcontent_textarea() {
?>
wo_meta->textarea( 'adcontent_text', $this->wo_meta->get_value( $this->current_meta(), 'adcontent_text' ), $this->textarea_code_args() );
/* translators: %1$s anchor tag, %2$s close anchor tag */
$this->message( sprintf( __( 'Paste your entire ad code here. Linebreaks will be removed from output. For text ads with linebreaks, use the %1$sRich Content Editor%2$s.', 'ad-commander' ), '', '' ) );
?>
wo_meta->get_value( $this->current_meta(), 'adcontent_rich' );
$editor_id = $this->wo_meta->make_key( 'adcontent_rich' );
$settings = array(
'wpautop' => true, // use wpautop?
'media_buttons' => true, // show insert/upload button(s)
'textarea_name' => $editor_id, // set the textarea name to something different, square brackets [] can be used here
'textarea_rows' => get_option( 'default_post_edit_rows', 10 ), // rows="..."
'tabindex' => '',
'editor_css' => '', // extra styles for both visual and HTML editors buttons,
'editor_class' => '', // add extra class(es) to the editor textarea
'teeny' => false, // output the minimal editor config used in Press This
'dfw' => false, // replace the default fullscreen with DFW (supported on the front-end in WordPress 3.4)
'tinymce' => true, // load TinyMCE, can be used to pass settings directly to TinyMCE using an array()
'quicktags' => true, // load Quicktags, can be used to pass settings directly to Quicktags using an array()
);
wp_editor( $content === null ? '' : $content, $editor_id, $settings );
?>
ID ) && $this->has_ad_saved() ) :
$reports = $this->admin_reports();
?>
message( __( 'Stats may take a minute to update.', 'ad-commander' ) ); ?>
wo_meta->label( 'impressions', __( 'Impressions:', 'ad-commander' ) ); ?>
wo_meta->message( $message, $args );
}
/**
* Check if this ad has saved previously.
*
* @return bool
*/
private function has_ad_saved() {
global $post;
return isset( $post->post_status ) && $post->post_status !== 'auto-draft';
}
/**
* The onboarding message (maybe) displayed after a post is published.
*
* @return void
*/
public function new_ad_notice() {
global $post;
if ( ! $post ||
! isset( $post->ID ) ||
! $this->has_ad_saved() ||
! isset( $post->post_type ) ||
$post->post_type !== AdCommander::posttype_ad() ||
! $this->is_screen( AdCommander::posttype_ad() ) ||
$post->post_status !== 'publish' ||
! AdminOnboarding::instance()->should_onboard( 'ads' ) ) {
return;
}
$ad_type = $this->wo_meta->get_value( $this->current_meta(), 'adtype' );
if ( ! $ad_type || $this->invalid_ad_message() !== false ) {
return;
}
/**
* TODO: Consider some restrictions on when this should show.
* We could do by X minutes, but that seems unreliable.
* Could check if the post is in an insert or not?
* Or a combination of the two.
* Right now it shows until the onboarding messages are disabled.
*/
?>