1
|
|
|
<?php |
|
|
|
|
2
|
|
|
namespace LSX\Classes; |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* All the functions for setting up the theme. |
6
|
|
|
* |
7
|
|
|
* @package LSX |
8
|
|
|
* @author LightSpeed |
9
|
|
|
* @license GPL3 |
10
|
|
|
* @link |
11
|
|
|
* @copyright 2023 LightSpeed |
12
|
|
|
*/ |
13
|
|
|
class Frontend { |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Contructor |
17
|
|
|
*/ |
18
|
|
|
public function __construct() { |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Initiate our class. |
23
|
|
|
* |
24
|
|
|
* @return void |
25
|
|
|
*/ |
26
|
|
|
public function init() { |
27
|
|
|
// Styles and Scripts |
|
|
|
|
28
|
|
|
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) ); |
29
|
|
|
add_action( 'wp_enqueue_scripts', array( $this, 'yoast_faq_asset_files' ) ); |
30
|
|
|
add_action( 'wp_enqueue_scripts', array( $this, 'woo_asset_files' ) ); |
31
|
|
|
|
32
|
|
|
//Output on the frontend. |
|
|
|
|
33
|
|
|
add_filter( 'wpforms_frontend_form_data', array( $this, 'wpforms_match_button_block' ) ); |
34
|
|
|
add_filter( 'woocommerce_account_menu_items', array( $this, 'woocommerce_account_menu_items_fix' ), 10, 2 ); |
35
|
|
|
|
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Enqueues the frontend styles |
40
|
|
|
* |
41
|
|
|
* @return void |
42
|
|
|
*/ |
43
|
|
|
public function enqueue_styles() { |
44
|
|
|
wp_enqueue_style( 'lsx-styles', get_template_directory_uri() . '/style.css', array(), wp_get_theme()->get( 'Version' ) ); |
|
|
|
|
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Load the assets files for Yoast |
50
|
|
|
* |
51
|
|
|
* @return void |
52
|
|
|
*/ |
53
|
|
|
public function yoast_faq_asset_files() { |
54
|
|
|
if ( function_exists( 'wpseo_init' ) ) { |
55
|
|
|
wp_enqueue_style( 'lsx-yoast-faq-css', get_template_directory_uri() . '/assets/css/faq/style.css', array() ); |
|
|
|
|
56
|
|
|
wp_enqueue_script( 'lsx-yoast-faq-js', get_template_directory_uri() . '/assets/js/faq.js', array( "jquery" ), "1.0", true ); |
|
|
|
|
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Load the assets files for Yoast |
62
|
|
|
* |
63
|
|
|
* @return void |
64
|
|
|
*/ |
65
|
|
|
public function woo_asset_files() { |
66
|
|
|
if ( class_exists( 'woocommerce' ) ) { |
67
|
|
|
wp_enqueue_style( 'lsx-woo-css', get_template_directory_uri() . '/assets/css/woocommerce.css', array() ); |
|
|
|
|
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* WPForms submit button, match Gutenberg button block |
73
|
|
|
* |
74
|
|
|
* @param [type] $form_data |
|
|
|
|
75
|
|
|
* @return void |
|
|
|
|
76
|
|
|
*/ |
77
|
|
|
function wpforms_match_button_block( $form_data ) { |
|
|
|
|
78
|
|
|
$form_data['settings']['submit_class'] .= ' btn'; |
79
|
|
|
return $form_data; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
|
|
|
|
83
|
|
|
* Fixes the plural for the edit address my account menu. |
84
|
|
|
* |
85
|
|
|
* @return array |
86
|
|
|
*/ |
87
|
|
|
public function woocommerce_account_menu_items_fix( $items, $endpoints ) { |
|
|
|
|
88
|
|
|
if ( ! isset( $items['edit-address'] ) || '' !== $items['edit-address'] ) { |
89
|
|
|
return $items; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
if ( true === wc_shipping_enabled() ) { |
|
|
|
|
93
|
|
|
$items['edit-address'] = __( 'Addresses', 'woocommerce' ); |
94
|
|
|
} else { |
95
|
|
|
$items['edit-address'] = __( 'Address', 'woocommerce' ); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
return $items; |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|