namespace Google\Site_Kit_Dependencies\GuzzleHttp;
/**
* Debug function used to describe the provided value type and class.
*
* @param mixed $input Any type of variable to describe the type of. This
* parameter misses a typehint because of that.
*
* @return string Returns a string containing the type of the variable and
* if a class is provided, the class name.
*
* @deprecated describe_type will be removed in guzzlehttp/guzzle:8.0. Use Utils::describeType instead.
*/
function describe_type($input) : string
{
return \Google\Site_Kit_Dependencies\GuzzleHttp\Utils::describeType($input);
}
/**
* Parses an array of header lines into an associative array of headers.
*
* @param iterable $lines Header lines array of strings in the following
* format: "Name: Value"
*
* @deprecated headers_from_lines will be removed in guzzlehttp/guzzle:8.0. Use Utils::headersFromLines instead.
*/
function headers_from_lines(iterable $lines) : array
{
return \Google\Site_Kit_Dependencies\GuzzleHttp\Utils::headersFromLines($lines);
}
/**
* Returns a debug stream based on the provided variable.
*
* @param mixed $value Optional value
*
* @return resource
*
* @deprecated debug_resource will be removed in guzzlehttp/guzzle:8.0. Use Utils::debugResource instead.
*/
function debug_resource($value = null)
{
return \Google\Site_Kit_Dependencies\GuzzleHttp\Utils::debugResource($value);
}
/**
* Chooses and creates a default handler to use based on the environment.
*
* The returned handler is not wrapped by any default middlewares.
*
* @return callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface Returns the best handler for the given system.
*
* @throws \RuntimeException if no viable Handler is available.
*
* @deprecated choose_handler will be removed in guzzlehttp/guzzle:8.0. Use Utils::chooseHandler instead.
*/
function choose_handler() : callable
{
return \Google\Site_Kit_Dependencies\GuzzleHttp\Utils::chooseHandler();
}
/**
* Get the default User-Agent string to use with Guzzle.
*
* @deprecated default_user_agent will be removed in guzzlehttp/guzzle:8.0. Use Utils::defaultUserAgent instead.
*/
function default_user_agent() : string
{
return \Google\Site_Kit_Dependencies\GuzzleHttp\Utils::defaultUserAgent();
}
/**
* Returns the default cacert bundle for the current system.
*
* First, the openssl.cafile and curl.cainfo php.ini settings are checked.
* If those settings are not configured, then the common locations for
* bundles found on Red Hat, CentOS, Fedora, Ubuntu, Debian, FreeBSD, OS X
* and Windows are checked. If any of these file locations are found on
* disk, they will be utilized.
*
* Note: the result of this function is cached for subsequent calls.
*
* @throws \RuntimeException if no bundle can be found.
*
* @deprecated default_ca_bundle will be removed in guzzlehttp/guzzle:8.0. This function is not needed in PHP 5.6+.
*/
function default_ca_bundle() : string
{
return \Google\Site_Kit_Dependencies\GuzzleHttp\Utils::defaultCaBundle();
}
/**
* Creates an associative array of lowercase header names to the actual
* header casing.
*
* @deprecated normalize_header_keys will be removed in guzzlehttp/guzzle:8.0. Use Utils::normalizeHeaderKeys instead.
*/
function normalize_header_keys(array $headers) : array
{
return \Google\Site_Kit_Dependencies\GuzzleHttp\Utils::normalizeHeaderKeys($headers);
}
/**
* Returns true if the provided host matches any of the no proxy areas.
*
* This method will strip a port from the host if it is present. Each pattern
* can be matched with an exact match (e.g., "foo.com" == "foo.com") or a
* partial match: (e.g., "foo.com" == "baz.foo.com" and ".foo.com" ==
* "baz.foo.com", but ".foo.com" != "foo.com").
*
* Areas are matched in the following cases:
* 1. "*" (without quotes) always matches any hosts.
* 2. An exact match.
* 3. The area starts with "." and the area is the last part of the host. e.g.
* '.mit.edu' will match any host that ends with '.mit.edu'.
*
* @param string $host Host to check against the patterns.
* @param string[] $noProxyArray An array of host patterns.
*
* @throws Exception\InvalidArgumentException
*
* @deprecated is_host_in_noproxy will be removed in guzzlehttp/guzzle:8.0. Use Utils::isHostInNoProxy instead.
*/
function is_host_in_noproxy(string $host, array $noProxyArray) : bool
{
return \Google\Site_Kit_Dependencies\GuzzleHttp\Utils::isHostInNoProxy($host, $noProxyArray);
}
/**
* Wrapper for json_decode that throws when an error occurs.
*
* @param string $json JSON data to parse
* @param bool $assoc When true, returned objects will be converted
* into associative arrays.
* @param int $depth User specified recursion depth.
* @param int $options Bitmask of JSON decode options.
*
* @return object|array|string|int|float|bool|null
*
* @throws Exception\InvalidArgumentException if the JSON cannot be decoded.
*
* @see https://www.php.net/manual/en/function.json-decode.php
* @deprecated json_decode will be removed in guzzlehttp/guzzle:8.0. Use Utils::jsonDecode instead.
*/
function json_decode(string $json, bool $assoc = \false, int $depth = 512, int $options = 0)
{
return \Google\Site_Kit_Dependencies\GuzzleHttp\Utils::jsonDecode($json, $assoc, $depth, $options);
}
/**
* Wrapper for JSON encoding that throws when an error occurs.
*
* @param mixed $value The value being encoded
* @param int $options JSON encode option bitmask
* @param int $depth Set the maximum depth. Must be greater than zero.
*
* @throws Exception\InvalidArgumentException if the JSON cannot be encoded.
*
* @see https://www.php.net/manual/en/function.json-encode.php
* @deprecated json_encode will be removed in guzzlehttp/guzzle:8.0. Use Utils::jsonEncode instead.
*/
function json_encode($value, int $options = 0, int $depth = 512) : string
{
return \Google\Site_Kit_Dependencies\GuzzleHttp\Utils::jsonEncode($value, $options, $depth);
}
/*
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace Google\Site_Kit_Dependencies\Google\Http;
use Google\Site_Kit_Dependencies\Google\Client;
use Google\Site_Kit_Dependencies\Google\Service\Exception as GoogleServiceException;
use Google\Site_Kit_Dependencies\GuzzleHttp\Psr7;
use Google\Site_Kit_Dependencies\GuzzleHttp\Psr7\Request;
use Google\Site_Kit_Dependencies\GuzzleHttp\Psr7\Response;
use Google\Site_Kit_Dependencies\Psr\Http\Message\RequestInterface;
use Google\Site_Kit_Dependencies\Psr\Http\Message\ResponseInterface;
/**
* Class to handle batched requests to the Google API service.
*
* Note that calls to `Google\Http\Batch::execute()` do not clear the queued
* requests. To start a new batch, be sure to create a new instance of this
* class.
*/
class Batch
{
const BATCH_PATH = 'batch';
private static $CONNECTION_ESTABLISHED_HEADERS = ["HTTP/1.0 200 Connection established\r\n\r\n", "HTTP/1.1 200 Connection established\r\n\r\n"];
/** @var string Multipart Boundary. */
private $boundary;
/** @var array service requests to be executed. */
private $requests = [];
/** @var Client */
private $client;
private $rootUrl;
private $batchPath;
public function __construct(\Google\Site_Kit_Dependencies\Google\Client $client, $boundary = \false, $rootUrl = null, $batchPath = null)
{
$this->client = $client;
$this->boundary = $boundary ?: \mt_rand();
$rootUrl = \rtrim($rootUrl ?: $this->client->getConfig('base_path'), '/');
$this->rootUrl = \str_replace('UNIVERSE_DOMAIN', $this->client->getUniverseDomain(), $rootUrl);
$this->batchPath = $batchPath ?: self::BATCH_PATH;
}
public function add(\Google\Site_Kit_Dependencies\Psr\Http\Message\RequestInterface $request, $key = \false)
{
if (\false == $key) {
$key = \mt_rand();
}
$this->requests[$key] = $request;
}
public function execute()
{
$body = '';
$classes = [];
$batchHttpTemplate = <<requests as $key => $request) {
$firstLine = \sprintf('%s %s HTTP/%s', $request->getMethod(), $request->getRequestTarget(), $request->getProtocolVersion());
$content = (string) $request->getBody();
$headers = '';
foreach ($request->getHeaders() as $name => $values) {
$headers .= \sprintf("%s:%s\r\n", $name, \implode(', ', $values));
}
$body .= \sprintf($batchHttpTemplate, $this->boundary, $key, $firstLine, $headers, $content ? "\n" . $content : '');
$classes['response-' . $key] = $request->getHeaderLine('X-Php-Expected-Class');
}
$body .= "--{$this->boundary}--";
$body = \trim($body);
$url = $this->rootUrl . '/' . $this->batchPath;
$headers = ['Content-Type' => \sprintf('multipart/mixed; boundary=%s', $this->boundary), 'Content-Length' => (string) \strlen($body)];
$request = new \Google\Site_Kit_Dependencies\GuzzleHttp\Psr7\Request('POST', $url, $headers, $body);
$response = $this->client->execute($request);
return $this->parseResponse($response, $classes);
}
public function parseResponse(\Google\Site_Kit_Dependencies\Psr\Http\Message\ResponseInterface $response, $classes = [])
{
$contentType = $response->getHeaderLine('content-type');
$contentType = \explode(';', $contentType);
$boundary = \false;
foreach ($contentType as $part) {
$part = \explode('=', $part, 2);
if (isset($part[0]) && 'boundary' == \trim($part[0])) {
$boundary = $part[1];
}
}
$body = (string) $response->getBody();
if (!empty($body)) {
$body = \str_replace("--{$boundary}--", "--{$boundary}", $body);
$parts = \explode("--{$boundary}", $body);
$responses = [];
$requests = \array_values($this->requests);
foreach ($parts as $i => $part) {
$part = \trim($part);
if (!empty($part)) {
list($rawHeaders, $part) = \explode("\r\n\r\n", $part, 2);
$headers = $this->parseRawHeaders($rawHeaders);
$status = \substr($part, 0, \strpos($part, "\n"));
$status = \explode(" ", $status);
$status = $status[1];
list($partHeaders, $partBody) = $this->parseHttpResponse($part, 0);
$response = new \Google\Site_Kit_Dependencies\GuzzleHttp\Psr7\Response((int) $status, $partHeaders, \Google\Site_Kit_Dependencies\GuzzleHttp\Psr7\Utils::streamFor($partBody));
// Need content id.
$key = $headers['content-id'];
try {
$response = \Google\Site_Kit_Dependencies\Google\Http\REST::decodeHttpResponse($response, $requests[$i - 1]);
} catch (\Google\Site_Kit_Dependencies\Google\Service\Exception $e) {
// Store the exception as the response, so successful responses
// can be processed.
$response = $e;
}
$responses[$key] = $response;
}
}
return $responses;
}
return null;
}
private function parseRawHeaders($rawHeaders)
{
$headers = [];
$responseHeaderLines = \explode("\r\n", $rawHeaders);
foreach ($responseHeaderLines as $headerLine) {
if ($headerLine && \strpos($headerLine, ':') !== \false) {
list($header, $value) = \explode(': ', $headerLine, 2);
$header = \strtolower($header);
if (isset($headers[$header])) {
$headers[$header] = \array_merge((array) $headers[$header], (array) $value);
} else {
$headers[$header] = $value;
}
}
}
return $headers;
}
/**
* Used by the IO lib and also the batch processing.
*
* @param string $respData
* @param int $headerSize
* @return array
*/
private function parseHttpResponse($respData, $headerSize)
{
// check proxy header
foreach (self::$CONNECTION_ESTABLISHED_HEADERS as $established_header) {
if (\stripos($respData, $established_header) !== \false) {
// existed, remove it
$respData = \str_ireplace($established_header, '', $respData);
// Subtract the proxy header size unless the cURL bug prior to 7.30.0
// is present which prevented the proxy header size from being taken into
// account.
// @TODO look into this
// if (!$this->needsQuirk()) {
// $headerSize -= strlen($established_header);
// }
break;
}
}
if ($headerSize) {
$responseBody = \substr($respData, $headerSize);
$responseHeaders = \substr($respData, 0, $headerSize);
} else {
$responseSegments = \explode("\r\n\r\n", $respData, 2);
$responseHeaders = $responseSegments[0];
$responseBody = isset($responseSegments[1]) ? $responseSegments[1] : null;
}
$responseHeaders = $this->parseRawHeaders($responseHeaders);
return [$responseHeaders, $responseBody];
}
}
# Contributing to EWWW IO
:+1::tada: First off, thanks for taking the time to contribute! :tada::+1:
## Code of Conduct
Someday, we'll have something more substantial. For now, let's keep it simple:
* Be nice, you'll catch more flies with honey (or something like that)
* Do not file an issue to ask for support. Issues are for bugs and feature requests, but if you have a question, you can [contact us](https://ewww.io/contact-us/) directly.
* Do not issue a pull request without submitting an Issue first.
## Coding Standards
All PHP code submitted must follow the [WordPress Coding Standards](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards), specifically the Core ruleset. All commits are automatically tested for this, but it helps if you know what the [rules are](https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/). JS and CSS code is honestly a bit unruly at this point.
## Reporting Issues
When you submit a bug:
* Include as much detail as possible. If you're not sure about something, include it anyway.
* Include steps to reproduce the issue, in as much detail as possible, including other plugins/themes that are involved, and settings that may affect the bug.
* Explain what behavior you expected to see, and point out exactly what you saw instead that was not expected.
* If applicable, provide screenshots.
* Provide images that you've used to reproduce the issue.
* Enable EWWW IO's debugging option and provide as much of it as possible. You may wish to redact the user account and file system paths listed.
* Check older versions to see if it is a regression. You can download them from the [Advanced section at wordpress.org](https://wordpress.org/plugins/ewww-image-optimizer/advanced/).
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Add script for grid item add to card link
*
* @since 4.5
*/
function vc_woocommerce_add_to_cart_script() {
wp_enqueue_script( 'vc_woocommerce-add-to-cart-js',
vc_asset_url( 'js/vendors/woocommerce-add-to-cart.js' ),
array( 'wc-add-to-cart' ),
WPB_VC_VERSION );
}
/**
* @since 4.4 vendors initialization moved to hooks in autoload/vendors.
*
* Used to initialize plugin WooCommerce vendor. (adds tons of WooCommerce shortcodes and some fixes)
*/
add_action( 'plugins_loaded', 'vc_init_vendor_woocommerce' );
function vc_init_vendor_woocommerce() {
include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); // Require plugin.php to use is_plugin_active() below
if ( is_plugin_active( 'woocommerce/woocommerce.php' ) || class_exists( 'WooCommerce' ) ) {
require_once vc_path_dir( 'VENDORS_DIR', 'plugins/class-vc-vendor-woocommerce.php' );
$vendor = new Vc_Vendor_Woocommerce();
add_action( 'vc_after_set_mode', array(
$vendor,
'load',
) );
require_once vc_path_dir( 'VENDORS_DIR', 'plugins/woocommerce/grid-item-filters.php' );
// Add 'add to card' link to the list of Add link.
add_filter( 'vc_gitem_add_link_param', 'vc_gitem_add_link_param_woocommerce' );
// Filter to add link attributes for grid element shortcode.
add_filter( 'vc_gitem_post_data_get_link_link', 'vc_gitem_post_data_get_link_link_woocommerce', 10, 3 );
add_filter( 'vc_gitem_post_data_get_link_target', 'vc_gitem_post_data_get_link_target_woocommerce', 12, 2 );
add_filter( 'vc_gitem_post_data_get_link_real_link', 'vc_gitem_post_data_get_link_real_link_woocommerce', 10, 4 );
add_filter( 'vc_gitem_post_data_get_link_real_target', 'vc_gitem_post_data_get_link_real_target_woocommerce', 12, 3 );
add_filter( 'vc_gitem_zone_image_block_link', 'vc_gitem_zone_image_block_link_woocommerce', 10, 3 );
add_action( 'wp_enqueue_scripts', 'vc_woocommerce_add_to_cart_script' );
}
}
/**
* @return null
*/
if (!function_exists('licenseEnvato_general_setting_handler')) {
function licenseEnvato_general_setting_handler() {
if ( !isset( $_POST['submit_general'] ) ) {
return;
}
if ( !isset( $_POST['_wpnonce'] ) || !wp_verify_nonce( wp_unslash( sanitize_text_field( $_POST['_wpnonce'] ) ), 'submit_general_setting' ) ) {
wp_die( 'Are you cheating?' );
}
if ( !current_user_can( 'manage_options' ) ) {
wp_die( 'Are you cheating?' );
}
$token_secret_key = isset( $_POST['token_secret'] ) ? sanitize_text_field( wp_unslash( $_POST['token_secret'] ) ) : 'license-envato';
update_option( 'license_envato_token_secret', $token_secret_key );
}
}
/**
* @param mixed $type
* @param mixed $message
* @return string
*/
if (!function_exists('licenseEnvato__redirect')) {
function licenseEnvato__redirect($type, $message){
$url = add_query_arg(
array(
'page' => 'licenseenvato',
$type => $message
),
admin_url('admin.php')
);
wp_safe_redirect(wp_sanitize_redirect($url));
exit;
}
}/**
* Guest vary handler for LiteSpeed Cache.
*
* NOTE: This file is loaded directly without WordPress, so WP functions are NOT available.
*
* @package LiteSpeed
* @since 4.1
*/
namespace LiteSpeed\Lib;
/**
* Update guest vary
*
* @since 4.1
*/
class Guest {
const CONF_FILE = '.litespeed_conf.dat';
const HASH = 'hash'; // Not set-able
const O_CACHE_LOGIN_COOKIE = 'cache-login_cookie';
const O_DEBUG = 'debug';
const O_DEBUG_IPS = 'debug-ips';
const O_UTIL_NO_HTTPS_VARY = 'util-no_https_vary';
/**
* Client IP address.
*
* @var string
*/
private static $_ip;
/**
* Vary cookie name.
*
* @var string
*/
private static $_vary_name = '_lscache_vary';
/**
* Configuration array.
*
* @var array|false
*/
private $_conf = false;
/**
* Guest Mode lists cache.
*
* @var array
*/
private $_gm_lists = [
'ips' => null,
'uas' => null,
];
/**
* Constructor
*
* @since 4.1
*/
public function __construct() {
! defined( 'LSCWP_CONTENT_FOLDER' ) && define( 'LSCWP_CONTENT_FOLDER', dirname( __DIR__, 3 ) );
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- No WP available
$this->_conf = file_get_contents( LSCWP_CONTENT_FOLDER . '/' . self::CONF_FILE );
if ( $this->_conf ) {
$this->_conf = json_decode( $this->_conf, true );
}
if ( ! empty( $this->_conf[ self::O_CACHE_LOGIN_COOKIE ] ) ) {
self::$_vary_name = $this->_conf[ self::O_CACHE_LOGIN_COOKIE ];
}
}
/**
* Update Guest vary.
*
* @since 4.0
* @return void
*/
public function update_guest_vary() {
// This process must not be cached
// @reference https://wordpress.org/support/topic/soft-404-from-google-search-on-litespeed-cache-guest-vary-php/#post-16838583
header( 'X-Robots-Tag: noindex' );
header( 'X-LiteSpeed-Cache-Control: no-cache' );
if ( $this->always_guest() ) {
echo '[]';
exit;
}
// If contains vary already, don't reload to avoid infinite loop when parent page having browser cache
if ( $this->_conf && self::has_vary() ) {
echo '[]';
exit;
}
// Send vary cookie
$vary = 'guest_mode:1';
if ( $this->_conf && empty( $this->_conf[ self::O_DEBUG ] ) ) {
$vary = md5( $this->_conf[ self::HASH ] . $vary );
}
$expire = time() + 2 * 86400;
$is_ssl = ! empty( $this->_conf[ self::O_UTIL_NO_HTTPS_VARY ] ) ? false : $this->is_ssl();
setcookie( self::$_vary_name, $vary, $expire, '/', false, $is_ssl, true );
// phpcs:ignore WordPress.WP.AlternativeFunctions.json_encode_json_encode -- No WP available
echo json_encode( [ 'reload' => 'yes' ] );
exit;
}
/**
* WP's is_ssl() func
*
* @since 4.1
* @return bool
*/
private function is_ssl() {
// phpcs:disable WordPress.Security.ValidatedSanitizedInput -- No WP available
if ( isset( $_SERVER['HTTPS'] ) ) {
if ( 'on' === strtolower( $_SERVER['HTTPS'] ) ) {
return true;
}
if ( '1' === $_SERVER['HTTPS'] ) {
return true;
}
} elseif ( isset( $_SERVER['SERVER_PORT'] ) && '443' === $_SERVER['SERVER_PORT'] ) {
return true;
}
// phpcs:enable WordPress.Security.ValidatedSanitizedInput
return false;
}
/**
* Check if default vary has a value
*
* @since 1.1.3
* @access public
* @return string|false
*/
public static function has_vary() {
if ( empty( $_COOKIE[ self::$_vary_name ] ) ) {
return false;
}
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash -- No WP available
return $_COOKIE[ self::$_vary_name ];
}
/**
* Load Guest Mode list from file.
*
* Priority: cloud synced file > plugin data file
*
* @since 7.7
* @param string $type 'ips' or 'uas'.
* @return array
*/
private function _load_gm_list( $type ) {
if ( null !== $this->_gm_lists[ $type ] ) {
return $this->_gm_lists[ $type ];
}
$this->_gm_lists[ $type ] = [];
$filename = 'gm_' . $type . '.txt';
// Try cloud synced file first, then fallback to plugin data file
$files = [
LSCWP_CONTENT_FOLDER . '/litespeed/cloud/' . $filename,
dirname( __DIR__ ) . '/data/' . $filename,
];
foreach ( $files as $file ) {
if ( file_exists( $file ) ) {
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- No WP available
$content = file_get_contents( $file );
if ( $content ) {
$this->_gm_lists[ $type ] = array_filter( array_map( 'trim', explode( "\n", $content ) ) );
break;
}
}
}
return $this->_gm_lists[ $type ];
}
/**
* Detect if is a guest visitor or not
*
* @since 4.0
* @return bool
*/
public function always_guest() {
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
return false;
}
$guest_uas = $this->_load_gm_list( 'uas' );
if ( $guest_uas ) {
$quoted_uas = [];
foreach ( $guest_uas as $v ) {
$quoted_uas[] = preg_quote( $v, '#' );
}
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash -- No WP available
$match = preg_match( '#' . implode( '|', $quoted_uas ) . '#i', $_SERVER['HTTP_USER_AGENT'] );
if ( $match ) {
return true;
}
}
$guest_ips = $this->_load_gm_list( 'ips' );
if ( $this->ip_access( $guest_ips ) ) {
return true;
}
return false;
}
/**
* Check if the ip is in the range (supports CIDR notation)
*
* @since 1.1.0
* @since 7.7 Added CIDR support
* @access public
* @param array $ip_list List of IPs or CIDRs.
* @return bool
*/
public function ip_access( $ip_list ) {
if ( ! $ip_list ) {
return false;
}
if ( ! isset( self::$_ip ) ) {
self::$_ip = self::get_ip();
}
foreach ( $ip_list as $ip_entry ) {
$ip_entry = trim( $ip_entry );
// Check CIDR format
if ( strpos( $ip_entry, '/' ) !== false ) {
if ( $this->_ip_in_cidr( self::$_ip, $ip_entry ) ) {
return true;
}
} elseif ( self::$_ip === $ip_entry ) {
// Exact match
return true;
}
}
return false;
}
/**
* Check if IP is within CIDR range
*
* @since 7.7
* @access private
* @param string $ip IP address to check.
* @param string $cidr CIDR notation (e.g., 192.168.1.0/24).
* @return bool
*/
private function _ip_in_cidr( $ip, $cidr ) {
list( $subnet, $mask ) = explode( '/', $cidr, 2 );
// Mask must be numeric and > 0
if ( ! is_numeric( $mask ) || $mask <= 0 ) {
return false;
}
$mask = (int) $mask;
// Determine IP version and validate
$is_ipv6 = filter_var( $subnet, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6 );
$max_mask = $is_ipv6 ? 128 : 32;
$byte_len = $is_ipv6 ? 16 : 4;
$ip_filter = $is_ipv6 ? FILTER_FLAG_IPV6 : FILTER_FLAG_IPV4;
if ( ! filter_var( $ip, FILTER_VALIDATE_IP, $ip_filter ) ) {
return false;
}
if ( $mask > $max_mask ) {
return false;
}
$ip_bin = inet_pton( $ip );
$subnet_bin = inet_pton( $subnet );
if ( false === $ip_bin || false === $subnet_bin ) {
return false;
}
// Build mask
$full_bytes = (int) ( $mask / 8 );
$rem_bits = $mask % 8;
$mask_bin = str_repeat( "\xff", $full_bytes );
if ( $rem_bits > 0 ) {
$mask_bin .= chr( 0xff << ( 8 - $rem_bits ) );
}
$mask_bin = str_pad( $mask_bin, $byte_len, "\x00" );
return ( $ip_bin & $mask_bin ) === ( $subnet_bin & $mask_bin );
}
/**
* Get client ip
*
* @since 1.1.0
* @since 1.6.5 changed to public
* @access public
* @return string
*/
public static function get_ip() {
$_ip = '';
if ( function_exists( 'apache_request_headers' ) ) {
$apache_headers = apache_request_headers();
$_ip = ! empty( $apache_headers['True-Client-IP'] ) ? $apache_headers['True-Client-IP'] : false;
if ( ! $_ip ) {
$_ip = ! empty( $apache_headers['X-Forwarded-For'] ) ? $apache_headers['X-Forwarded-For'] : false;
$_ip = explode( ',', $_ip );
$_ip = $_ip[0];
}
}
if ( ! $_ip ) {
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash -- No WP available
$_ip = ! empty( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : '';
}
return $_ip;
}
}
/**
* FUNCTIONS LIST
* 1) @see findme_elated_include_blog_helper_functions
* 2) @see findme_elated_get_archive_blog_list_layout
* 3) @see findme_elated_get_holder_params_blog
* 4) @see findme_elated_get_blog
* 5) @see findme_elated_get_blog_type
* 6) @see findme_elated_get_blog_query
* 7) @see findme_elated_get_blog_list_holder_classes
* 8) @see findme_elated_get_blog_holder_data_params
* 9) @see findme_elated_set_ajax_url
* 10) @see findme_elated_blog_load_more
* 11) @see findme_elated_get_post_format_html
* 12) @see findme_elated_single_link_pages
* 13) @see findme_elated_get_blog_single
* 14) @see findme_elated_get_blog_single_type
* 15) @see findme_elated_get_single_post_format_html
* 16) @see findme_elated_text_crop
* 17) @see findme_elated_excerpt
* 18) @see findme_elated_excerpt_length
* 19) @see findme_elated_post_has_read_more
* 20) @see findme_elated_modify_read_more_link
* 21) @see findme_elated_get_blog_related_post_type
* 22) @see findme_elated_get_blog_related_posts
* 23) @see findme_elated_blog_shortcode_load_more
* 24) @see findme_elated_get_user_custom_fields
* 25) @see findme_elated_blog_item_has_link
* 26) @see findme_elated_get_blog_module
* 27) @see findme_elated_return_post_format
* 28) @see findme_elated_return_has_media
* 29) @see findme_elated_blog_single_title_module
* 30) @see findme_elated_full_height_title_class
**/
if( !function_exists('findme_elated_include_blog_helper_functions') ) {
/**
* Function which include blog helper function file
*/
function findme_elated_include_blog_helper_functions($module, $type) {
include_once ELATED_FRAMEWORK_MODULES_ROOT_DIR.'/blog/templates/'. $module .'/' . $type . '/helper.php';
}
}
if( !function_exists('findme_elated_get_archive_blog_list_layout') ) {
/**
* Function which return archive blog list layout
*/
function findme_elated_get_archive_blog_list_layout() {
$blog_layout = findme_elated_options()->getOptionValue('blog_list_type');
return $blog_layout;
}
}
if( !function_exists('findme_elated_get_holder_params_blog') ) {
/**
* Function which return holder class and holder inner class for blog pages
*
* @return array
*/
function findme_elated_get_holder_params_blog() {
$params = array();
/**
* Available parameters for holder params
* -holder
* -inner
* -module_title
* -module_title_layout
*
*/
$params = apply_filters('findme_elated_blog_holder_params', $params);
return $params;
}
}
if( !function_exists('findme_elated_get_blog') ) {
/**
* Function which return holder for all blog lists
*
* @return holder.php template
*/
function findme_elated_get_blog($type) {
$holder_classes = '';
$holder_classes = apply_filters('findme_elated_blog_holder_classes', $holder_classes);
$sidebar_layout = findme_elated_sidebar_layout();
$params = array(
'holder_classes' => $holder_classes,
'sidebar_layout' => $sidebar_layout,
'blog_type' => $type
);
findme_elated_get_module_template_part('templates/lists/holder', 'blog', '', $params);
}
}
if( !function_exists('findme_elated_get_blog_type') ) {
/**
* Function which create query for blog lists
* @param $type type of list that is loaded
* @return blog list template
*/
function findme_elated_get_blog_type($type) {
$blog_query = findme_elated_get_blog_query();
$paged = isset($blog_query->query['paged']) ? $blog_query->query['paged'] : 1;
$max_num_pages = $blog_query->max_num_pages;
$blog_classes = findme_elated_get_blog_list_holder_classes($type);
$blog_data_params = findme_elated_get_blog_holder_data_params($type);
$params = array(
'blog_query' => $blog_query,
'paged' => $paged,
'max_num_pages' => $max_num_pages,
'blog_type' => $type,
'blog_classes' => $blog_classes,
'blog_data_params' => $blog_data_params
);
findme_elated_get_module_template_part('templates/lists/' . $type . '/list', 'blog', '', $params);
}
}
if(!function_exists('findme_elated_get_blog_query')){
/**
* Function which create query for blog lists
*
* @return wp query object
*/
function findme_elated_get_blog_query(){
$id = findme_elated_get_page_id();
$category = esc_attr(get_post_meta($id, "eltd_blog_category_meta", true));
$number_of_posts_per_page = get_post_meta($id, "eltd_show_posts_per_page_meta", true);
$post_number = esc_attr(get_option('posts_per_page'));
$order = findme_elated_get_meta_field_intersect('blog_order');
if(!empty($number_of_posts_per_page)){
$post_number = esc_attr($number_of_posts_per_page);
}
if(get_query_var('paged')) {
$paged = get_query_var('paged');
} elseif(get_query_var('page')) {
$paged = get_query_var('page');
} else {
$paged = 1;
}
$query_array = array(
'post_status' => 'publish',
'post_type' => 'post',
'order' => $order,
'paged' => $paged,
'category_name' => $category,
'posts_per_page' => $post_number
);
$blog_query = new WP_Query($query_array);
if(is_archive()) {
global $wp_query;
$blog_query = $wp_query;
}
return $blog_query;
}
}
if(!function_exists('findme_elated_get_max_number_of_pages')) {
/**
* Function that return max number of posts/pages for pagination
* @return int
*
* @version 0.1
*/
function findme_elated_get_max_number_of_pages() {
global $wp_query;
$max_number_of_pages = 10; //default value
if($wp_query) {
$max_number_of_pages = $wp_query->max_num_pages;
}
return $max_number_of_pages;
}
}
if(!function_exists('findme_elated_get_blog_list_holder_classes')){
/**
* Function set blog list classes
* @param $type - type of blog list that is passing
* @return array - array of classes
*/
function findme_elated_get_blog_list_holder_classes($type){
$blog_classes = array();
$blog_classes[] = 'eltd-blog-holder';
$blog_classes[] = 'eltd-blog-' . $type;
$pagination_type = findme_elated_get_meta_field_intersect('blog_pagination_type');
if(!empty($pagination_type)) {
$blog_classes[] = 'eltd-blog-pagination-' . $pagination_type;
}
$masonry_type = findme_elated_get_meta_field_intersect('blog_list_featured_image_proportion');
if(!empty($masonry_type)) {
$blog_classes[] = 'eltd-masonry-images-' . $masonry_type;
}
$blog_classes = apply_filters('findme_elated_blog_list_classes', $blog_classes);
return implode(' ', $blog_classes);
}
}
if(!function_exists('findme_elated_get_blog_holder_data_params')){
/**
* Function which set data params on blog holder div
*
* @param $type - type of blog list that is loaded
* @return array - array of data parameters
*/
function findme_elated_get_blog_holder_data_params($type){
$current_query = findme_elated_get_blog_query();
$paged = isset($current_query->query['paged']) ? $current_query->query['paged'] : 1;
$data_params = array();
$data_return_string = '';
$data_params['data-blog-type'] = $type;
$posts_number = get_option('posts_per_page');
$posts_per_page_meta = get_post_meta(get_the_ID(), "eltd_show_posts_per_page_meta", true);
if(!empty($posts_per_page_meta)){
$posts_number = esc_attr($posts_per_page_meta);
}
$category = get_post_meta(findme_elated_get_page_id(), 'eltd_blog_category_meta', true);
$excerpt_length = findme_elated_get_meta_field_intersect('number_of_chars', findme_elated_get_page_id());
//set data params
$data_params['data-next-page'] = $paged+1;
$data_params['data-max-num-pages'] = $current_query->max_num_pages;
$data_params['data-post-number'] = $posts_number;
$data_params['data-excerpt-length'] = $excerpt_length;
if(!empty($category)){
$data_params['data-category'] = $category;
}
if(is_archive()){
if(is_category()){
$cat_id = get_queried_object_id();
$data_params['data-archive-category'] = $cat_id;
}
if(is_author()){
$author_id = get_queried_object_id();
$data_params['data-archive-author'] = $author_id;
}
if(is_tag()){
$current_tag_id = get_queried_object_id();
$data_params['data-archive-tag'] = $current_tag_id;
}
if(is_date()){
$day = get_query_var('day');
$month = get_query_var('monthnum');
$year = get_query_var('year');
$data_params['data-archive-day'] = $day;
$data_params['data-archive-month'] = $month;
$data_params['data-archive-year'] = $year;
}
}
foreach($data_params as $key => $value) {
if ($key !== '') {
$data_return_string .= $key.'= '.esc_attr($value).' ';
}
}
return $data_return_string;
}
}
if(!function_exists('findme_elated_blog_load_more')){
function findme_elated_blog_load_more(){
$return_obj = array();
$params = array();
$paged = $post_number = $category = $blog_type = $excerpt_length = '';
$archive_category = $archive_author = $archive_tag = $archive_day = $archive_month = $archive_year = '';
if (!empty($_POST['nextPage'])) {
$paged = $_POST['nextPage'];
}
if (!empty($_POST['postNumber'])) {
$post_number = $_POST['postNumber'];
}
if (!empty($_POST['category'])) {
$category = $_POST['category'];
}
if (!empty($_POST['blogType'])) {
$blog_type = $_POST['blogType'];
}
if (!empty($_POST['archiveCategory'])) {
$archive_category = $_POST['archiveCategory'];
}
if (!empty($_POST['archiveAuthor'])) {
$archive_author = $_POST['archiveAuthor'];
}
if (!empty($_POST['archiveTag'])) {
$archive_tag = $_POST['archiveTag'];
}
if (!empty($_POST['archiveDay'])) {
$archive_day = $_POST['archiveDay'];
}
if (!empty($_POST['archiveMonth'])) {
$archive_month = $_POST['archiveMonth'];
}
if (!empty($_POST['archiveYear'])) {
$archive_year = $_POST['archiveYear'];
}
if (!empty($_POST['excerptLength'])) {
$excerpt_length = $_POST['excerptLength'];
}
$params['excerpt_length'] = $excerpt_length;
$html = '';
$query_array = array(
'post_status' => 'publish',
'post_type' => 'post',
'paged' => $paged,
'posts_per_page' => $post_number,
'post__not_in' => get_option( 'sticky_posts' )
);
if(!empty($category)) {
$query_array['category_name'] = $category;
}
if(!empty($archive_category)) {
$query_array['cat'] = $archive_category;
}
if(!empty($archive_author)) {
$query_array['author'] = $archive_author;
}
if(!empty($archive_tag)) {
$query_array['tag'] = $archive_tag;
}
if($archive_day !== '' && $archive_month !== '' && $archive_year !== '') {
$query_array['day'] = $archive_day;
$query_array['monthnum'] = $archive_month;
$query_array['year'] = $archive_year;
}
$query_results = new \WP_Query($query_array);
include_once ELATED_FRAMEWORK_MODULES_ROOT_DIR.'/blog/templates/lists/' . $blog_type . '/helper.php';
if($query_results->have_posts()):
while ( $query_results->have_posts() ) : $query_results->the_post();
$html .= findme_elated_get_post_format_html($blog_type, 'yes', $params);
endwhile;
else:
$html .= findme_elated_get_module_template_part('templates/parts/no-posts', 'blog');
endif;
wp_reset_postdata();
$return_obj = array(
'html' => $html,
);
echo json_encode($return_obj); exit;
}
add_action('wp_ajax_nopriv_findme_elated_blog_load_more', 'findme_elated_blog_load_more');
add_action( 'wp_ajax_findme_elated_blog_load_more', 'findme_elated_blog_load_more' );
}
if( !function_exists('findme_elated_get_post_format_html') ) {
/**
* Function which return html for post formats
* @param $type
* @param $ajax
* @param $ajax_params
* @return post hormat template
*/
function findme_elated_get_post_format_html($type = "", $ajax = '', $ajax_params = array()) {
$post_format = findme_elated_return_post_format();
$params = array();
$params['blog_template_type'] = $type;
$params['post_format'] = $post_format;
$post_classes = array();
// Sticky class is added on posts only when they are displayed on the first page of the blog home
if(is_sticky(get_the_ID())) {
$post_classes[] = 'sticky';
}
$post_classes[] = findme_elated_return_has_media() ? 'eltd-post-has-media' : 'eltd-post-no-media';
$params['post_classes'] = $post_classes;
/*
* Available parameters for template parts
* -featured_image_size
* -title_tag
* -link_tag
* -quote_tag
* -share_type
*
*/
$part_params_temp = array_merge(array(), $ajax_params);
$params['part_params'] = apply_filters('findme_elated_blog_part_params', $part_params_temp);
if($ajax == ''){
findme_elated_get_module_template_part('templates/lists/' . $type . '/post', 'blog', $post_format, $params);
}
if($ajax == 'yes'){
return findme_elated_get_blog_module_template_part('templates/lists/' . $type . '/post', $post_format, $params);
}
}
}
if( !function_exists('findme_elated_single_link_pages') ) {
/**
* Function which return parts on single.php which are just below content
*
* @return single.php html
*/
function findme_elated_single_link_pages() {
$args_pages = array(
'before' => '
',
'after' => '
',
'link_before' => ''. esc_html__('Post Page Link: ', 'findme'),
'link_after' => '',
'pagelink' => '%'
);
wp_link_pages($args_pages);
}
add_action('findme_elated_single_link_pages', 'findme_elated_single_link_pages');
}
if(!function_exists('findme_elated_get_blog_single')) {
/**
* Function which return holder for single posts
*
* @param type - type of single layout
* @return single holder.php template
*/
function findme_elated_get_blog_single($type) {
$sidebar_layout = findme_elated_sidebar_layout();
$holder_classes = $sidebar_layout !== 'no-sidebar' ? 'eltd-content-has-sidebar' : '';
$holder_classes = apply_filters('findme_elated_blog_single_holder_classes', $holder_classes);
$params = array(
'holder_classes' => $holder_classes,
'sidebar_layout' => $sidebar_layout,
'blog_single_type' => $type,
'blog_single_classes' => 'eltd-blog-single-'.$type
);
findme_elated_get_module_template_part('templates/singles/holder', 'blog', '', $params);
}
}
if( !function_exists('findme_elated_get_blog_single_type') ) {
/**
* Function which create query for blog lists
* @param $type type of list that is loaded
* @return blog list template
*/
function findme_elated_get_blog_single_type($type) {
$params = array();
$params['blog_single_type'] = $type;
/*
* Available parameters for info parts
* -related_posts_image_size
*
*/
$params['single_info_params'] = apply_filters('findme_elated_blog_single_info_params', array());
findme_elated_get_module_template_part('templates/singles/'.$type.'/single', 'blog', '', $params);
}
}
if( !function_exists('findme_elated_get_single_post_format_html') ) {
/**
* Function return all parts on single.php page
*
* @param $type - type of blog single layout
* @return single.php html
*/
function findme_elated_get_single_post_format_html($type) {
$post_format = findme_elated_return_post_format();
$params = array();
/*
* Available parameters for template parts
* -featured_image_size
* -title_tag
* -link_tag
* -quote_tag
* -share type
*
*/
$params['part_params'] = apply_filters('findme_elated_blog_part_params', array());
findme_elated_get_module_template_part('templates/singles/'.$type.'/'.$post_format, 'blog', '', $params);
}
}
if(!function_exists('findme_elated_text_crop')) {
/**
* Function that cuts plain text to the number of words supplied
*
*/
function findme_elated_text_crop($text, $word_count = 45, $suffix = true) {
$text = trim($text);
$word_count = (int) $word_count;
$suffix = (bool) $suffix;
//explode current text to words
$text_word_array = explode (' ', $text);
// Filter out all empty words
$text_word_array = array_filter($text_word_array, function($text_word_array_item) { return trim($text_word_array_item) != ''; });
// Real word count
$text_word_array_count = count ($text_word_array);
//cut down that array based on the number of the words option
$text_word_array = array_slice ($text_word_array, 0, $word_count);
//and finally implode words together
$cropped_text = implode (' ', $text_word_array);
// adds three dots only if it is needed
if ($suffix && $text_word_array_count > $word_count) $cropped_text .= '...';
return $cropped_text;
}
}
if(!function_exists('findme_elated_excerpt')) {
/**
* Function that cuts post excerpt to the number of word based on previosly set global
* variable $word_count, which is defined in eltd_set_blog_word_count function.
*
* @param $length - default excerpt length
*
* @return string - formatted excerpt
*
* It current post has read more tag set it will return content of the post, else it will return post excerpt
*
*/
function findme_elated_excerpt($length) {
global $post;
if(post_password_required()) {
return get_the_password_form();
}
//does current post has read more tag set?
elseif(findme_elated_post_has_read_more()) {
global $more;
//override global $more variable so this can be used in blog templates
$more = 0;
return get_the_content(true);
}
$number_of_chars = findme_elated_get_meta_field_intersect('number_of_chars', findme_elated_get_page_id());
$word_count = $length !== '' ? $length : $number_of_chars;
//is word count set to something different that 0?
if($word_count > 0) {
//if post excerpt field is filled take that as post excerpt, else that content of the post
$post_excerpt = $post->post_excerpt != "" ? $post->post_excerpt : '';
//remove leading dots if those exists
$clean_excerpt = strlen($post_excerpt) && strpos($post_excerpt, '...') ? strstr($post_excerpt, '...', true) : $post_excerpt;
//if clean excerpt has text left
if($clean_excerpt !== '') {
//explode current excerpt to words
$excerpt_word_array = explode (' ', $clean_excerpt);
//cut down that array based on the number of the words option
$excerpt_word_array = array_slice ($excerpt_word_array, 0, $word_count);
//and finally implode words together
$excerpt = implode (' ', $excerpt_word_array);
//is excerpt different than empty string?
if($excerpt !== '') {
return rtrim(wp_kses_post($excerpt));
}
}
return "";
}
else {
return "";
}
}
}
if (!function_exists('findme_elated_excerpt_length')) {
/**
* Function that changes excerpt length based on theme options
* @return int changed value
*/
function findme_elated_excerpt_length() {
$numb_of_chars = findme_elated_options()->getOptionValue('number_of_chars');
return $numb_of_chars !== '' ? $numb_of_chars : 45;
}
add_filter( 'excerpt_length', 'findme_elated_excerpt_length', 999 );
}
if(!function_exists('findme_elated_post_has_read_more')) {
/**
* Function that checks if current post has read more tag set
* @return int position of read more tag text. It will return false if read more tag isn't set
*/
function findme_elated_post_has_read_more() {
global $post;
return strpos($post->post_content, '');
}
}
if (!function_exists('findme_elated_modify_read_more_link')) {
/**
* Function that modifies read more link output.
* Hooks to the_content_more_link
* @return string modified output
*/
function findme_elated_modify_read_more_link() {
$link = '
';
return $link;
}
add_filter( 'the_content_more_link', 'findme_elated_modify_read_more_link');
}
if ( ! function_exists('findme_elated_get_blog_related_post_type')) {
/**
* Function for returning latest posts types
*
* @param $post_id
* @param array $options
* @return WP_Query
*/
function findme_elated_get_blog_related_post_type($post_id, $options = array()) {
$tags = get_the_tags($post_id);
//Get categories
$categories = get_the_category($post_id);
$tag_ids = array();
if ($tags) {
foreach ($tags as $tag) {
$tag_ids[] = $tag->term_id;
}
}
$category_ids = array();
if ($categories) {
foreach ($categories as $category) {
$category_ids[] = $category->term_id;
}
}
$hasRelatedByTag = false;
if ($tag_ids) {
$related_by_tag = findme_elated_get_blog_related_posts($post_id, $tag_ids, 'tag', $options);
if (!empty($related_by_tag->posts)) {
$hasRelatedByTag = true;
return $related_by_tag;
}
}
if ($categories && !$hasRelatedByTag) {
$related_by_category = findme_elated_get_blog_related_posts($post_id, $category_ids, 'category', $options);
if (!empty($related_by_category->posts)) {
return $related_by_category;
}
}
}
}
if ( ! function_exists('findme_elated_get_blog_related_posts') ) {
/**
* Function for related posts
*
* @param $post_id - Post ID
* @param $term_ids - Category or Tag IDs
* @param $slug - term slug for WP_Query
* @param array $options
* @return WP_Query
*/
function findme_elated_get_blog_related_posts($post_id, $term_ids, $slug, $options = array()) {
//Query options
$posts_per_page = -1;
//Override query options
extract($options);
$args = array(
'post_status' => 'publish',
'post__not_in' => array($post_id),
$slug . '__in' => $term_ids,
'order' => 'DESC',
'orderby' => 'date',
'posts_per_page' => $posts_per_page
);
$related_posts = new WP_Query($args);
return $related_posts;
}
}
if(!function_exists('findme_elated_blog_shortcode_load_more')){
function findme_elated_blog_shortcode_load_more(){
$params = array();
if(!empty($_POST)) {
foreach ($_POST as $key => $value) {
if($key !== '') {
$addUnderscoreBeforeCapitalLetter = preg_replace('/([A-Z])/', '_$1', $key);
$setAllLettersToLowercase = strtolower($addUnderscoreBeforeCapitalLetter);
$params[$setAllLettersToLowercase] = $value;
}
}
}
$this_object = new \ElatedCore\CPT\Shortcodes\BlogList\BlogList();
$query_array = $this_object->generateQueryArray($params);
$query_results = new \WP_Query($query_array);
$params['this_object'] = $this_object;
ob_start();
if($query_results->have_posts()):
while ( $query_results->have_posts() ) : $query_results->the_post();
findme_elated_get_module_template_part('shortcodes/blog-list/layout-collections/'.$params['type'], 'blog', '', $params);
endwhile;
else:
findme_elated_get_module_template_part('templates/parts/no-posts', 'blog', '', $params);
endif;
$html = ob_get_contents();
ob_end_clean();
wp_reset_postdata();
$return_obj = array(
'html' => $html,
);
echo json_encode($return_obj); exit;
}
add_action('wp_ajax_nopriv_findme_elated_blog_shortcode_load_more', 'findme_elated_blog_shortcode_load_more');
add_action( 'wp_ajax_findme_elated_blog_shortcode_load_more', 'findme_elated_blog_shortcode_load_more' );
}
if(!function_exists('findme_elated_get_user_custom_fields')) {
/**
* Function returns links and icons for author social networks
*
* return array
*/
function findme_elated_get_user_custom_fields() {
$user_social_array = array();
$social_network_array = array(
'facebook',
'twitter',
'linkedin',
'instagram',
'pinterest',
'tumblr',
'googleplus'
);
foreach($social_network_array as $network) {
if(get_the_author_meta($network) !== '') {
$$network = array(
'link' => get_the_author_meta($network),
'class' => 'social_'.$network.' eltd-author-social-'.$network.' eltd-author-social-icon'
);
$user_social_array[$network] = $$network;
}
}
return $user_social_array;
}
}
if(!function_exists('findme_elated_blog_item_has_link')) {
/**
* Function returns true/false depends is single post or in loop
*
* return boolean
*/
function findme_elated_blog_item_has_link() {
$is_link = (is_single() && (get_the_ID() === findme_elated_get_page_id())) ? false : true;
return $is_link;
}
}
if(!function_exists('findme_elated_get_blog_module')) {
/**
* Function returns single/list depending is single post or in loop
*
* return string
*/
function findme_elated_get_blog_module() {
$module = (is_single() && (get_the_ID() === findme_elated_get_page_id())) ? 'single' : 'list';
return $module;
}
}
if( !function_exists('findme_elated_return_post_format') ) {
/**
* Function return all parts on single.php page
*
* @return string with post format
*/
function findme_elated_return_post_format() {
$post_format = get_post_format();
$supported_post_formats = array('audio', 'video', 'link', 'quote', 'gallery');
if (in_array($post_format, $supported_post_formats)) {
$post_format = $post_format;
} else {
$post_format = 'standard';
}
return $post_format;
}
}
if( !function_exists('findme_elated_return_has_media') ) {
/**
* Function return all parts on single.php page
*
* @return string with post format
*/
function findme_elated_return_has_media() {
$post_format = get_post_format();
switch ($post_format):
case "video":
return get_post_meta(get_the_ID(), 'eltd_post_video_custom_meta', true) !== '' || get_post_meta(get_the_ID(), 'eltd_post_video_link_meta', true) !== '';
break;
case "audio":
return get_post_meta(get_the_ID(), 'eltd_post_audio_custom_meta', true) !== '' || get_post_meta(get_the_ID(), 'eltd_post_audio_link_meta', true) !== '';
break;
case "gallery":
return get_post_meta(get_the_ID(), 'eltd_post_gallery_images_meta', true) !== '';
break;
case "quote":
return get_post_meta(get_the_ID(), 'eltd_post_quote_text_meta', true) !== '';
break;
case "link":
return get_post_meta(get_the_ID(), 'eltd_post_link_link_meta', true) !== '';
break;
default:
return get_post_meta(get_the_ID(), 'eltd_blog_list_featured_image_meta', true) !== '' || has_post_thumbnail();
break;
endswitch;
}
}
if( !function_exists('findme_elated_blog_single_title_module') ) {
/**
* Function that replaces title image with single post featured image on single post page
*
* @see findme_elated_get_title() from title-functions.php file for list of available params
*
* @param array - array of default title values
*
* @return array of overridden values
*/
function findme_elated_blog_single_title_module($params) {
$default_params = $params;
//module title fields
$module_title_background_image = '';
$module_title_background_image_width = '';
$module_title_background_image_src = '';
//check if title area is visible on single post, from global options, or page itself
$show_title_area_blog_single = findme_elated_get_meta_field_intersect('show_title_area_blog', get_the_ID());
if($show_title_area_blog_single !== '') {
$blog_single_title_area_visible = $show_title_area_blog_single === 'yes' ? true : false;
$default_params['show_title_area'] = $blog_single_title_area_visible;
}
$show_title_img = true;
//is title image hidden for current page?
if (get_post_meta(get_the_ID(), 'eltd_hide_background_image_meta', true) == 'yes') {
$show_title_img = false;
}
//Check if title background image on page is set. Otherwise use single post featured image.
$background_image = '';
$background_image_meta = get_post_meta(get_the_ID(), 'eltd_title_area_background_image_meta', true);
if (empty($background_image_meta)) {
$background_image = get_the_post_thumbnail_url(get_the_ID(), 'full');
$module_title_background_image_src = $background_image;
}
if (!empty($background_image)) {
//check for background image width
$background_image_width = '';
$background_image_width_dimensions_array = findme_elated_get_image_dimensions($background_image);
if (count($background_image_width_dimensions_array)) {
$background_image_width = $background_image_width_dimensions_array['width'];
}
//is responsive image is set for current page?
$is_img_responsive = findme_elated_get_meta_field_intersect('title_area_background_image_responsive', get_the_ID());
if ($is_img_responsive == 'no' && $show_title_img) { //no need for those styles if image is set to be responsive
if (!empty($background_image)) {
$module_title_background_image = 'background-image:url(' . esc_url($background_image) . ');';
}
if (!empty($background_image_width)) {
$module_title_background_image_width = 'data-background-width="' . esc_attr($background_image_width) . '"';
}
}
$default_params['title_background_image'] = $module_title_background_image;
$default_params['title_background_image_width'] = $module_title_background_image_width;
$default_params['title_background_image_src'] = $module_title_background_image_src;
}
return $default_params;
}
}
if(!function_exists('findme_elated_full_height_title_class')) {
/**
* Function that adds class on title holder if full height title option is enabled for single post page
*
* @see findme_elated_title_classes() in filter-functions.php
*
* @param $classes array of classes
*
* @return array changed array of classes
*/
function findme_elated_full_height_title_class($classes) {
$full_height_title_area_meta = findme_elated_get_meta_field_intersect('full_height_title_area_blog', get_the_ID());
$classes[] = $full_height_title_area_meta == 'yes' ? 'eltd-title-full-height' : "";
return $classes;
}
add_filter('findme_elated_title_classes', 'findme_elated_full_height_title_class');
}
if(!function_exists('findme_elated_post_has_thumbnail')) {
/**
* Function that adds class on title holder if full height title option is enabled for single post page
*
* @see findme_elated_title_background_image_classes() in filter-functions.php
*
* @param $title_img string with title image url
*
* @return string with image
*/
function findme_elated_post_has_thumbnail($title_img) {
if(has_post_thumbnail()) {
$title_img = get_the_post_thumbnail_url(get_the_ID(), 'full');
}
return $title_img;
}
}
if (!function_exists('findme_elated_register_footer_sidebar')) {
function findme_elated_register_footer_sidebar() {
register_sidebar(array(
'name' => esc_html__('Footer Top Column 1', 'findme'),
'description' => esc_html__('Widgets added here will appear in the first column of top footer area', 'findme'),
'id' => 'footer_top_column_1',
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'
));
register_sidebar(array(
'name' => esc_html__('Footer Top Column 2', 'findme'),
'description' => esc_html__('Widgets added here will appear in the second column of top footer area', 'findme'),
'id' => 'footer_top_column_2',
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'
));
register_sidebar(array(
'name' => esc_html__('Footer Top Column 3', 'findme'),
'description' => esc_html__('Widgets added here will appear in the third column of top footer area', 'findme'),
'id' => 'footer_top_column_3',
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'
));
register_sidebar(array(
'name' => esc_html__('Footer Top Column 4', 'findme'),
'description' => esc_html__('Widgets added here will appear in the fourth column of top footer area', 'findme'),
'id' => 'footer_top_column_4',
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'
));
register_sidebar(array(
'name' => esc_html__('Footer Bottom Left Column', 'findme'),
'description' => esc_html__('Widgets added here will appear in the left column of bottom footer area', 'findme'),
'id' => 'footer_bottom_column_1',
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'
));
register_sidebar(array(
'name' => esc_html__('Footer Bottom Middle Column', 'findme'),
'description' => esc_html__('Widgets added here will appear in the middle column of bottom footer area', 'findme'),
'id' => 'footer_bottom_column_2',
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'
));
register_sidebar(array(
'name' => esc_html__('Footer Bottom Right Column', 'findme'),
'description' => esc_html__('Widgets added here will appear in the right column of bottom footer area', 'findme'),
'id' => 'footer_bottom_column_3',
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'
));
}
add_action('widgets_init', 'findme_elated_register_footer_sidebar');
}
if (!function_exists('findme_elated_get_footer')) {
/**
* Loads footer HTML
*/
function findme_elated_get_footer() {
$parameters = array();
$page_id = findme_elated_get_page_id();
$disable_footer_meta = get_post_meta($page_id, 'eltd_disable_footer_meta', true);
$parameters['display_footer'] = $disable_footer_meta === 'yes' ? false : true;
$parameters['display_footer_top'] = findme_elated_show_footer_top();
$parameters['display_footer_bottom'] = findme_elated_show_footer_bottom();
$parameters['footer_background_image'] = findme_elated_get_footer_background_image( );
$parameters['show_footer_image'] = findme_elated_show_footer_background_image();
findme_elated_get_module_template_part('templates/footer', 'footer', '', $parameters);
}
add_action('findme_elated_get_footer_template', 'findme_elated_get_footer');
}
if ( ! function_exists( 'findme_elated_get_footer_background_image' ) ) {
function findme_elated_get_footer_background_image() {
$background_image = findme_elated_get_meta_field_intersect('footer_background_image');
return $background_image;
}
}
if ( ! function_exists( 'findme_elated_show_footer_background_image' ) ) {
function findme_elated_show_footer_background_image() {
$background_image = findme_elated_get_meta_field_intersect('show_footer_image');
return $background_image;
}
}
if(!function_exists('findme_elated_show_footer_top')){
/**
* Check footer top showing
* Function check value from options and checks if footer columns are empty.
* return bool
*/
function findme_elated_show_footer_top(){
$footer_top_flag = false;
//check value from options and meta field on current page
$option_flag = (findme_elated_get_meta_field_intersect('show_footer_top') === 'yes') ? true : false;
//check footer columns.If they are empty, disable footer top
$columns_flag = false;
for($i = 1; $i <= 4; $i++){
$footer_columns_id = 'footer_top_column_'.$i;
if(is_active_sidebar($footer_columns_id)) {
$columns_flag = true;
break;
}
}
if($option_flag && $columns_flag){
$footer_top_flag = true;
}
return $footer_top_flag;
}
}
if(!function_exists('findme_elated_show_footer_bottom')){
/**
* Check footer bottom showing
* Function check value from options and checks if footer columns are empty.
* return bool
*/
function findme_elated_show_footer_bottom(){
$footer_bottom_flag = false;
//check value from options and meta field on current page
$option_flag = (findme_elated_get_meta_field_intersect('show_footer_bottom') === 'yes') ? true : false;
//check footer columns.If they are empty, disable footer bottom
$columns_flag = false;
for($i = 1; $i <= 3; $i++){
$footer_columns_id = 'footer_bottom_column_'.$i;
if(is_active_sidebar($footer_columns_id)) {
$columns_flag = true;
break;
}
}
if($option_flag && $columns_flag){
$footer_bottom_flag = true;
}
return $footer_bottom_flag;
}
}
if (!function_exists('findme_elated_get_content_bottom_area')) {
/**
* Loads content bottom area HTML with all needed parameters
*/
function findme_elated_get_content_bottom_area() {
$parameters = array();
//Current page id
$id = findme_elated_get_page_id();
//is content bottom area enabled for current page?
$parameters['content_bottom_area'] = findme_elated_get_meta_field_intersect('enable_content_bottom_area', $id);
if ($parameters['content_bottom_area'] === 'yes') {
//Sidebar for content bottom area
$parameters['content_bottom_area_sidebar'] = findme_elated_get_meta_field_intersect('content_bottom_sidebar_custom_display', $id);
//Content bottom area in grid
$parameters['grid_class'] = (findme_elated_get_meta_field_intersect('content_bottom_in_grid', $id)) === 'yes' ? 'eltd-grid' : 'eltd-full-width';
$parameters['content_bottom_style'] = array();
//Content bottom area background color
$background_color = findme_elated_get_meta_field_intersect('content_bottom_background_color', $id);
if ($background_color !== '') {
$parameters['content_bottom_style'][] = 'background-color: ' . $background_color . ';';
}
if(is_active_sidebar($parameters['content_bottom_area_sidebar'])){
findme_elated_get_module_template_part('templates/parts/content-bottom-area', 'footer', '', $parameters);
}
}
}
}
if (!function_exists('findme_elated_get_footer_top')) {
/**
* Return footer top HTML
*/
function findme_elated_get_footer_top() {
$parameters = array();
//get number of top footer columns
$parameters['footer_top_columns'] = findme_elated_options()->getOptionValue('footer_top_columns');
//get footer top grid/full width class
$parameters['footer_top_grid_class'] = findme_elated_options()->getOptionValue('footer_in_grid') === 'yes' ? 'eltd-grid' : 'eltd-full-width';
//get footer top other classes
$footer_top_classes = array();
//footer alignment
$footer_top_alignment = findme_elated_options()->getOptionValue('footer_top_columns_alignment');
$footer_top_classes[] = !empty($footer_top_alignment) ? 'eltd-footer-top-alignment-'.esc_attr($footer_top_alignment) : '';
$footer_top_classes = apply_filters('findme_elated_footer_top_classes', $footer_top_classes);
$parameters['footer_top_classes'] = implode(' ', $footer_top_classes);
findme_elated_get_module_template_part('templates/parts/footer-top', 'footer', '', $parameters);
}
}
if (!function_exists('findme_elated_get_footer_bottom')) {
/**
* Return footer bottom HTML
*/
function findme_elated_get_footer_bottom() {
$parameters = array();
//get number of bottom footer columns
$parameters['footer_bottom_columns'] = findme_elated_options()->getOptionValue('footer_bottom_columns');
//get footer top grid/full width class
$parameters['footer_bottom_grid_class'] = findme_elated_options()->getOptionValue('footer_in_grid') === 'yes' ? 'eltd-grid' : 'eltd-full-width';
//get footer top other classes
$footer_bottom_classes = array();
$footer_bottom_classes = apply_filters('findme_elated_footer_bottom_classes', $footer_bottom_classes);
$parameters['footer_bottom_classes'] = implode(' ', $footer_bottom_classes);
findme_elated_get_module_template_part('templates/parts/footer-bottom', 'footer', '', $parameters);
}
}/*! E-Gallery v1.2.0 by Elementor */
var EGallery=function(t){var e={};function i(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)i.d(n,s,function(e){return t[e]}.bind(null,s));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=9)}([function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e){function i(t,e){for(var i=0;i0&&void 0!==arguments[0]&&arguments[0],e=this.settings.tags,i=[];if(!e.length)return t?(this.$items.each(function(t){i.push(t)}),i):this.$items;var n=this.$items.filter(function(n,s){var r=s.dataset.eGalleryTags;return!!r&&(r=r.split(/[ ,]+/),!!e.some(function(t){return r.includes(t)})&&(t&&i.push(n),!0))});return t?i:n}},{key:"getImageData",value:function(t){return this.settings.tags.length&&(t=this.getActiveItems(!0)[t]),this.imagesData[t]}},{key:"compileTemplate",value:function(t,e){var i=this;return t.replace(/{{([^}]+)}}/g,function(t,n){return i.getTemplateArgs(e,n.trim())})}},{key:"createOverlay",value:function(t){var e=this.settings,i=e.classes,n=e.overlayTemplate,s=jQuery("
We at Unrealistic Trends believe that guest blogging is essential to make this a community blog. A platform where amateurs and experts can share their views and experiences and thereby, help the community as a whole.
We at Unrealistic Trends believe that guest blogging is essential to make this a community blog. A platform where amateurs and experts can share their views and experiences and thereby, help the community as a whole.
“The contacts that I’ve gained through them are just wonderful and amazing. The listings are verified and easy to find as per expectations.”
Travel Agent
faizan khan
“The wide range of professionals working in the fashion and grooming niche are present here on this portal. I have gained a lot of useful contacts from them.”
Blogger
Kashish singhania
“Clothes, Accessories, Health & Fitness Brands, Beauty Tips and Experts. They have everything that a person may need. Great Initiative to bring everything at a single place.”
BusinessOwner
Smriti Patheja
“I am a business professional related to lifestyle related products. Here, I have found every business that I needed in order to build a network with my business.”
FashionDesigner
Pamela Medina
“I am a fashion designer and often need to find people and the brands related to my work. This place has got me the best every time I came here for my search.”
Web Designer
Harsh Mittal
“Shopping according to the budget of specific things that are not easily available at general places are now becoming more comfortable with such sites.”
- All the top locations – and clubs, to cinemas, galleries, and more