' . PHP_EOL . PHP_EOL; $vars = func_get_args(); foreach ( $vars as $var ) { echo '
'; if ( is_scalar( $var ) || is_null( $var ) ) { var_dump( $var ); } else { echo PHP_EOL; print_r( $var ); echo PHP_EOL; } echo '' . PHP_EOL; } echo PHP_EOL . '
' . PHP_EOL; print_r( $backtrace ); echo PHP_EOL . '' . PHP_EOL; $html = ob_get_contents(); ob_end_clean(); if ( 'XMLHttpRequest' == __getHttpHeader( 'X_REQUESTED_WITH' ) ) { $html = str_replace( array( '
', ''), array( "\n", "\n", '' ), $html ); $html = str_replace( array( '
'; if ( is_scalar( $var ) || is_null( $var ) ) { var_dump( $var ); } else { print_r( $var ); } echo ''; } return true; } } if ( ! function_exists( 'sanitize_html_id' ) ) { function sanitize_html_id( $id ) { return str_replace( ['[', ']'], ['-', ''], $id ); } } if ( ! function_exists( 'esc_html_id' ) ) { function esc_html_id( $id ) { return esc_attr( sanitize_html_id( $id ) ); } } if ( ! function_exists( 'esc_html_id_e' ) ) { function esc_html_id_e($id) { echo esc_html_id($id); } } if ( ! function_exists( 'fqp_array_get' ) ) { function fqp_array_get( $array, $field, $default = null ) { $array = (array) $array; if ( false !== $field && null !== $field ) { if ( is_array( $field ) ) { $parts = $field; } else { $field = str_replace( ']', '', '' . $field ); $parts = explode( '[', $field ); } while ( null !== ( $name = array_shift( $parts ) ) ) { if ( ! is_array( $array ) || ! array_key_exists( $name, $array ) ) { return $default; } $array = $array[$name]; } } return $array; } } if ( ! function_exists( 'fqd_default ' ) ) { function fqp_default( $value, $default = '-' ) { return ( '' == $value ) ? $default : $value; } } if ( ! function_exists( 'fqp_money' ) ) { function fqp_money( $input, $decimals = 2 ) { $input = number_format( floatval( $input ), $decimals, '.', "'" ); return str_replace( '.00', '.-', $input ); } } if ( ! function_exists( 'fqp__' ) ) { function fqp__( $text, $text_domain = \FQP\FQP::TEXT_DOMAIN ) { return __( $text, $text_domain ); } } if ( ! function_exists( 'fqp_esc_html__' ) ) { function fqp_esc_html__( $text, $text_domain = \FQP\FQP::TEXT_DOMAIN ) { return esc_html__( $text, $text_domain ); } } if ( ! function_exists( 'fqp_esc_attr__' ) ) { function fqp_esc_attr__( $text, $text_domain = \FQP\FQP::TEXT_DOMAIN ) { return esc_attr__( $text, $text_domain ); } } if ( ! function_exists( 'fqp_list_hooks' ) ) { function fqp_list_hooks( $hook = '' ) { global $wp_filter; if ( isset( $wp_filter[$hook]->callbacks ) ) { array_walk( $wp_filter[$hook]->callbacks, function( $callbacks, $priority ) use ( &$hooks ) { foreach ( $callbacks as $id => $callback ) $hooks[] = array_merge( [ 'id' => $id, 'priority' => $priority ], $callback ); }); } else { return []; } foreach( $hooks as &$item ) { // skip if callback does not exist if ( !is_callable( $item['function'] ) ) continue; // function name as string or static class method eg. 'Foo::Bar' if ( is_string( $item['function'] ) ) { $ref = strpos( $item['function'], '::' ) ? new ReflectionClass( strstr( $item['function'], '::', true ) ) : new ReflectionFunction( $item['function'] ); $item['file'] = $ref->getFileName(); $item['line'] = get_class( $ref ) == 'ReflectionFunction' ? $ref->getStartLine() : $ref->getMethod( substr( $item['function'], strpos( $item['function'], '::' ) + 2 ) )->getStartLine(); // array( object, method ), array( string object, method ), array( string object, string 'parent::method' ) } elseif ( is_array( $item['function'] ) ) { $ref = new ReflectionClass( $item['function'][0] ); // $item['function'][0] is a reference to existing object $item['function'] = array( is_object( $item['function'][0] ) ? get_class( $item['function'][0] ) : $item['function'][0], $item['function'][1] ); $item['file'] = $ref->getFileName(); $item['line'] = strpos( $item['function'][1], '::' ) ? $ref->getParentClass()->getMethod( substr( $item['function'][1], strpos( $item['function'][1], '::' ) + 2 ) )->getStartLine() : $ref->getMethod( $item['function'][1] )->getStartLine(); // closures } elseif ( is_callable( $item['function'] ) ) { $ref = new ReflectionFunction( $item['function'] ); $item['function'] = get_class( $item['function'] ); $item['file'] = $ref->getFileName(); $item['line'] = $ref->getStartLine(); } } return $hooks; } } if ( ! function_exists( 'array_flatten' ) ) { function array_flatten( $array ) { if ( ! is_array( $array ) ) { // nothing to do if it's not an array return array( $array ); } $result = array(); foreach ( $array as $value ) { // explode the sub-array, and add the parts $result = array_merge( $result, array_flatten( $value ) ); } return $result; } }