define('FIFU_AUTHOR', get_option('fifu_author') ? get_option('fifu_author') : 77777); add_filter('get_attached_file', 'fifu_replace_attached_file', 10, 2); function fifu_replace_attached_file($att_url, $att_id) { return fifu_process_url($att_url, $att_id); } function fifu_process_url($att_url, $att_id) { if (strpos($att_url, "https://thumbnails.odycdn.com") === 0 || strpos($att_url, "https://res.cloudinary.com") === 0 || strpos($att_url, "https://i0.wp.com") === 0 || strpos($att_url, "https://i1.wp.com") === 0 || strpos($att_url, "https://i2.wp.com") === 0 || strpos($att_url, "https://i3.wp.com") === 0) return $att_url; if (!$att_id) return $att_url; $att_post = get_post($att_id); if (!$att_post) return $att_url; // internal if ($att_post->post_author != FIFU_AUTHOR) return $att_url; $url = get_post_meta($att_id, '_wp_attached_file', true); // to avoid wp_get_attachment_url() infinite loop fifu_fix_legacy($url, $att_id); return fifu_process_external_url($url, $att_id, null); } function fifu_process_external_url($url, $att_id, $size) { return fifu_add_url_parameters($url, $att_id, $size); } function fifu_fix_legacy($url, $att_id) { if (strpos($url, ';') === false) return; $att_url = get_post_meta($att_id, '_wp_attached_file'); $att_url = is_array($att_url) ? $att_url[0] : $att_url; if (fifu_starts_with($att_url, ';http') || fifu_starts_with($att_url, ';/')) update_post_meta($att_id, '_wp_attached_file', $url); } add_filter('wp_get_attachment_url', 'fifu_replace_attachment_url', 10, 2); function fifu_replace_attachment_url($att_url, $att_id) { if ($att_url) return fifu_process_url($att_url, $att_id); return $att_url; } add_filter('posts_where', 'fifu_query_attachments'); function fifu_query_attachments($where) { global $wpdb; if (fifu_is_web_story() || (isset($_POST['action']) && ($_POST['action'] == 'query-attachments' || $_POST['action'] == 'get-attachment'))) $where .= ' AND ' . $wpdb->prefix . 'posts.post_author <> ' . FIFU_AUTHOR . ' '; return $where; } add_filter('posts_where', function ($where, \WP_Query $q) { global $wpdb; if (fifu_is_web_story() || (is_admin() && $q->is_main_query() && strpos($where, 'attachment') !== false)) $where .= ' AND ' . $wpdb->prefix . 'posts.post_author <> ' . FIFU_AUTHOR . ' '; return $where; }, 10, 2); add_filter('wp_get_attachment_image_src', 'fifu_replace_attachment_image_src', 10, 3); function fifu_replace_attachment_image_src($image, $att_id, $size) { if (!$image || !$att_id) return $image; $att_post = get_post($att_id); if (!$att_post) return $image; // internal if ($att_post->post_author != FIFU_AUTHOR) return $image; global $FIFU_SESSION; $prev_url = null; if (isset($FIFU_SESSION['cdn-new-old']) && isset($image[0]) && isset($FIFU_SESSION['cdn-new-old'][$image[0]])) $prev_url = $FIFU_SESSION['cdn-new-old'][$image[0]]; if (!isset($FIFU_SESSION['att_img_src'])) $FIFU_SESSION['att_img_src'] = array(); $image[0] = fifu_process_url($image[0], $att_id); $original_url = fifu_main_image_url(get_queried_object_id(), true); if (fifu_should_hide() && ($original_url == $image[0] || ($prev_url && $prev_url == $original_url))) { if (!in_array($original_url, $FIFU_SESSION['att_img_src'])) { $aux = is_array($size) ? implode(',', $size) : $size; $FIFU_SESSION['att_img_src'][] = $original_url . $aux; return null; } } $FIFU_SESSION['att_img_src'][] = $original_url; if (fifu_is_from_speedup($image[0])) $image = fifu_speedup_get_url($image, $size, $att_id); // photon if (fifu_is_on('fifu_photon') && !fifu_jetpack_blocked($image[0])) $image = fifu_get_photon_url($image, $size, $att_id); // fallback if ($image[1] == 1 && $image[2] == 1) { $image[1] = null; $image[2] = null; } return $image; } function fifu_add_size($image, $size) { // fix lightbox if ($size == 'woocommerce_single') return $image; if (!is_array($size)) { if (function_exists('wp_get_registered_image_subsizes')) { $width = null; $height = null; $crop = null; if (isset(wp_get_registered_image_subsizes()[$size]['width'])) $width = wp_get_registered_image_subsizes()[$size]['width']; if (isset(wp_get_registered_image_subsizes()[$size]['height'])) $height = wp_get_registered_image_subsizes()[$size]['height']; if (isset(wp_get_registered_image_subsizes()[$size]['crop'])) $crop = wp_get_registered_image_subsizes()[$size]['crop']; if (!$width && !$height) return $image; $image[1] = $width; $image[2] = $height == 9999 ? null : $height; $image[3] = $crop; } } else { $image[1] = $size[0]; $image[2] = $size[1]; } return $image; } function fifu_get_photon_url($image, $size, $att_id) { $image = fifu_add_size($image, $size); $w = $image[1]; $h = $image[2]; $args = array(); if ($w > 0 && $h > 0) { $args['resize'] = $w . ',' . $h; } elseif ($w > 0) { $args['resize'] = $w; $args['w'] = $w; } elseif ($h > 0) { $args['resize'] = $h; $args['h'] = $h; } else { } $image[0] = fifu_jetpack_photon_url($image[0], $args); $image[0] = fifu_process_external_url($image[0], $att_id, $size); return $image; } add_action('template_redirect', 'fifu_action', 10); function fifu_action() { ob_start("fifu_callback"); } function fifu_callback($buffer) { global $FIFU_SESSION; if (empty($buffer)) return; /* plugins: Oxygen, Bricks */ if (isset($_REQUEST['ct_builder']) || isset($_REQUEST['bricks']) || isset($_REQUEST['fb-edit'])) return $buffer; /* img */ $srcType = "src"; $imgList = array(); preg_match_all('/]*>/', $buffer, $imgList); foreach ($imgList[0] as $imgItem) { preg_match('/(' . $srcType . ')([^\'\"]*[\'\"]){2}/', $imgItem, $src); if (!$src) continue; $del = substr($src[0], - 1); $url = fifu_normalize(explode($del, $src[0])[1]); $post_id = null; // get parameters $data = null; if (isset($FIFU_SESSION[$url])) { $data = $FIFU_SESSION[$url]; } else { if (isset($FIFU_SESSION['cdn-new-old'][$url])) { $prev_url = $FIFU_SESSION['cdn-new-old'][$url]; if (isset($FIFU_SESSION[$prev_url])) { $data = $FIFU_SESSION[$prev_url]; } } } if (!$data) continue; if (strpos($imgItem, 'fifu-replaced') !== false) continue; $post_id = $data['post_id']; $att_id = $data['att_id']; $featured = $data['featured']; $is_category = $data['category']; $theme_width = isset($data['theme-width']) ? $data['theme-width'] : null; $theme_height = isset($data['theme-height']) ? $data['theme-height'] : null; if ($featured) { // add featured $newImgItem = str_replace(']*background-image[^>]*>/', $buffer, $imgList); foreach ($imgList[0] as $imgItem) { if (strpos($imgItem, 'style=') === false || strpos($imgItem, 'url(') === false) continue; $mainDelimiter = substr(explode('style=', str_replace('\\', '', $imgItem))[1], 0, 1); $subDelimiter = substr(explode('url(', str_replace('\\', '', $imgItem))[1], 0, 1); if (in_array($subDelimiter, array('"', "'", ' '))) $url = preg_split('/[\'\" ]{1}\)/', preg_split('/url\([\'\" ]{1}/', $imgItem, -1)[1], -1)[0]; else { $url = preg_split('/\)/', preg_split('/url\(/', $imgItem, -1)[1], -1)[0]; $subDelimiter = ''; } $newImgItem = $imgItem; $url = fifu_normalize($url); if (isset($FIFU_SESSION[$url])) { $data = $FIFU_SESSION[$url]; if (strpos($imgItem, 'fifu-replaced') !== false) continue; $att_id = $data['att_id']; $post_id = $data['post_id']; $newImgItem = str_replace('>', ' ' . 'post-id="' . $post_id . '">', $newImgItem); } if ($newImgItem != $imgItem) $buffer = str_replace($imgItem, $newImgItem, $buffer); } return $buffer; } add_filter('wp_get_attachment_metadata', 'fifu_filter_wp_get_attachment_metadata', 10, 2); function fifu_filter_wp_get_attachment_metadata($data, $att_id) { return $data; } function fifu_add_url_parameters($url, $att_id, $size) { global $FIFU_SESSION; // avoid duplicated call if (isset($FIFU_SESSION[$url])) return $url; $post_id = get_post($att_id)->post_parent; if (!$post_id) return $url; // "categories" page if (function_exists('get_current_screen') && isset(get_current_screen()->parent_file) && get_current_screen()->parent_file == 'edit.php?post_type=product' && get_current_screen()->id == 'edit-product_cat') return fifu_optimized_column_image($url); $post_thumbnail_id = get_post_thumbnail_id($post_id); $is_category = false; if (!$post_thumbnail_id) { $post_thumbnail_id = get_term_meta($post_id, 'thumbnail_id', true); if ($post_thumbnail_id) $is_category = true; } $featured = $post_thumbnail_id == $att_id ? 1 : 0; if (!$featured) return $url; // avoid duplicated call if (isset($FIFU_SESSION[$url])) return $url; $parameters = array(); $parameters['att_id'] = $att_id; $parameters['post_id'] = $post_id; $parameters['featured'] = $featured; $parameters['category'] = $is_category; // theme size if ($size && !is_array($size) && function_exists('wp_get_registered_image_subsizes')) { $width = null; $height = null; if (isset(wp_get_registered_image_subsizes()[$size]['width'])) $width = wp_get_registered_image_subsizes()[$size]['width']; if (isset(wp_get_registered_image_subsizes()[$size]['height'])) $height = wp_get_registered_image_subsizes()[$size]['height']; if ($width && $height) { $parameters['theme-width'] = $width; $parameters['theme-height'] = $height; } } $FIFU_SESSION[$url] = $parameters; if (fifu_is_from_speedup($url)) { $FIFU_SESSION['fifu-cloud'][$url] = fifu_speedup_get_set($url); wp_enqueue_script('fifu-cloud', plugins_url('/html/js/cloud.js', __FILE__), array('jquery'), fifu_version_number_enq()); wp_localize_script('fifu-cloud', 'fifuCloudVars', [ 'srcsets' => $FIFU_SESSION['fifu-cloud'], ]); } return $url; } function fifu_get_photon_args($w, $h) { $args = array(); if ($w > 0 && $h > 0) { $args['resize'] = $w . ',' . $h; } elseif ($w > 0) { $args['resize'] = $w; $args['w'] = $w; } elseif ($h > 0) { $args['resize'] = $h; $args['h'] = $h; } else { $args = null; } return $args; } function fifu_add_parameters_single_post($post_id) { $att_id = get_post_thumbnail_id($post_id); $url = get_post_meta($att_id, '_wp_attached_file', true); if ($url) fifu_add_url_parameters($url, $att_id, null); } // dont load remote image data in the media library when called from block editor function custom_get_attachment_intercept() { $att_id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; if ($att_id > 0) { if (fifu_is_remote_image($att_id)) { $response = array( 'success' => false, 'data' => array(), ); wp_die(); } } } add_action('wp_ajax_get-attachment', 'custom_get_attachment_intercept', 0);namespace Google\Site_Kit_Dependencies\GuzzleHttp\Psr7; use Google\Site_Kit_Dependencies\Psr\Http\Message\MessageInterface; use Google\Site_Kit_Dependencies\Psr\Http\Message\RequestInterface; use Google\Site_Kit_Dependencies\Psr\Http\Message\StreamInterface; use Google\Site_Kit_Dependencies\Psr\Http\Message\UriInterface; /** * Returns the string representation of an HTTP message. * * @param MessageInterface $message Message to convert to a string. * * @return string * * @deprecated str will be removed in guzzlehttp/psr7:2.0. Use Message::toString instead. */ function str(\Google\Site_Kit_Dependencies\Psr\Http\Message\MessageInterface $message) { return \Google\Site_Kit_Dependencies\GuzzleHttp\Psr7\Message::toString($message); } /** * Returns a UriInterface for the given value. * * This function accepts a string or UriInterface and returns a * UriInterface for the given value. If the value is already a * UriInterface, it is returned as-is. * * @param string|UriInterface $uri * * @return UriInterface * * @throws \InvalidArgumentException * * @deprecated uri_for will be removed in guzzlehttp/psr7:2.0. Use Utils::uriFor instead. */ function uri_for($uri) { return \Google\Site_Kit_Dependencies\GuzzleHttp\Psr7\Utils::uriFor($uri); } /** * Create a new stream based on the input type. * * Options is an associative array that can contain the following keys: * - metadata: Array of custom metadata. * - size: Size of the stream. * * This method accepts the following `$resource` types: * - `Psr\Http\Message\StreamInterface`: Returns the value as-is. * - `string`: Creates a stream object that uses the given string as the contents. * - `resource`: Creates a stream object that wraps the given PHP stream resource. * - `Iterator`: If the provided value implements `Iterator`, then a read-only * stream object will be created that wraps the given iterable. Each time the * stream is read from, data from the iterator will fill a buffer and will be * continuously called until the buffer is equal to the requested read size. * Subsequent read calls will first read from the buffer and then call `next` * on the underlying iterator until it is exhausted. * - `object` with `__toString()`: If the object has the `__toString()` method, * the object will be cast to a string and then a stream will be returned that * uses the string value. * - `NULL`: When `null` is passed, an empty stream object is returned. * - `callable` When a callable is passed, a read-only stream object will be * created that invokes the given callable. The callable is invoked with the * number of suggested bytes to read. The callable can return any number of * bytes, but MUST return `false` when there is no more data to return. The * stream object that wraps the callable will invoke the callable until the * number of requested bytes are available. Any additional bytes will be * buffered and used in subsequent reads. * * @param resource|string|int|float|bool|StreamInterface|callable|\Iterator|null $resource Entity body data * @param array $options Additional options * * @return StreamInterface * * @throws \InvalidArgumentException if the $resource arg is not valid. * * @deprecated stream_for will be removed in guzzlehttp/psr7:2.0. Use Utils::streamFor instead. */ function stream_for($resource = '', array $options = []) { return \Google\Site_Kit_Dependencies\GuzzleHttp\Psr7\Utils::streamFor($resource, $options); } /** * Parse an array of header values containing ";" separated data into an * array of associative arrays representing the header key value pair data * of the header. When a parameter does not contain a value, but just * contains a key, this function will inject a key with a '' string value. * * @param string|array $header Header to parse into components. * * @return array Returns the parsed header values. * * @deprecated parse_header will be removed in guzzlehttp/psr7:2.0. Use Header::parse instead. */ function parse_header($header) { return \Google\Site_Kit_Dependencies\GuzzleHttp\Psr7\Header::parse($header); } /** * Converts an array of header values that may contain comma separated * headers into an array of headers with no comma separated values. * * @param string|array $header Header to normalize. * * @return array Returns the normalized header field values. * * @deprecated normalize_header will be removed in guzzlehttp/psr7:2.0. Use Header::normalize instead. */ function normalize_header($header) { return \Google\Site_Kit_Dependencies\GuzzleHttp\Psr7\Header::normalize($header); } /** * Clone and modify a request with the given changes. * * This method is useful for reducing the number of clones needed to mutate a * message. * * The changes can be one of: * - method: (string) Changes the HTTP method. * - set_headers: (array) Sets the given headers. * - remove_headers: (array) Remove the given headers. * - body: (mixed) Sets the given body. * - uri: (UriInterface) Set the URI. * - query: (string) Set the query string value of the URI. * - version: (string) Set the protocol version. * * @param RequestInterface $request Request to clone and modify. * @param array $changes Changes to apply. * * @return RequestInterface * * @deprecated modify_request will be removed in guzzlehttp/psr7:2.0. Use Utils::modifyRequest instead. */ function modify_request(\Google\Site_Kit_Dependencies\Psr\Http\Message\RequestInterface $request, array $changes) { return \Google\Site_Kit_Dependencies\GuzzleHttp\Psr7\Utils::modifyRequest($request, $changes); } /** * Attempts to rewind a message body and throws an exception on failure. * * The body of the message will only be rewound if a call to `tell()` returns a * value other than `0`. * * @param MessageInterface $message Message to rewind * * @throws \RuntimeException * * @deprecated rewind_body will be removed in guzzlehttp/psr7:2.0. Use Message::rewindBody instead. */ function rewind_body(\Google\Site_Kit_Dependencies\Psr\Http\Message\MessageInterface $message) { \Google\Site_Kit_Dependencies\GuzzleHttp\Psr7\Message::rewindBody($message); } /** * Safely opens a PHP stream resource using a filename. * * When fopen fails, PHP normally raises a warning. This function adds an * error handler that checks for errors and throws an exception instead. * * @param string $filename File to open * @param string $mode Mode used to open the file * * @return resource * * @throws \RuntimeException if the file cannot be opened * * @deprecated try_fopen will be removed in guzzlehttp/psr7:2.0. Use Utils::tryFopen instead. */ function try_fopen($filename, $mode) { return \Google\Site_Kit_Dependencies\GuzzleHttp\Psr7\Utils::tryFopen($filename, $mode); } /** * Copy the contents of a stream into a string until the given number of * bytes have been read. * * @param StreamInterface $stream Stream to read * @param int $maxLen Maximum number of bytes to read. Pass -1 * to read the entire stream. * * @return string * * @throws \RuntimeException on error. * * @deprecated copy_to_string will be removed in guzzlehttp/psr7:2.0. Use Utils::copyToString instead. */ function copy_to_string(\Google\Site_Kit_Dependencies\Psr\Http\Message\StreamInterface $stream, $maxLen = -1) { return \Google\Site_Kit_Dependencies\GuzzleHttp\Psr7\Utils::copyToString($stream, $maxLen); } /** * Copy the contents of a stream into another stream until the given number * of bytes have been read. * * @param StreamInterface $source Stream to read from * @param StreamInterface $dest Stream to write to * @param int $maxLen Maximum number of bytes to read. Pass -1 * to read the entire stream. * * @throws \RuntimeException on error. * * @deprecated copy_to_stream will be removed in guzzlehttp/psr7:2.0. Use Utils::copyToStream instead. */ function copy_to_stream(\Google\Site_Kit_Dependencies\Psr\Http\Message\StreamInterface $source, \Google\Site_Kit_Dependencies\Psr\Http\Message\StreamInterface $dest, $maxLen = -1) { return \Google\Site_Kit_Dependencies\GuzzleHttp\Psr7\Utils::copyToStream($source, $dest, $maxLen); } /** * Calculate a hash of a stream. * * This method reads the entire stream to calculate a rolling hash, based on * PHP's `hash_init` functions. * * @param StreamInterface $stream Stream to calculate the hash for * @param string $algo Hash algorithm (e.g. md5, crc32, etc) * @param bool $rawOutput Whether or not to use raw output * * @return string Returns the hash of the stream * * @throws \RuntimeException on error. * * @deprecated hash will be removed in guzzlehttp/psr7:2.0. Use Utils::hash instead. */ function hash(\Google\Site_Kit_Dependencies\Psr\Http\Message\StreamInterface $stream, $algo, $rawOutput = \false) { return \Google\Site_Kit_Dependencies\GuzzleHttp\Psr7\Utils::hash($stream, $algo, $rawOutput); } /** * Read a line from the stream up to the maximum allowed buffer length. * * @param StreamInterface $stream Stream to read from * @param int|null $maxLength Maximum buffer length * * @return string * * @deprecated readline will be removed in guzzlehttp/psr7:2.0. Use Utils::readLine instead. */ function readline(\Google\Site_Kit_Dependencies\Psr\Http\Message\StreamInterface $stream, $maxLength = null) { return \Google\Site_Kit_Dependencies\GuzzleHttp\Psr7\Utils::readLine($stream, $maxLength); } /** * Parses a request message string into a request object. * * @param string $message Request message string. * * @return Request * * @deprecated parse_request will be removed in guzzlehttp/psr7:2.0. Use Message::parseRequest instead. */ function parse_request($message) { return \Google\Site_Kit_Dependencies\GuzzleHttp\Psr7\Message::parseRequest($message); } /** * Parses a response message string into a response object. * * @param string $message Response message string. * * @return Response * * @deprecated parse_response will be removed in guzzlehttp/psr7:2.0. Use Message::parseResponse instead. */ function parse_response($message) { return \Google\Site_Kit_Dependencies\GuzzleHttp\Psr7\Message::parseResponse($message); } /** * Parse a query string into an associative array. * * If multiple values are found for the same key, the value of that key value * pair will become an array. This function does not parse nested PHP style * arrays into an associative array (e.g., `foo[a]=1&foo[b]=2` will be parsed * into `['foo[a]' => '1', 'foo[b]' => '2'])`. * * @param string $str Query string to parse * @param int|bool $urlEncoding How the query string is encoded * * @return array * * @deprecated parse_query will be removed in guzzlehttp/psr7:2.0. Use Query::parse instead. */ function parse_query($str, $urlEncoding = \true) { return \Google\Site_Kit_Dependencies\GuzzleHttp\Psr7\Query::parse($str, $urlEncoding); } /** * Build a query string from an array of key value pairs. * * This function can use the return value of `parse_query()` to build a query * string. This function does not modify the provided keys when an array is * encountered (like `http_build_query()` would). * * @param array $params Query string parameters. * @param int|false $encoding Set to false to not encode, PHP_QUERY_RFC3986 * to encode using RFC3986, or PHP_QUERY_RFC1738 * to encode using RFC1738. * * @return string * * @deprecated build_query will be removed in guzzlehttp/psr7:2.0. Use Query::build instead. */ function build_query(array $params, $encoding = \PHP_QUERY_RFC3986) { return \Google\Site_Kit_Dependencies\GuzzleHttp\Psr7\Query::build($params, $encoding); } /** * Determines the mimetype of a file by looking at its extension. * * @param string $filename * * @return string|null * * @deprecated mimetype_from_filename will be removed in guzzlehttp/psr7:2.0. Use MimeType::fromFilename instead. */ function mimetype_from_filename($filename) { return \Google\Site_Kit_Dependencies\GuzzleHttp\Psr7\MimeType::fromFilename($filename); } /** * Maps a file extensions to a mimetype. * * @param $extension string The file extension. * * @return string|null * * @link http://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x/conf/mime.types * @deprecated mimetype_from_extension will be removed in guzzlehttp/psr7:2.0. Use MimeType::fromExtension instead. */ function mimetype_from_extension($extension) { return \Google\Site_Kit_Dependencies\GuzzleHttp\Psr7\MimeType::fromExtension($extension); } /** * Parses an HTTP message into an associative array. * * The array contains the "start-line" key containing the start line of * the message, "headers" key containing an associative array of header * array values, and a "body" key containing the body of the message. * * @param string $message HTTP request or response to parse. * * @return array * * @internal * * @deprecated _parse_message will be removed in guzzlehttp/psr7:2.0. Use Message::parseMessage instead. */ function _parse_message($message) { return \Google\Site_Kit_Dependencies\GuzzleHttp\Psr7\Message::parseMessage($message); } /** * Constructs a URI for an HTTP request message. * * @param string $path Path from the start-line * @param array $headers Array of headers (each value an array). * * @return string * * @internal * * @deprecated _parse_request_uri will be removed in guzzlehttp/psr7:2.0. Use Message::parseRequestUri instead. */ function _parse_request_uri($path, array $headers) { return \Google\Site_Kit_Dependencies\GuzzleHttp\Psr7\Message::parseRequestUri($path, $headers); } /** * Get a short summary of the message body. * * Will return `null` if the response is not printable. * * @param MessageInterface $message The message to get the body summary * @param int $truncateAt The maximum allowed size of the summary * * @return string|null * * @deprecated get_message_body_summary will be removed in guzzlehttp/psr7:2.0. Use Message::bodySummary instead. */ function get_message_body_summary(\Google\Site_Kit_Dependencies\Psr\Http\Message\MessageInterface $message, $truncateAt = 120) { return \Google\Site_Kit_Dependencies\GuzzleHttp\Psr7\Message::bodySummary($message, $truncateAt); } /** * Remove the items given by the keys, case insensitively from the data. * * @param iterable $keys * * @return array * * @internal * * @deprecated _caseless_remove will be removed in guzzlehttp/psr7:2.0. Use Utils::caselessRemove instead. */ function _caseless_remove($keys, array $data) { return \Google\Site_Kit_Dependencies\GuzzleHttp\Psr7\Utils::caselessRemove($keys, $data); }/** * Theme utils class */ class tagdiv_util { /** * reads a theme option from wp * @param $optionName * @param string $default_value * @return string|array */ static function get_option( $optionName, $default_value = '' ) { return tagdiv_options::get( $optionName, $default_value ); } /** * updates a theme option * @param $optionName * @param $newValue */ static function update_option( $optionName, $newValue ) { tagdiv_options::update( $optionName, $newValue ); } /** * @return bool returns true if the TagDiv Composer is installed */ static function tdc_is_installed() { if ( class_exists('tdc_state', false ) && function_exists( 'tdc_b64_decode' ) ) { return true; } return false; } /** * check if a theme plugin is active * * @param $plugin - the plugin td_config array * @return bool - true if active, false otherwise */ static function is_active( $plugin ) { $plugin_key = str_replace( '-', '_', strtoupper( $plugin['slug'] ) ); $td_plugins = tagdiv_global::get_td_plugins(); // check if it's a theme plugin if ( array_key_exists( $plugin_key, $td_plugins ) ) { if ( class_exists( $plugin['td_class'], false ) ) { return true; } elseif ( $plugin['slug'] === 'td-mobile-plugin' ) { if ( ( defined('TD_MOBILE_PLUGIN') || has_action( 'admin_notices', 'td_mobile_msg' ) ) ) { return true; } } elseif ( $plugin['slug'] === 'amp' ) { if ( self::is_amp_plugin_installed() ) { return true; } } return false; } elseif ( strpos($plugin_key, 'TD_DEMO_') !== false ) { if ( class_exists( $plugin['td_class'], false ) ) { return true; } } return false; } /** * Checks if the default AMP WP plugin is installed * @return bool true if AMP is installed( and it's not the old tagdiv amp plugin ) */ static function is_amp_plugin_installed() { if ( defined('AMP__VERSION') && ! defined('TD_AMP') ) { return true; } return false; } } /** * mbstring support - if missing from host */ if ( !function_exists('mb_strlen') ) { function mb_strlen ( $string, $encoding = '' ) { return strlen( $string ); } } if ( !function_exists('mb_strpos') ) { function mb_strpos( $haystack, $needle, $offset=0 ) { return strpos( $haystack, $needle, $offset ); } } if ( !function_exists('mb_strrpos') ) { function mb_strrpos ( $haystack, $needle, $offset=0 ) { return strrpos( $haystack, $needle, $offset ); } } if ( !function_exists('mb_strtolower') ) { function mb_strtolower( $string ) { return strtolower( $string ); } } if ( !function_exists('mb_strtoupper') ) { function mb_strtoupper( $string ){ return strtoupper( $string ); } } if ( !function_exists('mb_substr') ) { function mb_substr( $string, $start, $length, $encoding = '' ) { return substr( $string, $start, $length ); } } if ( !function_exists('mb_detect_encoding' ) ) { function mb_detect_encoding( $string, $enc=null, $ret=null ) { static $enclist = array( 'UTF-8', 'ASCII', 'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3', 'ISO-8859-4', 'ISO-8859-5', 'ISO-8859-6', 'ISO-8859-7', 'ISO-8859-8', 'ISO-8859-9', 'ISO-8859-10', 'ISO-8859-13', 'ISO-8859-14', 'ISO-8859-15', 'ISO-8859-16', 'Windows-1251', 'Windows-1252', 'Windows-1254', ); $result = false; foreach ( $enclist as $enc_type ) { $sample = @iconv( $enc_type, $enc_type, $string ); if ( md5( $sample ) == md5( $string ) ) { if ( $ret === NULL ) { $result = $enc_type; } else { $result = true; } break; } } return $result; } }/*! elementor - v3.29.0 - 04-06-2025 */ :root { --color-box-shadow-color: rgba(0, 0, 0, 0.05); } .eps-theme-dark { --color-box-shadow-color: rgba(0, 0, 0, 0.1); } .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; } @media screen and (min-width: 480px) { .text-start-sm { text-align: start; } } @media screen and (min-width: 480px) { .text-center-sm { text-align: center; } } @media screen and (min-width: 480px) { .text-end-sm { text-align: end; } } @media screen and (min-width: 768px) { .text-start-md { text-align: start; } } @media screen and (min-width: 768px) { .text-center-md { text-align: center; } } @media screen and (min-width: 768px) { .text-end-md { text-align: end; } } @media screen and (min-width: 1025px) { .text-start-lg { text-align: start; } } @media screen and (min-width: 1025px) { .text-center-lg { text-align: center; } } @media screen and (min-width: 1025px) { .text-end-lg { text-align: end; } } @media screen and (min-width: 1440px) { .text-start-xl { text-align: start; } } @media screen and (min-width: 1440px) { .text-center-xl { text-align: center; } } @media screen and (min-width: 1440px) { .text-end-xl { text-align: end; } } @media screen and (min-width: 1600px) { .text-start-xxl { text-align: start; } } @media screen and (min-width: 1600px) { .text-center-xxl { text-align: center; } } @media screen and (min-width: 1600px) { .text-end-xxl { text-align: end; } } @keyframes eps-animation-pop { from { transform: scale(0.75); opacity: 0; } to { transform: scale(1); opacity: 1; } } /*# sourceMappingURL=app-base.css.map */declare(strict_types=1); namespace Imagify\Webp\RewriteRules; use Imagify\EventManagement\SubscriberInterface; use Imagify\Notices\Notices; use Imagify\WriteFile\WriteFileInterface; /** * Display WebP images on the site with rewrite rules. * * @since 1.9 */ class Display implements SubscriberInterface { /** * Configuration file writer. * * @var WriteFileInterface|null */ protected $server_conf = null; /** * Option value. * * @var string * @since 1.9 */ const OPTION_VALUE = 'rewrite'; /** * Returns an array of events this subscriber listens to * * @return array */ public static function get_subscribed_events() { return [ 'imagify_settings_on_save' => [ 'maybe_add_rewrite_rules', 10 ], 'imagify_settings_webp_info' => 'maybe_add_webp_info', 'imagify_activation' => 'activate', 'imagify_deactivation' => 'deactivate', ]; } /** * If display WebP images via rewrite rules, add the rules to the .htaccess/etc file. * * @since 1.9 * * @param array $values The option values. * * @return array */ public function maybe_add_rewrite_rules( $values ) { $was_enabled = (bool) get_imagify_option( 'display_nextgen' ); $is_enabled = ! empty( $values['display_nextgen'] ); // Which method? $old_value = get_imagify_option( 'display_nextgen_method' ); $new_value = ! empty( $values['display_nextgen_method'] ) ? $values['display_nextgen_method'] : ''; // Decide when to add or remove rules. $is_rewrite = self::OPTION_VALUE === $new_value; $was_rewrite = self::OPTION_VALUE === $old_value; if ( ! $this->get_server_conf() ) { return $values; } $result = false; if ( $is_enabled && $is_rewrite && ( ! $was_enabled || ! $was_rewrite ) ) { // Add the rewrite rules. $result = $this->get_server_conf()->add(); } elseif ( $was_enabled && $was_rewrite && ( ! $is_enabled || ! $is_rewrite ) ) { // Remove the rewrite rules. $result = $this->get_server_conf()->remove(); } if ( ! is_wp_error( $result ) ) { return $values; } // Display an error message. if ( is_multisite() && strpos( wp_get_referer(), network_admin_url( '/' ) ) === 0 ) { Notices::get_instance()->add_network_temporary_notice( $result->get_error_message() ); return $values; } Notices::get_instance()->add_site_temporary_notice( $result->get_error_message() ); return $values; } /** * If the conf file is not writable, add a warning. * * @since 1.9 */ public function maybe_add_webp_info() { global $is_nginx; $conf = $this->get_server_conf(); if ( ! $conf ) { return; } $writable = $conf->is_file_writable(); if ( is_wp_error( $writable ) ) { $rules = $conf->get_new_contents(); if ( ! $rules ) { // Uh? return; } printf( /* translators: %s is a file name. */ esc_html__( 'If you choose to use rewrite rules, you will have to add the following lines manually to the %s file:', 'imagify' ), '' . $this->get_file_path( true ) . '' ); echo '
' . esc_html( $rules ) . '
'; } elseif ( $is_nginx ) { printf( /* translators: %s is a file name. */ esc_html__( 'If you choose to use rewrite rules, the file %s will be created and must be included into the server’s configuration file (then restart the server).', 'imagify' ), '' . $this->get_file_path( true ) . '' ); } } /** * Add rules on plugin activation. * * @since 1.9 */ public function activate() { $conf = $this->get_server_conf(); if ( ! $conf ) { return; } if ( ! get_imagify_option( 'display_nextgen' ) ) { return; } if ( self::OPTION_VALUE !== get_imagify_option( 'display_nextgen_method' ) ) { return; } if ( is_wp_error( $conf->is_file_writable() ) ) { return; } $conf->add(); } /** * Remove rules on plugin deactivation. * * @since 1.9 */ public function deactivate() { $conf = $this->get_server_conf(); if ( ! $conf ) { return; } if ( ! get_imagify_option( 'display_nextgen' ) ) { return; } if ( self::OPTION_VALUE !== get_imagify_option( 'display_nextgen_method' ) ) { return; } $file_path = $conf->get_file_path(); $filesystem = \Imagify_Filesystem::get_instance(); if ( ! $filesystem->exists( $file_path ) ) { return; } if ( ! $filesystem->is_writable( $file_path ) ) { return; } $conf->remove(); } /** * Get the path to the directory conf file. * * @since 1.9 * * @param bool $relative True to get a path relative to the site’s root. * * @return string|bool The file path. False on failure. */ public function get_file_path( $relative = false ) { if ( ! $this->get_server_conf() ) { return false; } $file_path = $this->get_server_conf()->get_file_path(); if ( $relative ) { return \Imagify_Filesystem::get_instance()->make_path_relative( $file_path ); } return $file_path; } /** * Get the server conf instance. * * @since 1.9 * * @return WriteFileInterface */ protected function get_server_conf() { global $is_apache, $is_iis7, $is_nginx; if ( isset( $this->server_conf ) ) { return $this->server_conf; } if ( $is_apache ) { $this->server_conf = new Apache(); } elseif ( $is_iis7 ) { $this->server_conf = new IIS(); } elseif ( $is_nginx ) { $this->server_conf = new Nginx(); } return $this->server_conf; } }function _toConsumableArray(t){return _arrayWithoutHoles(t)||_iterableToArray(t)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function _iterableToArray(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}function _arrayWithoutHoles(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e-1&&(I(t,e),y(t,r.class_loading)),g(t,e),function(t){s(t,"was-processed","true")}(t),f(r.callback_reveal,t),f(r.callback_set,t))},z=function(t){return!!n&&(t._observer=new IntersectionObserver(function(e){e.forEach(function(e){return function(t){return t.isIntersecting||t.intersectionRatio>0}(e)?function(t,e){var n=e._settings;f(n.callback_enter,t),n.load_delay?x(t,e):L(t,e)}(e.target,t):function(t,e){var n=e._settings;f(n.callback_exit,t),n.load_delay&&O(t)}(e.target,t)})},{root:(e=t._settings).container===document?null:e.container,rootMargin:e.thresholds||e.threshold+"px"}),!0);var e},C=["IMG","IFRAME"],N=function(t,e){return function(t){return t.filter(function(t){return!c(t)})}((n=t||function(t){return t.container.querySelectorAll(t.elements_selector)}(e),Array.prototype.slice.call(n)));var n},M=function(t){var e=t._settings;_toConsumableArray(e.container.querySelectorAll("."+e.class_error)).forEach(function(t){h(t,e.class_error),function(t){s(t,"was-processed",null)}(t)}),t.update()},R=function(e,n){var r;this._settings=function(t){return _extends({},o,t)}(e),this._loadingCount=0,z(this),this.update(n),r=this,t&&window.addEventListener("online",function(t){M(r)})};return R.prototype={update:function(t){var n,r=this,o=this._settings;(this._elements=N(t,o),!e&&this._observer)?(function(t){return t.use_native&&"loading"in HTMLImageElement.prototype}(o)&&((n=this)._elements.forEach(function(t){-1!==C.indexOf(t.tagName)&&(t.setAttribute("loading","lazy"),S(t,n))}),this._elements=N(t,o)),this._elements.forEach(function(t){r._observer.observe(t)})):this.loadAll()},destroy:function(){var t=this;this._observer&&(this._elements.forEach(function(e){t._observer.unobserve(e)}),this._observer=null),this._elements=null,this._settings=null},load:function(t,e){S(t,this,e)},loadAll:function(){var t=this;this._elements.forEach(function(e){L(e,t)})}},t&&function(t,e){if(e)if(e.length)for(var n,r=0;n=e[r];r+=1)a(t,n);else a(t,e)}(R,window.lazyLoadOptions),R}); return array('dependencies' => array(), 'version' => '6927f9b0b7d1200c5329');import apiFetch from '@wordpress/api-fetch'; import * as wpAPI from '@shared/api/wp'; jest.mock('@wordpress/api-fetch'); describe('WordPress Plugin API helpers', () => { afterEach(() => { jest.clearAllMocks(); }); it('getPlugin calls correct endpoint', async () => { apiFetch.mockResolvedValueOnce([{ name: 'test-plugin' }]); const result = await wpAPI.getPlugin('test-plugin'); expect(apiFetch).toHaveBeenCalledWith({ path: '/wp/v2/plugins?search=test-plugin', }); expect(result).toEqual({ name: 'test-plugin' }); }); it('installPlugin calls correct POST endpoint', async () => { apiFetch.mockResolvedValueOnce({ success: true }); const result = await wpAPI.installPlugin('my-plugin'); expect(apiFetch).toHaveBeenCalledWith({ path: '/wp/v2/plugins', method: 'POST', data: { slug: 'my-plugin' }, }); expect(result).toEqual({ success: true }); }); it('activatePlugin calls correct POST endpoint', async () => { apiFetch.mockResolvedValueOnce([{ name: 'plugin-x' }]); apiFetch.mockResolvedValueOnce({ activated: true }); const result = await wpAPI.activatePlugin('plugin-x'); expect(apiFetch).toHaveBeenCalledTimes(2); expect(result).toEqual({ activated: true }); }); }); Финтех – PHARMABOX.IN
Skip to content

Финтех

Трендовые Индикаторы: Что Это Такое И Как Использовать

К ним относятся скользящие средние (Moving average/MA), схождение-расхождение скользящих средних (MACD), параболический стоп и разворот (Parabolic SAR). Мы подготовили подборку основных индикаторов технического анализа. Собрали… Read More »Трендовые Индикаторы: Что Это Такое И Как Использовать

Лучшие Индикаторы Для Криптовалютной Торговли И Анализа В 2024 Году

Его также можно использовать для выявления сигналов потенциального разворота цен. Индекс относительной силы показывает перекупленность или перепроданность рынка. Он указывает на слабость или силу криптовалюты… Read More »Лучшие Индикаторы Для Криптовалютной Торговли И Анализа В 2024 Году

Торговля С Помощью Протокола Fix Часть Вторая: Создание Fix-клиента Хабр

Большинство полей являются стандартными и всегда будут иметь один и тот же смысл на всех биржах. В fix сообщении есть как обязательные поля, так и… Read More »Торговля С Помощью Протокола Fix Часть Вторая: Создание Fix-клиента Хабр