Code Duplication    Length = 27-28 lines in 4 locations

classes/fields/color.php 1 location

@@ 72-99 (lines=28) @@
69
	/**
70
	 * {@inheritdoc}
71
	 */
72
	public function input( $name, $value = null, $options = null, $pod = null, $id = null ) {
73
74
		$options         = (array) $options;
75
		$form_field_type = PodsForm::$field_type;
76
77
		if ( is_array( $value ) ) {
78
			$value = implode( ' ', $value );
79
		}
80
81
		// WP Color Picker for 3.5+
82
		$field_type = 'color';
83
84
		if ( isset( $options['name'] ) && false === PodsForm::permission( static::$type, $options['name'], $options, null, $pod, $id ) ) {
85
			if ( pods_v( 'read_only', $options, false ) ) {
86
				$options['readonly'] = true;
87
88
				$field_type = 'text';
89
			} else {
90
				return;
91
			}
92
		} elseif ( ! pods_has_permissions( $options ) && pods_v( 'read_only', $options, false ) ) {
93
			$options['readonly'] = true;
94
95
			$field_type = 'text';
96
		}
97
98
		pods_view( PODS_DIR . 'ui/fields/' . $field_type . '.php', compact( array_keys( get_defined_vars() ) ) );
99
	}
100
101
	/**
102
	 * {@inheritdoc}

classes/fields/email.php 1 location

@@ 95-121 (lines=27) @@
92
	/**
93
	 * {@inheritdoc}
94
	 */
95
	public function input( $name, $value = null, $options = null, $pod = null, $id = null ) {
96
97
		$options         = (array) $options;
98
		$form_field_type = PodsForm::$field_type;
99
100
		if ( is_array( $value ) ) {
101
			$value = implode( ' ', $value );
102
		}
103
104
		$field_type = 'email';
105
106
		if ( isset( $options['name'] ) && false === PodsForm::permission( static::$type, $options['name'], $options, null, $pod, $id ) ) {
107
			if ( pods_v( 'read_only', $options, false ) ) {
108
				$options['readonly'] = true;
109
110
				$field_type = 'text';
111
			} else {
112
				return;
113
			}
114
		} elseif ( ! pods_has_permissions( $options ) && pods_v( 'read_only', $options, false ) ) {
115
			$options['readonly'] = true;
116
117
			$field_type = 'text';
118
		}
119
120
		pods_view( PODS_DIR . 'ui/fields/' . $field_type . '.php', compact( array_keys( get_defined_vars() ) ) );
121
	}
122
123
	/**
124
	 * {@inheritdoc}

classes/fields/phone.php 1 location

@@ 120-146 (lines=27) @@
117
	/**
118
	 * {@inheritdoc}
119
	 */
120
	public function input( $name, $value = null, $options = null, $pod = null, $id = null ) {
121
122
		$options         = (array) $options;
123
		$form_field_type = PodsForm::$field_type;
124
125
		if ( is_array( $value ) ) {
126
			$value = implode( ' ', $value );
127
		}
128
129
		$field_type = 'phone';
130
131
		if ( isset( $options['name'] ) && false === PodsForm::permission( static::$type, $options['name'], $options, null, $pod, $id ) ) {
132
			if ( pods_v( 'read_only', $options, false ) ) {
133
				$options['readonly'] = true;
134
135
				$field_type = 'text';
136
			} else {
137
				return;
138
			}
139
		} elseif ( ! pods_has_permissions( $options ) && pods_v( 'read_only', $options, false ) ) {
140
			$options['readonly'] = true;
141
142
			$field_type = 'text';
143
		}
144
145
		pods_view( PODS_DIR . 'ui/fields/' . $field_type . '.php', compact( array_keys( get_defined_vars() ) ) );
146
	}
147
148
	/**
149
	 * {@inheritdoc}

classes/fields/slug.php 1 location

@@ 81-107 (lines=27) @@
78
	/**
79
	 * {@inheritdoc}
80
	 */
81
	public function input( $name, $value = null, $options = null, $pod = null, $id = null ) {
82
83
		$options         = (array) $options;
84
		$form_field_type = PodsForm::$field_type;
85
86
		if ( is_array( $value ) ) {
87
			$value = implode( '-', $value );
88
		}
89
90
		$field_type = 'slug';
91
92
		if ( isset( $options['name'] ) && false === PodsForm::permission( static::$type, $options['name'], $options, null, $pod, $id ) ) {
93
			if ( pods_v( 'read_only', $options, false ) ) {
94
				$options['readonly'] = true;
95
96
				$field_type = 'text';
97
			} else {
98
				return;
99
			}
100
		} elseif ( ! pods_has_permissions( $options ) && pods_v( 'read_only', $options, false ) ) {
101
			$options['readonly'] = true;
102
103
			$field_type = 'text';
104
		}
105
106
		pods_view( PODS_DIR . 'ui/fields/' . $field_type . '.php', compact( array_keys( get_defined_vars() ) ) );
107
	}
108
109
	/**
110
	 * {@inheritdoc}