first commit

This commit is contained in:
2024-12-17 13:43:22 +01:00
commit 8e6cd8b410
21292 changed files with 3514826 additions and 0 deletions

View File

@@ -0,0 +1,271 @@
<?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["view"]) && $_GET["view"]=="rev_addon-admin-display"){
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["view"]) && $_GET["view"]=="rev_addon-admin-display"){
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' => rev_site_admin_url()."?route=extension/module/revslideropencart/ajaxexecute&token=".sds_get_oc_token(),
'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() {
if(isset($_REQUEST['plugin'])){
update_option($_REQUEST['plugin'],'active');
$hook_register = get_option('hook_register', array());
if(!empty($hook_register)){
$hook_register = json_decode($hook_register,true);
}
if(isset($hook_register[$_REQUEST['plugin']])){
$hook_info = $hook_register[$_REQUEST['plugin']];
if(is_array($hook_register[$_REQUEST['plugin']])){
call_user_func_array(array($hook_info[0],$hook_info[1]),array());
}else{
require_once(RS_PLUGIN_ADDONS_PATH . $_REQUEST['plugin']);
call_user_func_array($hook_register[$_REQUEST['plugin']],array());
}
}
die( '1' );
}
else{
die( '0' );
}
}
/**
* 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'] );
update_option($_REQUEST['plugin'],'deactive');
$hook_deregister = get_option('hook_deregister', array());
if(!empty($hook_deregister)){
$hook_deregister = json_decode($hook_deregister,true);
}
if(isset($hook_deregister[$_REQUEST['plugin']])){
$hook_info = $hook_deregister[$_REQUEST['plugin']];
if(is_array($hook_deregister[$_REQUEST['plugin']])){
call_user_func_array(array($hook_info[0],$hook_info[1]),array());
}else{
require_once(RS_PLUGIN_ADDONS_PATH . $_REQUEST['plugin']);
call_user_func_array($hook_deregister[$_REQUEST['plugin']],array());
}
}
die( '1' );
}
else{
die( '0' );
}
// }
// else {
// die( '-1' );
// }
}
/**
* Install Add-On/Plugin
*
* @since 1.0.0
*/
public function install_plugin() {
if(isset($_REQUEST['plugin'])){
global $wp_version;
$plugin_slug = basename($_REQUEST['plugin']);
$plugin_result = false;
$plugin_message = 'UNKNOWN';
if(0 !== strpos($plugin_slug, 'revslider-')) die( '-1' );
$code = get_option('revslider-code', '');
//$url = 'http://updates.themepunch.tools/revslider-prestashop/addons/'.$plugin_slug.'/download.php?code='.$code.'&type='.$plugin_slug;
$url = 'http://revapi.smartdatasoft.net/v5/call/index.php?code='.$code.'&type='.$plugin_slug;
$get = wp_remote_post($url, array(
'user-agent' => 'Prestashop/'.$wp_version.'; '.get_bloginfo('url'),
'body' => '',
'timeout' => 400
));
if( $get == null || $get["info"]["http_code"] != "200" ){
$plugin_message = 'FAILED TO DOWNLOAD';
}else{
// var_dump($get);die();
$plugin_message = 'ZIP is there';
$upload_dir = wp_upload_dir();
$file = $upload_dir. '/revslider/templates/' . $plugin_slug . '.zip';
//@mkdir(dirname($file));
@mkdir(dirname($file), 0777, true);
$ret = @file_put_contents( $file, $get['body'] );
// WP_Filesystem();
// global $wp_filesystem;
$upload_dir = wp_upload_dir();
//$d_path = WP_PLUGIN_DIR;
$d_path = RS_PLUGIN_PATH . '/addons/';
if(class_exists("ZipArchive")){
//var_dump($d_path);var_dump($exactfilepath);die();
$zip = new ZipArchive;
$unzipfile = $zip->open($file, ZIPARCHIVE::CREATE);
$zip->extractTo($d_path);
}
@unlink($file);
die('1');
}
//$result = activate_plugin( $plugin_slug.'/'.$plugin_slug.'.php' );
}
else{
die( '0' );
}
}
} // END of class

View File

@@ -0,0 +1,175 @@
<?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(!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 ) {
if ( ! $url || ( ! $width && ! $height ) ) return false;
$upload_dir = UniteFunctionsWPRev::getUrlUploads();
$upload_url = uploads_url();
$http_prefix = "http://";
$https_prefix = "https://";
if(!strncmp($url,$https_prefix,strlen($https_prefix))){
$upload_url = str_replace($http_prefix,$https_prefix,$upload_url);
}
elseif(!strncmp($url,$http_prefix,strlen($http_prefix))){
$upload_url = str_replace($https_prefix,$http_prefix,$upload_url);
}
if ( false === strpos( $url, $upload_url ) ) return false;
$rel_path = str_replace( $upload_url, '', $url );
$img_path = $upload_dir . $rel_path;
if ( ! file_exists( $img_path ) or ! getimagesize( $img_path ) ) return false;
$info = pathinfo( $img_path );
$ext = $info['extension'];
list( $orig_w, $orig_h ) = getimagesize( $img_path );
$dims = image_resize_dimensions( $orig_w, $orig_h, $width, $height, $crop );
$dst_w = $dims[4];
$dst_h = $dims[5];
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 {
$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 ) ) ) {
return false;
}
elseif ( file_exists( $destfilename ) && getimagesize( $destfilename ) ) {
$img_url = "{$upload_url}{$dst_rel_path}-{$suffix}.{$ext}";
}
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;
}
}
}
if ( true === $upscale ) remove_filter( 'image_resize_dimensions', array( $this, 'aq_upscale' ) );
if ( $single ) {
$image = $img_url;
} else {
$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 );
}
}

View File

