Code Duplication    Length = 16-16 lines in 2 locations

core/Field/Icon_Field.php 1 location

@@ 95-110 (lines=16) @@
92
	/**
93
	 * Check if there are callbacks and populate the options
94
	 */
95
	protected function load_options() {
96
		if ( empty( $this->options ) ) {
97
			return false;
98
		}
99
100
		if ( is_callable( $this->options ) ) {
101
			$options = call_user_func( $this->options );
102
			if ( ! is_array( $options ) ) {
103
				$options = array();
104
			}
105
		} else {
106
			$options = $this->options;
107
		}
108
109
		$this->options = $options;
110
	}
111
112
	/**
113
	 * Returns an array that holds the field data, suitable for JSON representation.

core/Field/Predefined_Options_Field.php 1 location

@@ 46-61 (lines=16) @@
43
	 *
44
	 * @param array|callable $options
45
	 */
46
	public function add_options( $options ) {
47
		if ( is_array( $options ) ) {
48
			$old_options = is_callable( $this->options ) ? array() : $this->options;
49
50
			if ( ! empty( $old_options ) ) {
51
				$this->options = array_merge( $old_options, $options );
52
			} else {
53
				$this->options = $options;
54
			}
55
		} else {
56
			$this->options = array();
57
			Incorrect_Syntax_Exception::raise( 'Only arrays are allowed in the <code>add_options()</code> method.' );
58
		}
59
60
		return $this;
61
	}
62
63
	/**
64
	 * Check if there are callbacks and populate the options