This commit is contained in:
KhaiNguyen
2020-02-13 10:39:37 +07:00
commit 59401cb805
12867 changed files with 4646216 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
<?php
require_once __DIR__ . '/InstagramScraper/Instagram.php';
require_once __DIR__ . '/InstagramScraper/Endpoints.php';
require_once __DIR__ . '/InstagramScraper/InstagramQueryId.php';
require_once __DIR__ . '/InstagramScraper/Traits/ArrayLikeTrait.php';
require_once __DIR__ . '/InstagramScraper/Traits/InitializerTrait.php';
require_once __DIR__ . '/InstagramScraper/Model/AbstractModel.php';
require_once __DIR__ . '/InstagramScraper/Model/Account.php';
require_once __DIR__ . '/InstagramScraper/Model/CarouselMedia.php';
require_once __DIR__ . '/InstagramScraper/Model/Comment.php';
require_once __DIR__ . '/InstagramScraper/Model/Location.php';
require_once __DIR__ . '/InstagramScraper/Model/Media.php';
require_once __DIR__ . '/InstagramScraper/Model/Tag.php';
require_once __DIR__ . '/InstagramScraper/Exception/InstagramException.php';
require_once __DIR__ . '/InstagramScraper/Exception/InstagramAuthException.php';
require_once __DIR__ . '/InstagramScraper/Exception/InstagramNotFoundException.php';

View File

@@ -0,0 +1,182 @@
<?php
namespace InstagramScraper;
class Endpoints
{
const BASE_URL = 'https://www.instagram.com';
const LOGIN_URL = 'https://www.instagram.com/accounts/login/ajax/';
const ACCOUNT_PAGE = 'https://www.instagram.com/{username}';
const MEDIA_LINK = 'https://www.instagram.com/p/{code}';
const ACCOUNT_MEDIAS = 'https://www.instagram.com/graphql/query/?query_hash=42323d64886122307be10013ad2dcc44&variables={variables}';
const ACCOUNT_JSON_INFO = 'https://www.instagram.com/{username}/?__a=1';
const MEDIA_JSON_INFO = 'https://www.instagram.com/p/{code}/?__a=1';
const MEDIA_JSON_BY_LOCATION_ID = 'https://www.instagram.com/explore/locations/{{facebookLocationId}}/?__a=1&max_id={{maxId}}';
const MEDIA_JSON_BY_TAG = 'https://www.instagram.com/explore/tags/{tag}/?__a=1&max_id={max_id}';
const GENERAL_SEARCH = 'https://www.instagram.com/web/search/topsearch/?query={query}';
const ACCOUNT_JSON_INFO_BY_ID = 'ig_user({userId}){id,username,external_url,full_name,profile_pic_url,biography,followed_by{count},follows{count},media{count},is_private,is_verified}';
const COMMENTS_BEFORE_COMMENT_ID_BY_CODE = 'https://www.instagram.com/graphql/query/?query_id=17852405266163336&shortcode={{shortcode}}&first={{count}}&after={{commentId}}';
const LAST_LIKES_BY_CODE = 'ig_shortcode({{code}}){likes{nodes{id,user{id,profile_pic_url,username,follows{count},followed_by{count},biography,full_name,media{count},is_private,external_url,is_verified}},page_info}}';
const LIKES_BY_SHORTCODE = 'https://www.instagram.com/graphql/query/?query_id=17864450716183058&variables={"shortcode":"{{shortcode}}","first":{{count}},"after":"{{likeId}}"}';
const FOLLOWING_URL = 'https://www.instagram.com/graphql/query/?query_id=17874545323001329&id={{accountId}}&first={{count}}&after={{after}}';
const FOLLOWERS_URL = 'https://www.instagram.com/graphql/query/?query_id=17851374694183129&id={{accountId}}&first={{count}}&after={{after}}';
const FOLLOW_URL = 'https://www.instagram.com/web/friendships/{{accountId}}/follow/';
const UNFOLLOW_URL = 'https://www.instagram.com/web/friendships/{{accountId}}/unfollow/';
const USER_FEED = 'https://www.instagram.com/graphql/query/?query_id=17861995474116400&fetch_media_item_count=12&fetch_media_item_cursor=&fetch_comment_count=4&fetch_like=10';
const USER_FEED2 = 'https://www.instagram.com/?__a=1';
const INSTAGRAM_QUERY_URL = 'https://www.instagram.com/query/';
const INSTAGRAM_CDN_URL = 'https://scontent.cdninstagram.com/';
const ACCOUNT_JSON_PRIVATE_INFO_BY_ID = 'https://i.instagram.com/api/v1/users/{userId}/info/';
const ACCOUNT_MEDIAS2 = 'https://www.instagram.com/graphql/query/?query_id=17880160963012870&id={{accountId}}&first=10&after=';
// Look alike??
const URL_SIMILAR = 'https://www.instagram.com/graphql/query/?query_id=17845312237175864&id=4663052';
const GRAPH_QL_QUERY_URL = 'https://www.instagram.com/graphql/query/?query_id={{queryId}}';
private static $requestMediaCount = 30;
/**
* @param int $count
*/
public static function setAccountMediasRequestCount($count)
{
static::$requestMediaCount = $count;
}
public static function getAccountMediasRequestCount()
{
return static::$requestMediaCount;
}
public static function getAccountPageLink($username)
{
return str_replace('{username}', urlencode($username), static::ACCOUNT_PAGE);
}
public static function getAccountJsonLink($username)
{
return str_replace('{username}', urlencode($username), static::ACCOUNT_JSON_INFO);
}
public static function getAccountJsonInfoLinkByAccountId($id)
{
return str_replace('{userId}', urlencode($id), static::ACCOUNT_JSON_INFO_BY_ID);
}
public static function getAccountJsonPrivateInfoLinkByAccountId($id)
{
return str_replace('{userId}', urlencode($id), static::ACCOUNT_JSON_PRIVATE_INFO_BY_ID);
}
public static function getAccountMediasJsonLink($variables)
{
return str_replace('{variables}', urlencode($variables), static::ACCOUNT_MEDIAS);
}
public static function getMediaPageLink($code)
{
return str_replace('{code}', urlencode($code), static::MEDIA_LINK);
}
public static function getMediaJsonLink($code)
{
return str_replace('{code}', urlencode($code), static::MEDIA_JSON_INFO);
}
public static function getMediasJsonByLocationIdLink($facebookLocationId, $maxId = '')
{
$url = str_replace('{{facebookLocationId}}', urlencode($facebookLocationId), static::MEDIA_JSON_BY_LOCATION_ID);
return str_replace('{{maxId}}', urlencode($maxId), $url);
}
public static function getMediasJsonByTagLink($tag, $maxId = '')
{
$url = str_replace('{tag}', urlencode($tag), static::MEDIA_JSON_BY_TAG);
return str_replace('{max_id}', urlencode($maxId), $url);
}
public static function getGeneralSearchJsonLink($query)
{
return str_replace('{query}', urlencode($query), static::GENERAL_SEARCH);
}
public static function getCommentsBeforeCommentIdByCode($code, $count, $commentId)
{
$url = str_replace('{{shortcode}}', urlencode($code), static::COMMENTS_BEFORE_COMMENT_ID_BY_CODE);
$url = str_replace('{{count}}', urlencode($count), $url);
return str_replace('{{commentId}}', urlencode($commentId), $url);
}
public static function getLastLikesByCodeLink($code)
{
$url = str_replace('{{code}}', urlencode($code), static::LAST_LIKES_BY_CODE);
return $url;
}
public static function getLastLikesByCode($code, $count, $lastLikeID)
{
$url = str_replace('{{shortcode}}', urlencode($code), static::LIKES_BY_SHORTCODE);
$url = str_replace('{{count}}', urlencode($count), $url);
$url = str_replace('{{likeId}}', urlencode($lastLikeID), $url);
return $url;
}
public static function getGraphQlUrl($queryId, $parameters)
{
$url = str_replace('{{queryId}}', urlencode($queryId), static::GRAPH_QL_QUERY_URL);
if (!empty($parameters)) {
$query_string = http_build_query($parameters);
$url .= '&' . $query_string;
}
return $url;
}
public static function getFollowUrl($accountId)
{
$url = str_replace('{{accountId}}', urlencode($accountId), static::FOLLOW_URL);
return $url;
}
public static function getFollowersJsonLink($accountId, $count, $after = '')
{
$url = str_replace('{{accountId}}', urlencode($accountId), static::FOLLOWERS_URL);
$url = str_replace('{{count}}', urlencode($count), $url);
if ($after === '') {
$url = str_replace('&after={{after}}', '', $url);
} else {
$url = str_replace('{{after}}', urlencode($after), $url);
}
return $url;
}
public static function getFollowingJsonLink($accountId, $count, $after = '')
{
$url = str_replace('{{accountId}}', urlencode($accountId), static::FOLLOWING_URL);
$url = str_replace('{{count}}', urlencode($count), $url);
if ($after === '') {
$url = str_replace('&after={{after}}', '', $url);
} else {
$url = str_replace('{{after}}', urlencode($after), $url);
}
return $url;
}
public static function getUserStoriesLink()
{
$url = self::getGraphQlUrl(InstagramQueryId::USER_STORIES, ['variables' => json_encode([])]);
return $url;
}
public static function getStoriesLink($variables)
{
$url = self::getGraphQlUrl(InstagramQueryId::STORIES, ['variables' => json_encode($variables)]);
return $url;
}
}

View File

@@ -0,0 +1,9 @@
<?php
namespace InstagramScraper\Exception;
class InstagramAuthException extends \Exception
{
}

View File

@@ -0,0 +1,7 @@
<?php
namespace InstagramScraper\Exception;
class InstagramException extends \Exception
{
}

View File

