Skip to content

Commit 18d6667

Browse files
wpessentialMuhammad Umer
authored andcommitted
improvements
Signed-off-by: Muhammad Umer <mumer@updraftplus.com>
1 parent b90f555 commit 18d6667

35 files changed

Lines changed: 660 additions & 122 deletions

composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wpessential/wpessential-theme-module",
3-
"minimum-stability": "stable",
3+
"version" : "2.1",
44
"description": "Help to build the WP theme.",
55
"type": "library",
66
"license": "GPL-3.0-or-later",
@@ -9,13 +9,13 @@
99
"require": {
1010
"php" : ">=7.4",
1111
"ext-json" : "*",
12-
"wpessential/wpessential-commons": "^1.1.21",
13-
"wpessential/wpessential-images": "^2.0",
14-
"wpessential/wpessential-menus": "^2.0.2",
15-
"wpessential/wpessential-sidebars": "^2.0",
16-
"wpessential/wpessential-widgets": "^1.0.5",
12+
"wpessential/wpessential-commons": "^1.1.3",
13+
"wpessential/wpessential-images": "^2.0.1",
14+
"wpessential/wpessential-menus": "^2.0.3",
15+
"wpessential/wpessential-postypes": "^0.2.3",
16+
"wpessential/wpessential-sidebars": "^2.0.1",
1717
"wpessential/wpessential-theme-support": "^1.0.2",
18-
"wpessential/wpessential-postypes": "^0.2.2"
18+
"wpessential/wpessential-widgets": "^1.0.5"
1919
},
2020
"autoload": {
2121
"psr-4": {

inc/Constants.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ public static function constructor ()
3636
"{$theme_info->UcwordsNameHyphen}_T_VER" => $theme_info->Version,
3737
"{$theme_info->UcwordsNameHyphen}_T_DIR" => get_stylesheet_directory() . '/',
3838
"{$theme_info->UcwordsNameHyphen}_T_URI" => get_stylesheet_directory_uri() . '/',
39-
"{$theme_info->UpperNameHyphen}_T_VER" => $theme_info->Version,
40-
"{$theme_info->UpperNameHyphen}_T_DIR" => get_stylesheet_directory() . '/',
41-
"{$theme_info->UpperNameHyphen}_T_URI" => get_stylesheet_directory_uri() . '/',
39+
"{$theme_info->UpperNameHyphen}_T_VER" => $theme_info->Version,
40+
"{$theme_info->UpperNameHyphen}_T_DIR" => get_stylesheet_directory() . '/',
41+
"{$theme_info->UpperNameHyphen}_T_URI" => get_stylesheet_directory_uri() . '/',
4242
];
4343

4444
// Allow developers to filter and modify the constants.

inc/MenuWalker.php

Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
<?php
2+
3+
namespace WPEssential\Theme;
4+
5+
if ( ! \defined( 'ABSPATH' ) )
6+
{
7+
exit; // Exit if accessed directly.
8+
}
9+
10+
final class MenuWalker extends \Walker_Nav_Menu
11+
{
12+
13+
/**
14+
* Starts the element output.
15+
*
16+
* @param string $output Used to append additional content (passed by reference).
17+
* @param \WP_Post $data_object Menu item data object.
18+
* @param int $depth Depth of menu item. Used for padding.
19+
* @param \stdClass $args An object of wp_nav_menu() arguments.
20+
* @param int $current_object_id Optional. ID of the current menu item. Default 0.
21+
*
22+
* @since 3.0.0
23+
* @since 4.4.0 The {@see 'nav_menu_item_args'} filter was added.
24+
* @since 5.9.0 Renamed `$item` to `$data_object` and `$id` to `$current_object_id`
25+
* to match parent class for PHP 8 named parameter support.
26+
* @since 6.7.0 Removed redundant title attributes.
27+
*
28+
* @see Walker::start_el()
29+
*
30+
*/
31+
public function start_el ( &$output, $data_object, $depth = 0, $args = null, $current_object_id = 0 )
32+
{
33+
// Restores the more descriptive, specific name for use within this method.
34+
$menu_item = $data_object;
35+
36+
if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing )
37+
{
38+
$t = '';
39+
}
40+
else
41+
{
42+
$t = "\t";
43+
}
44+
$indent = ( $depth ) ? str_repeat( $t, $depth ) : '';
45+
46+
$classes = empty( $menu_item->classes ) ? [] : (array) $menu_item->classes;
47+
$classes[] = 'menu-item-' . $menu_item->ID;
48+
49+
/**
50+
* Filters the arguments for a single nav menu item.
51+
*
52+
* @param stdClass $args An object of wp_nav_menu() arguments.
53+
* @param \WP_Post $menu_item Menu item data object.
54+
* @param int $depth Depth of menu item. Used for padding.
55+
*
56+
* @since 4.4.0
57+
*
58+
*/
59+
$args = apply_filters( 'nav_menu_item_args', $args, $menu_item, $depth );
60+
61+
/**
62+
* Filters the CSS classes applied to a menu item's list item element.
63+
*
64+
* @param string[] $classes Array of the CSS classes that are applied to the menu item's `<li>` element.
65+
* @param \WP_Post $menu_item The current menu item object.
66+
* @param stdClass $args An object of wp_nav_menu() arguments.
67+
* @param int $depth Depth of menu item. Used for padding.
68+
*
69+
* @since 3.0.0
70+
* @since 4.1.0 The `$depth` parameter was added.
71+
*
72+
*/
73+
$class_names = implode( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $menu_item, $args, $depth ) );
74+
75+
/**
76+
* Filters the ID attribute applied to a menu item's list item element.
77+
*
78+
* @param string $menu_item_id The ID attribute applied to the menu item's `<li>` element.
79+
* @param \WP_Post $menu_item The current menu item.
80+
* @param stdClass $args An object of wp_nav_menu() arguments.
81+
* @param int $depth Depth of menu item. Used for padding.
82+
*
83+
* @since 3.0.1
84+
* @since 4.1.0 The `$depth` parameter was added.
85+
*
86+
*/
87+
$id = apply_filters( 'nav_menu_item_id', 'menu-item-' . $menu_item->ID, $menu_item, $args, $depth );
88+
89+
$li_atts = [];
90+
$li_atts[ 'id' ] = ! empty( $id ) ? $id : '';
91+
$li_atts[ 'class' ] = ! empty( $class_names ) ? $class_names : '';
92+
$li_atts[ 'class' ] .= ' wpe-fs-px-14 wpe-fw-medium wpe-position-rel';
93+
94+
/**
95+
* Filters the HTML attributes applied to a menu's list item element.
96+
*
97+
* @param array $li_atts {
98+
* The HTML attributes applied to the menu item's `<li>` element, empty strings are ignored.
99+
*
100+
* @type string $class HTML CSS class attribute.
101+
* @type string $id HTML id attribute.
102+
* }
103+
*
104+
* @param \WP_Post $menu_item The current menu item object.
105+
* @param stdClass $args An object of wp_nav_menu() arguments.
106+
* @param int $depth Depth of menu item. Used for padding.
107+
*
108+
* @since 6.3.0
109+
*
110+
*/
111+
$li_atts = apply_filters( 'nav_menu_item_attributes', $li_atts, $menu_item, $args, $depth );
112+
$li_attributes = $this->build_atts( $li_atts );
113+
114+
$output .= $indent . '<li' . $li_attributes . '>';
115+
116+
/** This filter is documented in wp-includes/post-template.php */
117+
$title = apply_filters( 'the_title', $menu_item->title, $menu_item->ID );
118+
119+
// Save filtered value before filtering again.
120+
$the_title_filtered = $title;
121+
122+
/**
123+
* Filters a menu item's title.
124+
*
125+
* @param string $title The menu item's title.
126+
* @param WP_Post $menu_item The current menu item object.
127+
* @param stdClass $args An object of wp_nav_menu() arguments.
128+
* @param int $depth Depth of menu item. Used for padding.
129+
*
130+
* @since 4.4.0
131+
*
132+
*/
133+
$title = apply_filters( 'nav_menu_item_title', $title, $menu_item, $args, $depth );
134+
135+
$atts = [];
136+
$atts[ 'target' ] = ! empty( $menu_item->target ) ? $menu_item->target : '';
137+
$atts[ 'rel' ] = ! empty( $menu_item->xfn ) ? $menu_item->xfn : '';
138+
139+
if ( ! empty( $menu_item->url ) )
140+
{
141+
if ( get_privacy_policy_url() === $menu_item->url )
142+
{
143+
$atts[ 'rel' ] = empty( $atts[ 'rel' ] ) ? 'privacy-policy' : $atts[ 'rel' ] . ' privacy-policy';
144+
}
145+
146+
$atts[ 'href' ] = $menu_item->url;
147+
}
148+
else
149+
{
150+
$atts[ 'href' ] = '';
151+
}
152+
153+
$atts[ 'aria-current' ] = $menu_item->current ? 'page' : '';
154+
155+
// Add title attribute only if it does not match the link text (before or after filtering).
156+
if ( ! empty( $menu_item->attr_title )
157+
&& trim( strtolower( $menu_item->attr_title ) ) !== trim( strtolower( $menu_item->title ) )
158+
&& trim( strtolower( $menu_item->attr_title ) ) !== trim( strtolower( $the_title_filtered ) )
159+
&& trim( strtolower( $menu_item->attr_title ) ) !== trim( strtolower( $title ) )
160+
)
161+
{
162+
$atts[ 'title' ] = $menu_item->attr_title;
163+
}
164+
else
165+
{
166+
$atts[ 'title' ] = '';
167+
}
168+
169+
/**
170+
* Filters the HTML attributes applied to a menu item's anchor element.
171+
*
172+
* @param array $atts {
173+
* The HTML attributes applied to the menu item's `<a>` element, empty strings are ignored.
174+
*
175+
* @type string $title Title attribute.
176+
* @type string $target Target attribute.
177+
* @type string $rel The rel attribute.
178+
* @type string $href The href attribute.
179+
* @type string $aria -current The aria-current attribute.
180+
* }
181+
*
182+
* @param WP_Post $menu_item The current menu item object.
183+
* @param stdClass $args An object of wp_nav_menu() arguments.
184+
* @param int $depth Depth of menu item. Used for padding.
185+
*
186+
* @since 3.6.0
187+
* @since 4.1.0 The `$depth` parameter was added.
188+
*
189+
*/
190+
$atts = apply_filters( 'nav_menu_link_attributes', $atts, $menu_item, $args, $depth );
191+
$attributes = $this->build_atts( $atts );
192+
193+
$item_output = $args->before;
194+
$item_output .= '<a' . $attributes . '>';
195+
$item_output .= $args->link_before . $title . $args->link_after;
196+
$item_output .= '</a>';
197+
$item_output .= $args->after;
198+
199+
/**
200+
* Filters a menu item's starting output.
201+
*
202+
* The menu item's starting output only includes `$args->before`, the opening `<a>`,
203+
* the menu item's title, the closing `</a>`, and `$args->after`. Currently, there is
204+
* no filter for modifying the opening and closing `<li>` for a menu item.
205+
*
206+
* @param string $item_output The menu item's starting HTML output.
207+
* @param WP_Post $menu_item Menu item data object.
208+
* @param int $depth Depth of menu item. Used for padding.
209+
* @param stdClass $args An object of wp_nav_menu() arguments.
210+
*
211+
* @since 3.0.0
212+
*
213+
*/
214+
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $menu_item, $depth, $args );
215+
}
216+
}

