Initial Commit
This commit is contained in:
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
/**
|
||||
* @author ThemePunch <info@themepunch.com>
|
||||
* @link http://www.themepunch.com/
|
||||
* @copyright 2016 ThemePunch
|
||||
*/
|
||||
|
||||
if( !defined( 'ABSPATH') ) exit();
|
||||
|
||||
require_once(RS_SNOW_PLUGIN_PATH . 'framework/slider.admin.class.php');
|
||||
|
||||
class RsSnowSliderAdmin extends RsAddonSnowSliderAdmin {
|
||||
|
||||
protected static $_Icon,
|
||||
$_Title,
|
||||
$_Markup,
|
||||
$_JavaScript;
|
||||
|
||||
public function __construct($_title) {
|
||||
|
||||
static::$_Title = $_title;
|
||||
parent::init();
|
||||
|
||||
}
|
||||
|
||||
protected static function _init($_slider) {
|
||||
|
||||
$_enabled = RevSliderFunctions::getVal($_slider, 'snow_enabled', false) == 'true' ? ' checked' : '';
|
||||
$_startSlide = RevSliderFunctions::getVal($_slider, 'snow_start_slide', 'first');
|
||||
$_endSlide = RevSliderFunctions::getVal($_slider, 'snow_end_slide', 'last');
|
||||
$_maxFlakes = RevSliderFunctions::getVal($_slider, 'snow_max_num', '400');
|
||||
$_minSize = RevSliderFunctions::getVal($_slider, 'snow_min_size', '0.2');
|
||||
$_maxSize = RevSliderFunctions::getVal($_slider, 'snow_max_size', '6');
|
||||
$_minOpacity = RevSliderFunctions::getVal($_slider, 'snow_min_opacity', '0.3');
|
||||
$_maxOpacity = RevSliderFunctions::getVal($_slider, 'snow_max_opacity', '1');
|
||||
$_minSpeed = RevSliderFunctions::getVal($_slider, 'snow_min_speed', '30');
|
||||
$_maxSpeed = RevSliderFunctions::getVal($_slider, 'snow_max_speed', '100');
|
||||
$_minSinus = RevSliderFunctions::getVal($_slider, 'snow_min_sinus', '1');
|
||||
$_maxSinus = RevSliderFunctions::getVal($_slider, 'snow_max_sinus', '100');
|
||||
$_alias = RevSliderFunctions::getVal($_slider, 'alias', '');
|
||||
$_showSettings = $_enabled ? 'block' : 'none';
|
||||
$_textDomain = 'rs_' . static::$_Title;
|
||||
$_total = 2;
|
||||
|
||||
if($_alias) {
|
||||
|
||||
$_clas = new RevSlider();
|
||||
$_rev_sliders = $_clas->getArrSliders();
|
||||
foreach($_rev_sliders as $_rev_slider) {
|
||||
|
||||
if($_alias === $_rev_slider->getAlias()) $_total = $_rev_slider->getNumSlides();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static::$_Markup =
|
||||
|
||||
'<span class="label" id="label_snow_enabled" origtitle="' . __("Enable/Disable Holiday Snow for this Slider", $_textDomain) . '">' . __('Add Holiday Snow', $_textDomain) . '</span>
|
||||
<input type="checkbox" class="tp-moderncheckbox withlabel" id="snow_enabled" name="snow_enabled"' . $_enabled . '
|
||||
onchange="document.getElementById(\'snow-settings\').style.display=this.checked ? \'block\' : \'none\'" />
|
||||
|
||||
<div id="snow-settings" style="display: ' . $_showSettings . '">
|
||||
|
||||
<h4>General Settings</h4>
|
||||
|
||||
<span class="label" id="label_snow_start_slide" origtitle="' . __('Start Snowing on Slide Number X', $_textDomain) . '">' . __("Start on Slide", $_textDomain) . '</span>
|
||||
<select class="withlabel" id="snow_start_slide" name="snow_start_slide" data-default="0">
|
||||
<option value="first"';
|
||||
|
||||
if($_startSlide === 'first') static::$_Markup .= ' selected';
|
||||
static::$_Markup .= '>First Slide</option>';
|
||||
|
||||
for($i = 2; $i < $_total + 1; $i++) {
|
||||
|
||||
static::$_Markup .= '<option value="' . $i . '"';
|
||||
if($_startSlide == $i) static::$_Markup .= ' selected';
|
||||
static::$_Markup .= '>' . $i . '</option>';
|
||||
|
||||
}
|
||||
|
||||
static::$_Markup .= '</select>
|
||||
<br>
|
||||
|
||||
<span class="label" id="label_snow_end_slide" origtitle="' . __('End Snowing on Slide Number X', $_textDomain) . '">' . __("End on Slide", $_textDomain) . '</span>
|
||||
<select class="withlabel" id="snow_end_slide" name="snow_end_slide" data-default="0">
|
||||
<option value="last"';
|
||||
|
||||
if($_endSlide === 'last') static::$_Markup .= ' selected';
|
||||
static::$_Markup .= '>Last Slide</option>';
|
||||
|
||||
for($i = 1; $i < $_total; $i++) {
|
||||
|
||||
static::$_Markup .= '<option value="' . $i . '"';
|
||||
if($_endSlide == $i) static::$_Markup .= ' selected';
|
||||
static::$_Markup .= '>' . $i . '</option>';
|
||||
|
||||
}
|
||||
|
||||
static::$_Markup .= '</select>
|
||||
<br>
|
||||
|
||||
<h4>Snowflake Settings</h4>
|
||||
|
||||
<span class="label" id="label_snow_max" origtitle="' . __('Maximum Number of Snowflakes', $_textDomain) . '">' . __("Max Snowflakes", $_textDomain) . '</span>
|
||||
<input type="text" class="text-sidebar withlabel" id="snow_max_num" name="snow_max_num" value="' . $_maxFlakes . '" data-default="400" />
|
||||
<br>
|
||||
|
||||
<span class="label" id="label_snow_min_size" origtitle="' . __('Minimum Snowflake Size in pixels', $_textDomain) . '">' . __("Min Snowflake Size", $_textDomain) . '</span>
|
||||
<input type="text" class="text-sidebar withlabel" id="snow_min_size" name="snow_min_size" value="' . $_minSize . '" data-default="0.2" />
|
||||
<span>px</span>
|
||||
<br>
|
||||
|
||||
<span class="label" id="label_snow_max_size" origtitle="' . __('Maximum Snowflake Size in pixels', $_textDomain) . '">' . __("Max Snowflake Size", $_textDomain) . '</span>
|
||||
<input type="text" class="text-sidebar withlabel" id="snow_max_size" name="snow_max_size" value="' . $_maxSize . '" data-default="6" />
|
||||
<span>px</span>
|
||||
<br>
|
||||
|
||||
<span class="label" id="label_snow_min_opacity" origtitle="' . __('Minimum Snowflake Transparency (0-1)', $_textDomain) . '">' . __("Min Opacity (0-1)", $_textDomain) . '</span>
|
||||
<input type="text" class="text-sidebar withlabel" id="snow_min_opacity" name="snow_min_opacity" value="' . $_minOpacity . '" data-default="0.3" />
|
||||
<br>
|
||||
|
||||
<span class="label" id="label_snow_max_opacity" origtitle="' . __('Maximum Snowflake Transparency (0-1)', $_textDomain) . '">' . __("Max Opacity (0-1)", $_textDomain) . '</span>
|
||||
<input type="text" class="text-sidebar withlabel" id="snow_max_opacity" name="snow_max_opacity" value="' . $_maxOpacity . '" data-default="1" />
|
||||
<br>
|
||||
|
||||
<span class="label" id="label_snow_min_speed" origtitle="' . __('Higher the number, the faster the speed', $_textDomain) . '">' . __("Min Speed", $_textDomain) . '</span>
|
||||
<input type="text" class="text-sidebar withlabel" id="snow_min_speed" name="snow_min_speed" value="' . $_minSpeed . '" data-default="30" />
|
||||
<br>
|
||||
|
||||
<span class="label" id="label_snow_max_speed" origtitle="' . __('Higher the number, the faster the speed', $_textDomain) . '">' . __("Max Speed", $_textDomain) . '</span>
|
||||
<input type="text" class="text-sidebar withlabel" id="snow_max_speed" name="snow_max_speed" value="' . $_maxSpeed . '" data-default="100" />
|
||||
<br>
|
||||
|
||||
<span class="label" id="label_snow_min_sinus" origtitle="' . __('Applies additional variation to the falling snow', $_textDomain) . '">' . __("Min Amplitude", $_textDomain) . '</span>
|
||||
<input type="text" class="text-sidebar withlabel" id="snow_min_sinus" name="snow_min_sinus" value="' . $_minSinus . '" data-default="1" />
|
||||
<br>
|
||||
|
||||
<span class="label" id="label_snow_min_sinus" origtitle="' . __('Applies additional variation to the falling snow', $_textDomain) . '">' . __("Max Amplitude", $_textDomain) . '</span>
|
||||
<input type="text" class="text-sidebar withlabel" id="snow_max_sinus" name="snow_max_sinus" value="' . $_maxSinus . '" data-default="100" />
|
||||
<br>
|
||||
|
||||
<div class="toggle-custom-navigation-style visible" onclick="resetSnowDefaults()">Reset to Default Values</div>
|
||||
|
||||
</div>';
|
||||
|
||||
static::$_Icon = 'eg-icon-magic';
|
||||
static::$_JavaScript = 'function resetSnowDefaults() {
|
||||
|
||||
if(window.confirm("Reset Settings to their Defaults?")) {
|
||||
|
||||
jQuery("#snow-settings").children("select, input").each(function() {
|
||||
|
||||
this[this.type === "text" ? "value" : "selectedIndex"] = this.getAttribute("data-default");
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}';
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,224 @@
|
||||
<?php
|
||||
/**
|
||||
* @author ThemePunch <info@themepunch.com>
|
||||
* @link http://www.themepunch.com/
|
||||
* @copyright 2016 ThemePunch
|
||||
*/
|
||||
|
||||
if( !defined( 'ABSPATH') ) exit();
|
||||
|
||||
class rs_snow_update {
|
||||
private $plugin_url = 'http://codecanyon.net/item/slider-revolution-responsive-wordpress-plugin/2751380';
|
||||
private $remote_url = 'http://updates.themepunch.tools/check_for_updates.php';
|
||||
private $remote_url_info = 'http://updates.themepunch.tools/addons/revslider-snow-addon/revslider-snow-addon.php';
|
||||
private $plugin_slug = 'revslider-snow-addon';
|
||||
private $plugin_path = 'revslider-snow-addon/revslider-snow-addon.php';
|
||||
private $version;
|
||||
private $plugins;
|
||||
private $option;
|
||||
|
||||
|
||||
public function __construct($version) {
|
||||
$this->option = $this->plugin_slug . '_update_info';
|
||||
$this->version = $version;
|
||||
$this->_retrieve_version_info();
|
||||
}
|
||||
|
||||
public function delete_update_transients() {
|
||||
delete_transient( 'update_themes' );
|
||||
delete_transient( 'update_plugins' );
|
||||
delete_site_transient( 'update_plugins' );
|
||||
delete_site_transient( 'update_themes' );
|
||||
}
|
||||
|
||||
|
||||
public function add_update_checks(){
|
||||
|
||||
add_filter('pre_set_site_transient_update_plugins', array(&$this, 'set_update_transient'));
|
||||
add_filter('plugins_api', array(&$this, 'set_updates_api_results'), 10, 3);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function set_update_transient($transient) {
|
||||
|
||||
$this->_check_updates();
|
||||
|
||||
if(isset($transient) && !isset($transient->response)) {
|
||||
$transient->response = array();
|
||||
}
|
||||
|
||||
if(!empty($this->data->basic) && is_object($this->data->basic)) {
|
||||
if(version_compare($this->version, $this->data->basic->version, '<')) {
|
||||
|
||||
$this->data->basic->new_version = $this->data->basic->version;
|
||||
$transient->response[$this->plugin_path] = $this->data->basic;
|
||||
}
|
||||
}
|
||||
|
||||
return $transient;
|
||||
}
|
||||
|
||||
|
||||
public function set_updates_api_results($result, $action, $args) {
|
||||
|
||||
$this->_check_updates();
|
||||
|
||||
if(isset($args->slug) && $args->slug == $this->plugin_slug && $action == 'plugin_information') {
|
||||
if(is_object($this->data->full) && !empty($this->data->full)) {
|
||||
$result = $this->data->full;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
protected function _check_updates() {
|
||||
|
||||
$force_check = false;
|
||||
|
||||
if( (isset($_GET['checkforupdates']) && $_GET['checkforupdates'] == 'true') || isset($_GET["force-check"])) $force_check = true;
|
||||
|
||||
// Get data
|
||||
if(empty($this->data)) {
|
||||
$data = get_option($this->option, false);
|
||||
$data = $data ? $data : new stdClass;
|
||||
|
||||
$this->data = is_object($data) ? $data : maybe_unserialize($data);
|
||||
}
|
||||
|
||||
$last_check = get_option('rs_snow-update-check');
|
||||
|
||||
|
||||
if($last_check == false){ //first time called
|
||||
$last_check = time();
|
||||
update_option('rs_snow-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('rs_snow-update-check', time());
|
||||
|
||||
$this->data->checked = time();
|
||||
$this->data->basic = $data->basic;
|
||||
$this->data->full = $data->full;
|
||||
|
||||
//update_option('rs_snow-stable-version', $data->full->stable);
|
||||
update_option('rs_snow-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
|
||||
|
||||
$validated = get_option('rs_snow-valid', 'false');
|
||||
$purchase = (get_option('revslider-valid', 'false') == 'true') ? get_option('revslider-code', '') : '';
|
||||
$rattr = array(
|
||||
'code' => urlencode($purchase),
|
||||
'version' => urlencode($this->version)
|
||||
);
|
||||
|
||||
$request = wp_remote_post($this->remote_url_info, array(
|
||||
'user-agent' => 'WordPress/'.$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('rs_snow-update-check-short');
|
||||
if($last_check == false){ //first time called
|
||||
$last_check = time();
|
||||
update_option('rs_snow-update-check-short', $last_check);
|
||||
}
|
||||
|
||||
// Check for updates
|
||||
if(time() - $last_check > 172800 || $force_check == true){
|
||||
|
||||
|
||||
update_option('rs_snow-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' => 'WordPress/'.$wp_version.'; '.get_bloginfo('url'),
|
||||
'body' => array(
|
||||
'item' => urlencode('revslider-snow-addon'),
|
||||
'version' => urlencode($this->version),
|
||||
'code' => urlencode($purchase)
|
||||
)
|
||||
));
|
||||
|
||||
$response_code = wp_remote_retrieve_response_code( $response );
|
||||
$version_info = wp_remote_retrieve_body( $response );
|
||||
|
||||
if ( $response_code != 200 || is_wp_error( $version_info ) ) {
|
||||
update_option('rs_snow-connection', false);
|
||||
return false;
|
||||
}else{
|
||||
update_option('rs_snow-connection', true);
|
||||
}
|
||||
|
||||
/*
|
||||
$version_info = json_decode($version_info);
|
||||
if(isset($version_info->version)){
|
||||
update_option('rs_snow-latest-version', $version_info->version);
|
||||
}
|
||||
|
||||
if(isset($version_info->notices)){
|
||||
update_option('rs_snow-notices', $version_info->notices);
|
||||
}
|
||||
|
||||
if(isset($version_info->dashboard)){
|
||||
update_option('rs_snow-dashboard', $version_info->dashboard);
|
||||
}
|
||||
|
||||
if(isset($version_info->deactivated) && $version_info->deactivated === true){
|
||||
if(get_option('rs_snow-valid', 'false') == 'true'){
|
||||
//remove validation, add notice
|
||||
update_option('rs_snow-valid', 'false');
|
||||
update_option('rs_snow-deact-notice', true);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
if($force_check == true){ //force that the update will be directly searched
|
||||
update_option('rs_snow-update-check', '');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user