@@ -0,0 +1,7 @@
<?php
namespace InstagramScraper\Exception;
class InstagramNotFoundException extends \Exception
{
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,15 @@
<?php
namespace InstagramScraper;
class InstagramQueryId
{
/**
* id = {{accoundId}}, first = {{count}}, after = {{mediaId}}
*/
const USER_MEDIAS = '17880160963012870';
const USER_STORIES = '17890626976041463';
const STORIES = '17873473675158481';
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,28 @@
<?php
namespace InstagramScraper\Model;
use InstagramScraper\Traits\ArrayLikeTrait;
use InstagramScraper\Traits\InitializerTrait;
/**
* Class AbstractModel
* @package InstagramScraper\Model
*/
abstract class AbstractModel implements \ArrayAccess
{
use InitializerTrait, ArrayLikeTrait;
/**
* @var array
*/
protected static $initPropertiesMap = [];
/**
* @return array
*/
public static function getColumns()
{
return \array_keys(static::$initPropertiesMap);
}
}

View File

@@ -0,0 +1,249 @@
<?php
namespace InstagramScraper\Model;
/**
* Class Account
* @package InstagramScraper\Model
*/
class Account extends AbstractModel
{
/**
* User id
* @var string
*/
protected $id = 0;
/**
* Username
* @var string
*/
protected $username = '';
/**
* Full name
* @var string
*/
protected $fullName = '';
/**
* Profile picture url
* @var string
*/
protected $profilePicUrl = '';
/**
* Profile picture url HD
* @var string
*/
protected $profilePicUrlHd = '';
/**
* Information filled by user
* @var string
*/
protected $biography = '';
/**
* Url provided by user in profile
* @var string
*/
protected $externalUrl = '';
/**
* Number of subscriptions
* @var integer
*/
protected $followsCount = 0;
/**
* Number of followers
* @var integer
*/
protected $followedByCount = 0;
/**
* Number of medias published by user
* @var integer
*/
protected $mediaCount = 0;
/**
* true if account is private
* @var boolean
*/
protected $isPrivate = false;
/**
* true if verified by Instagram as celebrity
* @var boolean
*/
protected $isVerified = false;
/**
* @var bool
*/
protected $isLoaded = false;
/**
* @return bool
*/
public function isLoaded()
{
return $this->isLoaded;
}
/**
* @return string
*/
public function getUsername()
{
return $this->username;
}
/**
* @return int
*/
public function getId()
{
if (PHP_INT_SIZE > 4) {
$this->id = (int)$this->id;
}
return $this->id;
}
/**
* @return string
*/
public function getFullName()
{
return $this->fullName;
}
/**
* @return string
*/
public function getProfilePicUrl()
{
return $this->profilePicUrl;
}
/**
* @return string
*/
public function getProfilePicUrlHd()
{
$toReturn = $this->profilePicUrl;
if ($this->profilePicUrlHd !== '') {
$toReturn = $this->profilePicUrlHd;
}
return $toReturn;
}
/**
* @return string
*/
public function getBiography()
{
return $this->biography;
}
/**
* @return string
*/
public function getExternalUrl()
{
return $this->externalUrl;
}
/**
* @return int
*/
public function getFollowsCount()
{
return $this->followsCount;
}
/**
* @return int
*/
public function getFollowedByCount()
{
return $this->followedByCount;
}
/**
* @return int
*/
public function getMediaCount()
{
return $this->mediaCount;
}
/**
* @return bool
*/
public function isPrivate()
{
return $this->isPrivate;
}
/**
* @return bool
*/
public function isVerified()
{
return $this->isVerified;
}
/**
* @param $value
* @param $prop
* @param $array
*/
protected function initPropertiesCustom($value, $prop, $array)
{
switch ($prop) {
case 'id':
case 'pk':
$this->id = $value;
break;
case 'username':
$this->username = $value;
break;
case 'full_name':
$this->fullName = $value;
break;
case 'profile_pic_url':
$this->profilePicUrl = $value;
break;
case 'profile_pic_url_hd':
$this->profilePicUrlHd = $value;
break;
case 'biography':
$this->biography = $value;
break;
case 'external_url':
$this->externalUrl = $value;
break;
case 'edge_follow':
$this->followsCount = !empty($array[$prop]['count']) ? (int)$array[$prop]['count'] : 0;
break;
case 'edge_followed_by':
$this->followedByCount = !empty($array[$prop]['count']) ? (int)$array[$prop]['count'] : 0;
break;
case 'edge_owner_to_timeline_media':
$this->mediaCount = !empty($array[$prop]['count']) ? $array[$prop]['count'] : 0;
break;
case 'is_private':
$this->isPrivate = (bool)$value;
break;
case 'is_verified':
$this->isVerified = (bool)$value;
break;
}
}
}

View File

@@ -0,0 +1,235 @@
<?php
namespace InstagramScraper\Model;
/**
* Class CarouselMedia
* @package InstagramScraper\Model
*/
class CarouselMedia
{
/**
* @var string
*/
private $type;
/**
* @var string
*/
private $imageLowResolutionUrl;
/**
* @var string
*/
private $imageThumbnailUrl;
/**
* @var string
*/
private $imageStandardResolutionUrl;
/**
* @var string
*/
private $imageHighResolutionUrl;
/**
* @var string
*/
private $videoLowResolutionUrl;
/**
* @var string
*/
private $videoStandardResolutionUrl;
/**
* @var string
*/
private $videoLowBandwidthUrl;
/**
* @var
*/
private $videoViews;
/**
* CarouselMedia constructor.
*/
public function __construct()
{
return $this;
}
/**
* @return mixed
*/
public function getType()
{
return $this->type;
}
/**
* @param mixed $type
*
* @return $this
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
/**
* @return mixed
*/
public function getImageLowResolutionUrl()
{
return $this->imageLowResolutionUrl;
}
/**
* @param mixed $imageLowResolutionUrl
*
* @return CarouselMedia
*/
public function setImageLowResolutionUrl($imageLowResolutionUrl)
{
$this->imageLowResolutionUrl = $imageLowResolutionUrl;
return $this;
}
/**
* @return mixed
*/
public function getImageThumbnailUrl()
{
return $this->imageThumbnailUrl;
}
/**
* @param mixed $imageThumbnailUrl
*
* @return CarouselMedia
*/
public function setImageThumbnailUrl($imageThumbnailUrl)
{
$this->imageThumbnailUrl = $imageThumbnailUrl;
return $this;
}
/**
* @return mixed
*/
public function getImageStandardResolutionUrl()
{
return $this->imageStandardResolutionUrl;
}
/**
* @param mixed $imageStandardResolutionUrl
*
* @return CarouselMedia
*/
public function setImageStandardResolutionUrl($imageStandardResolutionUrl)
{
$this->imageStandardResolutionUrl = $imageStandardResolutionUrl;
return $this;
}
/**
* @return mixed
*/
public function getImageHighResolutionUrl()
{
return $this->imageHighResolutionUrl;
}
/**
* @param mixed $imageHighResolutionUrl
*
* @return CarouselMedia
*/
public function setImageHighResolutionUrl($imageHighResolutionUrl)
{
$this->imageHighResolutionUrl = $imageHighResolutionUrl;
return $this;
}
/**
* @return mixed
*/
public function getVideoLowResolutionUrl()
{
return $this->videoLowResolutionUrl;
}
/**
* @param mixed $videoLowResolutionUrl
*
* @return CarouselMedia
*/
public function setVideoLowResolutionUrl($videoLowResolutionUrl)
{
$this->videoLowResolutionUrl = $videoLowResolutionUrl;
return $this;
}
/**
* @return mixed
*/
public function getVideoStandardResolutionUrl()
{
return $this->videoStandardResolutionUrl;
}
/**
* @param mixed $videoStandardResolutionUrl
*
* @return CarouselMedia
*/
public function setVideoStandardResolutionUrl($videoStandardResolutionUrl)
{
$this->videoStandardResolutionUrl = $videoStandardResolutionUrl;
return $this;
}
/**
* @return mixed
*/
public function getVideoLowBandwidthUrl()
{
return $this->videoLowBandwidthUrl;
}
/**
* @param mixed $videoLowBandwidthUrl
*
* @return CarouselMedia
*/
public function setVideoLowBandwidthUrl($videoLowBandwidthUrl)
{
$this->videoLowBandwidthUrl = $videoLowBandwidthUrl;
return $this;
}
/**
* @return mixed
*/
public function getVideoViews()
{
return $this->videoViews;
}
/**
* @param mixed $videoViews
*
* @return CarouselMedia
*/
public function setVideoViews($videoViews)
{
$this->videoViews = $videoViews;
return $this;
}
}

View File

@@ -0,0 +1,87 @@
<?php
namespace InstagramScraper\Model;
class Comment extends AbstractModel
{
/**
* @var
*/
protected $id;
/**
* @var
*/
protected $text;
/**
* @var
*/
protected $createdAt;
/**
* @var Account
*/
protected $owner;
/**
* @var bool
*/
protected $isLoaded = false;
/**
* @return mixed
*/
public function getId()
{
return $this->id;
}
/**
* @return mixed
*/
public function getText()
{
return $this->text;
}
/**
* @return mixed
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* @return Account
*/
public function getOwner()
{
return $this->owner;
}
/**
* @param $value
* @param $prop
*/
protected function initPropertiesCustom($value, $prop)
{
switch ($prop) {
case 'id':
$this->id = $value;
break;
case 'created_at':
$this->createdAt = $value;
break;
case 'text':
$this->text = $value;
break;
case 'owner':
$this->owner = Account::create($value);
break;
}
}
}

View File

@@ -0,0 +1,50 @@
<?php
namespace InstagramScraper\Model;
class Like extends AbstractModel
{
/**
* @var
*/
protected $id;
/**
* @var Account
*/
protected $username;
/**
* @return mixed
*/
public function getId()
{
return $this->id;
}
/**
* @return mixed
*/
public function getUserName()
{
return $this->username;
}
/**
* @param $value
* @param $prop
*/
protected function initPropertiesCustom($value, $prop)
{
switch ($prop) {
case 'id':
$this->id = $value;
break;
case 'username':
$this->username = $value;
break;
}
}
}

View File

@@ -0,0 +1,109 @@
<?php
namespace InstagramScraper\Model;
class Location extends AbstractModel
{
/**
* @var array
*/
protected static $initPropertiesMap = [
'id' => 'id',
'has_public_page' => 'hasPublicPage',
'name' => 'name',
'slug' => 'slug',
'lat' => 'lat',
'lng' => 'lng',
'modified' => 'modified'
];
/**
* @var
*/
protected $id;
/**
* @var
*/
protected $hasPublicPage;
/**
* @var
*/
protected $name;
/**
* @var
*/
protected $slug;
/**
* @var
*/
protected $lng;
/**
* @var
*/
protected $lat;
/**
* @var bool
*/
protected $isLoaded = false;
/**
* @var
*/
protected $modified;
/**
* @return mixed
*/
public function getId()
{
return $this->id;
}
/**
* @return mixed
*/
public function getHasPublicPage()
{
return $this->hasPublicPage;
}
/**
* @return mixed
*/
public function getName()
{
return $this->name;
}
/**
* @return mixed
*/
public function getSlug()
{
return $this->slug;
}
/**
* @return mixed
*/
public function getLng()
{
return $this->lng;
}
/**
* @return mixed
*/
public function getLat()
{
return $this->lat;
}
/**
* @return mixed
*/
public function getModified()
{
return $this->modified;
}
}

View File

@@ -0,0 +1,663 @@
<?php
namespace InstagramScraper\Model;
use InstagramScraper\Endpoints;
/**
* Class Media
* @package InstagramScraper\Model
*/
class Media extends AbstractModel
{
const TYPE_IMAGE = 'image';
const TYPE_VIDEO = 'video';
const TYPE_SIDECAR = 'sidecar';
const TYPE_CAROUSEL = 'carousel';
/**
* @var string
*/
protected $id = '';
/**
* @var string
*/
protected $shortCode = '';
/**
* @var int
*/
protected $createdTime = 0;
/**
* @var string
*/
protected $type = '';
/**
* @var string
*/
protected $link = '';
/**
* @var string
*/
protected $imageLowResolutionUrl = '';
/**
* @var string
*/
protected $imageThumbnailUrl = '';
/**
* @var string
*/
protected $imageStandardResolutionUrl = '';
/**
* @var string
*/
protected $imageHighResolutionUrl = '';
/**
* @var array
*/
protected $squareThumbnailsUrl = [];
/**
* @var array
*/
protected $carouselMedia = [];
/**
* @var string
*/
protected $caption = '';
/**
* @var bool
*/
protected $isCaptionEdited = false;
/**
* @var bool
*/
protected $isAd = false;
/**
* @var string
*/
protected $videoLowResolutionUrl = '';
/**
* @var string
*/
protected $videoStandardResolutionUrl = '';
/**
* @var string
*/
protected $videoLowBandwidthUrl = '';
/**
* @var int
*/
protected $videoViews = 0;
/**
* @var Account
*/
protected $owner;
/**
* @var int
*/
protected $ownerId = 0;
/**
* @var int
*/
protected $likesCount = 0;
/**
* @var
*/
protected $locationId;
/**
* @var string
*/
protected $locationName = '';
/**
* @var string
*/
protected $commentsCount = 0;
/**
* @var Comment[]
*/
protected $comments = [];
/**
* @var bool
*/
protected $hasMoreComments = false;
/**
* @var string
*/
protected $commentsNextPage = '';
/**
* @var Media[]|array
*/
protected $sidecarMedias = [];
/**
* @param string $code
*
* @return int
*/
public static function getIdFromCode($code)
{
$alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';
$id = 0;
for ($i = 0; $i < strlen($code); $i++) {
$c = $code[$i];
$id = $id * 64 + strpos($alphabet, $c);
}
return $id;
}
/**
* @param string $id
*
* @return mixed
*/
public static function getLinkFromId($id)
{
$code = Media::getCodeFromId($id);
return Endpoints::getMediaPageLink($code);
}
/**
* @param string $id
*
* @return string
*/
public static function getCodeFromId($id)
{
$parts = explode('_', $id);
$id = $parts[0];
$alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';
$code = '';
while ($id > 0) {
$remainder = $id % 64;
$id = ($id - $remainder) / 64;
$code = $alphabet{$remainder} . $code;
};
return $code;
}
/**
* @return mixed
*/
public function getId()
{
return $this->id;
}
/**
* @return string
*/
public function getShortCode()
{
return $this->shortCode;
}
/**
* @return int
*/
public function getCreatedTime()
{
return $this->createdTime;
}
/**
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* @return string
*/
public function getLink()
{
return $this->link;
}
/**
* @return string
*/
public function getImageLowResolutionUrl()
{
return $this->imageLowResolutionUrl;
}
/**
* @return string
*/
public function getImageThumbnailUrl()
{
return $this->imageThumbnailUrl;
}
/**
* @return string
*/
public function getImageStandardResolutionUrl()
{
return $this->imageStandardResolutionUrl;
}
/**
* @return string
*/
public function getImageHighResolutionUrl()
{
return $this->imageHighResolutionUrl;
}
/**
* @return array
*/
public function getSquareThumbnailsUrl()
{
return $this->squareThumbnailsUrl;
}
/**
* @return array
*/
public function getCarouselMedia()
{
return $this->carouselMedia;
}
/**
* @return string
*/
public function getCaption()
{
return $this->caption;
}
/**
* @return bool
*/
public function isCaptionEdited()
{
return $this->isCaptionEdited;
}
/**
* @return bool
*/
public function isAd()
{
return $this->isAd;
}
/**
* @return string
*/
public function getVideoLowResolutionUrl()
{
return $this->videoLowResolutionUrl;
}
/**
* @return string
*/
public function getVideoStandardResolutionUrl()
{
return $this->videoStandardResolutionUrl;
}
/**
* @return string
*/
public function getVideoLowBandwidthUrl()
{
return $this->videoLowBandwidthUrl;
}
/**
* @return int
*/
public function getVideoViews()
{
return $this->videoViews;
}
/**
* @return int
*/
public function getOwnerId()
{
return $this->ownerId;
}
/**
* @return int
*/
public function getLikesCount()
{
return $this->likesCount;
}
/**
* @return mixed
*/
public function getLocationId()
{
return $this->locationId;
}
/**
* @return string
*/
public function getLocationName()
{
return $this->locationName;
}
/**
* @return string
*/
public function getCommentsCount()
{
return $this->commentsCount;
}
/**
* @return Comment[]
*/
public function getComments()
{
return $this->comments;
}
/**
* @return bool
*/
public function hasMoreComments()
{
return $this->hasMoreComments;
}
/**
* @return string
*/
public function getCommentsNextPage()
{
return $this->commentsNextPage;
}
/**
* @return Media[]|array
*/
public function getSidecarMedias()
{
return $this->sidecarMedias;
}
/**
* @param $value
* @param $prop
*/
protected function initPropertiesCustom($value, $prop, $arr)
{
switch ($prop) {
case 'id':
$this->id = $value;
break;
case 'type':
$this->type = $value;
break;
case 'created_time':
$this->createdTime = (int)$value;
break;
case 'code':
$this->shortCode = $value;
$this->link = Endpoints::getMediaPageLink($this->shortCode);
break;
case 'link':
$this->link = $value;
break;
case 'comments':
$this->commentsCount = $arr[$prop]['count'];
break;
case 'likes':
$this->likesCount = $arr[$prop]['count'];
break;
case 'display_resources':
foreach ($value as $thumbnail) {
$thumbnailsUrl[] = $thumbnail['src'];
switch ($thumbnail['config_width']) {
case 640:
$this->imageThumbnailUrl = $thumbnail['src'];
break;
case 750:
$this->imageLowResolutionUrl = $thumbnail['src'];
break;
case 1080:
$this->imageStandardResolutionUrl = $thumbnail['src'];
break;
default:
;
}
}
$this->squareThumbnailsUrl = $thumbnailsUrl;
break;
case 'display_url':
$this->imageHighResolutionUrl = $value;
break;
case 'display_src':
$this->imageHighResolutionUrl = $value;
if (!isset($this->type)) {
$this->type = static::TYPE_IMAGE;
}
break;
case 'carousel_media':
$this->type = self::TYPE_CAROUSEL;
$this->carouselMedia = [];
foreach ($arr["carousel_media"] as $carouselArray) {
self::setCarouselMedia($arr, $carouselArray, $this);
}
break;
case 'caption':
$this->caption = $arr[$prop];
break;
case 'video_views':
$this->videoViews = $value;
$this->type = static::TYPE_VIDEO;
break;
case 'videos':
$this->videoLowResolutionUrl = $arr[$prop]['low_resolution']['url'];
$this->videoStandardResolutionUrl = $arr[$prop]['standard_resolution']['url'];
$this->videoLowBandwidthUrl = $arr[$prop]['low_bandwidth']['url'];
break;
case 'video_resources':
foreach ($value as $video) {
if ($video['profile'] == 'MAIN') {
$this->videoStandardResolutionUrl = $video['src'];
} elseif ($video['profile'] == 'BASELINE') {
$this->videoLowResolutionUrl = $video['src'];
$this->videoLowBandwidthUrl = $video['src'];
}
}
break;
case 'location':
$this->locationId = $arr[$prop]['id'];
$this->locationName = $arr[$prop]['name'];
break;
case 'user':
$this->owner = Account::create($arr[$prop]);
break;
case 'is_video':
if ((bool)$value) {
$this->type = static::TYPE_VIDEO;
}
break;
case 'video_url':
$this->videoStandardResolutionUrl = $value;
break;
case 'video_view_count':
$this->videoViews = $value;
break;
case 'caption_is_edited':
$this->isCaptionEdited = $value;
break;
case 'is_ad':
$this->isAd = $value;
break;
case 'taken_at_timestamp':
$this->createdTime = $value;
break;
case 'shortcode':
$this->shortCode = $value;
$this->link = Endpoints::getMediaPageLink($this->shortCode);
break;
case 'edge_media_to_comment':
if (isset($arr[$prop]['count'])) {
$this->commentsCount = (int) $arr[$prop]['count'];
}
if (isset($arr[$prop]['edges']) && is_array($arr[$prop]['edges'])) {
foreach ($arr[$prop]['edges'] as $commentData) {
$this->comments[] = Comment::create($commentData['node']);
}
}
if (isset($arr[$prop]['page_info']['has_next_page'])) {
$this->hasMoreComments = (bool) $arr[$prop]['page_info']['has_next_page'];
}
if (isset($arr[$prop]['page_info']['end_cursor'])) {
$this->commentsNextPage = (string) $arr[$prop]['page_info']['end_cursor'];
}
break;
case 'edge_media_preview_like':
$this->likesCount = $arr[$prop]['count'];
break;
case 'edge_liked_by':
$this->likesCount = $arr[$prop]['count'];
break;
case 'edge_media_to_caption':
if (is_array($arr[$prop]['edges']) && !empty($arr[$prop]['edges'])) {
$first_caption = $arr[$prop]['edges'][0];
if (is_array($first_caption) && isset($first_caption['node'])) {
if (is_array($first_caption['node']) && isset($first_caption['node']['text'])) {
$this->caption = $arr[$prop]['edges'][0]['node']['text'];
}
}
}
break;
case 'edge_sidecar_to_children':
if (!is_array($arr[$prop]['edges'])) {
break;
}
foreach ($arr[$prop]['edges'] as $edge) {
if (!isset($edge['node'])) {
continue;
}
$this->sidecarMedias[] = static::create($edge['node']);
}
break;
case 'owner':
$this->owner = Account::create($arr[$prop]);
break;
case 'date':
$this->createdTime = (int)$value;
break;
case '__typename':
if ($value == 'GraphImage') {
$this->type = static::TYPE_IMAGE;
} else if ($value == 'GraphVideo') {
$this->type = static::TYPE_VIDEO;
} else if ($value == 'GraphSidecar') {
$this->type = static::TYPE_SIDECAR;
}
break;
}
if (!$this->ownerId && !is_null($this->owner)) {
$this->ownerId = $this->getOwner()->getId();
}
}
/**
* @param $mediaArray
* @param $carouselArray
* @param $instance
*
* @return mixed
*/
private static function setCarouselMedia($mediaArray, $carouselArray, $instance)
{
$carouselMedia = new CarouselMedia();
$carouselMedia->setType($carouselArray['type']);
if (isset($carouselArray['images'])) {
$carouselImages = self::getImageUrls($carouselArray['images']['standard_resolution']['url']);
$carouselMedia->setImageLowResolutionUrl($carouselImages['low']);
$carouselMedia->setImageThumbnailUrl($carouselImages['thumbnail']);
$carouselMedia->setImageStandardResolutionUrl($carouselImages['standard']);
$carouselMedia->setImageHighResolutionUrl($carouselImages['high']);
}
if ($carouselMedia->getType() === self::TYPE_VIDEO) {
if (isset($mediaArray['video_views'])) {
$carouselMedia->setVideoViews($carouselArray['video_views']);
}
if (isset($carouselArray['videos'])) {
$carouselMedia->setVideoLowResolutionUrl($carouselArray['videos']['low_resolution']['url']);
$carouselMedia->setVideoStandardResolutionUrl($carouselArray['videos']['standard_resolution']['url']);
$carouselMedia->setVideoLowBandwidthUrl($carouselArray['videos']['low_bandwidth']['url']);
}
}
array_push($instance->carouselMedia, $carouselMedia);
return $mediaArray;
}
/**
* @param string $imageUrl
*
* @return array
*/
private static function getImageUrls($imageUrl)
{
$parts = explode('/', parse_url($imageUrl)['path']);
$imageName = $parts[sizeof($parts) - 1];
$urls = [
'thumbnail' => Endpoints::INSTAGRAM_CDN_URL . 't/s150x150/' . $imageName,
'low' => Endpoints::INSTAGRAM_CDN_URL . 't/s320x320/' . $imageName,
'standard' => Endpoints::INSTAGRAM_CDN_URL . 't/s640x640/' . $imageName,
'high' => Endpoints::INSTAGRAM_CDN_URL . 't/' . $imageName,
];
return $urls;
}
/**
* @return Account
*/
public function getOwner()
{
return $this->owner;
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace InstagramScraper\Model;
/**
* Class Story
* @package InstagramScraper\Model
*/
class Story extends Media
{
private $skip_prop = [
'owner' => true,
];
/***
* We do not need some values - do not parse it for Story,
* for example - we do not need owner object inside story
*
* @param $value
* @param $prop
* @param $arr
*/
protected function initPropertiesCustom($value, $prop, $arr)
{
if (!empty($this->skip_prop[$prop])) {
return;
}
parent::initPropertiesCustom($value, $prop, $arr);
}
}

View File

@@ -0,0 +1,55 @@
<?php
namespace InstagramScraper\Model;
/**
* Class Tag
* @package InstagramScraper\Model
*/
class Tag extends AbstractModel
{
/**
* @var array
*/
protected static $initPropertiesMap = [
'media_count' => 'mediaCount',
'name' => 'name',
'id' => 'initInt',
];
/**
* @var int
*/
protected $mediaCount = 0;
/**
* @var string
*/
protected $name;
/**
* @var int
*/
protected $id;
/**
* @return int
*/
public function getMediaCount()
{
return $this->mediaCount;
}
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @return int
*/
public function getId()
{
return $this->id;
}
}

View File

@@ -0,0 +1,41 @@
<?php
namespace InstagramScraper\Model;
/**
* Class UserStories
* @package InstagramScraper\Model
*/
class UserStories extends AbstractModel
{
/** @var Account */
protected $owner;
/** @var Story[] */
protected $stories;
public function setOwner($owner)
{
$this->owner = $owner;
}
public function getOwner()
{
return $this->owner;
}
public function addStory($story)
{
$this->stories[] = $story;
}
public function setStories($stories)
{
$this->stories = $stories;
}
public function getStories()
{
return $this->stories;
}
}

View File

@@ -0,0 +1,113 @@
<?php
/**
* File: ArrayLikeTrait.php
* Project: instagram-php-scraper
* User: evgen
* Date: 19.07.17
* Time: 11:50
*/
namespace InstagramScraper\Traits;
/**
* ArrayAccess implementation
*/
trait ArrayLikeTrait
{
/**
* @param mixed $offset
*
* @return bool
*/
public function offsetExists($offset)
{
return $this->isMethod($offset, 'get') || \property_exists($this, $offset);
}
/**
* @param mixed $offset
*
* @return mixed
*/
public function offsetGet($offset)
{
if ($run = $this->isMethod($offset, 'get')) {
return $this->run($run);
} elseif (\property_exists($this, $offset)) {
if (isset($this->{$offset})) {
return $this->{$offset};
} elseif (isset($this::$offset)) {
return $this::$offset;
}
}
return null;
}
/**
* @param mixed $offset
* @param mixed $value
*
* @return void
*/
public function offsetSet($offset, $value)
{
if ($run = $this->isMethod($offset, 'set')) {
$this->run($run);
} else {
$this->{$offset} = $value;
}
}
/**
* @param mixed $offset
*
* @return void
*/
public function offsetUnset($offset)
{
if ($run = $this->isMethod($offset, 'unset')) {
$this->run($run);
} else {
$this->{$offset} = null;
}
}
/**
* @param $method
* @param $case
*
* @return bool|string
*/
protected function isMethod($method, $case)
{
$uMethod = $case . \ucfirst($method);
if (\method_exists($this, $uMethod)) {
return $uMethod;
}
if (\method_exists($this, $method)) {
return $method;
}
return false;
}
/**
* @param $method
*
* @return mixed
*/
protected function run($method)
{
if (\is_array($method)) {
$params = $method;
$method = \array_shift($params);
if ($params) {
return \call_user_func_array([$this, $method], $params);
}
}
return \call_user_func([$this, $method]);
}
}

View File

@@ -0,0 +1,334 @@
<?php
/**
* File: InitializerTrait.php
* Project: instagram-php-scraper
* User: evgen
* Date: 19.07.17
* Time: 11:50
*/
namespace InstagramScraper\Traits;
trait InitializerTrait
{
/**
* @var bool
*/
protected $isNew = true;
/**
* @var bool
*/
protected $isLoaded = false;
/**
* @var bool - init data was empty
*/
protected $isLoadEmpty = true;
/**
* @var bool
*/
protected $isFake = false;
/**
* @var int
*/
protected $isAutoConstruct = false;
/**
* @var int
*/
protected $modified;
/**
* Array of initialization data
*
* @var array
*/
protected $data = [];
/**
* @param array $props
*/
protected function __construct(array $props = null)
{
$this->beforeInit();
$this->modified = \time();
if ($this->isAutoConstruct) {
$this->initAuto();
} elseif (empty($props)) {
$this->initDefaults();
} else {
$this->init($props);
}
$this->afterInit();
}
/**
* @return $this
*/
protected function beforeInit()
{
return $this;
}
/**
* @return $this
*/
final protected function initAuto()
{
foreach ($this as $prop => $value) {
if (isset(static::$initPropertiesMap[$prop]) and $methodOrProp = static::$initPropertiesMap[$prop] and \method_exists($this,
$methodOrProp)
) {
//if there is method then use it firstly
\call_user_func([$this, $methodOrProp], $value, $prop);
}
}
$this->isNew = false;
$this->isLoaded = true;
$this->isLoadEmpty = false;
return $this;
}
/**
* @return $this
*/
protected function initDefaults()
{
return $this;
}
/**
* @param array $props
*
* @return $this
*/
final protected function init(array $props)
{
//?reflection?
foreach ($props as $prop => $value) {
if (\method_exists($this, 'initPropertiesCustom')) {
\call_user_func([$this, 'initPropertiesCustom'], $value, $prop, $props);
} elseif (isset(static::$initPropertiesMap[$prop])) {
$methodOrProp = static::$initPropertiesMap[$prop];
if (\method_exists($this, $methodOrProp)) {
//if there is method then use it firstly
\call_user_func([$this, $methodOrProp], $value, $prop, $props);
} elseif (\property_exists($this, $methodOrProp)) {
//if there is property then it just assign value
$this->{$methodOrProp} = $value;
} else {
//otherwise fill help data array
//for following initialization
$this->data[$methodOrProp] = $value;
$this->data[$prop] = $value;
}
} else {
//otherwise fill help data array
$this->data[$prop] = $value;
}
}
$this->isNew = false;
$this->isLoaded = true;
$this->isLoadEmpty = false;
return $this;
}
/**
* @return $this
*/
protected function afterInit()
{
return $this;
}
/**
* @return $this
*/
public static function fake()
{
return static::create()->setFake(true);
}
/**
* @param bool $value
*
* @return $this
*/
protected function setFake($value = true)
{
$this->isFake = (bool)$value;
return $this;
}
/**
* @param array $params
*
* @return static
*/
public static function create(array $params = null)
{
return new static($params);
}
/**
* @return bool
*/
public function isNotEmpty()
{
return !$this->isLoadEmpty;
}
/**
* @return bool
*/
public function isFake()
{
return $this->isFake;
}
/**
* @return array
*/
public function toArray()
{
$ret = [];
$map = static::$initPropertiesMap;
foreach ($map as $key => $init) {
if (\property_exists($this, $key)) {
//if there is property then it just assign value
$ret[$key] = $this->{$key};
} elseif (isset($this[$key])) {
//probably array access
$ret[$key] = $this[$key];
} else {
$ret[$key] = null;
}
}
return $ret;
}
/**
* @param $datetime
*
* @return $this
*/
protected function initModified($datetime)
{
$this->modified = \strtotime($datetime);
return $this;
}
/**
* @param string $date
* @param string $key
*
* @return $this
*/
protected function initDatetime($date, $key)
{
return $this->initProperty(\strtotime($date), $key);
}
/**
* @param $value
* @param $key
*
* @return $this
*/
protected function initProperty($value, $key)
{
$keys = \func_get_args();
unset($keys[0]); //remove value
if (\count($keys) > 1) {
foreach ($keys as $key) {
if (\property_exists($this, $key)) { //first found set
$this->{$key} = $value;
return $this;
}
}
} elseif (\property_exists($this, $key)) {
$this->{$key} = $value;
}
return $this;
}
/**
* @param mixed $value
* @param string $key
*
* @return $this
*/
protected function initBool($value, $key)
{
return $this->initProperty(!empty($value), "is{$key}", $key);
}
/**
* @param mixed $value
* @param string $key
*
* @return $this
*/
protected function initInt($value, $key)
{
return $this->initProperty((int)$value, $key);
}
/**
* @param mixed $value
* @param string $key
*
* @return $this
*/
protected function initFloat($value, $key)
{
return $this->initProperty((float)$value, $key);
}
/**
* @param string $rawData
* @param string $key
*
* @return $this
*/
protected function initJsonArray($rawData, $key)
{
$value = \json_decode($rawData, true, 512, JSON_BIGINT_AS_STRING);
if (empty($value)) {
//could not resolve -
if ('null' === $rawData or '' === $rawData) {
$value = [];
} else {
$value = (array)$rawData;
}
} else {
$value = (array)$value;
}
return $this->initProperty($value, $key);
}
/**
* @param mixed $value
* @param string $key
*
* @return $this
*/
protected function initExplode($value, $key)
{
return $this->initProperty(\explode(',', $value), "is{$key}", $key);
}
}

View File

@@ -0,0 +1,7 @@
<?php
require_once dirname(__FILE__) . '/Unirest/Exception.php';
require_once dirname(__FILE__) . '/Unirest/Method.php';
require_once dirname(__FILE__) . '/Unirest/Response.php';
require_once dirname(__FILE__) . '/Unirest/Request.php';
require_once dirname(__FILE__) . '/Unirest/Request/Body.php';

View File

@@ -0,0 +1,5 @@
<?php
namespace Unirest;
class Exception extends \Exception {}

View File

@@ -0,0 +1,75 @@
<?php
/**
* Hypertext Transfer Protocol (HTTP) Method Registry
*
* http://www.iana.org/assignments/http-methods/http-methods.xhtml
*/
namespace Unirest;
interface Method
{
// RFC7231
const GET = 'GET';
const HEAD = 'HEAD';
const POST = 'POST';
const PUT = 'PUT';
const DELETE = 'DELETE';
const CONNECT = 'CONNECT';
const OPTIONS = 'OPTIONS';
const TRACE = 'TRACE';
// RFC3253
const BASELINE = 'BASELINE';
// RFC2068
const LINK = 'LINK';
const UNLINK = 'UNLINK';
// RFC3253
const MERGE = 'MERGE';
const BASELINECONTROL = 'BASELINE-CONTROL';
const MKACTIVITY = 'MKACTIVITY';
const VERSIONCONTROL = 'VERSION-CONTROL';
const REPORT = 'REPORT';
const CHECKOUT = 'CHECKOUT';
const CHECKIN = 'CHECKIN';
const UNCHECKOUT = 'UNCHECKOUT';
const MKWORKSPACE = 'MKWORKSPACE';
const UPDATE = 'UPDATE';
const LABEL = 'LABEL';
// RFC3648
const ORDERPATCH = 'ORDERPATCH';
// RFC3744
const ACL = 'ACL';
// RFC4437
const MKREDIRECTREF = 'MKREDIRECTREF';
const UPDATEREDIRECTREF = 'UPDATEREDIRECTREF';
// RFC4791
const MKCALENDAR = 'MKCALENDAR';
// RFC4918
const PROPFIND = 'PROPFIND';
const LOCK = 'LOCK';
const UNLOCK = 'UNLOCK';
const PROPPATCH = 'PROPPATCH';
const MKCOL = 'MKCOL';
const COPY = 'COPY';
const MOVE = 'MOVE';
// RFC5323
const SEARCH = 'SEARCH';
// RFC5789
const PATCH = 'PATCH';
// RFC5842
const BIND = 'BIND';
const UNBIND = 'UNBIND';
const REBIND = 'REBIND';
}

View File

@@ -0,0 +1,582 @@
<?php
namespace Unirest;
class Request
{
private static $cookie = null;
private static $cookieFile = null;
private static $curlOpts = array();
private static $defaultHeaders = array();
private static $handle = null;
private static $jsonOpts = array();
private static $socketTimeout = null;
private static $verifyPeer = true;
private static $verifyHost = true;
private static $auth = array (
'user' => '',
'pass' => '',
'method' => CURLAUTH_BASIC
);
private static $proxy = array(
'port' => false,
'tunnel' => false,
'address' => false,
'type' => CURLPROXY_HTTP,
'auth' => array (
'user' => '',
'pass' => '',
'method' => CURLAUTH_BASIC
)
);
/**
* Set JSON decode mode
*
* @param bool $assoc When TRUE, returned objects will be converted into associative arrays.
* @param integer $depth User specified recursion depth.
* @param integer $options Bitmask of JSON decode options. Currently only JSON_BIGINT_AS_STRING is supported (default is to cast large integers as floats)
* @return array
*/
public static function jsonOpts($assoc = false, $depth = 512, $options = 0)
{
return self::$jsonOpts = array($assoc, $depth, $options);
}
/**
* Verify SSL peer
*
* @param bool $enabled enable SSL verification, by default is true
* @return bool
*/
public static function verifyPeer($enabled)
{
return self::$verifyPeer = $enabled;
}
/**
* Verify SSL host
*
* @param bool $enabled enable SSL host verification, by default is true
* @return bool
*/
public static function verifyHost($enabled)
{
return self::$verifyHost = $enabled;
}
/**
* Set a timeout
*
* @param integer $seconds timeout value in seconds
* @return integer
*/
public static function timeout($seconds)
{
return self::$socketTimeout = $seconds;
}
/**
* Set default headers to send on every request
*
* @param array $headers headers array
* @return array
*/
public static function defaultHeaders($headers)
{
return self::$defaultHeaders = array_merge(self::$defaultHeaders, $headers);
}
/**
* Set a new default header to send on every request
*
* @param string $name header name
* @param string $value header value
* @return string
*/
public static function defaultHeader($name, $value)
{
return self::$defaultHeaders[$name] = $value;
}
/**
* Clear all the default headers
*/
public static function clearDefaultHeaders()
{
return self::$defaultHeaders = array();
}
/**
* Set curl options to send on every request
*
* @param array $options options array
* @return array
*/
public static function curlOpts($options)
{
return self::mergeCurlOptions(self::$curlOpts, $options);
}
/**
* Set a new default header to send on every request
*
* @param string $name header name
* @param string $value header value
* @return string
*/
public static function curlOpt($name, $value)
{
return self::$curlOpts[$name] = $value;
}
/**
* Clear all the default headers
*/
public static function clearCurlOpts()
{
return self::$curlOpts = array();
}
/**
* Set a Mashape key to send on every request as a header
* Obtain your Mashape key by browsing one of your Mashape applications on https://www.mashape.com
*
* Note: Mashape provides 2 keys for each application: a 'Testing' and a 'Production' one.
* Be aware of which key you are using and do not share your Production key.
*
* @param string $key Mashape key
* @return string
*/
public static function setMashapeKey($key)
{
return self::defaultHeader('X-Mashape-Key', $key);
}
/**
* Set a cookie string for enabling cookie handling
*
* @param string $cookie
*/
public static function cookie($cookie)
{
self::$cookie = $cookie;
}
/**
* Set a cookie file path for enabling cookie handling
*
* $cookieFile must be a correct path with write permission
*
* @param string $cookieFile - path to file for saving cookie
*/
public static function cookieFile($cookieFile)
{
self::$cookieFile = $cookieFile;
}
/**
* Set authentication method to use
*
* @param string $username authentication username
* @param string $password authentication password
* @param integer $method authentication method
*/
public static function auth($username = '', $password = '', $method = CURLAUTH_BASIC)
{
self::$auth['user'] = $username;
self::$auth['pass'] = $password;
self::$auth['method'] = $method;
}
/**
* Set proxy to use
*
* @param string $address proxy address
* @param integer $port proxy port
* @param integer $type (Available options for this are CURLPROXY_HTTP, CURLPROXY_HTTP_1_0 CURLPROXY_SOCKS4, CURLPROXY_SOCKS5, CURLPROXY_SOCKS4A and CURLPROXY_SOCKS5_HOSTNAME)
* @param bool $tunnel enable/disable tunneling
*/
public static function proxy($address, $port = 1080, $type = CURLPROXY_HTTP, $tunnel = false)
{
self::$proxy['type'] = $type;
self::$proxy['port'] = $port;
self::$proxy['tunnel'] = $tunnel;
self::$proxy['address'] = $address;
}
/**
* Set proxy authentication method to use
*
* @param string $username authentication username
* @param string $password authentication password
* @param integer $method authentication method
*/
public static function proxyAuth($username = '', $password = '', $method = CURLAUTH_BASIC)
{
self::$proxy['auth']['user'] = $username;
self::$proxy['auth']['pass'] = $password;
self::$proxy['auth']['method'] = $method;
}
/**
* Send a GET request to a URL
*
* @param string $url URL to send the GET request to
* @param array $headers additional headers to send
* @param mixed $parameters parameters to send in the querystring
* @param string $username Authentication username (deprecated)
* @param string $password Authentication password (deprecated)
* @return Response
*/
public static function get($url, $headers = array(), $parameters = null, $username = null, $password = null)
{
return self::send(Method::GET, $url, $parameters, $headers, $username, $password);
}
/**
* Send a HEAD request to a URL
* @param string $url URL to send the HEAD request to
* @param array $headers additional headers to send
* @param mixed $parameters parameters to send in the querystring
* @param string $username Basic Authentication username (deprecated)
* @param string $password Basic Authentication password (deprecated)
* @return Response
*/
public static function head($url, $headers = array(), $parameters = null, $username = null, $password = null)
{
return self::send(Method::HEAD, $url, $parameters, $headers, $username, $password);
}
/**
* Send a OPTIONS request to a URL
* @param string $url URL to send the OPTIONS request to
* @param array $headers additional headers to send
* @param mixed $parameters parameters to send in the querystring
* @param string $username Basic Authentication username
* @param string $password Basic Authentication password
* @return Response
*/
public static function options($url, $headers = array(), $parameters = null, $username = null, $password = null)
{
return self::send(Method::OPTIONS, $url, $parameters, $headers, $username, $password);
}
/**
* Send a CONNECT request to a URL
* @param string $url URL to send the CONNECT request to
* @param array $headers additional headers to send
* @param mixed $parameters parameters to send in the querystring
* @param string $username Basic Authentication username (deprecated)
* @param string $password Basic Authentication password (deprecated)
* @return Response
*/
public static function connect($url, $headers = array(), $parameters = null, $username = null, $password = null)
{
return self::send(Method::CONNECT, $url, $parameters, $headers, $username, $password);
}
/**
* Send POST request to a URL
* @param string $url URL to send the POST request to
* @param array $headers additional headers to send
* @param mixed $body POST body data
* @param string $username Basic Authentication username (deprecated)
* @param string $password Basic Authentication password (deprecated)
* @return Response response
*/
public static function post($url, $headers = array(), $body = null, $username = null, $password = null)
{
return self::send(Method::POST, $url, $body, $headers, $username, $password);
}
/**
* Send DELETE request to a URL
* @param string $url URL to send the DELETE request to
* @param array $headers additional headers to send
* @param mixed $body DELETE body data
* @param string $username Basic Authentication username (deprecated)
* @param string $password Basic Authentication password (deprecated)
* @return Response
*/
public static function delete($url, $headers = array(), $body = null, $username = null, $password = null)
{
return self::send(Method::DELETE, $url, $body, $headers, $username, $password);
}
/**
* Send PUT request to a URL
* @param string $url URL to send the PUT request to
* @param array $headers additional headers to send
* @param mixed $body PUT body data
* @param string $username Basic Authentication username (deprecated)
* @param string $password Basic Authentication password (deprecated)
* @return Response
*/
public static function put($url, $headers = array(), $body = null, $username = null, $password = null)
{
return self::send(Method::PUT, $url, $body, $headers, $username, $password);
}
/**
* Send PATCH request to a URL
* @param string $url URL to send the PATCH request to
* @param array $headers additional headers to send
* @param mixed $body PATCH body data
* @param string $username Basic Authentication username (deprecated)
* @param string $password Basic Authentication password (deprecated)
* @return Response
*/
public static function patch($url, $headers = array(), $body = null, $username = null, $password = null)
{
return self::send(Method::PATCH, $url, $body, $headers, $username, $password);
}
/**
* Send TRACE request to a URL
* @param string $url URL to send the TRACE request to
* @param array $headers additional headers to send
* @param mixed $body TRACE body data
* @param string $username Basic Authentication username (deprecated)
* @param string $password Basic Authentication password (deprecated)
* @return Response
*/
public static function trace($url, $headers = array(), $body = null, $username = null, $password = null)
{
return self::send(Method::TRACE, $url, $body, $headers, $username, $password);
}
/**
* This function is useful for serializing multidimensional arrays, and avoid getting
* the 'Array to string conversion' notice
* @param array|object $data array to flatten.
* @param bool|string $parent parent key or false if no parent
* @return array
*/
public static function buildHTTPCurlQuery($data, $parent = false)
{
$result = array();
if (is_object($data)) {
$data = get_object_vars($data);
}
foreach ($data as $key => $value) {
if ($parent) {
$new_key = sprintf('%s[%s]', $parent, $key);
} else {
$new_key = $key;
}
if (!$value instanceof \CURLFile and (is_array($value) or is_object($value))) {
$result = array_merge($result, self::buildHTTPCurlQuery($value, $new_key));
} else {
$result[$new_key] = $value;
}
}
return $result;
}
/**
* Send a cURL request
* @param \Unirest\Method|string $method HTTP method to use
* @param string $url URL to send the request to
* @param mixed $body request body
* @param array $headers additional headers to send
* @param string $username Authentication username (deprecated)
* @param string $password Authentication password (deprecated)
* @throws \Unirest\Exception if a cURL error occurs
* @return Response
*/
public static function send($method, $url, $body = null, $headers = array(), $username = null, $password = null)
{
self::$handle = curl_init();
if ($method !== Method::GET) {
if ($method === Method::POST) {
curl_setopt(self::$handle, CURLOPT_POST, true);
} else {
if ($method === Method::HEAD) {
curl_setopt(self::$handle, CURLOPT_NOBODY, true);
}
curl_setopt(self::$handle, CURLOPT_CUSTOMREQUEST, $method);
}
curl_setopt(self::$handle, CURLOPT_POSTFIELDS, $body);
} elseif (is_array($body)) {
if (strpos($url, '?') !== false) {
$url .= '&';
} else {
$url .= '?';
}
$url .= urldecode(http_build_query(self::buildHTTPCurlQuery($body)));
}
$curl_base_options = [
CURLOPT_URL => self::encodeUrl($url),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_MAXREDIRS => 10,
CURLOPT_HTTPHEADER => self::getFormattedHeaders($headers),
CURLOPT_HEADER => true,
CURLOPT_SSL_VERIFYPEER => self::$verifyPeer,
//CURLOPT_SSL_VERIFYHOST accepts only 0 (false) or 2 (true). Future versions of libcurl will treat values 1 and 2 as equals
CURLOPT_SSL_VERIFYHOST => self::$verifyHost === false ? 0 : 2,
// If an empty string, '', is set, a header containing all supported encoding types is sent
CURLOPT_ENCODING => ''
];
curl_setopt_array(self::$handle, self::mergeCurlOptions($curl_base_options, self::$curlOpts));
if (self::$socketTimeout !== null) {
curl_setopt(self::$handle, CURLOPT_TIMEOUT, self::$socketTimeout);
}
if (self::$cookie) {
curl_setopt(self::$handle, CURLOPT_COOKIE, self::$cookie);
}
if (self::$cookieFile) {
curl_setopt(self::$handle, CURLOPT_COOKIEFILE, self::$cookieFile);
curl_setopt(self::$handle, CURLOPT_COOKIEJAR, self::$cookieFile);
}
// supporting deprecated http auth method
if (!empty($username)) {
curl_setopt_array(self::$handle, array(
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
CURLOPT_USERPWD => $username . ':' . $password
));
}
if (!empty(self::$auth['user'])) {
curl_setopt_array(self::$handle, array(
CURLOPT_HTTPAUTH => self::$auth['method'],
CURLOPT_USERPWD => self::$auth['user'] . ':' . self::$auth['pass']
));
}
if (self::$proxy['address'] !== false) {
curl_setopt_array(self::$handle, array(
CURLOPT_PROXYTYPE => self::$proxy['type'],
CURLOPT_PROXY => self::$proxy['address'],
CURLOPT_PROXYPORT => self::$proxy['port'],
CURLOPT_HTTPPROXYTUNNEL => self::$proxy['tunnel'],
CURLOPT_PROXYAUTH => self::$proxy['auth']['method'],
CURLOPT_PROXYUSERPWD => self::$proxy['auth']['user'] . ':' . self::$proxy['auth']['pass']
));
}
$response = curl_exec(self::$handle);
$error = curl_error(self::$handle);
$info = self::getInfo();
if ($error) {
throw new Exception($error);
}
// Split the full response in its headers and body
$header_size = $info['header_size'];
$header = substr($response, 0, $header_size);
$body = substr($response, $header_size);
$httpCode = $info['http_code'];
return new Response($httpCode, $body, $header, self::$jsonOpts);
}
public static function getInfo($opt = false)
{
if ($opt) {
$info = curl_getinfo(self::$handle, $opt);
} else {
$info = curl_getinfo(self::$handle);
}
return $info;
}
public static function getCurlHandle()
{
return self::$handle;
}
public static function getFormattedHeaders($headers)
{
$formattedHeaders = array();
$combinedHeaders = array_change_key_case(array_merge(self::$defaultHeaders, (array) $headers));
foreach ($combinedHeaders as $key => $val) {
$formattedHeaders[] = self::getHeaderString($key, $val);
}
if (!array_key_exists('user-agent', $combinedHeaders)) {
$formattedHeaders[] = 'user-agent: unirest-php/2.0';
}
if (!array_key_exists('expect', $combinedHeaders)) {
$formattedHeaders[] = 'expect:';
}
return $formattedHeaders;
}
private static function getArrayFromQuerystring($query)
{
$query = preg_replace_callback('/(?:^|(?<=&))[^=[]+/', function ($match) {
return bin2hex(urldecode($match[0]));
}, $query);
parse_str($query, $values);
return array_combine(array_map('hex2bin', array_keys($values)), $values);
}
/**
* Ensure that a URL is encoded and safe to use with cURL
* @param string $url URL to encode
* @return string
*/
private static function encodeUrl($url)
{
$url_parsed = parse_url($url);
$scheme = $url_parsed['scheme'] . '://';
$host = $url_parsed['host'];
$port = (isset($url_parsed['port']) ? $url_parsed['port'] : null);
$path = (isset($url_parsed['path']) ? $url_parsed['path'] : null);
$query = (isset($url_parsed['query']) ? $url_parsed['query'] : null);
if ($query !== null) {
$query = '?' . http_build_query(self::getArrayFromQuerystring($query));
}
if ($port && $port[0] !== ':') {
$port = ':' . $port;
}
$result = $scheme . $host . $port . $path . $query;
return $result;
}
private static function getHeaderString($key, $val)
{
$key = trim(strtolower($key));
return $key . ': ' . $val;
}
/**
* @param array $existing_options
* @param array $new_options
* @return array
*/
private static function mergeCurlOptions(&$existing_options, $new_options)
{
$existing_options = $new_options + $existing_options;
return $existing_options;
}
}

View File

@@ -0,0 +1,66 @@
<?php
namespace Unirest\Request;
use Unirest\Request as Request;
use Unirest\Exception as Exception;
class Body
{
/**
* Prepares a file for upload. To be used inside the parameters declaration for a request.
* @param string $filename The file path
* @param string $mimetype MIME type
* @param string $postname the file name
* @return string|\CURLFile
*/
public static function File($filename, $mimetype = '', $postname = '')
{
if (class_exists('CURLFile')) {
return new \CURLFile($filename, $mimetype, $postname);
}
if (function_exists('curl_file_create')) {
return curl_file_create($filename, $mimetype, $postname);
}
return sprintf('@%s;filename=%s;type=%s', $filename, $postname ?: basename($filename), $mimetype);
}
public static function Json($data)
{
if (!function_exists('json_encode')) {
throw new Exception('JSON Extension not available');
}
return json_encode($data);
}
public static function Form($data)
{
if (is_array($data) || is_object($data) || $data instanceof \Traversable) {
return http_build_query(Request::buildHTTPCurlQuery($data));
}
return $data;
}
public static function Multipart($data, $files = false)
{
if (is_object($data)) {
return get_object_vars($data);
}
if (!is_array($data)) {
return array($data);
}
if ($files !== false) {
foreach ($files as $name => $file) {
$data[$name] = call_user_func(array(__CLASS__, 'File'), $file);
}
}
return $data;
}
}

View File

@@ -0,0 +1,78 @@
<?php
namespace Unirest;
class Response
{
public $code;
public $raw_body;
public $body;
public $headers;
/**
* @param int $code response code of the cURL request
* @param string $raw_body the raw body of the cURL response
* @param string $headers raw header string from cURL response
* @param array $json_args arguments to pass to json_decode function
*/
public function __construct($code, $raw_body, $headers, $json_args = array())
{
$this->code = $code;
$this->headers = $this->parseHeaders($headers);
$this->raw_body = $raw_body;
$this->body = $raw_body;
// make sure raw_body is the first argument
array_unshift($json_args, $raw_body);
if (function_exists('json_decode')) {
$json = call_user_func_array('json_decode', $json_args);
if (json_last_error() === JSON_ERROR_NONE) {
$this->body = $json;
}
}
}
/**
* if PECL_HTTP is not available use a fall back function
*
* thanks to ricardovermeltfoort@gmail.com
* http://php.net/manual/en/function.http-parse-headers.php#112986
* @param string $raw_headers raw headers
* @return array
*/
private function parseHeaders($raw_headers)
{
if (function_exists('http_parse_headers')) {
return http_parse_headers($raw_headers);
} else {
$key = '';
$headers = array();
foreach (explode("\n", $raw_headers) as $i => $h) {
$h = explode(':', $h, 2);
if (isset($h[1])) {
if (!isset($headers[$h[0]])) {
$headers[$h[0]] = trim($h[1]);
} elseif (is_array($headers[$h[0]])) {
$headers[$h[0]] = array_merge($headers[$h[0]], array(trim($h[1])));
} else {
$headers[$h[0]] = array_merge(array($headers[$h[0]]), array(trim($h[1])));
}
$key = $h[0];
} else {
if (substr($h[0], 0, 1) == "\t") {
$headers[$key] .= "\r\n\t".trim($h[0]);
} elseif (!$key) {
$headers[0] = trim($h[0]);
}
}
}
return $headers;
}
}
}

View File

@@ -0,0 +1,213 @@
<?php
/**
* Title : Aqua Resizer
* Description : Resizes WordPress images on the fly
* Version : 1.2.x
* Author : Syamil MJ
* Author URI : http://aquagraphite.com
* License : WTFPL - http://sam.zoy.org/wtfpl/
* Documentation : https://github.com/sy4mil/Aqua-Resizer/
*
* @param string $url - (required) must be uploaded using wp media uploader
* @param int $width - (required)
* @param int $height - (optional)
* @param bool $crop - (optional) default to soft crop
* @param bool $single - (optional) returns an array if false
* @uses wp_upload_dir()
* @uses image_resize_dimensions()
* @uses wp_get_image_editor()
*
* @return str|array
*/
if(!defined('ABSPATH')) exit();
if(!class_exists('Rev_Aq_Resize')){
class Rev_Aq_Resize
{
/**
* The singleton instance
*/
static private $instance = null;
/**
* No initialization allowed
*/
private function __construct() {}
/**
* No cloning allowed
*/
private function __clone() {}
/**
* For your custom default usage you may want to initialize an Aq_Resize object by yourself and then have own defaults
*/
static public function getInstance() {
if(self::$instance == null) {
self::$instance = new self;
}
return self::$instance;
}
/**
* Run, forest.
*/
public function process( $url, $width = null, $height = null, $crop = null, $single = true, $upscale = false ) {
// Validate inputs.
if ( ! $url || ( ! $width && ! $height ) ) return false;
// Caipt'n, ready to hook.
if ( true === $upscale ) add_filter( 'image_resize_dimensions', array($this, 'aq_upscale'), 10, 6 );
// Define upload path & dir.
$upload_info = wp_upload_dir();
$upload_dir = $upload_info['basedir'];
$upload_url = $upload_info['baseurl'];
$http_prefix = "http://";
$https_prefix = "https://";
/* if the $url scheme differs from $upload_url scheme, make them match
if the schemes differe, images don't show up. */
if(!strncmp($url,$https_prefix,strlen($https_prefix))){ //if url begins with https:// make $upload_url begin with https:// as well
$upload_url = str_replace($http_prefix,$https_prefix,$upload_url);
}
elseif(!strncmp($url,$http_prefix,strlen($http_prefix))){ //if url begins with http:// make $upload_url begin with http:// as well
$upload_url = str_replace($https_prefix,$http_prefix,$upload_url);
}
// Check if $img_url is local.
if ( false === strpos( $url, $upload_url ) ) return false;
// Define path of image.
$rel_path = str_replace( $upload_url, '', $url );
$img_path = $upload_dir . $rel_path;
// Check if img path exists, and is an image indeed.
if ( ! file_exists( $img_path ) or ! @getimagesize( $img_path ) ) return false;
// Get image info.
$info = pathinfo( $img_path );
$ext = $info['extension'];
list( $orig_w, $orig_h ) = getimagesize( $img_path );
// Get image size after cropping.
$dims = image_resize_dimensions( $orig_w, $orig_h, $width, $height, $crop );
$dst_w = $dims[4];
$dst_h = $dims[5];
// Return the original image only if it exactly fits the needed measures.
if ( ! $dims && ( ( ( null === $height && $orig_w == $width ) xor ( null === $width && $orig_h == $height ) ) xor ( $height == $orig_h && $width == $orig_w ) ) ) {
$img_url = $url;
$dst_w = $orig_w;
$dst_h = $orig_h;
} else {
// Use this to check if cropped image already exists, so we can return that instead.
$suffix = "{$dst_w}x{$dst_h}";
$dst_rel_path = str_replace( '.' . $ext, '', $rel_path );
$destfilename = "{$upload_dir}{$dst_rel_path}-{$suffix}.{$ext}";
if ( ! $dims || ( true == $crop && false == $upscale && ( $dst_w < $width || $dst_h < $height ) ) ) {
// Can't resize, so return false saying that the action to do could not be processed as planned.
return false;
}
// Else check if cache exists.
elseif ( file_exists( $destfilename ) && getimagesize( $destfilename ) ) {
$img_url = "{$upload_url}{$dst_rel_path}-{$suffix}.{$ext}";
}
// Else, we resize the image and return the new resized image url.
else {
$editor = wp_get_image_editor( $img_path );
if ( is_wp_error( $editor ) || is_wp_error( $editor->resize( $width, $height, $crop ) ) )
return false;
$resized_file = $editor->save();
if ( ! is_wp_error( $resized_file ) ) {
$resized_rel_path = str_replace( $upload_dir, '', $resized_file['path'] );
$img_url = $upload_url . $resized_rel_path;
} else {
return false;
}
}
}
// Okay, leave the ship.
if ( true === $upscale ) remove_filter( 'image_resize_dimensions', array( $this, 'aq_upscale' ) );
// Return the output.
if ( $single ) {
// str return.
$image = $img_url;
} else {
// array return.
$image = array (
0 => $img_url,
1 => $dst_w,
2 => $dst_h
);
}
return $image;
}
/**
* Callback to overwrite WP computing of thumbnail measures
*/
function aq_upscale( $default, $orig_w, $orig_h, $dest_w, $dest_h, $crop ) {
if ( ! $crop ) return null; // Let the wordpress default function handle this.
// Here is the point we allow to use larger image size than the original one.
$aspect_ratio = $orig_w / $orig_h;
$new_w = $dest_w;
$new_h = $dest_h;
if ( ! $new_w ) {
$new_w = intval( $new_h * $aspect_ratio );
}
if ( ! $new_h ) {
$new_h = intval( $new_w / $aspect_ratio );
}
$size_ratio = max( $new_w / $orig_w, $new_h / $orig_h );
$crop_w = round( $new_w / $size_ratio );
$crop_h = round( $new_h / $size_ratio );
$s_x = floor( ( $orig_w - $crop_w ) / 2 );
$s_y = floor( ( $orig_h - $crop_h ) / 2 );
return array( 0, 0, (int) $s_x, (int) $s_y, (int) $new_w, (int) $new_h, (int) $crop_w, (int) $crop_h );
}
}
}
if(!function_exists('rev_aq_resize')){
/**
* This is just a tiny wrapper function for the class above so that there is no
* need to change any code in your own WP themes. Usage is still the same :)
*/
function rev_aq_resize($url, $width = null, $height = null, $crop = null, $single = true, $upscale = false){
/* WPML Fix */
if ( defined( 'ICL_SITEPRESS_VERSION' ) ){
global $sitepress;
$url = $sitepress->convert_url( $url, $sitepress->get_default_language() );
}
/* WPML Fix */
$aq_resize = Rev_Aq_Resize::getInstance();
$image = $aq_resize->process( $url, $width, $height, $crop, $single, $upscale );
return (!empty($image) || $image === false) ? $image : $url;
}
}
?>

View File

@@ -0,0 +1,79 @@
<?php
/**
* @author ThemePunch <info@themepunch.com>
* @link https://www.themepunch.com/
* @copyright 2019 ThemePunch
*/
if(!defined('ABSPATH')) exit();
/**
* backwards compatibility code
* @START
**/
//mostly needed for RevSlider AddOns
class RevSliderGlobals {
const SLIDER_REVISION = RS_REVISION;
const TABLE_SLIDERS_NAME = RevSliderFront::TABLE_SLIDER;
const TABLE_SLIDES_NAME = RevSliderFront::TABLE_SLIDES;
const TABLE_STATIC_SLIDES_NAME = RevSliderFront::TABLE_STATIC_SLIDES;
const TABLE_SETTINGS_NAME = RevSliderFront::TABLE_SETTINGS;
const TABLE_CSS_NAME = RevSliderFront::TABLE_CSS;
const TABLE_LAYER_ANIMS_NAME = RevSliderFront::TABLE_LAYER_ANIMATIONS;
const TABLE_NAVIGATION_NAME = RevSliderFront::TABLE_NAVIGATIONS;
public static $table_sliders;
public static $table_slides;
public static $table_static_slides;
}
global $wpdb;
RevSliderGlobals::$table_sliders = $wpdb->prefix.'revslider_sliders';
RevSliderGlobals::$table_slides = $wpdb->prefix.'revslider_slides';
RevSliderGlobals::$table_static_slides = $wpdb->prefix.'revslider_static_slides';
class RevSliderBase {
public static function check_file_in_zip($d_path, $image, $alias, $alreadyImported = false){
$f = new RevSliderFunctions();
return $f->check_file_in_zip($d_path, $image, $alias, $alreadyImported, $add_path = false);
}
}
class RevSliderFunctionsWP {
public static function getImageUrlFromPath($url){
$f = new RevSliderFunctions();
return $f->get_image_url_from_path($url);
}
public static function get_image_id_by_url($image_url){
$f = new RevSliderFunctions();
return $f->get_image_id_by_url($image_url);
}
}
class RevSliderOperations {
public function getGeneralSettingsValues(){
$f = new RevSliderFunctions();
return $f->get_global_settings();
}
}
class RevSlider extends RevSliderSlider {
public function __construct(){
//echo '<!-- Slider Revolution Notice: Please do not use the class "RevSlider" anymore, use "RevSliderSlider" instead -->'."\n";
}
}
class UniteFunctionsRev extends RevSliderFunctions {}
if(!function_exists('set_revslider_as_theme')){
function set_revslider_as_theme(){
}
}
/**
* backwards compatibility code
* @END
**/
?>

View File

@@ -0,0 +1,640 @@
<?php
$css = '.tp-caption.medium_grey {
position:absolute;
color:#fff;
text-shadow:0px 2px 5px rgba(0, 0, 0, 0.5);
font-weight:700;
font-size:20px;
line-height:20px;
font-family:Arial;
padding:2px 4px;
margin:0px;
border-width:0px;
border-style:none;
background-color:#888;
white-space:nowrap;
}
.tp-caption.small_text {
position:absolute;
color:#fff;
text-shadow:0px 2px 5px rgba(0, 0, 0, 0.5);
font-weight:700;
font-size:14px;
line-height:20px;
font-family:Arial;
margin:0px;
border-width:0px;
border-style:none;
white-space:nowrap;
}
.tp-caption.medium_text {
position:absolute;
color:#fff;
text-shadow:0px 2px 5px rgba(0, 0, 0, 0.5);
font-weight:700;
font-size:20px;
line-height:20px;
font-family:Arial;
margin:0px;
border-width:0px;
border-style:none;
white-space:nowrap;
}
.tp-caption.large_text {
position:absolute;
color:#fff;
text-shadow:0px 2px 5px rgba(0, 0, 0, 0.5);
font-weight:700;
font-size:40px;
line-height:40px;
font-family:Arial;
margin:0px;
border-width:0px;
border-style:none;
white-space:nowrap;
}
.tp-caption.very_large_text {
position:absolute;
color:#fff;
text-shadow:0px 2px 5px rgba(0, 0, 0, 0.5);
font-weight:700;
font-size:60px;
line-height:60px;
font-family:Arial;
margin:0px;
border-width:0px;
border-style:none;
white-space:nowrap;
letter-spacing:-2px;
}
.tp-caption.very_big_white {
position:absolute;
color:#fff;
text-shadow:none;
font-weight:800;
font-size:60px;
line-height:60px;
font-family:Arial;
margin:0px;
border-width:0px;
border-style:none;
white-space:nowrap;
padding:0px 4px;
padding-top:1px;
background-color:#000;
}
.tp-caption.very_big_black {
position:absolute;
color:#000;
text-shadow:none;
font-weight:700;
font-size:60px;
line-height:60px;
font-family:Arial;
margin:0px;
border-width:0px;
border-style:none;
white-space:nowrap;
padding:0px 4px;
padding-top:1px;
background-color:#fff;
}
.tp-caption.modern_medium_fat {
position:absolute;
color:#000;
text-shadow:none;
font-weight:800;
font-size:24px;
line-height:20px;
font-family:"Open Sans", sans-serif;
margin:0px;
border-width:0px;
border-style:none;
white-space:nowrap;
}
.tp-caption.modern_medium_fat_white {
position:absolute;
color:#fff;
text-shadow:none;
font-weight:800;
font-size:24px;
line-height:20px;
font-family:"Open Sans", sans-serif;
margin:0px;
border-width:0px;
border-style:none;
white-space:nowrap;
}
.tp-caption.modern_medium_light {
position:absolute;
color:#000;
text-shadow:none;
font-weight:300;
font-size:24px;
line-height:20px;
font-family:"Open Sans", sans-serif;
margin:0px;
border-width:0px;
border-style:none;
white-space:nowrap;
}
.tp-caption.modern_big_bluebg {
position:absolute;
color:#fff;
text-shadow:none;
font-weight:800;
font-size:30px;
line-height:36px;
font-family:"Open Sans", sans-serif;
padding:3px 10px;
margin:0px;
border-width:0px;
border-style:none;
background-color:#4e5b6c;
letter-spacing:0;
}
.tp-caption.modern_big_redbg {
position:absolute;
color:#fff;
text-shadow:none;
font-weight:300;
font-size:30px;
line-height:36px;
font-family:"Open Sans", sans-serif;
padding:3px 10px;
padding-top:1px;
margin:0px;
border-width:0px;
border-style:none;
background-color:#de543e;
letter-spacing:0;
}
.tp-caption.modern_small_text_dark {
position:absolute;
color:#555;
text-shadow:none;
font-size:14px;
line-height:22px;
font-family:Arial;
margin:0px;
border-width:0px;
border-style:none;
white-space:nowrap;
}
.tp-caption.boxshadow {
-moz-box-shadow:0px 0px 20px rgba(0, 0, 0, 0.5);
-webkit-box-shadow:0px 0px 20px rgba(0, 0, 0, 0.5);
box-shadow:0px 0px 20px rgba(0, 0, 0, 0.5);
}
.tp-caption.black {
color:#000;
text-shadow:none;
}
.tp-caption.noshadow {
text-shadow:none;
}
.tp-caption.thinheadline_dark {
position:absolute;
color:rgba(0,0,0,0.85);
text-shadow:none;
font-weight:300;
font-size:30px;
line-height:30px;
font-family:"Open Sans";
background-color:transparent;
}
.tp-caption.thintext_dark {
position:absolute;
color:rgba(0,0,0,0.85);
text-shadow:none;
font-weight:300;
font-size:16px;
line-height:26px;
font-family:"Open Sans";
background-color:transparent;
}
.tp-caption.largeblackbg {
position:absolute;
color:#fff;
text-shadow:none;
font-weight:300;
font-size:50px;
line-height:70px;
font-family:"Open Sans";
background-color:#000;
padding:0px 20px;
-webkit-border-radius:0px;
-moz-border-radius:0px;
border-radius:0px;
}
.tp-caption.largepinkbg {
position:absolute;
color:#fff;
text-shadow:none;
font-weight:300;
font-size:50px;
line-height:70px;
font-family:"Open Sans";
background-color:#db4360;
padding:0px 20px;
-webkit-border-radius:0px;
-moz-border-radius:0px;
border-radius:0px;
}
.tp-caption.largewhitebg {
position:absolute;
color:#000;
text-shadow:none;
font-weight:300;
font-size:50px;
line-height:70px;
font-family:"Open Sans";
background-color:#fff;
padding:0px 20px;
-webkit-border-radius:0px;
-moz-border-radius:0px;
border-radius:0px;
}
.tp-caption.largegreenbg {
position:absolute;
color:#fff;
text-shadow:none;
font-weight:300;
font-size:50px;
line-height:70px;
font-family:"Open Sans";
background-color:#67ae73;
padding:0px 20px;
-webkit-border-radius:0px;
-moz-border-radius:0px;
border-radius:0px;
}
.tp-caption.excerpt {
font-size:36px;
line-height:36px;
font-weight:700;
font-family:Arial;
color:#ffffff;
text-decoration:none;
background-color:rgba(0, 0, 0, 1);
text-shadow:none;
margin:0px;
letter-spacing:-1.5px;
padding:1px 4px 0px 4px;
width:150px;
white-space:normal !important;
height:auto;
border-width:0px;
border-color:rgb(255, 255, 255);
border-style:none;
}
.tp-caption.large_bold_grey {
font-size:60px;
line-height:60px;
font-weight:800;
font-family:"Open Sans";
color:rgb(102, 102, 102);
text-decoration:none;
background-color:transparent;
text-shadow:none;
margin:0px;
padding:1px 4px 0px;
border-width:0px;
border-color:rgb(255, 214, 88);
border-style:none;
}
.tp-caption.medium_thin_grey {
font-size:34px;
line-height:30px;
font-weight:300;
font-family:"Open Sans";
color:rgb(102, 102, 102);
text-decoration:none;
background-color:transparent;
padding:1px 4px 0px;
text-shadow:none;
margin:0px;
border-width:0px;
border-color:rgb(255, 214, 88);
border-style:none;
}
.tp-caption.small_thin_grey {
font-size:18px;
line-height:26px;
font-weight:300;
font-family:"Open Sans";
color:rgb(117, 117, 117);
text-decoration:none;
background-color:transparent;
padding:1px 4px 0px;
text-shadow:none;
margin:0px;
border-width:0px;
border-color:rgb(255, 214, 88);
border-style:none;
}
.tp-caption.lightgrey_divider {
text-decoration:none;
background-color:rgba(235, 235, 235, 1);
width:370px;
height:3px;
background-position:initial initial;
background-repeat:initial initial;
border-width:0px;
border-color:rgb(34, 34, 34);
border-style:none;
}
.tp-caption.large_bold_darkblue {
font-size:58px;
line-height:60px;
font-weight:800;
font-family:"Open Sans";
color:rgb(52, 73, 94);
text-decoration:none;
background-color:transparent;
border-width:0px;
border-color:rgb(255, 214, 88);
border-style:none;
}
.tp-caption.medium_bg_darkblue {
font-size:20px;
line-height:20px;
font-weight:800;
font-family:"Open Sans";
color:rgb(255, 255, 255);
text-decoration:none;
background-color:rgb(52, 73, 94);
padding:10px;
border-width:0px;
border-color:rgb(255, 214, 88);
border-style:none;
}
.tp-caption.medium_bold_red {
font-size:24px;
line-height:30px;
font-weight:800;
font-family:"Open Sans";
color:rgb(227, 58, 12);
text-decoration:none;
background-color:transparent;
padding:0px;
border-width:0px;
border-color:rgb(255, 214, 88);
border-style:none;
}
.tp-caption.medium_light_red {
font-size:21px;
line-height:26px;
font-weight:300;
font-family:"Open Sans";
color:rgb(227, 58, 12);
text-decoration:none;
background-color:transparent;
padding:0px;
border-width:0px;
border-color:rgb(255, 214, 88);
border-style:none;
}
.tp-caption.medium_bg_red {
font-size:20px;
line-height:20px;
font-weight:800;
font-family:"Open Sans";
color:rgb(255, 255, 255);
text-decoration:none;
background-color:rgb(227, 58, 12);
padding:10px;
border-width:0px;
border-color:rgb(255, 214, 88);
border-style:none;
}
.tp-caption.medium_bold_orange {
font-size:24px;
line-height:30px;
font-weight:800;
font-family:"Open Sans";
color:rgb(243, 156, 18);
text-decoration:none;
background-color:transparent;
border-width:0px;
border-color:rgb(255, 214, 88);
border-style:none;
}
.tp-caption.medium_bg_orange {
font-size:20px;
line-height:20px;
font-weight:800;
font-family:"Open Sans";
color:rgb(255, 255, 255);
text-decoration:none;
background-color:rgb(243, 156, 18);
padding:10px;
border-width:0px;
border-color:rgb(255, 214, 88);
border-style:none;
}
.tp-caption.grassfloor {
text-decoration:none;
background-color:rgba(160, 179, 151, 1);
width:4000px;
height:150px;
border-width:0px;
border-color:rgb(34, 34, 34);
border-style:none;
}
.tp-caption.large_bold_white {
font-size:58px;
line-height:60px;
font-weight:800;
font-family:"Open Sans";
color:rgb(255, 255, 255);
text-decoration:none;
background-color:transparent;
border-width:0px;
border-color:rgb(255, 214, 88);
border-style:none;
}
.tp-caption.medium_light_white {
font-size:30px;
line-height:36px;
font-weight:300;
font-family:"Open Sans";
color:rgb(255, 255, 255);
text-decoration:none;
background-color:transparent;
padding:0px;
border-width:0px;
border-color:rgb(255, 214, 88);
border-style:none;
}
.tp-caption.mediumlarge_light_white {
font-size:34px;
line-height:40px;
font-weight:300;
font-family:"Open Sans";
color:rgb(255, 255, 255);
text-decoration:none;
background-color:transparent;
padding:0px;
border-width:0px;
border-color:rgb(255, 214, 88);
border-style:none;
}
.tp-caption.mediumlarge_light_white_center {
font-size:34px;
line-height:40px;
font-weight:300;
font-family:"Open Sans";
color:#ffffff;
text-decoration:none;
background-color:transparent;
padding:0px 0px 0px 0px;
text-align:center;
border-width:0px;
border-color:rgb(255, 214, 88);
border-style:none;
}
.tp-caption.medium_bg_asbestos {
font-size:20px;
line-height:20px;
font-weight:800;
font-family:"Open Sans";
color:rgb(255, 255, 255);
text-decoration:none;
background-color:rgb(127, 140, 141);
padding:10px;
border-width:0px;
border-color:rgb(255, 214, 88);
border-style:none;
}
.tp-caption.medium_light_black {
font-size:30px;
line-height:36px;
font-weight:300;
font-family:"Open Sans";
color:rgb(0, 0, 0);
text-decoration:none;
background-color:transparent;
padding:0px;
border-width:0px;
border-color:rgb(255, 214, 88);
border-style:none;
}
.tp-caption.large_bold_black {
font-size:58px;
line-height:60px;
font-weight:800;
font-family:"Open Sans";
color:rgb(0, 0, 0);
text-decoration:none;
background-color:transparent;
border-width:0px;
border-color:rgb(255, 214, 88);
border-style:none;
}
.tp-caption.mediumlarge_light_darkblue {
font-size:34px;
line-height:40px;
font-weight:300;
font-family:"Open Sans";
color:rgb(52, 73, 94);
text-decoration:none;
background-color:transparent;
padding:0px;
border-width:0px;
border-color:rgb(255, 214, 88);
border-style:none;
}
.tp-caption.small_light_white {
font-size:17px;
line-height:28px;
font-weight:300;
font-family:"Open Sans";
color:rgb(255, 255, 255);
text-decoration:none;
background-color:transparent;
padding:0px;
border-width:0px;
border-color:rgb(255, 214, 88);
border-style:none;
}
.tp-caption.roundedimage {
border-width:0px;
border-color:rgb(34, 34, 34);
border-style:none;
}
.tp-caption.large_bg_black {
font-size:40px;
line-height:40px;
font-weight:800;
font-family:"Open Sans";
color:rgb(255, 255, 255);
text-decoration:none;
background-color:rgb(0, 0, 0);
padding:10px 20px 15px;
border-width:0px;
border-color:rgb(255, 214, 88);
border-style:none;
}
.tp-caption.mediumwhitebg {
font-size:30px;
line-height:30px;
font-weight:300;
font-family:"Open Sans";
color:rgb(0, 0, 0);
text-decoration:none;
background-color:rgb(255, 255, 255);
padding:5px 15px 10px;
text-shadow:none;
border-width:0px;
border-color:rgb(0, 0, 0);
border-style:none;
}';
?>

View File

@@ -0,0 +1,271 @@
<?php
/**
* @author ThemePunch <info@themepunch.com>
* @link https://www.themepunch.com/
* @copyright 2019 ThemePunch
*/
if(!defined('ABSPATH')) exit();
if(!class_exists('RSColorEasing')) {
class RSColorEasing {
public function __construct() {}
/**
* get the distance between two r/g/b values
* @since 6.0
*/
public static function distColor($px, $bx, $ex, $bv, $ev) {
$num = abs(((($px - $bx) / ($ex - $bx)) * ($ev - $bv)) + $bv);
$num = round($num);
$num = min($num, 255);
return max($num, 0);
}
/**
* get the distance between two alpha values
* @since 6.0
*/
public static function distAlpha($px, $bx, $ex, $bv, $ev) {
$bv = floatval($bv);
$num = floatval((($px - $bx) / ($ex - $bx)) * ($ev - $bv));
$num = number_format($num, 2, '.', '');
$num = abs($num + $bv);
$num = min($num, 1);
return max($num, 0);
}
/**
* insert easing colors to a gradient
* @since 6.0
*/
public static function insertPoints($start, $end, &$ar, $easing, $strength) {
$startPos = $start['position'];
$endPos = $end['position'];
if($startPos > $endPos) return;
$positions = array();
$point;
$val;
$px;
for($i = 0; $i < $strength; $i++) {
$val = RSColorEasing::easing($i, 0, 1, $strength, $easing);
$val = floatval($val);
$val = number_format($val, 2, '.', '');
$val = $val * ($endPos - $startPos) + $startPos;
if($val > $startPos && $val < $endPos) $positions[] = $val;
}
$len = count($positions);
$num = floatval(($endPos - $startPos) / ($len + 1));
$count = number_format($num, 2, '.', '');
$p = $count + $startPos;
for($i = 0; $i < $len; $i++) {
$px = $positions[$i];
if($px === $start['position']) continue;
$r = RSColorEasing::distColor($px, $startPos, $endPos, $start['r'], $end['r']);
$g = RSColorEasing::distColor($px, $startPos, $endPos, $start['g'], $end['g']);
$b = RSColorEasing::distColor($px, $startPos, $endPos, $start['b'], $end['b']);
$a = RSColorEasing::distAlpha($px, $startPos, $endPos, $start['a'], $end['a']);
$startA = RSColorpicker::sanitizeAlpha($start['a']);
$endA = RSColorpicker::sanitizeAlpha($end['a']);
$point = array(
'position' => $p,
'r' => $start['r'] !== $end['r'] ? round($r) : $start['r'],
'g' => $start['g'] !== $end['g'] ? round($g) : $start['g'],
'b' => $start['b'] !== $end['b'] ? round($b) : $start['b'],
'a' => $startA !== $endA ? RSColorpicker::sanitizeAlpha($a) : $startA
);
$p += $count;
$p = number_format(floatval($p), 2, '.', '');
$ar[] = $point;
}
}
/**
* easing equations
* @since 6.0
*/
public static function easing($n, $t, $e, $u, $ease = 'sine.easeinout') {
$easing = array('sine, easeinout');
if(is_string($ease) && strpos($ease, '.') !== false) {
$ease = explode('.', $ease);
if(count($ease) === 2) $easing = [$ease[0], $ease[1]];
}
switch($easing[0]) {
case 'quint':
switch($easing[1]) {
case 'easein':
return $e*(($n=$n/$u-1)*$n*$n*$n*$n+1)+$t;
break;
case 'easeout':
return $e*($n/=$u)*$n*$n*$n*$n+$t;
break;
case 'easeinout':
return ($n/=$u/2)<1?$e/2*$n*$n*$n*$n*$n+$t:$e/2*(($n-=2)*$n*$n*$n*$n+2)+$t;
break;
}
break;
case 'quad':
switch($easing[1]) {
case 'easein':
return $e*($n/=$u)*$n+$t;
break;
case 'easeout':
return -$e*($n/=$u)*($n-2)+$t;
break;
case 'easeinout':
return ($n/=$u/2)<1?$e/2*$n*$n+$t:-$e/2*(--$n*($n-2)-1)+$t;
break;
}
break;
case 'quart':
switch($easing[1]) {
case 'easein':
return $e*($n/=$u)*$n*$n*$n+$t;
break;
case 'easeout':
return -$e*(($n=$n/$u-1)*$n*$n*$n-1)+$t;
break;
case 'easeinout':
return ($n/=$u/2)<1?$e/2*$n*$n*$n*$n+$t:-$e/2*(($n-=2)*$n*$n*$n-2)+$t;
break;
}
break;
case 'cubic':
switch($easing[1]) {
case 'easein':
return $e*($n/=$u)*$n*$n+$t;
break;
case 'easeout':
return $e*(($n=$n/$u-1)*$n*$n+1)+$t;
break;
case 'easeinout':
return ($n/=$u/2)<1?$e/2*$n*$n*$n+$t:$e/2*(($n-=2)*$n*$n+2)+$t;
break;
}
break;
case 'circ':
switch($easing[1]) {
case 'easein':
return -$e*(sqrt(1-($n/=$u)*$n)-1)+$t;
break;
case 'easeout':
return $e*sqrt(1-($n=$n/$u-1)*$n)+$t;
break;
case 'easeinout':
return ($n/=$u/2)<1?-$e/2*(sqrt(1-$n*$n)-1)+$t:$e/2*(sqrt(1-($n-=2)*$n)+1)+$t;
break;
}
break;
case 'expo':
switch($easing[1]) {
case 'easein':
return 0===$n?$t:$e*pow(2,10*($n/$u-1))+$t;
break;
case 'easeout':
return $n===$u?$t+$e:$e*(1-pow(2,-10*$n/$u))+$t;
break;
case 'easeinout':
return 0===$n?$t:$n===$u?$t+$e:($n/=$u/2)<1?$e/2*pow(2,10*($n-1))+$t:$e/2*(2-pow(2,-10*--$n))+$t;
break;
}
break;
case 'bounce':
switch($easing[1]) {
case 'easein':
return $e-RSColorEasing::easing($u-$n,0,$e,$u,'bounce.easeout')+$t;
break;
case 'easeout':
if(($n/=$u)<(1/2.75)){return $e*(7.5625*$n*$n)+$t;}
else if($n<(2/2.75)){return $e*(7.5625*($n-=(1.5/2.75))*$n+0.75)+$t;}
else if ($n<(2.5/2.75)){return $e*(7.5625*($n-=(2.25/2.75))*$n+0.9375)+$t;}
else{return $e*(7.5625*($n-=(2.625/2.75))*$n+0.984375)+$t;}
break;
case 'easeinout':
if($n<$u/2){return RSColorEasing::easing($n*2,0,$e,$u,'bounce.easein')*0.5+$t;}
else{return RSColorEasing::easing($n*2-$u,0,$e,$u,'bounce.easeout')*0.5+$e*0.5+$t;}
break;
}
break;
default:
switch($easing[1]) {
case 'easein':
return -$e*cos($n/$u*(M_PI/2))+$e+$t;
break;
case 'easeout':
return $e*sin($n/$u*(M_PI/2))+$t;
break;
default:
return -$e/2*(cos(M_PI*$n/$u)-1)+$t;
// end default
}
// end default
}
return 0;
}
}
}

View File

@@ -0,0 +1,640 @@
<?php
/**
* @author ThemePunch <info@themepunch.com>
* @link https://www.themepunch.com/
* @copyright 2019 ThemePunch
*/
if(!defined('ABSPATH')) exit();
if(!class_exists('RSColorpicker')){
class RSColorpicker {
/**
* @since 5.3.1.6
*/
public function __construct(){
}
/**
* get a value
* @since 5.3.1.6
*/
public static function get($val){
if(!$val || empty($val)) return 'transparent';
$process = RSColorpicker::process($val, true);
return $process[0];
}
/**
* parse a color
* @since 5.3.1.6
*/
public static function parse($val, $prop, $returnColorType){
$val = RSColorpicker::process($val, true);
$ar = array();
if(!$prop){
$ar[0] = $val[0];
}else{
$ar[0] = $prop . ': ' . $val[0] . ';';
}
if($returnColorType) $ar[1] = $val[1];
return $ar;
}
/**
* convert a color
* @since 5.3.1.6
*/
public static function convert($color, $opacity = '100'){
if($opacity == 'transparent'){
return 'rgba(0,0,0,0)';
}
if($color == '') return '';
if(strpos($color, '[{') !== false || strpos($color, 'gradient') !== false) return RSColorpicker::get($color);
if(!is_bool($opacity) && ''.$opacity === '0'){
return 'transparent';
}
if($opacity == -1 || !$opacity || empty($opacity) || !is_numeric($opacity) || $color == 'transparent' || $opacity === 1 || $opacity === 100){
if(strpos($color, 'rgba') === false && strpos($color, '#') !== false){
return RSColorpicker::processRgba(RSColorpicker::sanitizeHex($color), $opacity);
}else{
$color = RSColorpicker::process($color, true);
return $color[0];
}
}
$opacity = floatval($opacity);
if($opacity < 1) $opacity = $opacity * 100;
$opacity = round($opacity);
$opacity = ($opacity > 100) ? 100 : $opacity;
$opacity = ($opacity < -1) ? 0 : $opacity;
if($opacity === 0) return 'transparent';
if(strpos($color, '#') !== false){
return RSColorpicker::processRgba(RSColorpicker::sanitizeHex($color), $opacity);
}else{
$color = RSColorpicker::rgbValues($color, 3);
return RSColorpicker::rgbaString($color[0], $color[1], $color[2], $opacity);
}
}
/**
* process color
* @since 5.3.1.6
*/
public static function process($clr, $processColor = false){
if(!is_string($clr)){
if($processColor) $clr = RSColorpicker::sanatizeGradient($clr);
return array(RSColorpicker::processGradient($clr), 'gradient', $clr);
}elseif(trim($clr) == 'transparent'){
return array('transparent', 'transparent');
}elseif(strpos($clr, '[{') !== false){
try{
$clr = json_decode(str_replace("amp;", '',str_replace("&", '"', $clr)), true);
if($processColor) $clr = RSColorpicker::sanatizeGradient($clr);
return array(RSColorpicker::processGradient($clr), 'gradient', $clr);
}catch(Exception $e){
return array(
'linear-gradient(0deg, rgb(255, 255, 255) 0%, rgb(0, 0, 0) 100%)',
'gradient',
array(
'type' => 'linear',
'angle' => '0',
'colors' => array(
array(
'r' => '255',
'g' => '255',
'b' => '255',
'a' => '1',
'position' => '0',
'align' => 'bottom'
),
array(
'r' => '0',
'g' => '0',
'b' => '0',
'a' => '1',
'position' => '100',
'align' => 'bottom'
)
)
)
);
}
}elseif(strpos($clr, '-gradient') !== false){
// gradient was not stored as a JSON string for some reason and needs to be converted
$reversed = RSColorpicker::reverseGradient($clr);
return array(RSColorpicker::processGradient($reversed), 'gradient_css', $reversed);
}elseif(strpos($clr,'#') !== false){
return array(RSColorpicker::sanitizeHex($clr), 'hex');
}elseif(strpos($clr,'rgba') !== false){
$clr = preg_replace('/\s+/', '', $clr);
// fixes 'rgba(0,0,0,)' issue
preg_match('/,\)/', $clr, $matches);
if(!empty($matches)) {
$clr = explode(',)', $clr);
$clr = $clr[0] . ',1)';
}
return array($clr, 'rgba');
}else{
$clr = preg_replace('/\s+/', '', $clr);
return array($clr, 'rgb');
}
}
/**
* sanitize a gradient
* @since 5.3.1.6
*/
public static function sanatizeGradient($obj){
$colors = $obj['colors'];
$len = count($colors);
$ar = array();
for($i = 0; $i < $len; $i++){
$cur = $colors[$i];
unset($cur['align']);
if(is_bool($cur['a'])) $cur['a'] = $cur['a'] ? 1 : 0;
$cur['a'] = RSColorpicker::sanitizeAlpha($cur['a']);
$cur['r'] = intval($cur['r']);
$cur['g'] = intval($cur['g']);
$cur['b'] = intval($cur['b']);
$cur['position'] = intval($cur['position']);
if(isset($prev)){
if(json_encode($cur) !== json_encode($prev)){
$ar[] = $cur;
}
}else{
$ar[] = $cur;
}
$prev = $cur;
}
$obj['colors'] = $ar;
return $obj;
}
/**
* cleans up the alpha value for comparison operations
* @since 6.0
*/
public static function sanitizeAlpha($alpha){
$alpha = floatval($alpha);
$alpha = min($alpha, 1);
$alpha = max($alpha, 0);
$alpha = number_format($alpha, 2, '.', '');
$alpha = preg_replace('/\.?0*$/', '', $alpha);
return floatval($alpha);
}
/**
* accounting for cases where gradient doesn't exist as a JSON Object from previous templates for some reason
* @since 6.0
*/
public static function reverseGradient($str){
// hsl colors not supported yet
if(strpos($str, 'hsl') !== false) return $str;
$str = str_replace('/\-moz\-|\-webkit\-/', '', $str);
$str = str_replace('to left', '90deg', $str);
$str = str_replace('to bottom', '180deg', $str);
$str = str_replace('to top', '0deg', $str);
$str = str_replace('to right', '270deg', $str);
$str = str_replace(';', '', $str);
$gradient = explode('-gradient(', $str);
if(count($gradient) < 2) return $str;
$grad = trim($gradient[1]);
$degree = '0';
if(strpos($grad, 'ellipse at center') === false){
if(strpos($grad, 'deg') !== false){
$grad = explode('deg', $grad);
$degree = trim($grad[0]);
$grad = trim($grad[1]);
}
}else{
$grad = str_replace('ellipse at center', '', $grad);
}
if($grad[0] === ',') $grad = ltrim($grad, ',');
if($grad[strlen($grad) - 1] === ',') $grad = rtrim($grad, ',');
$colors = explode('%', $grad);
$list = array();
array_pop($colors);
$prev = false;
foreach($colors as $clr) {
$clr = trim($clr);
$perc = '';
if($clr[0] === ',') $clr = ltrim($clr, ',');
if(strpos($clr, ' ') === false) return $str;
$perc = explode(' ', $clr);
$perc = $perc[count($perc) - 1];
$leg = strlen($clr);
$index = 0;
while($leg--){
$index = $leg;
if($clr[$leg] === ' ') break;
}
$clr = substr($clr, 0, $index);
preg_match('/\)/', $clr, $matches);
if(!empty($matches)) {
$clr = explode(')', $clr);
$clr = trim($clr[0]) . ')';
}else{
$clr = explode(' ', $clr);
$clr = trim($clr[0]);
}
$tpe = RSColorpicker::process($clr, false);
if($tpe[1] === 'hex'){
$clr = RSColorpicker::sanitizeHex($clr);
$clr = RSColorpicker::processRgba($clr);
}
if($prev && $prev === $clr) continue;
$prev = $clr;
$clr = RSColorpicker::rgbValues($clr, 4);
$list[] = array('r' => $clr[0], 'g' => $clr[1], 'b' => $clr[2], 'a' => $clr[3], 'position' => $perc, 'align' => 'top');
}
return array('type' => trim($gradient[0]), 'angle' => $degree, 'colors' => $list);
}
/**
* create the gradient
* @since 6.0
*/
public static function easeGradient(&$gradient){
include_once(RS_PLUGIN_PATH . 'includes/coloreasing.class.php');
if(class_exists('RSColorEasing')){
$strength = (intval($gradient['strength']) * 0.01) * 15;
$easing = $gradient['easing'];
$points = $gradient['colors'];
$len = count($points) - 1;
$ar = array();
for($i = 0; $i < $len; $i++){
$ar[] = $points[$i];
RSColorEasing::insertPoints($points[$i], $points[$i + 1], $ar, $easing, $strength);
}
$ar[] = $points[$len];
$gradient['colors'] = $ar;
}
}
/**
* create the gradient
* @since 5.3.1.6
*/
public static function processGradient($obj){
if(!is_array($obj)) return 'transparent';
if(array_key_exists('easing', $obj) && $obj['easing'] !== 'none') {
RSColorpicker::easeGradient($obj);
}
$tpe = $obj['type'];
$begin = $tpe . '-gradient(';
if($tpe === 'linear') {
$angle = intval($obj['angle']);
$middle = $angle !== 180 ? $angle . 'deg, ' : '';
}
else {
$middle = 'ellipse at center, ';
}
$colors = $obj['colors'];
$end = '';
$i = 0;
foreach($colors as $clr){
if($i > 0) $end .= ', ';
$end .= 'rgba(' . $clr['r'] . ',' . $clr['g'] . ',' . $clr['b'] . ',' . $clr['a'] . ') ' . $clr['position'] . '%';
$i++;
}
return $begin . $middle . $end . ')';
}
/**
* get rgb values
* @since 5.3.1.6
*/
public static function rgbValues($values, $num){
$values = substr( $values, strpos($values, '(') + 1 , strpos($values, ')')-strpos($values, '(') - 1 );
$values = explode(",", $values);
if(count($values) == 3 && $num == 4) $values[3] = '1';
for($i = 0; $i < $num; $i++){
if(isset($values[$i])) $values[$i] = trim($values[$i]);
}
if(count($values) < $num){
$v = count($values)-1;
for($i = $v; $i < $num; $i++){
$values[$i] = $values[0];
}
}
return $values;
}
/**
* get an rgba string
* @since 5.3.1.6
*/
public static function rgbaString($r, $g, $b, $a){
if($a > 1){
$a = ''.number_format($a * 0.01, 2, '.', '');
$a = str_replace('.00', '', $a);
}
return 'rgba(' . $r . ',' . $g . ',' . $b . ',' . $a . ')';
}
/**
* change rgb to hex
* @since 5.3.1.6
*/
public static function rgbToHex($clr){
$values = RSColorpicker::rgbValues($clr, 3);
return RSColorpicker::getRgbToHex($values[0], $values[1], $values[2]);
}
/**
* change rgba to hex
* @since 5.3.1.6
*/
public static function rgbaToHex($clr){
$values = RSColorpicker::rgbValues($clr, 4);
return RSColorpicker::getRgbToHex($values[0], $values[1], $values[2]);
}
/**
* get opacity
* @since 5.3.1.6
*/
public static function getOpacity($val){
$rgb = RSColorpicker::rgbValues($val, 4);
return intval($rgb[3] * 100, 10) + '%';
}
/**
* change rgb to hex
* @since 5.3.1.6
*/
public static function getRgbToHex($r, $g, $b){
$rgb = array($r, $g, $b);
$hex = "#";
$hex .= str_pad(dechex($rgb[0]), 2, "0", STR_PAD_LEFT);
$hex .= str_pad(dechex($rgb[1]), 2, "0", STR_PAD_LEFT);
$hex .= str_pad(dechex($rgb[2]), 2, "0", STR_PAD_LEFT);
return $hex;
}
/**
* join it together to be rgba
* @since 5.3.1.6
*/
public static function joinToRgba($val){
$val = explode('||', $val);
return RSColorpicker::convert($val[0], $val[1]);
}
/**
* rgb to rgba
* @since 6.0
*/
public static function rgbToRgba($val){
$val = RSColorpicker::rgbValues($val, 4);
return RSColorpicker::rgbaString($val[0], $val[1], $val[2], $val[3]);
}
/**
* convert rgba with 100% opacity to hex
* @since 6.0
*/
public static function trimHex($color) {
$color = trim($color);
if(strlen($color) !== 7) return $color;
$clr = str_replace('#', '', $color);
$char = $clr[0];
for($i = 1; $i < 6; $i++) {
if($clr[$i] !== $char) return $color;
$char = $clr[$i];
}
return '#' . substr($clr, 0, 3);
}
/**
* the legacy opacity to rgba conversions and also checks for gradients
* @since: 6.0
*/
public function correctValue($color, $opacity = false) {
if(!is_string($color)) return $color; // unknown value
// gradients can exist as a JSON string or a CSS string
// when they exist as a CSS string it is a result of a bug from 5.0
if(strpos($color, '[{') === false && strpos($color, 'gradient') === false) {
if($opacity === false) return $color; // normal color
return RSColorpicker::convert($color, $opacity); // legacy conversion
}
return $color; // gradient
}
/**
* useful when you need to compare two values and also for smallest print size
* for example, this function will convert both"
* "rgba(255,255, 255,1)" and "#FFFFFF" to "#FFF"
* @since: 6.0
*/
public static function normalizeColor($color) {
$color = RSColorpicker::process($color, true);
$clr = $color[0];
$tpe = $color[1];
$processed = true;
if($tpe === 'hex') {
$clr = RSColorpicker::processRgba($clr, true);
$processed = true;
}
else if($tpe === 'rgb') {
$clr = RSColorpicker::rgbToRgba($clr);
}
else if($tpe === 'rgba') {
$clr = preg_replace('/\s+/', '', $clr);
}
else {
$processed = false;
}
if($processed) $clr = RSColorpicker::sanitizeRgba($clr);
return $clr;
}
/**
* normalize colors for comparison
* @since: 6.0
*/
public static function normalizeColors($color) {
if(is_object($color)) $color = (array)$color;
if(is_array($color)) {
$total = count($color);
for($i = 0; $i < $total; $i++) $color[$i] = RSColorpicker::normalizeColor($color[$i]);
}
else {
$color = RSColorpicker::normalizeColor($color);
}
return $color;
}
/**
* convert rgba with 100% opacity to hex
* @since 6.0
*/
public static function sanitizeRgba($color, $opacity = false) {
if($opacity) {
$color = RSColorpicker::rgbaToHex($color);
$color = RSColorpicker::trimHex($color);
}
else {
$opacity = RSColorpicker::rgbValues($color, 4);
if($opacity[3] === '1') {
$color = RSColorpicker::rgbaToHex($color);
$color = RSColorpicker::trimHex($color);
}
}
return $color;
}
/**
* process rgba
* @since 5.3.1.6
*/
public static function processRgba($hex, $opacity = false){
$hex = trim(str_replace('#', '' , $hex));
$rgb = $opacity!==false ? 'rgba' : 'rgb';
$r = hexdec(substr($hex,0,2));
$g = hexdec(substr($hex,2,2));
$b = hexdec(substr($hex,4,2));
$color = $rgb . "(" . $r . "," . $g . "," . $b ;
if($opacity!==false){
if($opacity > 1)
$opacity = ''.number_format($opacity * 0.01 , 2, '.', '');
$opacity = str_replace('.00', '', $opacity);
$color .= ',' . $opacity;
}
$color .= ')';
return $color;
}
/**
* sanitize hex
* @since 5.3.1.6
*/
public static function sanitizeHex($hex){
$hex = trim(str_replace('#', '' , $hex));
if (strlen($hex) == 3) {
$hex[5] = $hex[2]; // f60##0
$hex[4] = $hex[2]; // f60#00
$hex[3] = $hex[1]; // f60600
$hex[2] = $hex[1]; // f66600
$hex[1] = $hex[0]; // ff6600
}
return '#'.$hex;
}
/**
* Save presets
* @since 5.3.2
*/
public static function save_color_presets($presets){
update_option('tp_colorpicker_presets', $presets);
return self::get_color_presets();
}
/**
* Load presets
* @since 5.3.2
*/
public static function get_color_presets(){
return get_option('tp_colorpicker_presets', array());
}
}
}
?>

View File

@@ -0,0 +1,826 @@
<?php
/**
* @author ThemePunch <info@themepunch.com>
* @link https://www.themepunch.com/
* @copyright 2019 ThemePunch
*/
if(!defined('ABSPATH')) exit();
class RevSliderCssParser extends RevSliderFunctions {
public $css;
/**
* init the parser, set css content
* @before: RevSliderCssParser::initContent()
*/
public function init_css($css){
$this->css = $css;
}
/**
* get array of slide classes, between two sections.
* @before: RevSliderCssParser::getArrClasses()
*/
public function get_classes($start_text = '', $end_text = '', $explodeonspace = false){
$content = $this->css;
$classes = array();
//trim from top
if(!empty($start_text)){
$pos_start = strpos($content, $start_text);
$content = ($pos_start !== false) ? substr($content, $pos_start, strlen($content) - $pos_start) : $content;
}
//trim from bottom
if(!empty($end_text)){
$pos_end = strpos($content, $end_text);
$content = ($pos_end !== false) ? substr($content, 0, $pos_end) : $content;
}
//get styles
$lines = explode("\n", $content);
foreach($lines as $key => $line){
$line = trim($line);
if(strpos($line, '{') === false || strpos($line, '.caption a') || strpos($line, '.tp-caption a') !== false)
continue;
//get style out of the line
$class = trim(str_replace('{', '', $line));
//skip captions like this: .tp-caption.imageclass img
if(strpos($class, ' ') !== false){
if(!$explodeonspace){
continue;
}else{
$class = explode(',', $class);
$class = $class[0];
}
}
//skip captions like this: .tp-caption.imageclass:hover, :before, :after
if(strpos($class, ':') !== false)
continue;
$class = str_replace(array('.caption.', '.tp-caption.'), '.', $class);
$class = trim(str_replace('.', '', $class));
$words = explode(' ', $class);
$class = $words[count($words)-1];
$class = trim($class);
$classes[] = $class;
}
sort($classes);
return $classes;
}
/**
* parse css stylesheet to an array
* @before: RevSliderCssParser::parseCssToArray();
**/
public function css_to_array($css){
while(strpos($css, '/*') !== false){
if(strpos($css, '*/') === false) return false;
$start = strpos($css, '/*');
$end = strpos($css, '*/') + 2;
$css = str_replace(substr($css, $start, $end - $start), '', $css);
}
//preg_match_all('/(?ims)([a-z0-9\s\.\:#_\-@]+)\{([^\}]*)\}/', $css, $arr);
preg_match_all('/(?ims)([a-z0-9\,\s\.\:#_\-@]+)\{([^\}]*)\}/', $css, $arr);
$result = array();
foreach($arr[0] as $i => $x){
$selector = trim($arr[1][$i]);
if(strpos($selector, '{') !== false || strpos($selector, '}') !== false) return false;
$rules = explode(';', trim($arr[2][$i]));
$result[$selector] = array();
foreach($rules as $strRule){
if(!empty($strRule)){
$rule = explode(':', $strRule);
//does not work if in css is another { or }
//if(strpos($rule[0], '{') !== false || strpos($rule[0], '}') !== false || strpos($rule[1], '{') !== false || strpos($rule[1], '}') !== false) return false;
//put back everything but not $rule[0];
$key = trim($rule[0]);
unset($rule[0]);
$values = implode(':', $rule);
$result[$selector][trim($key)] = trim(str_replace("'", '"', $values));
}
}
}
return $result;
}
/**
* parse database entry to css
* @before: RevSliderCssParser::parseDbArrayToCss();
**/
public function parse_db_to_css($css_array, $nl = "\n\r"){
$css = '';
$deformations = $this->get_deformation_css_tags();
$transparency = array(
'color' => 'color-transparency',
'background-color' => 'background-transparency',
'border-color' => 'border-transparency'
);
$check_parameters = array(
'border-width' => 'px',
'border-radius' => 'px',
'padding' => 'px',
'font-size' => 'px',
'line-height' => 'px'
);
foreach($css_array as $id => $attr){
$stripped = (strpos($attr['handle'], '.tp-caption') !== false) ? trim(str_replace('.tp-caption', '', $attr['handle'])) : '';
$attr['advanced'] = json_decode($attr['advanced'], true);
$styles = json_decode(str_replace("'", '"', $attr['params']), true);
$styles_adv = $attr['advanced']['idle'];
$css .= $attr['handle'];
$css .= (!empty($stripped)) ? ', '.$stripped : '';
$css .= ' {'.$nl;
if(is_array($styles) || is_array($styles_adv)){
if(is_array($styles)){
foreach($styles as $name => $style){
if(in_array($name, $deformations) && $name !== 'cursor') continue;
if(!is_array($name) && isset($transparency[$name])){ //the style can have transparency!
if(isset($styles[$transparency[$name]]) && $style !== 'transparent'){
$style = $this->hex2rgba($style, $styles[$transparency[$name]] * 100);
}
}
if(!is_array($name) && isset($check_parameters[$name])){
$style = $this->add_missing_val($style, $check_parameters[$name]);
}
if(is_array($style) || is_object($style)) $style = implode(' ', $style);
$ret = $this->check_for_modifications($name, $style);
if($ret['name'] == 'cursor' && $ret['style'] == 'auto') continue;
$css .= $ret['name'].':'.$ret['style'].";".$nl;
}
}
if(is_array($styles_adv)){
foreach($styles_adv as $name => $style){
if(in_array($name, $deformations) && $name !== 'cursor') continue;
if(is_array($style) || is_object($style)) $style = implode(' ', $style);
$ret = $this->check_for_modifications($name, $style);
if($ret['name'] == 'cursor' && $ret['style'] == 'auto') continue;
$css .= $ret['name'].':'.$ret['style'].";".$nl;
}
}
}
$css .= '}'.$nl.$nl;
//add hover
$setting = json_decode($attr['settings'], true);
if(isset($setting['hover']) && $setting['hover'] == 'true'){
$hover = json_decode(str_replace("'", '"', $attr['hover']), true);
$hover_adv = $attr['advanced']['hover'];
if(is_array($hover) || is_array($hover_adv)){
$css .= $attr['handle'].':hover';
if(!empty($stripped)) $css .= ', '.$stripped.':hover';
$css .= ' {'.$nl;
if(is_array($hover)){
foreach($hover as $name => $style){
if(in_array($name, $deformations) && $name !== 'cursor') continue;
if(!is_array($name) && isset($transparency[$name])){ //the style can have transparency!
if(isset($hover[$transparency[$name]]) && $style !== 'transparent'){
$style = $this->hex2rgba($style, $hover[$transparency[$name]] * 100);
}
}
if(!is_array($name) && isset($check_parameters[$name])){
$style = $this->add_missing_val($style, $check_parameters[$name]);
}
if(is_array($style)|| is_object($style)) $style = implode(' ', $style);
$ret = $this->check_for_modifications($name, $style);
if($ret['name'] == 'cursor' && $ret['style'] == 'auto') continue;
$css .= $ret['name'].':'.$ret['style'].";".$nl;
}
}
if(is_array($hover_adv)){
foreach($hover_adv as $name => $style){
if(in_array($name, $deformations) && $name !== 'cursor') continue;
if(is_array($style)|| is_object($style)) $style = implode(' ', $style);
$ret = $this->check_for_modifications($name, $style);
if($ret['name'] == 'cursor' && $ret['style'] == 'auto') continue;
$css .= $ret['name'].':'.$ret['style'].";".$nl;
}
}
$css .= '}'.$nl.$nl;
}
}
}
return $css;
}
/**
* Check for Modifications like with cursor
* @since: 5.1.3
**/
public function check_for_modifications($name, $style){
if($name == 'cursor'){
$style = ($style == 'zoom-in') ? 'zoom-in; -webkit-zoom-in; cursor: -moz-zoom-in' : $style;
$style = ($style == 'zoom-out') ? 'zoom-out; -webkit-zoom-out; cursor: -moz-zoom-out' : $style;
$name = 'cursor';
}
return array('name' => $name, 'style' => $style);
}
/**
* Check for Modifications like with cursor
* @before: RevSliderCssParser::parseArrayToCss();
**/
public function array_to_css($css_array, $nl = "\n\r", $adv = false){
$css = '';
$deformations = $this->get_deformation_css_tags();
foreach($css_array as $id => $attr){
$setting = (array)$attr['settings'];
$advanced = (array)$attr['advanced'];
$stripped = (strpos($attr['handle'], '.tp-caption') !== false) ? trim(str_replace('.tp-caption', '', $attr['handle'])) : '';
$styles = (array)$attr['params'];
$css .= $attr['handle'];
$css .= (!empty($stripped)) ? ', '.$stripped : $css;
$css .= ' {'.$nl;
if($adv && isset($advanced['idle'])){
$styles = array_merge($styles, (array)$advanced['idle']);
if(isset($setting['type'])){
$styles['type'] = $setting['type'];
}
}
if(is_array($styles) && !empty($styles)){
foreach($styles as $name => $style){
if(in_array($name, $deformations) && $name !== 'cursor') continue;
if($name == 'background-color' && strpos($style, 'rgba') !== false){ //rgb && rgba
$rgb = explode(',', str_replace('rgba', 'rgb', $style));
unset($rgb[count($rgb)-1]);
$rgb = implode(',', $rgb).')';
$css .= $name.':'.$rgb.';'.$nl;
}
$style = (is_array($style) || is_object($style)) ? implode(' ', $style) : $style;
$css .= $name.':'.$style.';'.$nl;
}
}
$css .= '}'.$nl.$nl;
//add hover
if(isset($setting['hover']) && $setting['hover'] == 'true'){
$hover = (array)$attr['hover'];
if($adv && isset($advanced['hover'])){
$styles = array_merge($styles, (array)$advanced['hover']);
}
if(is_array($hover)){
$css .= $attr['handle'].':hover';
if(!empty($stripped)) $css.= ', '.$stripped.':hover';
$css .= ' {'.$nl;
foreach($hover as $name => $style){
if($name == 'background-color' && strpos($style, 'rgba') !== false){ //rgb && rgba
$rgb = explode(',', str_replace('rgba', 'rgb', $style));
unset($rgb[count($rgb)-1]);
$rgb = implode(',', $rgb).')';
$css .= $name.':'.$rgb.';'.$nl;
}
$style = (is_array($style) || is_object($style)) ? implode(' ', $style) : $style;
$css .= $name.':'.$style.';'.$nl;
}
$css .= '}'.$nl.$nl;
}
}
}
return $css;
}
/**
* parse static database to css
* @before: RevSliderCssParser::parseStaticArrayToCss();
**/
public function static_to_css($css_array, $nl = "\n"){
return $this->simple_array_to_css($css_array);
}
/**
* parse simple array to css
* @before: RevSliderCssParser::parseSimpleArrayToCss();
**/
public function simple_array_to_css($css_array, $nl = "\n"){
$css = '';
foreach($css_array as $class => $styles){
$css .= $class.' {'.$nl;
if(is_array($styles) && !empty($styles)){
foreach($styles as $name => $style){
$style = (is_array($style) || is_object($style)) ? implode(' ', $style) : $style;
$css .= $name.':'.$style.';'.$nl;
}
}
$css .= '}'.$nl.$nl;
}
return $css;
}
/**
* parse db array to array
* @before: RevSliderCssParser::parseDbArrayToArray();
**/
public function db_array_to_array($css_array, $handle = false){
if(!is_array($css_array) || empty($css_array)) return false;
foreach($css_array as $key => $css){
if($handle != false){
if($this->get_val($css_array[$key], 'handle') == '.tp-caption.'.$handle){
$css_array[$key]['params'] = json_decode(str_replace("'", '"', $this->get_val($css, 'params')));
$css_array[$key]['hover'] = json_decode(str_replace("'", '"', $this->get_val($css, 'hover')));
$css_array[$key]['advanced'] = json_decode(str_replace("'", '"', $this->get_val($css, 'advanced')));
$css_array[$key]['settings'] = json_decode(str_replace("'", '"', $this->get_val($css, 'settings')));
return $css_array[$key];
}else{
unset($css_array[$key]);
}
}else{
$css_array[$key]['params'] = json_decode(str_replace("'", '"', $this->get_val($css, 'params')));
$css_array[$key]['hover'] = json_decode(str_replace("'", '"', $this->get_val($css, 'hover')));
$css_array[$key]['advanced'] = json_decode(str_replace("'", '"', $this->get_val($css, 'advanced')));
$css_array[$key]['settings'] = json_decode(str_replace("'", '"', $this->get_val($css, 'settings')));
}
}
return $css_array;
}
/**
* compress the css
**/
public function compress_css($buffer){
/* remove comments */
$buffer = preg_replace("!/\*[^*]*\*+([^/][^*]*\*+)*/!", '', $buffer) ;
/* remove tabs, spaces, newlines, etc. */
$arr = array("\r\n", "\r", "\n", "\t", ' ', ' ', ' ');
$rep = array('', '', '', '', ' ', ' ', ' ');
$buffer = str_replace($arr, $rep, $buffer);
/* remove whitespaces around {}:, */
$buffer = preg_replace("/\s*([\{\}:,])\s*/", "$1", $buffer);
/* remove last ; */
$buffer = str_replace(';}', '}', $buffer);
return $buffer;
}
/**
* Defines the default CSS Classes, can be given a version number to order them accordingly
* @since: 5.0
**/
public function default_css_classes(){
$c = '.tp-caption';
$default = array(
$c.'.medium_grey' => '4',
$c.'.small_text' => '4',
$c.'.medium_text' => '4',
$c.'.large_text' => '4',
$c.'.very_large_text' => '4',
$c.'.very_big_white' => '4',
$c.'.very_big_black' => '4',
$c.'.modern_medium_fat' => '4',
$c.'.modern_medium_fat_white' => '4',
$c.'.modern_medium_light' => '4',
$c.'.modern_big_bluebg' => '4',
$c.'.modern_big_redbg' => '4',
$c.'.modern_small_text_dark' => '4',
$c.'.boxshadow' => '4',
$c.'.black' => '4',
$c.'.noshadow' => '4',
$c.'.thinheadline_dark' => '4',
$c.'.thintext_dark' => '4',
$c.'.largeblackbg' => '4',
$c.'.largepinkbg' => '4',
$c.'.largewhitebg' => '4',
$c.'.largegreenbg' => '4',
$c.'.excerpt' => '4',
$c.'.large_bold_grey' => '4',
$c.'.medium_thin_grey' => '4',
$c.'.small_thin_grey' => '4',
$c.'.lightgrey_divider' => '4',
$c.'.large_bold_darkblue' => '4',
$c.'.medium_bg_darkblue' => '4',
$c.'.medium_bold_red' => '4',
$c.'.medium_light_red' => '4',
$c.'.medium_bg_red' => '4',
$c.'.medium_bold_orange' => '4',
$c.'.medium_bg_orange' => '4',
$c.'.grassfloor' => '4',
$c.'.large_bold_white' => '4',
$c.'.medium_light_white' => '4',
$c.'.mediumlarge_light_white' => '4',
$c.'.mediumlarge_light_white_center' => '4',
$c.'.medium_bg_asbestos' => '4',
$c.'.medium_light_black' => '4',
$c.'.large_bold_black' => '4',
$c.'.mediumlarge_light_darkblue'=> '4',
$c.'.small_light_white' => '4',
$c.'.roundedimage' => '4',
$c.'.large_bg_black' => '4',
$c.'.mediumwhitebg' => '4',
$c.'.MarkerDisplay' => '5.0',
$c.'.Restaurant-Display' => '5.0',
$c.'.Restaurant-Cursive' => '5.0',
$c.'.Restaurant-ScrollDownText' => '5.0',
$c.'.Restaurant-Description' => '5.0',
$c.'.Restaurant-Price' => '5.0',
$c.'.Restaurant-Menuitem' => '5.0',
$c.'.Furniture-LogoText' => '5.0',
$c.'.Furniture-Plus' => '5.0',
$c.'.Furniture-Title' => '5.0',
$c.'.Furniture-Subtitle' => '5.0',
$c.'.Gym-Display' => '5.0',
$c.'.Gym-Subline' => '5.0',
$c.'.Gym-SmallText' => '5.0',
$c.'.Fashion-SmallText' => '5.0',
$c.'.Fashion-BigDisplay' => '5.0',
$c.'.Fashion-TextBlock' => '5.0',
$c.'.Sports-Display' => '5.0',
$c.'.Sports-DisplayFat' => '5.0',
$c.'.Sports-Subline' => '5.0',
$c.'.Instagram-Caption' => '5.0',
$c.'.News-Title' => '5.0',
$c.'.News-Subtitle' => '5.0',
$c.'.Photography-Display' => '5.0',
$c.'.Photography-Subline' => '5.0',
$c.'.Photography-ImageHover' => '5.0',
$c.'.Photography-Menuitem' => '5.0',
$c.'.Photography-Textblock' => '5.0',
$c.'.Photography-Subline-2' => '5.0',
$c.'.Photography-ImageHover2' => '5.0',
$c.'.WebProduct-Title' => '5.0',
$c.'.WebProduct-SubTitle' => '5.0',
$c.'.WebProduct-Content' => '5.0',
$c.'.WebProduct-Menuitem' => '5.0',
$c.'.WebProduct-Title-Light' => '5.0',
$c.'.WebProduct-SubTitle-Light' => '5.0',
$c.'.WebProduct-Content-Light' => '5.0',
$c.'.FatRounded' => '5.0',
$c.'.NotGeneric-Title' => '5.0',
$c.'.NotGeneric-SubTitle' => '5.0',
$c.'.NotGeneric-CallToAction' => '5.0',
$c.'.NotGeneric-Icon' => '5.0',
$c.'.NotGeneric-Menuitem' => '5.0',
$c.'.MarkerStyle' => '5.0',
$c.'.Gym-Menuitem' => '5.0',
$c.'.Newspaper-Button' => '5.0',
$c.'.Newspaper-Subtitle' => '5.0',
$c.'.Newspaper-Title' => '5.0',
$c.'.Newspaper-Title-Centered' => '5.0',
$c.'.Hero-Button' => '5.0',
$c.'.Video-Title' => '5.0',
$c.'.Video-SubTitle' => '5.0',
$c.'.NotGeneric-Button' => '5.0',
$c.'.NotGeneric-BigButton' => '5.0',
$c.'.WebProduct-Button' => '5.0',
$c.'.Restaurant-Button' => '5.0',
$c.'.Gym-Button' => '5.0',
$c.'.Gym-Button-Light' => '5.0',
$c.'.Sports-Button-Light' => '5.0',
$c.'.Sports-Button-Red' => '5.0',
$c.'.Photography-Button' => '5.0',
$c.'.Newspaper-Button-2' => '5.0'
);
return apply_filters('revslider_mod_default_css_handles', $default);
}
/**
* Defines the deformation CSS which is not directly usable as pure CSS
* @since: 5.0
**/
public function get_deformation_css_tags(){
return array(
'x' => 'x',
'y' => 'y',
'z' => 'z',
'skewx' => 'skewx',
'skewy' => 'skewy',
'scalex' => 'scalex',
'scaley' => 'scaley',
'opacity' => 'opacity',
'xrotate' => 'xrotate',
'yrotate' => 'yrotate',
'2d_rotation' => '2d_rotation',
'layer_2d_origin_x' => 'layer_2d_origin_x',
'layer_2d_origin_y' => 'layer_2d_origin_y',
'2d_origin_x' => '2d_origin_x',
'2d_origin_y' => '2d_origin_y',
'pers' => 'pers',
'color-transparency' => 'color-transparency',
'background-transparency' => 'background-transparency',
'border-transparency'=> 'border-transparency',
'cursor' => 'cursor',
'speed' => 'speed',
'easing' => 'easing',
'corner_left' => 'corner_left',
'corner_right' => 'corner_right',
'parallax' => 'parallax',
'type' => 'type',
'padding' => 'padding',
'margin' => 'margin',
'text-align' => 'text-align'
);
}
/**
* return the captions sorted by handle name
**/
public function get_captions_sorted(){
global $wpdb;
$styles = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix . RevSliderFront::TABLE_CSS . " ORDER BY handle ASC", ARRAY_A);
$arr = array('5.0' => array(), 'Custom' => array(), '4' => array());
foreach($styles as $style){
$setting = json_decode($this->get_val($style, 'settings'), true);
if(!isset($setting['type'])) $setting['type'] = 'text';
if(array_key_exists('version', $setting) && isset($setting['version'])) $arr[ucfirst($setting['version'])][] = array('label' => trim(str_replace('.tp-caption.', '', $style['handle'])), 'type' => $setting['type']);
}
$sorted = array();
foreach($arr as $version => $class){
foreach($class as $name){
$sorted[] = array('label' => $this->get_val($name, 'label'), 'version' => $version, 'type' => $this->get_val($name, 'type'));
}
}
return $sorted;
}
/**
* Handles media queries
* @since: 5.2.0
**/
public function parse_media_blocks($css){
$blocks = array();
$start = 0;
while(($start = strpos($css, '@media', $start)) !== false){
$s = array();
$i = strpos($css, '{', $start);
if ($i !== false){
$block = trim(substr($css, $start, $i - $start));
array_push($s, $css[$i]);
$i++;
while(!empty($s)){
if($css[$i] == '{'){
array_push($s, '{');
}elseif($css[$i] == '}'){
array_pop($s);
}else{
//broken css?
}
$i++;
}
$blocks[$block] = substr($css, $start, ($i + 1) - $start);
$start = $i;
}
}
return $blocks;
}
/**
* removes @media { ... } queries from CSS
* @since: 5.2.0
**/
public function clear_media_block($css){
$start = 0;
if(strpos($css, '@media', $start) !== false){
$start = strpos($css, '@media', 0);
$i = strpos($css, '{', $start) + 1;
$remove = substr($css, $start - 1, $i - $start + 1); //remove @media ... first {
$css = str_replace($remove, '', $css);
$css = preg_replace('/}$/', '', $css); //remove last }
}
return $css;
}
/**
* import contents of the css file
* @before: RevSliderOperations::importCaptionsCssContentArray()
*/
public function import_css_captions(){
global $wpdb;
$css = $this->get_base_css_captions();
$static = array();
if(is_array($css) && $css !== false && count($css) > 0){
foreach($css as $class => $styles){
//check if static style or dynamic style
$class = trim($class);
if((strpos($class, ':hover') === false && strpos($class, ':') !== false) || //before, after
strpos($class, ' ') !== false || // .tp-caption.imageclass img or .tp-caption .imageclass or .tp-caption.imageclass .img
strpos($class, '.tp-caption') === false || // everything that is not tp-caption
(strpos($class, '.') === false || strpos($class, '#') !== false) || // no class -> #ID or img
strpos($class, '>') !== false){ //.tp-caption>.imageclass or .tp-caption.imageclass>img or .tp-caption.imageclass .img
$static[$class] = $styles;
continue;
}
//is a dynamic style
if(strpos($class, ':hover') !== false){
$class = trim(str_replace(':hover', '', $class));
$add = array(
'hover' => json_encode($styles),
'settings' => json_encode(array('hover' => 'true'))
);
}else{
$add = array(
'params' => json_encode($styles)
);
}
//check if class exists
$result = $wpdb->get_row($wpdb->prepare("SELECT * FROM ".$wpdb->prefix . RevSliderFront::TABLE_CSS." WHERE handle = %s", $class), ARRAY_A);
if(!empty($result)){ //update
$wpdb->update($wpdb->prefix . RevSliderFront::TABLE_CSS, $add, array('handle' => $class));
}else{ //insert
$add['handle'] = $class;
$wpdb->insert($wpdb->prefix . RevSliderFront::TABLE_CSS, $add);
}
}
}
if(!empty($static)){ //save static into static-captions.css
$css = $this->get_static_css()."\n".$this->static_to_css($static); //get the open sans line!
$this->update_static_css($css);
}
}
/**
* get contents of the css file
* @before: RevSliderOperations::getCaptionsCssContentArray();
*/
public function get_base_css_captions(){
include(RS_PLUGIN_PATH . 'includes/basic-css.php');
return $this->css_to_array($css);
}
/**
* get the css raw from the database
*/
public function get_raw_css(){
global $wpdb;
$result = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix . RevSliderFront::TABLE_CSS, ARRAY_A);
return $result;
}
/**
* get the css from the database and set it into an object structure
*/
public function get_database_classes($adv = false){
$css = $this->get_raw_css();
if(!empty($css)){
foreach($css as $k => $v){
if($adv === true){
$css[$v['handle']]['hover'] = json_decode($this->get_val($v, 'hover', ''), true);
$css[$v['handle']]['params'] = json_decode($this->get_val($v, 'params', ''), true);
$css[$v['handle']]['settings'] = json_decode($this->get_val($v, 'settings', ''), true);
}else{
unset($css[$v['handle']]['hover']);
unset($css[$v['handle']]['params']);
unset($css[$v['handle']]['settings']);
}
$css[$v['handle']]['advanced'] = json_decode($this->get_val($v, 'advanced', ''), true);
}
}
return $css;
}
/**
* add missing px/% to value, do also for object and array
* @since: 5.0
**/
public function add_missing_val($obj, $set_to = 'px'){
if(is_array($obj)){
foreach($obj as $key => $value){
if(strpos($value, $set_to) === false){
$obj[$key] = $value.$set_to;
}
}
}elseif(is_object($obj)){
foreach($obj as $key => $value){
if(is_object($value)){
if(isset($value->v)){
if(strpos($value->v, $set_to) === false){
$obj->$key->v = $value->v.$set_to;
}
}
}else{
if(strpos($value, $set_to) === false){
$obj->$key = $value.$set_to;
}
}
}
}else{
if(strpos($obj, $set_to) === false){
$obj .= $set_to;
}
}
return $obj;
}
/**
* change hex to rgba
*/
public function hex2rgba($hex, $transparency = false, $raw = false, $do_rgb = false){
if($transparency !== false){
$transparency = ($transparency > 0) ? number_format(($transparency / 100), 2, '.', '') : 0;
}else{
$transparency = 1;
}
$hex = str_replace('#', '', $hex);
if(strlen($hex) == 3){
$r = hexdec(substr($hex,0,1).substr($hex,0,1));
$g = hexdec(substr($hex,1,1).substr($hex,1,1));
$b = hexdec(substr($hex,2,1).substr($hex,2,1));
}elseif($this->is_rgb($hex)){
return $hex;
}else{
$r = hexdec(substr($hex,0,2));
$g = hexdec(substr($hex,2,2));
$b = hexdec(substr($hex,4,2));
}
$ret = ($do_rgb) ? $r.', '.$g.', '.$b : $r.', '.$g.', '.$b.', '.$transparency;
return ($raw) ? $ret : 'rgba('.$ret.')';
}
}
?>

View File

@@ -0,0 +1,603 @@
<?php
/**
* @author ThemePunch <info@themepunch.com>
* @link https://www.themepunch.com/
* @copyright 2019 ThemePunch
*/
if(!defined('ABSPATH')) exit();
define('RS_T', ' ');
define('RS_T2', ' ');
define('RS_T3', ' ');
define('RS_T4', ' ');
define('RS_T5', ' ');
define('RS_T6', ' ');
define('RS_T7', ' ');
define('RS_T8', ' ');
define('RS_T9', ' ');
define('RS_T10', ' ');
define('RS_T11', ' ');
class RevSliderData {
public $css;
public $animations;
/**
* get all font family types
* before: RevSliderOperations::getArrFontFamilys()
*/
public function get_font_familys(){
$fonts = array();
//add custom added fonts
$gs = $this->get_global_settings();
$cf = $this->get_val($gs, 'customfonts', '');
$cfa = (!empty($cf)) ? explode(',', $cf) : '';
if(!empty($cfa)){
foreach($cfa as $_cfa){
$fonts[] = array('type' => 'custom', 'version' => __('Custom Fonts', 'revslider'), 'label' => $_cfa);
}
}
//Web Safe Fonts
// GOOGLE Loaded Fonts
$fonts[] = array('type' => 'websafe', 'version' => __('Loaded Google Fonts', 'revslider'), 'label' => 'Dont Show Me');
//Serif Fonts
$fonts[] = array('type' => 'websafe', 'version' => __('Serif Fonts', 'revslider'), 'label' => 'Georgia, serif');
$fonts[] = array('type' => 'websafe', 'version' => __('Serif Fonts', 'revslider'), 'label' => '"Palatino Linotype", "Book Antiqua", Palatino, serif');
$fonts[] = array('type' => 'websafe', 'version' => __('Serif Fonts', 'revslider'), 'label' => '"Times New Roman", Times, serif');
//Sans-Serif Fonts
$fonts[] = array('type' => 'websafe', 'version' => __('Sans-Serif Fonts', 'revslider'), 'label' => 'Arial, Helvetica, sans-serif');
$fonts[] = array('type' => 'websafe', 'version' => __('Sans-Serif Fonts', 'revslider'), 'label' => '"Arial Black", Gadget, sans-serif');
$fonts[] = array('type' => 'websafe', 'version' => __('Sans-Serif Fonts', 'revslider'), 'label' => '"Comic Sans MS", cursive, sans-serif');
$fonts[] = array('type' => 'websafe', 'version' => __('Sans-Serif Fonts', 'revslider'), 'label' => 'Impact, Charcoal, sans-serif');
$fonts[] = array('type' => 'websafe', 'version' => __('Sans-Serif Fonts', 'revslider'), 'label' => '"Lucida Sans Unicode", "Lucida Grande", sans-serif');
$fonts[] = array('type' => 'websafe', 'version' => __('Sans-Serif Fonts', 'revslider'), 'label' => 'Tahoma, Geneva, sans-serif');
$fonts[] = array('type' => 'websafe', 'version' => __('Sans-Serif Fonts', 'revslider'), 'label' => '"Trebuchet MS", Helvetica, sans-serif');
$fonts[] = array('type' => 'websafe', 'version' => __('Sans-Serif Fonts', 'revslider'), 'label' => 'Verdana, Geneva, sans-serif');
//Monospace Fonts
$fonts[] = array('type' => 'websafe', 'version' => __('Monospace Fonts', 'revslider'), 'label' => '"Courier New", Courier, monospace');
$fonts[] = array('type' => 'websafe', 'version' => __('Monospace Fonts', 'revslider'), 'label' => '"Lucida Console", Monaco, monospace');
//push all variants to the websafe fonts
foreach($fonts as $f => $font){
$font[$f]['variants'] = array('100', '100italic', '200', '200italic', '300', '300italic', '400', '400italic', '500', '500italic', '600', '600italic', '700', '700italic', '800', '800italic', '900', '900italic');
}
include(RS_PLUGIN_PATH . 'includes/googlefonts.php');
foreach($googlefonts as $f => $val){
$fonts[] = array('type' => 'googlefont', 'version' => __('Google Fonts', 'revslider'), 'label' => $f, 'variants' => $val['variants'], 'subsets' => $val['subsets'], 'category' => $val['category']);
}
return apply_filters('revslider_data_get_font_familys', apply_filters('revslider_operations_getArrFontFamilys', $fonts));
}
/**
* get animations array
* @before: RevSliderOperations::getArrAnimations();
*/
public function get_animations(){
return $this->get_custom_animations_full_pre('in');
}
/**
* get "end" animations array
* @before: RevSliderOperations::getArrEndAnimations();
*/
public function get_end_animations(){
return $this->get_custom_animations_full_pre('out');
}
public function get_loop_animations(){
return $this->get_custom_animations_full_pre('loop');
}
/**
* get the version 5 animations only, if available
**/
public function get_animations_v5(){
$custom = array();
$temp = array();
$sort = array();
$this->fill_animations();
foreach($this->animations as $value){
$type = $this->get_val($value, array('params', 'type'), '');
if(!in_array($type, array('customout', 'customin'))) continue;
$settings = $this->get_val($value, 'settings', '');
$type = $this->get_val($value, 'type', '');
if($type == '' && $settings == '' || $type == $pre){
$temp[$value['id']] = $value;
$temp[$value['id']]['id'] = $value['id'];
$sort[$value['id']] = $value['handle'];
}
if($settings == 'in' && $pre == 'in' || $settings == 'out' && $pre == 'out' || $settings == 'loop' && $pre == 'loop'){
$temp[$value['id']] = $value['params'];
$temp[$value['id']]['settings'] = $settings;
$temp[$value['id']]['id'] = $value['id'];
$sort[$value['id']] = $value['handle'];
}
}
if(!empty($sort)){
asort($sort);
foreach ($sort as $k => $v){
$custom[$k] = $temp[$k];
}
}
return $custom;
}
/**
* get custom animations
* @before: RevSliderOperations::getCustomAnimationsFullPre()
*/
public function get_custom_animations_full_pre($pre = 'in'){
$custom = array();
$temp = array();
$sort = array();
$this->fill_animations();
foreach($this->animations as $value){
$settings = $this->get_val($value, 'settings', '');
$type = $this->get_val($value, 'type', '');
if($type == '' && $settings == '' || $type == $pre){
$temp[$value['id']] = $value;
$temp[$value['id']]['id'] = $value['id'];
$sort[$value['id']] = $value['handle'];
}
if($settings == 'in' && $pre == 'in' || $settings == 'out' && $pre == 'out' || $settings == 'loop' && $pre == 'loop'){
$temp[$value['id']] = $value['params'];
$temp[$value['id']]['settings'] = $settings;
$temp[$value['id']]['id'] = $value['id'];
$sort[$value['id']] = $value['handle'];
}
}
if(!empty($sort)){
asort($sort);
foreach($sort as $k => $v){
$custom[$k] = $temp[$k];
}
}
return $custom;
}
/**
* Fetch all Custom Animations only one time
* @since: 5.2.4
* @before: RevSliderOperations::fillAnimations();
**/
public function fill_animations(){
if(empty($this->animations)){
global $wpdb;
$result = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . RevSliderFront::TABLE_LAYER_ANIMATIONS, ARRAY_A);
$this->animations = (!empty($result)) ? $result : array();
if(!empty($this->animations)){
foreach($this->animations as $ak => $av){
$this->animations[$ak]['params'] = json_decode(str_replace("'", '"', $av['params']), true);
}
}
if(!empty($this->animations)){
array_walk_recursive($this->animations, array('RevSliderData', 'force_to_boolean'));
}
}
}
/**
* make sure that all false and true are really boolean
**/
public static function force_to_boolean(&$a, &$b){
$a = ($a === 'false') ? false : $a;
$a = ($a === 'true') ? true : $a;
$b = ($b === 'false') ? false : $b;
$b = ($b === 'true') ? true : $b;
}
/**
* get contents of the css table as an array
* before: RevSliderOperations::getCaptionsContentArray();
*/
public function get_captions_array($handle = false){
$css = new RevSliderCssParser();
if(empty($this->css)){
$this->fill_css();
}
return $css->db_array_to_array($this->css, $handle);
}
/**
* Fetch all Custom CSS only one time
* @since: 5.2.4
* before: RevSliderOperations::fillCSS();
**/
public function fill_css(){
if(empty($this->css)){
global $wpdb;
$css_data = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . RevSliderFront::TABLE_CSS, ARRAY_A);
$this->css = (!empty($css_data)) ? $css_data : array();
}
}
/**
* Get all images sizes + custom added sizes
* @before: RevSliderBase::get_all_image_sizes($type);
*/
public function get_all_image_sizes($type = 'gallery'){
$custom_sizes = array();
switch($type){
case 'flickr':
$custom_sizes = array(
'original' => __('Original', 'revslider'),
'large' => __('Large', 'revslider'),
'large-square' => __('Large Square', 'revslider'),
'medium' => __('Medium', 'revslider'),
'medium-800' => __('Medium 800', 'revslider'),
'medium-640' => __('Medium 640', 'revslider'),
'small' => __('Small', 'revslider'),
'small-320' => __('Small 320', 'revslider'),
'thumbnail' => __('Thumbnail', 'revslider'),
'square' => __('Square', 'revslider'),
);
break;
case 'instagram':
$custom_sizes = array(
'standard_resolution' => __('Standard Resolution', 'revslider'),
'thumbnail' => __('Thumbnail', 'revslider'),
'low_resolution' => __('Low Resolution', 'revslider'),
'original_size' => __('Original Size', 'revslider'),
'large' => __('Large Size', 'revslider'),
);
break;
case 'twitter':
$custom_sizes = array(
'large' => __('Standard Resolution', 'revslider'),
);
break;
case 'facebook':
$custom_sizes = array(
'full' => __('Original Size', 'revslider'),
'thumbnail' => __('Thumbnail', 'revslider'),
);
break;
case 'youtube':
$custom_sizes = array(
'high' => __('High', 'revslider'),
'medium' => __('Medium', 'revslider'),
'default' => __('Default', 'revslider'),
'standard' => __('Standard', 'revslider'),
'maxres' => __('Max. Res.', 'revslider'),
);
break;
case 'vimeo':
$custom_sizes = array(
'thumbnail_large' => __('Large', 'revslider'),
'thumbnail_medium' => __('Medium', 'revslider'),
'thumbnail_small' => __('Small', 'revslider'),
);
break;
case 'gallery':
default:
$added_image_sizes = get_intermediate_image_sizes();
if(!empty($added_image_sizes) && is_array($added_image_sizes)){
foreach($added_image_sizes as $key => $img_size_handle){
$custom_sizes[$img_size_handle] = ucwords(str_replace('_', ' ', $img_size_handle));
}
}
$img_orig_sources = array(
'full' => __('Original Size', 'revslider'),
'thumbnail' => __('Thumbnail', 'revslider'),
'medium' => __('Medium', 'revslider'),
'large' => __('Large', 'revslider'),
);
$custom_sizes = array_merge($img_orig_sources, $custom_sizes);
break;
}
return $custom_sizes;
}
/**
* get the default layer animations
**/
public function get_layer_animations($raw = false){
$custom_in = $this->get_animations();
$custom_out = $this->get_end_animations();
$custom_loop = $this->get_loop_animations();
$in = '{
"custom":{"group":"Custom","custom":true,"transitions":' .
json_encode($custom_in)
. '},
"blck":{
"group":"Block Transitions (SFX)",
"transitions":{
"blockfromleft":{"name":"Block from Left","frame_0":{"transform":{"opacity":0}},"frame_1":{"transform":{"opacity":1},"sfx":{"effect":"blocktoright","color":"#ffffff"},"timeline":{"ease":"Power4.easeInOut","speed":1200}}},
"blockfromright":{"name":"Block from Right","frame_0":{"transform":{"opacity":0}},"frame_1":{"transform":{"opacity":1},"sfx":{"effect":"blocktoleft","color":"#ffffff"},"timeline":{"ease":"Power4.easeInOut","speed":1200}}},
"blockfromtop":{"name":"Block from Top","frame_0":{"transform":{"opacity":0}},"frame_1":{"transform":{"opacity":1},"sfx":{"effect":"blocktobottom","color":"#ffffff"},"timeline":{"ease":"Power4.easeInOut","speed":1200}}},
"blockfrombottom":{"name":"Block from Bottom","frame_0":{"transform":{"opacity":0}},"frame_1":{"transform":{"opacity":1},"sfx":{"effect":"blocktotop","color":"#ffffff"},"timeline":{"ease":"Power4.easeInOut","speed":1200}}}
}
},
"lettran":{
"group":"Letter Transitions",
"transitions":{
"LettersFlyInFromLeft":{"name":"Letters Fly In From Left","frame_0":{"transform":{"opacity":1},"chars":{"use":true,"x":"-105%","opacity":"0","rotationZ":"-90deg"},"mask":{"use":true}},"frame_1":{"timeline":{"speed":1200},"transform":{"opacity":1},"chars":{"ease":"Power4.easeInOut","use":true,"direction":"backward","delay":10,"x":0,"opacity":1,"rotationZ":"0deg"},"mask":{"use":true}}},
"LettersFlyInFromRight":{"name":"Letters Fly In From Right","frame_0":{"transform":{"opacity":1},"chars":{"use":true,"x":"105%","opacity":"1","rotationY":"45deg","rotationZ":"90deg"},"mask":{"use":true}},"frame_1":{"timeline":{"speed":1200},"transform":{"opacity":1},"chars":{"ease":"Power4.easeInOut","use":true,"direction":"forward","delay":10,"x":0,"opacity":1,"rotationY":0,"rotationZ":"0deg"},"mask":{"use":true}}},
"LettersFlyInFromTop":{"name":"Letters Fly In From Top","frame_0":{"transform":{"opacity":1},"chars":{"use":true,"y":"-100%","opacity":"0","rotationZ":"35deg"},"mask":{"use":true}},"frame_1":{"timeline":{"speed":1200},"transform":{"opacity":1},"chars":{"ease":"Power4.easeInOut","use":true,"direction":"forward","delay":10,"y":0,"opacity":1,"rotationZ":"0deg"},"mask":{"use":true}}},
"LettersFlyInFromBottom":{"name":"Letters Fly In From Bottom","frame_0":{"transform":{"opacity":1},"chars":{"use":true,"y":"100%","opacity":"0","rotationZ":"-35deg"},"mask":{"use":true}},"frame_1":{"timeline":{"speed":1200},"transform":{"opacity":1},"chars":{"ease":"Power4.easeInOut","use":true,"direction":"forward","delay":10,"y":0,"opacity":1,"rotationZ":"0deg"},"mask":{"use":true}}},
"LetterFlipFromTop":{"name":"Letter Flip From Top","frame_0":{"transform":{"opacity":1},"chars":{"use":true,"opacity":0,"rotationX":"90deg","y":"0","originZ":"-50"}},"frame_1":{"timeline":{"speed":1750},"chars":{"use":true,"opacity":1,"rotationX":0,"delay":10,"originZ":"-50","ease":"Power4.easeInOut"}}},
"LetterFlipFromBottom":{"name":"Letter Flip From Bottom","frame_0":{"transform":{"opacity":1},"chars":{"use":true,"opacity":0,"rotationX":"-90deg","y":"0","originZ":"-50"}},"frame_1":{"timeline":{"speed":1750},"chars":{"use":true,"opacity":1,"rotationX":0,"delay":10,"originZ":"-50","ease":"Power4.easeInOut"}}},
"FlipAndLetterCycle":{"name":"Letter Flip Cycle","frame_0":{"transform":{"opacity":0,"rotationX":"70deg","y":"0","originZ":"-50"},"chars":{"use":true,"opacity":0,"y":"[-100||100]"}},"frame_1":{"timeline":{"speed":1750,"ease":"Power4.easeInOut"},"transform":{"opacity":1,"originZ":"-50","rotationX":0},"chars":{"use":true,"direction":"middletoedge","opacity":1,"y":0,"delay":10,"ease":"Power4.easeInOut"}}}
}
},
"masktrans":{
"group":"Masked Transitions",
"transitions":{
"MaskedZoomOut":{"name":"Masked Zoom Out","frame_0":{"transform":{"opacity":0,"scaleX":2,"scaleY":2},"mask":{"use":true}},"frame_1":{"timeline":{"speed":1000,"ease":"Power2.easeOut"},"mask":{"use":true},"transform":{"opacity":1,"scaleX":1,"scaleY":1}}},
"SlideMaskFromBottom":{"name":"Slide From Bottom","frame_0":{"transform":{"opacity":0,"y":"100%"},"mask":{"use":true}},"frame_1":{"timeline":{"speed":1200,"ease":"Power3.easeInOut"},"mask":{"use":true,"y":0},"transform":{"opacity":1,"y":0}}},
"SlideMaskFromLeft":{"name":"Slide From Left","frame_0":{"transform":{"opacity":0,"x":"-100%"},"mask":{"use":true}},"frame_1":{"timeline":{"speed":1000,"ease":"Power3.easeInOut"},"mask":{"use":true},"transform":{"opacity":1,"x":0}}},
"SlideMaskFromRight":{"name":"Slide From Right","frame_0":{"transform":{"opacity":0,"x":"100%"},"mask":{"use":true}},"frame_1":{"timeline":{"speed":1000,"ease":"Power3.easeInOut"},"mask":{"use":true},"transform":{"opacity":1,"x":0}}},
"SlideMaskFromTop":{"name":"Slide From Top","frame_0":{"transform":{"opacity":0,"y":"-100%"},"mask":{"use":true}},"frame_1":{"timeline":{"speed":1200,"ease":"Power3.easeInOut"},"mask":{"use":true},"transform":{"opacity":1,"y":0}}},
"SmoothMaskFromRight":{"name":"Smooth Mask From Right","frame_0":{"transform":{"opacity":1,"x":"-175%"},"mask":{"use":true,"x":"100%"}},"frame_1":{"timeline":{"speed":1000,"ease":"Power3.easeOut"},"mask":{"use":true,"x":0},"transform":{"opacity":1,"x":0}}},
"SmoothMaskFromLeft":{"name":"Smooth Mask From Left","frame_0":{"transform":{"opacity":1,"x":"175%"},"mask":{"use":true,"x":"-100%"}},"frame_1":{"timeline":{"speed":1000,"ease":"Power3.easeOut"},"mask":{"use":true,"x":0},"transform":{"opacity":1,"x":0}}}
}
},
"popup":{
"group":"Pop Ups",
"transitions":{
"PopUpBack":{"name":"Pop Up Back","frame_0":{"transform":{"opacity":0,"rotationY":"360deg"}},"frame_1":{"timeline":{"speed":500,"ease":"Back.easeOut"},"transform":{"opacity":1,"rotationY":0}}},
"PopUpSmooth":{"name":"Pop Up Smooth","frame_0":{"transform":{"opacity":0,"scaleX":0.9,"scaleY":0.9}},"frame_1":{"timeline":{"speed":1000,"ease":"Power3.easeInOut"},"transform":{"opacity":1,"scaleX":1,"scaleY":1}}},
"SmoothPopUp_One":{"name":"Smooth Pop Up v.1","frame_0":{"transform":{"opacity":0,"scaleX":0.8,"scaleY":0.8}},"frame_1":{"timeline":{"speed":1000,"ease":"Power4.easeOut"},"transform":{"opacity":1,"scaleX":1,"scaleY":1}}},
"SmoothPopUp_Two":{"name":"Smooth Pop Up v.2","frame_0":{"transform":{"opacity":0,"scaleX":0.9,"scaleY":0.9}},"frame_1":{"timeline":{"speed":1000,"ease":"Power2.easeInOut"},"transform":{"opacity":1,"scaleX":1,"scaleY":1}}}
}
},
"rotate":{
"group":"Rotations",
"transitions":{
"RotateInFromBottom":{"name":"Rotate In From Bottom","frame_0":{"transform":{"opacity":0,"rotationZ":"70deg","y":"bottom","scaleY":2,"scaleX":2}},"frame_1":{"timeline":{"speed":1000,"ease":"Power3.easeInOut"},"transform":{"opacity":1,"y":0,"rotationZ":0,"scaleX":1,"scaleY":1}}},
"RotateInFormZero":{"name":"Rotate In From Bottom v2.","frame_0":{"transform":{"opacity":1,"rotationY":"-20deg","rotationX":"-20deg","y":"200%","scaleY":2,"scaleX":2}},"frame_1":{"timeline":{"speed":1000,"ease":"Power3.easeOut"},"transform":{"opacity":1,"y":0,"rotationZ":0,"rotationY":0,"scaleX":1,"scaleY":1}}},
"FlipFromTop":{"name":"Flip From Top","frame_0":{"transform":{"opacity":0,"rotationX":"70deg","y":"0","originZ":"-50"}},"frame_1":{"timeline":{"speed":1750,"ease":"Power4.easeInOut"},"transform":{"opacity":1,"originZ":"-50","rotationX":0}}},
"FlipFromBottom":{"name":"Flip From Bottom","frame_0":{"transform":{"opacity":0,"rotationX":"-70deg","y":"0","originZ":"-50"}},"frame_1":{"timeline":{"speed":1750,"ease":"Power4.easeInOut"},"transform":{"opacity":1,"rotationX":0,"originZ":"-50"}}}
}
},
"slidetrans":{
"group":"Slide Transitions",
"transitions":{
"sft":{"name":"Short Slide from Top","frame_0":{"transform":{"opacity":0,"y":-50}},"frame_1":{"timeline":{"speed":1000,"ease":"Power3.easeInOut"},"transform":{"opacity":1,"y":0}}},
"sfb":{"name":"Short Slide from Bottom","frame_0":{"transform":{"opacity":0,"y":50}},"frame_1":{"timeline":{"speed":1000,"ease":"Power3.easeInOut"},"transform":{"opacity":1,"y":0}}},
"sfl":{"name":"Short Slide from Left","frame_0":{"transform":{"opacity":0,"x":-50}},"frame_1":{"timeline":{"speed":1000,"ease":"Power3.easeInOut"},"transform":{"opacity":1,"x":0}}},
"sfr":{"name":"Short Slide from Right","frame_0":{"transform":{"opacity":0,"x":50}},"frame_1":{"timeline":{"speed":1000,"ease":"Power3.easeInOut"},"transform":{"opacity":1,"x":0}}},
"lft":{"name":"Long Slide from Top","frame_0":{"transform":{"opacity":0,"y":"top"}},"frame_1":{"timeline":{"speed":1000,"ease":"Power3.easeInOut"},"transform":{"opacity":1,"y":0}}},
"lfb":{"name":"Long Slide from Bottom","frame_0":{"transform":{"opacity":0,"y":"bottom"}},"frame_1":{"timeline":{"speed":1000,"ease":"Power3.easeInOut"},"transform":{"opacity":1,"y":0}}},
"lfl":{"name":"Long Slide from Left","frame_0":{"transform":{"opacity":0,"x":"left"}},"frame_1":{"timeline":{"speed":1000,"ease":"Power3.easeInOut"},"transform":{"opacity":1,"x":0}}},
"lfr":{"name":"Long Slide from Right","frame_0":{"transform":{"opacity":0,"x":"right"}},"frame_1":{"timeline":{"speed":1000,"ease":"Power3.easeInOut"},"transform":{"opacity":1,"x":0}}},
"SmoothSlideFromBottom":{"name":"Smooth Slide From Bottom","frame_0":{"transform":{"opacity":0,"y":"100%"}},"frame_1":{"timeline":{"speed":1200,"ease":"Power4.easeInOut"},"transform":{"opacity":1,"y":0}}}
}
},
"skewtrans":{
"group":"Skew Transitions",
"transitions":{
"skewfromleft":{"name":"Skew from Left","frame_0":{"transform":{"opacity":0,"skewX":85,"x":"left"}},"frame_1":{"timeline":{"speed":1000,"ease":"Power3.easeInOut"},"transform":{"opacity":1,"skewX":0,"x":0}}},
"skewfromright":{"name":"Skew from Right","frame_0":{"transform":{"opacity":0,"skewX":-85,"x":"right"}},"frame_1":{"timeline":{"speed":1000,"ease":"Power3.easeInOut"},"transform":{"opacity":1,"skewX":0,"x":0}}},
"skewfromleftshort":{"name":"Skew from Left Short","frame_0":{"transform":{"opacity":0,"skewX":45,"x":"-100%"}},"frame_1":{"timeline":{"speed":1000,"ease":"Power3.easeInOut"},"transform":{"opacity":1,"skewX":0,"x":0}}},
"skewfromrightshort":{"name":"Skew from Right Short","frame_0":{"transform":{"opacity":0,"skewX":-45,"x":"100%"}},"frame_1":{"timeline":{"speed":1000,"ease":"Power3.easeInOut"},"transform":{"opacity":1,"skewX":0,"x":0}}}
}
},
"simpltrans":{
"group":"Simple Transitions",
"transitions":{
"noanim":{"name":"No Animation","frame_0":{"transform":{"opacity":1}},"frame_1":{"transform":{"opacity":1}}},
"tp-fade":{"name":"Fade In","frame_0":{"transform":{"opacity":0}},"frame_1":{"timeline":{"speed":1500,"ease":"Power4.easeInOut"},"transform":{"opacity":1}}}
}
},
"randtrans":{
"group":"Random Transitions",
"transitions":{
"Random":{"name":"Random","frame_0":{"transform":{"opacity":0,"y":"{-150,150}","x":"{-250,250}","scaleX":"{0,1.5}","scaleY":"{0,1.5}","rotationX":"{-90,90}","rotationY":"{-90,90}","rotationZ":"{-90,90}"}},"frame_1":{"timeline":{"speed":1500,"ease":"Power4.easeInOut"},"transform":{"opacity":1,"x":0,"y":0,"z":0,"rotationX":0,"rotationY":0,"rotationZ":0,"scaleX":1,"scaleY":1}}},
"RandomChars":{"name":"Random Chars","frame_0":{"transform":{"opacity":1},"chars":{"use":true,"y":"{-150,150}","x":"{-250,250}","scaleX":"{0,1.5}","scaleY":"{0,1.5}","rotationX":"{-90,90}","rotationY":"{-90,90}","rotationZ":"{-90,90}"}},"frame_1":{"timeline":{"speed":1500,"ease":"Power4.easeInOut"},"chars":{"use":true,"direction":"random","pacity":1,"x":0,"y":0,"z":0,"rotationX":0,"rotationY":0,"rotationZ":0,"scaleX":1,"scaleY":1,"delay":10}}}
}
}
}';
$out = '{
"custom":{"group":"Custom","custom":true,"transitions":' .
json_encode($custom_out)
. '},
"blck":{
"group":"Block Transitions (SFX)",
"transitions":{
"blocktoleft":{"name":"Block to Left","frame_999":{"transform":{"opacity":0},"sfx":{"effect":"blocktoright","color":"#ffffff"},"timeline":{"ease":"Power4.easeInOut","speed":1200}}},
"blocktoright":{"name":"Block to Right","frame_999":{"transform":{"opacity":0},"sfx":{"effect":"blocktoleft","color":"#ffffff"},"timeline":{"ease":"Power4.easeInOut","speed":1200}}},
"blocktotop":{"name":"Block to Top","frame_999":{"transform":{"opacity":0},"sfx":{"effect":"blocktobottom","color":"#ffffff"},"timeline":{"ease":"Power4.easeInOut","speed":1200}}},
"blocktobottom":{"name":"Block to Bottom","frame_999":{"transform":{"opacity":0},"sfx":{"effect":"blocktotop","color":"#ffffff"},"timeline":{"ease":"Power4.easeInOut","speed":1200}}}
}
},
"lettran":{
"group":"Letter Transitions",
"transitions":{
"LettersFlyOutToLeft":{"name":"Letters Fly Out To Left","frame_999":{"transform":{"opacity":1},"chars":{"ease":"Power4.easeInOut","direction":"forward","use":true,"x":"-105%","opacity":"0","delay":10,"rotationZ":"-90deg"},"mask":{"use":true},"timeline":{"speed":1200}}},
"LettersFlyInFromRight":{"name":"Letters Fly In From Right","frame_999":{"transform":{"opacity":1},"chars":{"ease":"Power4.easeInOut","delay":10,"direction":"backward","use":true,"x":"105%","opacity":"0","rotationY":"45deg","rotationZ":"90deg"},"timeline":{"speed":1200},"mask":{"use":true}}},
"LettersFlyInFromTop":{"name":"Letters Fly In From Top","frame_999":{"transform":{"opacity":1},"chars":{"use":true,"y":"-100%","opacity":"0","rotationZ":"35deg","ease":"Power4.easeInOut","direction":"backward","delay":10},"timeline":{"speed":1200},"mask":{"use":true}}},
"LettersFlyInFromBottom":{"name":"Letters Fly In From Bottom","frame_999":{"transform":{"opacity":1},"chars":{"use":true,"y":"100%","opacity":"0","rotationZ":"-35deg","ease":"Power4.easeInOut","direction":"forward","delay":10},"timeline":{"speed":1200},"mask":{"use":true}}},
"LetterFlipFromTop":{"name":"Letter Flip From Top","frame_999":{"transform":{"opacity":1},"chars":{"use":true,"opacity":0,"rotationX":"90deg","y":"0","originZ":"-50","ease":"Power4.easeInOut","delay":10},"timeline":{"speed":1750}}},
"LetterFlipFromBottom":{"name":"Letter Flip From Bottom","frame_999":{"transform":{"opacity":1},"chars":{"use":true,"opacity":0,"rotationX":"-90deg","y":"0","originZ":"-50","delay":10,"ease":"Power4.easeInOut"},"timeline":{"speed":1750}}},
"FlipAndLetterCycle":{"name":"Letter Flip Cycle","frame_999":{"transform":{"opacity":0,"rotationX":"70deg","y":"0","originZ":"-50"},"chars":{"use":true,"direction":"middletoedge","delay":10,"ease":"Power4.easeInOut","opacity":0,"y":"[-100||100]"},"timeline":{"speed":1750,"ease":"Power4.easeInOut"}}}
}
},
"masktrans":{
"group":"Masked Transitions",
"transitions":{
"MaskedZoomOut":{"name":"Masked Zoom In","frame_999":{"transform":{"opacity":0,"scaleX":2,"scaleY":2},"mask":{"use":true},"timeline":{"speed":1000,"ease":"Power2.easeOut"}}},
"SlideMaskToBottom":{"name":"Slide To Bottom","frame_999":{"transform":{"opacity":0,"y":"100%"},"mask":{"use":true},"timeline":{"speed":1200,"ease":"Power3.easeInOut"}}},
"SlideMaskToLeft":{"name":"Slide To Left","frame_999":{"transform":{"opacity":0,"x":"-100%"},"mask":{"use":true},"timeline":{"speed":1000,"ease":"Power3.easeInOut"}}},
"SlideMaskToRight":{"name":"Slide To Right","frame_999":{"transform":{"opacity":0,"x":"100%"},"mask":{"use":true},"timeline":{"speed":1000,"ease":"Power3.easeInOut"}}},
"SlideMaskToTop":{"name":"Slide To Top","frame_999":{"transform":{"opacity":0,"y":"-100%"},"mask":{"use":true},"timeline":{"speed":1200,"ease":"Power3.easeInOut"}}},
"SmoothMaskToRight":{"name":"Smooth Mask To Right","frame_999":{"transform":{"opacity":1,"x":"-175%"},"mask":{"use":true,"x":"100%"},"timeline":{"speed":1000,"ease":"Power3.easeInOut"}}},
"SmoothMaskToLeft":{"name":"Smooth Mask To Left","frame_999":{"transform":{"opacity":1,"x":"175%"},"mask":{"use":true,"x":"-100%"},"timeline":{"speed":1000,"ease":"Power3.easeInOut"}}},
"SmoothToBottom":{"name":"Smooth To Bottom","frame_999":{"transform":{"opacity":1,"y":"175%"},"mask":{"use":true},"timeline":{"speed":1000,"ease":"Power2.easeInOut"}}},
"SmoothToTop":{"name":"Smooth To Top","frame_999":{"transform":{"opacity":1,"y":"-175%"},"mask":{"use":true},"timeline":{"speed":1000,"ease":"Power2.easeInOut"}}}
}
},
"bounce":{
"group":"Bounce and Hide",
"transitions":{
"BounceOut":{"name":"Bounce Out","frame_999":{"timeline":{"speed":500,"ease":"Back.easeIn"},"transform":{"opacity":0,"scaleX":0.7,"scaleY":0.7}}},
"SlurpOut":{"name":"Slurp Out","frame_999":{"timeline":{"speed":1000,"ease":"Power2.easeIn"},"transform":{"opacity":0,"y":"100%","scaleX":0.7,"scaleY":0.7},"mask":{"use":true}}},
"PopUpBack":{"name":"Bounce Out Rotate","frame_999":{"timeline":{"speed":500,"ease":"Back.easeIn"},"transform":{"opacity":0,"rotationY":"360deg"}}},
"PopUpSmooth":{"name":"Hide Smooth","frame_999":{"timeline":{"speed":1000,"ease":"Power3.easeInOut"},"transform":{"opacity":0,"scaleX":0.9,"scaleY":0.9}}},
"SmoothPopUp_One":{"name":"Smooth Hide v.1","frame_999":{"timeline":{"speed":1000,"ease":"Power4.easeOut"},"transform":{"opacity":0,"scaleX":0.8,"scaleY":0.8}}},
"SmoothPopUp_Two":{"name":"Smooth Hide v.2","frame_999":{"timeline":{"speed":1000,"ease":"Power2.easeInOut"},"transform":{"opacity":0,"scaleX":0.9,"scaleY":0.9}}}
}
},
"rotate":{
"group":"Rotations",
"transitions":{
"RotateOutToBottom":{"name":"Rotate Out To Bottom","frame_999":{"timeline":{"speed":1000,"ease":"Power3.easeInOut"},"transform":{"opacity":0,"rotationZ":"70deg","y":"bottom","scaleY":2,"scaleX":2}}},
"RotateInFormZero":{"name":"Rotate Out To Bottom v2.","frame_999":{"timeline":{"speed":1000,"ease":"Power3.easeOut"},"transform":{"opacity":0,"rotationY":"-20deg","rotationX":"-20deg","y":"200%","scaleY":2,"scaleX":2}}},
"FlipToTop":{"name":"Flip To Top","frame_999":{"timeline":{"speed":1750,"ease":"Power4.easeInOut"},"transform":{"opacity":0,"rotationX":"70deg","y":"0","originZ":"-50"}}},
"FlipToBottom":{"name":"Flip To Bottom","frame_999":{"timeline":{"speed":1750,"ease":"Power4.easeInOut"},"transform":{"opacity":0,"rotationX":"-70deg","y":"0","originZ":"-50"}}}
}
},
"slidetrans":{
"group":"Slide Transitions",
"transitions":{
"stt":{"name":"Short Slide to Top","frame_999":{"timeline":{"speed":1000,"ease":"Power3.easeInOut"},"transform":{"opacity":0,"y":-50}}},
"stb":{"name":"Short Slide to Bottom","frame_999":{"timeline":{"speed":1000,"ease":"Power3.easeInOut"},"transform":{"opacity":0,"y":50}}},
"stl":{"name":"Short Slide to Left","frame_999":{"timeline":{"speed":1000,"ease":"Power3.easeInOut"},"transform":{"opacity":0,"x":-50}}},
"str":{"name":"Short Slide to Right","frame_999":{"timeline":{"speed":1000,"ease":"Power3.easeInOut"},"transform":{"opacity":0,"x":50}}},
"ltt":{"name":"Long Slide to Top","frame_999":{"timeline":{"speed":1000,"ease":"Power3.easeInOut"},"transform":{"opacity":0,"y":"top"}}},
"ltb":{"name":"Long Slide to Bottom","frame_999":{"timeline":{"speed":1000,"ease":"Power3.easeInOut"},"transform":{"opacity":0,"y":"bottom"}}},
"ltl":{"name":"Long Slide to Left","frame_999":{"timeline":{"speed":1000,"ease":"Power3.easeInOut"},"transform":{"opacity":0,"x":"left"}}},
"ltr":{"name":"Long Slide to Right","frame_999":{"timeline":{"speed":1000,"ease":"Power3.easeInOut"},"transform":{"opacity":0,"x":"right"}}},
"SmoothSlideToBottom":{"name":"Smooth Slide To Bottom","frame_999":{"timeline":{"speed":1200,"ease":"Power4.easeInOut"},"transform":{"opacity":0,"y":"100%"}}}
}
},
"skewtrans":{
"group":"Skew Transitions",
"transitions":{
"skewfromleft":{"name":"Skew from Left","frame_999":{"timeline":{"speed":1000,"ease":"Power3.easeInOut"},"transform":{"opacity":0,"skewX":85,"x":"left"}}},
"skewfromright":{"name":"Skew from Right","frame_999":{"timeline":{"speed":1000,"ease":"Power3.easeInOut"},"transform":{"opacity":0,"skewX":-85,"x":"right"}}},
"skewfromleftshort":{"name":"Skew from Left Short","frame_999":{"timeline":{"speed":1000,"ease":"Power3.easeInOut"},"transform":{"opacity":0,"skewX":45,"x":"-100%"}}},
"skewfromrightshort":{"name":"Skew from Right Short","frame_999":{"timeline":{"speed":1000,"ease":"Power3.easeInOut"},"transform":{"opacity":0,"skewX":-45,"x":"100%"}}}
}
},
"simpltrans":{
"group":"Simple Transitions",
"transitions":{
"noanim":{"name":"No Animation","frame_999":{"transform":{"opacity":1}}},
"tp-fade-out":{"name":"Fade Out","frame_999":{"timeline":{"speed":1000,"ease":"Power4.easeInOut"},"transform":{"opacity":0}}},
"fadeoutlong":{"name":"Fade Out Long","frame_999":{"timeline":{"speed":1000,"ease":"Power2.easeIn"},"transform":{"opacity":0}}}
}
},
"randtrans":{
"group":"Random Transitions",
"transitions":{
"RandomOut":{"name":"Random Out","frame_999":{"timeline":{"speed":1500,"ease":"Power4.easeInOut"},"transform":{"opacity":0,"y":"{-150,150}","x":"{-250,250}","scaleX":"{0,1.5}","scaleY":"{0,1.5}","rotationX":"{-90,90}","rotationY":"{-90,90}","rotationZ":"{-90,90}"}}},
"RandomCharsOut":{"name":"Random Chars Out","frame_999":{"timeline":{"speed":1500,"ease":"Power4.easeInOut"},"transform":{"opacity":1},"chars":{"direction":"random","delay":10,"use":true,"y":"{-150,150}","x":"{-250,250}","scaleX":"{0,1.5}","scaleY":"{0,1.5}","rotationX":"{-90,90}","rotationY":"{-90,90}","rotationZ":"{-90,90}"}}}
}
}
}';
$loop = '{
"custom":{group:"Custom",custom:true,transitions:' .
json_encode($custom_loop)
. '},
"pendulum":{group:"Pendulum Loops",
transitions: {
"inplacependulum":{name:"In Place Pendulum", loop:{use:true, yoyo_rotate:true, speed:3000, ease:"Power1.easeInOut", frame_0:{rotationZ:-40}, frame_999:{rotationZ:40}}},
"pendulumbelow":{name:"Pendulum Below", loop:{use:true, yoyo_rotate:true, speed:3000, originY:"-200%", ease:"Sine.easeInOut", frame_0:{rotationZ:-40}, frame_999:{rotationZ:40}}},
"pendulumabove":{name:"Pendulum Above",loop:{use:true, yoyo_rotate:true, speed:3000, originY:"200%", ease:"Sine.easeInOut", frame_0:{rotationZ:-40}, frame_999:{rotationZ:40}}},
"pendulumleft":{name:"Pendulum Left",loop:{use:true, yoyo_rotate:true, speed:3000, originX:"150%", ease:"Sine.easeInOut", frame_0:{rotationZ:-20}, frame_999:{rotationZ:20}}},
"pendulumright":{name:"Pendulum Right",loop:{use:true, yoyo_rotate:true, speed:3000, originX:"-50%", ease:"Sine.easeInOut", frame_0:{rotationZ:-20}, frame_999:{rotationZ:20}}}
}},
"effects":{group:"Effect Loops",
transitions: {
"grayscale":{name:"Grayscale",loop:{use:true, yoyo_filter:true, speed:1000, ease:"Sine.easeInOut", frame_0:{grayscale:0}, frame_999:{grayscale:100}}},
"blink":{name:"Blink",loop:{use:true, yoyo_filter:true, speed:1500, ease:"Sine.easeInOut", frame_0:{opacity:0}, frame_999:{opacity:1}}},
"flattern":{name:"Flattern",loop:{use:true, yoyo_filter:true, speed:100, ease:"Sine.easeInOut", frame_0:{opacity:0.2,blur:0}, frame_999:{opacity:1,blur:4}}},
"lighting":{name:"Lithing",loop:{use:true, yoyo_filter:true, speed:1000, ease:"Sine.easeInOut", frame_0:{brightness:100}, frame_999:{brightness:1000}}}
}},
"wave":{group:"Wave",
transitions: {
"littlewaveleft":{name:"Little Wave Left", loop:{use:true, curved:true, speed:3000, ease:"Linear.easeNone", frame_0:{xr:60,yr:60}, frame_999:{xr:60,yr:60}}},
"littlewaveright":{name:"Little Wave Right", loop:{use:true, curved:true, speed:3000, ease:"Linear.easeNone", frame_0:{xr:60,yr:-60}, frame_999:{xr:60,yr:-60}}},
"Bigwaveleft":{name:"Big Wave Left", loop:{use:true, curved:true, speed:3000, ease:"Linear.easeNone", frame_0:{xr:140,yr:140}, frame_999:{xr:140,yr:140}}},
"Bigwaveright":{name:"Big Wave Right", loop:{use:true, curved:true, speed:3000, ease:"Linear.easeNone", frame_0:{xr:140,yr:-140}, frame_999:{xr:140,yr:-140}}},
"eight":{name:"Curving Wave", loop:{use:true, curved:true, speed:3000, ease:"Linear.easeNone", curviness:8, frame_0:{xr:100,yr:100}, frame_999:{xr:100,yr:100}}}
}},
"wiggle":{group:"Wiggles",
transitions: {
"smoothwigglez":{name:"Smooth Y Axis Wiggle", loop:{use:true, yoyo_rotate:true, speed:3000, ease:"Sine.easeInOut", frame_0:{rotationY:-40}, frame_999:{rotationY:40}}},
"smoothwigglezii":{name:"Smooth Y Axis Wiggle II.", loop:{use:true, originZ:60, yoyo_rotate:true, speed:3000, ease:"Sine.easeInOut", frame_0:{rotationY:-40}, frame_999:{rotationY:40}}},
"smoothwiggleziii":{name:"Smooth Y Axis Wiggle III.", loop:{use:true, originZ:-160, yoyo_rotate:true, speed:3000, ease:"Sine.easeInOut", frame_0:{rotationY:-40}, frame_999:{rotationY:40}}},
"smoothwigglex":{name:"Smooth X Axis Wiggle", loop:{use:true, yoyo_rotate:true, speed:3000, ease:"Sine.easeInOut", frame_0:{rotationX:-40}, frame_999:{rotationX:40}}},
"smoothwigglexii":{name:"Smooth X Axis Wiggle II", loop:{use:true, originZ:60, yoyo_rotate:true, speed:3000, ease:"Sine.easeInOut", frame_0:{rotationX:-40}, frame_999:{rotationX:40}}},
"smoothwigglexiii":{name:"Smooth X Axis Wiggle III", loop:{use:true, originZ:-160, yoyo_rotate:true, speed:3000, ease:"Sine.easeInOut", frame_0:{rotationX:-40}, frame_999:{rotationX:40}}},
"crazywiggle":{name:"Funny Wiggle Path", loop:{use:true, originZ:-160, originY:"-50%", yoyo_scale:true, yoyo_move:true, yoyo_rotate:true, speed:3000, ease:"Circ.easeInOut", frame_0:{x:100, y:-70,rotationX:-20, rotationY:-20, rotationZ:10}, frame_999:{x:0, y:70,scaleX:1.4, scaleY:1.4, rotationX:30, rotationY:10, rotationZ:-5}}}
}},
"rotate":{group:"Rotating",
transitions: {
"rotating":{name:"Rotate", loop:{use:true, speed:3000, ease:"Linear.easeNone", frame_0:{rotationZ:0}, frame_999:{rotationZ:360}}},
"rotatingyoyo":{name:"Rotate Forw. Backw.", loop:{use:true, yoyo_rotate:true, speed:3000, ease:"Linear.easeNone", frame_0:{rotationZ:-100}, frame_999:{rotationZ:100}}},
"leaf":{name:"Flying Around", loop:{use:true, curved:true, curviness:25, yoyo_rotate:true, yoyo_filter:true, speed:6000, ease:"Linear.easeNone", frame_0:{xr:30,yr:22,zr:40}, frame_999:{xr:40,yr:12, zr:-100, rotationZ:720,blur:5}}},
}},
"slide":{group:"Slide and Hover",
transitions: {
"slidehorizontal":{name:"Slide Horizontal", loop:{use:true, yoyo_move:true, speed:3000, ease:"Sine.easeInOut", frame_0:{x:-100}, frame_999:{x:100}}},
"hoover":{name:"Hover", loop:{use:true, yoyo_move:true,speed:6000, ease:"Sine.easeInOut", frame_0:{y:-10}, frame_999:{y:10}}},
}},
"pulse":{group:"Pulse",
transitions: {
"pulse":{name:"Pulse", loop:{use:true, yoyo_scale:true, yoyo_filter:true, speed:2000, ease:"Power4.easeInOut", frame_999:{scaleX:1.2, scaleY:1.2}}},
"pulseminus":{name:"Pulse Minus", loop:{use:true, yoyo_scale:true, yoyo_filter:true, speed:2000, ease:"Power0.easeInOut", frame_999:{scaleX:0.8, scaleY:0.8}}},
"pulseandopacity":{name:"Pulse and Fade", loop:{use:true, yoyo_scale:true, yoyo_filter:true, speed:2000, ease:"Power0.easeInOut", frame_999:{scaleX:1.2, scaleY:1.2,opacity:0.6}}},
"pulseandopacityminus":{name:"Pulse and Fade Minus", loop:{use:true, yoyo_scale:true, yoyo_filter:true, speed:2000, ease:"Power2.easeInOut", frame_999:{scaleX:0.8, scaleY:0.8,opacity:0.6}}},
"pulseandopablur":{name:"Pulse and Blur", loop:{use:true, yoyo_scale:true, yoyo_filter:true, speed:2000, ease:"Power1.easeInOut", frame_999:{scaleX:1.2, scaleY:1.2,opacity:0.8,blur:5}}},
"pulseandopablurminus":{name:"Pulse and Blur Minus", loop:{use:true, yoyo_scale:true, yoyo_filter:true, speed:2000, ease:"Power0.easeInOut", frame_999:{scaleX:0.8, scaleY:0.8,opacity:0.8,blur:5}}}
}},
}';
$anim = array();
$anim['in'] = ($raw) ? $in : json_decode($in, true);
$anim['out'] = ($raw) ? $out : json_decode($out, true);
$anim['loop'] = ($raw) ? $loop : json_decode($loop, true);
return $anim;
}
/**
* add default icon sets of Slider Revolution
* @since: 5.0
* @before: RevSliderBase::set_icon_sets();
**/
public function set_icon_sets($icon_sets){
$icon_sets[] = 'fa-icon-';
$icon_sets[] = 'fa-';
$icon_sets[] = 'pe-7s-';
return $icon_sets;
}
}
?>

