| @@ -1,12 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @package FireBox |
| 4 | - * @version 1.0.0 Free | |
| 4 | + * @version 2.1.14 Free | |
| 5 | 5 | * |
| 6 | 6 | * @author FirePlugins <info@fireplugins.com> |
| 7 | 7 | * @link https://www.fireplugins.com |
| 8 | - * @copyright Copyright © 2021 FirePlugins All Rights Reserved | |
| 8 | + * @copyright Copyright © 2024 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; |
| @@ -67,13 +67,15 @@ | ||
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | - * Create a shortcode [fboxLoginShortcode] to print the WP Login Form | |
| 71 | + * Create a shortcode [fboxLoginForm] to print the WP Login Form | |
| 72 | 72 | * |
| 73 | + * @param array $attributes | |
| 74 | + * | |
| 73 | 75 | * @return void |
| 74 | 76 | */ |
| 75 | - public function fboxLoginFormShortcodeHandler($atts) | |
| 77 | + public function fboxLoginFormShortcodeHandler($attributes) | |
| 76 | 78 | { |
| 77 | 79 | if (is_user_logged_in()) |
| 78 | 80 | { |
| 79 | 81 | $factory = new \FPFramework\Base\Factory(); |
| @@ -90,14 +92,20 @@ | ||
| 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 | 95 | |
| 94 | - $show_forgot_password_link = isset($atts['show_forgot_link']) && $atts['show_forgot_link']; | |
| 96 | + $show_forgot_password_link = isset($attributes['show_forgot_link']) && $attributes['show_forgot_link']; | |
| 97 | + $redirect = isset($attributes['redirect']) ? $attributes['redirect'] : (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; | |
| 95 | 98 | |
| 96 | 99 | $args = [ |
| 97 | 100 | 'echo' => false, |
| 98 | 101 | 'remember' => true, |
| 99 | - 'redirect' => ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], | |
| 102 | + /** | |
| 103 | + * We can only redirect to local URLs due to WP using wp_safe_redirect. | |
| 104 | + * To redirect to external URLs, users need to hook on allowed_redirect_hosts and add their external URL hosts. | |
| 105 | + * Hook doc: https://developer.wordpress.org/reference/hooks/allowed_redirect_hosts/ | |
| 106 | + */ | |
| 107 | + 'redirect' => $redirect, | |
| 100 | 108 | 'form_id' => 'fboxLogin', |
| 101 | 109 | 'id_username' => 'user_login', |
| 102 | 110 | 'id_password' => 'user_pass', |
| 103 | 111 | 'id_remember' => 'rememberme', |
| @@ -126,13 +134,16 @@ | ||
| 126 | 134 | |
| 127 | 135 | /** |
| 128 | 136 | * Create a shortcode [fboxNavigationMenu] to print the navigation menu |
| 129 | 137 | * |
| 138 | + * @param array $attributes | |
| 139 | + * @param string $content | |
| 140 | + * | |
| 130 | 141 | * @return void |
| 131 | 142 | */ |
| 132 | - public function fboxNavigationMenuShortcodeHandler($atts, $content = null) | |
| 143 | + public function fboxNavigationMenuShortcodeHandler($attributes, $content = null) | |
| 133 | 144 | { |
| 134 | - extract(shortcode_atts( | |
| 145 | + $atts = shortcode_atts( | |
| 135 | 146 | [ |
| 136 | 147 | 'menu' => '', |
| 137 | 148 | 'container' => 'div', |
| 138 | 149 | 'container_class' => '', |
| @@ -147,29 +158,30 @@ | ||
| 147 | 158 | 'link_after' => '', |
| 148 | 159 | 'depth' => 0, |
| 149 | 160 | 'walker' => '', |
| 150 | 161 | 'theme_location' => '' |
| 151 | - ], $atts) | |
| 162 | + ], | |
| 163 | + $attributes, | |
| 164 | + 'fboxNavigationMenu' | |
| 152 | 165 | ); |
| 153 | 166 | |
| 154 | - | |
| 155 | 167 | return wp_nav_menu( |
| 156 | 168 | [ |
| 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, | |
| 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'], | |
| 163 | 175 | '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 | |
| 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'] | |
| 172 | 184 | ] |
| 173 | 185 | ); |
| 174 | 186 | } |
| 175 | 187 | } |