Import legacy nurinda.co.id website

This commit is contained in:
dirga committed 2026-10-01 14:27:19 +07:00
1 parent 3f59bb9038
commit 6e21646ac4
13389 files changed
+3246690

No files matched your search

@@ -0,0 +1,278 @@
<?php
/**
* The admin-specific functionality of the plugin.
*
* @link h
* @since 1.0.0
*
* @package Rev_addon
* @subpackage Rev_addon/admin
*/
/**
* The admin-specific functionality of the plugin.
*
* Defines the plugin name, version, and two examples hooks for how to
* enqueue the admin-specific stylesheet and JavaScript.
*
* @package Rev_addon
* @subpackage Rev_addon/admin
* @author ThemePunch <info@themepunch.com>
*/
class Rev_addon_Admin {
/**
* The ID of this plugin.
*
* @since 1.0.0
* @access private
* @var string $plugin_name The ID of this plugin.
*/
private $plugin_name;
/**
* The version of this plugin.
*
* @since 1.0.0
* @access private
* @var string $version The current version of this plugin.
*/
private $version;
/**
* Initialize the class and set its properties.
*
* @since 1.0.0
* @param string $plugin_name The name of this plugin.
* @param string $version The version of this plugin.
*/
public function __construct( $plugin_name, $version ) {
$this->plugin_name = $plugin_name;
$this->version = $version;
}
/**
* Register the stylesheets for the admin area.
*
* @since 1.0.0
*/
public function enqueue_styles() {
/**
* This function is provided for demonstration purposes only.
*
* An instance of this class should be passed to the run() function
* defined in Rev_addon_Loader as all of the hooks are defined
* in that particular class.
*
* The Rev_addon_Loader will then create the relationship
* between the defined hooks and the functions defined in this
* class.
*/
if(isset($_GET["page"]) && $_GET["page"]=="rev_addon"){
wp_enqueue_style('rs-plugin-settings', RS_PLUGIN_URL .'admin/assets/css/admin.css', array(), RevSliderGlobals::SLIDER_REVISION);
wp_enqueue_style( $this->plugin_name, RS_PLUGIN_URL . 'admin/assets/css/rev_addon-admin.css', array( ), $this->version);
}
}
/**
* Register the JavaScript for the admin area.
*
* @since 1.0.0
*/
public function enqueue_scripts() {
/**
* This function is provided for demonstration purposes only.
*
* An instance of this class should be passed to the run() function
* defined in Rev_addon_Loader as all of the hooks are defined
* in that particular class.
*
* The Rev_addon_Loader will then create the relationship
* between the defined hooks and the functions defined in this
* class.
*/
if(isset($_GET["page"]) && $_GET["page"]=="rev_addon"){
wp_enqueue_script('tp-tools', RS_PLUGIN_URL .'public/assets/js/jquery.themepunch.tools.min.js', array(), RevSliderGlobals::SLIDER_REVISION );
wp_enqueue_script('unite_admin', RS_PLUGIN_URL .'admin/assets/js/admin.js', array(), RevSliderGlobals::SLIDER_REVISION );
wp_enqueue_script( $this->plugin_name, RS_PLUGIN_URL .'admin/assets/js/rev_addon-admin.js', array( 'jquery' ), $this->version, false );
wp_localize_script( $this->plugin_name, 'rev_slider_addon', array(
'ajax_url' => admin_url( 'admin-ajax.php' ),
'please_wait_a_moment' => __("Please Wait a Moment",'revslider'),
'settings_saved' => __("Settings saved",'revslider')
));
}
}
/**
* Register the administration menu for this plugin into the WordPress Dashboard menu.
*
* @since 1.0.0
*/
public function add_plugin_admin_menu() {
$this->plugin_screen_hook_suffix = add_submenu_page(
'revslider',
__( 'Add-Ons', 'revslider' ),
__( 'Add-Ons', 'revslider' ),
'manage_options',
$this->plugin_name,
array( $this, 'display_plugin_admin_page' )
);
}
/**
* Render the settings page for this plugin.
*
* @since 1.0.0
*/
public function display_plugin_admin_page() {
include_once( RS_PLUGIN_PATH.'admin/views/rev_addon-admin-display.php' );
}
/**
* Activates Installed Add-On/Plugin
*
* @since 1.0.0
*/
public function activate_plugin() {
// Verify that the incoming request is coming with the security nonce
if( wp_verify_nonce( $_REQUEST['nonce'], 'ajax_rev_slider_addon_nonce' ) ) {
if(isset($_REQUEST['plugin'])){
//update_option( "rev_slider_addon_gal_default", sanitize_text_field($_REQUEST['default_gallery']) );
$result = activate_plugin( $_REQUEST['plugin'] );
if ( is_wp_error( $result ) ) {
// Process Error
die('0');
}
die( '1' );
}
else{
die( '0' );
}
}
else {
die( '-1' );
}
}
/**
* Deactivates Installed Add-On/Plugin
*
* @since 1.0.0
*/
public function deactivate_plugin() {
// Verify that the incoming request is coming with the security nonce
if( wp_verify_nonce( $_REQUEST['nonce'], 'ajax_rev_slider_addon_nonce' ) ) {
if(isset($_REQUEST['plugin'])){
//update_option( "rev_slider_addon_gal_default", sanitize_text_field($_REQUEST['default_gallery']) );
$result = deactivate_plugins( $_REQUEST['plugin'] );
if ( is_wp_error( $result ) ) {
// Process Error
die('0');
}
die( '1' );
}
else{
die( '0' );
}
}
else {
die( '-1' );
}
}
/**
* Install Add-On/Plugin
*
* @since 1.0.0
*/
public function install_plugin() {
if( wp_verify_nonce( $_REQUEST['nonce'], 'ajax_rev_slider_addon_nonce' ) ) {
if(isset($_REQUEST['plugin'])){
global $wp_version, $rslb;
$plugin_slug = basename($_REQUEST['plugin']);
$plugin_result = false;
$plugin_message = 'UNKNOWN';
if(0 !== strpos($plugin_slug, 'revslider-')) die( '-1' );
$done = false;
$count = 0;
do{
$url = $rslb->get_url('updates');
$url .= '/addons/'.$plugin_slug.'/'.$plugin_slug.'.zip';
$get = wp_remote_post($url, array(
'user-agent' => 'WordPress/'.$wp_version.'; '.get_bloginfo('url'),
'body' => '',
'timeout' => 45
));
$response_code = wp_remote_retrieve_response_code( $get );
if($response_code == 200){
$done = true;
}else{
$rslb->move_server_list();
}
$count++;
}while($done == false && $count < 5);
if( !$get || $get["response"]["code"] != "200" ){
$plugin_message = 'FAILED TO DOWNLOAD';
}else{
$plugin_message = 'ZIP is there';
$upload_dir = wp_upload_dir();
$file = $upload_dir['basedir']. '/revslider/templates/' . $plugin_slug . '.zip';
@mkdir(dirname($file));
$ret = @file_put_contents( $file, $get['body'] );
WP_Filesystem();
global $wp_filesystem;
$upload_dir = wp_upload_dir();
$d_path = WP_PLUGIN_DIR;
$unzipfile = unzip_file( $file, $d_path);
if( is_wp_error($unzipfile) ){
define('FS_METHOD', 'direct'); //lets try direct.
WP_Filesystem(); //WP_Filesystem() needs to be called again since now we use direct !
//@chmod($file, 0775);
$unzipfile = unzip_file( $file, $d_path);
if( is_wp_error($unzipfile) ){
$d_path = WP_PLUGIN_DIR;
$unzipfile = unzip_file( $file, $d_path);
if( is_wp_error($unzipfile) ){
$f = basename($file);
$d_path = str_replace($f, '', $file);
$unzipfile = unzip_file( $file, $d_path);
}
}
}
@unlink($file);
die('1');
}
//$result = activate_plugin( $plugin_slug.'/'.$plugin_slug.'.php' );
}
else{
die( '0' );
}
}
else {
die( '-1' );
}
}
} // END of class
@@ -0,0 +1,205 @@
<?php
/**
* Title : Aqua Resizer
* Description : Resizes WordPress images on the fly
* Version : 1.2.0
* 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 ) {
$aq_resize = Rev_Aq_Resize::getInstance();
return $aq_resize->process( $url, $width, $height, $crop, $single, $upscale );
}
}
?>
@@ -0,0 +1,543 @@
<?php
/**
* @author ThemePunch <info@themepunch.com>
* @link http://www.themepunch.com/
* @copyright 2015 ThemePunch
*/
if( !defined( 'ABSPATH') ) exit();
class RevSliderBaseAdmin extends RevSliderBase {
protected static $master_view;
protected static $view;
private static $arrSettings = array();
private static $arrMenuPages = array();
private static $arrSubMenuPages = array();
private static $tempVars = array();
private static $startupError = '';
private static $menuRole = 'admin';
private static $arrMetaBoxes = array(); //option boxes that will be added to post
private static $allowed_views = array('master-view', 'system/validation', 'system/dialog-video', 'system/dialog-update', 'system/dialog-global-settings', 'sliders', 'slider', 'slider_template', 'slides', 'slide', 'navigation-editor', 'slide-editor', 'slide-overview', 'slide-editor', 'slider-overview', 'themepunch-google-fonts', 'global-settings');
/**
*
* main constructor
*/
public function __construct($t){
parent::__construct($t);
//set view
self::$view = self::getGetVar("view");
if(empty(self::$view))
self::$view = 'sliders';
//add internal hook for adding a menu in arrMenus
add_action('admin_menu', array('RevSliderBaseAdmin', 'addAdminMenu'));
add_action('add_meta_boxes', array('RevSliderBaseAdmin', 'onAddMetaboxes'));
add_action('save_post', array('RevSliderBaseAdmin', 'onSavePost'));
//if not inside plugin don't continue
if($this->isInsidePlugin() == true){
add_action('admin_enqueue_scripts', array('RevSliderBaseAdmin', 'addCommonScripts'));
add_action('admin_enqueue_scripts', array('RevSliderAdmin', 'onAddScripts'));
}else{
add_action('admin_enqueue_scripts', array('RevSliderBaseAdmin', 'addGlobalScripts'));
}
//a must event for any admin. call onActivate function.
$this->addEvent_onActivate();
$this->addAction_onActivate();
self::addActionAjax('show_image', 'onShowImage');
}
/**
*
* add some meta box
* return metabox handle
*/
public static function addMetaBox($title,$content = null, $customDrawFunction = null,$location="post"){
$box = array();
$box['title'] = $title;
$box['location'] = $location;
$box['content'] = $content;
$box['draw_function'] = $customDrawFunction;
self::$arrMetaBoxes[] = $box;
}
/**
*
* on add metaboxes
*/
public static function onAddMetaboxes(){
foreach(self::$arrMetaBoxes as $index=>$box){
$title = $box['title'];
$location = $box['location'];
$boxID = 'mymetabox_revslider_'.$index;
$function = array(self::$t, "onAddMetaBoxContent");
if(is_array($location)){
foreach($location as $loc)
add_meta_box($boxID,$title,$function,$loc,'normal','default');
}else
add_meta_box($boxID,$title,$function,$location,'normal','default');
}
}
/**
*
* on save post meta. Update metaboxes data from post, add it to the post meta
*/
public static function onSavePost(){
//protection against autosave
if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ){
$postID = RevSliderFunctions::getPostVariable("ID");
return $postID;
}
$postID = RevSliderFunctions::getPostVariable("ID");
if(empty($postID))
return(false);
foreach(self::$arrMetaBoxes as $box){
$arrSettingNames = array('slide_template');
foreach($arrSettingNames as $name){
$value = RevSliderFunctions::getPostVariable($name);
update_post_meta( $postID, $name, $value );
} //end foreach settings
} //end foreach meta
}
/**
*
* on add metabox content
*/
public static function onAddMetaBoxContent($post,$boxData){
$postID = $post->ID;
$boxID = RevSliderFunctions::getVal($boxData, "id");
$index = str_replace('mymetabox_revslider_',"",$boxID);
$arrMetabox = self::$arrMetaBoxes[$index];
//draw element
$drawFunction = RevSliderFunctions::getVal($arrMetabox, "draw_function");
if(!empty($drawFunction))
call_user_func($drawFunction);
}
/**
*
* set the menu role - for viewing menus
*/
public static function setMenuRole($menuRole){
self::$menuRole = $menuRole;
}
/**
* get the menu role - for viewing menus
*/
public static function getMenuRole(){
return self::$menuRole;
}
/**
*
* set startup error to be shown in master view
*/
public static function setStartupError($errorMessage){
self::$startupError = $errorMessage;
}
/**
*
* tells if the the current plugin opened is this plugin or not
* in the admin side.
*/
private function isInsidePlugin(){
$page = self::getGetVar("page");
if($page == 'revslider' || $page == 'themepunch-google-fonts' || $page == 'revslider_navigation' || $page == 'revslider_global_settings')
return(true);
return(false);
}
/**
* add global used scripts
* @since: 5.1.1
*/
public static function addGlobalScripts(){
wp_enqueue_script(array('jquery', 'jquery-ui-core', 'jquery-ui-sortable', 'wpdialogs'));
wp_enqueue_style(array('wp-jquery-ui', 'wp-jquery-ui-dialog', 'wp-jquery-ui-core'));
}
/**
* add common used scripts
*/
public static function addCommonScripts(){
if(function_exists("wp_enqueue_media"))
wp_enqueue_media();
wp_enqueue_script(array('jquery', 'jquery-ui-core', 'jquery-ui-mouse', 'jquery-ui-accordion', 'jquery-ui-datepicker', 'jquery-ui-dialog', 'jquery-ui-slider', 'jquery-ui-autocomplete', 'jquery-ui-sortable', 'jquery-ui-droppable', 'jquery-ui-tabs', 'jquery-ui-widget', 'wp-color-picker'));
wp_enqueue_style(array('wp-jquery-ui', 'wp-jquery-ui-core', 'wp-jquery-ui-dialog', 'wp-color-picker'));
wp_enqueue_script('unite_settings', RS_PLUGIN_URL .'admin/assets/js/settings.js', array(), RevSliderGlobals::SLIDER_REVISION );
wp_enqueue_script('unite_admin', RS_PLUGIN_URL .'admin/assets/js/admin.js', array(), RevSliderGlobals::SLIDER_REVISION );
wp_enqueue_style('unite_admin', RS_PLUGIN_URL .'admin/assets/css/admin.css', array(), RevSliderGlobals::SLIDER_REVISION);
//add tipsy
wp_enqueue_script('tipsy', RS_PLUGIN_URL .'admin/assets/js/jquery.tipsy.js', array(), RevSliderGlobals::SLIDER_REVISION );
wp_enqueue_style('tipsy', RS_PLUGIN_URL .'admin/assets/css/tipsy.css', array(), RevSliderGlobals::SLIDER_REVISION);
//include codemirror
wp_enqueue_script('codemirror_js', RS_PLUGIN_URL .'admin/assets/js/codemirror/codemirror.js', array(), RevSliderGlobals::SLIDER_REVISION );
wp_enqueue_script('codemirror_js_highlight', RS_PLUGIN_URL .'admin/assets/js/codemirror/util/match-highlighter.js', array(), RevSliderGlobals::SLIDER_REVISION );
wp_enqueue_script('codemirror_js_searchcursor', RS_PLUGIN_URL .'admin/assets/js/codemirror/util/searchcursor.js', array(), RevSliderGlobals::SLIDER_REVISION );
wp_enqueue_script('codemirror_js_css', RS_PLUGIN_URL .'admin/assets/js/codemirror/css.js', array(), RevSliderGlobals::SLIDER_REVISION );
wp_enqueue_script('codemirror_js_html', RS_PLUGIN_URL .'admin/assets/js/codemirror/xml.js', array(), RevSliderGlobals::SLIDER_REVISION );
wp_enqueue_style('codemirror_css', RS_PLUGIN_URL .'admin/assets/js/codemirror/codemirror.css', array(), RevSliderGlobals::SLIDER_REVISION);
}
/**
*
* admin pages parent, includes all the admin files by default
*/
public static function adminPages(){
//self::validateAdminPermissions();
}
/**
*
* validate permission that the user is admin, and can manage options.
*/
protected static function isAdminPermissions(){
if( is_admin() && current_user_can("manage_options") )
return(true);
return(false);
}
/**
*
* validate admin permissions, if no pemissions - exit
*/
protected static function validateAdminPermissions(){
if(!self::isAdminPermissions()){
echo "access denied";
return(false);
}
}
/**
*
* set view that will be the master
*/
protected static function setMasterView($masterView){
self::$master_view = $masterView;
}
/**
*
* inlcude some view file
*/
protected static function requireView($view){
try{
//require master view file, and
if(!empty(self::$master_view) && !isset(self::$tempVars["is_masterView"]) ){
$masterViewFilepath = self::$path_views.self::$master_view.".php";
RevSliderFunctions::validateFilepath($masterViewFilepath,"Master View");
self::$tempVars["is_masterView"] = true;
require $masterViewFilepath;
}else{ //simple require the view file.
if(!in_array($view, self::$allowed_views)) UniteFunctionsRev::throwError(__('Wrong Request', 'revslider'));
switch($view){ //switch URLs to corresponding php files
case 'slide':
$view = 'slide-editor';
break;
case 'slider':
$view = 'slider-editor';
break;
case 'sliders':
$view = 'slider-overview';
break;
case 'slides':
$view = 'slide-overview';
break;
}
$viewFilepath = self::$path_views.$view.".php";
RevSliderFunctions::validateFilepath($viewFilepath,"View");
require $viewFilepath;
}
}catch (Exception $e){
echo "<br><br>View (".esc_attr($view).") Error: <b>".esc_attr($e->getMessage())."</b>";
}
}
/**
* require some template from "templates" folder
*/
protected static function getPathTemplate($templateName){
$pathTemplate = self::$path_templates.$templateName.'.php';
RevSliderFunctions::validateFilepath($pathTemplate,'Template');
return($pathTemplate);
}
/**
*
* add all js and css needed for media upload
*/
protected static function addMediaUploadIncludes(){
wp_enqueue_script('thickbox');
wp_enqueue_script('media-upload');
wp_enqueue_style('thickbox');
}
/**
* add admin menus from the list.
*/
public static function addAdminMenu(){
global $revslider_screens;
$role = "manage_options";
switch(self::$menuRole){
case 'author':
$role = "edit_published_posts";
break;
case 'editor':
$role = "edit_pages";
break;
default:
case 'admin':
$role = "manage_options";
break;
}
foreach(self::$arrMenuPages as $menu){
$title = $menu["title"];
$pageFunctionName = $menu["pageFunction"];
$revslider_screens[] = add_menu_page( $title, $title, $role, 'revslider', array(self::$t, $pageFunctionName), 'dashicons-update' );
}
foreach(self::$arrSubMenuPages as $menu){
$title = $menu["title"];
$pageFunctionName = $menu["pageFunction"];
$pageSlug = $menu["pageSlug"];
$revslider_screens[] = add_submenu_page( 'revslider', $title, $title, $role, $pageSlug, array(self::$t, $pageFunctionName) );
}
}
/**
*
* add menu page
*/
protected static function addMenuPage($title,$pageFunctionName){
self::$arrMenuPages[] = array("title"=>$title,"pageFunction"=>$pageFunctionName);
}
/**
*
* add menu page
*/
protected static function addSubMenuPage($title,$pageFunctionName,$pageSlug){
self::$arrSubMenuPages[] = array("title"=>$title,"pageFunction"=>$pageFunctionName,"pageSlug"=>$pageSlug);
}
/**
*
* get url to some view.
*/
public static function getViewUrl($viewName,$urlParams=""){
$params = "&view=".$viewName;
if(!empty($urlParams))
$params .= "&".$urlParams;
$link = admin_url( 'admin.php?page=revslider'.$params);
return($link);
}
/**
*
* register the "onActivate" event
*/
protected function addEvent_onActivate($eventFunc = "onActivate"){
register_activation_hook( RS_PLUGIN_FILE_PATH, array(self::$t, $eventFunc) );
}
protected function addAction_onActivate(){
register_activation_hook( RS_PLUGIN_FILE_PATH, array(self::$t, 'onActivateHook') );
}
public static function onActivateHook(){
$options = array();
$options = apply_filters('revslider_mod_activation_option', $options);
$operations = new RevSliderOperations();
$options_exist = $operations->getGeneralSettingsValues();
if(!is_array($options_exist)) $options_exist = array();
$options = array_merge($options_exist, $options);
$operations->updateGeneralSettings($options);
}
/**
*
* store settings in the object
*/
protected static function storeSettings($key,$settings){
self::$arrSettings[$key] = $settings;
}
/**
*
* get settings object
*/
protected static function getSettings($key){
if(!isset(self::$arrSettings[$key]))
RevSliderFunctions::throwError("Settings $key not found");
$settings = self::$arrSettings[$key];
return($settings);
}
/**
*
* add ajax back end callback, on some action to some function.
*/
protected static function addActionAjax($ajaxAction,$eventFunction){
add_action('wp_ajax_revslider_'.$ajaxAction, array('RevSliderAdmin', $eventFunction));
}
/**
*
* echo json ajax response
*/
private static function ajaxResponse($success,$message,$arrData = null){
$response = array();
$response["success"] = $success;
$response["message"] = $message;
if(!empty($arrData)){
if(gettype($arrData) == "string")
$arrData = array("data"=>$arrData);
$response = array_merge($response,$arrData);
}
$json = json_encode($response);
echo $json;
exit();
}
/**
*
* echo json ajax response, without message, only data
*/
protected static function ajaxResponseData($arrData){
if(gettype($arrData) == "string")
$arrData = array("data"=>$arrData);
self::ajaxResponse(true,"",$arrData);
}
/**
*
* echo json ajax response
*/
protected static function ajaxResponseError($message,$arrData = null){
self::ajaxResponse(false,$message,$arrData,true);
}
/**
* echo ajax success response
*/
protected static function ajaxResponseSuccess($message,$arrData = null){
self::ajaxResponse(true,$message,$arrData,true);
}
/**
* echo ajax success response
*/
protected static function ajaxResponseSuccessRedirect($message,$url){
$arrData = array("is_redirect"=>true,"redirect_url"=>$url);
self::ajaxResponse(true,$message,$arrData,true);
}
}
/**
* old classname extends new one (old classnames will be obsolete soon)
* @since: 5.0
**/
class UniteBaseAdminClassRev extends RevSliderBaseAdmin {}
?>
@@ -0,0 +1,32 @@
<?php
/**
* @author ThemePunch <info@themepunch.com>
* @link http://www.themepunch.com/
* @copyright 2015 ThemePunch
*/
if( !defined( 'ABSPATH') ) exit();
class RevSliderBaseFront extends RevSliderBase {
const ACTION_ENQUEUE_SCRIPTS = "wp_enqueue_scripts";
/**
*
* main constructor
*/
public function __construct($t){
parent::__construct($t);
add_action('wp_enqueue_scripts', array('RevSliderFront', 'onAddScripts'));
}
}
/**
* old classname extends new one (old classnames will be obsolete soon)
* @since: 5.0
**/
class UniteBaseFrontClassRev extends RevSliderBaseFront {}
?>
@@ -0,0 +1,656 @@
<?php
/**
* @author ThemePunch <info@themepunch.com>
* @link http://www.themepunch.com/
* @copyright 2015 ThemePunch
*/
if( !defined( 'ABSPATH') ) exit();
class RevSliderBase {
protected static $wpdb;
protected static $table_prefix;
protected static $t;
protected static $url_ajax;
protected static $url_ajax_showimage;
protected static $path_views;
protected static $path_templates;
protected static $is_multisite;
public static $url_ajax_actions;
/**
*
* the constructor
*/
public function __construct($t){
global $wpdb;
self::$is_multisite = RevSliderFunctionsWP::isMultisite();
self::$wpdb = $wpdb;
self::$table_prefix = self::$wpdb->base_prefix;
if(self::$is_multisite){
$blogID = RevSliderFunctionsWP::getBlogID();
if($blogID != 1){
self::$table_prefix .= $blogID."_";
}
}
self::$t = $t;
self::$url_ajax = admin_url("admin-ajax.php");
self::$url_ajax_actions = self::$url_ajax . "?action=revslider_ajax_action";
self::$url_ajax_showimage = self::$url_ajax . "?action=revslider_show_image";
self::$path_views = RS_PLUGIN_PATH."admin/views/";
self::$path_templates = self::$path_views."/templates/";
load_plugin_textdomain('revslider',false,'revslider/languages/');
//update globals oldversion flag
RevSliderGlobals::$isNewVersion = false;
$version = get_bloginfo("version");
$version = (double)$version;
if($version >= 3.5)
RevSliderGlobals::$isNewVersion = true;
}
/**
*
* add some wordpress action
*/
protected static function addAction($action,$eventFunction){
add_action( $action, array(self::$t, $eventFunction) );
}
/**
*
* get image url to be shown via thumb making script.
*/
public static function getImageUrl($filepath, $width=null,$height=null,$exact=false,$effect=null,$effect_param=null){
$urlImage = self::getUrlThumb(self::$url_ajax_showimage, $filepath,$width ,$height ,$exact ,$effect ,$effect_param);
return($urlImage);
}
/**
* get thumb url
* @since: 5.0
* @moved from image_view.class.php
*/
public static function getUrlThumb($urlBase, $filename,$width=null,$height=null,$exact=false,$effect=null,$effect_param=null){
$filename = urlencode($filename);
$url = $urlBase."&img=$filename";
if(!empty($width))
$url .= "&w=".$width;
if(!empty($height))
$url .= "&h=".$height;
if($exact == true){
$url .= "&t=".self::TYPE_EXACT;
}
if(!empty($effect)){
$url .= "&e=".$effect;
if(!empty($effect_param))
$url .= "&ea1=".$effect_param;
}
return($url);
}
/**
*
* on show image ajax event. outputs image with parameters
*/
public static function onShowImage(){
$pathImages = RevSliderFunctionsWP::getPathContent();
$urlImages = RevSliderFunctionsWP::getUrlContent();
try{
$imageID = intval(RevSliderFunctions::getGetVar("img"));
$img = wp_get_attachment_image_src( $imageID, 'thumb' );
if(empty($img)) exit;
self::outputImage($img[0]);
}catch (Exception $e){
header("status: 500");
echo __('Image not Found', 'revslider');
exit();
}
}
/**
* show Image to client
* @since: 5.0
* @moved from image_view.class.php
*/
private static function outputImage($filepath){
$info = RevSliderFunctions::getPathInfo($filepath);
$ext = $info["extension"];
$ext = strtolower($ext);
if($ext == "jpg")
$ext = "jpeg";
$numExpires = 31536000; //one year
$strExpires = @date('D, d M Y H:i:s',time()+$numExpires);
$contents = file_get_contents($filepath);
$filesize = strlen($contents);
header("Expires: $strExpires GMT");
header("Cache-Control: public");
header("Content-Type: image/$ext");
header("Content-Length: $filesize");
echo $contents;
exit();
}
/**
*
* get POST var
*/
protected static function getPostVar($key,$defaultValue = ""){
$val = self::getVar($_POST, $key, $defaultValue);
return($val);
}
/**
*
* get GET var
*/
protected static function getGetVar($key,$defaultValue = ""){
$val = self::getVar($_GET, $key, $defaultValue);
return($val);
}
/**
*
* get post or get variable
*/
protected static function getPostGetVar($key,$defaultValue = ""){
if(array_key_exists($key, $_POST))
$val = self::getVar($_POST, $key, $defaultValue);
else
$val = self::getVar($_GET, $key, $defaultValue);
return($val);
}
/**
*
* get some var from array
*/
public static function getVar($arr,$key,$defaultValue = ""){
$val = $defaultValue;
if(isset($arr[$key])) $val = $arr[$key];
return($val);
}
/**
* Get all images sizes + custom added sizes
*/
public static 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')
);
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(
'default' => __('Default', 'revslider'),
'medium' => __('Medium', 'revslider'),
'high' => __('High', 'revslider'),
'standard' => __('Standard', 'revslider'),
'maxres' => __('Max. Res.', 'revslider')
);
break;
case 'vimeo':
$custom_sizes = array(
'thumbnail_small' => __('Small', 'revslider'),
'thumbnail_medium' => __('Medium', 'revslider'),
'thumbnail_large' => __('Large', '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;
}
/**
* retrieve the image id from the given image url
*/
public static function get_image_id_by_url($image_url) {
global $wpdb;
$attachment_id = 0;
// If there is no url, return.
if('' == $image_url || !$image_url)
return $attachment_id;
if(function_exists('attachment_url_to_postid')){
$attachment_id = attachment_url_to_postid($image_url); //0 if failed
}
if ( 0 == $attachment_id ){ //try to get it old school way
//for WP < 4.0.0
$attachment_id = false;
// Get the upload directory paths
$upload_dir_paths = wp_upload_dir();
// Make sure the upload path base directory exists in the attachment URL, to verify that we're working with a media library image
if ( false !== strpos( $image_url, $upload_dir_paths['baseurl'] ) ) {
// If this is the URL of an auto-generated thumbnail, get the URL of the original image
$image_url = preg_replace( '/-\d+x\d+(?=\.(jpg|jpeg|png|gif)$)/i', '', $image_url );
// Remove the upload path base directory from the attachment URL
$image_url = str_replace( $upload_dir_paths['baseurl'] . '/', '', $image_url );
// Finally, run a custom database query to get the attachment ID from the modified attachment URL
$attachment_id = $wpdb->get_var( $wpdb->prepare( "SELECT wposts.ID FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = '_wp_attached_file' AND wpostmeta.meta_value = '%s' AND wposts.post_type = 'attachment'", $image_url ) );
}
}
return $attachment_id;
}
/**
* get all the svg url sets used in Slider Revolution
* @since: 5.1.7
**/
public static function get_svg_sets_url(){
$svg_sets = array();
$path = RS_PLUGIN_PATH . 'public/assets/assets/svg/';
$url = RS_PLUGIN_URL . 'public/assets/assets/svg/';
if(!file_exists($path.'action/ic_3d_rotation_24px.svg')){ //the path needs to be changed to the uploads folder then
$upload_dir = wp_upload_dir();
$path = $upload_dir['basedir'].'/revslider/assets/svg/';
$url = $upload_dir['baseurl'].'/revslider/assets/svg/';
}
$svg_sets['Actions'] = array('path' => $path.'action/', 'url' => $url.'action/');
$svg_sets['Alerts'] = array('path' => $path.'alert/', 'url' => $url.'alert/');
$svg_sets['AV'] = array('path' => $path.'av/', 'url' => $url.'av/');
$svg_sets['Communication'] = array('path' => $path.'communication/', 'url' => $url.'communication/');
$svg_sets['Content'] = array('path' => $path.'content/', 'url' => $url.'content/');
$svg_sets['Device'] = array('path' => $path.'device/', 'url' => $url.'device/');
$svg_sets['Editor'] = array('path' => $path.'editor/', 'url' => $url.'editor/');
$svg_sets['File'] = array('path' => $path.'file/', 'url' => $url.'file/');
$svg_sets['Hardware'] = array('path' => $path.'hardware/', 'url' => $url.'hardware/');
$svg_sets['Images'] = array('path' => $path.'image/', 'url' => $url.'image/');
$svg_sets['Maps'] = array('path' => $path.'maps/', 'url' => $url.'maps/');
$svg_sets['Navigation'] = array('path' => $path.'navigation/', 'url' => $url.'navigation/');
$svg_sets['Notifications'] = array('path' => $path.'notification/', 'url' => $url.'notification/');
$svg_sets['Places'] = array('path' => $path.'places/', 'url' => $url.'places/');
$svg_sets['Social'] = array('path' => $path.'social/', 'url' => $url.'social/');
$svg_sets['Toggle'] = array('path' => $path.'toggle/', 'url' => $url.'toggle/');
$svg_sets = apply_filters('revslider_get_svg_sets', $svg_sets);
return $svg_sets;
}
/**
* get all the svg files for given sets used in Slider Revolution
* @since: 5.1.7
**/
public static function get_svg_sets_full(){
$svg_sets = self::get_svg_sets_url();
$svg = array();
if(!empty($svg_sets)){
foreach($svg_sets as $handle => $values){
$svg[$handle] = array();
if($dir = opendir($values['path'])) {
while(false !== ($file = readdir($dir))){
if ($file != "." && $file != "..") {
$filetype = pathinfo($file);
if(isset($filetype['extension']) && $filetype['extension'] == 'svg'){
$svg[$handle][$file] = $values['url'].$file;
}
}
}
}
}
}
$svg = apply_filters('revslider_get_svg_sets_full', $svg);
return $svg;
}
/**
* get all the icon sets used in Slider Revolution
* @since: 5.0
**/
public static function get_icon_sets(){
$icon_sets = array();
$icon_sets = apply_filters('revslider_mod_icon_sets', $icon_sets);
return $icon_sets;
}
/**
* add default icon sets of Slider Revolution
* @since: 5.0
**/
public static function set_icon_sets($icon_sets){
$icon_sets[] = 'fa-icon-';
$icon_sets[] = 'pe-7s-';
return $icon_sets;
}
/**
* translates removed settings from Slider Settings from version <= 4.x to 5.0
* @since: 5.0
**/
public static function translate_settings_to_v5($settings){
if(isset($settings['navigaion_type'])){
switch($settings['navigaion_type']){
case 'none': // all is off, so leave the defaults
break;
case 'bullet':
$settings['enable_bullets'] = 'on';
$settings['enable_thumbnails'] = 'off';
$settings['enable_tabs'] = 'off';
break;
case 'thumb':
$settings['enable_bullets'] = 'off';
$settings['enable_thumbnails'] = 'on';
$settings['enable_tabs'] = 'off';
break;
}
unset($settings['navigaion_type']);
}
if(isset($settings['navigation_arrows'])){
$settings['enable_arrows'] = ($settings['navigation_arrows'] == 'solo' || $settings['navigation_arrows'] == 'nexttobullets') ? 'on' : 'off';
unset($settings['navigation_arrows']);
}
if(isset($settings['navigation_style'])){
$settings['navigation_arrow_style'] = $settings['navigation_style'];
$settings['navigation_bullets_style'] = $settings['navigation_style'];
unset($settings['navigation_style']);
}
if(isset($settings['navigaion_always_on'])){
$settings['arrows_always_on'] = $settings['navigaion_always_on'];
$settings['bullets_always_on'] = $settings['navigaion_always_on'];
$settings['thumbs_always_on'] = $settings['navigaion_always_on'];
unset($settings['navigaion_always_on']);
}
if(isset($settings['hide_thumbs']) && !isset($settings['hide_arrows']) && !isset($settings['hide_bullets'])){ //as hide_thumbs is still existing, we need to check if the other two were already set and only translate this if they are not set yet
$settings['hide_arrows'] = $settings['hide_thumbs'];
$settings['hide_bullets'] = $settings['hide_thumbs'];
}
if(isset($settings['navigaion_align_vert'])){
$settings['bullets_align_vert'] = $settings['navigaion_align_vert'];
$settings['thumbnails_align_vert'] = $settings['navigaion_align_vert'];
unset($settings['navigaion_align_vert']);
}
if(isset($settings['navigaion_align_hor'])){
$settings['bullets_align_hor'] = $settings['navigaion_align_hor'];
$settings['thumbnails_align_hor'] = $settings['navigaion_align_hor'];
unset($settings['navigaion_align_hor']);
}
if(isset($settings['navigaion_offset_hor'])){
$settings['bullets_offset_hor'] = $settings['navigaion_offset_hor'];
$settings['thumbnails_offset_hor'] = $settings['navigaion_offset_hor'];
unset($settings['navigaion_offset_hor']);
}
if(isset($settings['navigaion_offset_hor'])){
$settings['bullets_offset_hor'] = $settings['navigaion_offset_hor'];
$settings['thumbnails_offset_hor'] = $settings['navigaion_offset_hor'];
unset($settings['navigaion_offset_hor']);
}
if(isset($settings['navigaion_offset_vert'])){
$settings['bullets_offset_vert'] = $settings['navigaion_offset_vert'];
$settings['thumbnails_offset_vert'] = $settings['navigaion_offset_vert'];
unset($settings['navigaion_offset_vert']);
}
if(isset($settings['show_timerbar']) && !isset($settings['enable_progressbar'])){
if($settings['show_timerbar'] == 'hide'){
$settings['enable_progressbar'] = 'off';
$settings['show_timerbar'] = 'top';
}else{
$settings['enable_progressbar'] = 'on';
}
}
return $settings;
}
/**
* explodes google fonts and returns the number of font weights of all fonts
* @since: 5.0
**/
public static function get_font_weight_count($string){
$string = explode(':', $string);
$nums = 0;
if(count($string) >= 2){
$string = $string[1];
if(strpos($string, '&') !== false){
$string = explode('&', $string);
$string = $string[0];
}
$nums = count(explode(',', $string));
}
return $nums;
}
/**
* strip slashes recursive
* @since: 5.0
*/
public static function stripslashes_deep($value){
$value = is_array($value) ?
array_map( array('RevSliderBase', 'stripslashes_deep'), $value) :
stripslashes($value);
return $value;
}
/**
* check if file is in zip
* @since: 5.0
*/
public static function check_file_in_zip($d_path, $image, $alias, &$alreadyImported, $add_path = false){
global $wp_filesystem;
if(trim($image) !== ''){
if(strpos($image, 'http') !== false){
}else{
$strip = false;
$zimage = $wp_filesystem->exists( $d_path.'images/'.$image );
if(!$zimage){
$zimage = $wp_filesystem->exists( str_replace('//', '/', $d_path.'images/'.$image) );
$strip = true;
}
if(!$zimage){
//echo $image.__(' not found!<br>', 'revslider');
}else{
if(!isset($alreadyImported['images/'.$image])){
//check if we are object folder, if yes, do not import into media library but add it to the object folder
$uimg = ($strip == true) ? str_replace('//', '/', 'images/'.$image) : $image; //pclzip
$object_library = (strpos($uimg, 'revslider/objects/') === 0) ? true : false;
if($object_library === true){ //copy the image to the objects folder if false
$objlib = new RevSliderObjectLibrary();
$importImage = $objlib->_import_object($d_path.'images/'.$uimg);
}else{
$importImage = RevSliderFunctionsWP::import_media($d_path.'images/'.$uimg, $alias.'/');
}
if($importImage !== false){
$alreadyImported['images/'.$image] = $importImage['path'];
$image = $importImage['path'];
}
}else{
$image = $alreadyImported['images/'.$image];
}
}
if($add_path){
$upload_dir = wp_upload_dir();
$cont_url = $upload_dir['baseurl'];
$image = str_replace('uploads/uploads/', 'uploads/', $cont_url . '/' . $image);
}
}
}
return $image;
}
/**
* add "a" tags to links within a text
* @since: 5.0
*/
public static function add_wrap_around_url($text){
$reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
// Check if there is a url in the text
if(preg_match($reg_exUrl, $text, $url)){
// make the urls hyper links
return preg_replace($reg_exUrl, '<a href="'.$url[0].'" rel="nofollow" target="_blank">'.$url[0].'</a>', $text);
}else{
// if no urls in the text just return the text
return $text;
}
}
/**
* prints out debug text if constant TP_DEBUG is defined and true
* @since: 5.2.4
*/
public static function debug($value , $message, $where = "console"){
if( defined('TP_DEBUG') && TP_DEBUG ){
if($where=="console"){
echo '<script>
jQuery(document).ready(function(){
if(window.console) {
console.log("'.$message.'");
console.log('.json_encode($value).');
}
});
</script>
';
}
else{
var_dump($value);
}
}
else {
return false;
}
}
}
/**
* old classname extends new one (old classnames will be obsolete soon)
* @since: 5.0
**/
class UniteBaseClassRev extends RevSliderBase {}
?>
@@ -0,0 +1,377 @@
<?php
/**
* @author ThemePunch <info@themepunch.com>
* @link http://www.themepunch.com/
* @version: 1.0.5 (13.6.2018)
* @copyright 2017 ThemePunch
*/
if( !defined( 'ABSPATH') ) exit();
if(!class_exists('TPColorpicker')){
class TPColorpicker {
/**
* @since 5.3.1.6
*/
public function __construct(){
add_filter(AJAX_ACTION, array($this, 'init_ajax'), 10, 6);
}
/**
* @since 5.3.1.6
*/
public static $isColor = '/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i';
/**
* best option for frontend
* @since 5.3.1.6
*/
public static function get($val) {
if(!$val || empty($val)) return 'transparent';
$process = TPColorpicker::process($val, true);
return $process[0];
}
/**
* return usable CSS value from stored color data value
* @since 5.3.1.6
*/
public static function parse($val, $prop, $returnColorType){
$val = TPColorpicker::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 hex and opacity to rgba
* @since 5.3.1.6
*/
public static function convert($color, $opacity){
if( $opacity == "transparent" ){
return 'rgba(0,0,0,0)';
}
if($color=="" ) return '';
if(strpos($color, "[{") !== false || strpos($color,'gradient') !== false ) return TPColorpicker::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 TPColorpicker::processRgba(TPColorpicker::sanitizeHex($color), $opacity);
}
else {
$color = TPColorpicker::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 TPColorpicker::processRgba(TPColorpicker::sanitizeHex($color), $opacity);
}
else if(strpos($color, 'rgb') !== false) {
$color = TPColorpicker::rgbValues($color, 3);
return TPColorpicker::rgbaString($color[0], $color[1], $color[2], $opacity);
}
return 'transparent';
}
/**
* core function for converting ColorPicker input values
* @since 5.3.1.6
*/
public static function process($clr, $processColor = false){
if(empty($clr)) return array('transparent', 'transparent');
if(!is_string($clr) ) {
if($processColor) $clr = TPColorpicker::sanatizeGradient($clr);
return array( TPColorpicker::processGradient($clr), 'gradient', $clr );
}
else if( trim($clr) == 'transparent' ) {
return array('transparent', 'transparent');
}
else if( strpos( $clr, "[{" ) !== false ) {
try {
$clr = json_decode( str_replace("amp;", '',str_replace("&", '"', $clr)) );
if($processColor) $clr = TPColorpicker::sanatizeGradient($clr);
return array(TPColorpicker::processGradient($clr), 'gradient', $clr);
}
catch (Exception $e) {
return '{"type":"linear","angle":"0","colors":[{"r":"255","g":"255","b":"255","a":"1","position":"0","align":"bottom"},{"r":"0","g":"0","b":"0","a":"1","position":"100","align":"bottom"}]}';
}
}
else if( strpos($clr,'#') !== false ) {
return array(TPColorpicker::sanitizeHex($clr), 'hex');
}
else if( strpos($clr,'rgba') !== false ) {
$clr = preg_replace( '/\s+/', '', $clr ) ;
return array($clr, 'rgba');
}
else if( strpos($clr,'rgb') !== false ) {
$clr = preg_replace('/\s+/', '', $clr);
return array($clr, 'rgb');
}
else if(preg_match(TPColorpicker::$isColor, $clr) !== false) {
$clr = preg_replace('/\s+/', '', $clr);
return array($clr, 'hex');
}
return array('transparent', 'transparent');
}
/**
* clean up duplicate values in gradient
* @since 5.3.1.6
*/
public static function sanatizeGradient($obj) {
$colors = $obj->colors;
$len = sizeof($colors);
$ar = array();
for($i = 0; $i < $len; $i++) {
$cur = $colors[$i];
unset($cur->align);
if( isset($prev) ) {
if(json_encode($cur) !== json_encode($prev)) {
$ar[sizeof($ar)] = $cur;
}
}
else {
$ar[sizeof($ar)] = $cur;
}
$prev = $cur;
}
$obj->colors = $ar;
return $obj;
}
/**
* convert gradient object to CSS background gradient value
* @since 5.3.1.6
*/
public static function processGradient($obj){
$tpe = $obj->type;
$begin = $tpe . '-gradient(';
$middle = $tpe === 'linear' ? $obj->angle . 'deg, ' : 'ellipse at center, ';
$colors = $obj->colors;
$len = sizeof($colors);
$end = '';
for($i = 0; $i < $len; $i++) {
if($i > 0) $end .= ', ';
$clr = $colors[$i];
$end .= 'rgba(' . $clr->r . ',' . $clr->g . ',' . $clr->b . ',' . $clr->a . ') ' . $clr->position . '%';
}
return $begin . $middle . $end . ')';
}
/**
* convert rgb values to CSS value
* @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(sizeof($values) == 3 && $num == 4) $values[3] = '1';
for($i = 0; $i < $num; $i++) {
if(isset($values[$i])) $values[$i] = trim($values[$i]);
}
return $values;
}
/**
* convert rgba data values to CSS value
* @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 . ')';
}
/**
* convert rgb to hex
* @since 5.3.1.6
*/
public static function rgbToHex($clr) {
$values = TPColorpicker::rgbValues($clr, 3);
return TPColorpicker::getRgbToHex($values[0], $values[1], $values[2]);
}
/**
* convert rgba to hex
* @since 5.3.1.6
*/
public static function rgbaToHex($clr) {
$values = TPColorpicker::rgbValues($clr, 4);
return array(TPColorpicker::getRgbToHex($values[0], $values[1], $values[2]), $values[3]);
}
/**
* get opacity value from rgba
* @since 5.3.1.6
*/
public static function getOpacity($val){
$rgb = TPColorpicker::rgbValues($val, 4);
return intval($rgb[3] * 100, 10) + '%';
}
/**
* convert 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;
}
/**
* convert hex and opacity values to rgba
* @since 5.3.1.6
*/
public static function joinToRgba($val){
$val = explode('||', $val);
return TPColorpicker::convert($val[0], $val[1]);
}
/**
* convert hex to 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 color values
* @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());
}
}
}
?>
@@ -0,0 +1,688 @@
<?php
/**
* @author ThemePunch <info@themepunch.com>
* @link http://www.themepunch.com/
* @copyright 2015 ThemePunch
*/
if( !defined( 'ABSPATH') ) exit();
class RevSliderCssParser{
private $cssContent;
public function __construct(){
}
/**
*
* init the parser, set css content
*/
public function initContent($cssContent){
$this->cssContent = $cssContent;
}
/**
*
* get array of slide classes, between two sections.
*/
public function getArrClasses($startText = "",$endText="",$explodeonspace=false){
$content = $this->cssContent;
//trim from top
if(!empty($startText)){
$posStart = strpos($content, $startText);
if($posStart !== false)
$content = substr($content, $posStart,strlen($content)-$posStart);
}
//trim from bottom
if(!empty($endText)){
$posEnd = strpos($content, $endText);
if($posEnd !== false)
$content = substr($content,0,$posEnd);
}
//get styles
$lines = explode("\n",$content);
$arrClasses = array();
foreach($lines as $key=>$line){
$line = trim($line);
if(strpos($line, "{") === false)
continue;
//skip unnessasary links
if(strpos($line, ".caption a") !== false)
continue;
if(strpos($line, ".tp-caption a") !== false)
continue;
//get style out of the line
$class = str_replace("{", "", $line);
$class = trim($class);
//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(".caption.", ".", $class);
$class = str_replace(".tp-caption.", ".", $class);
$class = str_replace(".", "", $class);
$class = trim($class);
$arrWords = explode(" ", $class);
$class = $arrWords[count($arrWords)-1];
$class = trim($class);
$arrClasses[] = $class;
}
sort($arrClasses);
return($arrClasses);
}
public static function parseCssToArray($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);
}
public static function parseDbArrayToCss($cssArray, $nl = "\n\r"){
$css = '';
$deformations = self::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($cssArray as $id => $attr){
$stripped = '';
if(strpos($attr['handle'], '.tp-caption') !== false){
$stripped = 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'];
if(!empty($stripped)) $css.= ', '.$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)) {
if($name !== 'css_cursor' && $name !== 'pointer_events') continue;
}
if(!is_array($name) && isset($transparency[$name])){ //the style can have transparency!
if(isset($styles[$transparency[$name]]) && $style !== 'transparent'){
$style = RevSliderFunctions::hex2rgba($style, $styles[$transparency[$name]] * 100);
}
}
if(!is_array($name) && isset($check_parameters[$name])){
$style = RevSliderFunctions::add_missing_val($style, $check_parameters[$name]);
}
if(is_array($style) || is_object($style)) $style = implode(' ', $style);
$ret = self::check_for_modifications($name, $style);
if($ret['name'] == 'cursor' && $ret['style'] == 'auto') continue;
if($ret['name'] == 'pointer-events' && $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)) {
if($name !== 'css_cursor' && $name !== 'pointer_events') continue;
}
if(is_array($style) || is_object($style)) $style = implode(' ', $style);
$ret = self::check_for_modifications($name, $style);
if($ret['name'] == 'cursor' && $ret['style'] == 'auto') continue;
if($ret['name'] == 'pointer-events' && $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)) {
if($name !== 'css_cursor' && $name !== 'pointer_events') continue;
}
if(!is_array($name) && isset($transparency[$name])){ //the style can have transparency!
if(isset($hover[$transparency[$name]]) && $style !== 'transparent'){
$style = RevSliderFunctions::hex2rgba($style, $hover[$transparency[$name]] * 100);
}
}
if(!is_array($name) && isset($check_parameters[$name])){
$style = RevSliderFunctions::add_missing_val($style, $check_parameters[$name]);
}
if(is_array($style)|| is_object($style)) $style = implode(' ', $style);
$ret = self::check_for_modifications($name, $style);
if($ret['name'] == 'cursor' && $ret['style'] == 'auto') continue;
if($ret['name'] == 'pointer-events' && $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)) {
if($name !== 'css_cursor' && $name !== 'pointer_events') continue;
}
if(is_array($style)|| is_object($style)) $style = implode(' ', $style);
$ret = self::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 css_cursor
* @since: 5.1.3
**/
public static function check_for_modifications($name, $style){
if($name == 'css_cursor'){
if($style == 'zoom-in') $style = 'zoom-in; -webkit-zoom-in; cursor: -moz-zoom-in';
if($style == 'zoom-out') $style = 'zoom-out; -webkit-zoom-out; cursor: -moz-zoom-out';
$name = 'cursor';
}
if($name == 'pointer_events'){
$name = 'pointer-events';
}
return array('name' => $name, 'style' => $style);
}
public static function parseArrayToCss($cssArray, $nl = "\n\r", $adv = false){
$deformations = self::get_deformation_css_tags();
$css = '';
foreach($cssArray as $id => $attr){
$setting = (array)$attr['settings'];
$advanced = (array)$attr['advanced'];
$stripped = '';
if(strpos($attr['handle'], '.tp-caption') !== false){
$stripped = trim(str_replace('.tp-caption', '', $attr['handle']));
}
$styles = (array)$attr['params'];
$css.= $attr['handle'];
if(!empty($stripped)) $css.= ', '.$stripped;
$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)) {
if($name !== 'css_cursor' && $name !== 'pointer_events') 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;
}
public static function parseStaticArrayToCss($cssArray, $nl = "\n"){
$css = RevSliderCssParser::parseSimpleArrayToCss();
return $css;
}
public static function parseSimpleArrayToCss($cssArray, $nl = "\n"){
$css = '';
foreach($cssArray 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;
}
public static function parseDbArrayToArray($cssArray, $handle = false){
if(!is_array($cssArray) || empty($cssArray)) return false;
foreach($cssArray as $key => $css){
if($handle != false){
if($cssArray[$key]['handle'] == '.tp-caption.'.$handle){
$cssArray[$key]['params'] = json_decode(str_replace("'", '"', $css['params']));
$cssArray[$key]['hover'] = json_decode(str_replace("'", '"', $css['hover']));
$cssArray[$key]['advanced'] = json_decode(str_replace("'", '"', $css['advanced']));
$cssArray[$key]['settings'] = json_decode(str_replace("'", '"', $css['settings']));
return $cssArray[$key];
}else{
unset($cssArray[$key]);
}
}else{
$cssArray[$key]['params'] = json_decode(str_replace("'", '"', $css['params']));
$cssArray[$key]['hover'] = json_decode(str_replace("'", '"', $css['hover']));
$cssArray[$key]['advanced'] = json_decode(str_replace("'", '"', $css['advanced']));
$cssArray[$key]['settings'] = json_decode(str_replace("'", '"', $css['settings']));
}
}
return $cssArray;
}
public static 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 static function default_css_classes(){
$default = array(
'.tp-caption.medium_grey' => '4',
'.tp-caption.small_text' => '4',
'.tp-caption.medium_text' => '4',
'.tp-caption.large_text' => '4',
'.tp-caption.very_large_text' => '4',
'.tp-caption.very_big_white' => '4',
'.tp-caption.very_big_black' => '4',
'.tp-caption.modern_medium_fat' => '4',
'.tp-caption.modern_medium_fat_white' => '4',
'.tp-caption.modern_medium_light' => '4',
'.tp-caption.modern_big_bluebg' => '4',
'.tp-caption.modern_big_redbg' => '4',
'.tp-caption.modern_small_text_dark' => '4',
'.tp-caption.boxshadow' => '4',
'.tp-caption.black' => '4',
'.tp-caption.noshadow' => '4',
'.tp-caption.thinheadline_dark' => '4',
'.tp-caption.thintext_dark' => '4',
'.tp-caption.largeblackbg' => '4',
'.tp-caption.largepinkbg' => '4',
'.tp-caption.largewhitebg' => '4',
'.tp-caption.largegreenbg' => '4',
'.tp-caption.excerpt' => '4',
'.tp-caption.large_bold_grey' => '4',
'.tp-caption.medium_thin_grey' => '4',
'.tp-caption.small_thin_grey' => '4',
'.tp-caption.lightgrey_divider' => '4',
'.tp-caption.large_bold_darkblue' => '4',
'.tp-caption.medium_bg_darkblue' => '4',
'.tp-caption.medium_bold_red' => '4',
'.tp-caption.medium_light_red' => '4',
'.tp-caption.medium_bg_red' => '4',
'.tp-caption.medium_bold_orange' => '4',
'.tp-caption.medium_bg_orange' => '4',
'.tp-caption.grassfloor' => '4',
'.tp-caption.large_bold_white' => '4',
'.tp-caption.medium_light_white' => '4',
'.tp-caption.mediumlarge_light_white' => '4',
'.tp-caption.mediumlarge_light_white_center' => '4',
'.tp-caption.medium_bg_asbestos' => '4',
'.tp-caption.medium_light_black' => '4',
'.tp-caption.large_bold_black' => '4',
'.tp-caption.mediumlarge_light_darkblue' => '4',
'.tp-caption.small_light_white' => '4',
'.tp-caption.roundedimage' => '4',
'.tp-caption.large_bg_black' => '4',
'.tp-caption.mediumwhitebg' => '4',
'.tp-caption.MarkerDisplay' => '5.0',
'.tp-caption.Restaurant-Display' => '5.0',
'.tp-caption.Restaurant-Cursive' => '5.0',
'.tp-caption.Restaurant-ScrollDownText' => '5.0',
'.tp-caption.Restaurant-Description' => '5.0',
'.tp-caption.Restaurant-Price' => '5.0',
'.tp-caption.Restaurant-Menuitem' => '5.0',
'.tp-caption.Furniture-LogoText' => '5.0',
'.tp-caption.Furniture-Plus' => '5.0',
'.tp-caption.Furniture-Title' => '5.0',
'.tp-caption.Furniture-Subtitle' => '5.0',
'.tp-caption.Gym-Display' => '5.0',
'.tp-caption.Gym-Subline' => '5.0',
'.tp-caption.Gym-SmallText' => '5.0',
'.tp-caption.Fashion-SmallText' => '5.0',
'.tp-caption.Fashion-BigDisplay' => '5.0',
'.tp-caption.Fashion-TextBlock' => '5.0',
'.tp-caption.Sports-Display' => '5.0',
'.tp-caption.Sports-DisplayFat' => '5.0',
'.tp-caption.Sports-Subline' => '5.0',
'.tp-caption.Instagram-Caption' => '5.0',
'.tp-caption.News-Title' => '5.0',
'.tp-caption.News-Subtitle' => '5.0',
'.tp-caption.Photography-Display' => '5.0',
'.tp-caption.Photography-Subline' => '5.0',
'.tp-caption.Photography-ImageHover' => '5.0',
'.tp-caption.Photography-Menuitem' => '5.0',
'.tp-caption.Photography-Textblock' => '5.0',
'.tp-caption.Photography-Subline-2' => '5.0',
'.tp-caption.Photography-ImageHover2' => '5.0',
'.tp-caption.WebProduct-Title' => '5.0',
'.tp-caption.WebProduct-SubTitle' => '5.0',
'.tp-caption.WebProduct-Content' => '5.0',
'.tp-caption.WebProduct-Menuitem' => '5.0',
'.tp-caption.WebProduct-Title-Light' => '5.0',
'.tp-caption.WebProduct-SubTitle-Light' => '5.0',
'.tp-caption.WebProduct-Content-Light' => '5.0',
'.tp-caption.FatRounded' => '5.0',
'.tp-caption.NotGeneric-Title' => '5.0',
'.tp-caption.NotGeneric-SubTitle' => '5.0',
'.tp-caption.NotGeneric-CallToAction' => '5.0',
'.tp-caption.NotGeneric-Icon' => '5.0',
'.tp-caption.NotGeneric-Menuitem' => '5.0',
'.tp-caption.MarkerStyle' => '5.0',
'.tp-caption.Gym-Menuitem' => '5.0',
'.tp-caption.Newspaper-Button' => '5.0',
'.tp-caption.Newspaper-Subtitle' => '5.0',
'.tp-caption.Newspaper-Title' => '5.0',
'.tp-caption.Newspaper-Title-Centered' => '5.0',
'.tp-caption.Hero-Button' => '5.0',
'.tp-caption.Video-Title' => '5.0',
'.tp-caption.Video-SubTitle' => '5.0',
'.tp-caption.NotGeneric-Button' => '5.0',
'.tp-caption.NotGeneric-BigButton' => '5.0',
'.tp-caption.WebProduct-Button' => '5.0',
'.tp-caption.Restaurant-Button' => '5.0',
'.tp-caption.Gym-Button' => '5.0',
'.tp-caption.Gym-Button-Light' => '5.0',
'.tp-caption.Sports-Button-Light' => '5.0',
'.tp-caption.Sports-Button-Red' => '5.0',
'.tp-caption.Photography-Button' => '5.0',
'.tp-caption.Newspaper-Button-2' => '5.0'
);
$default = apply_filters('revslider_mod_default_css_handles', $default);
return $default;
}
/**
* Defines the deformation CSS which is not directly usable as pure CSS
* @since: 5.0
**/
public static 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',
'css_cursor' => 'css_cursor',
'pointer_events' => 'pointer_events',
'speed' => 'speed',
'easing' => 'easing',
'corner_left' => 'corner_left',
'corner_right' => 'corner_right',
'parallax' => 'parallax',
'type' => 'type',
'padding' => 'padding',
'margin' => 'margin',
'text-align' => 'text-align'
);
}
public static function get_captions_sorted(){
$db = new RevSliderDB();
$styles = $db->fetch(RevSliderGlobals::$table_css, '', 'handle ASC');
$arr = array('5.0' => array(), 'Custom' => array(), '4' => array());
foreach($styles as $style){
$setting = json_decode($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' => $name['label'], 'version' => $version, 'type' => $name['type']);
}
}
return $sorted;
}
/**
* Handles media queries
* @since: 5.2.0
**/
public static function parse_media_blocks($css){
$mediaBlocks = 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++;
}
$mediaBlocks[$block] = substr($css, $start, ($i + 1) - $start);
$start = $i;
}
}
return $mediaBlocks;
}
/**
* removes @media { ... } queries from CSS
* @since: 5.2.0
**/
public static function clear_media_block($css){
$start = 0;
if(strpos($css, '@media', $start) !== false){
$start = strpos($css, '@media', 0);
$i = strpos($css, '{', $start) + 1;
//remove @media ... first {
$remove = substr($css, $start - 1, $i - $start + 1);
$css = str_replace($remove, '', $css);
//remove last }
$css = preg_replace('/}$/', '', $css);
}
return $css;
}
}
/**
* old classname extends new one (old classnames will be obsolete soon)
* @since: 5.0
**/
class UniteCssParserRev extends RevSliderCssParser {}
?>
@@ -0,0 +1,182 @@
<?php
/**
* @author ThemePunch <info@themepunch.com>
* @link http://www.themepunch.com/
* @copyright 2015 ThemePunch
*/
if( !defined( 'ABSPATH') ) exit();
class RevSliderDB{
private $lastRowID;
/**
*
* constructor - set database object
*/
public function __construct(){
}
/**
*
* throw error
*/
private function throwError($message,$code=-1){
RevSliderFunctions::throwError($message,$code);
}
//------------------------------------------------------------
// validate for errors
private function checkForErrors($prefix = ""){
global $wpdb;
if($wpdb->last_error !== ''){
$query = $wpdb->last_query;
$message = $wpdb->last_error;
if($prefix) $message = $prefix.' - <b>'.$message.'</b>';
if($query) $message .= '<br>---<br> Query: ' . esc_attr($query);
$this->throwError($message);
}
}
/**
*
* insert variables to some table
*/
public function insert($table,$arrItems){
global $wpdb;
$wpdb->insert($table, $arrItems);
$this->checkForErrors("Insert query error");
$this->lastRowID = $wpdb->insert_id;
return($this->lastRowID);
}
/**
*
* get last insert id
*/
public function getLastInsertID(){
global $wpdb;
$this->lastRowID = $wpdb->insert_id;
return($this->lastRowID);
}
/**
*
* delete rows
*/
public function delete($table,$where){
global $wpdb;
RevSliderFunctions::validateNotEmpty($table,"table name");
RevSliderFunctions::validateNotEmpty($where,"where");
$query = "delete from $table where $where";
$wpdb->query($query);
$this->checkForErrors("Delete query error");
}
/**
*
* run some sql query
*/
public function runSql($query){
global $wpdb;
$wpdb->query($query);
$this->checkForErrors("Regular query error");
}
/**
*
* run some sql query
*/
public function runSqlR($query){
global $wpdb;
$return = $wpdb->get_results($query, ARRAY_A);
return $return;
}
/**
*
* insert variables to some table
*/
public function update($table,$arrItems,$where){
global $wpdb;
$response = $wpdb->update($table, $arrItems, $where);
return($wpdb->num_rows);
}
/**
*
* get data array from the database
*
*/
public function fetch($tableName,$where="",$orderField="",$groupByField="",$sqlAddon=""){
global $wpdb;
$query = "select * from $tableName";
if($where) $query .= " where $where";
if($orderField) $query .= " order by $orderField";
if($groupByField) $query .= " group by $groupByField";
if($sqlAddon) $query .= " ".$sqlAddon;
$response = $wpdb->get_results($query,ARRAY_A);
$this->checkForErrors("fetch");
return($response);
}
/**
*
* fetch only one item. if not found - throw error
*/
public function fetchSingle($tableName,$where="",$orderField="",$groupByField="",$sqlAddon=""){
$response = $this->fetch($tableName, $where, $orderField, $groupByField, $sqlAddon);
if(empty($response))
$this->throwError("Record not found");
$record = $response[0];
return($record);
}
/**
* prepare statement to avoid sql injections
*/
public function prepare($query, $array){
global $wpdb;
$query = $wpdb->prepare($query, $array);
return($query);
}
}
/**
* old classname extends new one (old classnames will be obsolete soon)
* @since: 5.0
**/
class UniteDBRev extends RevSliderDB {}
?>
@@ -0,0 +1,26 @@
<?php
/**
* @author ThemePunch <info@themepunch.com>
* @link http://www.themepunch.com/
* @copyright 2015 ThemePunch
*/
if( !defined( 'ABSPATH') ) exit();
class RevSliderElementsBase {
protected $db;
public function __construct(){
$this->db = new RevSliderDB();
}
}
/**
* old classname extends new one (old classnames will be obsolete soon)
* @since: 5.0
**/
class UniteElementsBaseRev extends RevSliderElementsBase {}
?>
@@ -0,0 +1,180 @@
<?php
/**
* @author ThemePunch <info@themepunch.com>
* @link http://www.themepunch.com/
* @copyright 2015 ThemePunch
*/
if( !defined( 'ABSPATH') ) exit();
class RevSliderEventsManager {
const DEFAULT_FILTER = "none";
/**
*
* check if events class exists
*/
public static function isEventsExists(){
if(defined("EM_VERSION") && defined("EM_PRO_MIN_VERSION"))
return(true);
return(false);
}
/**
*
* get sort by list
*/
public static function getArrFilterTypes(){
$arrEventsSort = 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')
);
return($arrEventsSort);
}
/**
*
* get meta query
*/
public static function getWPQuery($filterType, $sortBy){
$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($filterType){
case self::DEFAULT_FILTER: //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:
RevSliderFunctions::throwError("Wrong event filter");
break;
}
if(!empty($query))
$response["meta_query"] = $query;
//convert sortby
switch($sortBy){
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
*/
public static function getEventPostData($postID){
if(self::isEventsExists() == false)
return(array());
$postType = get_post_type($postID);
if($postType != EM_POST_TYPE_EVENT)
return(array());
$event = new EM_Event($postID, 'post_id');
$location = $event->get_location();
$arrEvent = $event->to_array();
$arrLocation = $location->to_array();
$date_format = get_option('date_format');
$time_format = get_option('time_format');
$arrEvent["event_start_date"] = date_format(date_create_from_format('Y-m-d', $arrEvent["event_start_date"]), $date_format);
$arrEvent["event_end_date"] = date_format(date_create_from_format('Y-m-d', $arrEvent["event_end_date"]), $date_format);
$arrEvent["event_start_time"] = date_format(date_create_from_format('H:i:s', $arrEvent["event_start_time"]), $time_format);
$arrEvent["event_end_time"] = date_format(date_create_from_format('H:i:s', $arrEvent["event_end_time"]), $time_format);
$response = array();
$response["start_date"] = $arrEvent["event_start_date"];
$response["end_date"] = $arrEvent["event_end_date"];
$response["start_time"] = $arrEvent["event_start_time"];
$response["end_time"] = $arrEvent["event_end_time"];
$response["id"] = $arrEvent["event_id"];
$response["location_name"] = $arrLocation["location_name"];
$response["location_address"] = $arrLocation["location_address"];
$response["location_slug"] = $arrLocation["location_slug"];
$response["location_town"] = $arrLocation["location_town"];
$response["location_state"] = $arrLocation["location_state"];
$response["location_postcode"] = $arrLocation["location_postcode"];
$response["location_region"] = $arrLocation["location_region"];
$response["location_country"] = $arrLocation["location_country"];
$response["location_latitude"] = $arrLocation["location_latitude"];
$response["location_longitude"] = $arrLocation["location_longitude"];
return($response);
}
/**
*
* get events sort by array
*/
public static function getArrSortBy(){
$arrSortBy = array();
$arrSortBy["event_start_date"] = __("Event Start Date",'revslider');
$arrSortBy["event_end_date"] = __("Event End Date",'revslider');
return($arrSortBy);
}
}
/**
* old classname extends new one (old classnames will be obsolete soon)
* @since: 5.0
**/
class UniteEmRev extends RevSliderEventsManager {}
?>
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,692 @@
<?php
/**
* @author ThemePunch <info@themepunch.com>
* @link http://www.themepunch.com/
* @copyright 2015 ThemePunch
*/
if( !defined( 'ABSPATH') ) exit();
class RevSliderFunctions{
public static function throwError($message,$code=null){
if(!empty($code)){
throw new Exception($message,$code);
}else{
throw new Exception($message);
}
}
/**
* set output for download
*/
public static function downloadFile($str,$filename="output.txt"){
//output for download
header('Content-Description: File Transfer');
header('Content-Type: text/html; charset=UTF-8');
header("Content-Disposition: attachment; filename=".$filename.";");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".strlen($str));
echo $str;
exit();
}
/**
* turn boolean to string
*/
public static function boolToStr($bool){
if(gettype($bool) == "string")
return($bool);
if($bool == true)
return("true");
else
return("false");
}
/**
* convert string to boolean
*/
public static function strToBool($str){
if(is_bool($str))
return($str);
if(empty($str))
return(false);
if(is_numeric($str))
return($str != 0);
$str = strtolower($str);
if($str == "true")
return(true);
return(false);
}
/**
* get value from array. if not - return alternative
*/
public static function getVal($arr,$key,$altVal=""){
if(is_array($arr)){
if(isset($arr[$key])){
return($arr[$key]);
}
}elseif(is_object($arr)){
if(isset($arr->$key)){
return($arr->$key);
}
}
return($altVal);
}
//------------------------------------------------------------
// get variable from post or from get. post wins.
public static function getPostGetVariable($name,$initVar = ""){
$var = $initVar;
if(isset($_POST[$name])) $var = $_POST[$name];
else if(isset($_GET[$name])) $var = $_GET[$name];
return($var);
}
//------------------------------------------------------------
public static function getPostVariable($name,$initVar = ""){
$var = $initVar;
if(isset($_POST[$name])) $var = $_POST[$name];
return($var);
}
//------------------------------------------------------------
public static function getGetVar($name,$initVar = ""){
$var = $initVar;
if(isset($_GET[$name])) $var = $_GET[$name];
return($var);
}
public static function sortByOrder($a, $b) {
return $a['order'] - $b['order'];
}
/**
* validate that some file exists, if not - throw error
*/
public static function validateFilepath($filepath,$errorPrefix=null){
if(file_exists($filepath) == true)
return(false);
if($errorPrefix == null)
$errorPrefix = "File";
$message = $errorPrefix." ".esc_attr($filepath)." not exists!";
self::throwError($message);
}
/**
* validate that some value is numeric
*/
public static function validateNumeric($val,$fieldName=""){
self::validateNotEmpty($val,$fieldName);
if(empty($fieldName))
$fieldName = "Field";
if(!is_numeric($val))
self::throwError("$fieldName should be numeric ");
}
/**
* validate that some variable not empty
*/
public static function validateNotEmpty($val,$fieldName=""){
if(empty($fieldName))
$fieldName = "Field";
if(empty($val) && is_numeric($val) == false)
self::throwError("Field <b>$fieldName</b> should not be empty");
}
//------------------------------------------------------------
//get path info of certain path with all needed fields
public static function getPathInfo($filepath){
$info = pathinfo($filepath);
//fix the filename problem
if(!isset($info["filename"])){
$filename = $info["basename"];
if(isset($info["extension"]))
$filename = substr($info["basename"],0,(-strlen($info["extension"])-1));
$info["filename"] = $filename;
}
return($info);
}
/**
* Convert std class to array, with all sons
* @param unknown_type $arr
*/
public static function convertStdClassToArray($arr){
$arr = (array)$arr;
$arrNew = array();
foreach($arr as $key=>$item){
$item = (array)$item;
$arrNew[$key] = $item;
}
return($arrNew);
}
public static function cleanStdClassToArray($arr){
$arr = (array)$arr;
$arrNew = array();
foreach($arr as $key=>$item){
$arrNew[$key] = $item;
}
return($arrNew);
}
/**
* encode array into json for client side
*/
public static function jsonEncodeForClientSide($arr){
$json = "";
if(!empty($arr)){
$json = json_encode($arr);
$json = addslashes($json);
}
if(empty($json)) $json = '{}';
$json = "'".$json."'";
return($json);
}
/**
* decode json from the client side
*/
public static function jsonDecodeFromClientSide($data){
$data = stripslashes($data);
$data = str_replace('&#092;"','\"',$data);
$data = json_decode($data);
$data = (array)$data;
return($data);
}
/**
* do "trim" operation on all array items.
*/
public static function trimArrayItems($arr){
if(gettype($arr) != "array")
RevSliderFunctions::throwError("trimArrayItems error: The type must be array");
foreach ($arr as $key=>$item){
if(is_array($item)){
foreach($item as $key => $value){
$arr[$key][$key] = trim($value);
}
}else{
$arr[$key] = trim($item);
}
}
return($arr);
}
/**
* get link html
*/
public static function getHtmlLink($link,$text,$id="",$class=""){
if(!empty($class))
$class = " class='$class'";
if(!empty($id))
$id = " id='$id'";
$html = "<a href=\"$link\"".$id.$class.">$text</a>";
return($html);
}
/**
* get select from array
*/
public static function getHTMLSelect($arr,$default="",$htmlParams="",$assoc = false){
$html = "<select $htmlParams>";
foreach($arr as $key=>$item){
$selected = "";
if($assoc == false){
if($item == $default) $selected = " selected ";
}else{
if(trim($key) == trim($default)) $selected = " selected ";
}
if($assoc == true)
$html .= "<option $selected value='$key'>$item</option>";
else
$html .= "<option $selected value='$item'>$item</option>";
}
$html.= "</select>";
return($html);
}
/**
* convert assoc array to array
*/
public static function assocToArray($assoc){
$arr = array();
foreach($assoc as $item)
$arr[] = $item;
return($arr);
}
/**
*
* strip slashes from textarea content after ajax request to server
*/
public static function normalizeTextareaContent($content){
if(empty($content))
return($content);
$content = stripslashes($content);
$content = trim($content);
return($content);
}
/**
* get text intro, limit by number of words
*/
public static function getTextIntro($text, $limit){
$arrIntro = explode(' ', $text, $limit);
if (count($arrIntro)>=$limit) {
array_pop($arrIntro);
$intro = implode(" ",$arrIntro);
$intro = trim($intro);
if(!empty($intro))
$intro .= '...';
} else {
$intro = implode(" ",$arrIntro);
}
$intro = preg_replace('`\[[^\]]*\]`','',$intro);
return($intro);
}
/**
* add missing px/% to value, do also for object and array
* @since: 5.0
**/
public static 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(strpos($value, $set_to) === false){
$obj->$key = $value.$set_to;
}
}
}else{
if(strpos($obj, $set_to) === false){
$obj .= $set_to;
}
}
return $obj;
}
/**
* normalize object with device informations depending on what is enabled for the Slider
* @since: 5.0
**/
public static function normalize_device_settings($obj, $enabled_devices, $return = 'obj', $set_to_if = array()){ //array -> from -> to
/*desktop
notebook
tablet
mobile*/
if(!empty($set_to_if)){
foreach($obj as $key => $value) {
foreach($set_to_if as $from => $to){
if(trim($value) == $from) $obj->$key = $to;
}
}
}
$inherit_size = self::get_biggest_device_setting($obj, $enabled_devices);
if($enabled_devices['desktop'] == 'on'){
if(!isset($obj->desktop) || $obj->desktop === ''){
$obj->desktop = $inherit_size;
}else{
$inherit_size = $obj->desktop;
}
}else{
$obj->desktop = $inherit_size;
}
if($enabled_devices['notebook'] == 'on'){
if(!isset($obj->notebook) || $obj->notebook === ''){
$obj->notebook = $inherit_size;
}else{
$inherit_size = $obj->notebook;
}
}else{
$obj->notebook = $inherit_size;
}
if($enabled_devices['tablet'] == 'on'){
if(!isset($obj->tablet) || $obj->tablet === ''){
$obj->tablet = $inherit_size;
}else{
$inherit_size = $obj->tablet;
}
}else{
$obj->tablet = $inherit_size;
}
if($enabled_devices['mobile'] == 'on'){
if(!isset($obj->mobile) || $obj->mobile === ''){
$obj->mobile = $inherit_size;
}else{
$inherit_size = $obj->mobile;
}
}else{
$obj->mobile = $inherit_size;
}
switch($return){
case 'obj':
//order according to: desktop, notebook, tablet, mobile
$new_obj = new stdClass();
$new_obj->desktop = $obj->desktop;
$new_obj->notebook = $obj->notebook;
$new_obj->tablet = $obj->tablet;
$new_obj->mobile = $obj->mobile;
return $new_obj;
break;
case 'html-array':
if($obj->desktop === $obj->notebook && $obj->desktop === $obj->mobile && $obj->desktop === $obj->tablet){
return $obj->desktop;
}else{
return "['".@$obj->desktop."','".@$obj->notebook."','".@$obj->tablet."','".@$obj->mobile."']";
}
break;
}
return $obj;
}
/**
* return biggest value of object depending on which devices are enabled
* @since: 5.0
**/
public static function get_biggest_device_setting($obj, $enabled_devices){
if($enabled_devices['desktop'] == 'on'){
if(isset($obj->desktop) && $obj->desktop != ''){
return $obj->desktop;
}
}
if($enabled_devices['notebook'] == 'on'){
if(isset($obj->notebook) && $obj->notebook != ''){
return $obj->notebook;
}
}
if($enabled_devices['tablet'] == 'on'){
if(isset($obj->tablet) && $obj->tablet != ''){
return $obj->tablet;
}
}
if($enabled_devices['mobile'] == 'on'){
if(isset($obj->mobile) && $obj->mobile != ''){
return $obj->mobile;
}
}
return '';
}
/**
* change hex to rgba
*/
public static 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));
} else if(self::isrgb($hex)){
return $hex;
} else {
$r = hexdec(substr($hex,0,2));
$g = hexdec(substr($hex,2,2));
$b = hexdec(substr($hex,4,2));
}
if($do_rgb){
$ret = $r.', '.$g.', '.$b;
}else{
$ret = $r.', '.$g.', '.$b.', '.$transparency;
}
if($raw){
return $ret;
}else{
return 'rgba('.$ret.')';
}
}
public static function isrgb($rgba){
if(strpos($rgba, 'rgb') !== false) return true;
return false;
}
/**
* change rgba to hex
* @since: 5.0
*/
public static function rgba2hex($rgba){
if(strtolower($rgba) == 'transparent') return $rgba;
$temp = explode(',', $rgba);
$rgb = array();
if(count($temp) == 4) unset($temp[3]);
foreach($temp as $val){
$t = dechex(preg_replace('/[^\d.]/', '', $val));
if(strlen($t) < 2) $t = '0'.$t;
$rgb[] = $t;
}
return '#'.implode('', $rgb);
}
/**
* get transparency from rgba
* @since: 5.0
*/
public static function get_trans_from_rgba($rgba, $in_percent = false){
if(strtolower($rgba) == 'transparent') return 100;
$temp = explode(',', $rgba);
if(count($temp) == 4){
return ($in_percent) ? preg_replace('/[^\d.]/', '', $temp[3]) : preg_replace('/[^\d.]/', "", $temp[3]) * 100;
}
return 100;
}
public static function get_responsive_size($slider){
$operations = new RevSliderOperations();
$arrValues = $operations->getGeneralSettingsValues();
$enable_custom_size_notebook = $slider->slider->getParam('enable_custom_size_notebook','off');
$enable_custom_size_tablet = $slider->slider->getParam('enable_custom_size_tablet','off');
$enable_custom_size_iphone = $slider->slider->getParam('enable_custom_size_iphone','off');
$adv_resp_sizes = ($enable_custom_size_notebook == 'on' || $enable_custom_size_tablet == 'on' || $enable_custom_size_iphone == 'on') ? true : false;
if($adv_resp_sizes == true){
$width = $slider->slider->getParam("width", 1240, RevSlider::FORCE_NUMERIC);
$def = $width;
$width .= ',';
if($enable_custom_size_notebook == 'on'){
$width.= $slider->slider->getParam("width_notebook", 1024, RevSlider::FORCE_NUMERIC);
$def = $slider->slider->getParam("width_notebook", 1024, RevSlider::FORCE_NUMERIC);
}else{
$width.= $def;
}
$width.= ',';
if($enable_custom_size_tablet == 'on'){
$width.= $slider->slider->getParam("width_tablet", 778, RevSlider::FORCE_NUMERIC);
$def = $slider->slider->getParam("width_tablet", 778, RevSlider::FORCE_NUMERIC);
}else{
$width.= $def;
}
$width.= ',';
if($enable_custom_size_iphone == 'on'){
$width.= $slider->slider->getParam("width_mobile", 480, RevSlider::FORCE_NUMERIC);
$def = $slider->slider->getParam("width_mobile", 480, RevSlider::FORCE_NUMERIC);
}else{
$width.= $def;
}
$height = $slider->slider->getParam("height", 1240, RevSlider::FORCE_NUMERIC);
$def = $height;
$height .= ',';
if($enable_custom_size_notebook == 'on'){
$height.= $slider->slider->getParam("height_notebook", 1024, RevSlider::FORCE_NUMERIC);
$def = $slider->slider->getParam("height_notebook", 1024, RevSlider::FORCE_NUMERIC);
}else{
$height.= $def;
}
$height.= ',';
if($enable_custom_size_tablet == 'on'){
$height.= $slider->slider->getParam("height_tablet", 778, RevSlider::FORCE_NUMERIC);
$def = $slider->slider->getParam("height_tablet", 778, RevSlider::FORCE_NUMERIC);
}else{
$height.= $def;
}
$height.= ',';
if($enable_custom_size_iphone == 'on'){
$height.= $slider->slider->getParam("height_mobile", 480, RevSlider::FORCE_NUMERIC);
$def = $slider->slider->getParam("height_mobile", 480, RevSlider::FORCE_NUMERIC);
}else{
$height.= $def;
}
$responsive = (isset($arrValues['width'])) ? $arrValues['width'] : '1240';
$def = (isset($arrValues['width'])) ? $arrValues['width'] : '1240';
$responsive.= ',';
if($enable_custom_size_notebook == 'on'){
$responsive.= (isset($arrValues['width_notebook'])) ? $arrValues['width_notebook'] : '1024';
$def = (isset($arrValues['width_notebook'])) ? $arrValues['width_notebook'] : '1024';
}else{
$responsive.= $def;
}
$responsive.= ',';
if($enable_custom_size_tablet == 'on'){
$responsive.= (isset($arrValues['width_tablet'])) ? $arrValues['width_tablet'] : '778';
$def = (isset($arrValues['width_tablet'])) ? $arrValues['width_tablet'] : '778';
}else{
$responsive.= $def;
}
$responsive.= ',';
if($enable_custom_size_iphone == 'on'){
$responsive.= (isset($arrValues['width_mobile'])) ? $arrValues['width_mobile'] : '480';
$def = (isset($arrValues['width_mobile'])) ? $arrValues['width_mobile'] : '480';
}else{
$responsive.= $def;
}
return array(
'level' => $responsive,
'height' => $height,
'width' => $width
);
}else{
$responsive = (isset($arrValues['width'])) ? $arrValues['width'] : '1240';
$def = (isset($arrValues['width'])) ? $arrValues['width'] : '1240';
$responsive.= ',';
$responsive.= (isset($arrValues['width_notebook'])) ? $arrValues['width_notebook'] : '1024';
$responsive.= ',';
$responsive.= (isset($arrValues['width_tablet'])) ? $arrValues['width_tablet'] : '778';
$responsive.= ',';
$responsive.= (isset($arrValues['width_mobile'])) ? $arrValues['width_mobile'] : '480';
return array(
'visibilitylevel' => $responsive,
'height' => $slider->slider->getParam("height", "868", RevSlider::FORCE_NUMERIC),
'width' => $slider->slider->getParam("width", "1240", RevSlider::FORCE_NUMERIC)
);
}
}
}
if(!function_exists("dmp")){
function dmp($str){
echo "<div align='left'>";
echo "<pre>";
print_r($str);
echo "</pre>";
echo "</div>";
}
}
/**
* old classname extends new one (old classnames will be obsolete soon)
* @since: 5.0
**/
class UniteFunctionsRev extends RevSliderFunctions {}
?>
@@ -0,0 +1,24 @@
<?php
/**
* @author ThemePunch <info@themepunch.com>
* @link http://www.themepunch.com/
* @copyright 2015 ThemePunch
*/
if( !defined( 'ABSPATH') ) exit();
$folderIncludes = dirname(__FILE__)."/";
require_once($folderIncludes . 'functions.class.php');
require_once($folderIncludes . 'functions-wordpress.class.php');
require_once($folderIncludes . 'db.class.php');
require_once($folderIncludes . 'cssparser.class.php');
require_once($folderIncludes . 'wpml.class.php');
require_once($folderIncludes . 'woocommerce.class.php');
require_once($folderIncludes . 'em-integration.class.php');
require_once($folderIncludes . 'aq-resizer.class.php');
require_once($folderIncludes . 'plugin-update.class.php');
require_once($folderIncludes . 'addon-admin.class.php');
require_once($folderIncludes . 'colorpicker.class.php');
require_once($folderIncludes . 'loadbalancer.class.php');
?>
Whitespace-only changes.
@@ -0,0 +1,102 @@
<?php
/**
* @author ThemePunch <info@themepunch.com>
* @link http://www.themepunch.com/
* @copyright 2017 ThemePunch
*/
if( !defined( 'ABSPATH') ) exit();
class RevSliderLoadBalancer {
public $servers = array();
/**
* set the server list on construct
**/
public function __construct(){
$this->servers = get_option('revslider_servers', array());
$this->servers = (empty($this->servers)) ? array('themepunch.tools') : $this->servers; //, 'themepunch-ext-a.tools'
}
/**
* get the url depending on the purpose, here with key, you can switch do a different server
**/
public function get_url($purpose, $key = 0){
$url = 'https://';
$use_url = (!isset($this->servers[$key])) ? reset($this->servers) : $this->servers[$key];
//$use_url = 'themepunch.tools';
switch($purpose){
case 'updates':
$url .= 'updates.';
break;
case 'templates':
$url .= 'templates.';
break;
case 'library':
$url .= 'library.';
break;
default:
return false;
}
$url .= $use_url;
return $url;
}
/**
* refresh the server list to be used, will be done once in a month
**/
public function refresh_server_list($force = false){
global $wp_version;
$last_check = get_option('revslider_server_refresh', false);
if($force === true || $last_check === false || time() - $last_check > 60 * 60 * 24 * 14){
//$url = $this->get_url('updates');
$url = 'https://updates.themepunch.tools';
$count = 0;
/*$response = false;
do{*/
$request = wp_remote_post($url.'/get_server_list.php', array(
'user-agent' => 'WordPress/'.$wp_version.'; '.get_bloginfo('url'),
'body' => array(
'item' => urlencode(RS_PLUGIN_SLUG),
'version' => urlencode(RevSliderGlobals::SLIDER_REVISION)
),
'timeout' => 45
));
if(!is_wp_error($request)){
if($response = maybe_unserialize($request['body'])){
$list = json_decode($response, true);
update_option('revslider_servers', $list);
}
}/*else{
$url = $this->get_url('updates');
}
$count++;
}while($response === false && $count < 5);*/
update_option('revslider_server_refresh', time());
}
}
/**
* move the server list, to take the next server as the one currently seems unavailable
**/
public function move_server_list(){
$servers = $this->servers;
$a = array_shift($servers);
$servers[] = $a;
$this->servers = $servers;
update_option('revslider_servers', $servers);
}
}
?>
@@ -0,0 +1,84 @@
<?php
/**
* @author ThemePunch <info@themepunch.com>
* @link http://www.themepunch.com/
* @copyright 2015 ThemePunch
* @version 1.0.0
*/
if( !defined( 'ABSPATH') ) exit();
if(!class_exists('ThemePunch_Newsletter')) {
class ThemePunch_Newsletter {
protected static $remote_url = 'http://newsletter.themepunch.com/';
protected static $subscribe = 'subscribe.php';
protected static $unsubscribe = 'unsubscribe.php';
public function __construct(){
}
/**
* Subscribe to the ThemePunch Newsletter
* @since: 1.0.0
**/
public static function subscribe($email){
global $wp_version;
$request = wp_remote_post(self::$remote_url.self::$subscribe, array(
'user-agent' => 'WordPress/'.$wp_version.'; '.get_bloginfo('url'),
'timeout' => 15,
'body' => array(
'email' => urlencode($email)
)
));
if(!is_wp_error($request)) {
if($response = json_decode($request['body'], true)) {
if(is_array($response)) {
$data = $response;
return $data;
}else{
return false;
}
}
}
}
/**
* Unsubscribe to the ThemePunch Newsletter
* @since: 1.0.0
**/
public static function unsubscribe($email){
global $wp_version;
$request = wp_remote_post(self::$remote_url.self::$unsubscribe, array(
'user-agent' => 'WordPress/'.$wp_version.'; '.get_bloginfo('url'),
'timeout' => 15,
'body' => array(
'email' => urlencode($email)
)
));
if(!is_wp_error($request)) {
if($response = json_decode($request['body'], true)) {
if(is_array($response)) {
$data = $response;
return $data;
}else{
return false;
}
}
}
}
}
}
?>
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,328 @@
<?php
/**
* @author ThemePunch <info@themepunch.com>
* @link http://www.themepunch.com/
* @copyright 2015 ThemePunch
*/
if( !defined( 'ABSPATH') ) exit();
class RevSliderUpdate {
private $plugin_url = 'https://codecanyon.net/item/slider-revolution-responsive-wordpress-plugin/2751380';
private $remote_url = 'check_for_updates.php';
private $remote_url_info = 'revslider/revslider.php';
private $remote_temp_active = 'temp_activate.php';
private $plugin_slug = 'revslider';
private $plugin_path = 'revslider/revslider.php';
private $version;
private $plugins;
private $option;
public function __construct($version) {
$this->option = $this->plugin_slug . '_update_info';
$this->_retrieve_version_info();
$this->version = $version;
}
public function add_update_checks(){
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[$this->plugin_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;
}
protected function _check_updates() {
//reset saved options
//update_option($this->option, false);
$force_check = false;
if(isset($_GET['checkforupdates']) && $_GET['checkforupdates'] == 'true') $force_check = true;
// 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();
update_option('revslider-update-check', $last_check);
}
// Check for updates
if(time() - $last_check > 172800 || $force_check == 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() {
global $wp_version, $rslb;
$data = new stdClass;
// Build request
$code = get_option('revslider-code', '');
$validated = get_option('revslider-valid', 'false');
$stable_version = get_option('revslider-stable-version', '4.2');
$rattr = array(
'code' => urlencode($code),
'version' => urlencode(RevSliderGlobals::SLIDER_REVISION)
);
if($validated !== 'true' && version_compare(RevSliderGlobals::SLIDER_REVISION, $stable_version, '<')){ //We'll get the last stable only now!
$rattr['get_stable'] = 'true';
}
$done = false;
$count = 0;
do{
$url = $rslb->get_url('updates');
$request = wp_remote_post($url.'/'.$this->remote_url_info, array(
'user-agent' => 'WordPress/'.$wp_version.'; '.get_bloginfo('url'),
'body' => $rattr
));
$response_code = wp_remote_retrieve_response_code( $request );
if($response_code == 200){
$done = true;
}else{
$rslb->move_server_list();
}
$count++;
}while($done == false && $count < 5);
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($force_check = false) {
global $wp_version, $rslb;
$last_check = get_option('revslider-update-check-short');
if($last_check == false){ //first time called
$last_check = time();
update_option('revslider-update-check-short', $last_check);
}
// Check for updates
if(time() - $last_check > 172800 || $force_check == true){
update_option('revslider-update-check-short', time());
$purchase = (get_option('revslider-valid', 'false') == 'true') ? get_option('revslider-code', '') : '';
$done = false;
$count = 0;
do{
$url = $rslb->get_url('updates');
$response = wp_remote_post($url.'/'.$this->remote_url, array(
'user-agent' => 'WordPress/'.$wp_version.'; '.get_bloginfo('url'),
'body' => array(
'item' => urlencode(RS_PLUGIN_SLUG),
'version' => urlencode(RevSliderGlobals::SLIDER_REVISION),
'code' => urlencode($purchase)
),
'timeout' => 45
));
$response_code = wp_remote_retrieve_response_code( $response );
$version_info = wp_remote_retrieve_body( $response );
if($response_code == 200){
$done = true;
}else{
$rslb->move_server_list();
}
$count++;
}while($done == false && $count < 5);
if ( $response_code != 200 || is_wp_error( $version_info ) ) {
update_option('revslider-connection', false);
return false;
}else{
update_option('revslider-connection', true);
}
$version_info = json_decode($version_info);
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->dashboard)){
update_option('revslider-dashboard', $version_info->dashboard);
}
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);
}
}
}
if($force_check == true){ //force that the update will be directly searched
update_option('revslider-update-check', '');
}
}
public function add_temp_active_check($force = false){
global $wp_version, $rslb;
$last_check = get_option('revslider-activate-temp-short');
if($last_check == false){ //first time called
$last_check = time();
update_option('revslider-activate-temp-short', $last_check);
}
// Check for updates
if(time() - $last_check > 3600 || $force == true){
$done = false;
$count = 0;
do{
$url = $rslb->get_url('updates');
$response = wp_remote_post($url.'/'.$this->remote_temp_active, array(
'user-agent' => 'WordPress/'.$wp_version.'; '.get_bloginfo('url'),
'body' => array(
'item' => urlencode(RS_PLUGIN_SLUG),
'version' => urlencode(RevSliderGlobals::SLIDER_REVISION),
'code' => urlencode(get_option('revslider-code', ''))
),
'timeout' => 45
));
$response_code = wp_remote_retrieve_response_code( $response );
$version_info = wp_remote_retrieve_body( $response );
if($response_code == 200){
$done = true;
}else{
$rslb->move_server_list();
}
$count++;
}while($done == false && $count < 5);
if ( $response_code != 200 || is_wp_error( $version_info ) ) {
//wait, cant connect
}else{
if($version_info == 'valid'){
update_option('revslider-valid', 'true');
update_option('revslider-temp-active', 'false');
}elseif($version_info == 'temp_valid'){
//do nothing,
}elseif($version_info == 'invalid'){
//invalid, deregister plugin!
update_option('revslider-valid', 'false');
update_option('revslider-temp-active', 'false');
update_option('revslider-temp-active-notice', 'true');
}
}
$last_check = time();
update_option('revslider-activate-temp-short', $last_check);
}
}
}
/**
* old classname extends new one (old classnames will be obsolete soon)
* @since: 5.0
**/
class UniteUpdateClassRev extends RevSliderUpdate {}
?>
@@ -0,0 +1,171 @@
<?php
/**
* @author ThemePunch <info@themepunch.com>
* @link http://www.themepunch.com/
* @copyright 2015 ThemePunch
*/
if( !defined( 'ABSPATH') ) exit();
class RevSliderWooCommerce{
const ARG_REGULAR_PRICE_FROM = "reg_price_from";
const ARG_REGULAR_PRICE_TO = "reg_price_to";
const ARG_SALE_PRICE_FROM = "sale_price_from";
const ARG_SALE_PRICE_TO = "sale_price_to";
const ARG_IN_STOCK_ONLY = "instock_only";
const ARG_FEATURED_ONLY = "featured_only";
const META_REGULAR_PRICE = "_regular_price";
const META_SALE_PRICE = "_sale_price";
const META_SKU = "_sku"; //can be 'instock' or 'outofstock'
const META_STOCK = "_stock"; //can be 'instock' or 'outofstock'
const SORTBY_NUMSALES = "meta_num_total_sales";
const SORTBY_REGULAR_PRICE = "meta_num__regular_price";
const SORTBY_SALE_PRICE = "meta_num__sale_price";
const SORTBY_FEATURED = "meta__featured";
const SORTBY_SKU = "meta__sku";
const SORTBY_STOCK = "meta_num_stock";
/**
*
* return true / false if the woo commerce exists
*/
public static function isWooCommerceExists(){
if(class_exists( 'Woocommerce' ))
return(true);
return(false);
}
/**
* compare wc current version to given version
*/
public static function version_check( $version = '1.0' ) {
if(self::isWooCommerceExists()){
global $woocommerce;
if(version_compare($woocommerce->version, $version, '>=')){
return true;
}
}
return false;
}
/**
*
* get wc post types
*/
public static function getCustomPostTypes(){
$arr = array();
$arr["product"] = __("Product", 'revslider');
$arr["product_variation"] = __("Product Variation", 'revslider');
return($arr);
}
/**
*
* get price query
*/
private static function getPriceQuery($priceFrom, $priceTo, $metaTag){
if(empty($priceFrom))
$priceFrom = 0;
if(empty($priceTo))
$priceTo = 9999999999;
$query = array( 'key' => $metaTag,
'value' => array( $priceFrom, $priceTo),
'type' => 'numeric',
'compare' => 'BETWEEN');
return($query);
}
/**
*
* get meta query for filtering woocommerce posts.
*/
public static function getMetaQuery($args){
$regPriceFrom = RevSliderFunctions::getVal($args, self::ARG_REGULAR_PRICE_FROM);
$regPriceTo = RevSliderFunctions::getVal($args, self::ARG_REGULAR_PRICE_TO);
$salePriceFrom = RevSliderFunctions::getVal($args, self::ARG_SALE_PRICE_FROM);
$salePriceTo = RevSliderFunctions::getVal($args, self::ARG_SALE_PRICE_TO);
$inStockOnly = RevSliderFunctions::getVal($args, self::ARG_IN_STOCK_ONLY);
$featuredOnly = RevSliderFunctions::getVal($args, self::ARG_FEATURED_ONLY);
$arrQueries = array();
$tax_query = array();
//get regular price array
if(!empty($regPriceFrom) || !empty($regPriceTo)){
$arrQueries[] = self::getPriceQuery($regPriceFrom, $regPriceTo, self::META_REGULAR_PRICE);
}
//get sale price array
if(!empty($salePriceFrom) || !empty($salePriceTo)){
$arrQueries[] = self::getPriceQuery($salePriceFrom, $salePriceTo, self::META_SALE_PRICE);
}
if($inStockOnly == "on"){
$tax_query[] = array(
'taxonomy' => 'product_visibility',
'field' => 'name',
'terms' => 'outofstock',
'operator' => 'NOT IN',
);
}
if($featuredOnly == "on"){
$tax_query[] = array(
'taxonomy' => 'product_visibility',
'field' => 'name',
'terms' => 'featured',
);
}
$query = array();
if(!empty($arrQueries)){
$query = array("meta_query"=>$arrQueries);
}
if(!empty($tax_query)){
$query['tax_query'] = $tax_query;
}
return($query);
}
/**
*
* get sortby function including standart wp sortby array
*/
public static function getArrSortBy(){
$arrSortBy = array();
$arrSortBy[self::SORTBY_REGULAR_PRICE] = __("Regular Price", 'revslider');
$arrSortBy[self::SORTBY_SALE_PRICE] = __("Sale Price", 'revslider');
$arrSortBy[self::SORTBY_NUMSALES] = __("Number Of Sales", 'revslider');
$arrSortBy[self::SORTBY_FEATURED] = __("Featured Products", 'revslider');
$arrSortBy[self::SORTBY_SKU] = __("SKU", 'revslider');
$arrSortBy[self::SORTBY_STOCK] = __("Stock Quantity", 'revslider');
return($arrSortBy);
}
} //end of the class
?>
@@ -0,0 +1,226 @@
<?php
/**
* @author ThemePunch <info@themepunch.com>
* @link http://www.themepunch.com/
* @copyright 2015 ThemePunch
*/
if( !defined( 'ABSPATH') ) exit();
class RevSliderWpml{
private static $sitepress;
/**
*
* true / false if the wpml plugin exists
*/
public static function isWpmlExists(){
return did_action( 'wpml_loaded' );
}
/**
*
* valdiate that wpml exists
*/
private static function validateWpmlExists(){
if(!self::isWpmlExists())
RevSliderFunctions::throwError("The wpml plugin is not activated");
}
/**
*
* get languages array
*/
public static function getArrLanguages($getAllCode = true){
self::validateWpmlExists();
$arrLangs = apply_filters( 'wpml_active_languages', array() );
$response = array();
if($getAllCode == true)
$response["all"] = __("All Languages",'revslider');
foreach($arrLangs as $code=>$arrLang){
$name = $arrLang["native_name"];
$response[$code] = $name;
}
return($response);
}
/**
*
* get assoc array of lang codes
*/
public static function getArrLangCodes($getAllCode = true){
$arrCodes = array();
if($getAllCode == true)
$arrCodes["all"] = "all";
self::validateWpmlExists();
$arrLangs = apply_filters( 'wpml_active_languages', array() );
foreach($arrLangs as $code=>$arr){
$arrCodes[$code] = $code;
}
return($arrCodes);
}
/**
*
* check if all languages exists in the given langs array
*/
public static function isAllLangsInArray($arrCodes){
$arrAllCodes = self::getArrLangCodes();
$diff = array_diff($arrAllCodes, $arrCodes);
return(empty($diff));
}
/**
*
* get langs with flags menu list
* @param $props
*/
public static function getLangsWithFlagsHtmlList($props = "",$htmlBefore = ""){
$arrLangs = self::getArrLanguages();
if(!empty($props))
$props = " ".$props;
$html = "<ul".$props.">"."\n";
$html .= $htmlBefore;
foreach($arrLangs as $code=>$title){
$urlIcon = self::getFlagUrl($code);
/* NEW:
foreach($arrLangs as $lang){
$code = $lang['language_code'];
$title = $lang['native_name'];
$urlIcon = $lang['country_flag_url'];
*/
$html .= "<li data-lang='".$code."' class='item_lang'><a data-lang='".$code."' href='javascript:void(0)'>"."\n";
$html .= "<img src='".$urlIcon."'/> $title"."\n";
$html .= "</a></li>"."\n";
}
$html .= "</ul>";
return($html);
}
/**
* get flag url
*/
public static function getFlagUrl($code){
self::validateWpmlExists();
if ( empty( $code ) || $code == "all" ) {
$url = RS_PLUGIN_URL.'admin/assets/images/icon-all.png'; // NEW: 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';
// NEW: $url = ICL_PLUGIN_URL . '/res/img/icon16.png';
}
return($url);
}
/**
*
* get language title by code
*/
public static function getLangTitle($code){
if($code == "all")
return(__("All Languages", 'revslider'));
$default_language = apply_filters( 'wpml_default_language', null );
return apply_filters( 'wpml_translated_language_name', '', $code, $default_language );
}
/**
*
* get current language
*/
public static function getCurrentLang(){
self::validateWpmlExists();
if ( is_admin() ) {
return apply_filters( 'wpml_default_language', null );
}
return apply_filters( 'wpml_current_language', null );
return($lang);
}
public static function svg_val_filter( $svg_val ) {
$current_language = apply_filters( 'wpml_current_language', null );
if ( is_array( $svg_val ) && array_key_exists( 'src', $svg_val )
&& $current_language != apply_filters( 'wpml_default_language', null )
&& apply_filters( 'wpml_setting', null, 'language_negotiation_type' ) == 2
) {
$svg_val['src'] = self::convert_url( $svg_val['src'], $current_language );
}
return $svg_val;
}
public static function convert_url( $url, $language ){
if ( self::$sitepress instanceof SitePress ) {
$url = self::$sitepress->convert_url( $url, $language );
}
return $url;
}
private static function set_sitepress() {
if ( ! self::$sitepress instanceof SitePress ) {
global $sitepress;
self::$sitepress = $sitepress;
}
}
public static function add_hooks() {
if ( self::isWpmlExists() ) {
self::set_sitepress();
add_filter( 'revslider_svg_val', array( 'RevSliderWpml', 'svg_val_filter' ) );
}
}
}
/**
* old classname extends new one (old classnames will be obsolete soon)
* @since: 5.0
**/
class UniteWpmlRev extends RevSliderWpml {}
?>