PluginProbe ʕ •ᴥ•ʔ
FrontBlocks for Gutenberg/GeneratePress / 1.3.3
FrontBlocks for Gutenberg/GeneratePress v1.3.3
trunk 0.2.0 0.2.1 0.2.2 0.2.3 0.2.4 0.2.5 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.1.0 1.2.0 1.2.1 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 ci-artifacts
frontblocks / includes / Frontend / BackButton.php
frontblocks / includes / Frontend Last commit date
Animations.php 4 months ago BackButton.php 7 months ago BlockPatterns.php 4 months ago Carousel.php 4 months ago ContainerEdgeAlignment.php 7 months ago Counter.php 4 months ago Events.php 6 months ago FluidTypography.php 4 months ago Gallery.php 8 months ago GravityFormsInline.php 7 months ago Headline.php 4 months ago InsertPost.php 8 months ago ProductCategories.php 8 months ago ReadingProgress.php 7 months ago ReadingTime.php 8 months ago ShapeAnimations.php 7 months ago StackedImages.php 4 months ago StickyColumn.php 8 months ago Testimonials.php 8 months ago
BackButton.php
89 lines
1 <?php
2 /**
3 * Back Button module for FrontBlocks.
4 *
5 * @package FrontBlocks
6 * @author Closemarketing
7 * @copyright 2025 Closemarketing
8 * @version 1.0
9 */
10
11 namespace FrontBlocks\Frontend;
12
13 defined( 'ABSPATH' ) || exit;
14
15 /**
16 * BackButton class.
17 *
18 * @since 1.0.0
19 */
20 class BackButton {
21
22 /**
23 * Constructor.
24 */
25 public function __construct() {
26 // Only load on frontend if enabled.
27 if ( ! is_admin() && $this->is_enabled() ) {
28 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_assets' ) );
29 add_action( 'wp_footer', array( $this, 'render_button' ) );
30 }
31 }
32
33 /**
34 * Check if back button is enabled.
35 *
36 * @return bool
37 */
38 private function is_enabled() {
39 $options = get_option( 'frontblocks_settings', array() );
40 return (bool) ( $options['enable_back_button'] ?? false );
41 }
42
43 /**
44 * Enqueue frontend assets.
45 *
46 * @return void
47 */
48 public function enqueue_assets() {
49 wp_enqueue_style(
50 'frontblocks-back-button',
51 FRBL_PLUGIN_URL . 'assets/back-button/frontblocks-back-button.css',
52 array(),
53 FRBL_VERSION
54 );
55
56 wp_enqueue_script(
57 'frontblocks-back-button',
58 FRBL_PLUGIN_URL . 'assets/back-button/frontblocks-back-button.js',
59 array(),
60 FRBL_VERSION,
61 true
62 );
63 }
64
65 /**
66 * Render the back button HTML.
67 *
68 * @return void
69 */
70 public function render_button() {
71 ?>
72 <button
73 id="frbl-back-button"
74 class="frbl-back-button"
75 aria-label="<?php echo esc_attr__( 'Go back to previous page', 'frontblocks' ); ?>"
76 title="<?php echo esc_attr__( 'Go back', 'frontblocks' ); ?>"
77 >
78 <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
79 <line x1="19" y1="12" x2="5" y2="12"></line>
80 <polyline points="12 19 5 12 12 5"></polyline>
81 </svg>
82 </button>
83 <?php
84 }
85 }
86
87 new BackButton();
88
89