Code Duplication    Length = 15-15 lines in 2 locations

wp-includes/functions.wp-scripts.php 1 location

@@ 106-120 (lines=15) @@
103
 *                         or after. Default 'after'.
104
 * @return bool True on success, false on failure.
105
 */
106
function wp_add_inline_script( $handle, $data, $position = 'after' ) {
107
	_wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );
108
109
	if ( false !== stripos( $data, '</script>' ) ) {
110
		_doing_it_wrong( __FUNCTION__, sprintf(
111
			/* translators: 1: <script>, 2: wp_add_inline_script() */
112
			__( 'Do not pass %1$s tags to %2$s.' ),
113
			'<code>&lt;script&gt;</code>',
114
			'<code>wp_add_inline_script()</code>'
115
		), '4.5.0' );
116
		$data = trim( preg_replace( '#<script[^>]*>(.*)</script>#is', '$1', $data ) );
117
	}
118
119
	return wp_scripts()->add_inline_script( $handle, $data, $position );
120
}
121
122
/**
123
 * Register a new script.

wp-includes/functions.wp-styles.php 1 location

@@ 83-97 (lines=15) @@
80
 * @param string $data   String containing the CSS styles to be added.
81
 * @return bool True on success, false on failure.
82
 */
83
function wp_add_inline_style( $handle, $data ) {
84
	_wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );
85
86
	if ( false !== stripos( $data, '</style>' ) ) {
87
		_doing_it_wrong( __FUNCTION__, sprintf(
88
			/* translators: 1: <style>, 2: wp_add_inline_style() */
89
			__( 'Do not pass %1$s tags to %2$s.' ),
90
			'<code>&lt;style&gt;</code>',
91
			'<code>wp_add_inline_style()</code>'
92
		), '3.7.0' );
93
		$data = trim( preg_replace( '#<style[^>]*>(.*)</style>#is', '$1', $data ) );
94
	}
95
96
	return wp_styles()->add_inline_style( $handle, $data );
97
}
98
99
/**
100
 * Register a CSS stylesheet.