@@ -0,0 +1,735 @@
<?php
/**
* @author ThemePunch <info@themepunch.com>
* @link http://www.themepunch.com/
* @copyright 2015 ThemePunch
*/
if( !defined( 'ABSPATH') ) exit();
class RevSliderBaseAdmin extends RevSliderBase {
public static $master_view;
public 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','revaddon','global_settings','revslider_navigation','ps_layout');
/**
*
* 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
// self::addAction('admin_menu', array('RevSliderBaseAdmin', 'addAdminMenu'));
$this->addAdminMenu();
// add_action('add_meta_boxes', array('RevSliderBaseAdmin', 'onAddMetaboxes'));
// add_action('save_post', array('RevSliderBaseAdmin', 'onSavePost'));
//if not inside plugin don't continue
//
// $RevSliderAdmin = new RevSliderAdmin();
// $this->addCommonScripts();
// $RevSliderAdmin->onAddScripts();
//
//if($this->isInsidePlugin() == true){
// self::addAction('admin_enqueue_scripts', array('RevSliderBaseAdmin', 'addCommonScripts'));
// self::addAction('admin_enqueue_scripts', array('RevSliderAdmin', 'onAddScripts'));
// }else{
// self::addAction('admin_enqueue_scripts', array('RevSliderBaseAdmin', 'addGlobalScripts'));
// }
//will have to uncomment it
//
// var_dump('sdfsdfsdfsdfd');
//a must event for any admin. call onActivate function.
// $this->addEvent_onActivate();
// $this->addAction_onActivate();
//
self::addActionAjax('show_image', 'onShowImage');
}
protected static function get_javascript_multilanguage(){
$lang = array(
'wrong_alias' => __('-- wrong alias -- ', 'revslider'),
'nav_bullet_arrows_to_none' => __('Navigation Bullets and Arrows are now set to none.', 'revslider'),
'create_template' => __('Create Template', 'revslider'),
'really_want_to_delete' => __('Do you really want to delete', 'revslider'),
'sure_to_replace_urls' => __('Are you sure to replace the urls?', 'revslider'),
'set_settings_on_all_slider' => __('Set selected settings on all Slides of this Slider? (This will be saved immediately)', 'revslider'),
'select_slide_img' => __('Select Slide Image', 'revslider'),
'select_layer_img' => __('Select Layer Image', 'revslider'),
'select_slide_video' => __('Select Slide Video', 'revslider'),
'show_slide_opt' => __('Show Slide Options', 'revslider'),
'hide_slide_opt' => __('Hide Slide Options', 'revslider'),
'close' => __('Close', 'revslider'),
'really_update_global_styles' => __('Really update global styles?', 'revslider'),
'really_clear_global_styles' => __('This will remove all Global Styles, continue?', 'revslider'),
'global_styles_editor' => __('Global Styles Editor', 'revslider'),
'select_image' => __('Select Image', 'revslider'),
'video_not_found' => __('No Thumbnail Image Set on Video / Video Not Found / No Valid Video ID', 'revslider'),
'handle_at_least_three_chars' => __('Handle has to be at least three character long', 'revslider'),
'really_change_font_sett' => __('Really change font settings?', 'revslider'),
'really_delete_font' => __('Really delete font?', 'revslider'),
'class_exist_overwrite' => __('Class already exists, overwrite?', 'revslider'),
'class_must_be_valid' => __('Class must be a valid CSS class name', 'revslider'),
'really_overwrite_class' => __('Really overwrite Class?', 'revslider'),
'relly_delete_class' => __('Really delete Class', 'revslider'),
'class_this_cant_be_undone' => __('? This can\'t be undone!', 'revslider'),
'this_class_does_not_exist' => __('This class does not exist.', 'revslider'),
'making_changes_will_probably_overwrite_advanced' => __('Making changes to these settings will probably overwrite advanced settings. Continue?', 'revslider'),
'select_static_layer_image' => __('Select Static Layer Image', 'revslider'),
'select_layer_image' => __('Select Layer Image', 'revslider'),
'really_want_to_delete_all_layer' => __('Do you really want to delete all the layers?', 'revslider'),
'layer_animation_editor' => __('Layer Animation Editor', 'revslider'),
'animation_exists_overwrite' => __('Animation already exists, overwrite?', 'revslider'),
'really_overwrite_animation' => __('Really overwrite animation?', 'revslider'),
'default_animations_cant_delete' => __('Default animations can\'t be deleted', 'revslider'),
'must_be_greater_than_start_time' => __('Must be greater than start time', 'revslider'),
'sel_layer_not_set' => __('Selected layer not set', 'revslider'),
'edit_layer_start' => __('Edit Layer Start', 'revslider'),
'edit_layer_end' => __('Edit Layer End', 'revslider'),
'default_animations_cant_rename' => __('Default Animations can\'t be renamed', 'revslider'),
'anim_name_already_exists' => __('Animationname already existing', 'revslider'),
'css_name_already_exists' => __('CSS classname already existing', 'revslider'),
'css_orig_name_does_not_exists' => __('Original CSS classname not found', 'revslider'),
'enter_correct_class_name' => __('Enter a correct class name', 'revslider'),
'class_not_found' => __('Class not found in database', 'revslider'),
'css_name_does_not_exists' => __('CSS classname not found', 'revslider'),
'delete_this_caption' => __('Delete this caption? This may affect other Slider', 'revslider'),
'this_will_change_the_class' => __('This will update the Class with the current set Style settings, this may affect other Sliders. Proceed?', 'revslider'),
'unsaved_changes_will_not_be_added' => __('Template will have the state of the last save, proceed?', 'revslider'),
'please_enter_a_slide_title' => __('Please enter a Slide title', 'revslider'),
'please_wait_a_moment' => __('Please Wait a Moment', 'revslider'),
'copy_move' => __('Copy / Move', 'revslider'),
'preset_loaded' => __('Preset Loaded', 'revslider'),
'add_bulk_slides' => __('Add Bulk Slides', 'revslider'),
'select_image' => __('Select Image', 'revslider'),
'arrows' => __('Arrows', 'revslider'),
'bullets' => __('Bullets', 'revslider'),
'thumbnails' => __('Thumbnails', 'revslider'),
'tabs' => __('Tabs', 'revslider'),
'delete_navigation' => __('Delete this Navigation?', 'revslider'),
'could_not_update_nav_name' => __('Navigation name could not be updated', 'revslider'),
'name_too_short_sanitize_3' => __('Name too short, at least 3 letters between a-zA-z needed', 'revslider'),
'nav_name_already_exists' => __('Navigation name already exists, please choose a different name', 'revslider'),
'remove_nav_element' => __('Remove current element from Navigation?', 'revslider'),
'create_this_nav_element' => __('This navigation element does not exist, create one?', 'revslider'),
'overwrite_animation' => __('Overwrite current animation?', 'revslider'),
'cant_modify_default_anims' => __('Default animations can\'t be changed', 'revslider'),
'anim_with_handle_exists' => __('Animation already existing with given handle, please choose a different name.', 'revslider'),
'really_delete_anim' => __('Really delete animation:', 'revslider'),
'this_will_reset_navigation' => __('This will reset the navigation, continue?', 'revslider'),
'preset_name_already_exists' => __('Preset name already exists, please choose a different name', 'revslider'),
'delete_preset' => __('Really delete this preset?', 'revslider'),
'update_preset' => __('This will update the preset with the current settings. Proceed?', 'revslider'),
'maybe_wrong_yt_id' => __('No Thumbnail Image Set on Video / Video Not Found / No Valid Video ID', 'revslider'),
'preset_not_found' => __('Preset not found', 'revslider'),
'cover_image_needs_to_be_set' => __('Cover Image need to be set for videos', 'revslider'),
'remove_this_action' => __('Really remove this action?', 'revslider'),
'layer_action_by' => __('Layer is triggered by ', 'revslider'),
'due_to_action' => __(' due to action: ', 'revslider'),
'layer' => __('layer:', 'revslider'),
'start_layer_in' => __('Start Layer in animation', 'revslider'),
'start_layer_out' => __('Start Layer out animation', 'revslider'),
'start_video' => __('Start Media', 'revslider'),
'stop_video' => __('Stop Media', 'revslider'),
'mute_video' => __('Mute Media', 'revslider'),
'unmute_video' => __('Unmute Media', 'revslider'),
'toggle_layer_anim' => __('Toggle Layer Animation', 'revslider'),
'toggle_video' => __('Toggle Media', 'revslider'),
'toggle_mute_video' => __('Toggle Mute Media', 'revslider'),
'toggle_global_mute_video' => __('Toggle Mute All Media', 'revslider'),
'last_slide' => __('Last Slide', 'revslider'),
'simulate_click' => __('Simulate Click', 'revslider'),
'togglefullscreen' => __('Toggle FullScreen', 'revslider'),
'gofullscreen' => __('Go FullScreen', 'revslider'),
'exitfullscreen' => __('Exit FullScreen', 'revslider'),
'toggle_class' => __('Toogle Class', 'revslider'),
'copy_styles_to_hover_from_idle' => __('Copy hover styles to idle?', 'revslider'),
'copy_styles_to_idle_from_hover' => __('Copy idle styles to hover?', 'revslider'),
'select_at_least_one_device_type' => __('Please select at least one device type', 'revslider'),
'please_select_first_an_existing_style' => __('Please select an existing Style Template', 'revslider'),
'cant_remove_last_transition' => __('Can not remove last transition!', 'revslider'),
'name_is_default_animations_cant_be_changed' => __('Given animation name is a default animation. These can not be changed.', 'revslider'),
'override_animation' => __('Animation exists, override existing animation?', 'revslider'),
'this_feature_only_if_activated' => __('This feature is only available if you activate Slider Revolution for this installation', 'revslider'),
'unsaved_data_will_be_lost_proceed' => __('Unsaved data will be lost, proceed?', 'revslider'),
'delete_user_slide' => __('This will delete this Slide Template, proceed?', 'revslider'),
'is_loading' => __('is Loading...', 'revslider'),
'google_fonts_loaded' => __('Google Fonts Loaded', 'revslider'),
'delete_layer' => __('Delete Layer?', 'revslider'),
'this_template_requires_version' => __('This template requires at least version', 'revslider'),
'of_slider_revolution' => __('of Slider Revolution to work.', 'revslider'),
'slider_revolution_shortcode_creator' => __('Slider Revolution Shortcode Creator', 'revslider'),
'slider_informations_are_missing' => __('Slider informations are missing!', 'revslider'),
'shortcode_generator' => __('Shortcode Generator', 'revslider'),
'please_add_at_least_one_layer' => __('Please add at least one Layer.', 'revslider'),
'choose_image' => __('Choose Image', 'revslider'),
'shortcode_parsing_successfull' => __('Shortcode parsing successfull. Items can be found in step 3', 'revslider'),
'shortcode_could_not_be_correctly_parsed' => __('Shortcode could not be parsed.', 'revslider'),
'background_video' => __('Background Video', 'revslider'),
'active_video' => __('Video in Active Slide', 'revslider'),
'empty_data_retrieved_for_slider' => __('Data could not be fetched for selected Slider', 'revslider'),
'import_selected_layer' => __('Import Selected Layer?', 'revslider'),
'import_all_layer_from_actions' => __('Layer Imported! The Layer has actions which include other Layers. Import all connected layers?', 'revslider'),
'not_available_in_demo' => __('Not available in Demo Mode', 'revslider'),
'leave_not_saved' => __('By leaving now, all changes since the last saving will be lost. Really leave now?', 'revslider'),
'static_layers' => __('--- Static Layers ---', 'revslider'),
'objects_only_available_if_activated' => __('Only available if plugin is activated', 'revslider'),
'download_install_takes_longer' => __('Download/Install takes longer than usual, please wait', 'revslider'),
'download_failed_check_server' => __('<div class=\'import_failure\'>Download/Install seems to have failed.</div><br>Please check your server <span class=\'import_failure\'>download speed</span> and if the server can programatically connect to <span class=\'import_failure\'>http://templates.themepunch.com</span><br><br>', 'revslider'),
'aborting_import' => __('<b>Aborting Import...</b>', 'revslider'),
'create_draft' => __('Creating Draft Page...', 'revslider'),
'draft_created' => __('Draft Page created. Popup will open', 'revslider'),
'draft_not_created' => __('Draft Page could not be created.', 'revslider'),
'slider_import_success_reload' => __('Slider import successful', 'revslider'),
'save_changes' => __('Save Changes?', 'revslider')
);
return $lang;
}
/**
*
* 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
*/
public static function setMasterView($masterView){
self::$master_view = $masterView;
}
/**
*
* inlcude some view file
*/
public 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;
case 'revaddon':
$view = 'rev_addon-admin-display';
break;
case 'revslider_navigation':
$view = 'navigation-editor';
break;
case 'ps_layout':
$view = 'ps_layout';
break;
case 'global_settings':
$view = 'global-settings';
break;
}
$viewFilepath = self::$path_views.$view.".php";
// var_dump($viewFilepath);die();
RevSliderFunctions::validateFilepath($viewFilepath,"View");
require $viewFilepath;
}
}catch (Exception $e){
echo "<br><br>View (".$view.") Error: <b>".$e->getMessage()."</b>";
}
}
/**
* require some template from "templates" folder
*/
protected static function getPathTemplate($templateName){
$pathTemplate = self::$path_templates.$templateName.'.php';
RevSliderFunctions::validateFilepath($pathTemplate,'Template');
//die($pathTemplate);
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){
if($menu["title"] == 'Slider Revolution'){
// die('working fine');
}
$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){
//die($title);
self::$arrMenuPages[] = array("title"=>$title,"pageFunction"=>$pageFunctionName);
//var_dump(self::$arrMenuPages);die();
}
/**
*
* 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;
$base_url = RevLoader::getConstants('revslider_core_url');
$link = $base_url.$params.'&page=revslider';
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 {}
?>

View File

@@ -0,0 +1,35 @@
<?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);
//die('kakakkakak');
//add_action('wp_enqueue_scripts', array('RevSliderFront', 'onAddScripts'));
RevSliderFront::onAddScripts();
}
}
/**
* old classname extends new one (old classnames will be obsolete soon)
* @since: 5.0
**/
class UniteBaseFrontClassRev extends RevSliderBaseFront {}
?>

