Code Duplication    Length = 26-27 lines in 4 locations

classes/fields/color.php 1 location

@@ 108-134 (lines=27) @@
105
	 *
106
	 * @since 2.0
107
	 */
108
	public function input( $name, $value = null, $options = null, $pod = null, $id = null ) {
109
110
		$options         = (array) $options;
111
		$form_field_type = PodsForm::$field_type;
112
113
		if ( is_array( $value ) ) {
114
			$value = implode( ' ', $value );
115
		}
116
117
		// WP Color Picker for 3.5+
118
		$field_type = 'color';
119
120
		if ( isset( $options['name'] ) && false === PodsForm::permission( self::$type, $options['name'], $options, null, $pod, $id ) ) {
121
			if ( pods_v( 'read_only', $options, false ) ) {
122
				$options['readonly'] = true;
123
124
				$field_type = 'text';
125
			} else {
126
				return;
127
			}
128
		} elseif ( ! pods_has_permissions( $options ) && pods_v( 'read_only', $options, false ) ) {
129
			$options['readonly'] = true;
130
131
			$field_type = 'text';
132
		}
133
134
		pods_view( PODS_DIR . 'ui/fields/' . $field_type . '.php', compact( array_keys( get_defined_vars() ) ) );
135
	}
136
137
	/**

classes/fields/email.php 1 location

@@ 137-162 (lines=26) @@
134
	 *
135
	 * @since 2.0
136
	 */
137
	public function input( $name, $value = null, $options = null, $pod = null, $id = null ) {
138
139
		$options         = (array) $options;
140
		$form_field_type = PodsForm::$field_type;
141
142
		if ( is_array( $value ) ) {
143
			$value = implode( ' ', $value );
144
		}
145
146
		$field_type = 'email';
147
148
		if ( isset( $options['name'] ) && false === PodsForm::permission( self::$type, $options['name'], $options, null, $pod, $id ) ) {
149
			if ( pods_var( 'read_only', $options, false ) ) {
150
				$options['readonly'] = true;
151
152
				$field_type = 'text';
153
			} else {
154
				return;
155
			}
156
		} elseif ( ! pods_has_permissions( $options ) && pods_var( 'read_only', $options, false ) ) {
157
			$options['readonly'] = true;
158
159
			$field_type = 'text';
160
		}
161
162
		pods_view( PODS_DIR . 'ui/fields/' . $field_type . '.php', compact( array_keys( get_defined_vars() ) ) );
163
	}
164
165
	/**

classes/fields/phone.php 1 location

@@ 163-188 (lines=26) @@
160
	 *
161
	 * @since 2.0
162
	 */
163
	public function input( $name, $value = null, $options = null, $pod = null, $id = null ) {
164
165
		$options         = (array) $options;
166
		$form_field_type = PodsForm::$field_type;
167
168
		if ( is_array( $value ) ) {
169
			$value = implode( ' ', $value );
170
		}
171
172
		$field_type = 'phone';
173
174
		if ( isset( $options['name'] ) && false === PodsForm::permission( self::$type, $options['name'], $options, null, $pod, $id ) ) {
175
			if ( pods_var( 'read_only', $options, false ) ) {
176
				$options['readonly'] = true;
177
178
				$field_type = 'text';
179
			} else {
180
				return;
181
			}
182
		} elseif ( ! pods_has_permissions( $options ) && pods_var( 'read_only', $options, false ) ) {
183
			$options['readonly'] = true;
184
185
			$field_type = 'text';
186
		}
187
188
		pods_view( PODS_DIR . 'ui/fields/' . $field_type . '.php', compact( array_keys( get_defined_vars() ) ) );
189
	}
190
191
	/**

classes/fields/slug.php 1 location

@@ 114-139 (lines=26) @@
111
	 *
112
	 * @since 2.0
113
	 */
114
	public function input( $name, $value = null, $options = null, $pod = null, $id = null ) {
115
116
		$options         = (array) $options;
117
		$form_field_type = PodsForm::$field_type;
118
119
		if ( is_array( $value ) ) {
120
			$value = implode( '-', $value );
121
		}
122
123
		$field_type = 'slug';
124
125
		if ( isset( $options['name'] ) && false === PodsForm::permission( self::$type, $options['name'], $options, null, $pod, $id ) ) {
126
			if ( pods_var( 'read_only', $options, false ) ) {
127
				$options['readonly'] = true;
128
129
				$field_type = 'text';
130
			} else {
131
				return;
132
			}
133
		} elseif ( ! pods_has_permissions( $options ) && pods_var( 'read_only', $options, false ) ) {
134
			$options['readonly'] = true;
135
136
			$field_type = 'text';
137
		}
138
139
		pods_view( PODS_DIR . 'ui/fields/' . $field_type . '.php', compact( array_keys( get_defined_vars() ) ) );
140
	}
141
142
	/**