{"id":331,"date":"2023-10-20T15:39:42","date_gmt":"2023-10-20T15:39:42","guid":{"rendered":"https:\/\/wpshortcode.org\/?p=331"},"modified":"2023-10-20T15:39:43","modified_gmt":"2023-10-20T15:39:43","slug":"popup-builder","status":"publish","type":"post","link":"https:\/\/wpshortcode.org\/popup-builder\/","title":{"rendered":"Popup Builder Shortcode"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Below, you&#8217;ll find a detailed guide on how to add the <strong>Popup Builder Shortcode<\/strong> to your WordPress website, including its <strong>parameters<\/strong>, <strong>examples<\/strong>, and <strong>PHP function code<\/strong>. Additionally, we&#8217;ll assist you with common issues that might cause the Popup Builder Plugin shortcode not to show or not to work correctly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Before starting, here is an overview of the Popup Builder Plugin and the shortcodes it provides:<\/p>\n\n\n<p>    <div class=\"plugin-info-box\">\n        <div class=\"top-main\">\n            <!-- SVG Image -->\n            <div class=\"plugin-image\">\n                <img decoding=\"async\" src=\"https:\/\/ps.w.org\/popup-builder\/assets\/icon-128x128.gif?rev=2698840\" alt=\"Plugin Icon\" \/>\n            <\/div>\n            \n            <div class=\"plugin-descriptive-part\">\n                <!-- Plugin Name with Link -->\n\n                    <a class=\"plugin-title\" href=\"https:\/\/wordpress.org\/plugins\/popup-builder\" target=\"_blank\" rel=\"noopener\">\n                        Popup Builder &#8211; Create highly converting, mobile friendly marketing popups.                    <\/a>\n\n\n                <!-- Plugin Description -->\n                <p class=\"plugin-description\">\n                    &quot;Popup Builder is a dynamic WordPress plugin that lets you create mobile-friendly, high-converting marketing popups. Perfect for boosting your site&#039;s engagement and lead generation.&quot;                <\/p>\n            <\/div>\n        <\/div>\n\n        <!-- Rating and Additional Info -->\n        <div class=\"plugin-meta\">\n            <span class=\"plugin-rating\">\n                <span class='stars'>\u2605\u2605\u2605\u2605\u2606<\/span> (2121)\n            <\/span>\n            <span class=\"plugin-active-installs\">\n                <strong>Active Installs<\/strong>: 200000+\n            <\/span>\n            <span class=\"plugin-tested\">\n                <strong>Tested with<\/strong>: 6.1.4            <\/span>\n            <span class=\"plugin-php-version\">\n                <strong>PHP Version<\/strong>: 5.3.3            <\/span>\n        <\/div>\n\n        <!-- List of Included Shortcodes -->\n        <div class=\"plugin-shortcodes\">\n            <strong>Included Shortcodes:<\/strong>\n            <ul>\n                <li>[sg_popup]<\/li>            <\/ul>\n        <\/div>\n    <\/div>\n    <\/p>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Popup Builder [sg_popup] Shortcode<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The SG Popup shortcode is used to launch a popup with specific settings. This shortcode checks the popup&#8217;s ID, event type, and status before displaying it.\n\n\n\nThe PHP function &#8216;popupShortcode&#8217; first checks if the popup ID is valid. If not, it returns the original content. It then checks if the popup is active and retrieves its events and loadable modes.\n\nIf the &#8216;event&#8217; argument is not set or is &#8216;onload&#8217;, the function sets the event to &#8216;click&#8217;. If the &#8216;event&#8217; argument is &#8216;inherit&#8217;, the function uses the existing event settings. The function also supports the &#8216;insidepopup&#8217; event, which triggers the popup when the user clicks inside it.\n\nOnce the popup settings are finalized, the function loads the necessary scripts and renders the content within the popup. The content can include other shortcodes, which are also processed. The function then returns the final popup content.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Shortcode<\/strong>: <code>[sg_popup]<\/code><\/p>\n\n\n\n<div style=\"height:5px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Parameters<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Here is a list of all possible sg_popup shortcode parameters and attributes:<\/p>\n\n\n<ul>\n<li><code>id<\/code> &#8211; The unique identifier of the popup<\/li>\n<li><code>event<\/code> &#8211; Determines when the popup appears. Possible values: &#8216;onload&#8217;, &#8216;inherit&#8217;, or &#8216;insideclick&#8217;<\/li>\n<li><code>insidepopup<\/code> &#8211; When set, the popup will appear upon clicking inside the popup area<\/li>\n<\/ul>\n\n\n<div style=\"height:5px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Examples and Usage<\/h3>\n\n\n<p><strong>Basic example<\/strong> &#8211; The shortcode displays a popup by referencing its ID.<\/p>\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">[sg_popup id=1 \/]<\/code><\/pre>\n\n\n<p><strong>Advanced examples<\/strong><\/p>\n<p>The shortcode displays a popup by referencing its ID and event. This event can be &#8216;onload&#8217;, &#8216;inherit&#8217;, or other custom events.<\/p>\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">[sg_popup id=1 event=\"onload\" \/]<\/code><\/pre>\n\n\n<p>Another advanced example is using the shortcode to display a popup inside another popup by referencing both ID and the &#8216;insidepopup&#8217; attribute. This attribute helps to prevent an infinite loop of popups.<\/p>\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">[sg_popup id=1 insidepopup=true \/]<\/code><\/pre>\n\n\n<p>Lastly, you can also use the shortcode to display a popup by referencing its ID and custom events. The popup will first try to load by ID, but if not found, it will try to load by the event.<\/p>\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">[sg_popup id=1 event=\"customEvent\" \/]<\/code><\/pre>\n\n\n\n<div style=\"height:5px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">PHP Function Code<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In case you have difficulties debugging what causing issues with <code>[sg_popup]<\/code> shortcode, check below the related PHP functions code.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Shortcode line<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">add_shortcode('sg_popup', array($this, 'popupShortcode'));<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Shortcode PHP function<\/strong>:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; light: false; title: ; toolbar: true; notranslate\" title=\"\">\nfunction popupShortcode($args, $content)\n\t{\n\t\tif (empty($args) || empty($args&#91;&#039;id&#039;])) {\n\t\t\treturn $content;\n\t\t}\n\n\t\t$oldShortcode = isset($args&#91;&#039;event&#039;]) &amp;&amp; $args&#91;&#039;event&#039;] === &#039;onload&#039;;\n\t\t$isInherit = isset($args&#91;&#039;event&#039;]) &amp;&amp; $args&#91;&#039;event&#039;] == &#039;inherit&#039;;\n\t\t$event = &#039;&#039;;\n\n\t\t$shortcodeContent = &#039;&#039;;\n\t\t$argsId = $popupId = (int)$args&#91;&#039;id&#039;];\n\n\t\t\/\/ for old popups\n\t\tif (function_exists(&#039;sgpb\\sgpGetCorrectPopupId&#039;)) {\n\t\t\t$popupId = sgpGetCorrectPopupId($popupId);\n\t\t}\n\n\t\t$popup = SGPopup::find($popupId);\n\t\t$popup = apply_filters(&#039;sgpbShortCodePopupObj&#039;, $popup);\n\n\t\t$event = preg_replace(&#039;\/on\/&#039;, &#039;&#039;, (isset($args&#91;&#039;event&#039;]) ? $args&#91;&#039;event&#039;] : &#039;&#039;));\n\t\t\/\/ when popup does not exists or popup post status it&#039;s not publish ex when popup in trash\n\t\tif (empty($popup) || (!is_object($popup) &amp;&amp; $popup != &#039;publish&#039;)) {\n\t\t\treturn $content;\n\t\t}\n\n\t\t$isActive = $popup-&gt;isActive();\n\t\tif (!$isActive) {\n\t\t\treturn $content;\n\t\t}\n\n\t\t$alreadySavedEvents = $popup-&gt;getEvents();\n\t\t$loadableMode = $popup-&gt;getLoadableModes();\n\n\t\tif (!isset($args&#91;&#039;event&#039;]) &amp;&amp; isset($args&#91;&#039;insidepopup&#039;])) {\n\t\t\tunset($args&#91;&#039;insidepopup&#039;]);\n\t\t\t$event = &#039;insideclick&#039;;\n\t\t\t$insideShortcodeKey = $popupId.$event;\n\n\t\t\t\/\/ for prevent infinity chain\n\t\t\tif (is_array($this-&gt;insideShortcodes) &amp;&amp; in_array($insideShortcodeKey, $this-&gt;insideShortcodes)) {\n\t\t\t\t$shortcodeContent =  SGPopup::renderPopupContentShortcode($content, $argsId, $event, $args);\n\n\t\t\t\treturn $shortcodeContent;\n\t\t\t}\n\t\t\t$this-&gt;insideShortcodes&#91;] = $insideShortcodeKey;\n\t\t}\n\t\t\/\/ if no event attribute is set, or old shortcode\n\t\tif (!isset($args&#91;&#039;event&#039;]) || $oldShortcode || $isInherit) {\n\t\t\t$loadableMode = $popup-&gt;getLoadableModes();\n\t\t\tif (!empty($content)) {\n\t\t\t\t$alreadySavedEvents = false;\n\t\t\t}\n\t\t\t\/\/ for old popup, after the update, there aren&#039;t any events\n\t\t\tif (empty($alreadySavedEvents)) {\n\t\t\t\t$event = &#039;&#039;;\n\t\t\t\tif (!empty($content)) {\n\t\t\t\t\t$event = &#039;click&#039;;\n\t\t\t\t}\n\t\t\t\tif (!empty($args&#91;&#039;event&#039;])) {\n\t\t\t\t\t$event = $args&#91;&#039;event&#039;];\n\t\t\t\t}\n\t\t\t\t$event = preg_replace(&#039;\/on\/&#039;, &#039;&#039;, $event);\n\t\t\t\t$popup-&gt;setEvents(array($event));\n\t\t\t}\n\t\t\tif (empty($loadableMode)) {\n\t\t\t\t$loadableMode = array();\n\t\t\t}\n\t\t\t$loadableMode&#91;&#039;option_event&#039;] = true;\n\t\t}\n\t\telse {\n\t\t\t$event = $args&#91;&#039;event&#039;];\n\t\t\t$event = preg_replace(&#039;\/on\/&#039;, &#039;&#039;, $event);\n\t\t\t$popup-&gt;setEvents(array($event));\n\t\t}\n\n\t\t$popup-&gt;setLoadableModes($loadableMode);\n\n\t\t$groupObj = new PopupGroupFilter();\n\t\t$groupObj-&gt;setPopups(array($popup));\n\t\t$loadablePopups = $groupObj-&gt;filter();\n\t\t$scriptsLoader = new ScriptsLoader();\n\t\t$scriptsLoader-&gt;setLoadablePopups($loadablePopups);\n\t\t$scriptsLoader-&gt;loadToFooter();\n\n\t\tif (!empty($content)) {\n\t\t\t$matches = SGPopup::getPopupShortcodeMatchesFromContent($content);\n\t\t\tif (!empty($matches)) {\n\t\t\t\tforeach ($matches&#91;0] as $key =&gt; $value) {\n\t\t\t\t\t$attrs = shortcode_parse_atts($matches&#91;3]&#91;$key]);\n\t\t\t\t\tif (empty($attrs&#91;&#039;id&#039;])) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\t$shortcodeContent = SGPopup::renderPopupContentShortcode($content, $attrs&#91;&#039;id&#039;], $attrs&#91;&#039;event&#039;], $attrs);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (isset($event) &amp;&amp; $event != &#039;onload&#039; &amp;&amp; !empty($content)) {\n\t\t\t$shortcodeContent = SGPopup::renderPopupContentShortcode($content, $argsId, $event, $args);\n\t\t}\n\t\t$shortcodeContent = apply_filters(&#039;sgpbPopupShortCodeContent&#039;, $shortcodeContent);\n\n\t\treturn do_shortcode($shortcodeContent);\n\t}\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\"><strong>Code file location<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">popup-builder\/popup-builder\/com\/classes\/Actions.php<\/code><\/pre>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Now that you&#8217;ve learned how to embed the <strong>Popup Builder Plugin shortcode<\/strong>, understood the parameters, and seen code examples, it&#8217;s easy to use and debug any issue that might cause it to &#8216;not work&#8217;. If you still have difficulties with it, don&#8217;t hesitate to leave a comment below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Below, you&#8217;ll find a detailed guide on how to add the Popup Builder Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we&#8217;ll assist you with common issues that might cause the Popup Builder Plugin shortcode not to show or not to work correctly. Before starting, here is an overview [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"name":"Popup Builder &#8211; Create highly converting, mobile friendly marketing popups.","slug":"","version":"4.2.0","author":"<a href=\"https:\/\/popup-builder.com\">Looking Forward Software Incorporated.<\/a>","icons":"https:\/\/ps.w.org\/popup-builder\/assets\/icon-128x128.gif?rev=2698840","plugin_tags":"{\"exit-popup\":\"exit popup\",\"pop-up\":\"pop up\",\"popup\":\"popup\",\"popup-maker\":\"popup maker\",\"wordpress-popup\":\"wordpress popup\"}","author_profile":"https:\/\/profiles.wordpress.org\/popupbuilder\/","requires":"4.2","tested":"6.1.4","requires_php":"5.3.3","rating":96,"num_ratings":2121,"active_installs":200000,"downloaded":8988712,"last_updated":"2023-10-09 4:35pm GMT","added":"2015-05-30","homepage":"https:\/\/popup-builder.com","short_description":"Increase Sales, Lead Generation, Conversion rates and receive good Call to Action rates with smart WordPress popup plugin.","description":"\"Popup Builder is a dynamic WordPress plugin that lets you create mobile-friendly, high-converting marketing popups. Perfect for boosting your site's engagement and lead generation.\"","shortcodes":"[\"sg_popup\"]","footnotes":""},"categories":[1],"tags":[],"class_list":["post-331","post","type-post","status-publish","format-standard","hentry","category-plugins"],"_links":{"self":[{"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/posts\/331","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/comments?post=331"}],"version-history":[{"count":1,"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/posts\/331\/revisions"}],"predecessor-version":[{"id":332,"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/posts\/331\/revisions\/332"}],"wp:attachment":[{"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/media?parent=331"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/categories?post=331"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/tags?post=331"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}