View File

@@ -0,0 +1,177 @@
<?php
/**
* @author ThemePunch <info@themepunch.com>
* @link https://www.themepunch.com/
* @copyright 2019 ThemePunch
*/
if(!defined('ABSPATH')) exit();
class RevSliderEventsManager extends RevSliderFunctions {
public function __construct(){
add_filter('revslider_get_posts_by_category', array($this, 'add_post_query'), 10, 2);
}
/**
* check if events class exists
*/
public static function isEventsExists(){
return (defined('EM_VERSION') && defined('EM_PRO_MIN_VERSION')) ? true : false;
}
/**
* get sort by list
* @before: RevSliderEventsManager::getArrFilterTypes()
*/
public static function get_filter_types(){
return array(
'none' => __('All Events', 'revslider'),
'today' => __('Today', 'revslider'),
'tomorrow' => __('Tomorrow', 'revslider'),
'future' => __('Future', 'revslider'),
'past' => __('Past', 'revslider'),
'month' => __('This Month', 'revslider'),
'nextmonth' => __('Next Month', 'revslider')
);
}
/**
* get meta query
* @before: RevSliderEventsManager::getWPQuery()
*/
public static function get_query($filter_type, $sort_by){
$response = array();
$dayMs = 60 * 60 * 24;
$time = current_time('timestamp');
$todayStart = strtotime(date('Y-m-d', $time));
$todayEnd = $todayStart + $dayMs-1;
$tomorrowStart = $todayEnd+1;
$tomorrowEnd = $tomorrowStart + $dayMs-1;
$start_month = strtotime(date('Y-m-1',$time));
$end_month = strtotime(date('Y-m-t',$time)) + 86399;
$next_month_middle = strtotime('+1 month', $time); //get the end of this month + 1 day
$start_next_month = strtotime(date('Y-m-1',$next_month_middle));
$end_next_month = strtotime(date('Y-m-t',$next_month_middle)) + 86399;
$query = array();
switch($filter_type){
case 'none': //none
break;
case 'today':
$query[] = array('key' => '_start_ts', 'value' => $todayEnd, 'compare' => '<=');
$query[] = array('key' => '_end_ts', 'value' => $todayStart, 'compare' => '>=');
break;
case 'future':
$query[] = array('key' => '_start_ts', 'value' => $time, 'compare' => '>');
break;
case 'tomorrow':
$query[] = array('key' => '_start_ts', 'value' => $tomorrowEnd, 'compare' => '<=');
$query[] = array('key' => '_end_ts', 'value' => $todayStart, 'compare' => '>=');
break;
case 'past':
$query[] = array('key' => '_end_ts', 'value' => $todayStart, 'compare' => '<');
break;
case 'month':
$query[] = array('key' => '_start_ts', 'value' => $end_month, 'compare' => '<=');
$query[] = array('key' => '_end_ts', 'value' => $start_month, 'compare' => '>=');
break;
case 'nextmonth':
$query[] = array('key' => '_start_ts', 'value' => $end_next_month, 'compare' => '<=');
$query[] = array('key' => '_end_ts', 'value' => $start_next_month, 'compare' => '>=');
break;
default:
$this->throw_error('Wrong event filter');
break;
}
if(!empty($query))
$response['meta_query'] = $query;
//convert sortby
switch($sort_by){
case 'event_start_date':
$response['orderby'] = 'meta_value_num';
$response['meta_key'] = '_start_ts';
break;
case 'event_end_date':
$response['orderby'] = 'meta_value_num';
$response['meta_key'] = '_end_ts';
break;
}
return $response;
}
/**
* get event post data in array.
* if the post is not event, return empty array
* @before: RevSliderEventsManager::getEventPostData()
*/
public static function get_event_post_data($postID){
if(self::isEventsExists() == false) return array();
$postType = get_post_type($postID);
if($postType != EM_POST_TYPE_EVENT) return array();
$f = new RevSliderFunctions();
$event = new EM_Event($postID, 'post_id');
$location = $event->get_location();
$ev = $event->to_array();
$loc = $location->to_array();
$date_format = get_option('date_format');
$time_format = get_option('time_format');
$response = array(
'id' => $f->get_val($ev, 'event_id'),
'start_date' => date_format(date_create_from_format('Y-m-d', $f->get_val($ev, 'event_start_date')), $date_format),
'end_date' => date_format(date_create_from_format('Y-m-d', $f->get_val($ev, 'event_end_date')), $date_format),
'start_time' => date_format(date_create_from_format('H:i:s', $f->get_val($ev, 'event_start_time')), $time_format),
'end_time' => date_format(date_create_from_format('H:i:s', $f->get_val($ev, 'event_end_time')), $time_format),
'location_name' => $f->get_val($loc, 'location_name'),
'location_address' => $f->get_val($loc, 'location_address'),
'location_slug' => $f->get_val($loc, 'location_slug'),
'location_town' => $f->get_val($loc, 'location_town'),
'location_state' => $f->get_val($loc, 'location_state'),
'location_postcode' => $f->get_val($loc, 'location_postcode'),
'location_region' => $f->get_val($loc, 'location_region'),
'location_country' => $f->get_val($loc, 'location_country'),
'location_latitude' => $f->get_val($loc, 'location_latitude'),
'location_longitude' => $f->get_val($loc, 'location_longitude')
);
return $response;
}
/**
* get events sort by array
*/
public static function getArrSortBy(){
return array(
'event_start_date' => __('Event Start Date', 'revslider'),
'event_end_date' => __('Event End Date', 'revslider')
);
}
/**
* triggered if we receive posts by categories (RevSliderSlider::get_posts_by_categories())
**/
public function add_post_query($data, $slider){
$filter_type = $slider->get_param('events_filter', 'none');
if(self::isEventsExists()){
$data['addition'] = RevSliderEventsManager::get_query($filter_type, $this->get_val($data, 'sort_by'));
}
return $data;
}
}
//$rs_em = new RevSliderEventsManager();
?>