View File

@@ -0,0 +1,978 @@
<?php
/**
* @author ThemePunch <info@themepunch.com>
* @link http://www.themepunch.com/
* @copyright 2015 ThemePunch
*/
class RevSliderBase {
protected static $wpdb;
protected static $table_prefix;
protected static $t;
public static $static_shortcode_tags;
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;
protected static $actions = array();
protected static $admin_scripts = array();
protected static $front_scripts = array();
protected static $admin_styles = array();
protected static $front_styles = array();
public static $local_scripts = array();
public static $local_scripts_footer =array();
/**
*
* the constructor
*/
public function __construct($t){
$wpdb = rev_db_class::rev_db_instance();
//self::$is_multisite = RevSliderFunctionsWP::isMultisite();
self::$wpdb = $wpdb;
self::$table_prefix = DB_PREFIX;
self::$t = $t;
self::$url_ajax = RevLoader::getConstants('url_ajax');
//self::$url_ajax_actions = self::$url_ajax . "?action=revslider_ajax_action";
self::$url_ajax_actions = RevLoader::getConstants('url_ajax_actions');
self::$url_ajax_showimage = RevLoader::getConstants('url_ajax_showimage');
self::$path_views = RS_PLUGIN_PATH."/admin/views/";
self::$path_templates = self::$path_views."/templates/";
//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) );
// }
protected static function addAction($action,$eventFunction){
//add_action( $action, array(self::$t, $eventFunction) );
if(!isset(self::$actions[$action])) {
self::$actions[$action] = array();
self::$actions[$action][0] = $eventFunction;
}
else
self::$actions[$action][count(self::$actions[$action])] = $eventFunction;
}
public static function parse ($str)
{
return self::do_shortcode($str);
}
public static function get_shortcode_regex() {
$tagnames = array_keys(self::$static_shortcode_tags);
$tagregexp = join( '|', array_map('preg_quote', $tagnames) );
// WARNING! Do not change this regex without changing do_shortcode_tag() and strip_shortcode_tag()
// Also, see shortcode_unautop() and shortcode.js.
return
'\\[' // Opening bracket
. '(\\[?)' // 1: Optional second opening bracket for escaping shortcodes: [[tag]]
. "($tagregexp)" // 2: Shortcode name
. '(?![\\w-])' // Not followed by word character or hyphen
. '(' // 3: Unroll the loop: Inside the opening shortcode tag
. '[^\\]\\/]*' // Not a closing bracket or forward slash
. '(?:'
. '\\/(?!\\])' // A forward slash not followed by a closing bracket
. '[^\\]\\/]*' // Not a closing bracket or forward slash
. ')*?'
. ')'
. '(?:'
. '(\\/)' // 4: Self closing tag ...
. '\\]' // ... and closing bracket
. '|'
. '\\]' // Closing bracket
. '(?:'
. '(' // 5: Unroll the loop: Optionally, anything between the opening and closing shortcode tags
. '[^\\[]*+' // Not an opening bracket
. '(?:'
. '\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing shortcode tag
. '[^\\[]*+' // Not an opening bracket
. ')*+'
. ')'
. '\\[\\/\\2\\]' // Closing shortcode tag
. ')?'
. ')'
. '(\\]?)'; // 6: Optional second closing brocket for escaping shortcodes: [[tag]]
}
public static function shortcode_parse_atts($text) {
$atts = array();
$pattern = '/(\w+)\s*=\s*"([^"]*)"(?:\s|$)|(\w+)\s*=\s*\'([^\']*)\'(?:\s|$)|(\w+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/';
$text = preg_replace("/[\x{00a0}\x{200b}]+/u", " ", $text);
if ( preg_match_all($pattern, $text, $match, PREG_SET_ORDER) ) {
foreach ($match as $m) {
if (!empty($m[1]))
$atts[strtolower($m[1])] = stripcslashes($m[2]);
elseif (!empty($m[3]))
$atts[strtolower($m[3])] = stripcslashes($m[4]);
elseif (!empty($m[5]))
$atts[strtolower($m[5])] = stripcslashes($m[6]);
elseif (isset($m[7]) and strlen($m[7]))
$atts[] = stripcslashes($m[7]);
elseif (isset($m[8]))
$atts[] = stripcslashes($m[8]);
}
} else {
$atts = ltrim($text);
}
return $atts;
}
public static function do_shortcode_tag( $m ) {
$shortcode_tags = self::$static_shortcode_tags;
// allow [[foo]] syntax for escaping a tag
if ( $m[1] == '[' && $m[6] == ']' ) {
return substr($m[0], 1, -1);
}
$tag = $m[2];
$attr = self::shortcode_parse_atts( $m[3] );
if ( isset( $m[5] ) ) {
// enclosing tag - extra parameter
return $m[1] . call_user_func( $shortcode_tags[$tag], $attr, $m[5], $tag ) . $m[6];
} else {
// self-closing tag
return $m[1] . call_user_func( $shortcode_tags[$tag], $attr, null, $tag ) . $m[6];
}
}
public static function do_shortcode($content) {
//$this->shortcodes = self::$static_shortcode_tags;
$shortcode_tags = self::$static_shortcode_tags;
if (empty($shortcode_tags) || !is_array($shortcode_tags))
return $content;
$pattern = self::get_shortcode_regex();
return preg_replace_callback( "/$pattern/s", array(__CLASS__,'do_shortcode_tag'), $content );
}
/**
*
* 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();
}
}
public static function add_shortcode($tag,$func){
self::$static_shortcode_tags[$tag] = $func;
}
public static function wp_enqueue_style($scriptName, $src = '' , $deps = array(),$ver = '1.0',$media = 'all', $noscript)
{
if(isset(sdsconfig::$registered_style[$scriptName])){
$src = sdsconfig::$registered_style[$scriptName];
$deps = array();
}
//global $admin_styles, $front_styles;
$cadm = count(self::$admin_styles) ? count(self::$admin_styles): 0;
$cfrt = count(self::$front_styles) ? count(self::$front_styles): 0;
if(is_array($scriptName))
$deps = $scriptName;
if(is_admin()){
self::$admin_styles[$cadm] = new stdClass();
//self::$admin_styles[$cadm]->deps = load_additional_scripts($deps, self::$admin_styles);
//self::$admin_styles[$cadm]->footer = false;
if(is_string($scriptName))
self::$admin_styles[$cadm]->css = "<link rel='stylesheet' id='{$scriptName}' media='{$media}' href='{$src}' type='text/css' />";
if($noscript)
self::$admin_styles[$cadm]->css = "<noscript>{self::$admin_styles[$cadm]->css}</noscript>";
}
else{
self::$front_styles[$cfrt] = new stdClass();
if(is_string($scriptName))
self::$front_styles[$cfrt]->css = "<link rel='stylesheet' id='{$scriptName}' media='{$media}' href='{$src}' type='text/css' />";
}
}
public static function wp_enqueue_script($scriptName, $src = '' , $deps = array(),$ver = '1.0',$in_footer = false)
{
if(isset(sdsconfig::$registered_script[$scriptName])){
$src = sdsconfig::$registered_script[$scriptName];
$deps = array();
}
//global $admin_scripts, $front_scripts;
$cadm = count(self::$admin_scripts) ? count(self::$admin_scripts): 0;
$cfrt = count(self::$front_scripts) ? count(self::$front_scripts): 0;
if(is_array($scriptName))
$deps = $scriptName;
if(is_admin()){
self::$admin_scripts[$cadm] = new stdClass();
self::$admin_scripts[$cadm]->deps = load_additional_scripts($deps, self::$admin_scripts);
self::$admin_scripts[$cadm]->footer = $in_footer;
if(is_string($scriptName) && !empty($src))
self::$admin_scripts[$cadm]->script = "<script id='{$scriptName}' src='{$src}' type='text/javascript'></script>";
else{
$scriptArr = is_array($scriptName)? $scriptName : array($scriptName);
$getScripts = load_additional_scripts($scriptArr, self::$admin_scripts);
if(!empty($getScripts))
foreach($getScripts as $id => $src):
self::$admin_scripts[$cadm]->script = "<script id='{$id}' src='".script_url().$src."' type='text/javascript'></script>";
self::$admin_scripts[$cadm]->footer = $in_footer;
$cadm++;
endforeach;
}
}
else{
self::$front_scripts[$cfrt] = new stdClass();
self::$front_scripts[$cadm]->deps = load_additional_scripts($deps, self::$front_scripts);
self::$front_scripts[$cfrt]->footer = $in_footer;
if(is_string($scriptName) && !empty($src))
{
self::$front_scripts[$cfrt]->script = "<script id='{$scriptName}' src='{$src}' type='text/javascript'></script>";
} else{
$scriptArr = is_array($scriptName)? $scriptName : array($scriptName);
$getScripts = load_additional_scripts($scriptArr, self::$front_scripts);
if(!empty($getScripts))
foreach($getScripts as $id => $src):
self::$front_scripts[$cadm]->script = "<script id='{$id}' src='".script_url().$src."' type='text/javascript'></script>";
self::$front_scripts[$cadm]->footer = $in_footer;
$cadm++;
endforeach;
}
}
// var_dump(self::$admin_scripts);
}
/**
* 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) {
return false;//forcefully making it false
//global $wpdb;
$wpdb = rev_db_class::rev_db_instance();
$filename = str_replace(wp_upload_url(), '', $image_url);
$attachment_id = 0;
$table_name = RevSliderGlobals::$table_attachment_images;
//var_dump($table_name);die();
$attachment_id = $wpdb->get_var("SELECT ID FROM {$table_name} WHERE file_name='{$filename}'");
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();
$upload_url = wp_upload_url();
$path = $upload_dir.'/revslider/assets/svg/';
$url = $upload_url.'/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 );
$zimage = file_exists( $d_path.'images/'.$image );
if(!$zimage){
$zimage = file_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_url = wp_upload_url();
$cont_url = $upload_url;
$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;
}
}
public static function rev_head()
{
$allLocalScripts = "<script type='text/javascript'>";
foreach(self::$local_scripts as $var_name => $scripts_each){
if(is_array($scripts_each)){
$value = json_encode($scripts_each);
}else{
$value = '"'.$scripts_each.'"';
}
$allLocalScripts .= "var ".$var_name."= ".$value.";";
}
$allLocalScripts .= "</script>";
echo $allLocalScripts;
foreach(RevLoader::$admin_styles as $style){
echo "<link rel='stylesheet' href='{$style}' type='text/css' media='all'>";
}
foreach(RevLoader::$admin_scripts as $script){
echo "<script type='text/javascript' src='{$script}'></script>";
}
}
public static function rev_footer()
{
// global self::$admin_scripts, $front_scripts ;
if(is_admin() && !empty(self::$admin_scripts)){
foreach(self::$admin_scripts as $script):
if(!$script->footer) continue;
self::enqueue_script($script);
endforeach;
}
elseif(!is_admin() && !empty(self::$front_scripts)){
foreach(self::$front_scripts as $script):
if(!$script->footer) continue;
self::enqueue_script($script);
endforeach;
}
}
public static function enqueue_css($script)
{
var_dump('ok');
echo "\t\n";
if(isset($script->css))
echo $script->css;
}
public static function enqueue_script($script)
{
if(!empty($script->deps)){
foreach($script->deps as $key=>$src):
echo "<script id='{$key}' type='text/javascript' src='".script_url().$src."'></script>";
endforeach;
}
echo "\t\n";
if(isset($script->script))
echo $script->script;
}
}
/**
* old classname extends new one (old classnames will be obsolete soon)
* @since: 5.0
**/
class UniteBaseClassRev extends RevSliderBase {}
?>

View File

@@ -0,0 +1,373 @@
<?php
/**
* @author ThemePunch <info@themepunch.com>
* @link http://www.themepunch.com/
* @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];
}
/**
* TODO: What does it do?
* @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;
}
/**
* TODO: What does it do?
* @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 {
$color = TPColorpicker::rgbValues($color, 3);
return TPColorpicker::rgbaString($color[0], $color[1], $color[2], $opacity);
}
}
/**
* TODO: What does it do?
* @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');
}
/**
* TODO: What does it do?
* @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;
}
/**
* TODO: What does it do?
* @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 . ')';
}
/**
* TODO: What does it do?
* @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;
}
/**
* TODO: What does it do?
* @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 . ')';
}
/**
* TODO: What does it do?
* @since 5.3.1.6
*/
public static function rgbToHex($clr) {
$values = TPColorpicker::rgbValues($clr, 3);
return TPColorpicker::getRgbToHex($values[0], $values[1], $values[2]);
}
/**
* TODO: What does it do?
* @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]);
}
/**
* TODO: What does it do?
* @since 5.3.1.6
*/
public static function getOpacity($val){
$rgb = TPColorpicker::rgbValues($val, 4);
return intval($rgb[3] * 100, 10) + '%';
}
/**
* TODO: What does it do?
* @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;
}
/**
* TODO: What does it do?
* @since 5.3.1.6
*/
public static function joinToRgba($val){
$val = explode('||', $val);
return TPColorpicker::convert($val[0], $val[1]);
}
/**
* TODO: What does it do?
* @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;
}
/**
* TODO: What does it do?
* @since 5.3.1.6
*/
public static function sanitizeHex($hex){
$hex = trim(str_replace('#', '' , $hex));
if (strlen($hex) == 3) {
$hex[5] = $hex[2]; // f60##0
$hex[4] = $hex[2]; // f60#00
$hex[3] = $hex[1]; // f60600
$hex[2] = $hex[1]; // f66600
$hex[1] = $hex[0]; // ff6600
}
return '#'.$hex;
}
/**
* Save presets
* @since 5.3.2
*/
public static function save_color_presets($presets){
update_option('tp_colorpicker_presets', $presets);
return self::get_color_presets();
}
/**
* Load presets
* @since 5.3.2
*/
public static function get_color_presets(){
return get_option('tp_colorpicker_presets', array());
}
}
}
?>

