PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 1.0.10
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v1.0.10
3.1.13 3.1.12 3.1.11 3.1.10 3.1.9 3.1.8 3.1.7 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 All 122 releases
firebox / Inc / Core / Shortcodes / Shortcodes.php

Shortcodes.php in FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment 1.0.10, at Inc/Core/Shortcodes/Shortcodes.php

175 lines 5.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package FireBox
4 * @version 1.0.10 Free
5 *
6 * @author FirePlugins <info@fireplugins.com>
7 * @link https://www.fireplugins.com
8 * @copyright Copyright © 2022 FirePlugins All Rights Reserved
9 * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
10 */
11
12 namespace FireBox\Core\Shortcodes;
13
14 if (!defined('ABSPATH'))
15 {
16 exit; // Exit if accessed directly.
17 }
18
19 class Shortcodes
20 {
21 /**
22 * A list of shortcodes.
23 *
24 * To run shortcode: [loginForm]. i.e. [fboxLoginForm]
25 *
26 * @var array.
27 */
28 private $shortcodes = [
29 'LoginForm',
30 'NavigationMenu'
31 ];
32
33 /**
34 * Shortcodes prefix
35 *
36 * @var string
37 */
38 private $prefix = 'fbox';
39
40 public function __construct()
41 {
42 $this->addShortcodes();
43 }
44
45 /**
46 * Adds all shortcodes
47 *
48 * @return void
49 */
50 private function addShortcodes()
51 {
52 // redirect shortcodes
53 foreach ($this->shortcodes as $shortcode)
54 {
55 $shortcode = $this->prefix . $shortcode;
56
57 $method = $shortcode . 'ShortcodeHandler';
58
59 // make sure callback exists
60 if (!method_exists($this, $method))
61 {
62 continue;
63 }
64
65 // add shortcode
66 add_shortcode($shortcode, [$this, $method]);
67 }
68 }
69
70 /**
71 * Create a shortcode [fboxLoginShortcode] to print the WP Login Form
72 *
73 * @return void
74 */
75 public function fboxLoginFormShortcodeHandler($atts)
76 {
77 if (is_user_logged_in())
78 {
79 $factory = new \FPFramework\Base\Factory();
80 $user = $factory->getUser();
81
82 $firstname = $user->user_firstname;
83 $lastname = $user->user_lastname;
84
85 $sep = empty($lastname) ? '' : ' ';
86
87 $name = $firstname . $sep . $lastname;
88 $name = empty($name) ? $user->user_login : $name;
89
90 $str = '<p>' . fpframework()->_('FPF_HI') . ' ' . esc_attr($name) . ',</p><p><a href="' . wp_logout_url() . '" class="fb-btn fb-btn-primary fb-fullwidth">' . fpframework()->_('FPF_LOG_OUT') . '</a></p>';
91 return $str;
92 }
93
94 $show_forgot_password_link = isset($atts['show_forgot_link']) && $atts['show_forgot_link'];
95
96 $args = [
97 'echo' => false,
98 'remember' => true,
99 'redirect' => ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'],
100 'form_id' => 'fboxLogin',
101 'id_username' => 'user_login',
102 'id_password' => 'user_pass',
103 'id_remember' => 'rememberme',
104 'id_submit' => 'wp-submit',
105 'label_username' => firebox()->_('FB_USERNAME_OR_EMAIL_ADDRESS'),
106 'label_password' => fpframework()->_('FPF_PASSWORD'),
107 'label_remember' => fpframework()->_('FPF_REMEMBER_ME'),
108 'label_log_in' => fpframework()->_('FPF_LOG_IN'),
109 'value_username' => '',
110 'value_remember' => false
111 ];
112
113 $forgot_password_link = $show_forgot_password_link ? '<div class="form-actions"><a href="' . wp_lostpassword_url() . '">' . fpframework()->_('FPF_FORGOT_YOUR_PASSWORD') . '</a></div>' : '';
114
115 // load CSS
116 wp_enqueue_style(
117 'firebox-login-shortcode',
118 FBOX_MEDIA_PUBLIC_URL . 'css/shortcodes/login.css',
119 [],
120 FBOX_VERSION,
121 false
122 );
123
124 return wp_login_form($args) . $forgot_password_link;
125 }
126
127 /**
128 * Create a shortcode [fboxNavigationMenu] to print the navigation menu
129 *
130 * @return void
131 */
132 public function fboxNavigationMenuShortcodeHandler($atts, $content = null)
133 {
134 extract(shortcode_atts(
135 [
136 'menu' => '',
137 'container' => 'div',
138 'container_class' => '',
139 'container_id' => '',
140 'menu_class' => 'menu',
141 'menu_id' => '',
142 'echo' => true,
143 'fallback_cb' => 'wp_page_menu',
144 'before' => '',
145 'after' => '',
146 'link_before' => '',
147 'link_after' => '',
148 'depth' => 0,
149 'walker' => '',
150 'theme_location' => ''
151 ], $atts)
152 );
153
154
155 return wp_nav_menu(
156 [
157 'menu' => $menu,
158 'container' => $container,
159 'container_class' => $container_class,
160 'container_id' => $container_id,
161 'menu_class' => $menu_class,
162 'menu_id' => $menu_id,
163 'echo' => false,
164 'fallback_cb' => $fallback_cb,
165 'before' => $before,
166 'after' => $after,
167 'link_before' => $link_before,
168 'link_after' => $link_after,
169 'depth' => $depth,
170 'walker' => $walker,
171 'theme_location' => $theme_location
172 ]
173 );
174 }
175 }