LoftLoader - Version 2.1.6

Version Description

  • Improved: Any Page Extension meta box redesigned to fit in Gutenberg Sidebar
Download this release

Release Info

Developer loftocean
Plugin Icon 128x128 LoftLoader
Version 2.1.6
Comparing to
See all releases

Code changes from version 2.1.5 to 2.1.6

assets/css/loftloader-settings.css CHANGED
@@ -6,7 +6,7 @@
6
  * Author: Kaylolo Yinxi Chen @Loft.Ocean
7
  * Author URI: http://www.loftocean.com
8
  * Description: LoftLoader (Lite Version) is a plugin for adding beautiful and smooth preload animation to your WordPress website. With setting options, you can choose from preset animations, add custom logo image, choose colours to match your branding, and amuse and impress your visitors while loading site content.
9
- * Version: 2.1.5
10
  */
11
  @import url(https://fonts.googleapis.com/css?family=Lato:400,600);
12
  #customize-theme-controls.loftloader-controls-wrapper {
6
  * Author: Kaylolo Yinxi Chen @Loft.Ocean
7
  * Author URI: http://www.loftocean.com
8
  * Description: LoftLoader (Lite Version) is a plugin for adding beautiful and smooth preload animation to your WordPress website. With setting options, you can choose from preset animations, add custom logo image, choose colours to match your branding, and amuse and impress your visitors while loading site content.
9
+ * Version: 2.1.6
10
  */
11
  @import url(https://fonts.googleapis.com/css?family=Lato:400,600);
12
  #customize-theme-controls.loftloader-controls-wrapper {
assets/css/loftloader.css CHANGED
@@ -6,7 +6,7 @@
6
  * Author: Kaylolo Yinxi Chen @Loft.Ocean
7
  * Author URI: http://www.loftocean.com
8
  * Description: LoftLoader (Lite Version) is a plugin for adding beautiful and smooth preload animation to your WordPress website. With setting options, you can choose from preset animations, add custom logo image, choose colours to match your branding, and amuse and impress your visitors while loading site content.
9
- * Version: 2.1.5
10
  */
11
  @-webkit-keyframes spinReturn {
12
  0% {
6
  * Author: Kaylolo Yinxi Chen @Loft.Ocean
7
  * Author URI: http://www.loftocean.com
8
  * Description: LoftLoader (Lite Version) is a plugin for adding beautiful and smooth preload animation to your WordPress website. With setting options, you can choose from preset animations, add custom logo image, choose colours to match your branding, and amuse and impress your visitors while loading site content.
9
+ * Version: 2.1.6
10
  */
11
  @-webkit-keyframes spinReturn {
12
  0% {
assets/js/customize.js CHANGED
@@ -139,6 +139,9 @@
139
  'square': [
140
  'loftloader_loader_color'
141
  ],
 
 
 
142
  'frame': [
143
  'loftloader_loader_color',
144
  'loftloader_custom_img'
139
  'square': [
140
  'loftloader_loader_color'
141
  ],
142
+ 'beating': [
143
+ 'loftloader_loader_color'
144
+ ],
145
  'frame': [
146
  'loftloader_loader_color',
147
  'loftloader_custom_img'
assets/js/customize.min.js CHANGED
@@ -1,183 +1 @@
1
- /**
2
- * Copyright (c) Loft.Ocean
3
- * http://www.loftocean.com
4
- */
5
-
6
- (function(api, $){
7
- $('head').append($('<style>', {'id': 'loftloader-hide-site-title', 'text': '.site-title { opacity: 0; }'}));
8
- // Main Switch section
9
- api.LoftLoaderSwitchSection = api.Section.extend({
10
- initialize: function () {
11
- return api.Section.prototype.initialize.apply( this, arguments );
12
- },
13
- ready: function(){
14
- var checked = this.container.find('input[name=loftloader-main-switch]').attr('checked') ? true : false;
15
- checked ? '' : $('#customize-theme-controls').addClass('loftloader-settings-disabled');
16
- $('#customize-theme-controls').addClass('loftloader-controls-wrapper');
17
- },
18
- attachEvents: function () {
19
- var container = this.container;
20
- container.on('change', 'input[name=loftloader-main-switch]', function(e){
21
- var checked = $(this).attr('checked') ? true : false,
22
- $element = container.find('#customize-control-loftloader_main_switch input[type=checkbox]'),
23
- controls_wrap = $('#customize-theme-controls');
24
-
25
- checked ? $element.attr('checked', 'checked') : $element.removeAttr('checked');
26
- $element.trigger('change');
27
- checked ? controls_wrap.removeClass('loftloader-settings-disabled') : controls_wrap.addClass('loftloader-settings-disabled');
28
- });
29
- }
30
- });
31
- $.extend(api.sectionConstructor, {loftloader_switch: api.LoftLoaderSwitchSection});
32
-
33
- // Slider control
34
- api.controlConstructor.slider = api.Control.extend({
35
- ready: function(){
36
- var elem = this.container.find('.loader-ui-slider'),
37
- input = this.container.find('input[data-customize-setting-link]');
38
- elem.slider({
39
- 'range': 'min',
40
- 'min': elem.data('min'),
41
- 'max': elem.data('max'),
42
- 'value': elem.data('value'),
43
- 'step': elem.data('step'),
44
- 'slide': function(event, ui){
45
- input.val(ui.value).trigger('change');
46
- }
47
- });
48
- }
49
- });
50
-
51
- // Register event handler for hide controls/description
52
- api.bind('ready', function(e){
53
- // Change the site title in string "You are customizing ..."
54
- loftloader_lite_i18n ? $('.site-title').text(loftloader_lite_i18n.name) : '';
55
- $('#loftloader-hide-site-title').remove();
56
-
57
- // Init for loader 2.0 customizer, when sync from lower version
58
- var settings = api.get(),
59
- $custom_img = $('#customize-control-loftloader_custom_img');
60
- if($custom_img.length && !$custom_img.find('.attachment-thumb').length && settings && settings['loftloader_custom_img']){
61
- var image = settings['loftloader_custom_img'];
62
- if(image){
63
- var $container = $custom_img.find('.attachment-media-view').addClass('attachment-media-view-image'),
64
- $image = $('<div>', {'class': "thumbnail thumbnail-image"}).append($('<img>', {'class': "attachment-thumb", 'src': image}));
65
-
66
- $container.children('.placeholder').css('display', 'none').after($image).remove();
67
- }
68
- }
69
-
70
- $('body')
71
- .on('change', 'input[type=number]', function(e){
72
- var val = parseInt($(this).val()),
73
- min = $(this).attr('min') ? parseInt($(this).attr('min')) : 1;
74
- (val < min) ? $(this).val(min).trigger('change') : '';
75
- })
76
- .on('change', 'input.loftlader-checkbox', function(e){
77
- var checked = $(this).attr('checked') ? true : false,
78
- $element = $(this).siblings('input');
79
- if($element.length){
80
- checked ? $element.attr('checked', 'checked') : $element.removeAttr('checked');
81
- $element.trigger('change');
82
- }
83
- })
84
- .on('click', '.customize-more-toggle', function(e){
85
- e.preventDefault();
86
- var self = $(this),
87
- description = $(this).siblings('.customize-control-description');
88
-
89
- if(description.length){
90
- self.hasClass('expanded') ? description.slideUp('slow') : description.slideDown('slow', function(){ $(this).css('display', 'block'); });
91
- self.toggleClass('expanded');
92
- }
93
- })
94
- .on('click', '.loftloader-any-page-generate', function(e){
95
- e.preventDefault();
96
- var shortcode = api.loftloader_generate_parameters();
97
- $(this).siblings('.loftloader-any-page-shortcode').val('[loftloader ' + shortcode + ']').select();
98
- });
99
- });
100
-
101
- /**
102
- * Convert to string 'on' if current value is boolean true (not other value equals to true)
103
- * @param value mix, the value to check
104
- * @return mix, string 'on' if current value equals to boolean true, otherwise return the original value.
105
- */
106
- function loftloader_check_boolean(value){
107
- return (value === true) ? 'on' : value;
108
- }
109
- /**
110
- * Get customize setting value
111
- * @param id string, the setting id
112
- * @return mix, return dirty value/setting value or false (the id not exists)
113
- **/
114
- function loftloader_get_setting_value(id){
115
- var settings = api.get(), //settings.settings, dirty_values = api.dirtyValues(),
116
- value = settings[id] ? settings[id] : false; //dirty_values[id] ? dirty_values[id] : (settings[id] ? settings[id]['value'] : false);
117
- if(typeof value === 'string'){
118
- value = value.trim();
119
- }
120
- return loftloader_check_boolean(value);
121
- }
122
-
123
- // Generate loftloader parameters
124
- api.loftloader_generate_parameters = function(){
125
- var dependency = {
126
- 'loftloader_bg_color': {},
127
- 'loftloader_bg_opacity': {},
128
- 'loftloader_bg_animation': {},
129
- 'loftloader_loader_type': {
130
- 'sun': [
131
- 'loftloader_loader_color'
132
- ],
133
- 'circles': [
134
- 'loftloader_loader_color'
135
- ],
136
- 'wave': [
137
- 'loftloader_loader_color'
138
- ],
139
- 'square': [
140
- 'loftloader_loader_color'
141
- ],
142
- 'frame': [
143
- 'loftloader_loader_color',
144
- 'loftloader_custom_img'
145
- ],
146
- 'imgloading': [
147
- 'loftloader_custom_img',
148
- 'loftloader_img_width'
149
- ]
150
- },
151
- 'loftloader_show_close_timer': {},
152
- 'loftloader_show_close_tip': {}
153
- };
154
- var loftloader = type_value = loop = '';
155
- if(loftloader_get_setting_value('loftloader_main_switch') === 'on'){
156
- loftloader = 'loftloader_main_switch=on loftloader_show_range=sitewide';
157
- for(var id in dependency){
158
- type_value = loftloader_get_setting_value(id);
159
- switch(id){
160
- case 'loftloader_show_close_tip':
161
- type_value = type_value ? ( '"' + btoa( unescape( encodeURIComponent( type_value ) ) ) + '"' ) : '""';
162
- case 'loftloader_bg_color':
163
- case 'loftloader_bg_opacity':
164
- case 'loftloader_bg_animation':
165
- loop = [];
166
- break;
167
- default:
168
- loop = dependency[id][type_value] ? dependency[id][type_value] : [];
169
- }
170
- loftloader += ' ' + id + '=' + type_value;
171
- if(loop){
172
- for(var j in loop){
173
- loftloader += ' ' + loop[j] + '=' + loftloader_get_setting_value(loop[j]);
174
- }
175
- }
176
- }
177
- }
178
- else{
179
- loftloader = 'loftloader_main_switch=false';
180
- }
181
- return loftloader;
182
- }
183
- })(wp.customize, jQuery);
1
+ !function(n,r){function l(e){var t,o=n.get(),a=!!o[e]&&o[e];return"string"==typeof a&&(a=a.trim()),!0===(t=a)?"on":t}r("head").append(r("<style>",{id:"loftloader-hide-site-title",text:".site-title { opacity: 0; }"})),n.LoftLoaderSwitchSection=n.Section.extend({initialize:function(){return n.Section.prototype.initialize.apply(this,arguments)},ready:function(){!!!this.container.find("input[name=loftloader-main-switch]").attr("checked")&&r("#customize-theme-controls").addClass("loftloader-settings-disabled"),r("#customize-theme-controls").addClass("loftloader-controls-wrapper")},attachEvents:function(){var l=this.container;l.on("change","input[name=loftloader-main-switch]",function(e){var t=!!r(this).attr("checked"),o=l.find("#customize-control-loftloader_main_switch input[type=checkbox]"),a=r("#customize-theme-controls");t?o.attr("checked","checked"):o.removeAttr("checked"),o.trigger("change"),t?a.removeClass("loftloader-settings-disabled"):a.addClass("loftloader-settings-disabled")})}}),r.extend(n.sectionConstructor,{loftloader_switch:n.LoftLoaderSwitchSection}),n.controlConstructor.slider=n.Control.extend({ready:function(){var e=this.container.find(".loader-ui-slider"),o=this.container.find("input[data-customize-setting-link]");e.slider({range:"min",min:e.data("min"),max:e.data("max"),value:e.data("value"),step:e.data("step"),slide:function(e,t){o.val(t.value).trigger("change")}})}}),n.bind("ready",function(e){loftloader_lite_i18n&&r(".site-title").text(loftloader_lite_i18n.name),r("#loftloader-hide-site-title").remove();var t=n.get(),o=r("#customize-control-loftloader_custom_img");if(o.length&&!o.find(".attachment-thumb").length&&t&&t.loftloader_custom_img){var a=t.loftloader_custom_img;if(a){var l=o.find(".attachment-media-view").addClass("attachment-media-view-image"),i=r("<div>",{class:"thumbnail thumbnail-image"}).append(r("<img>",{class:"attachment-thumb",src:a}));l.children(".placeholder").css("display","none").after(i).remove()}}r("body").on("change","input[type=number]",function(e){var t=parseInt(r(this).val()),o=r(this).attr("min")?parseInt(r(this).attr("min")):1;t<o&&r(this).val(o).trigger("change")}).on("change","input.loftlader-checkbox",function(e){var t=!!r(this).attr("checked"),o=r(this).siblings("input");o.length&&(t?o.attr("checked","checked"):o.removeAttr("checked"),o.trigger("change"))}).on("click",".customize-more-toggle",function(e){e.preventDefault();var t=r(this),o=r(this).siblings(".customize-control-description");o.length&&(t.hasClass("expanded")?o.slideUp("slow"):o.slideDown("slow",function(){r(this).css("display","block")}),t.toggleClass("expanded"))}).on("click",".loftloader-any-page-generate",function(e){e.preventDefault();var t=n.loftloader_generate_parameters();r(this).siblings(".loftloader-any-page-shortcode").val("[loftloader "+t+"]").select()})}),n.loftloader_generate_parameters=function(){var e={loftloader_bg_color:{},loftloader_bg_opacity:{},loftloader_bg_animation:{},loftloader_loader_type:{sun:["loftloader_loader_color"],circles:["loftloader_loader_color"],wave:["loftloader_loader_color"],square:["loftloader_loader_color"],beating:["loftloader_loader_color"],frame:["loftloader_loader_color","loftloader_custom_img"],imgloading:["loftloader_custom_img","loftloader_img_width"]},loftloader_show_close_timer:{},loftloader_show_close_tip:{}},t=type_value=loop="";if("on"===l("loftloader_main_switch"))for(var o in t="loftloader_main_switch=on loftloader_show_range=sitewide",e){switch(type_value=l(o),o){case"loftloader_show_close_tip":type_value=type_value?'"'+btoa(unescape(encodeURIComponent(type_value)))+'"':'""';case"loftloader_bg_color":case"loftloader_bg_opacity":case"loftloader_bg_animation":loop=[];break;default:loop=e[o][type_value]?e[o][type_value]:[]}if(t+=" "+o+"="+type_value,loop)for(var a in loop)t+=" "+loop[a]+"="+l(loop[a])}else t="loftloader_main_switch=false";return t}}(wp.customize,jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/scss/loftloader-settings.scss CHANGED
@@ -6,7 +6,7 @@
6
  * Author: Kaylolo Yinxi Chen @Loft.Ocean
7
  * Author URI: http://www.loftocean.com
8
  * Description: LoftLoader (Lite Version) is a plugin for adding beautiful and smooth preload animation to your WordPress website. With setting options, you can choose from preset animations, add custom logo image, choose colours to match your branding, and amuse and impress your visitors while loading site content.
9
- * Version: 2.1.5
10
  */
11
 
12
 
6
  * Author: Kaylolo Yinxi Chen @Loft.Ocean
7
  * Author URI: http://www.loftocean.com
8
  * Description: LoftLoader (Lite Version) is a plugin for adding beautiful and smooth preload animation to your WordPress website. With setting options, you can choose from preset animations, add custom logo image, choose colours to match your branding, and amuse and impress your visitors while loading site content.
9
+ * Version: 2.1.6
10
  */
11
 
12
 
assets/scss/loftloader.scss CHANGED
@@ -6,7 +6,7 @@
6
  * Author: Kaylolo Yinxi Chen @Loft.Ocean
7
  * Author URI: http://www.loftocean.com
8
  * Description: LoftLoader (Lite Version) is a plugin for adding beautiful and smooth preload animation to your WordPress website. With setting options, you can choose from preset animations, add custom logo image, choose colours to match your branding, and amuse and impress your visitors while loading site content.
9
- * Version: 2.1.5
10
  */
11
 
12
  $primary-color: #248acc;
6
  * Author: Kaylolo Yinxi Chen @Loft.Ocean
7
  * Author URI: http://www.loftocean.com
8
  * Description: LoftLoader (Lite Version) is a plugin for adding beautiful and smooth preload animation to your WordPress website. With setting options, you can choose from preset animations, add custom logo image, choose colours to match your branding, and amuse and impress your visitors while loading site content.
9
+ * Version: 2.1.6
10
  */
11
 
12
  $primary-color: #248acc;
inc/{class-loftloader-any-page.php → any-page/class-any-page-filter.php} RENAMED
@@ -1,39 +1,5 @@
1
  <?php
2
- if(!class_exists('LoftLoader_Any_Page') && !class_exists('LoftLoader_Any_Page_Filter')){
3
- class LoftLoader_Any_Page{
4
- public function __construct(){
5
- add_action('add_meta_boxes', array($this, 'register_meta_boxes'));
6
- add_action('save_post', array($this, 'save_meta'), 10, 3);
7
-
8
- $this->alter_loftloader();
9
- }
10
- // Register loftloader shortcode meta box
11
- public function register_meta_boxes(){
12
- add_meta_box('loftloader_any_page_meta', esc_html__('LoftLoader Any Page Shortcode', 'loftloader-any-page'), array($this, 'metabox_callback'), 'page', 'advanced');
13
- }
14
- // Show meta box html
15
- public function metabox_callback($post){
16
- $shortcode = get_post_meta($post->ID, 'loftloader_page_shortcode', true);
17
- $html = '<textarea name="loftloader_page_shortcode" style="width: 100%;" rows="4">' . str_replace('/\\"/g', '\\\\"', $shortcode) . '</textarea>';
18
- $html .= '<input type="hidden" name="loftloader_any_page_nonce" value="' . wp_create_nonce('loftloader_any_page_nonce') . '" />';
19
- echo $html;
20
- }
21
- // Save loftloader shortcode meta
22
- public function save_meta($post_id, $post, $update){
23
- if(empty($update) || ($post->post_type !== 'page')) return;
24
-
25
- if((wp_verify_nonce($_REQUEST['loftloader_any_page_nonce'], 'loftloader_any_page_nonce') !== false) && ($post->post_type === 'page')){
26
- update_post_meta($post_id, 'loftloader_page_shortcode', sanitize_text_field($_REQUEST['loftloader_page_shortcode']));
27
- }
28
- return $_post_id;
29
- }
30
-
31
- // Initial LoftLoader Pro Shortcode actions
32
- private function alter_loftloader(){
33
- new LoftLoader_Any_Page_Filter();
34
- }
35
- }
36
-
37
  class LoftLoader_Any_Page_Filter{
38
  private $defaults = array();
39
  private $page_settings = array();
@@ -87,6 +53,4 @@ if(!class_exists('LoftLoader_Any_Page') && !class_exists('LoftLoader_Any_Page_Fi
87
  return ($this->page_enabled && !$this->is_customize && isset($this->page_settings[$setting_id])) ? $this->page_settings[$setting_id] : $setting_value;
88
  }
89
  }
90
-
91
- new LoftLoader_Any_Page();
92
  }
1
  <?php
2
+ if ( ! class_exists('LoftLoader_Any_Page_Filter' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  class LoftLoader_Any_Page_Filter{
4
  private $defaults = array();
5
  private $page_settings = array();
53
  return ($this->page_enabled && !$this->is_customize && isset($this->page_settings[$setting_id])) ? $this->page_settings[$setting_id] : $setting_value;
54
  }
55
  }
 
 
56
  }
inc/any-page/class-loftloader-any-page.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! class_exists( 'LoftLoader_Any_Page' ) && !class_exists('LoftLoader_Any_Page_Filter')){
3
+ class LoftLoader_Any_Page{
4
+ public function __construct(){
5
+ add_action('add_meta_boxes', array($this, 'register_meta_boxes'));
6
+ add_action('save_post', array($this, 'save_meta'), 10, 3);
7
+
8
+ if ( ! is_admin() ) {
9
+ $this->alter_loftloader();
10
+ }
11
+
12
+ if ( function_exists( 'register_block_type' ) ) {
13
+ $this->load_gutenberg_panel();
14
+ }
15
+ }
16
+ // Load gutenberg file
17
+ protected function load_gutenberg_panel() {
18
+ require_once LOFTLOADER_ROOT . 'inc/any-page/gutenberg/class-gutenberg-any-page.php';
19
+ }
20
+ // Register loftloader shortcode meta box
21
+ public function register_meta_boxes(){
22
+ add_meta_box(
23
+ 'loftloader_any_page_meta',
24
+ esc_html__( 'LoftLoader Any Page Shortcode', 'loftloader-any-page' ),
25
+ array( $this, 'metabox_callback' ),
26
+ 'page',
27
+ 'advanced',
28
+ 'high',
29
+ array(
30
+ '__block_editor_compatible_meta_box' => true,
31
+ '__back_compat_meta_box' => true
32
+ )
33
+ );
34
+ }
35
+ // Show meta box html
36
+ public function metabox_callback($post){
37
+ $shortcode = get_post_meta($post->ID, 'loftloader_page_shortcode', true);
38
+ $html = '<textarea name="loftloader_page_shortcode" style="width: 100%;" rows="4">' . str_replace('/\\"/g', '\\\\"', $shortcode) . '</textarea>';
39
+ $html .= '<input type="hidden" name="loftloader_any_page_nonce" value="' . wp_create_nonce('loftloader_any_page_nonce') . '" />';
40
+ echo $html;
41
+ }
42
+ // Save loftloader shortcode meta
43
+ public function save_meta($post_id, $post, $update){
44
+ if ( empty( $update ) || ! in_array( $post->post_type, array( 'page' ) ) || empty( $_REQUEST['loftloader_any_page_nonce'] ) || ! empty( $_REQUEST['loftloader_gutenberg_enabled'] ) ) {
45
+ return $post_id;
46
+ }
47
+ if ( current_user_can( 'edit_post', $post_id ) ) {
48
+ update_post_meta( $post_id, 'loftloader_page_shortcode', sanitize_text_field( $_REQUEST['loftloader_page_shortcode'] ) );
49
+ }
50
+ return $_post_id;
51
+ }
52
+
53
+ // Initial LoftLoader Pro Shortcode actions
54
+ private function alter_loftloader() {
55
+ require_once LOFTLOADER_ROOT . 'inc/any-page/class-any-page-filter.php';
56
+ new LoftLoader_Any_Page_Filter();
57
+ }
58
+ }
59
+ new LoftLoader_Any_Page();
60
+ }
inc/any-page/gutenberg/class-gutenberg-any-page.php ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Gutenberg Manager class
4
+ */
5
+
6
+ if ( ! class_exists( 'LoftLoader_Gutenberg_Any_Page' ) ) {
7
+ class LoftLoader_Gutenberg_Any_Page {
8
+ /**
9
+ * Array of post meta name list
10
+ */
11
+ public $page_meta_list = array(
12
+ 'loftloader_page_shortcode' => 'string'
13
+ );
14
+ /**
15
+ * Construct function
16
+ */
17
+ public function __construct() {
18
+ add_action( 'rest_api_init', array( $this, 'api_update_post_meta' ) );
19
+ add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_editor_assets' ) );
20
+ $this->register_metas();
21
+ }
22
+ /**
23
+ * Enqueue editor assets
24
+ */
25
+ public function enqueue_editor_assets() {
26
+ switch ( $this->get_current_post_type() ) {
27
+ case 'page':
28
+ wp_enqueue_script(
29
+ 'loftloader-gutenberg-any-page-script',
30
+ LOFTLOADER_URI. 'inc/any-page/gutenberg/plugin.js',
31
+ array( 'wp-blocks', 'wp-element', 'wp-i18n' ),
32
+ LOFTLOADER_ASSET_VERSION,
33
+ true
34
+ );
35
+ break;
36
+ }
37
+ }
38
+ /**
39
+ * Register metas for gutenberg
40
+ */
41
+ public function register_metas() {
42
+ foreach( $this->page_meta_list as $id => $type ) {
43
+ register_meta( 'post', $id, array(
44
+ 'auth_callback' => array( $this, 'permission_check' ),
45
+ 'show_in_rest' => true,
46
+ 'single' => true,
47
+ 'type' => $type
48
+ ) );
49
+ }
50
+ }
51
+ /**
52
+ * Check permission for meta registration
53
+ */
54
+ public function permission_check( $arg1, $meta_name, $post_id ) {
55
+ return current_user_can( 'edit_post', $post_id );
56
+ }
57
+ /**
58
+ * Update post metas from gutenberg
59
+ */
60
+ public function api_update_post_meta() {
61
+ register_rest_route(
62
+ 'loftloader/v2', '/update-meta', array(
63
+ 'methods' => 'POST',
64
+ 'callback' => array( $this, 'update_callback' ),
65
+ 'args' => array(
66
+ 'id' => array(
67
+ 'sanitize_callback' => 'absint',
68
+ )
69
+ )
70
+ )
71
+ );
72
+ }
73
+ /**
74
+ * Hello Gutenberg REST API Callback for Gutenberg
75
+ */
76
+ function update_callback( $data ) {
77
+ $post_id = $data['id'];
78
+ switch ( get_post_type( $post_id ) ) {
79
+ case 'page':
80
+ $meta_names = array_keys( $this->page_meta_list );
81
+ break;
82
+ default:
83
+ $meta_names = array();
84
+ }
85
+ foreach( $meta_names as $meta_name ) {
86
+ update_post_meta( $post_id, $meta_name, $data[ $meta_name ] );
87
+ }
88
+ return true;
89
+ }
90
+ /**
91
+ * Get current post type
92
+ * @return mix post type string or boolean false
93
+ */
94
+ protected function get_current_post_type() {
95
+ global $post;
96
+ if ( is_admin() && ! empty( $post ) && ! empty( $post->post_type ) ) {
97
+ return $post->post_type;
98
+ } else {
99
+ return false;
100
+ }
101
+ }
102
+ }
103
+ function loftloader_init_gutenberg_any_page() {
104
+ new LoftLoader_Gutenberg_Any_Page();
105
+ }
106
+ add_action( 'init', 'loftloader_init_gutenberg_any_page' );
107
+ }
inc/any-page/gutenberg/plugin.js ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ( function( editor, components, i18n, element, $ ) {
2
+ "use strict";
3
+
4
+ const __ = i18n.__;
5
+ const el = element.createElement;
6
+ const compose = wp.compose.compose;
7
+ const registerPlugin = wp.plugins.registerPlugin;
8
+
9
+ const {
10
+ Fragment,
11
+ Component
12
+ } = element;
13
+
14
+
15
+ const {
16
+ TextareaControl,
17
+ PanelBody
18
+ } = components;
19
+
20
+ const {
21
+ dispatch,
22
+ withSelect,
23
+ withDispatch
24
+ } = wp.data;
25
+
26
+ const {
27
+ PluginSidebar,
28
+ PluginSidebarMoreMenuItem
29
+ } = wp.editPost;
30
+
31
+ const Icon = el( 'svg', {
32
+ height: '20px',
33
+ width: '20px',
34
+ viewBox: '0 0 17.39 17.39'
35
+ }, el ( 'polygon', {
36
+ points: '14.77 11.19 17.3 8.65 14.77 6.12 14.77 2.53 11.19 2.53 8.65 0 6.12 2.53 2.53 2.53 2.53 6.12 0 8.65 2.53 11.19 2.53 14.77 6.12 14.77 8.65 17.3 11.19 14.77 14.77 14.77 14.77 11.19'
37
+ } )
38
+ );
39
+
40
+ class LoftLoaderPlugin extends Component {
41
+ constructor() {
42
+ super( ...arguments );
43
+
44
+ this.state = this.props.meta;
45
+ }
46
+
47
+ static getDerivedStateFromProps( nextProps, state ) {
48
+ if ( ( nextProps.isPublishing || nextProps.isSaving ) && ! nextProps.isAutoSaving ) {
49
+ wp.apiRequest( { path: '/loftloader/v2/update-meta?id=' + nextProps.postId, method: 'POST', data: state } ).then(
50
+ ( data ) => {
51
+ return data;
52
+ }, ( err ) => {
53
+ return err;
54
+ }
55
+ );
56
+ }
57
+ }
58
+ render() {
59
+ return el( Fragment, {},
60
+ el( PluginSidebarMoreMenuItem, { target: 'loftloader-any-page' }, __( 'LoftLoader Any Page Shortcode' ) ),
61
+ el( PluginSidebar, { name: 'loftloader-any-page', title: __( 'LoftLoader Any Page Shortcode' ) },
62
+ el( PanelBody, {
63
+ className: 'loftloader-any-page-sidebar',
64
+ initialOpen: true
65
+ },
66
+ el( TextareaControl, {
67
+ label: __( 'Paste LoftLoader shortcode into the box below' ),
68
+ value: this.state.loftloader_page_shortcode,
69
+ onChange: ( value ) => {
70
+ this.setState( { loftloader_page_shortcode: value } );
71
+ }
72
+ } )
73
+ ),
74
+ el( 'input', {
75
+ type: 'hidden',
76
+ name: 'loftloader_gutenberg_enabled',
77
+ value: 'on'
78
+ } )
79
+ )
80
+ );
81
+ }
82
+ }
83
+
84
+ // Fetch the post meta.
85
+ const applyWithSelect = withSelect( ( select, { forceIsSaving } ) => {
86
+ const {
87
+ getEditedPostAttribute,
88
+ getCurrentPostId,
89
+ isSavingPost,
90
+ isPublishingPost,
91
+ isAutosavingPost,
92
+ } = select( 'core/editor' );
93
+
94
+ return {
95
+ meta: getEditedPostAttribute( 'meta' ),
96
+ postId: getCurrentPostId(),
97
+ isSaving: forceIsSaving || isSavingPost(),
98
+ isAutoSaving: isAutosavingPost(),
99
+ isPublishing: isPublishingPost(),
100
+ };
101
+ } );
102
+
103
+ const render = compose( [
104
+ applyWithSelect
105
+ ] )( LoftLoaderPlugin );
106
+
107
+ registerPlugin( 'loftloader-any-page', {
108
+ icon: Icon,
109
+ render
110
+ } );
111
+ } )(
112
+ window.wp.editor,
113
+ window.wp.components,
114
+ window.wp.i18n,
115
+ window.wp.element,
116
+ jQuery
117
+ );
inc/class-loftloader-upgrade.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
- if(!class_exists('LoftLoader_Upgrade')){
3
- class LoftLoader_Upgrade{
4
- private $version ='2.1.5';
5
  function __construct(){
6
  $old_version = get_option('loftloader_lite_version', '1.0');
7
  if(version_compare($old_version, $this->version, '<')){
1
  <?php
2
+ if ( ! class_exists( 'LoftLoader_Upgrade' ) ) {
3
+ class LoftLoader_Upgrade {
4
+ private $version ='2.1.6';
5
  function __construct(){
6
  $old_version = get_option('loftloader_lite_version', '1.0');
7
  if(version_compare($old_version, $this->version, '<')){
languages/loftloader.pot CHANGED
@@ -3,18 +3,18 @@
3
  #, fuzzy
4
  msgid ""
5
  msgstr ""
6
- "Project-Id-Version: LoftLoader 2.1.5\n"
7
  "Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/loftloader\n"
8
- "POT-Creation-Date: 2018-05-24 11:59+0800\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
  "PO-Revision-Date: 2018-MO-DA HO:MI+ZONE\n"
13
  "Last-Translator: Suihai <cain@loftocean.com>\n"
14
  "Language-Team: Loft Ocean <cain@loftocean.com>\n"
15
- "X-Generator: Poedit 1.8.12\n"
16
 
17
- #: inc/class-loftloader-any-page.php:12
18
  msgid "LoftLoader Any Page Shortcode"
19
  msgstr ""
20
 
3
  #, fuzzy
4
  msgid ""
5
  msgstr ""
6
+ "Project-Id-Version: LoftLoader 2.1.6\n"
7
  "Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/loftloader\n"
8
+ "POT-Creation-Date: 2018-11-17 17:03+0800\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
  "PO-Revision-Date: 2018-MO-DA HO:MI+ZONE\n"
13
  "Last-Translator: Suihai <cain@loftocean.com>\n"
14
  "Language-Team: Loft Ocean <cain@loftocean.com>\n"
15
+ "X-Generator: Poedit 2.2\n"
16
 
17
+ #: inc/any-page/class-loftloader-any-page.php:24
18
  msgid "LoftLoader Any Page Shortcode"
19
  msgstr ""
20
 
loftloader.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: LoftLoader
4
  Plugin URI: http://www.loftocean.com/
5
  Description: An easy to use plugin to add an animated preloader to your website with fully customisations.
6
- Version: 2.1.5
7
  Author: Loft Ocean
8
  Author URI: http://www.loftocean.com/
9
  Text Domain: loftloader
@@ -32,7 +32,7 @@ if(!class_exists('LoftLoader')){
32
  define('LOFTLOADER_ROOT', dirname(__FILE__) . '/');
33
  define('LOFTLOADER_NAME', plugin_basename( __FILE__ ));
34
  define('LOFTLOADER_URI', plugin_dir_url( __FILE__ ));
35
- define('LOFTLOADER_ASSET_VERSION', '2018052403');
36
 
37
  class LoftLoader{
38
  public function __construct(){
@@ -106,7 +106,7 @@ if(!class_exists('LoftLoader')){
106
  function loftloader_any_page(){
107
  $enable_any_page = get_option('loftloader_enable_any_page', '');
108
  if($enable_any_page === 'on'){
109
- require_once LOFTLOADER_ROOT . 'inc/class-loftloader-any-page.php';
110
  }
111
  }
112
 
3
  Plugin Name: LoftLoader
4
  Plugin URI: http://www.loftocean.com/
5
  Description: An easy to use plugin to add an animated preloader to your website with fully customisations.
6
+ Version: 2.1.6
7
  Author: Loft Ocean
8
  Author URI: http://www.loftocean.com/
9
  Text Domain: loftloader
32
  define('LOFTLOADER_ROOT', dirname(__FILE__) . '/');
33
  define('LOFTLOADER_NAME', plugin_basename( __FILE__ ));
34
  define('LOFTLOADER_URI', plugin_dir_url( __FILE__ ));
35
+ define('LOFTLOADER_ASSET_VERSION', '2018111901');
36
 
37
  class LoftLoader{
38
  public function __construct(){
106
  function loftloader_any_page(){
107
  $enable_any_page = get_option('loftloader_enable_any_page', '');
108
  if($enable_any_page === 'on'){
109
+ require_once LOFTLOADER_ROOT . 'inc/any-page/class-loftloader-any-page.php';
110
  }
111
  }
112
 
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: loftocean
3
  Tags: loader, load, preloader, page preloader, prelader spinner, preloader with custom logo, animated preloader, CSS3 preloader, customize
4
  Donate link:
5
  Requires at least: 4.3
6
- Tested up to: 4.9
7
- Stable tag: 2.1.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -56,7 +56,7 @@ LoftLoader Pro is available. [Upgrade to pro version](https://codecanyon.net/ite
56
  * Loader - 19 types of animations to choose. 6 of them support custom images.
57
  * Looping - Animation can be set to loop forever, and some animations can be set to run just once (ends after page has loaded).
58
  * Progress - Progress bar, counting percentage, or both. Any color. Position, size & font control.
59
- * Message - Enter your custom welcome or loading message to display. Control color, position & font.
60
  * Load Time - Set a minimum load time to prevent the pre-loader from disappearing too fast.
61
  * Device Control - Choose to show the loading screen on all devices, or hide on mobile, or show on mobile only.
62
  * Option to enable smooth page transition effect. [Check the example](http://demo.loftocean.com/loftloader-transition/).
@@ -92,6 +92,9 @@ Check some [examples](http://www.loftocean.com/loftloader/example-13/) created b
92
  8. Pro version: Load Time, Device Control & Smooth Page Transition
93
 
94
  == Changelog ==
 
 
 
95
  = 2.1.5 =
96
  * Fixed: Description for Close Button doesn’t work for Any Page Extension
97
  * Fixed: Minor CSS issues
3
  Tags: loader, load, preloader, page preloader, prelader spinner, preloader with custom logo, animated preloader, CSS3 preloader, customize
4
  Donate link:
5
  Requires at least: 4.3
6
+ Tested up to: 5.0
7
+ Stable tag: 2.1.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
56
  * Loader - 19 types of animations to choose. 6 of them support custom images.
57
  * Looping - Animation can be set to loop forever, and some animations can be set to run just once (ends after page has loaded).
58
  * Progress - Progress bar, counting percentage, or both. Any color. Position, size & font control.
59
+ * Message - Enter your custom welcome or loading message to display. Control color, position & font. And supports Random Message feature.
60
  * Load Time - Set a minimum load time to prevent the pre-loader from disappearing too fast.
61
  * Device Control - Choose to show the loading screen on all devices, or hide on mobile, or show on mobile only.
62
  * Option to enable smooth page transition effect. [Check the example](http://demo.loftocean.com/loftloader-transition/).
92
  8. Pro version: Load Time, Device Control & Smooth Page Transition
93
 
94
  == Changelog ==
95
+ = 2.1.6 =
96
+ * Improved: Any Page Extension meta box redesigned to fit in Gutenberg Sidebar
97
+
98
  = 2.1.5 =
99
  * Fixed: Description for Close Button doesn’t work for Any Page Extension
100
  * Fixed: Minor CSS issues