View File

@@ -0,0 +1,684 @@
<?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(in_array($name, $deformations) && $name !== 'css_cursor') continue;
if($name == 'background-color' && strpos($style, 'rgba') !== false){ //rgb && rgba
$rgb = explode(',', str_replace('rgba', 'rgb', $style));
unset($rgb[count($rgb)-1]);
$rgb = implode(',', $rgb).')';
$css.= $name.':'.$rgb.";".$nl;
}
$style = (is_array($style) || is_object($style)) ? implode(' ', $style) : $style;
$css.= $name.':'.$style.";".$nl;
}
}
$css.= "}".$nl.$nl;
//add hover
if(isset($setting['hover']) && $setting['hover'] == 'true'){
$hover = (array)$attr['hover'];
if($adv && isset($advanced['hover'])){
$styles = array_merge($styles, (array)$advanced['hover']);
}
if(is_array($hover)){
$css.= $attr['handle'].":hover";
if(!empty($stripped)) $css.= ', '.$stripped.":hover";
$css.= " {".$nl;
foreach($hover as $name => $style){
if($name == 'background-color' && strpos($style, 'rgba') !== false){ //rgb && rgba
$rgb = explode(',', str_replace('rgba', 'rgb', $style));
unset($rgb[count($rgb)-1]);
$rgb = implode(',', $rgb).')';
$css.= $name.':'.$rgb.";".$nl;
}
$style = (is_array($style) || is_object($style)) ? implode(' ', $style) : $style;
$css.= $name.':'.$style.";".$nl;
}
$css.= "}".$nl.$nl;
}
}
}
return $css;
}
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',
'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 {}
?>

