PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.13
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.13
1.8.13.1 1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 All 212 releases
charitable / includes / utilities / class-charitable-walker-nav-menu-checklist.php

class-charitable-walker-nav-menu-checklist.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.13, at includes/utilities/class-charitable-walker-nav-menu-checklist.php

125 lines 5.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Charitable navigation menu walker.
4 *
5 * @package Charitable/Classes/Charitable_Nav_Menu_Walker
6 * @author David Bisset
7 * @copyright Copyright (c) 2023, WP Charitable LLC
8 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 * @since 1.6.29
10 * @version 1.6.29
11 */
12
13 // Exit if accessed directly.
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit;
16 }
17
18 /**
19 * Create a set of Charitable-specific links for use in the Menus admin UI.
20 *
21 * Borrowed heavily from {@link Walker_Nav_Menu_Checklist}, but modified so as not
22 * to require an actual post type or taxonomy, and to force certain CSS classes.
23 *
24 * @since 1.9.0
25 */
26 class Charitable_Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
27
28 /**
29 * Constructor.
30 *
31 * @see Walker_Nav_Menu::__construct() for a description of parameters.
32 *
33 * @since 1.6.29
34 *
35 * @param array|boolean $fields
36 */
37 public function __construct( $fields = false ) {
38 if ( $fields ) {
39 $this->db_fields = $fields;
40 }
41 }
42
43 /**
44 * Create the markup to start a tree level.
45 *
46 * @see Walker_Nav_Menu::start_lvl() for description of parameters.
47 *
48 * @since 1.6.29
49 *
50 * @param string $output See {@Walker_Nav_Menu::start_lvl()}.
51 * @param int $depth See {@Walker_Nav_Menu::start_lvl()}.
52 * @param array $args See {@Walker_Nav_Menu::start_lvl()}.
53 * @return void
54 */
55 public function start_lvl( &$output, $depth = 0, $args = array() ) {
56 $indent = str_repeat( "\t", $depth );
57 $output .= "\n$indent<ul class='children'>\n";
58 }
59
60 /**
61 * Create the markup to end a tree level.
62 *
63 * @see Walker_Nav_Menu::end_lvl() for description of parameters.
64 *
65 * @since 1.6.29
66 *
67 * @param string $output See {@Walker_Nav_Menu::end_lvl()}.
68 * @param int $depth See {@Walker_Nav_Menu::end_lvl()}.
69 * @param array $args See {@Walker_Nav_Menu::end_lvl()}.
70 */
71 public function end_lvl( &$output, $depth = 0, $args = array() ) {
72 $indent = str_repeat( "\t", $depth );
73 $output .= "\n$indent</ul>";
74 }
75
76 /**
77 * Create the markup to start an element.
78 *
79 * @see Walker::start_el() for description of parameters.
80 *
81 * @since 1.6.29
82 *
83 * @param string $output Passed by reference. Used to append additional
84 * content.
85 * @param object $item Menu item data object.
86 * @param int $depth Depth of menu item. Used for padding.
87 * @param object|array $args See {@Walker::start_el()}.
88 * @param int $id See {@Walker::start_el()}.
89 * @return void
90 */
91 function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
92 global $_nav_menu_placeholder;
93
94 $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1;
95 $possible_object_id = isset( $item->post_type ) && 'nav_menu_item' == $item->post_type ? $item->object_id : $_nav_menu_placeholder;
96 $possible_db_id = ( ! empty( $item->ID ) ) && ( 0 < $possible_object_id ) ? (int) $item->ID : 0;
97
98 $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
99
100 $output .= $indent . '<li>';
101 $output .= '<label class="menu-item-title">';
102 $output .= '<input type="checkbox" class="menu-item-checkbox';
103
104 if ( property_exists( $item, 'label' ) ) {
105 $title = $item->label;
106 }
107
108 $output .= '" name="menu-item[' . $possible_object_id . '][menu-item-object-id]" value="'. esc_attr( $item->object_id ) .'" /> ';
109 $output .= isset( $title ) ? esc_html( $title ) : esc_html( $item->title );
110 $output .= '</label>';
111
112 /* Menu item hidden fields. */
113 $output .= '<input type="hidden" class="menu-item-db-id" name="menu-item[' . $possible_object_id . '][menu-item-db-id]" value="' . $possible_db_id . '" />';
114 $output .= '<input type="hidden" class="menu-item-object" name="menu-item[' . $possible_object_id . '][menu-item-object]" value="'. esc_attr( $item->object ) .'" />';
115 $output .= '<input type="hidden" class="menu-item-parent-id" name="menu-item[' . $possible_object_id . '][menu-item-parent-id]" value="'. esc_attr( $item->menu_item_parent ) .'" />';
116 $output .= '<input type="hidden" class="menu-item-type" name="menu-item[' . $possible_object_id . '][menu-item-type]" value="custom" />';
117 $output .= '<input type="hidden" class="menu-item-title" name="menu-item[' . $possible_object_id . '][menu-item-title]" value="'. esc_attr( $item->title ) .'" />';
118 $output .= '<input type="hidden" class="menu-item-url" name="menu-item[' . $possible_object_id . '][menu-item-url]" value="'. esc_attr( $item->url ) .'" />';
119 $output .= '<input type="hidden" class="menu-item-target" name="menu-item[' . $possible_object_id . '][menu-item-target]" value="'. esc_attr( $item->target ) .'" />';
120 $output .= '<input type="hidden" class="menu-item-attr_title" name="menu-item[' . $possible_object_id . '][menu-item-attr_title]" value="'. esc_attr( $item->attr_title ) .'" />';
121 $output .= '<input type="hidden" class="menu-item-classes" name="menu-item[' . $possible_object_id . '][menu-item-classes]" value="'. esc_attr( implode( ' ', $item->classes ) ) .'" />';
122 $output .= '<input type="hidden" class="menu-item-xfn" name="menu-item[' . $possible_object_id . '][menu-item-xfn]" value="'. esc_attr( $item->xfn ) .'" />';
123 }
124 }
125