inc/Templates/CommentsTemplates.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public static function constructor ()
3838
*/
3939
public static function title ()
4040
{
41-
include wpe_template_load( 'templates/comment/title' );
41+
wpe_template_load( 'templates/comment/title', '', true, true );
4242
}
4343

4444
/**
@@ -48,7 +48,7 @@ public static function title ()
4848
*/
4949
public static function form ()
5050
{
51-
include wpe_template_load( 'templates/comment/form' );
51+
wpe_template_load( 'templates/comment/form', '', true, true );
5252
}
5353

5454
/**
@@ -58,7 +58,7 @@ public static function form ()
5858
*/
5959
public static function list ()
6060
{
61-
include wpe_template_load( 'templates/comment/list' );
61+
wpe_template_load( 'templates/comment/list', '', true, true );
6262
}
6363

6464
/**
@@ -68,7 +68,7 @@ public static function list ()
6868
*/
6969
public static function comments ()
7070
{
71-
include wpe_template_load( 'templates/comment/index' );
71+
wpe_template_load( 'templates/comment/index', '', true, true );
7272
}
7373

7474
/**
@@ -78,7 +78,7 @@ public static function comments ()
7878
*/
7979
public static function closed ()
8080
{
81-
include wpe_template_load( 'templates/comment/close' );
81+
wpe_template_load( 'templates/comment/close', '', true, true );
8282
}
8383