View File

@@ -0,0 +1,198 @@
<?php
/**
* @author ThemePunch <info@themepunch.com>
* @link http://www.themepunch.com/
* @copyright 2015 ThemePunch
*/
class RevSliderDB{
private $wpdb;
private $lastRowID;
/**
*
* constructor - set database object
*/
public function __construct(){
$this->wpdb = rev_db_class::rev_db_instance();
}
/**
*
* throw error
*/
private function throwError($message,$code=-1){
RevSliderFunctions::throwError($message,$code);
}
//------------------------------------------------------------
// validate for errors
// private function checkForErrors($prefix = ""){
// //global $wpdb;
// $wpdb = $this->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);
// }
//
// }
private function checkForErrors($prefix = ""){
$errno = '';
if(!empty($errno)){
$message = '';
$message = '';
$this->throwError($message);
}
}
/**
*
* insert variables to some table
*/
public function insert($table,$arrItems){
//global $wpdb;
$wpdb = $this->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;
$wpdb = $this->wpdb;
$this->lastRowID = $wpdb->Insert_ID();
return($this->lastRowID);
}
/**
*
* delete rows
*/
public function delete($table,$where){
//global $wpdb;
$wpdb = $this->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 = $this->wpdb;
$wpdb->query($query);
$this->checkForErrors("Regular query error");
}
/**
*
* run some sql query
*/
public function runSqlR($query){
//global $wpdb;
$wpdb = $this->wpdb;
$return = $wpdb->get_results($query, ARRAY_A);
return $return;
}
/**
*
* insert variables to some table
*/
public function update($table,$arrItems,$where){
//global $wpdb;
$wpdb = $this->wpdb;
$response = $wpdb->update($table, $arrItems, $where);
return $response;
//return($wpdb->num_rows);
}
/**
*
* get data array from the database
*
*/
public function fetch($tableName,$where="",$orderField="",$groupByField="",$sqlAddon=""){
//global $wpdb;
$wpdb = $this->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;
$wpdb = $this->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 {}
?>

View File

@@ -0,0 +1,35 @@
<?php
/**
* @author ThemePunch <info@themepunch.com>
* @link http://www.themepunch.com/
* @copyright 2015 ThemePunch
*/
// class UniteElementsBaseRev{
//
// protected $db;
//
// public function __construct(){
//
// $this->db = new UniteDBRev();
// }
//
// }
class RevSliderElementsBase {
protected $db;
public function __construct(){
$this->db = rev_db_class::rev_db_instance();
}
}
/**
* old classname extends new one (old classnames will be obsolete soon)
* @since: 5.0
**/
class UniteElementsBaseRev extends RevSliderElementsBase {}
?>

View File

@@ -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

View File

@@ -0,0 +1,692 @@
<?php
/**
* @author ThemePunch <info@themepunch.com>
* @link http://www.themepunch.com/
* @copyright 2015 ThemePunch
*/
class RevSliderFunctions{
public static function throwError($message,$code=null){
if(!empty($code)){
throw new Exception($message,$code);
}else{
throw new Exception($message);
}
// return $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." ".$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 {}
?>

View File

@@ -0,0 +1,17 @@
<?php
//---------------------------------------------------------------------------------------------------------------------
if(!function_exists("dmp")){
function dmp($str){
echo "<div align='left'>";
echo "<pre>";
print_r($str);
echo "</pre>";
echo "</div>";
}
}
?>

View File

@@ -0,0 +1,628 @@
<?php
class UniteImageViewRev{
private $pathCache;
private $pathImages;
private $urlImages;
private $filename = null;
private $maxWidth = null;
private $maxHeight = null;
private $type = null;
private $effect = null;
private $effect_arg1 = null;
private $effect_arg2 = null;
const EFFECT_BW = "bw";
const EFFECT_BRIGHTNESS = "bright";
const EFFECT_CONTRAST = "contrast";
const EFFECT_EDGE = "edge";
const EFFECT_EMBOSS = "emboss";
const EFFECT_BLUR = "blur";
const EFFECT_BLUR3 = "blur3";
const EFFECT_MEAN = "mean";
const EFFECT_SMOOTH = "smooth";
const EFFECT_DARK = "dark";
const TYPE_EXACT = "exact";
const TYPE_EXACT_TOP = "exacttop";
private $jpg_quality = 81;
public function __construct($pathCache,$pathImages,$urlImages){
$this->pathCache = $pathCache;
$this->pathImages = $pathImages;
$this->urlImages = $urlImages;
}
/**
*
* set jpg quality output
*/
public function setJPGQuality($quality){
$this->jpg_quality = $quality;
}
/**
*
* get thumb url
*/
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);
}
/**
*
* throw error
*/
private function throwError($message,$code=null){
UniteFunctionsRev::throwError($message,$code);
}
/**
*
* get filename for thumbnail save / retrieve
* TODO: do input validations - security measures
*/
private function getThumbFilename(){
$info = pathInfo($this->filename);
//add dirname as postfix (if exists)
$postfix = "";
$dirname = UniteFunctionsRev::getVal($info, "dirname");
if(!empty($dirname)){
$postfix = str_replace("/", "-", $dirname);
}
$ext = $info["extension"];
$name = $info["filename"];
$width = ceil($this->maxWidth);
$height = ceil($this->maxHeight);
$thumbFilename = $name."_".$width."x".$height;
if(!empty($this->type))
$thumbFilename .= "_" . $this->type;
if(!empty($this->effect)){
$thumbFilename .= "_e" . $this->effect;
if(!empty($this->effect_arg1)){
$thumbFilename .= "x" . $this->effect_arg1;
}
}
//add postfix
if(!empty($postfix))
$thumbFilename .= "_".$postfix;
$thumbFilename .= ".".$ext;
return($thumbFilename);
}
//------------------------------------------------------------------------------------------
// get thumbnail fielpath by parameters.
private function getThumbFilepath(){
$filename = $this->getThumbFilename();
$filepath = $this->pathCache .$filename;
return($filepath);
}
//------------------------------------------------------------------------------------------
// ouptput emtpy image code.
private function outputEmptyImageCode(){
echo "empty image";
exit();
}
//------------------------------------------------------------------------------------------
// outputs image and exit.
private function outputImage($filepath){
$info = UniteFunctionsRev::getPathInfo($filepath);
$ext = $info["extension"];
//$filetime = filemtime($filepath);
$ext = strtolower($ext);
if($ext == "jpg")
$ext = "jpeg";
$numExpires = 31536000; //one year
$strExpires = @date('D, d M Y H:i:s',time()+$numExpires);
//$strModified = @date('D, d M Y H:i:s',$filetime);
$contents = file_get_contents($filepath);
$filesize = strlen($contents);
/*header("Last-Modified: $strModified GMT");*/
header("Expires: $strExpires GMT");
header("Cache-Control: public");
header("Content-Type: image/$ext");
header("Content-Length: $filesize");
echo $contents;
exit();
}
//------------------------------------------------------------------------------------------
// get src image from filepath according the image type
private function getGdSrcImage($filepath,$type){
// create the image
$src_img = false;
switch($type){
case IMAGETYPE_JPEG:
$src_img = @imagecreatefromjpeg($filepath);
break;
case IMAGETYPE_PNG:
$src_img = @imagecreatefrompng($filepath);
break;
case IMAGETYPE_GIF:
$src_img = @imagecreatefromgif($filepath);
break;
case IMAGETYPE_BMP:
$src_img = @imagecreatefromwbmp($filepath);
break;
default:
$this->throwError("wrong image format, can't resize");
break;
}
if($src_img == false){
$this->throwError("Can't resize image");
}
return($src_img);
}
//------------------------------------------------------------------------------------------
// save gd image to some filepath. return if success or not
private function saveGdImage($dst_img,$filepath,$type){
$successSaving = false;
switch($type){
case IMAGETYPE_JPEG:
$successSaving = imagejpeg($dst_img,$filepath,$this->jpg_quality);
break;
case IMAGETYPE_PNG:
$successSaving = imagepng($dst_img,$filepath);
break;
case IMAGETYPE_GIF:
$successSaving = imagegif($dst_img,$filepath);
break;
case IMAGETYPE_BMP:
$successSaving = imagewbmp($dst_img,$filepath);
break;
}
return($successSaving);
}
//------------------------------------------------------------------------------------------
// crop image to specifix height and width , and save it to new path
private function cropImageSaveNew($filepath,$filepathNew){
$imgInfo = getimagesize($filepath);
$imgType = $imgInfo[2];
$src_img = $this->getGdSrcImage($filepath,$imgType);
$width = imageSX($src_img);
$height = imageSY($src_img);
//crop the image from the top
$startx = 0;
$starty = 0;
//find precrop width and height:
$percent = $this->maxWidth / $width;
$newWidth = $this->maxWidth;
$newHeight = ceil($percent * $height);
if($this->type == "exact"){ //crop the image from the middle
$startx = 0;
$starty = ($newHeight-$this->maxHeight)/2 / $percent;
}
if($newHeight < $this->maxHeight){ //by width
$percent = $this->maxHeight / $height;
$newHeight = $this->maxHeight;
$newWidth = ceil($percent * $width);
if($this->type == "exact"){ //crop the image from the middle
$startx = ($newWidth - $this->maxWidth) /2 / $percent; //the startx is related to big image
$starty = 0;
}
}
//resize the picture:
$tmp_img = ImageCreateTrueColor($newWidth,$newHeight);
$this->handleTransparency($tmp_img,$imgType,$newWidth,$newHeight);
imagecopyresampled($tmp_img,$src_img,0,0,$startx,$starty,$newWidth,$newHeight,$width,$height);
$this->handleImageEffects($tmp_img);
//crop the picture:
$dst_img = ImageCreateTrueColor($this->maxWidth,$this->maxHeight);
$this->handleTransparency($dst_img,$imgType,$this->maxWidth,$this->maxHeight);
imagecopy($dst_img, $tmp_img, 0, 0, 0, 0, $newWidth, $newHeight);
//save the picture
$is_saved = $this->saveGdImage($dst_img,$filepathNew,$imgType);
imagedestroy($dst_img);
imagedestroy($src_img);
imagedestroy($tmp_img);
return($is_saved);
}
//------------------------------------------------------------------------------------------
// if the images are png or gif - handle image transparency
private function handleTransparency(&$dst_img,$imgType,$newWidth,$newHeight){
//handle transparency:
if($imgType == IMAGETYPE_PNG || $imgType == IMAGETYPE_GIF){
imagealphablending($dst_img, false);
imagesavealpha($dst_img,true);
$transparent = imagecolorallocatealpha($dst_img, 255, 255, 255, 127);
imagefilledrectangle($dst_img, 0, 0, $newWidth, $newHeight, $transparent);
}
}
//------------------------------------------------------------------------------------------
// handle image effects
private function handleImageEffects(&$imgHandle){
if(empty($this->effect))
return(false);
switch($this->effect){
case self::EFFECT_BW:
if(defined("IMG_FILTER_GRAYSCALE"))
imagefilter($imgHandle,IMG_FILTER_GRAYSCALE);
break;
case self::EFFECT_BRIGHTNESS:
if(defined("IMG_FILTER_BRIGHTNESS")){
if(!is_numeric($this->effect_arg1))
$this->effect_arg1 = 50; //set default value
UniteFunctionsRev::validateNumeric($this->effect_arg1,"'ea1' argument");
imagefilter($imgHandle,IMG_FILTER_BRIGHTNESS,$this->effect_arg1);
}
break;
case self::EFFECT_DARK:
if(defined("IMG_FILTER_BRIGHTNESS")){
if(!is_numeric($this->effect_arg1))
$this->effect_arg1 = -50; //set default value
UniteFunctionsRev::validateNumeric($this->effect_arg1,"'ea1' argument");
imagefilter($imgHandle,IMG_FILTER_BRIGHTNESS,$this->effect_arg1);
}
break;
case self::EFFECT_CONTRAST:
if(defined("IMG_FILTER_CONTRAST")){
if(!is_numeric($this->effect_arg1))
$this->effect_arg1 = -5; //set default value
imagefilter($imgHandle,IMG_FILTER_CONTRAST,$this->effect_arg1);
}
break;
case self::EFFECT_EDGE:
if(defined("IMG_FILTER_EDGEDETECT"))
imagefilter($imgHandle,IMG_FILTER_EDGEDETECT);
break;
case self::EFFECT_EMBOSS:
if(defined("IMG_FILTER_EMBOSS"))
imagefilter($imgHandle,IMG_FILTER_EMBOSS);
break;
case self::EFFECT_BLUR:
$this->effect_Blur($imgHandle,5);
/*
if(defined("IMG_FILTER_GAUSSIAN_BLUR"))
imagefilter($imgHandle,IMG_FILTER_GAUSSIAN_BLUR);
*/
break;
case self::EFFECT_MEAN:
if(defined("IMG_FILTER_MEAN_REMOVAL"))
imagefilter($imgHandle,IMG_FILTER_MEAN_REMOVAL);
break;
case self::EFFECT_SMOOTH:
if(defined("IMG_FILTER_SMOOTH")){
if(!is_numeric($this->effect_arg1))
$this->effect_arg1 = 15; //set default value
imagefilter($imgHandle,IMG_FILTER_SMOOTH,$this->effect_arg1);
}
break;
case self::EFFECT_BLUR3:
$this->effect_Blur($imgHandle,5);
break;
default:
$this->throwError("Effect not supported: <b>".$this->effect."</b>");
break;
}
}
private function effect_Blur(&$gdimg, $radius=0.5) {
// Taken from Torstein Hרnsi's phpUnsharpMask (see phpthumb.unsharp.php)
$radius = round(max(0, min($radius, 50)) * 2);
if (!$radius) {
return false;
}
$w = ImageSX($gdimg);
$h = ImageSY($gdimg);
if ($imgBlur = ImageCreateTrueColor($w, $h)) {
// Gaussian blur matrix:
// 1 2 1
// 2 4 2
// 1 2 1
// Move copies of the image around one pixel at the time and merge them with weight
// according to the matrix. The same matrix is simply repeated for higher radii.
for ($i = 0; $i < $radius; $i++) {
ImageCopy ($imgBlur, $gdimg, 0, 0, 1, 1, $w - 1, $h - 1); // up left
ImageCopyMerge($imgBlur, $gdimg, 1, 1, 0, 0, $w, $h, 50.00000); // down right
ImageCopyMerge($imgBlur, $gdimg, 0, 1, 1, 0, $w - 1, $h, 33.33333); // down left
ImageCopyMerge($imgBlur, $gdimg, 1, 0, 0, 1, $w, $h - 1, 25.00000); // up right
ImageCopyMerge($imgBlur, $gdimg, 0, 0, 1, 0, $w - 1, $h, 33.33333); // left
ImageCopyMerge($imgBlur, $gdimg, 1, 0, 0, 0, $w, $h, 25.00000); // right
ImageCopyMerge($imgBlur, $gdimg, 0, 0, 0, 1, $w, $h - 1, 20.00000); // up
ImageCopyMerge($imgBlur, $gdimg, 0, 1, 0, 0, $w, $h, 16.666667); // down
ImageCopyMerge($imgBlur, $gdimg, 0, 0, 0, 0, $w, $h, 50.000000); // center
ImageCopy ($gdimg, $imgBlur, 0, 0, 0, 0, $w, $h);
}
return true;
}
return false;
}
//------------------------------------------------------------------------------------------
// resize image and save it to new path
private function resizeImageSaveNew($filepath,$filepathNew){
$imgInfo = getimagesize($filepath);
$imgType = $imgInfo[2];
$src_img = $this->getGdSrcImage($filepath,$imgType);
$width = imageSX($src_img);
$height = imageSY($src_img);
$newWidth = $width;
$newHeight = $height;
//find new width
if($height > $this->maxHeight){
$procent = $this->maxHeight / $height;
$newWidth = ceil($width * $procent);
$newHeight = $this->maxHeight;
}
//if the new width is grater than max width, find new height, and remain the width.
if($newWidth > $this->maxWidth){
$procent = $this->maxWidth / $newWidth;
$newHeight = ceil($newHeight * $procent);
$newWidth = $this->maxWidth;
}
//if the image don't need to be resized, just copy it from source to destanation.
if($newWidth == $width && $newHeight == $height && empty($this->effect)){
$success = copy($filepath,$filepathNew);
if($success == false)
$this->throwError("can't copy the image from one path to another");
}
else{ //else create the resized image, and save it to new path:
$dst_img = ImageCreateTrueColor($newWidth,$newHeight);
$this->handleTransparency($dst_img,$imgType,$newWidth,$newHeight);
//copy the new resampled image:
imagecopyresampled($dst_img,$src_img,0,0,0,0,$newWidth,$newHeight,$width,$height);
$this->handleImageEffects($dst_img);
$is_saved = $this->saveGdImage($dst_img,$filepathNew,$imgType);
imagedestroy($dst_img);
}
imagedestroy($src_img);
return(true);
}
/**
*
* set image effect
*/
public function setEffect($effect,$arg1 = ""){
$this->effect = $effect;
$this->effect_arg1 = $arg1;
}
private function showImageByID($fileID, $maxWidth=-1, $maxHeight=-1, $type=""){
$fileID = intval($fileID);
if($fileID == 0) $this->throwError("image not found");
$img = wp_get_attachment_image_src( $fileID, 'thumb' );
if(empty($img)) $this->throwError("image not found");
$this->outputImage($img[0]);
exit();
}
//------------------------------------------------------------------------------------------
//return image
private function showImage($filename,$maxWidth=-1,$maxHeight=-1,$type=""){
if(empty($filename))
$this->throwError("image filename not found");
//validate input
if($type == self::TYPE_EXACT || $type == self::TYPE_EXACT_TOP){
if($maxHeight == -1)
$this->throwError("image with exact type must have height!");
if($maxWidth == -1)
$this->throwError("image with exact type must have width!");
}
$filepath = $this->pathImages.$filename;
if(!is_file($filepath)) $this->outputEmptyImageCode();
//if gd library doesn't exists - output normal image without resizing.
if(function_exists("gd_info") == false)
$this->throwError("php must support GD Library");
//check conditions for output original image
if(empty($this->effect)){
if((is_numeric($maxWidth) == false || is_numeric($maxHeight) == false)) outputImage($filepath);
if($maxWidth == -1 && $maxHeight == -1)
$this->outputImage($filepath);
}
if($maxWidth == -1) $maxWidth = 1000000;
if($maxHeight == -1) $maxHeight = 100000;
//init variables
$this->filename = $filename;
$this->maxWidth = $maxWidth;
$this->maxHeight = $maxHeight;
$this->type = $type;
$filepathNew = $this->getThumbFilepath();
if(is_file($filepathNew)){
$this->outputImage($filepathNew);
exit();
}
try{
if($type == self::TYPE_EXACT || $type == self::TYPE_EXACT_TOP){
$isSaved = $this->cropImageSaveNew($filepath,$filepathNew);
}
else
$isSaved = $this->resizeImageSaveNew($filepath,$filepathNew);
if($isSaved == false){
$this->outputImage($filepath);
exit();
}
}catch(Exception $e){
$this->outputImage($filepath);
}
if(is_file($filepathNew))
$this->outputImage($filepathNew);
else
$this->outputImage($filepath);
exit();
}
/**
*
* show image from get params
*/
public function showImageFromGet(){
//$imageFilename = UniteFunctionsRev::getGetVar("img");
// $imageID = intval(UniteFunctionsRev::getGetVar("img"));
$maxWidth = UniteFunctionsRev::getGetVar("w",-1);
$maxHeight = UniteFunctionsRev::getGetVar("h",-1);
$type = UniteFunctionsRev::getGetVar("t","");
//set effect
$effect = UniteFunctionsRev::getGetVar("e");
$effectArgument1 = UniteFunctionsRev::getGetVar("ea1");
if(!empty($effect))
$this->setEffect($effect,$effectArgument1);
// $this->showImageByID($imageID);
echo 'sechs<br>';
//$this->showImage($imageFilename,$maxWidth,$maxHeight,$type);
}
//------------------------------------------------------------------------------------------
// download image, change size and name if needed.
public function downloadImage($filename){
$filepath = $this->urlImages."/".$filename;
if(!is_file($filepath)) {
echo "file doesn't exists";
exit();
}
$this->outputImageForDownload($filepath,$filename);
}
//------------------------------------------------------------------------------------------
// output image for downloading
private function outputImageForDownload($filepath,$filename,$mimeType=""){
$contents = file_get_contents($filepath);
$filesize = strlen($contents);
if($mimeType == ""){
$info = UniteFunctionsRev::getPathInfo($filepath);
$ext = $info["extension"];
$mimeType = "image/$ext";
}
header("Content-Type: $mimeType");
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Length: $filesize");
echo $contents;
exit();
}
/**
*
* validate type
* @param unknown_type $type
*/
public function validateType($type){
switch($type){
case self::TYPE_EXACT:
case self::TYPE_EXACT_TOP:
break;
default:
$this->throwError("Wrong image type: ".$type);
break;
}
}
}
?>

View File

@@ -0,0 +1,21 @@
<?php
$folderIncludes = dirname(__FILE__)."/";
require_once $folderIncludes . 'functions.php';
require_once $folderIncludes . 'functions.class.php';
require_once $folderIncludes . 'functions-wordpress.class.php';
require_once $folderIncludes . 'db.class.php';
require_once $folderIncludes . 'settings.class.php';
require_once $folderIncludes . 'cssparser.class.php';
require_once $folderIncludes . 'settings_advances.class.php';
require_once $folderIncludes . 'settings_output.class.php';
require_once $folderIncludes . 'settings_product.class.php';
require_once $folderIncludes . 'settings_product_sidebar.class.php';
require_once $folderIncludes . 'image_view.class.php';
require_once $folderIncludes . 'zip.class.php';
require_once $folderIncludes . 'wpml.class.php';
require_once $folderIncludes . 'em-integration.class.php';
require_once $folderIncludes . 'aq_resizer.class.php';
?>

View File

@@ -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' => 'Prestashop'.$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' => 'Prestashop'.$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

View File

@@ -0,0 +1,350 @@
<?php
/**
* @author ThemePunch <info@themepunch.com>
* @link http://www.themepunch.com/
* @copyright 2015 ThemePunch
*/
class RevSliderUpdate {
private $plugin_url = 'https://codecanyon.net/item/slider-revolution-responsive-wordpress-plugin/2751380';
private $remote_url = 'https://updates.themepunch.tools/check_for_updates.php';
private $remote_url_info = 'https://updates.themepunch.tools/revslider_prestashop/revslider.php';
private $remote_url_info_sds = 'https://updates.themepunch.tools/revslider-prestashop/revslider.php';
private $remote_temp_active = 'https://updates.themepunch.tools/temp_activate.php';
private $plugin_slug = 'revslider_prestashop';
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);
//$this->set_update_transient();
}
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);
}
$code = get_option('revslider-code', '');
$request_sds = wp_remote_post($this->remote_url_info_sds, array(
'user-agent' => 'Prestashop'.$wp_version.'; '.get_bloginfo('url'),
'body' => array(
'item' => urlencode('revslider_prestashop'),
'version' => urlencode(RevSliderGlobals::SLIDER_REVISION),
'valid' => get_option('revslider-valid'),
'action' => 'get_version',
'code' => $code,
)
));
if($request_sds['body'] !='0'){
$sds_response = json_decode($request_sds['body']);
}
$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 ;
$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';
}
$request = wp_remote_post($this->remote_url_info, array(
'user-agent' => 'Prestashop'.$wp_version.'; '.get_bloginfo('url'),
'body' => $rattr
));
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;
$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){
// var_dump($force_check);
$code = get_option('revslider-code', '');
$request_sds = wp_remote_post($this->remote_url_info_sds, array(
'user-agent' => 'Prestashop'.$wp_version.'; '.get_bloginfo('url'),
'body' => array(
'item' => urlencode('revslider_prestashop'),
'version' => urlencode(RevSliderGlobals::SLIDER_REVISION),
'valid' => get_option('revslider-valid'),
'action' => 'get_all',
'code' => $code,
)
));
if($request_sds['body'] !='0'){
$sds_response = json_decode($request_sds['body']);
}
update_option('revslider-update-check-short', time());
$purchase = (get_option('revslider-valid', 'false') == 'true') ? get_option('revslider-code', '') : '';
$response = wp_remote_post($this->remote_url, array(
'user-agent' => 'Prestashop'.$wp_version.'; '.get_bloginfo('url'),
'body' => array(
'item' => urlencode('revslider_prestashop'),
'version' => urlencode(RevSliderGlobals::SLIDER_REVISION),
'code' => urlencode($purchase)
)
));
//var_dump($version_info);die();
$response_code = wp_remote_retrieve_response_code( $response );
$version_info = wp_remote_retrieve_body( $response );
if ( $response_code != 200 ) {
update_option('revslider-connection', false);
return false;
}else{
update_option('revslider-connection', true);
}
$version_info = json_decode($version_info);
if(isset($sds_response->update_url)){
update_option('update_url', $sds_response->update_url);
}
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);
}
// var_dump($version_info);die();
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);
}
}
}
// var_dump($last_check);die();
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;
$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){
$response = wp_remote_post($this->remote_temp_active, array(
'user-agent' => 'Prestashop'.$wp_version.'; '.get_bloginfo('url'),
'body' => array(
'item' => urlencode('revslider_prestashop'),
'version' => urlencode(RevSliderGlobals::SLIDER_REVISION),
'code' => urlencode(get_option('revslider-code', ''))
)
));
$response_code = wp_remote_retrieve_response_code( $response );
$version_info = wp_remote_retrieve_body( $response );
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);
}
}
public function update_revslider(){
global $wp_version;
$plugin_message = 'ZIP is there';
$url = get_option('update_url',false);
if($url !=false){
$get = wp_remote_post($url, array(
'user-agent' => 'Prestashop'.$wp_version.'; '.get_bloginfo('url'),
'body' => '',
'timeout' => 450
));
$upload_dir = wp_upload_dir();
$file = $upload_dir. 'revprestaupdate.zip';
@mkdir(dirname($file));
$ret = @file_put_contents( $file, $get['body'] );
$d_path = RS_PLUGIN_PATH . '/';
if(class_exists("ZipArchive")){
$zip = new ZipArchive();
$unzipfile = $zip->open($file, ZIPARCHIVE::CREATE);
$zip->extractTo($d_path);
}
@unlink($file);
Tools::redirectAdmin('index.php?controller=AdminModules&token='.Tools::getAdminTokenLite('AdminModules'));
}
}
}
/**
* old classname extends new one (old classnames will be obsolete soon)
* @since: 5.0
**/
class UniteUpdateClassRev extends RevSliderUpdate {}
?>

