Code Duplication    Length = 18-19 lines in 2 locations

includes/class-meta-box-post-type.php 1 location

@@ 142-160 (lines=19) @@
139
		 *
140
		 * @since  0.0.1
141
		 */
142
		private function is_cmb2_allowed() {
143
144
			$cmb2_settings = get_option( '_cmb2_settings' );
145
146
			if ( empty( $cmb2_settings ) ) {
147
				// No settings saved.
148
				return true;
149
			}
150
151
			$current_user  = wp_get_current_user();
152
			$allowed_users = isset( $cmb2_settings['_cmb2_user_multicheckbox'] ) ? $cmb2_settings['_cmb2_user_multicheckbox'] : array();
153
154
			if ( empty( $allowed_users ) || in_array( $current_user->ID, $allowed_users, true ) ) {
155
156
				return true;
157
158
			}
159
			return false;
160
		}
161
162
		/**
163
		 * Pass each item in an array through strpos().

includes/class-meta-box.php 1 location

@@ 69-86 (lines=18) @@
66
		 *
67
		 * @since  0.0.1
68
		 */
69
		public function is_cmb2_allowed() {
70
71
			$cmb2_settings = get_option( '_cmb2_settings' );
72
73
			if ( empty( $cmb2_settings ) ) {
74
				// No settings saved.
75
				return true;
76
			}
77
78
			$current_user  = wp_get_current_user();
79
			$allowed_users = isset( $cmb2_settings['_cmb2_user_multicheckbox'] ) ? $cmb2_settings['_cmb2_user_multicheckbox'] : array();
80
81
			if ( empty( $allowed_users ) || in_array( $current_user->ID, $allowed_users, true ) ) {
82
83
				return true;
84
			}
85
			return false;
86
		}
87
88
		/**
89
		 * Only show CMB2 plugins to users defined in settings.