Version Description
- Added support for Gutenberg: sliders can now be inserted in a page or a post via the WordPress visual editor, no need to use shortcodes anymore (but it will still be supported).
- Fixed slider option "Start from slide" displaying only "Random slide", as reported here.
- Fixed an issue where it was displayed an unsuccessful error message when saving slides with no elements, despite the operation being successful.
Download this release
Release Info
Developer | fabiorino |
Plugin | Crelly Slider |
Version | 1.4.0 |
Comparing to | |
See all releases |
Code changes from version 1.3.7 to 1.4.0
- crellyslider.php +2 -2
- css/crellyslider.css +1 -1
- css/crellyslider.min.css +1 -1
- js/jquery.crellyslider.js +1 -1
- js/jquery.crellyslider.min.js +1 -1
- readme.txt +6 -1
- wordpress/admin.php +9 -0
- wordpress/ajax.php +54 -1
- wordpress/css/admin.css +51 -2
- wordpress/images/logo2.png +0 -0
- wordpress/js/gutenberg.js +170 -0
- wordpress/slider.php +13 -9
crellyslider.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Crelly Slider
|
4 |
* Plugin URI: https://wordpress.org/plugins/crelly-slider/
|
5 |
* Description: A free responsive slider that supports layers. Add texts, images, videos and beautify them with transitions and animations.
|
6 |
-
* Version: 1.
|
7 |
* Author: Fabio Rinaldi
|
8 |
* Author URI: https://github.com/fabiorino
|
9 |
* Text Domain: crelly-slider
|
@@ -18,7 +18,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|
18 |
|
19 |
define('CS_DEBUG', false);
|
20 |
|
21 |
-
define('CS_VERSION', '1.
|
22 |
define('CS_MIN_CAPABILITY', 'manage_options');
|
23 |
define('CS_PATH', plugin_dir_path(__FILE__));
|
24 |
define('CS_PLUGIN_URL', plugins_url() . '/crelly-slider');
|
3 |
* Plugin Name: Crelly Slider
|
4 |
* Plugin URI: https://wordpress.org/plugins/crelly-slider/
|
5 |
* Description: A free responsive slider that supports layers. Add texts, images, videos and beautify them with transitions and animations.
|
6 |
+
* Version: 1.4.0
|
7 |
* Author: Fabio Rinaldi
|
8 |
* Author URI: https://github.com/fabiorino
|
9 |
* Text Domain: crelly-slider
|
18 |
|
19 |
define('CS_DEBUG', false);
|
20 |
|
21 |
+
define('CS_VERSION', '1.4.0');
|
22 |
define('CS_MIN_CAPABILITY', 'manage_options');
|
23 |
define('CS_PATH', plugin_dir_path(__FILE__));
|
24 |
define('CS_PLUGIN_URL', plugins_url() . '/crelly-slider');
|
css/crellyslider.css
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
* Plugin Name: Crelly Slider
|
3 |
* Plugin URI: https://wordpress.org/plugins/crelly-slider/
|
4 |
* Description: A free responsive slider that supports layers. Add texts, images, videos and beautify them with transitions and animations.
|
5 |
-
* Version: 1.
|
6 |
* Author: Fabio Rinaldi
|
7 |
* Author URI: https://github.com/fabiorino
|
8 |
* License: MIT
|
2 |
* Plugin Name: Crelly Slider
|
3 |
* Plugin URI: https://wordpress.org/plugins/crelly-slider/
|
4 |
* Description: A free responsive slider that supports layers. Add texts, images, videos and beautify them with transitions and animations.
|
5 |
+
* Version: 1.4.0
|
6 |
* Author: Fabio Rinaldi
|
7 |
* Author URI: https://github.com/fabiorino
|
8 |
* License: MIT
|
css/crellyslider.min.css
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
* Plugin Name: Crelly Slider
|
3 |
* Plugin URI: https://wordpress.org/plugins/crelly-slider/
|
4 |
* Description: A free responsive slider that supports layers. Add texts, images, videos and beautify them with transitions and animations.
|
5 |
-
* Version: 1.
|
6 |
* Author: Fabio Rinaldi
|
7 |
* Author URI: https://github.com/fabiorino
|
8 |
* License: MIT
|
2 |
* Plugin Name: Crelly Slider
|
3 |
* Plugin URI: https://wordpress.org/plugins/crelly-slider/
|
4 |
* Description: A free responsive slider that supports layers. Add texts, images, videos and beautify them with transitions and animations.
|
5 |
+
* Version: 1.4.0
|
6 |
* Author: Fabio Rinaldi
|
7 |
* Author URI: https://github.com/fabiorino
|
8 |
* License: MIT
|
js/jquery.crellyslider.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
* Plugin Name: Crelly Slider
|
3 |
* Plugin URI: https://wordpress.org/plugins/crelly-slider/
|
4 |
* Description: A free responsive slider that supports layers. Add texts, images, videos and beautify them with transitions and animations.
|
5 |
-
* Version: 1.
|
6 |
* Author: Fabio Rinaldi
|
7 |
* Author URI: https://github.com/fabiorino
|
8 |
* License: MIT
|
2 |
* Plugin Name: Crelly Slider
|
3 |
* Plugin URI: https://wordpress.org/plugins/crelly-slider/
|
4 |
* Description: A free responsive slider that supports layers. Add texts, images, videos and beautify them with transitions and animations.
|
5 |
+
* Version: 1.4.0
|
6 |
* Author: Fabio Rinaldi
|
7 |
* Author URI: https://github.com/fabiorino
|
8 |
* License: MIT
|
js/jquery.crellyslider.min.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
* Plugin Name: Crelly Slider
|
3 |
* Plugin URI: https://wordpress.org/plugins/crelly-slider/
|
4 |
* Description: A free responsive slider that supports layers. Add texts, images, videos and beautify them with transitions and animations.
|
5 |
-
* Version: 1.
|
6 |
* Author: Fabio Rinaldi
|
7 |
* Author URI: https://github.com/fabiorino
|
8 |
* License: MIT
|
2 |
* Plugin Name: Crelly Slider
|
3 |
* Plugin URI: https://wordpress.org/plugins/crelly-slider/
|
4 |
* Description: A free responsive slider that supports layers. Add texts, images, videos and beautify them with transitions and animations.
|
5 |
+
* Version: 1.4.0
|
6 |
* Author: Fabio Rinaldi
|
7 |
* Author URI: https://github.com/fabiorino
|
8 |
* License: MIT
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://crellyslider.altervista.org/contribute-and-support/
|
|
4 |
Tags: animations, layers, texts, images, videos
|
5 |
Requires at least: 3.9
|
6 |
Tested up to: 5.4
|
7 |
-
Stable tag: 1.
|
8 |
License: MIT
|
9 |
License URI: http://opensource.org/licenses/MIT
|
10 |
|
@@ -54,6 +54,11 @@ You can find the documentation <a href="http://crellyslider.altervista.org/docum
|
|
54 |
|
55 |
== Changelog ==
|
56 |
|
|
|
|
|
|
|
|
|
|
|
57 |
= 1.3.7 =
|
58 |
* Fixed PHP warning "Array and string offset access syntax with curly braces is deprecated" as reported <a href="https://wordpress.org/support/topic/syntax-with-curly-braces-is-deprecated">here</a>
|
59 |
|
4 |
Tags: animations, layers, texts, images, videos
|
5 |
Requires at least: 3.9
|
6 |
Tested up to: 5.4
|
7 |
+
Stable tag: 1.4.0
|
8 |
License: MIT
|
9 |
License URI: http://opensource.org/licenses/MIT
|
10 |
|
54 |
|
55 |
== Changelog ==
|
56 |
|
57 |
+
= 1.4.0 =
|
58 |
+
* Added support for Gutenberg: sliders can now be inserted in a page or a post via the WordPress visual editor, no need to use shortcodes anymore (but it will still be supported).
|
59 |
+
* Fixed slider option "Start from slide" displaying only "Random slide", as reported <a href="https://wordpress.org/support/topic/start-slide-cannot-be-selected-if-random-start-slide-is-selected">here</a>.
|
60 |
+
* Fixed an issue where it was displayed an unsuccessful error message when saving slides with no elements, despite the operation being successful.
|
61 |
+
|
62 |
= 1.3.7 =
|
63 |
* Fixed PHP warning "Array and string offset access syntax with curly braces is deprecated" as reported <a href="https://wordpress.org/support/topic/syntax-with-curly-braces-is-deprecated">here</a>
|
64 |
|
wordpress/admin.php
CHANGED
@@ -268,6 +268,11 @@ class CrellySliderAdmin {
|
|
268 |
|
269 |
wp_enqueue_style('crellyslider-admin', CS_PLUGIN_URL . '/wordpress/css/admin.css', array(), CS_VERSION);
|
270 |
wp_enqueue_script('crellyslider-admin');
|
|
|
|
|
|
|
|
|
|
|
271 |
}
|
272 |
|
273 |
public static function loadAssets() {
|
@@ -289,6 +294,9 @@ class CrellySliderAdmin {
|
|
289 |
'remove_slide' => __('Delete slide', 'crelly-slider'),
|
290 |
'exit_without_saving' => __('All unsaved changes will be lost. Are you sure you want to leave this page?', 'crelly-slider'),
|
291 |
'switch_editor' => __('Switch editor', 'crelly-slider'),
|
|
|
|
|
|
|
292 |
);
|
293 |
wp_localize_script('crellyslider-admin', 'crellyslider_translations', $crellyslider_translations);
|
294 |
}
|
@@ -300,6 +308,7 @@ class CrellySliderAdmin {
|
|
300 |
'duplicateSlider' => wp_create_nonce('crellyslider_duplicate-slider'),
|
301 |
'exportSlider' => wp_create_nonce('crellyslider_export-slider'),
|
302 |
'importSlider' => wp_create_nonce('crellyslider_import-slider'),
|
|
|
303 |
);
|
304 |
|
305 |
wp_localize_script('crellyslider-admin', 'crellyslider_nonces', $nonces);
|
268 |
|
269 |
wp_enqueue_style('crellyslider-admin', CS_PLUGIN_URL . '/wordpress/css/admin.css', array(), CS_VERSION);
|
270 |
wp_enqueue_script('crellyslider-admin');
|
271 |
+
|
272 |
+
// Add Gutenberg block
|
273 |
+
if(function_exists('register_block_type')) {
|
274 |
+
wp_enqueue_script('crellyslider-gutenberg', CS_PLUGIN_URL . '/wordpress/js/gutenberg.js', array('wp-blocks', 'wp-element'), CS_VERSION, true);
|
275 |
+
}
|
276 |
}
|
277 |
|
278 |
public static function loadAssets() {
|
294 |
'remove_slide' => __('Delete slide', 'crelly-slider'),
|
295 |
'exit_without_saving' => __('All unsaved changes will be lost. Are you sure you want to leave this page?', 'crelly-slider'),
|
296 |
'switch_editor' => __('Switch editor', 'crelly-slider'),
|
297 |
+
'select_slider' => __('Select slider', 'crelly-slider'),
|
298 |
+
'no_sliders_found' => __('No sliders found. Do you want to <a href="admin.php?page=crellyslider&view=add">create one</a>?', 'crelly-slider'),
|
299 |
+
'no_sliders_selected' => __('No sliders selected. Edit this page and select a slider in the Crelly Slider editor block.', 'crelly-slider'),
|
300 |
);
|
301 |
wp_localize_script('crellyslider-admin', 'crellyslider_translations', $crellyslider_translations);
|
302 |
}
|
308 |
'duplicateSlider' => wp_create_nonce('crellyslider_duplicate-slider'),
|
309 |
'exportSlider' => wp_create_nonce('crellyslider_export-slider'),
|
310 |
'importSlider' => wp_create_nonce('crellyslider_import-slider'),
|
311 |
+
'listSlidersForGutenberg' => wp_create_nonce('crellyslider_list-sliders-for-gutenberg'),
|
312 |
);
|
313 |
|
314 |
wp_localize_script('crellyslider-admin', 'crellyslider_nonces', $nonces);
|
wordpress/ajax.php
CHANGED
@@ -65,6 +65,59 @@ function crellyslider_wp_insert_rows($row_arrays = array(), $wp_table_name) {
|
|
65 |
|
66 |
}
|
67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
// Add slider
|
69 |
add_action('wp_ajax_crellyslider_addSlider', 'crellyslider_addSlider_callback');
|
70 |
function crellyslider_addSlider_callback() {
|
@@ -311,7 +364,7 @@ function crellyslider_editElements_callback() {
|
|
311 |
if(empty(json_decode(stripslashes($options['options'])))) {
|
312 |
// Remove all the old elements
|
313 |
$output = $wpdb->delete($wpdb->prefix . 'crellyslider_elements', array('slider_parent' => esc_sql($options['slider_parent'])), array('%d'));
|
314 |
-
if(
|
315 |
echo json_encode(false);
|
316 |
}
|
317 |
// Generate new nonce and return it
|
65 |
|
66 |
}
|
67 |
|
68 |
+
add_action('wp_ajax_crellyslider_listSlidersForGutenberg', 'crellyslider_listSlidersForGutenberg_callback');
|
69 |
+
function crellyslider_listSlidersForGutenberg_callback() {
|
70 |
+
if(! check_ajax_referer('crellyslider_list-sliders-for-gutenberg', 'security', false)) {
|
71 |
+
die('Could not verify nonce');
|
72 |
+
}
|
73 |
+
|
74 |
+
class SliderForGutenbergBlock {
|
75 |
+
public $id;
|
76 |
+
public $name;
|
77 |
+
public $alias;
|
78 |
+
public $backgroundImage;
|
79 |
+
public $backgroundColor;
|
80 |
+
public $backgroundRepeat;
|
81 |
+
}
|
82 |
+
|
83 |
+
$slidersForGutenberg = array();
|
84 |
+
global $wpdb;
|
85 |
+
$sliders = $wpdb->get_results('SELECT id, alias, name FROM ' . $wpdb->prefix . 'crellyslider_sliders');
|
86 |
+
if($sliders->last_error) {
|
87 |
+
echo json_encode(false);
|
88 |
+
die();
|
89 |
+
}
|
90 |
+
foreach($sliders as $slider) {
|
91 |
+
$sliderForGutenberg = new SliderForGutenbergBlock();
|
92 |
+
$sliderID = $slider->id;
|
93 |
+
$sliderForGutenberg->id = $sliderID;
|
94 |
+
$sliderForGutenberg->name = $slider->name;
|
95 |
+
$sliderForGutenberg->alias = $slider->alias;
|
96 |
+
$slide = $wpdb->get_results($wpdb->prepare(
|
97 |
+
'SELECT background_type_image, background_type_color, background_repeat FROM ' . $wpdb->prefix . 'crellyslider_slides WHERE slider_parent = %d AND position = 0 AND draft = 0', $sliderID
|
98 |
+
));
|
99 |
+
if($slide->last_error) {
|
100 |
+
echo json_encode(false);
|
101 |
+
die();
|
102 |
+
}
|
103 |
+
if($slide) {
|
104 |
+
$slide = $slide[0];
|
105 |
+
if($slide->background_type_image != 'undefined' && $slide->background_type_image != 'none') {
|
106 |
+
$sliderForGutenberg->backgroundImage = CrellySliderCommon::getURL($slide->background_type_image);
|
107 |
+
}
|
108 |
+
$sliderForGutenberg->backgroundColor = esc_attr($slide->background_type_color);
|
109 |
+
$sliderForGutenberg->backgroundRepeat = esc_attr($slide->background_repeat);
|
110 |
+
}
|
111 |
+
$slidersForGutenberg[$slider->alias] = $sliderForGutenberg;
|
112 |
+
}
|
113 |
+
if(! $slidersForGutenberg) {
|
114 |
+
echo json_encode(null);
|
115 |
+
die();
|
116 |
+
}
|
117 |
+
echo json_encode($slidersForGutenberg);
|
118 |
+
die();
|
119 |
+
}
|
120 |
+
|
121 |
// Add slider
|
122 |
add_action('wp_ajax_crellyslider_addSlider', 'crellyslider_addSlider_callback');
|
123 |
function crellyslider_addSlider_callback() {
|
364 |
if(empty(json_decode(stripslashes($options['options'])))) {
|
365 |
// Remove all the old elements
|
366 |
$output = $wpdb->delete($wpdb->prefix . 'crellyslider_elements', array('slider_parent' => esc_sql($options['slider_parent'])), array('%d'));
|
367 |
+
if($output === false) {
|
368 |
echo json_encode(false);
|
369 |
}
|
370 |
// Generate new nonce and return it
|
wordpress/css/admin.css
CHANGED
@@ -495,7 +495,9 @@
|
|
495 |
}
|
496 |
|
497 |
.cs-admin .cs-slide .cs-slide-editing-area:before,
|
498 |
-
.cs-admin .cs-slide .cs-slide-editing-area:after
|
|
|
|
|
499 |
z-index: -1;
|
500 |
position: absolute;
|
501 |
content: "";
|
@@ -515,7 +517,8 @@
|
|
515 |
transform: rotate(-3deg);
|
516 |
}
|
517 |
|
518 |
-
.cs-admin .cs-slide .cs-slide-editing-area:after
|
|
|
519 |
-webkit-transform: rotate(3deg);
|
520 |
-moz-transform: rotate(3deg);
|
521 |
-o-transform: rotate(3deg);
|
@@ -589,3 +592,49 @@
|
|
589 |
width: 110px;
|
590 |
cursor: default;
|
591 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
495 |
}
|
496 |
|
497 |
.cs-admin .cs-slide .cs-slide-editing-area:before,
|
498 |
+
.cs-admin .cs-slide .cs-slide-editing-area:after,
|
499 |
+
.cs-gutenberg:before,
|
500 |
+
.cs-gutenberg:after {
|
501 |
z-index: -1;
|
502 |
position: absolute;
|
503 |
content: "";
|
517 |
transform: rotate(-3deg);
|
518 |
}
|
519 |
|
520 |
+
.cs-admin .cs-slide .cs-slide-editing-area:after,
|
521 |
+
.cs-gutenberg:after {
|
522 |
-webkit-transform: rotate(3deg);
|
523 |
-moz-transform: rotate(3deg);
|
524 |
-o-transform: rotate(3deg);
|
592 |
width: 110px;
|
593 |
cursor: default;
|
594 |
}
|
595 |
+
|
596 |
+
.cs-gutenberg {
|
597 |
+
height: 200px;
|
598 |
+
display: flex;
|
599 |
+
align-items: center;
|
600 |
+
justify-content: center;
|
601 |
+
width: 100%;
|
602 |
+
border-radius: 4px;
|
603 |
+
border: solid 1px #eee;
|
604 |
+
border-bottom: 0;
|
605 |
+
position: relative;
|
606 |
+
background-color: #fff;
|
607 |
+
}
|
608 |
+
|
609 |
+
.cs-gutenberg-background {
|
610 |
+
position: absolute;
|
611 |
+
top: 0;
|
612 |
+
left: 0;
|
613 |
+
width: 100%;
|
614 |
+
height: 100%;
|
615 |
+
background-color: #fff;
|
616 |
+
z-index: 1;
|
617 |
+
}
|
618 |
+
|
619 |
+
.cs-gutenberg-content {
|
620 |
+
z-index: 2;
|
621 |
+
background: rgba(255, 255, 255, .9);
|
622 |
+
font-size: 14px;
|
623 |
+
color: #000;
|
624 |
+
font-family: 'Verdana', sans-serif;
|
625 |
+
line-height: 0;
|
626 |
+
border-radius: 5px;
|
627 |
+
padding: 5px 10px;
|
628 |
+
border: solid 1px rgba(0, 0, 0, .1);
|
629 |
+
}
|
630 |
+
|
631 |
+
.cs-gutenberg-content > span {
|
632 |
+
padding-right: 10px;
|
633 |
+
display: inline-block;
|
634 |
+
vertical-align: top;
|
635 |
+
margin-top: 15px;
|
636 |
+
}
|
637 |
+
|
638 |
+
.cs-gutenberg-content > select {
|
639 |
+
display: inline-block;
|
640 |
+
}
|
wordpress/images/logo2.png
CHANGED
Binary file
|
wordpress/js/gutenberg.js
ADDED
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// List of sliders retreived via ajax. Stored here to avoid querying it again unnecessarily
|
2 |
+
var crellyslider_gutenberg_sliders = null;
|
3 |
+
|
4 |
+
// Logo for Gutenberg block
|
5 |
+
var crellyslider_gutenberg_icon = wp.element.createElement(
|
6 |
+
'svg',
|
7 |
+
{
|
8 |
+
width: 20,
|
9 |
+
height: 24
|
10 |
+
},
|
11 |
+
wp.element.createElement(
|
12 |
+
'path',
|
13 |
+
{
|
14 |
+
d: "M 11.266136,2.2402648e-6 C 8.3735841,-0.00180026 5.4876887,1.084094 3.2859425,3.2856146 1.0878015,5.4835305 0.0018025,8.3778831 0,11.265478 l 3.300473e-4,0.01617 v -0.01617 H 5.8583247 C 5.8594569,9.8793604 6.3802566,8.4904236 7.4356167,7.4352888 8.4921033,6.378577 9.8777651,5.8570955 11.266136,5.8579969 c 1.385892,8.956e-4 2.775054,0.5223824 3.830189,1.5772919 L 19.246,3.2856146 C 17.048083,1.0879244 14.15373,0.00203004 11.266136,2.2402648e-6 Z M 11.265798,24.00032 c -7.5105374,-16.0002118 -3.7552686,-8.000106 0,0 z M 7.435737,16.564764 c 1.056712,1.05626 2.4419284,1.578082 3.830299,1.577182 1.385667,-8.45e-4 2.77539,-0.522047 3.830299,-1.577182 l 4.149567,4.149791 c -2.197917,2.197916 -5.092271,3.283918 -7.980091,3.285946 C 8.3734844,24.002304 5.4874666,22.916076 3.285946,20.714555 1.087805,18.516639 0.0018025,15.622285 0,12.734691 l 4.50624e-4,-0.01622 v 0.01622 H 5.8583298 c 0.00113,1.385667 0.5222726,2.774939 1.5774072,3.830073"
|
15 |
+
}
|
16 |
+
)
|
17 |
+
);
|
18 |
+
|
19 |
+
wp.blocks.registerBlockType('crelly-slider/slider', {
|
20 |
+
title: 'Crelly Slider',
|
21 |
+
category: 'common',
|
22 |
+
attributes: {
|
23 |
+
sliderAlias: {
|
24 |
+
type: 'string'
|
25 |
+
}
|
26 |
+
},
|
27 |
+
icon: crellyslider_gutenberg_icon,
|
28 |
+
supports: {
|
29 |
+
customClassName: false,
|
30 |
+
html: false,
|
31 |
+
},
|
32 |
+
|
33 |
+
edit: function (props) {
|
34 |
+
var el = wp.element.createElement;
|
35 |
+
|
36 |
+
// Get the list of sliders and the background of their first slide
|
37 |
+
if(crellyslider_gutenberg_sliders == null) {
|
38 |
+
jQuery.ajax({
|
39 |
+
type : 'POST',
|
40 |
+
url : ajaxurl,
|
41 |
+
async: false,
|
42 |
+
data : {
|
43 |
+
action: 'crellyslider_listSlidersForGutenberg',
|
44 |
+
security: crellyslider_nonces.listSlidersForGutenberg,
|
45 |
+
},
|
46 |
+
success: function(response) {
|
47 |
+
crellyslider_gutenberg_sliders = JSON.parse(response);
|
48 |
+
},
|
49 |
+
|
50 |
+
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
51 |
+
alert('Cannot request sliders list');
|
52 |
+
console.log(XMLHttpRequest.responseText);
|
53 |
+
}
|
54 |
+
});
|
55 |
+
}
|
56 |
+
|
57 |
+
// Print no sliders found msg
|
58 |
+
if(crellyslider_gutenberg_sliders == null) {
|
59 |
+
return el(
|
60 |
+
'div',
|
61 |
+
{
|
62 |
+
className: props.className + " cs-gutenberg",
|
63 |
+
dangerouslySetInnerHTML: {
|
64 |
+
__html: crellyslider_translations.no_sliders_found
|
65 |
+
}
|
66 |
+
}
|
67 |
+
);
|
68 |
+
}
|
69 |
+
|
70 |
+
var attributes = props.attributes;
|
71 |
+
var savedAlias = attributes.sliderAlias;
|
72 |
+
|
73 |
+
// Generate the list of <option> containing the slider info
|
74 |
+
var options = [];
|
75 |
+
for(var i in crellyslider_gutenberg_sliders) {
|
76 |
+
s = crellyslider_gutenberg_sliders[i];
|
77 |
+
if(s['alias'] == savedAlias) {
|
78 |
+
o = el('option', {value: s['alias'], selected: true}, s['name']);
|
79 |
+
}
|
80 |
+
else {
|
81 |
+
o = el('option', {value: s['alias']}, s['name']);
|
82 |
+
}
|
83 |
+
options.push(o);
|
84 |
+
}
|
85 |
+
|
86 |
+
// Generate the <select> containing the options
|
87 |
+
var select = el(
|
88 |
+
'select',
|
89 |
+
{
|
90 |
+
onChange: function(event) {
|
91 |
+
var alias = event.target.value;
|
92 |
+
if(alias == 'crellyslider-no-slider') {
|
93 |
+
alias = null;
|
94 |
+
}
|
95 |
+
props.setAttributes({
|
96 |
+
sliderAlias: alias
|
97 |
+
});
|
98 |
+
}
|
99 |
+
},
|
100 |
+
el('option', {value: 'crellyslider-no-slider'}, crellyslider_translations.select_slider),
|
101 |
+
options
|
102 |
+
);
|
103 |
+
|
104 |
+
// Generate text sitting next to the select menu
|
105 |
+
var text = el(
|
106 |
+
'span',
|
107 |
+
{},
|
108 |
+
"Crelly Slider"
|
109 |
+
);
|
110 |
+
|
111 |
+
// Wrap content generated above
|
112 |
+
var content = el(
|
113 |
+
'div',
|
114 |
+
{
|
115 |
+
className: "cs-gutenberg-content",
|
116 |
+
},
|
117 |
+
text, select
|
118 |
+
);
|
119 |
+
|
120 |
+
// Generate block background. If the first slide has a background color and/or image, that will be used.
|
121 |
+
// Otherwise, the background will be set to #fff.
|
122 |
+
// Non-pattern background images will be centered and have background-size set to 'cover'
|
123 |
+
var background;
|
124 |
+
if(savedAlias != null) {
|
125 |
+
var selectedSlider = crellyslider_gutenberg_sliders[savedAlias];
|
126 |
+
background = el(
|
127 |
+
'div',
|
128 |
+
{
|
129 |
+
className: "cs-gutenberg-background",
|
130 |
+
style: {
|
131 |
+
backgroundColor: selectedSlider.backgroundColor == 'transparent' ? '#fff' : selectedSlider.backgroundColor,
|
132 |
+
backgroundImage: selectedSlider.backgroundImage == null ? 'none' : 'url("' + selectedSlider.backgroundImage + '")',
|
133 |
+
backgroundRepeat: selectedSlider.backgroundRepeat,
|
134 |
+
backgroundSize: selectedSlider.backgroundRepeat == 'repeat' ? 'auto' : 'cover',
|
135 |
+
backgroundPosition: selectedSlider.backgroundRepeat == 'repeat' ? '0 0' : 'center center',
|
136 |
+
}
|
137 |
+
}
|
138 |
+
);
|
139 |
+
}
|
140 |
+
else {
|
141 |
+
background = el(
|
142 |
+
'div',
|
143 |
+
{
|
144 |
+
className: "cs-gutenberg-background",
|
145 |
+
}
|
146 |
+
);
|
147 |
+
}
|
148 |
+
|
149 |
+
// Wrap background and content
|
150 |
+
var wrapper = el(
|
151 |
+
'div',
|
152 |
+
{
|
153 |
+
className: props.className + " cs-gutenberg",
|
154 |
+
},
|
155 |
+
background,
|
156 |
+
content
|
157 |
+
);
|
158 |
+
|
159 |
+
return wrapper;
|
160 |
+
},
|
161 |
+
|
162 |
+
save: function(props) {
|
163 |
+
var attributes = props.attributes;
|
164 |
+
var alias = attributes.sliderAlias;
|
165 |
+
if(alias == null) {
|
166 |
+
return crellyslider_translations.no_sliders_selected;
|
167 |
+
}
|
168 |
+
return '[crellyslider alias="' + alias + '"]';
|
169 |
+
},
|
170 |
+
});
|
wordpress/slider.php
CHANGED
@@ -273,11 +273,15 @@
|
|
273 |
echo '<option selected value="0">' . __('Slide', 'crelly-slider') . ' 1</option>';
|
274 |
}
|
275 |
else {
|
|
|
276 |
if($slider->startFromSlide == -1) {
|
277 |
echo '<option selected value="-1">' . __('Random slide', 'crelly-slider') . '</option>';
|
278 |
}
|
279 |
else {
|
280 |
echo '<option value="-1">' . __('Random slide', 'crelly-slider') . '</option>';
|
|
|
|
|
|
|
281 |
for($i = 0; $i < count($slides); $i++) {
|
282 |
echo '<option value="' . $i . '"';
|
283 |
if($slider->startFromSlide == $i) {
|
@@ -296,22 +300,22 @@
|
|
296 |
</tr>
|
297 |
<tr>
|
298 |
<td class="cs-name"><?php _e('Display slider from/to', 'crelly-slider'); ?></td>
|
299 |
-
<td class="cs-content">
|
300 |
<?php
|
301 |
$minDate = '1000-01-01 00:00:00';
|
302 |
$maxDate = '9999-12-31 23:59:59';
|
303 |
|
304 |
-
if(!$edit || ($edit && $slider->fromDate == $minDate)) echo '<input checked id="cs-slider-displayImmediately" type="checkbox">' . __('Display from now', 'crelly-slider');
|
305 |
-
else echo '<input id="cs-slider-displayImmediately" type="checkbox">' . __('Display from now', 'crelly-slider');
|
306 |
|
307 |
if(!$edit || ($edit && $slider->fromDate == $minDate)) echo '<div style="display: none;" id="cs-slider-displayFromWrapper">';
|
308 |
else echo '<div id="cs-slider-displayFromWrapper">';
|
309 |
-
|
310 |
echo '<br />';
|
311 |
_e('Display from', 'crelly-slider');
|
312 |
echo ':<br />';
|
313 |
if(!$edit || ($edit && $slider->fromDate == $minDate)) echo '<input class="cs-slider-datepicker" id="cs-slider-fromDate" type="text" />';
|
314 |
-
else echo '<input class="cs-slider-datepicker" id="cs-slider-fromDate" type="text" value="' . sanitize_text_field($slider->fromDate) .'" />';
|
315 |
|
316 |
echo '</div>';
|
317 |
?>
|
@@ -320,17 +324,17 @@
|
|
320 |
<br />
|
321 |
|
322 |
<?php
|
323 |
-
if(!$edit || ($edit && $slider->toDate == $maxDate)) echo '<input checked id="cs-slider-displayForever" type="checkbox">' . __('Display forever', 'crelly-slider');
|
324 |
-
else echo '<input id="cs-slider-displayForever" type="checkbox">' . __('Display forever', 'crelly-slider');
|
325 |
|
326 |
if(!$edit || ($edit && $slider->toDate == $maxDate)) echo '<div style="display: none;" id="cs-slider-displayToWrapper">';
|
327 |
else echo '<div id="cs-slider-displayToWrapper">';
|
328 |
-
|
329 |
echo '<br />';
|
330 |
_e('Display to', 'crelly-slider');
|
331 |
echo ':<br />';
|
332 |
if(!$edit || ($edit && $slider->toDate == $maxDate)) echo '<input class="cs-slider-datepicker" id="cs-slider-toDate" type="text" />';
|
333 |
-
else echo '<input class="cs-slider-datepicker" id="cs-slider-toDate" type="text" value="' . sanitize_text_field($slider->toDate) .'" />';
|
334 |
|
335 |
echo '</div>';
|
336 |
?>
|
273 |
echo '<option selected value="0">' . __('Slide', 'crelly-slider') . ' 1</option>';
|
274 |
}
|
275 |
else {
|
276 |
+
// The first option is the "Random slide" link
|
277 |
if($slider->startFromSlide == -1) {
|
278 |
echo '<option selected value="-1">' . __('Random slide', 'crelly-slider') . '</option>';
|
279 |
}
|
280 |
else {
|
281 |
echo '<option value="-1">' . __('Random slide', 'crelly-slider') . '</option>';
|
282 |
+
}
|
283 |
+
// Then, add all the other slide links
|
284 |
+
if(is_array($slides)) {
|
285 |
for($i = 0; $i < count($slides); $i++) {
|
286 |
echo '<option value="' . $i . '"';
|
287 |
if($slider->startFromSlide == $i) {
|
300 |
</tr>
|
301 |
<tr>
|
302 |
<td class="cs-name"><?php _e('Display slider from/to', 'crelly-slider'); ?></td>
|
303 |
+
<td class="cs-content">
|
304 |
<?php
|
305 |
$minDate = '1000-01-01 00:00:00';
|
306 |
$maxDate = '9999-12-31 23:59:59';
|
307 |
|
308 |
+
if(!$edit || ($edit && $slider->fromDate == $minDate)) echo '<input checked id="cs-slider-displayImmediately" type="checkbox">' . __('Display from now', 'crelly-slider');
|
309 |
+
else echo '<input id="cs-slider-displayImmediately" type="checkbox">' . __('Display from now', 'crelly-slider');
|
310 |
|
311 |
if(!$edit || ($edit && $slider->fromDate == $minDate)) echo '<div style="display: none;" id="cs-slider-displayFromWrapper">';
|
312 |
else echo '<div id="cs-slider-displayFromWrapper">';
|
313 |
+
|
314 |
echo '<br />';
|
315 |
_e('Display from', 'crelly-slider');
|
316 |
echo ':<br />';
|
317 |
if(!$edit || ($edit && $slider->fromDate == $minDate)) echo '<input class="cs-slider-datepicker" id="cs-slider-fromDate" type="text" />';
|
318 |
+
else echo '<input class="cs-slider-datepicker" id="cs-slider-fromDate" type="text" value="' . sanitize_text_field($slider->fromDate) .'" />';
|
319 |
|
320 |
echo '</div>';
|
321 |
?>
|
324 |
<br />
|
325 |
|
326 |
<?php
|
327 |
+
if(!$edit || ($edit && $slider->toDate == $maxDate)) echo '<input checked id="cs-slider-displayForever" type="checkbox">' . __('Display forever', 'crelly-slider');
|
328 |
+
else echo '<input id="cs-slider-displayForever" type="checkbox">' . __('Display forever', 'crelly-slider');
|
329 |
|
330 |
if(!$edit || ($edit && $slider->toDate == $maxDate)) echo '<div style="display: none;" id="cs-slider-displayToWrapper">';
|
331 |
else echo '<div id="cs-slider-displayToWrapper">';
|
332 |
+
|
333 |
echo '<br />';
|
334 |
_e('Display to', 'crelly-slider');
|
335 |
echo ':<br />';
|
336 |
if(!$edit || ($edit && $slider->toDate == $maxDate)) echo '<input class="cs-slider-datepicker" id="cs-slider-toDate" type="text" />';
|
337 |
+
else echo '<input class="cs-slider-datepicker" id="cs-slider-toDate" type="text" value="' . sanitize_text_field($slider->toDate) .'" />';
|
338 |
|
339 |
echo '</div>';
|
340 |
?>
|