Below, you’ll find a detailed guide on how to add the Popup Anything On Click 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 Popup Anything On Click Plugin shortcodes not to show or not to work correctly.
Before starting, here is an overview of the Popup Anything On Click Plugin and the shortcodes it provides:
"Popup Anything – Popup for opt-ins and Lead Generation Conversions is a powerful WordPress plugin. It effortlessly creates interactive popups to boost user engagement and increase conversion rates."
- [paoc_details]
- [popup_anything]
Popup Anything On Click [paoc_details] Shortcode
The Popup Anything on Click (PAOC) shortcode is a flexible tool that allows you to display various types of information on your WordPress site. It uses the shortcode: [paoc_details]. This shortcode can display administrative email, site URL, site name, current page title, post excerpt, site logo, current date, time, year, and user details. It also has the capability to display query string values. The displayed content can be customized through the ‘display’ parameter. If this parameter is left empty, the shortcode will simply return the original content. All outputs are sanitized for safe usage.
Shortcode: [paoc_details]
Parameters
Here is a list of all possible null shortcode parameters and attributes:
display
– Determines the type of information to show in the popupdefault
– Default value to show if no ‘display’ value is setadmin_email
– Displays the admin’s email addresssite_url
– Shows the URL of the websitesite_name
– Displays the name of the websitepage_title
– Shows the title of the current pagepost_excerpt
– Shows the excerpt of the current page or postsite_logo
– Displays the logo of the websitedate_time
– Shows the current date and timedate
– Displays the current dateyear
– Shows the current yearuser_name
– Displays the username of the logged-in useruser_email
– Shows the email of the logged-in userkey_
– Displays the value of a query string key
Examples and Usage
Basic example – The following shortcode will display the admin email address.
[paoc_details display="admin_email" /]
Advanced examples
Displaying the site URL using the shortcode. If the ‘display’ attribute is set to ‘site_url’, the shortcode will return the site URL.
[paoc_details display="site_url" /]
Displaying the current page title using the shortcode. If the ‘display’ attribute is set to ‘page_title’, the shortcode will return the title of the current page.
[paoc_details display="page_title" /]
Displaying the current date and time using the shortcode. If the ‘display’ attribute is set to ‘date_time’, the shortcode will return the current date and time.
[paoc_details display="date_time" /]
Displaying the current user’s name using the shortcode. If the ‘display’ attribute is set to ‘user_name’, the shortcode will return the name of the current user.
[paoc_details display="user_name" /]
Displaying the current user’s email using the shortcode. If the ‘display’ attribute is set to ‘user_email’, the shortcode will return the email of the current user.
[paoc_details display="user_email" /]
Displaying a query string value using the shortcode. If the ‘display’ attribute is set to ‘key_{your_key}’, the shortcode will return the value of the query string with the specified key.
[paoc_details display="key_your_key" /]
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('paoc_details', 'popupaoc_details_shrt');
Shortcode PHP function:
function popupaoc_details_shrt( $atts, $content = null ) {
global $current_user;
// Shortcode Parameter
$atts = shortcode_atts(array(
'display' => '',
'default' => '',
), $atts, 'paoc_details');
// Taking some variable
$atts['display'] = ! empty( $atts['display'] ) ? $atts['display'] : '';
$atts['default'] = ! empty( $atts['default'] ) ? $atts['default'] : '';
extract( $atts );
// Return if `display` key is not there
if( empty( $display ) ) {
return $content;
}
ob_start();
// Display admin email address
if( $display == 'admin_email' ) {
$admin_email = get_option('admin_email');
echo esc_html( $admin_email );
} else if( $display == 'site_url' ) { // Display site URL
$site_url = get_option('siteurl');
echo wp_kses_post( $site_url );
} else if( $display == 'site_name' ) { // Display site name
$site_name = get_option('blogname');
echo wp_kses_post( $site_name );
} else if( $display == 'page_title' ) { // Display current page title
$page_title = get_the_title();
$page_title = ! empty( $page_title ) ? $page_title : $default;
echo wp_kses_post( $page_title );
} else if( $display == 'post_excerpt' ) { // Display current page OR post `excerpt`
$post_excerpt = get_the_excerpt();
echo wp_kses_post( $post_excerpt );
} else if( $display == 'site_logo' ) { // Display site logo
$site_logo = get_custom_logo();
echo wp_kses_post( $site_logo );
} else if( $display == 'date_time' ) { // Display current date & time
$default_date_format = get_option('date_format');
$default_time_format = get_option('time_format');
$date_format = ! empty( $default_date_format ) ? $default_date_format : 'Y-m-d';
$time_format = ! empty( $default_time_format ) ? $default_time_format : 'H:i:s';
$date_time = date_i18n( $date_format.' '.$time_format );
echo esc_html( $date_time );
} else if( $display == 'date' ) { // Display current date
$default_date_format = get_option( 'date_format' );
$date_format = ! empty( $default_date_format ) ? $default_date_format : 'Y-m-d';
$current_date = date_i18n( $date_format );
echo esc_html( $current_date );
} else if( $display == 'year' ) { // Display current year
echo esc_html( date_i18n('Y') );
} else if( $display == 'user_name' ) { // Display user name
// Taking some variable
$user_name = '';
$display_name = ! empty( $current_user->display_name ) ? $current_user->display_name : '';
$last_name = ! empty( $current_user->last_name ) ? $current_user->last_name : '';
$first_name = ! empty( $current_user->first_name ) ? $current_user->first_name : $display_name;
// If user `First Name` Or `Last Name` is there
if( ! empty( $first_name ) || ! empty( $last_name ) ) {
$user_name = $first_name .' '. $last_name;
} else if( $first_name ) {
$user_name = $first_name;
} else if( ! empty( $default ) ) {
$user_name = $default;
}
// Display Username
echo wp_kses_post( $user_name );
} else if( $display == 'user_email' ) { // Display user Email Address
// Taking some variable
$user_email = isset( $current_user->user_email ) ? $current_user->user_email : '';
echo wp_kses_post( $user_email );
} else if( strpos( $display, 'key_' ) !== false ) { // Display query string value
// Taking some variable
$key = str_replace( 'key_', '', $display );
$string_value = ! empty( $_GET[ $key ] ) ? popupaoc_clean( $_GET[ $key ] ) : $default;
echo wp_kses_post( $string_value );
}
$content .= ob_get_clean();
return $content;
}
Code file location:
popup-anything-on-click/popup-anything-on-click/includes/shortcode/paoc-details-shrt.php
Popup Anything On Click [popup_anything] Shortcode
The Popup Anything on Click shortcode enables you to create a popup for various elements like simple links, images, and buttons. Upon activation, it checks if the popup is enabled in the plugin settings. If not, it simply returns the content. It then validates the ID, post status, and post type. If any of these conditions fail, it returns the content. For each popup type (simple link, image, button), it retrieves specific parameters like link text, image URL, button text, etc. Finally, it includes the design HTML file and adds the popup to the content.
Shortcode: [popup_anything]
Parameters
Here is a list of all possible popup_anything shortcode parameters and attributes:
id
– The unique identifier of the popup content.
Examples and Usage
Basic example – A simple shortcode usage that triggers a popup with the specified ID.
[popup_anything id=123 /]
Advanced examples
Invoke a popup with a specific ID, and custom content within the shortcode tags. This will display the custom content if the popup with the specified ID is not found or not published.
[popup_anything id=123]Custom content goes here[/popup_anything]
Use the shortcode within PHP code. This is useful when you want to include the popup in your theme files. Make sure to replace 123 with your actual popup ID.
<?php echo do_shortcode('[popup_anything id=123]'); ?>
Include the shortcode within a text widget. This will make the popup appear when the text widget is clicked.
[popup_anything id=123]
Please note that the ID parameter in the shortcode represents the ID of the popup you want to trigger. You can find this ID in the list of popups in your WordPress admin area.
PHP Function Code
In case you have difficulties debugging what causing issues with [popup_anything]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'popup_anything', 'popupaoc_popup_shortcode' );
Shortcode PHP function:
function popupaoc_popup_shortcode( $atts, $content = null ) {
global $paoc_popup_data;
// Shortcode Parameter
$atts = shortcode_atts(array(
'id' => 0,
), $atts, 'popup_anything');
$atts['id'] = isset( $atts['id'] ) ? popupaoc_clean_number( $atts['id'] ) : false;
extract( $atts );
// Taking some variable
$prefix = POPUPAOC_META_PREFIX;
$enable = popupaoc_get_option( 'enable' );
// Return id popup is disabled from plugin settings
if( ! $enable ) {
return $content;
}
// Taking some variable
$post_status = popupaoc_get_post_status( $id );
$post_type = get_post_type( $id );
/* Timer ID is not there
* Timer post status is not publish
* Timer post type is not match
*/
if( empty( $id ) || $post_status != 'publish' || $post_type != POPUPAOC_POST_TYPE ) {
return $content;
}
// Taking some variables
$paoc_popup_data = ( ! empty( $paoc_popup_data ) && is_array( $paoc_popup_data ) ) ? $paoc_popup_data : array();
ob_start();
// Taking some variable
$unique = popupaoc_get_unique();
$popup_appear = get_post_meta( $id, $prefix.'popup_appear', true );
$behaviour = popupaoc_get_meta( $id, $prefix.'behaviour' );
// Assigning it into global var
$paoc_popup_data[ $id ]['popup_id'] = $id;
// If `Popup Appear` is `Simple Link`
if( $popup_appear == 'simple_link' ) {
$link_text = isset( $behaviour['link_text'] ) ? $behaviour['link_text'] : __('Click Me!!!', 'popup-anything-on-click');
}
// If `Popup Appear` is `Image Click`
if( $popup_appear == 'image' ) {
$image_url = isset( $behaviour['image_url'] ) ? $behaviour['image_url'] : '';
$popup_img_id = isset( $behaviour['popup_img_id'] ) ? $behaviour['popup_img_id'] : 0;
$show_img_title = ! empty( $behaviour['image_title'] ) ? 1 : 0;
$show_img_caption = ! empty( $behaviour['image_caption'] ) ? 1 : 0;
$image_title = '';
$image_caption = '';
$image_alt = '';
// Get Image `Title` & `Caption`
if( ! empty( $popup_img_id ) ) {
$image_data = get_post( $popup_img_id );
$image_title = $image_data->post_title;
$image_caption = $image_data->post_excerpt;
$image_alt = get_post_meta( $popup_img_id, '_wp_attachment_image_alt', true);
}
}
// If `Popup Appear` is `Button Click`
if( $popup_appear == 'button' ) {
$btn_text = isset( $behaviour['btn_text'] ) ? $behaviour['btn_text'] : __('Click Here!!!', 'popup-anything-on-click');
$button_class = isset( $behaviour['btn_class'] ) ? $behaviour['btn_class'] : '';
}
$design_file_path = POPUPAOC_DIR . '/templates/content.php';
$design_file_path = ( file_exists( $design_file_path ) ) ? $design_file_path : '';
// Include design html file
if( $design_file_path ) {
include( $design_file_path );
}
$content .= ob_get_clean();
return $content;
}
Code file location:
popup-anything-on-click/popup-anything-on-click/includes/shortcode/popupaoc-popup-shortcode.php
Conclusion
Now that you’ve learned how to embed the Popup Anything On Click 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