View File

@@ -0,0 +1,209 @@
<?php
/**
* @package RevSliderExtension
* @author ThemePunch <info@themepunch.com>
* @link https://revolution.themepunch.com/
* @copyright 2019 ThemePunch
*/
if(!defined('ABSPATH')) exit();
class RevSliderExtension {
public function __construct() {
$this->init_essential_grid_extensions();
}
/***************************
* Setup part for Revslider inclusion into Essential Grid
***************************/
/**
* Do all initializations for RevSlider integration
*/
public function init_essential_grid_extensions(){
if(!class_exists('Essential_Grid')) return false; //only add if Essential Grid is installed
add_filter('essgrid_set_ajax_source_order', array($this, 'add_slider_to_eg_ajax'));
add_filter('essgrid_handle_ajax_content', array($this, 'set_slider_values_to_eg_ajax'), 10, 4);
add_action('essgrid_add_meta_options', array($this, 'add_eg_additional_meta_field'));
add_action('essgrid_save_meta_options', array($this, 'save_eg_additional_meta_field'), 10, 2);
//only do on frontend
add_action('admin_head', array($this, 'add_eg_additional_inline_javascript'));
add_action('wp_footer', array($this, 'add_eg_additional_inline_javascript'));
}
/**
* Add Slider to the List of choosable media
*/
public function add_slider_to_eg_ajax($media){
$media['revslider'] = array('name' => __('Slider Revolution', 'revslider'), 'type' => 'ccw');
return $media;
}
/**
* Add Slider to the List of choosable media
*/
public function set_slider_values_to_eg_ajax($handle, $media_sources, $post, $grid_id){
if($handle !== 'revslider') return false;
$slider_source = '';
$values = get_post_custom($post['ID']);
if(isset($values['eg_sources_revslider'])){
if(isset($values['eg_sources_revslider'][0]))
$slider_source = (isset($values['eg_sources_revslider'][0])) ? $values['eg_sources_revslider'][0] : '';
else
$slider_source = (isset($values['eg_sources_revslider'])) ? $values['eg_sources_revslider'] : '';
}
if($slider_source === ''){
return false;
}else{
return ' data-ajaxtype="'.$handle.'" data-ajaxsource="'.$slider_source.'"';
}
}
/**
* Adds custom meta field into the essential grid meta box for post/pages
*/
public function add_eg_additional_meta_field($values){
$sld = new RevSliderSlider();
$sliders = $sld->get_sliders();
$shortcodes = array();
if(!empty($sliders)){
$first = true;
foreach($sliders as $slider){
$name = $slider->get_param('shortcode','false');
if($name != 'false'){
$shortcodes[$slider->get_id()] = $name;
$first = false;
}
}
}
$selected_slider = (isset($values['eg_sources_revslider'])) ? $values['eg_sources_revslider'] : '';
if($selected_slider == ''){
$selected_slider = array();
$selected_slider[0] = '';
}
?>
<p>
<strong style="font-size:14px"><?php _e('Choose Revolution Slider', 'revslider'); ?></strong>
</p>
<p>
<select name="eg_sources_revslider" id="eg_sources_revslider">
<option value=""<?php selected($selected_slider[0], ''); ?>><?php _e('--- Choose Slider ---', 'revslider'); ?></option>
<?php
if(!empty($shortcodes)){
foreach($shortcodes as $id => $name){
?>
<option value="<?php echo $id; ?>"<?php selected($selected_slider[0], $id); ?>><?php echo $name; ?></option>
<?php
}
}
?>
</select>
</p>
<?php
}
/**
* Adds custom meta field into the essential grid meta box for post/pages
*/
public function save_eg_additional_meta_field($metas, $post_id){
if(isset($metas['eg_sources_revslider']))
update_post_meta($post_id, 'eg_sources_revslider', $metas['eg_sources_revslider']);
}
/**
* Adds needed javascript to the DOM
*/
public function add_eg_additional_inline_javascript(){
?>
<script type="text/javascript">
var ajaxRevslider;
jQuery(document).ready(function() {
// CUSTOM AJAX CONTENT LOADING FUNCTION
ajaxRevslider = function(obj) {
// obj.type : Post Type
// obj.id : ID of Content to Load
// obj.aspectratio : The Aspect Ratio of the Container / Media
// obj.selector : The Container Selector where the Content of Ajax will be injected. It is done via the Essential Grid on Return of Content
var content = '';
var data = {
action: 'revslider_ajax_call_front',
client_action: 'get_slider_html',
token: '<?php echo wp_create_nonce('RevSlider_Front'); ?>',
type: obj.type,
id: obj.id,
aspectratio: obj.aspectratio
};
// SYNC AJAX REQUEST
jQuery.ajax({
type: 'post',
url: '<?php echo admin_url('admin-ajax.php'); ?>',
dataType: 'json',
data: data,
async: false,
success: function(ret, textStatus, XMLHttpRequest) {
if(ret.success == true)
content = ret.data;
},
error: function(e) {
console.log(e);
}
});
// FIRST RETURN THE CONTENT WHEN IT IS LOADED !!
return content;
};
// CUSTOM AJAX FUNCTION TO REMOVE THE SLIDER
var ajaxRemoveRevslider = function(obj) {
return jQuery(obj.selector + ' .rev_slider').revkill();
};
// EXTEND THE AJAX CONTENT LOADING TYPES WITH TYPE AND FUNCTION
if (jQuery.fn.tpessential !== undefined)
if(typeof(jQuery.fn.tpessential.defaults) !== 'undefined')
jQuery.fn.tpessential.defaults.ajaxTypes.push({type: 'revslider', func: ajaxRevslider, killfunc: ajaxRemoveRevslider, openAnimationSpeed: 0.3});
// type: Name of the Post to load via Ajax into the Essential Grid Ajax Container
// func: the Function Name which is Called once the Item with the Post Type has been clicked
// killfunc: function to kill in case the Ajax Window going to be removed (before Remove function !
// openAnimationSpeed: how quick the Ajax Content window should be animated (default is 0.3)
});
</script>
<?php
}
}
$revext = new RevSliderExtension();
?>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,73 @@
<?php
/**
* @author ThemePunch <info@themepunch.com>
* @link https://www.themepunch.com/
* @copyright 2019 ThemePunch
*/
if(!defined('ABSPATH')) exit();
class RevSliderFavorite extends RevSliderFunctions {
public $allowed = array(
'moduletemplates',
'moduletemplateslides',
'modules',
'moduleslides',
'svgs',
'images',
'videos',
'objects',
'fonticons'
);
/**
* change the setting of a favorization
**/
public function set_favorite($do, $type, $id){
$fav = get_option('rs_favorite', array());
$id = esc_attr($id);
if(in_array($type, $this->allowed)){
if(!isset($fav[$type])) $fav[$type] = array();
$key = array_search($id, $fav[$type]);
if($key === false){
if($do == 'add') $fav[$type][] = $id;
}else{
if($do == 'remove'){
unset($fav[$type][$key]);
}
}
}
update_option('rs_favorite', $fav);
return $fav;
}
/**
* get a certain favorite type
**/
public function get_favorite($type){
$fav = get_option('rs_favorite', array());
$list = array();
if(in_array($type, $this->allowed)){
$list = $this->get_val($fav, $type, array());
}
return $list;
}
/**
* return if certain element is in favorites
**/
public function is_favorite($type, $id){
$favs = $this->get_favorite($type);
return (array_search($id, $favs) !== false) ? true : false;
}
}
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,688 @@
<?php
/**
* @package Revolution Slider
* @author ThemePunch <info@themepunch.com>
* @link https://revolution.themepunch.com/
* @copyright 2019 ThemePunch
*/
if(!defined('ABSPATH')) exit();
class RevSliderNavigation extends RevSliderFunctions {
public $version = '6.0.0';
public function init_by_id($nav_id){
if(intval($nav_id) == 0) return false;
global $wpdb;
$row = $wpdb->get_row($wpdb->prepare("SELECT `id`, `handle`, `type`, `css`, `settings` FROM ".$wpdb->prefix.RevSliderFront::TABLE_NAVIGATIONS." WHERE `id` = %d", $nav_id), ARRAY_A);
return $row;
}
/**
* Get all Navigations Short
* @since: 5.0
**/
public function get_all_navigations_short(){
global $wpdb;
$navigations = $wpdb->get_results("SELECT `id`, `handle`, `name` FROM ".$wpdb->prefix.RevSliderFront::TABLE_NAVIGATIONS, ARRAY_A);
return $navigations;
}
public function get_all_navigations_builder($defaults = true, $raw = false){
$navs = $this->get_all_navigations($defaults, $raw);
$real_navs = array(
'arrows' => array(),
'thumbs' => array(),
'bullets' => array(),
'tabs' => array()
);
if(!empty($navs)){
foreach($navs as $nav){
$real_navs[$this->get_val($nav, 'type')][$this->get_val($nav, 'id')] = $nav;
/*array(
'id' => $this->get_val($nav, 'id'),
'handle' => $this->get_val($nav, 'handle'),
'name' => $this->get_val($nav, 'name'),
'factory' => $this->get_val($nav, 'factory'),
'css' => $this->get_val($nav, 'css'),
'markup' => $this->get_val($nav, 'markup'),
'dim' => $this->get_val($nav, 'dim', array()),
'placeholders' => $this->get_val($nav, 'placeholders', array()),
'presets' => $this->get_val($nav, 'presets', array())
);*/
}
}
return $real_navs;
}
/**
* Get all Navigations
* @since: 5.0
**/
public function get_all_navigations($defaults = true, $raw = false, $old = false){
global $wpdb;
$navigations = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix.RevSliderFront::TABLE_NAVIGATIONS, ARRAY_A);
if($raw == false){
foreach($navigations as $key => $nav){
$navigations[$key]['factory'] = false;
$navigations[$key]['css'] = ($old === true) ? $navigations[$key]['css'] : stripslashes($navigations[$key]['css']);
$navigations[$key]['markup'] = ($old === true) ? $navigations[$key]['markup'] : stripslashes($navigations[$key]['markup']);
if(isset($navigations[$key]['settings'])){
$navigations[$key]['settings'] = RevSliderFunctions::stripslashes_deep(json_decode($navigations[$key]['settings'], true));
if(!is_array($navigations[$key]['settings'])){
$navigations[$key]['settings'] = json_decode($navigations[$key]['settings'], true);
}
}
}
}
if($defaults){
$def = self::get_default_navigations();
$default_presets = get_option('revslider-nav-preset-default', array());
if(!empty($def)){
if($raw == false){
foreach($def as $key => $nav){
$def[$key]['factory'] = true;
if(isset($def[$key]['settings'])){
$def[$key]['settings'] = json_decode($def[$key]['settings'], true);
}
//add custom settings (placeholders) to the default navigation
if(!empty($default_presets)){
if(!isset($def[$key]['settings'])) $def[$key]['settings'] = array();
if(!isset($def[$key]['settings']['presets'])) $def[$key]['settings']['presets'] = array();
foreach($default_presets as $id => $v){
if($id !== $def[$key]['id']) continue;
if(!empty($v)){
foreach($v as $pr_v){
if($this->get_val($pr_v, 'type') !== $def[$key]['type']) continue;
$def[$key]['settings']['presets'][$this->get_val($pr_v, 'name')] = array(
'name' => $this->get_val($pr_v, 'name'),
'values' => $this->get_val($pr_v, 'values')
);
}
}
}
}
}
}
$navigations = array_merge($navigations, $def);
}
}
foreach($navigations as $key => $nav){
//check if this is the v6 version
if(version_compare($this->get_val($navigations[$key], array('settings', 'version'), false), $this->version, '>=')){
//we are v6, push settings to root
$navigations[$key]['dim'] = $this->get_val($navigations[$key], array('settings', 'dim'), false);
$navigations[$key]['placeholders'] = $this->get_val($navigations[$key], array('settings', 'placeholders'), false);
$navigations[$key]['presets'] = $this->get_val($navigations[$key], array('settings', 'presets'), false);
$navigations[$key]['version'] = $this->get_val($navigations[$key], array('settings', 'version'), false);
unset($navigations[$key]['settings']);
}
}
return $navigations;
}
/**
* Creates / Updates Navigation skins
* @since: 5.0
**/
public function create_update_full_navigation($data){
global $wpdb;
if(!empty($data) && is_array($data)){
$navigations = $this->get_all_navigations(false);
foreach($data as $vals){
$found = false;
if(!isset($vals['markup']) || !isset($vals['css'])) continue;
if($this->get_val($vals, 'factory', false) == 'true') continue; //defaults can't be deleted
if(isset($vals['id'])){ //new will be added temporary to navs to tell here that they are new
foreach($navigations as $nav){
if($vals['id'] == $nav['id']){
$found = true;
break;
}
}
}
if($found == true){ //update
$this->create_update_navigation($vals, $vals['id']);
}else{ //create
$this->create_update_navigation($vals);
}
}
}
return true;
}
/**
* Creates / Updates Navigation skins
* @since: 5.0
**/
public function create_update_navigation($data, $nav_id = 0){
global $wpdb;
if($this->get_val($data, 'factory', false) == 'true') return false;
$data['settings'] = array(
'dim' => $this->get_val($data, 'dim'),
'placeholders' => $this->get_val($data, 'placeholders'),
'presets' => $this->get_val($data, 'presets'),
'version' => $this->version
);
$nav_id = intval($nav_id);
if($nav_id > 0){
$response = $wpdb->update(
$wpdb->prefix.RevSliderFront::TABLE_NAVIGATIONS,
array(
'name' => $this->get_val($data, 'name'),
'handle' => $this->get_val($data, 'handle'),
'markup' => $this->get_val($data, 'markup'),
'css' => $this->get_val($data, 'css'),
'settings' => json_encode($this->get_val($data, 'settings'))
),
array('id' => $nav_id)
);
}else{
$response = $wpdb->insert(
$wpdb->prefix.RevSliderFront::TABLE_NAVIGATIONS,
array(
'name' => $this->get_val($data, 'name'),
'handle' => $this->get_val($data, 'handle'),
'type' => $this->get_val($data, 'type'),
'css' => $this->get_val($data, 'css'),
'markup' => $this->get_val($data, 'markup'),
'settings' => json_encode($this->get_val($data, 'settings'))
)
);
}
return $response;
}
/**
* Delete Navigation
* @since: 5.0
**/
public function delete_navigation($nav_id = 0){
global $wpdb;
if(!isset($nav_id) || intval($nav_id) == 0) return __('Invalid ID', 'revslider');
$response = $wpdb->delete($wpdb->prefix.RevSliderFront::TABLE_NAVIGATIONS, array('id' => $nav_id));
if($response === false) return __('Navigation could not be deleted', 'revslider');
return true;
}
/**
* Get Default Navigation
* @since: 5.0
**/
public static function get_default_navigations(){
$navigations = array();
include(RS_PLUGIN_PATH.'includes/navigations.php');
return apply_filters('revslider_mod_default_navigations', $navigations);
}
/**
* Translate Navigation for backwards compatibility
* @since: 5.0
**/
public static function translate_navigation($handle){
$translation = array(
'round' => 'hesperiden',
'navbar' => 'gyges',
'preview1' => 'hades',
'preview2' => 'ares',
'preview3' => 'hebe',
'preview4' => 'hermes',
'custom' => 'custom',
'round-old' => 'hephaistos',
'square-old' => 'persephone',
'navbar-old' => 'erinyen'
);
return (isset($translation[$handle])) ? $translation[$handle] : $handle;
}
/**
* Check if given Navigation is custom, if yes, export it
* @since: 5.1.1
**/
public function export_navigation($nav_handle){
$navs = self::get_all_navigations(false, true);
if(!is_array($nav_handle)) $nav_handle = array($nav_handle => true);
$entries = array();
if(!empty($nav_handle) && !empty($navs)){
foreach($nav_handle as $nav_id => $u){
foreach($navs as $n => $v){
//if($v['handle'] == $nav_id){
if($v['id'] == $nav_id){
$entries[$nav_id] = $navs[$n];
break;
}
}
}
if(!empty($entries)) return $entries;
}
return false;
}
/**
* Check the CSS for placeholders, replace them with correspinding values
* @since: 5.2.0
**/
public function add_placeholder_modifications($def_navi, $slider, $output){
if(!is_array($def_navi)) $def_navi = json_decode($def_navi, true);
$css = $this->get_val($def_navi, 'css');
$type = $this->get_val($def_navi, 'type');
$handle = $this->get_val($def_navi, 'handle');
if(!in_array($type, array('arrows', 'bullets', 'thumbs', 'tabs'))) return $css;
$placeholders = $this->get_val($def_navi, 'placeholders', array());
if(is_array($placeholders) && !empty($placeholders)){
foreach($placeholders as $phandle => $ph){
$def = $slider->get_param(array('nav', $type, 'presets', $phandle.'-def'), false);
$replace = ($def === true) ? $slider->get_param(array('nav', $type, 'presets', $phandle), $ph['data']) : $ph['data'];
$css = str_replace('##'.$phandle.'##', $replace, $css);
}
$css = str_replace('.'.$handle, '#'.$output->get_html_id().'_wrapper .'.$handle, $css);
}
return $css;
}
/**
* change rgb, rgba and hex to rgba like 120,130,50,0.5 (no () and rgb/rgba)
* @since: 3.0.0
**/
public static function parse_css_to_array($css){
while(strpos($css, '/*') !== false){
if(strpos($css, '*/') === false) return false;
$start = strpos($css, '/*');
$end = strpos($css, '*/') + 2;
$css = str_replace(substr($css, $start, $end - $start), '', $css);
}
//preg_match_all( '/(?ims)([a-z0-9\s\.\:#_\-@]+)\{([^\}]*)\}/', $css, $arr);
preg_match_all( '/(?ims)([a-z0-9\,\s\.\:#_\-@]+)\{([^\}]*)\}/', $css, $arr);
$result = array();
foreach ($arr[0] as $i => $x){
$selector = trim($arr[1][$i]);
if(strpos($selector, '{') !== false || strpos($selector, '}') !== false) return false;
$rules = explode(';', trim($arr[2][$i]));
$result[$selector] = array();
foreach ($rules as $strRule){
if (!empty($strRule)){
$rule = explode(':', $strRule);
if(strpos($rule[0], '{') !== false || strpos($rule[0], '}') !== false || strpos($rule[1], '{') !== false || strpos($rule[1], '}') !== false) return false;
//put back everything but not $rule[0];
$key = trim($rule[0]);
unset($rule[0]);
$values = implode(':', $rule);
$result[$selector][trim($key)] = trim(str_replace("'", '"', $values));
}
}
}
return $result;
}
/**
* Check the CSS for placeholders, replace them with correspinding values
* @since: x.x.x
**/
public function add_placeholder_sub_modifications($css, $handle, $type, $placeholders, $slide, $output){
$css_class = new RevSliderCssParser();
$c_css = '';
if(!is_array($placeholders)) $placeholders = json_decode($placeholders, true);
if(isset($placeholders) && is_array($placeholders) && !empty($placeholders)){
//first check for media queries, generate more than one staple
$marr = $css_class->parse_media_blocks($css);
if(!empty($marr)){//handle them separated
foreach($marr as $media => $mr){
$css = str_replace($mr, '', $css);
//clean @media query from $mr
$mr = $css_class->clear_media_block($mr);
//remove media query and bracket
$d = $css_class->css_to_array($mr);
$ret = $this->preset_return_array_css($d, $placeholders, $slide, $handle, $type, $output);
if(trim($ret) !== ''){
$c_css .= "\n".$media.' {'."\n";
$c_css .= $ret;
$c_css .= "\n".'}'."\n";
}
}
}
$c = $css_class->css_to_array($css);
$c_css .= $this->preset_return_array_css($c, $placeholders, $slide, $handle, $type, $output);
}
return $c_css;
}
/**
* Returns Array CSS modifications
* @since: 5.2.0
**/
public function preset_return_array_css($c, $placeholders, $slide, $handle, $type, $output){
$c_css = '';
$array_css = array();
if(!empty($c)){
if(!empty($placeholders)){
foreach($placeholders as $k => $d){
if($slide->get_param(array('nav', $type, 'presets', $k.'-def'), false) === true){ //get from Slide
foreach($c as $class => $styles){
foreach($styles as $name => $val){
if(strpos($val, '##'.$k.'##') !== false){
$e = $slide->get_param(array('nav', $type, 'presets', $k));
$array_css[$class][$name] = str_replace('##'.$k.'##', $e, $val);
}
}
}
}
}
}
if(!empty($array_css)){
foreach($array_css as $class => $styles){
if(!empty($styles)){
//class needs to get current slider and slide id
$slide_id = $slide->get_id();
$class = str_replace('.'.$handle, '#'.$output->get_html_id().'[data-slideactive="rs-'.$slide_id.'"] .'.$handle, $class);
$c_css .= $class.'{'."\n";
foreach($styles as $style => $value){
//check if there are still defaults that needs to be replaced
if(strpos($value, '##') !== false){
foreach($placeholders as $k => $d){
if(strpos($value, '##'.$k.'##') !== false){
$value = str_replace('##'.$k.'##', $d['data'], $value);
}
}
}
$c_css .= $style.': '.$value.' !important;'."\n";
}
$c_css .= '}'."\n";
}
}
}
}
return $c_css;
}
/**
* Add Navigation Preset to existing navigation
* @since: 5.2.0
**/
public function add_preset($data){
if(!isset($data['navigation'])) return false;
$navs = $this->get_all_navigations();
foreach($navs as $nav){
if($nav['id'] == $data['navigation']){ //found the navigation, get ID and update settings
//check if default, they cant have presets in the table
if(isset($nav['factory']) && $nav['factory'] == true){
//check if we are a default preset, if yes return error
if(isset($nav['presets'])){
foreach($nav['presets'] as $prkey => $preset){
if($prkey == $data['handle']){
if(!isset($preset['editable'])){
return __("Can't modify a default preset of default navigations", 'revslider');
}
}
}
}
//we want to add the preset somewhere
$overwrite = false;
$default_presets = get_option('revslider-nav-preset-default', array());
if(!empty($default_presets) && isset($default_presets[$nav['id']])){
foreach($default_presets[$nav['id']] as $prkey => $preset){
if($prkey == $data['handle']){
if($data['do_overwrite'] === false || $data['do_overwrite'] === 'false'){
return __('Preset handle already exists, please choose a different name', 'revslider');
}
$default_presets[$nav['id']][$prkey] = array(
'name' => esc_attr($data['name']),
//'handle' => esc_attr($data['handle']),
'type' => esc_attr($data['type']),
'values' => $data['values'],
'editable' => true
);
$overwrite = true;
}
}
}/*else{
$default_presets = array();
}*/
if($overwrite === false){
$default_presets[$nav['id']][$data['handle']] = array(
'name' => esc_attr($data['name']),
//'handle' => esc_attr($data['handle']),
'type' => esc_attr($data['type']),
'values' => $data['values'],
'editable' => true
);
}
update_option('revslider-nav-preset-default', $default_presets);
//return __('Can\'t add a preset to default navigations', 'revslider');
}else{
$overwrite = false;
if(isset($nav['presets']) && is_array($nav['presets']) && !empty($nav['presets'])){
foreach($nav['presets'] as $prkey => $preset){
if($prkey == $data['handle']){
if($data['do_overwrite'] === false || $data['do_overwrite'] === 'false'){
return __('Preset handle already exists, please choose a different name', 'revslider');
}
$nav['presets'][$prkey] = array(
'name' => esc_attr($data['name']),
//'handle' => esc_attr($data['handle']),
'type' => esc_attr($data['type']),
'values' => $data['values']
);
$overwrite = true;
}
}
}else{
$nav['presets'] = array();
}
if($overwrite === false){
$nav['presets'][$data['handle']] = array(
'name' => esc_attr($data['name']),
//'handle' => esc_attr($data['handle']),
'type' => esc_attr($data['type']),
'values' => $data['values']
);
}
$placeholders = $this->get_val($nav, 'placeholders');
if(!empty($placeholders)){
foreach($placeholders as $k => $pl){
if(isset($pl['data'])){
$placeholders[$k]['data'] = addslashes($pl['data']);
}
}
}
global $wpdb;
//save this navigation
$response = $wpdb->update(
$wpdb->prefix.RevSliderFront::TABLE_NAVIGATIONS,
array(
'settings' => json_encode(
array(
'dim' => $this->get_val($nav, 'dim'),
'placeholders' => $placeholders,
'presets' => $this->get_val($nav, 'presets'),
'version' => $this->version
)
)
),
array('id' => $nav['id'])
);
if($response == 0) $response = false;
}
return true;
}
}
return __('Navigation not found, could not add preset', 'revslider');
}
/**
* Add Navigation Preset to existing navigation
* @since: 5.2.0
**/
public function delete_preset($data){
if(!isset($data['style_handle']) || !isset($data['handle']) || !isset($data['type'])) return false;
$navs = $this->get_all_navigations();
foreach($navs as $nav){
if($nav['id'] != $data['style_handle']) continue;
if($nav['type'] != $data['type']) continue;
//found the navigation, get ID and update settings
//check if default, they cant have presets
if(isset($nav['factory']) && $nav['factory'] == true){
$default_presets = get_option('revslider-nav-preset-default', array());
if(!empty($default_presets) && isset($default_presets[$nav['id']])){
foreach($default_presets[$nav['id']] as $prkey => $preset){
if($preset['name'] == $data['handle']){
unset($default_presets[$nav['id']][$prkey]);
update_option('revslider-nav-preset-default', $default_presets);
return true;
}
}
return __('Can\'t delete default preset of default navigations', 'revslider');
}
return __('Preset not found in default navigations', 'revslider');
}else{
if(isset($nav['presets'])){
foreach($nav['presets'] as $pkey => $preset){
if($preset['handle'] == $data['handle']){
//delete
unset($nav['presets'][$pkey]);
break;
}
}
}else{
return __('Preset not found', 'revslider');
}
global $wpdb;
//save this navigation
$response = $wpdb->update(
$wpdb->prefix.RevSliderFront::TABLE_NAVIGATIONS,
array(
'settings' => json_encode(
array(
'dim' => $this->get_val($nav, 'dim'),
'placeholders' => $this->get_val($nav, 'placeholders'),
'presets' => $this->get_val($nav, 'presets'),
'version' => $this->version
)
)
),
array('id' => $nav['id'])
);
return $response;
}
}
return __('Navigation not found, could not delete preset', 'revslider');
}
}
?>

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,174 @@
<?php
/**
* @author ThemePunch <info@themepunch.com>
* @link https://www.themepunch.com/
* @copyright 2019 ThemePunch
*/
if( !defined( 'ABSPATH') ) exit();
class RevSliderPageTemplate {
/**
* A reference to an instance of this class.
*/
private static $instance;
/**
* The array of templates that this plugin tracks.
*/
protected $templates;
/**
* Returns an instance of this class.
*/
public static function get_instance() {
if( null == self::$instance ) {
self::$instance = new RevSliderPageTemplate();
}
return self::$instance;
}
/**
* Initializes the plugin by setting filters and administration functions.
*/
private function __construct() {
$this->templates = array();
// Add a filter to the attributes metabox to inject template into the cache.
add_filter(
'page_attributes_dropdown_pages_args',
array( $this, 'register_project_templates' )
);
// Add a filter to the save post to inject out template into the page cache
add_filter(
'wp_insert_post_data',
array( $this, 'register_project_templates' )
);
// Add a filter to the template include to determine if the page has our
// template assigned and return it's path
add_filter(
'template_include',
array( $this, 'view_project_template')
);
// Add your templates to this array.
$this->templates = array(
'../public/views/revslider-page-template.php' => 'Slider Revolution Blank Template',
);
// Fix for WP 4.7
add_filter( 'theme_page_templates', array($this, 'register_project_templates_new' ) );
// Add filters to the attributes metabox to inject templates to all posts
$types = get_post_types( [], 'objects' );
foreach ( $types as $type => $values ) {
if ( isset( $type ) ) {
$type_name = 'theme_' . $type . '_templates';
add_filter( $type_name , array( $this, 'add_post_templates' ));
}
}
}
// Adds our template to the new post templates setting (WP >= 4.7)
public function register_project_templates_new( $post_templates ) {
$post_templates = array_merge( $post_templates, $this->templates );
return $post_templates;
}
public function add_post_templates( $templates ) {
$my_virtual_templates = array(
'../public/views/revslider-page-template.php' => 'Slider Revolution Blank Template',
);
// Merge with any templates already available
$templates = array_merge( $templates, $my_virtual_templates );
return $templates;
}
/**
* Adds our template to the pages cache in order to trick WordPress
* into thinking the template file exists where it doens't really exist.
*
*/
public function register_project_templates( $atts ) {
// Create the key used for the themes cache
$cache_key = 'page_templates-' . md5( get_theme_root() . '/' . get_stylesheet() );
// Retrieve the cache list.
// If it doesn't exist, or it's empty prepare an array
$templates = wp_get_theme()->get_page_templates();
if ( empty( $templates ) ) {
$templates = array();
}
// New cache, therefore remove the old one
wp_cache_delete( $cache_key , 'themes');
// Now add our template to the list of templates by merging our templates
// with the existing templates array from the cache.
$templates = array_merge( $templates, $this->templates );
// Add the modified cache to allow WordPress to pick it up for listing
// available templates
wp_cache_add( $cache_key, $templates, 'themes', 1800 );
return $atts;
}
/**
* Checks if the template is assigned to the page
*/
public function view_project_template( $template ) {
global $post;
if(!isset($post->ID)) return $template;
if (!isset($this->templates[get_post_meta(
$post->ID, '_wp_page_template', true
)] ) ) {
return $template;
}
$file = plugin_dir_path(__FILE__). get_post_meta(
$post->ID, '_wp_page_template', true
);
// Just to be safe, we check if the file exist first
if( file_exists( $file ) ) {
return $file;
}
else { echo $file; }
return $template;
}
}
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,203 @@
<?php
/**
* @author ThemePunch <info@themepunch.com>
* @link https://www.themepunch.com/
* @copyright 2019 ThemePunch
*/
if(!defined('ABSPATH')) exit();
class RevSliderUpdate {
private $plugin_url = 'https://www.themepunch.com/links/slider_revolution_wordpress';
private $remote_url = 'check_for_updates.php';
private $remote_url_info = 'revslider/revslider.php';
private $plugin_slug = 'revslider';
private $version;
private $plugins;
private $option;
public $force = false;
public function __construct($version){
$this->option = $this->plugin_slug . '_update_info';
$this->_retrieve_version_info();
$this->version = $version;
}
public function add_update_checks(){
if($this->force === true){
ini_set('max_execution_time', 300); //an update can follow, so set the execution time high for the runtime
$transient = get_site_transient('update_plugins');
$rs_t = $this->set_update_transient($transient);
if(!empty($rs_t)){
set_site_transient('update_plugins', $rs_t);
}
}
add_filter('pre_set_site_transient_update_plugins', array(&$this, 'set_update_transient'));
add_filter('plugins_api', array(&$this, 'set_updates_api_results'), 10, 3);
}
public function set_update_transient($transient){
$this->_check_updates();
if(isset($transient) && !isset($transient->response)){
$transient->response = array();
}
if(!empty($this->data->basic) && is_object($this->data->basic)){
if(version_compare($this->version, $this->data->basic->version, '<')){
$this->data->basic->new_version = $this->data->basic->version;
$transient->response[RS_PLUGIN_SLUG_PATH] = $this->data->basic;
}
}
return $transient;
}
public function set_updates_api_results($result, $action, $args){
$this->_check_updates();
if(isset($args->slug) && $args->slug == $this->plugin_slug && $action == 'plugin_information'){
if(is_object($this->data->full) && !empty($this->data->full)){
$result = $this->data->full;
}
}
return $result;
}
public function _check_updates(){
// Get data
if(empty($this->data)){
$data = get_option($this->option, false);
$data = $data ? $data : new stdClass;
$this->data = is_object($data) ? $data : maybe_unserialize($data);
}
$last_check = get_option('revslider-update-check');
if($last_check == false){ //first time called
$last_check = time() - 172802;
update_option('revslider-update-check', $last_check);
}
// Check for updates
if(time() - $last_check > 172800 || $this->force == true){
$data = $this->_retrieve_update_info();
if(isset($data->basic)) {
update_option('revslider-update-check', time());
$this->data->checked = time();
$this->data->basic = $data->basic;
$this->data->full = $data->full;
update_option('revslider-stable-version', $data->full->stable);
update_option('revslider-latest-version', $data->full->version);
}
}
// Save results
update_option($this->option, $this->data);
}
public function _retrieve_update_info(){
$rslb = new RevSliderLoadBalancer();
$data = new stdClass;
// Build request
$rattr = array(
'code' => urlencode(get_option('revslider-code', '')),
'version' => urlencode(RS_REVISION)
);
if(get_option('revslider-valid', 'false') !== 'true' && version_compare(RS_REVISION, get_option('revslider-stable-version', '4.2'), '<')){ //We'll get the last stable only now!
$rattr['get_stable'] = 'true';
}
$request = $rslb->call_url($this->remote_url_info, $rattr, 'updates');
if(!is_wp_error($request)){
if($response = maybe_unserialize($request['body'])){
if(is_object($response)){
$data = $response;
$data->basic->url = $this->plugin_url;
$data->full->url = $this->plugin_url;
$data->full->external = 1;
}
}
}
return $data;
}
public function _retrieve_version_info(){
$rslb = new RevSliderLoadBalancer();
$last_check = get_option('revslider-update-check-short');
// Check for updates
if($last_check == false || time() - $last_check > 172800 || $this->force == true){
update_option('revslider-update-check-short', time());
$hash = ($this->force === true) ? '' : get_option('revslider-update-hash', '');
$purchase = (get_option('revslider-valid', 'false') == 'true') ? get_option('revslider-code', '') : '';
$data = array(
'version' => urlencode(RS_REVISION),
'item' => urlencode(RS_PLUGIN_SLUG),
'hash' => urlencode($hash),
'code' => urlencode($purchase)
);
$request = $rslb->call_url($this->remote_url, $data, 'updates');
$version_info = wp_remote_retrieve_body($request);
if(wp_remote_retrieve_response_code($request) != 200 || is_wp_error($version_info)){
update_option('revslider-connection', false);
return false;
}else{
update_option('revslider-connection', true);
}
if('actual' != $version_info){
$version_info = json_decode($version_info);
if(isset($version_info->hash)) update_option('revslider-update-hash', $version_info->hash);
if(isset($version_info->version)) update_option('revslider-latest-version', $version_info->version);
if(isset($version_info->stable)) update_option('revslider-stable-version', $version_info->stable);
if(isset($version_info->notices)) update_option('revslider-notices', $version_info->notices);
if(isset($version_info->addons)) update_option('revslider-addons', $version_info->addons);
if(isset($version_info->deactivated) && $version_info->deactivated === true){
if(get_option('revslider-valid', 'false') == 'true'){
//remove validation, add notice
update_option('revslider-valid', 'false');
update_option('revslider-deact-notice', true);
}
}
}
}
//force that the update will be directly searched
if($this->force == true) update_option('revslider-update-check', '');
return get_option('revslider-latest-version', RS_REVISION);
}
}
/**
* old classname extends new one (old classnames will be obsolete soon)
* @since: 5.0
**/
class UniteUpdateClassRev extends RevSliderUpdate {}
?>

