PluginProbe
Responsive Menu – Mobile Menu & Hamburger Menu Builder / 4.7.4
Responsive Menu – Mobile Menu & Hamburger Menu Builder v4.7.4
4.7.4 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 All 91 releases
responsive-menu / v4.0.0 / inc / classes / class-option-manager.php

class-option-manager.php in Responsive Menu – Mobile Menu & Hamburger Menu Builder 4.7.4, at v4.0.0/inc/classes/class-option-manager.php

133 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * This file contain the Option_Manager class and it's functionalities.
4 *
5 * @version 4.0.0
6 * @author Expresstech System
7 *
8 * @package responsive-menu
9 */
10
11 namespace RMP\Features\Inc;
12
13 use RMP\Features\Inc\Traits\Singleton;
14 use responsive_menu_pro\frontend\RMP_Menu;
15
16 // Disable the direct access to this class.
17 if ( ! defined( 'ABSPATH' ) ) {
18 exit;
19 }
20
21 /**
22 * Class Option_Manager
23 * This class is responsible for provide the options for menu that
24 * maybe global or specific menu options.
25 *
26 * @version 4.0.0
27 */
28 class Option_Manager {
29
30 use Singleton;
31
32 /**
33 * Construct method.
34 */
35 protected function __construct() {
36 $this->setup_hooks();
37 }
38
39 /**
40 * To setup action/filter.
41 *
42 * @version 4.0.0
43 *
44 * @return void
45 */
46 protected function setup_hooks() {
47 }
48
49 /**
50 * This function get all options stored in rmp_menu post meta for menu.
51 *
52 * @access public
53 * @param int $menu_id Menu id
54 *
55 * @return array $options Array of backend setting options.
56 */
57 public function get_options( $menu_id ) {
58
59 $options = get_post_meta( $menu_id, 'rmp_menu_meta', true );
60 $options = is_array( $options ) ? $options : array();
61 $options['menu_id'] = $menu_id;
62 $default_options = rmp_get_default_options();
63 $options = array_replace( $default_options, $options );
64 if ( ! empty( $default_options['items_order'] ) ) {
65 $existing_items_order = ! empty( $options['items_order'] ) && is_array( $options['items_order'] ) ? $options['items_order'] : array();
66 $missing_items_order = array_diff_key( $default_options['items_order'], $existing_items_order );
67 $options['items_order'] = $existing_items_order + $missing_items_order;
68 }
69 return $options;
70 }
71
72 /**
73 * This function get all options stored in table for responsive menu.
74 *
75 * @access public
76 * @param int $menu_id Menu id
77 *
78 * @return array $options Array of backend setting options.
79 */
80 public function get_option( $menu_id, $key ) {
81
82 $options = $this->get_options( $menu_id );
83 $default_options = rmp_get_default_options();
84
85 if ( ! empty( $options[ $key ] ) ) {
86 return $options[ $key ];
87 } elseif ( ! empty( $default_options[ $key ] ) ) {
88 return $default_options[ $key ];
89 }
90 }
91
92 /**
93 * Return the global setting options.
94 *
95 * @version 4.0.0
96 * @access public
97 *
98 * @return array
99 */
100 public function get_global_options() {
101
102 $global_settings = get_option( 'rmp_global_setting_options' );
103
104 if ( ! empty( $global_settings ) ) {
105 return $global_settings;
106 }
107
108 return array();
109 }
110
111 /**
112 * Return global option
113 *
114 * @version 4.0.0
115 *
116 * @access public
117 * @param string $key Option name.
118 *
119 * @return string|null
120 */
121 public function get_global_option( $key ) {
122
123 $global_options = $this->get_global_options();
124
125 if ( ! empty( $global_options[ $key ] ) ) {
126 return $global_options[ $key ];
127 }
128
129 return;
130 }
131
132 }
133