PluginProbe
Responsive Menu – Create Mobile-Friendly Menu / 3.0.17
Responsive Menu – Create Mobile-Friendly Menu v3.0.17
4.7.3 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.10 4.1.11 4.1.12 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 All 90 releases
responsive-menu / src / app / ViewModels / Components / Admin / Boxes.php

Boxes.php in Responsive Menu – Create Mobile-Friendly Menu 3.0.17, at src/app/ViewModels/Components/Admin/Boxes.php

114 lines 5.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ResponsiveMenu\ViewModels\Components\Admin;
4 use ResponsiveMenu\Collections\OptionsCollection;
5 use ResponsiveMenu\Form;
6
7 class Boxes {
8
9 private $config;
10 private $options;
11 private $current_page;
12
13 public function __construct(array $config, OptionsCollection $options, $current_page) {
14 $this->config = $config;
15 $this->options = $options;
16 $this->current_page = $current_page;
17 }
18
19 public function render() {
20 $output = '';
21 foreach($this->config as $tab_name => $sub_menus):
22 $display = $this->i($tab_name) == $this->current_page ? 'block' : 'none';
23 $output .= '<div class="tab_container" id="tab_container_' . $this->i($tab_name) . '" style="display: ' . $display . ';">';
24 foreach($sub_menus as $sub_menu_name => $options):
25 $output .= '
26 <div class="postbox" id="postbox_' . $this->i($sub_menu_name).'">
27 <div class="handlediv">
28 <button aria-expanded="true" class="button-link" type="button">
29 <span class="screen-reader-text">' . __('Toggle panel: Location', 'responsive-menu') . '</span>
30 <span aria-hidden="true" class="toggle-indicator"></span>
31 </button>
32 </div> <!-- .handlediv -->
33 <h2 class="ui-sortable-handle hndle">' . $tab_name . ' &raquo; ' . $sub_menu_name . '</h2>
34 <div class="inside">
35 <table class="widefat">';
36 foreach($options as $option):
37 $pro = isset($option['pro']) ? 'pro_option' : '';
38 $semi_pro = isset($option['semi_pro']) ? 'semi_pro_option' : '';
39 $type = isset($option['type']) ? $option['type'] : null;
40 $unit = isset($option['unit']) ? '<span class="units">' . $option['unit'] . '</span>' : null;
41 $has_sub_options_class = isset($option['sub_options']) ? 'has-sub-options' : '';
42 $select = isset($option['select']) ? $option['select'] : null;
43 $output .= '<tr class="' . $pro . ' ' . $semi_pro . '" id="' . $option['option'] . '_container">
44 <td>
45 <div class="label">' . $option['title'] . '</div>
46 <span class="description">' . $option['label'] . '</span>';
47 $output .= isset($option['beta']) ? '<span class="beta">beta</span>' : '';
48 $output .= '</td>
49 <td class="' . $has_sub_options_class . '">';
50 $output .= $this->f($type, $option['option'], $select);
51 if(isset($option['sub_options']))
52 foreach($option['sub_options'] as $sub_option)
53 $output .= $this->f($sub_option['type'], $sub_option['option'], $sub_option['select']);
54 $output .= isset($option['pro']) ? '<a href="https://responsive.menu/why-go-pro/?utm_source=free-plugin&utm_medium=option&utm_campaign=free-plugin-option-upgrade" target="_blank" class="responsive-menu-pro-overlay"><div class="responsive-menu-pro-overlay-text">Click to upgrade now to use</div></a>' : '';
55 $output .= $unit . '</td>
56 </tr>';
57 endforeach;
58 $output .= '</table>
59 </div> <!-- .inside -->
60 </div> <!-- .postbox -->';
61 endforeach;
62 $output .= '</div> <!-- .tab_container -->';
63 endforeach;
64 return $output;
65 }
66
67 public function i($data) {
68 return strtolower(str_replace([' ', '/'], '_', $data));
69 }
70
71 public function f($type, $option_name, $select) {
72 switch($type):
73 case 'checkbox' : $comp = new Form\Checkbox;
74 return $comp->render($this->options[$option_name]);
75 break;
76 case 'colour' : $comp = new Form\Colour;
77 return $comp->render($this->options[$option_name]);
78 break;
79 case 'textarea' : $comp = new Form\TextArea;
80 return $comp->render($this->options[$option_name]);
81 break;
82 case 'select' : $comp = new Form\Select;
83 return $comp->render($this->options[$option_name], $select);
84 break;
85 case 'image' : $comp = new Form\Image;
86 return $comp->render($this->options[$option_name]);
87 break;
88 case 'menu_ordering' : $comp = new Form\MenuOrdering;
89 return $comp->render($this->options[$option_name]);
90 break;
91 case 'header_ordering' : $comp = new Form\HeaderBarOrdering;
92 return $comp->render($this->options[$option_name]);
93 break;
94 case 'fonticons' : $comp = new Form\FontIconPageList;
95 return $comp->render($this->options[$option_name]);
96 break;
97 case 'import' : $comp = new Form\Import;
98 return $comp->render();
99 break;
100 case 'export' : $comp = new Form\Export;
101 return $comp->render();
102 break;
103 case 'reset' : $comp = new Form\Reset;
104 return $comp->render();
105 break;
106 default : $comp = new Form\Text;
107 return $comp->render($this->options[$option_name]);
108 break;
109 endswitch;
110
111 }
112
113 }
114