PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 3.1.14
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v3.1.14
3.1.14 3.1.13 3.1.12 3.1.11 3.1.10 3.1.9 3.1.8 3.1.7 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 All 123 releases
firebox / Inc / Framework / Inc / Helpers / MenuHelper.php

MenuHelper.php in FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment 3.1.14, at Inc/Framework/Inc/Helpers/MenuHelper.php

103 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package FirePlugins Framework
4 * @version 1.2.6
5 *
6 * @author FirePlugins <[email protected]>
7 * @link https://www.fireplugins.com
8 * @copyright Copyright © 2026 FirePlugins All Rights Reserved
9 * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
10 */
11
12 namespace FPFramework\Helpers;
13
14 if (!defined('ABSPATH'))
15 {
16 exit; // Exit if accessed directly.
17 }
18
19 class MenuHelper extends SearchDropdownProviderHelper
20 {
21 public function __construct($provider = null)
22 {
23 $this->class_name = 'Menu';
24
25 parent::__construct($provider);
26 }
27
28 /**
29 * Parses given data to a key,value array
30 *
31 * @param array $items
32 *
33 * @return array
34 */
35 public static function parseData($items)
36 {
37 $items = (array) $items;
38
39 if (empty($items))
40 {
41 return [];
42 }
43
44 $data = [];
45
46 foreach ($items as $key => $item)
47 {
48 if (!isset($item->id))
49 {
50 continue;
51 }
52
53 $data[] = [
54 'id' => $item->id,
55 'title' => $item->title,
56 'lang' => isset($item->lang) ? $item->lang : ''
57 ];
58 }
59
60 return $data;
61 }
62
63 /**
64 * Get the Menu ID by Post ID
65 *
66 * @param integer $post_id
67 *
68 * @return mixed
69 */
70 public static function getMenuIdByPostId($post_id)
71 {
72 if (!$post_id)
73 {
74 return false;
75 }
76
77 if (is_array($post_id) || is_object($post_id))
78 {
79 return false;
80 }
81
82 $post_id = (int) $post_id;
83
84 global $wpdb;
85
86 $sql = "SELECT
87 post_id
88 FROM
89 {$wpdb->prefix}postmeta
90 WHERE
91 meta_key = '_menu_item_object_id' AND
92 meta_value = '%d'";
93
94 $results = $wpdb->get_row($wpdb->prepare($sql, $post_id));// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
95
96 if (!$results)
97 {
98 return false;
99 }
100
101 return $results->post_id;
102 }
103 }