8484
/**
@@ -88,6 +88,6 @@ public static function closed ()
8888
*/
8989
public static function pagination ()
9090
{
91-
include wpe_template_load( 'templates/comment/pagination' );
91+
wpe_template_load( 'templates/comment/pagination', '', true, true );
9292
}
9393
}

inc/Templates/FooterTemplates.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ final class FooterTemplates
2323
*/
2424
public static function constructor ()
2525
{
26-
add_action( 'wpe_footer', [ __CLASS__, 'sidebar' ], 10 );
27-
add_action( 'wpe_footer', [ __CLASS__, 'menu' ], 20 );
28-
add_action( 'wpe_footer', [ __CLASS__, 'copyright' ], 30 );
2926
add_action( 'wp_footer', [ __CLASS__, 'footer' ], 0 );
27+
add_action( 'wpe_footer', [ __CLASS__, 'sidebar' ], 10 );
28+
add_action( 'wpe_footer_bottom', [ __CLASS__, 'copyright' ], 10 );
29+
add_action( 'wpe_footer_bottom', [ __CLASS__, 'menu' ], 20 );
3030
}
3131

3232
/**
@@ -36,7 +36,7 @@ public static function constructor ()
3636
*/
3737
public static function sidebar ()
3838
{
39-
include wpe_template_load( 'templates/footer/sidebar' );
39+
wpe_template_load( 'templates/footer/sidebar', '', true, true );
4040
}
4141

4242
/**
@@ -46,7 +46,7 @@ public static function sidebar ()
4646
*/
4747
public static function menu ()
4848
{
49-
include wpe_template_load( 'templates/footer/branding/menu' );
49+
wpe_template_load( 'templates/footer/branding/menu', '', true, true );
5050
}
5151

5252
/**
@@ -56,7 +56,7 @@ public static function menu ()
5656
*/
5757
public static function copyright ()
5858
{
59-
include wpe_template_load( 'templates/footer/branding/copyright' );
59+
wpe_template_load( 'templates/footer/branding/copyright', '', true, true );
6060
}
6161

6262
/**
@@ -66,6 +66,7 @@ public static function copyright ()
6666
*/
6767
public static function footer ()
6868
{
69-
include wpe_template_load( 'templates/footer/index' );
69+
wpe_template_load( 'templates/footer/index', '', true, true );
70+
wpe_template_load( 'templates/woo/cart', 'popup', true, true );
7071
}
7172
}

0 commit comments

Comments
 (0)