View File

@@ -0,0 +1,203 @@
<?php
/**
* 2016 Revolution Slider
*
* @author SmatDataSoft <support@smartdatasoft.com>
* @copyright 2016 SmatDataSoft
* @license private
* @version 5.1.3
* International Registered Trademark & Property of SmatDataSoft
*/
class UniteWpmlRev
{
public static function isWpmlExists()
{
return true;
if (class_exists("SitePress")) {
return(true);
} else {
return(false);
}
}
private static function validateWpmlExists()
{
if (!self::isWpmlExists()) {
UniteFunctionsRev::throwError("The wpml plugin don't exists");
}
}
public static function getArrLanguages($getAllCode = true)
{
$arrLangs = Language::getLanguages();
$response = array();
if ($getAllCode == true) {
$response["all"] = __("All Languages", REVSLIDER_TEXTDOMAIN);
}
foreach ($arrLangs as $code => $arrLang) {
$ind = $arrLang['iso_code'];
$response[$ind] = $arrLang['name'];
}
return($response);
}
public static function getArrLangCodes($getAllCode = true)
{
$arrCodes = array();
if ($getAllCode == true) {
$arrCodes["all"] = "all";
}
$arrLangs = Language::getLanguages();
foreach ($arrLangs as $code => $arr) {
$ind = $arr['iso_code'];
$arrCodes[$ind] = $ind;
}
return($arrCodes);
}
public static function isAllLangsInArray($arrCodes)
{
$arrAllCodes = self::getArrLangCodes();
$diff = array_diff($arrAllCodes, $arrCodes);
return(empty($diff));
}
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);
$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);
}
public static function getFlagUrl($code)
{
$arrLangs = Language::getLanguages();
if ($code == 'all') {
$url = get_url() . '/views/img/images/icon16.png';
} else {
$url = '';
foreach ($arrLangs as $lang) {
if ($lang['iso_code'] == $code) {
$url = _THEME_LANG_DIR_ . $lang['id_lang'] . '.jpg';
}
}
}
return($url);
}
private function getLangDetails($code)
{
$wpdb = rev_db_class::revDbInstance();
$details = $wpdb->getRow("SELECT * FROM " . $wpdb->prefix . "icl_languages WHERE code='$code'");
if (!empty($details)) {
$details = (array) $details;
}
return($details);
}
public static function getLangTitle($code)
{
$langs = self::getArrLanguages();
if ($code == "all") {
return(__("All Languages", REVSLIDER_TEXTDOMAIN));
}
if (array_key_exists($code, $langs)) {
return($langs[$code]);
}
$details = self::getLangDetails($code);
if (!empty($details)) {
return($details["english_name"]);
}
return("");
}
public static function getCurrentLang()
{
$language = Context::getContext()->language;
$lang = $language->iso_code;
return($lang);
}
// @codingStandardsIgnoreStart
}
// @codingStandardsIgnoreEnd
// @codingStandardsIgnoreStart
class RevSliderWpml extends UniteWpmlRev
{
// @codingStandardsIgnoreEnd
}

