| @@ -1,12 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @package FireBox |
| 4 | - * @version 3.1.13 Free | |
| 4 | + * @version 2.0.10 Free | |
| 5 | 5 | * |
| 6 | 6 | * @author FirePlugins <info@fireplugins.com> |
| 7 | 7 | * @link https://www.fireplugins.com |
| 8 | - * @copyright Copyright © 2026 FirePlugins All Rights Reserved | |
| 8 | + * @copyright Copyright © 2023 FirePlugins All Rights Reserved | |
| 9 | 9 | * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | namespace FireBox\Core\Shortcodes; |
| @@ -20,16 +20,15 @@ | ||
| 20 | 20 | { |
| 21 | 21 | /** |
| 22 | 22 | * A list of shortcodes. |
| 23 | 23 | * |
| 24 | - * To run shortcode: [loginForm]. i.e. [firebox.LoginForm] | |
| 24 | + * To run shortcode: [loginForm]. i.e. [fboxLoginForm] | |
| 25 | 25 | * |
| 26 | 26 | * @var array. |
| 27 | 27 | */ |
| 28 | 28 | private $shortcodes = [ |
| 29 | - 'loginForm', | |
| 30 | - 'navigationMenu', | |
| 31 | - 'embed' | |
| 29 | + 'LoginForm', | |
| 30 | + 'NavigationMenu' | |
| 32 | 31 | ]; |
| 33 | 32 | |
| 34 | 33 | /** |
| 35 | 34 | * Shortcodes prefix |
| @@ -35,9 +34,9 @@ | ||
| 35 | 34 | * Shortcodes prefix |
| 36 | 35 | * |
| 37 | 36 | * @var string |
| 38 | 37 | */ |
| 39 | - private $prefix = 'firebox.'; | |
| 38 | + private $prefix = 'fbox'; | |
| 40 | 39 | |
| 41 | 40 | public function __construct() |
| 42 | 41 | { |
| 43 | 42 | $this->addShortcodes(); |
| @@ -49,31 +48,34 @@ | ||
| 49 | 48 | * @return void |
| 50 | 49 | */ |
| 51 | 50 | private function addShortcodes() |
| 52 | 51 | { |
| 53 | - // Backwards compatibility Start - We changed shortcode syntax in vesion 2.1.22 | |
| 54 | - add_shortcode('fbox' . ucfirst($this->shortcodes[0]), [$this, 'LoginForm']); | |
| 55 | - add_shortcode('fbox' . ucfirst($this->shortcodes[1]), [$this, 'NavigationMenu']); | |
| 56 | - // Backwards compatibility end | |
| 57 | - | |
| 58 | 52 | // redirect shortcodes |
| 59 | 53 | foreach ($this->shortcodes as $shortcode) |
| 60 | 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 | + | |
| 61 | 65 | // add shortcode |
| 62 | - $callback = ucfirst($shortcode); | |
| 63 | - $shortcode = $this->prefix . $shortcode; | |
| 64 | - add_shortcode($shortcode, [$this, $callback]); | |
| 66 | + add_shortcode($shortcode, [$this, $method]); | |
| 65 | 67 | } |
| 66 | 68 | } |
| 67 | 69 | |
| 68 | 70 | /** |
| 69 | - * Create a shortcode [firebox.loginForm] to print the WP Login Form | |
| 71 | + * Create a shortcode [fboxLoginForm] to print the WP Login Form | |
| 70 | 72 | * |
| 71 | 73 | * @param array $attributes |
| 72 | 74 | * |
| 73 | 75 | * @return void |
| 74 | 76 | */ |
| 75 | - public function LoginForm($attributes) | |
| 77 | + public function fboxLoginFormShortcodeHandler($attributes) | |
| 76 | 78 | { |
| 77 | 79 | if (is_user_logged_in()) |
| 78 | 80 | { |
| 79 | 81 | $factory = new \FPFramework\Base\Factory(); |
| @@ -89,14 +91,11 @@ | ||
| 89 | 91 | |
| 90 | 92 | $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 | 93 | return $str; |
| 92 | 94 | } |
| 93 | - | |
| 94 | - global $wp; | |
| 95 | - $currentUrl = add_query_arg((isset($_SERVER['QUERY_STRING']) ? sanitize_url(wp_unslash($_SERVER['QUERY_STRING'])) : ''), '', home_url( $wp->request ) ); | |
| 96 | 95 | |
| 97 | 96 | $show_forgot_password_link = isset($attributes['show_forgot_link']) && $attributes['show_forgot_link']; |
| 98 | - $redirect = isset($attributes['redirect']) ? esc_url_raw($attributes['redirect']) : $currentUrl; | |
| 97 | + $redirect = isset($attributes['redirect']) ? $attributes['redirect'] : (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; | |
| 99 | 98 | |
| 100 | 99 | $args = [ |
| 101 | 100 | 'echo' => false, |
| 102 | 101 | 'remember' => true, |
| @@ -133,9 +132,9 @@ | ||
| 133 | 132 | return wp_login_form($args) . $forgot_password_link; |
| 134 | 133 | } |
| 135 | 134 | |
| 136 | 135 | /** |
| 137 | - * Create a shortcode [firebox.navigationMenu] to print the navigation menu | |
| 136 | + * Create a shortcode [fboxNavigationMenu] to print the navigation menu | |
| 138 | 137 | * |
| 139 | 138 | * @param array $attributes |
| 140 | 139 | * @param string $content |
| 141 | 140 | * |
| @@ -140,9 +139,9 @@ | ||
| 140 | 139 | * @param string $content |
| 141 | 140 | * |
| 142 | 141 | * @return void |
| 143 | 142 | */ |
| 144 | - public function NavigationMenu($attributes, $content = null) | |
| 143 | + public function fboxNavigationMenuShortcodeHandler($attributes, $content = null) | |
| 145 | 144 | { |
| 146 | 145 | $atts = shortcode_atts( |
| 147 | 146 | [ |
| 148 | 147 | 'menu' => '', |
| @@ -160,53 +159,29 @@ | ||
| 160 | 159 | 'depth' => 0, |
| 161 | 160 | 'walker' => '', |
| 162 | 161 | 'theme_location' => '' |
| 163 | 162 | ], |
| 164 | - $attributes | |
| 163 | + $attributes, | |
| 164 | + 'fboxNavigationMenu' | |
| 165 | 165 | ); |
| 166 | 166 | |
| 167 | 167 | return wp_nav_menu( |
| 168 | 168 | [ |
| 169 | - 'menu' => sanitize_text_field($atts['menu']), | |
| 170 | - 'container' => sanitize_text_field($atts['container']), | |
| 171 | - 'container_class' => sanitize_html_class($atts['container_class']), | |
| 172 | - 'container_id' => sanitize_html_class($atts['container_id']), | |
| 173 | - 'menu_class' => sanitize_html_class($atts['menu_class']), | |
| 174 | - 'menu_id' => sanitize_html_class($atts['menu_id']), | |
| 169 | + 'menu' => $atts['menu'], | |
| 170 | + 'container' => $atts['container'], | |
| 171 | + 'container_class' => $atts['container_class'], | |
| 172 | + 'container_id' => $atts['container_id'], | |
| 173 | + 'menu_class' => $atts['menu_class'], | |
| 174 | + 'menu_id' => $atts['menu_id'], | |
| 175 | 175 | 'echo' => false, |
| 176 | - 'fallback_cb' => sanitize_text_field($atts['fallback_cb']), | |
| 177 | - 'before' => wp_kses_post($atts['before']), | |
| 178 | - 'after' => wp_kses_post($atts['after']), | |
| 179 | - 'link_before' => wp_kses_post($atts['link_before']), | |
| 180 | - 'link_after' => wp_kses_post($atts['link_after']), | |
| 181 | - 'depth' => absint($atts['depth']), | |
| 182 | - 'walker' => sanitize_text_field($atts['walker']), | |
| 183 | - 'theme_location' => sanitize_text_field($atts['theme_location']) | |
| 176 | + 'fallback_cb' => $atts['fallback_cb'], | |
| 177 | + 'before' => $atts['before'], | |
| 178 | + 'after' => $atts['after'], | |
| 179 | + 'link_before' => $atts['link_before'], | |
| 180 | + 'link_after' => $atts['link_after'], | |
| 181 | + 'depth' => $atts['depth'], | |
| 182 | + 'walker' => $atts['walker'], | |
| 183 | + 'theme_location' => $atts['theme_location'] | |
| 184 | 184 | ] |
| 185 | 185 | ); |
| 186 | - } | |
| 187 | - | |
| 188 | - /** | |
| 189 | - * Create a shortcode [firebox.embed id="X"] to display a FireBox campaign with mode = Embed. | |
| 190 | - * | |
| 191 | - * @param array $attributes | |
| 192 | - * @param string $content | |
| 193 | - * | |
| 194 | - * @return void | |
| 195 | - */ | |
| 196 | - public function Embed($attributes, $content = null) | |
| 197 | - { | |
| 198 | - $atts = shortcode_atts( | |
| 199 | - [ | |
| 200 | - 'id' => '' | |
| 201 | - ], | |
| 202 | - $attributes | |
| 203 | - ); | |
| 204 | - | |
| 205 | - if (!$atts['id']) | |
| 206 | - { | |
| 207 | - return; | |
| 208 | - } | |
| 209 | - | |
| 210 | - return \FireBox\Core\Helpers\Embed::renderCampaign(absint($atts['id'])); | |
| 211 | 186 | } |
| 212 | 187 | } |