PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.6.4
VikBooking Hotel Booking Engine & PMS v1.6.4
1.8.16 1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 All 37 releases
vikbooking / libraries / adapter / form / fields / menuitem.php

menuitem.php in VikBooking Hotel Booking Engine & PMS 1.6.4, at libraries/adapter/form/fields/menuitem.php

67 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package VikWP - Libraries
4 * @subpackage adapter.form
5 * @author E4J s.r.l.
6 * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved.
7 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
8 * @link https://vikwp.com
9 */
10
11 // No direct access
12 defined('ABSPATH') or die('No script kiddies please!');
13
14 JLoader::import('adapter.form.fields.list');
15
16 /**
17 * Form field class to handle dropdown fields containing
18 * the pages assigned to a specific shortcode of the plugin.
19 *
20 * @since 10.0
21 */
22 class JFormFieldMenuItem extends JFormFieldList
23 {
24 /**
25 * @override
26 * Method to get the data to be passed to the layout for rendering.
27 *
28 * @return array An associative array of display data.
29 */
30 public function getLayoutData()
31 {
32 $this->option = array();
33 $this->option[''] = '--';
34
35 if (!empty($this->prefix))
36 {
37 // set modowner with custom prefix
38 $this->modowner = $this->prefix;
39 }
40
41 /**
42 * Force the client path because we need to load the shortcodes model
43 * always from the back-end folder.
44 *
45 * An issue occurred since WP 5.8, after the refactoring of the widgets
46 * management page, where the client now results to be "site" in place
47 * of "admin".
48 *
49 * @since 10.1.34
50 */
51 $model = JModel::getInstance($this->modowner, 'shortcodes', 'admin');
52
53 if ($model)
54 {
55 foreach ($model->all() as $item)
56 {
57 if ($item->post_id)
58 {
59 $this->option[$item->post_id] = get_the_title($item->post_id) . " - {$item->type}";
60 }
61 }
62 }
63
64 return parent::getLayoutData();
65 }
66 }
67