View File

@@ -0,0 +1,97 @@
<?php
class UniteZipRev{
private $zip;
/**
*
* get true / false if the zip archive exists.
*/
public static function isZipExists(){
$exists = class_exists("ZipArchive");
return $exists;
}
/**
*
* add zip file
*/
private function addItem($basePath,$path){
$rel_path = str_replace($basePath."/", "", $path);
if(is_dir($path)){ //directory
//add dir to zip
if($basePath != $path)
$this->zip->addEmptyDir($rel_path);
$files = scandir($path);
foreach($files as $file){
if($file == "." || $file == ".." || $file == ".svn")
continue;
$filepath = $path."/".$file;
$this->addItem($basePath, $filepath);
}
}
else{ //file
if(!file_exists($path))
throwError("filepath: '$path' don't exists, can't zip");
$this->zip->addFile($path,$rel_path);
}
}
/**
*
* make zip archive
* if exists additional paths, add additional items to the zip
*/
public function makeZip($srcPath, $zipFilepath,$additionPaths = array()){
if(!is_dir($srcPath))
throwError("The path: '$srcPath' don't exists, can't zip");
$this->zip = new ZipArchive;
$success = $this->zip->open($zipFilepath, ZipArchive::CREATE);
if($success == false)
throwError("Can't create zip file: $zipFilepath");
$this->addItem($srcPath,$srcPath);
if(gettype($additionPaths) != "array")
throwError("Wrong additional paths variable.");
//add additional paths
if(!empty($additionPaths))
foreach($additionPaths as $path){
if(!is_dir($path))
throwError("Path: $path not found, can't zip");
$this->addItem($path, $path);
}
$this->zip->close();
}
/**
*
* Extract zip archive
*/
public function extract($src, $dest){
$zip = new ZipArchive;
if ($zip->open($src)===true){
$zip->extractTo($dest);
$zip->close();
return true;
}
return false;
}
}
?>