Below, you’ll find a detailed guide on how to add the Adsmonetizer Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Adsmonetizer Plugin shortcodes not to show or not to work correctly.
Before starting, here is an overview of the Adsmonetizer Plugin and the shortcodes it provides:
"Adsmonetizer is a user-friendly WordPress plugin designed to manage and optimize your Adsense ads. With its unique features, it ensures maximum ad revenue without hindering the user experience."
- [sin_anuncios_b30]
- [anuncio_b30]
- [adsensei_ad]
- [adsensei_ad]
- [adsforwp]
- []
- [adsenseivi]
Adsmonetizer [sin_anuncios_b30] Shortcode
The Adsensei-B30 shortcode, ‘sin_anuncios_b30’, is a functionality that allows users to disable ads on specific posts or pages. Upon execution, it sets the ‘$no_ads_shortcode’ variable to true, preventing ad display.
Shortcode: [sin_anuncios_b30]
Examples and Usage
Basic example – The ‘sin_anuncios_b30’ shortcode simply disables ads for the page it’s implemented on.
[sin_anuncios_b30 /]
Advanced examples
While the ‘sin_anuncios_b30’ shortcode does not inherently support parameters, you can create a custom shortcode that integrates it with other shortcodes or parameters. Here’s an example of a custom shortcode that combines ‘sin_anuncios_b30’ with a ‘content’ parameter:
add_shortcode('custom_shortcode', 'custom_function');
function custom_function($atts) {
$atts = shortcode_atts(
array(
'content' => 'Default content',
), $atts, 'custom_shortcode' );
if (get_option('sin_anuncios_b30')) {
return do_shortcode($atts['content']);
}
}
With this custom shortcode, you can input any content into the ‘content’ parameter, and it will only display if ‘sin_anuncios_b30’ is active. Here’s how to use it:
[custom_shortcode content="Your content here" /]
Note that ‘Your content here’ will only display if ‘sin_anuncios_b30’ is active.
PHP Function Code
In case you have difficulties debugging what causing issues with [sin_anuncios_b30]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('sin_anuncios_b30', array($this, 'do_nothing_shortcode'));
Shortcode PHP function:
function do_nothing_shortcode()
{
self::$no_ads_shortcode = true;
return;
}
Code file location:
adsensei-b30/adsensei-b30/classAdsensei.php
Adsmonetizer [anuncio_b30] Shortcode
The Adsensei B30 shortcode serves to display ads. It fetches ad settings from the ‘adsenseib30_settings’ option and displays the ad based on device type. The shortcode uses the ‘id’ attribute to determine the specific ad to display. It checks the device type (desktop or mobile) and displays the ad accordingly. If the device type doesn’t match, it returns an empty string. The ad code is then wrapped into a div before being returned.
Shortcode: [anuncio_b30]
Parameters
Here is a list of all possible anuncio_b30 shortcode parameters and attributes:
id
– Specifies the unique identifier of the ad
Examples and Usage
Basic example – Display an ad with a specific ID using the shortcode.
[anuncio_b30 id=1 /]
Advanced examples
Displaying an ad by referencing the ID. The ad will load based on the ID specified in the shortcode.
[anuncio_b30 id=3 /]
Displaying an ad by referencing the ID. If the ad is not found with the ID, it will return an empty string.
[anuncio_b30 id=100 /]
It’s important to note that the shortcode will also consider the device type. If the ad is set to display only on desktop, and the user is accessing from a mobile device, the shortcode will return an empty string, and vice versa.
PHP Function Code
In case you have difficulties debugging what causing issues with [anuncio_b30]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('anuncio_b30', array($this, 'show_add_shortcode'));
Shortcode PHP function:
function show_add_shortcode($atts, $content)
{
$ad_shortcode = shortcode_atts(array(
'id' => 1
), $atts);
$numberOfAd = ($ad_shortcode['id']);
self::$shortcodes_being_used[$numberOfAd] = true;
$adsenseib30_settings = get_option('adsenseib30_settings');
//filter by device:
$device = $adsenseib30_settings['adDevice' . $numberOfAd];
if ($device == 'desktop') {
if ($this->isMobile()) return '';
};
if ($device == 'mobile') {
if (!$this->isMobile()) return '';
};
$myad = $adsenseib30_settings['adCode' . $numberOfAd];
$myad = $this->wrap_ad_into_div($myad, $adsenseib30_settings, $numberOfAd);
return $myad;
}
Code file location:
adsensei-b30/adsensei-b30/classAdsensei.php
Adsmonetizer [adsensei_ad] Shortcode
The Adsensei B30 shortcode, ‘adsensei_ad’, is a utility tool. It’s designed to remove unused shortcodes, ensuring cleaner, more efficient code. The PHP function ‘wpadsensei_remove_unsed_shortcode’ returns an empty string, effectively removing any unused shortcode from your WordPress site.
Shortcode: [adsensei_ad]
Examples and Usage
Basic example – The given shortcode can be used to remove unused shortcodes from your WordPress site. This is a simple example of how to use it:
[adsensei_ad]
For advanced examples:
Advanced example 1 – If you want to remove a specific shortcode by its ID, you can pass the ID as a parameter to the shortcode. Here’s how to do it:
[adsensei_ad id="123"]
Advanced example 2 – You can also pass multiple IDs to the shortcode to remove several unused shortcodes at once. Separate the IDs with commas, like this:
[adsensei_ad id="123,456,789"]
Please note that the given PHP function ‘wpadsensei_remove_unsed_shortcode’ doesn’t use any attributes and returns an empty string. To make these advanced examples work, the function needs to be modified to handle the ‘id’ attribute.
PHP Function Code
In case you have difficulties debugging what causing issues with [adsensei_ad]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'adsensei_ad', 'wpadsensei_remove_unsed_shortcode', 1);
Shortcode PHP function:
function wpadsensei_remove_unsed_shortcode( $atts ) {
return '';
}
Code file location:
adsensei-b30/adsensei-b30/includes/mu-plugin/wpadsensei_remove_shortcode.php
Adsmonetizer [adsensei_ad] Shortcode
The Adsensei B30 shortcode, identified as ‘adsensei_ad’, is used to display ads. It checks whether the ad display condition is met and if the ‘NoAds’ setting is off. If these conditions are met, it fetches the ad id and alignment details, then generates the ad code. This shortcode is versatile and can adapt to various ad configurations.
Shortcode: [adsensei_ad]
Parameters
Here is a list of all possible adsensei_ad shortcode parameters and attributes:
id
– Specifies the unique identifier of the ad.
Examples and Usage
Basic example – Display an ad by using its ID
[adsensei_ad id=1 /]
In this example, we are using the shortcode to display an ad from the Adsensei plugin. The ‘id’ attribute is used to specify which ad to display, based on the ad’s ID in the Adsensei settings.
Advanced examples
Display an ad with specific alignment and margin
[adsensei_ad id=1 align=2 margin=5 /]
In this advanced example, we are not only specifying the ad to display with the ‘id’ attribute, but we are also using the ‘align’ and ‘margin’ attributes to control the ad’s appearance. The ‘align’ attribute controls the alignment of the ad (0 = left, 1 = center, 2 = right, 3 = none), and the ‘margin’ attribute controls the margin around the ad, in pixels.
PHP Function Code
In case you have difficulties debugging what causing issues with [adsensei_ad]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'adsensei_ad', 'adsensei_shortcode_display_ad', 1); // Important use a very early priority to be able to count total ads accurate
Shortcode PHP function:
function adsensei_shortcode_display_ad( $atts ) {
global $adsensei_options;
// Display Condition is false and ignoreShortcodeCond is empty or not true
if( !adsensei_ad_is_allowed() && !isset($adsensei_options['ignoreShortcodeCond']) )
return;
//return adsensei_check_meta_setting('NoAds');
if( adsensei_check_meta_setting( 'NoAds' ) === '1' ){
return;
}
// The ad id
$id = isset( $atts['id'] ) ? ( int ) $atts['id'] : 0;
$ad_id = isset($adsensei_options['ads']['ad'.$id.'']) && $adsensei_options['ads']['ad'.$id.'']!==NULL ? (isset($adsensei_options['ads']['ad'.$id.'']['ad_id'])?$adsensei_options['ads']['ad'.$id.'']['ad_id']:NULL ): NULL ;
$arr = array(
'float:left;margin:%1$dpx %1$dpx %1$dpx 0;',
'float:none;margin:%1$dpx 0 %1$dpx 0;text-align:center;',
'float:right;margin:%1$dpx 0 %1$dpx %1$dpx;',
'float:none;margin:%1$dpx;');
$adsalign = isset($adsensei_options['ads']['ad' . $id]['align']) ? $adsensei_options['ads']['ad' . $id]['align'] : 3; // default
$adsmargin = isset( $adsensei_options['ads']['ad' . $id]['margin'] ) ? $adsensei_options['ads']['ad' . $id]['margin'] : '3'; // default
$margin = sprintf( $arr[( int ) $adsalign], $adsmargin );
$ad_checker = '';
// Removing duplicate db calls by saving function output in variable passing
$adsensei_ad_var = adsensei_get_ad( $id );
$ad_checker = $adsensei_ad_var ? $adsensei_ad_var : '' ;
if ( isset($ad_checker) ) {
if ( strpos( $ad_checker, 'adsensei-rotatorad')!==false) {
$margin = 'text-align: center';
}
}
else{
$margin = sprintf( $arr[( int ) $adsalign], $adsmargin );
}
// Do not create any inline style on AMP site
$style = !adsensei_is_amp_endpoint() ? apply_filters( 'adsensei_filter_margins', $margin, 'ad' . $id ) : '';
if(function_exists('adsensei_hide_markup') && adsensei_hide_markup()) {
$code = "\n" . '<div style="' . $style . '">' . "\n";
$code .= do_shortcode( $adsensei_ad_var );
$code .= '</div>' . "\n";
}else{
$idof_ad_id = '';
$idof_ad_id = $ad_id;
$code = "\n" . '<!-- WP ADSENSEI v. ' . ADSENSEI_VERSION . ' Shortcode Ad -->' . "\n" .
'<div class="adsensei-location adsensei-ad' . $idof_ad_id . '" id="adsensei-ad' . $idof_ad_id . '" style="' . $style . '">' . "\n";
$code .= do_shortcode( $adsensei_ad_var );
$code .= '</div>' . "\n";
}
return $code;
}
Code file location:
adsensei-b30/adsensei-b30/includes/shortcodes.php
Adsmonetizer [adsforwp] Shortcode
The Adsensei B30 shortcode is used to display ads on a WordPress site. It first checks if ad display is allowed and if the ‘NoAds’ setting is enabled. The shortcode then retrieves the ad ID from the attributes and queries the database for the ad details. It also gets the alignment and margin settings for the ad. Shortcode: [adsforwp] Finally, it generates the HTML code for the ad, applying the alignment, margin, and other settings, and returns this code to be displayed on the site. Shortcode: [adsforwp]
Shortcode: [adsforwp]
Parameters
Here is a list of all possible adsforwp shortcode parameters and attributes:
id
– It is the unique identifier for the specific ad you want to display.
Examples and Usage
Basic example – Display an ad by referencing its ID using the ‘adsforwp’ shortcode.
[adsforwp id=1 /]
Advanced examples
Display an ad by referencing its ID, and override the default alignment and margin settings from the adsensei options. This allows you to customize the appearance of the ad on a per-shortcode basis.
[adsforwp id=1 align=2 margin=5 /]
Display multiple ads by referencing their IDs. This can be useful if you want to display a group of ads together in a specific order.
[adsforwp id=1,2,3 /]
PHP Function Code
In case you have difficulties debugging what causing issues with [adsforwp]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('adsforwp', 'adsensei_from_adsforwp_manual_ads',1);
Shortcode PHP function:
function adsensei_from_adsforwp_manual_ads($atts ){
global $adsensei_options;
// Display Condition is false and ignoreShortcodeCond is empty or not true
if( !adsensei_ad_is_allowed() && !isset($adsensei_options['ignoreShortcodeCond']) )
return;
//return adsensei_check_meta_setting('NoAds');
if( adsensei_check_meta_setting( 'NoAds' ) === '1' ){
return;
}
// The ad id
$adsforwpid = isset( $atts['id'] ) ? ( int ) $atts['id'] : 0;
$args = array(
'post_type' => 'adsensei-ads',
'meta_key' => 'adsforwp_ads_id',
'meta_value' => $adsforwpid
);
$event_query = new WP_Query( $args );
if(!isset($event_query->post->ID)){
return '';
}
$adsensei_post_id =$event_query->post->ID;
$id_name = get_post_meta ( $adsensei_post_id, 'adsensei_ad_old_id', true );
$id_array = explode('ad', $id_name );
$id = $id_array[1];
$arr = array(
'float:left;margin:%1$dpx %1$dpx %1$dpx 0;',
'float:none;margin:%1$dpx 0 %1$dpx 0;text-align:center;',
'float:right;margin:%1$dpx 0 %1$dpx %1$dpx;',
'float:none;margin:%1$dpx;');
$adsalign = isset($adsensei_options['ads']['ad' . $id]['align']) ? $adsensei_options['ads']['ad' . $id]['align'] : 3; // default
$adsmargin = isset( $adsensei_options['ads']['ad' . $id]['margin'] ) ? $adsensei_options['ads']['ad' . $id]['margin'] : '3'; // default
$margin = sprintf( $arr[( int ) $adsalign], $adsmargin );
// Do not create any inline style on AMP site
$style = !adsensei_is_amp_endpoint() ? apply_filters( 'adsensei_filter_margins', $margin, 'ad' . $id ) : '';
$code =
"\n".'<div style="'.esc_html($style).'">'."\n".
do_shortcode(adsensei_get_ad($id)).
'</div>'. "\n";
return $code;
}
Code file location:
adsensei-b30/adsensei-b30/includes/template-functions.php
Adsmonetizer [null] Shortcode
The Adsensei-B30 plugin shortcode is used to integrate and display advertisements on your WordPress site. The shortcode is: [the_ad_placement]. This shortcode fetches ads from a specified location and places them in the desired part of your website. It also checks certain conditions like whether ad display is allowed or not. If not, it returns nothing. It also checks for ‘NoAds’ meta setting and returns nothing if it’s set to ‘1’. It dynamically creates ad placements based on the available advanced ads and fetches the ad corresponding to the given id. If no ad is found, it returns an empty string. It also applies specific styles to the ads based on the settings.
Shortcode: [null]
Parameters
Here is a list of all possible null shortcode parameters and attributes:
id
– unique identifier for the specific ad placement
Examples and Usage
Basic example – The following shortcode displays an ad placement by referencing the ad ID.
[the_ad_placement id=1 /]
Advanced examples
Displaying an ad placement by referencing multiple ad IDs. The ads will load by ID in the order they are listed.
[the_ad_placement id=1 id=2 id=3 /]
Using the shortcode to display multiple ad placements by referencing both ID and title. The ad placement will first try to load by ID, but if not found, it will try to load by title.
[the_ad_placement id=1 title="Ad Title" /]
PHP Function Code
In case you have difficulties debugging what causing issues with [null]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('the_ad_placement', 'adsensei_from_advance_manual_ads',1);
Shortcode PHP function:
function adsensei_from_advance_manual_ads($atts ){
global $adsensei_options;
// Display Condition is false and ignoreShortcodeCond is empty or not true
if( !adsensei_ad_is_allowed() && !isset($adsensei_options['ignoreShortcodeCond']) )
return;
//return adsensei_check_meta_setting('NoAds');
if( adsensei_check_meta_setting( 'NoAds' ) === '1' ){
return;
}
$id = '';
// The ad id
// $advance_ads_id = isset( $atts['id'] ) ? ( int ) $atts['id'] : 0;
$atts = is_array( $atts ) ? $atts : array();
$advance_ads_id = isset( $atts['id'] ) ? (string) $atts['id'] : '';
$advanced_ads_placements = get_option('advads-ads-placements');
$args = array(
'post_type' => 'advanced_ads',
'post_status' => 'publish'
);
$get_Advanced_Ads = get_posts($args);
foreach ($get_Advanced_Ads as $advanced_Ad) {
$name = 'shortcode_'.$advanced_Ad->ID;
$advanced_ads_placements[$name] = array('item' => 'ad_'.$advanced_Ad->ID,'advanced_ads'=>true);
}
foreach ($advanced_ads_placements as $key => $value) {
$idArray = (isset($value['item']) && !empty($value['item'])) ? explode('ad_', $value['item']) : array('1'=>'');
if($idArray['1'] == $advance_ads_id){
$id = $idArray['1'];
}
}
if(empty($id)){
return '';
}
$args = array(
'post_type' => 'adsensei-ads',
'meta_key' => 'advance_ads_id',
'meta_value' => $id
);
$event_query = new WP_Query( $args );
if(!isset($event_query->post->ID)){
return '';
}
$adsensei_post_id =$event_query->post->ID;
$id_name = get_post_meta ( $adsensei_post_id, 'adsensei_ad_old_id', true );
$id_array = explode('ad', $id_name );
$id = $id_array[1];
$arr = array(
'float:left;margin:%1$dpx %1$dpx %1$dpx 0;',
'float:none;margin:%1$dpx 0 %1$dpx 0;text-align:center;',
'float:right;margin:%1$dpx 0 %1$dpx %1$dpx;',
'float:none;margin:%1$dpx;');
$adsalign = isset($adsensei_options['ads']['ad' . $id]['align']) ? $adsensei_options['ads']['ad' . $id]['align'] : 3; // default
$adsmargin = isset( $adsensei_options['ads']['ad' . $id]['margin'] ) ? $adsensei_options['ads']['ad' . $id]['margin'] : '3'; // default
$margin = sprintf( $arr[( int ) $adsalign], $adsmargin );
// Do not create any inline style on AMP site
$style = !adsensei_is_amp_endpoint() ? apply_filters( 'adsensei_filter_margins', $margin, 'ad' . $id ) : '';
$code = "\n" . '<!-- WP ADSENSEI v. ' . ADSENSEI_VERSION . ' Shortcode Ad -->' . "\n" .
'<div class="adsensei-location adsensei-ad' . $id . '" id="adsensei-ad' . $id . '" style="' . $style . '">' . "\n";
$code .= do_shortcode( adsensei_get_ad( $id ) );
$code .= '</div>' . "\n";
return $code;
}
Code file location:
adsensei-b30/adsensei-b30/includes/template-functions.php
Adsmonetizer [adsenseivi] Shortcode
The Adsensei B30 plugin shortcode, ‘adsenseivi’, is designed to display ad content on your WordPress site. It checks if ads are enabled, if it’s not an AMP endpoint, and retrieves the ad code. The shortcode also considers the ad’s ID and implements a minimum width and height for the ad placement. If the ‘adsensei_hide_markup’ function is active, it hides the ad markup. Otherwise, it displays the ad with the assigned style and ID.
Shortcode: [adsenseivi]
Parameters
Here is a list of all possible adsenseivi shortcode parameters and attributes:
id
– specifies the unique identifier for the ad placement
Examples and Usage
Basic example – The shortcode is used to display an ad from the Adsensei plugin. The ad ID is specified as a parameter in the shortcode.
[adsenseivi id=1 /]
Advanced examples
Using the shortcode without any parameters will default to displaying the ad with an ID of 1.
[adsenseivi /]
Using the shortcode with a different ad ID. This will display the ad with the specified ID.
[adsenseivi id=2 /]
Using the shortcode with a non-integer ID will still default to displaying the ad with an ID of 1. This is because the ID is cast to an integer in the shortcode function.
[adsenseivi id="non-integer" /]
PHP Function Code
In case you have difficulties debugging what causing issues with [adsenseivi]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('adsenseivi', array($this, 'getShortcode'));
Shortcode PHP function:
function getShortcode($atts) {
global $adsensei_options;
if (!$this->token) {
return;
}
if (adsensei_check_meta_setting('NoAds') === '1') {
return;
}
if (adsensei_is_amp_endpoint()) {
return;
}
// The ad id
$id = isset($atts['id']) ? (int) $atts['id'] : 1;
$viad = $this->getAdCode();
$style = 'min-width:363px;min-height:363px;';
if(function_exists('adsensei_hide_markup') && adsensei_hide_markup() ) {
$code = '<div style="' . esc_html($style) . '">' . "\n";
$code .= "<script>";
$code .= do_shortcode($viad['ads'][1]['code']);
$code .= '</script>' . "\n";
$code .= '</div>' . "\n";
}else{
$code = "\n" . '<!-- WP ADSENSEI v. ' . ADSENSEI_VERSION . ' Shortcode vi ad -->' . "\n";
$code .= '<div class="adsensei-location' . esc_html($id) . '" id="adsensei-vi-ad' . esc_html($id) . '" style="' . esc_html($style) . '">' . "\n";
$code .= "<script>";
$code .= do_shortcode($viad['ads'][1]['code']);
$code .= '</script>' . "\n";
$code .= '</div>' . "\n";
}
return $code;
}
Code file location:
adsensei-b30/adsensei-b30/includes/vendor/vi/vi.php
Conclusion
Now that you’ve learned how to embed the Adsmonetizer Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.
Leave a Reply