PluginProbe ʕ •ᴥ•ʔ
Secure Custom Fields / 6.8.5
Secure Custom Fields v6.8.5
6.9.1 6.9.0 6.8.9 6.8.7 6.8.8 6.8.6 6.8.4 6.8.5 trunk 6.4.0-beta1 6.4.0-beta2 6.4.1 6.4.1-beta3 6.4.1-beta4 6.4.1-beta5 6.4.1-beta6 6.4.1-beta7 6.4.2 6.5.0 6.5.1 6.5.2 6.5.3 6.5.4 6.5.5 6.5.6 6.5.7 6.6.0 6.7.0 6.7.1 6.8.0 6.8.1 6.8.2 6.8.3
secure-custom-fields / includes / locations / class-acf-location-nav-menu.php
secure-custom-fields / includes / locations Last commit date
abstract-acf-legacy-location.php 1 year ago abstract-acf-location.php 1 year ago class-acf-location-attachment.php 1 year ago class-acf-location-block.php 1 year ago class-acf-location-comment.php 1 year ago class-acf-location-current-user-role.php 1 year ago class-acf-location-current-user.php 1 year ago class-acf-location-nav-menu-item.php 1 year ago class-acf-location-nav-menu.php 1 year ago class-acf-location-options-page.php 1 year ago class-acf-location-page-parent.php 1 year ago class-acf-location-page-template.php 1 year ago class-acf-location-page-type.php 1 year ago class-acf-location-page.php 1 year ago class-acf-location-post-category.php 1 year ago class-acf-location-post-format.php 1 year ago class-acf-location-post-status.php 1 year ago class-acf-location-post-taxonomy.php 1 year ago class-acf-location-post-template.php 1 year ago class-acf-location-post-type.php 1 year ago class-acf-location-post.php 1 year ago class-acf-location-taxonomy.php 1 year ago class-acf-location-user-form.php 1 year ago class-acf-location-user-role.php 1 year ago class-acf-location-widget.php 1 year ago index.php 1 year ago
class-acf-location-nav-menu.php
102 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit; // Exit if accessed directly
5 }
6
7 if ( ! class_exists( 'ACF_Location_Nav_Menu' ) ) :
8
9 class ACF_Location_Nav_Menu extends ACF_Location {
10
11 /**
12 * Initializes props.
13 *
14 * @date 5/03/2014
15 * @since ACF 5.0.0
16 *
17 * @return void
18 */
19 public function initialize() {
20 $this->name = 'nav_menu';
21 $this->label = __( 'Menu', 'secure-custom-fields' );
22 $this->category = 'forms';
23 $this->object_type = 'menu';
24 }
25
26 /**
27 * Matches the provided rule against the screen args returning a bool result.
28 *
29 * @date 9/4/20
30 * @since ACF 5.9.0
31 *
32 * @param array $rule The location rule.
33 * @param array $screen The screen args.
34 * @param array $field_group The field group settings.
35 * @return boolean
36 */
37 public function match( $rule, $screen, $field_group ) {
38
39 // Check screen args.
40 if ( isset( $screen['nav_menu'] ) ) {
41 $nav_menu = $screen['nav_menu'];
42 } else {
43 return false;
44 }
45
46 // Allow for "location/xxx" rule value.
47 $bits = explode( '/', $rule['value'] );
48 if ( $bits[0] === 'location' ) {
49 $location = $bits[1];
50
51 // Get the map of menu locations [location => menu_id] and update $nav_menu to a location value.
52 $menu_locations = get_nav_menu_locations();
53 if ( isset( $menu_locations[ $location ] ) ) {
54 $rule['value'] = $menu_locations[ $location ];
55 }
56 }
57
58 // Compare rule against $nav_menu.
59 return $this->compare_to_rule( $nav_menu, $rule );
60 }
61
62 /**
63 * Returns an array of possible values for this rule type.
64 *
65 * @date 9/4/20
66 * @since ACF 5.9.0
67 *
68 * @param array $rule A location rule.
69 * @return array
70 */
71 public function get_values( $rule ) {
72 $choices = array(
73 'all' => __( 'All', 'secure-custom-fields' ),
74 );
75
76 // Append locations.
77 $nav_locations = get_registered_nav_menus();
78 if ( $nav_locations ) {
79 $cat = __( 'Menu Locations', 'secure-custom-fields' );
80 foreach ( $nav_locations as $slug => $title ) {
81 $choices[ $cat ][ "location/$slug" ] = $title;
82 }
83 }
84
85 // Append menu IDs.
86 $nav_menus = wp_get_nav_menus();
87 if ( $nav_menus ) {
88 $cat = __( 'Menus', 'secure-custom-fields' );
89 foreach ( $nav_menus as $nav_menu ) {
90 $choices[ $cat ][ $nav_menu->term_id ] = $nav_menu->name;
91 }
92 }
93
94 // Return choices.
95 return $choices;
96 }
97 }
98
99 // Register.
100 acf_register_location_type( 'ACF_Location_Nav_Menu' );
101 endif; // class_exists check
102