Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808
Warning: foreach() argument must be of type array|object, string given in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 813
Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808
Warning: foreach() argument must be of type array|object, string given in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 813
Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808
PUM_Shortcode_Popup::handler( array $atts, string $content = null )
Shortcode handler
Description Description
Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808
Warning: foreach() argument must be of type array|object, string given in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 813
Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808
Warning: foreach() argument must be of type array|object, string given in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 813
Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808
Parameters Parameters
- $atts
-
(Required) shortcode attributes
- $content
-
(Optional) shortcode content
Default value: null
Return Return
(string)
Source Source
File: classes/Shortcode/Popup.php
public function handler( $atts, $content = null ) { global $popup; $atts = shortcode_atts( apply_filters( 'pum_popup_shortcode_default_atts', array( 'id' => "", 'title' => "", 'theme_id' => null, 'theme' => null, 'overlay_disabled' => 0, 'size' => "small", 'width' => "", 'width_unit' => "px", 'height' => "", 'height_unit' => "px", 'location' => "center top", 'position_top' => 100, 'position_left' => 0, 'position_bottom' => 0, 'position_right' => 0, 'position_fixed' => 0, 'animation_type' => "fade", 'animation_speed' => 1000, 'animation_origin' => 'top', 'overlay_click' => 0, 'esc_press' => 1, ) ), $atts, 'popup' ); // We need to fake a popup using the PUM_Popup data model. $post_id = rand( - 99999, - 1 ); // negative ID, to avoid clash with a valid post $post = new stdClass(); $post->ID = $post_id; $post->post_author = 1; $post->post_date = current_time( 'mysql' ); $post->post_date_gmt = current_time( 'mysql', 1 ); $post->post_title = $atts['title']; $post->post_content = $content; $post->post_status = 'publish'; $post->comment_status = 'closed'; $post->ping_status = 'closed'; $post->post_name = $atts['id']; // append random number to avoid clash $post->post_type = 'popup'; $post->filter = 'raw'; // important! $post->data_version = 3; $post->mock = true; // Convert to WP_Post object $wp_post = new WP_Post( $post ); // Add the fake post to the cache wp_cache_add( $post_id, $wp_post, 'posts' ); $popup = new PUM_Model_Popup( $wp_post ); // Get Theme ID if ( ! $atts['theme_id'] ) { $atts['theme_id'] = $atts['theme'] ? $atts['theme'] : pum_get_default_theme_id(); } $popup->title = $atts['title']; $popup->settings = array_merge( PUM_Admin_Popups::defaults(), array( 'disable_analytics' => true, 'theme_id' => $atts['theme_id'], 'size' => $atts['size'], 'overlay_disabled' => $atts['overlay_disabled'], 'custom_width' => $atts['width'], 'custom_width_unit' => $atts['width_unit'], 'custom_height' => $atts['height'], 'custom_height_unit' => $atts['height_unit'], 'custom_height_auto' => $atts['width'] > 0 ? 0 : 1, 'location' => $atts['location'], 'position_top' => $atts['position_top'], 'position_left' => $atts['position_left'], 'position_bottom' => $atts['position_bottom'], 'position_right' => $atts['position_right'], 'position_fixed' => $atts['position_fixed'], 'animation_type' => $atts['animation_type'], 'animation_speed' => $atts['animation_speed'], 'animation_origin' => $atts['animation_origin'], 'close_on_overlay_click' => $atts['overlay_click'], 'close_on_esc_press' => $atts['esc_press'], 'triggers' => array( array( 'type' => 'click_open', 'settings' => array( 'extra_selectors' => '#popmake-' . $atts['id'], ), ), ), ) ); $current_global_popup = pum()->current_popup; pum()->current_popup = $popup; $return = pum_get_template_part( 'popup' ); // Small hack to move popup to body. $return .= "<script type='text/javascript' id='pum-move-popup-" . $post_id . "'>jQuery(document).ready(function () { jQuery('#pum-" . $post_id . "').appendTo('body'); window.pum_vars.popups[ 'pum-" . $popup->ID . "' ] = " . PUM_Utils_Array::safe_json_encode( $popup->get_public_settings() ) . "; window.pum_popups[ 'pum-" . $popup->ID . "' ] = " . PUM_Utils_Array::safe_json_encode( $popup->get_public_settings() ) . "; jQuery('#pum-move-popup-" . $post_id . "').remove(); });</script>"; pum()->current_popup = $current_global_popup; return $return; }
Expand full source code Collapse full source code View on Trac