View File

@@ -0,0 +1,142 @@
<?php
/**
* @author ThemePunch <info@themepunch.com>
* @link https://www.themepunch.com/
* @copyright 2019 ThemePunch
*/
if(!defined('ABSPATH')) exit();
class RevSliderWooCommerce extends RevSliderFunctions {
const META_SKU = '_sku'; //can be 'instock' or 'outofstock'
const META_STOCK = '_stock'; //can be 'instock' or 'outofstock'
/**
* return true / false if the woo commerce exists
* @before RevSliderWooCommerce::isWooCommerceExists();
*/
public static function woo_exists(){
return (class_exists('Woocommerce')) ? true : false;
}
/**
* compare wc current version to given version
*/
public static function version_check($version = '1.0') {
if(self::woo_exists()){
global $woocommerce;
if(version_compare($woocommerce->version, $version, '>=')){
return true;
}
}
return false;
}
/**
* get wc post types
*/
public static function getCustomPostTypes(){
$arr = array(
'product' => __('Product', 'revslider'),
'product_variation' => __('Product Variation', 'revslider')
);
return $arr;
}
/**
* get price query
* @before: RevSliderWooCommerce::getPriceQuery()
*/
private static function get_price_query($from, $to, $meta_tag){
$from = (empty($from)) ? 0 : $from;
$to = (empty($to)) ? 9999999999 : $to;
$query = array(
'key' => $meta_tag,
'value' => array($from, $to),
'type' => 'numeric',
'compare' => 'BETWEEN'
);
return $query;
}
/**
* get meta query for filtering woocommerce posts.
* before: RevSliderWooCommerce::getMetaQuery();
*/
public static function get_meta_query($args){
$f = new RevSliderFunctions();
$reg_price_from = $f->get_val($args, array('source', 'woo', 'regPriceFrom'));
$reg_price_to = $f->get_val($args, array('source', 'woo', 'regPriceTo'));
$sale_price_from = $f->get_val($args, array('source', 'woo', 'salePriceFrom'));
$sale_price_to = $f->get_val($args, array('source', 'woo', 'salePriceTo'));
$query = array();
$meta_query = array();
$tax_query = array();
//get regular price array
if(!empty($reg_price_from) || !empty($reg_price_to)){
$meta_query[] = self::get_price_query($reg_price_from, $reg_price_to, '_regular_price');
}
//get sale price array
if(!empty($sale_price_from) || !empty($sale_price_to)){
$meta_query[] = self::get_price_query($sale_price_from, $sale_price_to, '_sale_price');
}
if($f->get_val($args, array('source', 'woo', 'inStockOnly')) == true){
$meta_query[] = array(
'key' => '_stock_status',
'value' => 'instock',
'compare' => '='
);
}
if($f->get_val($args, array('source', 'woo', 'featuredOnly')) == true){
$tax_query[] = array(
'taxonomy' => 'product_visibility',
'field' => 'name',
'terms' => 'featured',
);
}
if(!empty($meta_query)){
$query['meta_query'] = $meta_query;
}
if(!empty($tax_query)){
$query['tax_query'] = $tax_query;
}
return $query;
}
/**
* get sortby function including standart wp sortby array
*/
public static function getArrSortBy(){
$sort_by = array(
'meta_num__regular_price' => __('Regular Price', 'revslider'),
'meta_num__sale_price' => __('Sale Price', 'revslider'),
'meta_num_total_sales' => __('Number Of Sales', 'revslider'),
'meta__featured' => __('Featured Products', 'revslider'),
'meta__sku' => __('SKU', 'revslider'),
'meta_num_stock' => __('Stock Quantity', 'revslider')
);
return $sort_by;
}
} //end of the class
?>

View File

@@ -0,0 +1,230 @@
<?php
/**
* @author ThemePunch <info@themepunch.com>
* @link https://www.themepunch.com/
* @copyright 2019 ThemePunch
*/
if(!defined('ABSPATH')) exit();
class RevSliderWpml extends RevSliderFunctions {
private $cur_lang;
/**
* load the wpml filters ect.
**/
public function __construct(){
add_filter('revslider_get_posts_by_category', array($this, 'translate_category_lang'), 10, 2);
add_filter('revslider_get_parent_slides_pre', array($this, 'change_lang'), 10, 4);
add_filter('revslider_get_parent_slides_post', array($this, 'change_lang_to_orig'), 10, 4);
add_action('revslider_header_content', array($this, 'add_javascript_language'));
}
/**
* true / false if the wpml plugin exists
*/
public function wpml_exists(){
return did_action('wpml_loaded');
}
/**
* valdiate that wpml exists
*/
public function validateWpmlExists(){
if(!$this->wpml_exists()){
$this->throw_error(__('The WPML plugin is not activated', 'revslider'));
}
}
/**
* get languages array
*/
public function getArrLanguages($get_all = true){
$this->validateWpmlExists();
$langs = apply_filters('wpml_active_languages', array());
$response = array();
if($get_all == true){
$response['all'] = __('All Languages', 'revslider');
}
foreach($langs as $code => $lang){
$name = $lang['native_name'];
$response[$code] = $name;
}
return $response;
}
/**
* get assoc array of lang codes
*/
public function getArrLangCodes($get_all = true){
$codes = array();
if($get_all == true){
$codes['all'] = 'all';
}
$this->validateWpmlExists();
$langs = apply_filters('wpml_active_languages', array());
foreach($langs as $code => $arr){
$codes[$code] = $code;
}
return $codes;
}
/**
* check if all languages exists in the given langs array
*/
public function isAllLangsInArray($codes){
$all_codes = $this->getArrLangCodes();
$diff = array_diff($all_codes, $codes);
return empty($diff);
}
/**
* get flag url
*/
public function getFlagUrl($code){
$this->validateWpmlExists();
if(empty($code) || $code == 'all'){
//$url = RS_PLUGIN_URL.'admin/assets/images/icon-all.png'; // NEW: ICL_PLUGIN_URL . '/res/img/icon16.png';
$url = ICL_PLUGIN_URL . '/res/img/icon16.png';
}else{
$active_languages = apply_filters('wpml_active_languages', array());
$url = isset($active_languages[$code]['country_flag_url']) ? $active_languages[$code]['country_flag_url'] : null;
}
//default: show all
if(empty($url)){
//$url = RS_PLUGIN_URL.'admin/assets/images/icon-all.png';
$url = ICL_PLUGIN_URL . '/res/img/icon16.png';
}
return $url;
}
/**
* get language title by code
*/
public function getLangTitle($code){
if($code == 'all'){
return(__('All Languages', 'revslider'));
}else{
$def = apply_filters('wpml_default_language', null);
return apply_filters('wpml_translated_language_name', '', $code, $def);
}
}
/**
* get current language
*/
public function getCurrentLang(){
$this->validateWpmlExists();
return (is_admin()) ? apply_filters('wpml_default_language', null) : apply_filters('wpml_current_language', null);
}
/**
* was before in RevSliderFunctions::get_posts_by_category();
**/
public function translate_category_lang($data, $type){
$cat_id = $this->get_val($data, 'cat_id');
$cat_id = (strpos($cat_id, ',') !== false) ? explode(',', $cat_id) : array($cat_id);
if($this->wpml_exists()){ //translate categories to languages
$newcat = array();
foreach($cat_id as $id){
$newcat[] = apply_filters('wpml_object_id', $id, 'category', true);
}
$data['cat_id'] = implode(',', $newcat);
}
return $data;
}
/**
* switch the language if WPML is used in Slider
**/
public function change_lang($lang, $published, $gal_ids, $slider){
if($this->wpml_exists() && $slider->get_param('use_wpml', 'off') == 'on'){
$this->cur_lang = apply_filters('wpml_current_language', null);
do_action('wpml_switch_language', $lang);
}
}
/**
* switch the language back to original, if WPML is used in Slider
**/
public function change_lang_to_orig($lang, $published, $gal_ids, $slider){
if($this->wpml_exists() && $slider->get_param(array('general', 'useWPML'), false) == true){ //switch language back
do_action('wpml_switch_language', $this->cur_lang);
}
}
/**
* modify slider language
* @before: RevSliderOutput::setLang()
*/
public function get_language($use_wpml, $slider){
$lang = ($this->wpml_exists() && $use_wpml == true) ? ICL_LANGUAGE_CODE : 'all';
return $lang;
}
public function get_slider_language($slider){
$use_wmpl = $slider->get_param(array('general', 'useWPML'), false);
return $this->get_language($use_wmpl, $slider);
}
/**
* add languages as javascript object to the RevSlider BackEnd Header
**/
public function add_javascript_language($rsad){
if(!$this->wpml_exists()) return '';
$langs = $this->getArrLanguages();
$use_langs = array();
foreach($langs as $code => $lang){
$use_langs[$code] = array(
'title' => $lang,
'image' => $this->getFlagUrl($code)
);
}
echo '<script type="text/javascript">';
echo 'var RS_WPML_LANGS = jQuery.parseJSON(\''.json_encode($use_langs).'\');';
echo '</script>';
}
}
$rs_wmpl = new RevSliderWpml();
/**
* old classname extends new one (old classnames will be obsolete soon)
* @since: 5.0
**/
class UniteWpmlRev extends RevSliderWpml {}
?>