PluginProbe
WPMobile.App / trunk
WPMobile.App vtrunk
wpappninja / inc / functions / appify.php

appify.php in WPMobile.App trunk, at inc/functions/appify.php

815 lines 34.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 defined( 'ABSPATH' ) or die( 'Cheatin\' uh?' );
3
4 /* ADD BODY CLASS */
5 add_filter('body_class', 'wpmobileapp_theme_body_class');
6 function wpmobileapp_theme_body_class($classes) {
7
8 if (is_wpappninja()) {
9
10 $classes[] = 'theme-wpappninja';
11 $classes[] = 'wpmobileapp';
12
13 if (wpappninja_isIOS()) {
14 $classes[] = 'wpapp-ios';
15 }
16 }
17
18 return $classes;
19 }
20
21 /* BE SURE JQUERY IS READY */
22 add_filter('wp_enqueue_scripts','wpmobileapp_add_jquery', 1);
23 function wpmobileapp_add_jquery() {
24
25 if (is_wpappninja()) {
26 wp_enqueue_script('jquery', false, array(), false, false);
27 }
28 }
29
30 /* LISTS OPTIONS */
31 //add_action( 'pre_get_posts', 'wpmobileapp_pre_get_posts' );
32 function wpmobileapp_pre_get_posts($query) {
33
34 if (is_wpappninja() && !is_page() && !is_single() && !is_admin() && get_wpappninja_option('speed') == '1' && get_wpappninja_option('appify') != '1') {
35
36 $has_password = null;
37 if (get_wpappninja_option('has_password', "0") == "0") {
38 $has_password = false;
39 }
40
41 $query->set( 'posts_per_page', intval(get_wpappninja_option('listnb', 10)) );
42 $query->set( 'orderby', get_wpappninja_option('orderby_list', 'post_date') );
43 $query->set( 'order', get_wpappninja_option('order_list', 'DESC') );
44 $query->set( 'has_password', $has_password );
45 $query->set( 'date_query', array(
46 'column' => 'post_date',
47 'after' => '- '.get_wpappninja_option('maxage', '365000').' days'
48 ) );
49 $query->set( 'tag__not_in', get_wpappninja_option('excluded', '') );
50 }
51
52 }
53
54 /* WOOCOMMERCE */
55 //add_filter('woocommerce_get_catalog_ordering_args', 'wpmobileapp_woocommerce_catalog_orderby');
56 function wpmobileapp_woocommerce_catalog_orderby( $args ) {
57
58 if (is_wpappninja()) {
59 $args['orderby'] = get_wpappninja_option('orderby_list', 'post_date');
60 $args['order'] = get_wpappninja_option('order_list', 'desc');
61 }
62
63 return $args;
64 }
65 add_action( 'widgets_init', 'wpmobileapp_woo_sidebar' );
66 function wpmobileapp_woo_sidebar() {
67
68 //woocommerce sidebar
69 if (function_exists('is_woocommerce') && is_woocommerce() && is_wpmobileapp_ready()) {
70 unregister_sidebar('shop');
71 }
72 }
73
74 /* MAIN JS AND CSS */
75 add_action('wp_enqueue_scripts', 'wpmobileapp_theme_styles');
76 function wpmobileapp_theme_styles() {
77
78 if (is_wpmobileapp_ready()) {
79
80 wp_register_style( 'wpmobileapp-css', WPAPPNINJA_URL . 'themes/wpmobileapp/includes/app-ui.css', array(), WPAPPNINJA_VERSION, null );
81 wp_enqueue_style( 'wpmobileapp-css' );
82
83 wp_dequeue_style( 'select2' );
84 wp_dequeue_script( 'select2');
85 wp_dequeue_script( 'selectWoo' );
86 }
87 }
88
89 // LOADER
90 add_filter('wp_head', 'wpmobileapp_custom_loader', 11);
91 function wpmobileapp_custom_loader() {
92
93 if (is_wpappninja() && theme_is_changed()) {
94
95 // load framewor7 icons
96 ?>
97 <style>
98 #root p label { color: <?php echo get_wpappninja_option('css_d7a8405db9b1bc84f477b325f32d2574', '#000');?>;}
99 .posts {background:<?php echo get_wpappninja_option('css_102c4591c3ac08bbcdbf73981d5eb725', '#fff');?>!important;}
100 .md body, .ios body {color:<?php echo get_wpappninja_option('css_d7a8405db9b1bc84f477b325f32d2574', '#000');?>;}
101 .popup, .block {background: <?php echo get_wpappninja_option('css_102c4591c3ac08bbcdbf73981d5eb725', '#000');?>!important;}
102 .wpmobile-login-loggedin div {color: <?php echo get_wpappninja_option('css_c1cbcf662a13f13037d53a185986c2ad', '#fff');?>!important;}
103 input[type="submit"] {color: <?php echo get_wpappninja_option('css_37a011662d8b2e4e27b9f662ff3f91ed', '#333');?>!important;background-color: transparent!important;}
104 .ios .searchbar:after , .md .searchbar:after {background: transparent!important;}
105 .wpmobile-login-loggedin {
106 margin-top: 15px;
107 }
108
109 </style>
110
111 <?php
112
113 }
114
115 ?>
116 <style>
117 @font-face {
118 font-family: 'Framework7 Icons';
119 font-style: normal;
120 font-weight: 400;
121 src: url("<?php echo WPAPPNINJA_URL;?>themes/wpmobileapp/includes/fonts/Framework7Icons-Regular.eot?2019");
122 src: local('Framework7 Icons'),
123 local('Framework7Icons-Regular'),
124 url("<?php echo WPAPPNINJA_URL;?>themes/wpmobileapp/includes/fonts/Framework7Icons-Regular.woff2?2019") format("woff2"),
125 url("<?php echo WPAPPNINJA_URL;?>themes/wpmobileapp/includes/fonts/Framework7Icons-Regular.woff?2019") format("woff"),
126 url("<?php echo WPAPPNINJA_URL;?>themes/wpmobileapp/includes/fonts/Framework7Icons-Regular.ttf?2019") format("truetype");
127 }
128
129 .f7-icons, .framework7-icons {
130 font-family: 'Framework7 Icons';
131 font-weight: normal;
132 font-style: normal;
133 font-size: 25px;
134 line-height: 1;
135 letter-spacing: normal;
136 text-transform: none;
137 display: inline-block;
138 white-space: nowrap;
139 word-wrap: normal;
140 direction: ltr;
141 -webkit-font-smoothing: antialiased;
142 text-rendering: optimizeLegibility;
143 -moz-osx-font-smoothing: grayscale;
144 -webkit-font-feature-settings: "liga";
145 -moz-font-feature-settings: "liga=1";
146 -moz-font-feature-settings: "liga";
147 font-feature-settings: "liga";
148 }
149 </style>
150 <?php
151
152 if (get_wpappninja_option('effect', '1') == '0' || !is_wpappninja()) {
153
154 return;
155 }
156
157 if (get_wpappninja_option('wpappninja_main_theme', 'WPMobile.App') != "WPMobile.App" && get_wpappninja_option('wpmobile_loader_all_theme', '0') != '1') {
158
159 return;
160 }
161
162 ?>
163
164 <script>
165 var wpmobile_loader_handler = null;
166 jQuery(function() {
167
168 jQuery('a[download]').removeAttr('download');
169
170 if (!jQuery('html').hasClass("md") && !jQuery('html').hasClass("ios")) {
171
172 jQuery('input[type="submit"],a[href^="http://'+document.domain+'"],a[href^="https://'+document.domain+'"],a[href^="/"],a[href^="?"]').on('click', function(){wpmobile_start_loader();});
173 //jQuery(document).ajaxSend(function(){clearInterval(wpmobile_loader_handler);wpmobile_loader_handler = setTimeout(wpmobile_start_loader, 1800);});
174 //jQuery(document).ajaxComplete(function(){wpmobile_stop_loader();});
175 jQuery(function(){wpmobile_stop_loader();setTimeout(function(){wpmobile_stop_loader();}, 500);});
176 jQuery('body.wpmobileapp .post, body:not(.wpmobileapp)').css('transition', 'opacity 300ms, max-height 300ms');
177 }
178 });
179
180
181 function wpmobile_start_loader() {
182 //jQuery('.loader-wrapper').remove();
183 jQuery('html').css('background', 'white');
184 jQuery('body').css('opacity', '0.2');
185 //jQuery('body').prepend('<div class="loader-wrapper"><div class="loader"><div class="roller"></div><div class="roller"></div></div><div id="loader2" class="loader"><div class="roller"></div><div class="roller"></div></div><div id="loader3" class="loader"><div class="roller"></div><div class="roller"></div></div></div>')
186 }
187
188 function wpmobile_stop_loader() {
189 //clearInterval(wpmobile_loader_handler);
190 //jQuery('.loader-wrapper').remove();
191 jQuery('body').css('opacity', 'initial');
192
193 }
194 </script>
195
196 <?php
197 }
198
199
200 /* HEADER SCRIPT */
201 add_filter('wp_head', 'wpmobileapp_css_colors', 11);
202 function wpmobileapp_css_colors() {
203
204
205 if (is_wpappninja()) {
206 echo '<script>try{window.webkit.messageHandlers.wpmobile.postMessage(\'resetbadge\');} catch(err) {}</script>';
207 wpappninja_stats_log("read", 1);
208 ?>
209 <meta name="viewport" content="height=device-height,width=device-width,initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no<?php echo (wpappninja_isIOS() ? ', viewport-fit=cover' : '');?>">
210 <meta name="apple-mobile-web-app-capable" content="yes">
211 <?php
212 }
213
214 if (is_wpmobileapp_ready()) {
215
216 $admob_float = '';
217 if (wpappninja_is_apple_reviewer()) {
218 $admob_float = 'x';
219 }
220 $admob_splash = wpappninja_is_ios() ? get_wpappninja_option('admob_float_ios', $admob_float) : get_wpappninja_option('admob_float', '');
221
222 if (theme_is_changed()) {
223 echo '<style type="text/css">';
224
225 $classes = wpappninja_get_css_rules();
226 foreach($classes as $class) {
227 echo $class['class'] . ' { ' . $class['zone'] . ':' . get_wpappninja_option('css_' . md5($class['class'] . $class['zone']), $class['color']) . '}';
228 }
229
230 echo '.panel .wpappninja_make_it_colorfull li{background:'.wpappninja_adjustBrightness(get_wpappninja_option('css_98cbd51ad8789c03f7dd7d6cd3cd9e08', '#f5f5f5'), -20).'}.toolbar-inner .wpappninja_make_it_colorfull i {color:'.get_wpappninja_option('css_d56e17633aad9957d84a39b9db286028').'}.toolbar-inner .wpappninja_make_it_colorfull span {color:'.get_wpappninja_option('css_d56e17633aad9957d84a39b9db286028').';text-shadow:0 0 #fff}';if ($admob_splash != '' && wpappninja_is_ios()) { ?>html{max-height:Calc(100% - 50px)!important;}<?php } if ($admob_splash != '' && !wpappninja_is_ios()) { ?>html{max-height:Calc(100% - 50px)!important;}<?php } ?>.md .item-input-focused .item-input-wrap:after,.md .input-focused:after {background: <?php echo get_wpappninja_option('css_5786e51e83c834d64469d823887736ff');?>!important}.page-content {background-color:<?php echo get_wpappninja_option('css_102c4591c3ac08bbcdbf73981d5eb725');?>!important} .md .dialog-button, .ios .dialog-button {color:<?php echo get_wpappninja_option('css_37a011662d8b2e4e27b9f662ff3f91ed');?>!important;}body.wpappninja .toolbar {background:<?php echo get_wpappninja_option('css_9be9a1df3d0a60c0bc18ff5c65da2d99');?>!important}span.preloader-inner-half-circle {border-color: <?php echo get_wpappninja_option('css_e0c30224e61a0fa53753d0992872782d');?>!important;}a{color:<?php echo get_wpappninja_option('css_d115509b7fa9b63e2e07aed34183fea8');?>}.tabbar-labels a {color:<?php echo get_wpappninja_option('css_d56e17633aad9957d84a39b9db286028');?>!important;}.fab a {background: <?php echo get_wpappninja_option('css_06a182f400cbc8002d5b0aa4d0d2082e');?>!important;}.ios form.searchbar {background:<?php echo get_wpappninja_option('css_51d39016596e1db1ffd8f5118a11dd3c');?>}.md .page,.ios .page{background:<?php echo get_wpappninja_option('css_95549900f280b71ea92d360dd94dfbd3');?>;}body .woocommerce .button.checkout, body .woocommerce .button.alt{border:1px solid!important;background-color:transparent!important;color:<?php echo get_wpappninja_option('css_37a011662d8b2e4e27b9f662ff3f91ed');?>!important;}.wpmobile_preload {background:<?php echo get_wpappninja_option('css_102c4591c3ac08bbcdbf73981d5eb725');?>;}<?php if (get_wpappninja_option('effect', '1') == '0') {echo '.posts,.title-speed{opacity:1;}.wpmobile_preload{display:none!important}';} else {echo '.posts,.title-speed{opacity:0}';}?>
231 </style>
232 <?php } ?>
233 <script>
234
235
236 <?php if (get_wpappninja_option('effect', '1') == '1') {
237
238 echo "var wpmobileImLoaded = true, wpmobileinterval;
239 function wpmobileIsLoaded() {if (wpmobileImLoaded) {wpmobileappHideSplashscreen();app.progressbar.hide();jQuery('.wpmobile_preload').css('display','none');setTimeout(function(){jQuery('.posts,.title-speed').css('opacity', '1');},100); } else {}}
240 jQuery( document ).ready(function() {wpmobileIsLoaded();});
241 window.addEventListener('pageshow', function(event) {wpmobileIsLoaded();});";
242 }?>
243 </script>
244
245
246 <?php }
247 }
248
249 /* ADD TO FOOTER */
250 add_filter('wp_footer', 'wpmobileapp_inject_footer');
251 function wpmobileapp_inject_footer($content) {
252
253 if (is_wpmobileapp_ready()) {
254
255
256
257 if (isset($_GET['wpapp_shortcode']) || isset($_GET['wpappninja_read_push'])) {
258 echo '</div>';
259 }
260
261 $before = "";
262 $after = "";
263 if (function_exists('is_woocommerce') && (is_woocommerce() || is_checkout() || is_cart())) {
264 $before = wpappninja_widget('woocommerce-top');
265 $after = wpappninja_widget('woocommerce-bottom');
266 } elseif( function_exists ( "bp_current_component" ) && bp_current_component()){
267 $before = wpappninja_widget('buddypress-top');
268 $after = wpappninja_widget('buddypress-bottom');
269 } elseif (is_page()) {
270 $before = wpappninja_widget('page-top');
271 $after = wpappninja_widget('page-bottom');
272 } elseif (is_single()) {
273 $before = wpappninja_widget('post-top');
274 $after = wpappninja_widget('post-bottom');
275 } elseif (!isset($_GET['wpapp_shortcode']) && !isset($_GET['wpappninja_read_push'])) {
276 $before = wpappninja_widget('list-top');
277 $after = wpappninja_widget('list-bottom');
278 }
279
280 echo $after;
281
282 echo '</div>';
283
284 // infinite scroll
285 $content_post = get_post();
286 if(get_wpappninja_option('infinitescroll', '0') !== "0" && !wpappninja_is_custom_home($content_post) && !isset($_GET['wpappninja_read_push']) && !isset($_GET['wpapp_shortcode'])) {
287 wpappninja_show_previous_next($content_post);
288 }
289
290 echo wpappninja_widget('content-bottom'); ?>
291
292 <?php global $wpappninja_popup; echo $wpappninja_popup;?>
293 </div>
294 </div>
295 </div>
296
297 <script type='text/javascript' src='<?php echo WPAPPNINJA_URL;?>themes/wpmobileapp/includes/app-ui.js?v=<?php echo WPAPPNINJA_VERSION;?>'></script>
298
299 <script>
300 var isAndroid = Framework7.prototype.device.android === true;
301 var isIos = Framework7.prototype.device.ios === true;
302
303 var $$ = Dom7;
304 var app = new Framework7({
305 dialog: {
306 buttonOk: '<?php _e('Ok', 'wpappninja');?>',
307 buttonCancel: '<?php _e('Cancel', 'wpappninja');?>',
308 },
309 root: '#root',
310 <?php if(get_wpappninja_option('slidetoopen', '1') == '1') { ?>
311 panel: {
312 swipe: 'left',
313 },
314 <?php } ?>
315 cache: false,
316 statusbar: {
317 },
318 clicks: {
319 externalLinks: 'a[href^="http"],a[href^="/"],a[href^="?"],a[href^="tel"],a[href^="geo"],a[href^="mailto"],a[href^="sms"],a[href^="javascript"]'
320 },
321 navbar: {
322 iosCenterTitle: false
323 },
324 touch: {
325 disableContextMenu: false
326 }
327 });
328
329 /** VIBREUR **/
330 <?php if(get_wpappninja_option('vibrator', '1') == '1') {?>
331 app.on('popupOpen actionsOpen dialogOpen', function (popup) {
332
333 try{window.webkit.messageHandlers.wpmobile.postMessage('vibrateLight');} catch(err) {}
334 try{wpmobileapp.vibrateLight();} catch(err) {}
335 });
336 <?php } ?>
337 /*************/
338
339 var $ptrContent = $$('.ptr-content');
340 $ptrContent.on('ptr:refresh', function (e) { wpappninja_load_bar();setTimeout(function(){document.location=document.location}, 300); });
341
342 jQuery('a[href*="wppwa=true"]').click(function () {
343 app.progressbar.show();
344 });
345
346 jQuery('a[href*="wpappninja_v"]').click(function () {
347 app.progressbar.show();
348 });
349
350 function wpappninja_show_loader() {
351 app.progressbar.show();
352 }
353
354 jQuery( "form" ).submit(function( event ) {
355 app.progressbar.show();
356 });
357
358 jQuery( document ).ajaxSend(function() {
359 //app.progressbar.show();
360 });
361
362
363 <?php if (get_wpappninja_option('effect', '1') == '1') { ?>
364 jQuery(document).ajaxComplete(function() {
365 wpmobileIsLoaded();
366 });
367 <?php } ?>
368
369 <?php if (get_wpappninja_option('pdfdrive', '1') == '1') { ?>
370 jQuery('a[href$=".pdf"]').each(function(){jQuery(this).attr("href", "https://drive.google.com/viewerng/viewer?embedded=true&url=" + encodeURIComponent(jQuery(this).attr("href")));});
371 <?php } ?>
372
373 </script>
374
375 <?php
376 $css = "<script>
377 var mainView = app.views.create('.view-main');
378
379 function wpappninja_load_bar(el) {
380 wpmobileImLoaded = false;
381 app.panel.close('left', true);
382 app.popup.close();
383
384 setTimeout(function() {
385 app.progressbar.show();
386 }, 1200);";
387
388 if (get_wpappninja_option('effect', '1') == '1') {
389 $css .= "jQuery('.posts,.title-speed').css('opacity', '0.2');";
390 }
391 $css .= "
392 }
393
394 function wpappninja_color_scheme(el) {
395 wpmobileImLoaded = false;
396
397 if (jQuery(el).attr('id') != undefined && jQuery(el).attr('id').match('^wpm_')) {
398 document.cookie='wpmobile_last_tab=' + jQuery(el).attr('id') + ';path=/';
399 }
400
401 if (!jQuery(el).hasClass('wpappninja_change_color_card')) {
402 jQuery('i.wpapp_icon_nofill:not(.wpapp_sep i.wpapp_icon_nofill)').css('display', 'block');
403 jQuery('i.wpapp_icon_fill:not(.wpapp_sep i.wpapp_icon)').css('display', 'none');
404 jQuery('i.wpapp_tabbar').css('color', '".get_wpappninja_option('css_d56e17633aad9957d84a39b9db286028')."');
405 jQuery('span.wpapp_tabbar').css('color', '".get_wpappninja_option('css_d56e17633aad9957d84a39b9db286028')."');
406 jQuery('span.wpapp_tabbar').css('text-shadow', '0 0 0 transparent');
407 jQuery('li.item-content').css('background', '".get_wpappninja_option('css_98cbd51ad8789c03f7dd7d6cd3cd9e08', '#fff')."');
408 }
409
410 jQuery('.card-content').css('background', '".get_wpappninja_option('css_305cad765b7512c618c0d6174913fb94', '#fff')."');
411 jQuery('i.wpapp_icon_nofill:not(.wpapp_sep i.wpapp_icon_nofill)', el).css('display', 'none');
412 jQuery('i.wpapp_icon_fill:not(.wpapp_sep i.wpapp_icon_fill)', el).css('display', 'block');
413 jQuery('i.wpapp_tabbar', el).css('color', '".get_wpappninja_option('css_d56e17633aad9957d84a39b9db286028')."');
414 jQuery('span.wpapp_tabbar', el).css('color', '".get_wpappninja_option('css_d56e17633aad9957d84a39b9db286028')."');
415 jQuery('span.wpapp_tabbar', el).css('text-shadow', '0 0 #fff');
416 jQuery('li.item-content', el).css('background', '".wpappninja_adjustBrightness(get_wpappninja_option('css_98cbd51ad8789c03f7dd7d6cd3cd9e08', '#f5f5f5'), -20)."');
417 jQuery('.card-content', el).css('background', '".wpappninja_adjustBrightness(get_wpappninja_option('css_305cad765b7512c618c0d6174913fb94', '#fff'), -10)."');
418 }
419
420 function wpmobile_getCookie(cname) {
421 var name = cname + '=';
422 var ca = document.cookie.split(';');
423 for(var i=0; i<ca.length; i++) {
424 var c = ca[i];
425 while (c.charAt(0)==' ') c = c.substring(1);
426 if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
427 }
428 return '';
429 }
430
431 if (jQuery('.wpappninja_make_it_colorfull').length === 0) {
432
433 if (wpmobile_getCookie('wpmobile_last_tab') != '') {
434 jQuery('#' + wpmobile_getCookie('wpmobile_last_tab')).addClass('wpappninja_make_it_colorfull');
435 }
436 }
437 </script>";
438
439 echo $css;
440 ?>
441 <script>var _extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(e,t){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.LazyLoad=t()}(this,function(){"use strict";var e=function(e){var t={elements_selector:"img",container:document,threshold:300,data_src:"src",data_srcset:"srcset",class_loading:"loading",class_loaded:"loaded",class_error:"error",callback_load:null,callback_error:null,callback_set:null,callback_enter:null};return _extends({},t,e)},t=function(e,t){return e.getAttribute("data-"+t)},n=function(e,t,n){return e.setAttribute("data-"+t,n)},r=function(e){return e.filter(function(e){return!t(e,"was-processed")})},s=function(e,t){var n,r=new e(t);try{n=new CustomEvent("LazyLoad::Initialized",{detail:{instance:r}})}catch(e){(n=document.createEvent("CustomEvent")).initCustomEvent("LazyLoad::Initialized",!1,!1,{instance:r})}window.dispatchEvent(n)},o=function(e,n){var r=n.data_srcset,s=e.parentNode;if(s&&"PICTURE"===s.tagName)for(var o,a=0;o=s.children[a];a+=1)if("SOURCE"===o.tagName){var i=t(o,r);i&&o.setAttribute("srcset",i)}},a=function(e,n){var r=n.data_src,s=n.data_srcset,a=e.tagName,i=t(e,r);if("IMG"===a){o(e,n);var c=t(e,s);return c&&e.setAttribute("srcset",c),void(i&&e.setAttribute("src",i))}"IFRAME"!==a?i&&(e.style.backgroundImage='url("'+i+'")'):i&&e.setAttribute("src",i)},i="undefined"!=typeof window,c=i&&"IntersectionObserver"in window,l=i&&"classList"in document.createElement("p"),u=function(e,t){l?e.classList.add(t):e.className+=(e.className?" ":"")+t},d=function(e,t){l?e.classList.remove(t):e.className=e.className.replace(new RegExp("(^|\\s+)"+t+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},f=function(e,t){e&&e(t)},_=function(e,t,n){e.removeEventListener("load",t),e.removeEventListener("error",n)},v=function(e,t){var n=function n(s){m(s,!0,t),_(e,n,r)},r=function r(s){m(s,!1,t),_(e,n,r)};e.addEventListener("load",n),e.addEventListener("error",r)},m=function(e,t,n){var r=e.target;d(r,n.class_loading),u(r,t?n.class_loaded:n.class_error),f(t?n.callback_load:n.callback_error,r)},b=function(e,t){f(t.callback_enter,e),["IMG","IFRAME"].indexOf(e.tagName)>-1&&(v(e,t),u(e,t.class_loading)),a(e,t),n(e,"was-processed",!0),f(t.callback_set,e)},p=function(e){return e.isIntersecting||e.intersectionRatio>0},h=function(t,n){this._settings=e(t),this._setObserver(),this.update(n)};h.prototype={_setObserver:function(){var e=this;if(c){var t=this._settings,n={root:t.container===document?null:t.container,rootMargin:t.threshold+"px"};this._observer=new IntersectionObserver(function(t){t.forEach(function(t){if(p(t)){var n=t.target;b(n,e._settings),e._observer.unobserve(n)}}),e._elements=r(e._elements)},n)}},update:function(e){var t=this,n=this._settings,s=e||n.container.querySelectorAll(n.elements_selector);this._elements=r(Array.prototype.slice.call(s)),this._observer?this._elements.forEach(function(e){t._observer.observe(e)}):(this._elements.forEach(function(e){b(e,n)}),this._elements=r(this._elements))},destroy:function(){var e=this;this._observer&&(r(this._elements).forEach(function(t){e._observer.unobserve(t)}),this._observer=null),this._elements=null,this._settings=null}};var y=window.lazyLoadOptions;return i&&y&&function(e,t){if(t.length)for(var n,r=0;n=t[r];r+=1)s(e,n);else s(e,t)}(h,y),h});new LazyLoad();</script>
442 </div>
443 <?php }
444 }
445
446 $wpmobile_inject_head = "";
447
448 add_action( 'wp_enqueue_scripts', 'wpmobileapp_process_obstart', PHP_INT_MAX );
449 function wpmobileapp_process_obstart() {
450 global $wpmobile_inject_head;
451
452 if (is_wpmobileapp_ready() && !is_embed()) {
453 $wpmobile_inject_head = wpmobile_inject_head();
454 ob_start('wpmobileapp_modify_body');
455 }
456 }
457
458 add_filter('wpmobileapp_final_output', 'wpmobileapp_modify_body');
459 function wpmobileapp_modify_body($output) {
460
461 global $wpmobile_inject_head;
462 $html = 'class="';
463 if (wpappninja_iosstyle()) {$html .= 'ios';if (wpmobile_need_old_ios_support()) {$html .= ' with-statusbar';}}else{$html .= 'md';}
464 $html .= '" ';
465 if (substr(get_wpappninja_option('cache_type', 'networkonly'), 0, 4) == 'fast'){
466 $html .= ' manifest="' . WPAPPNINJA_ASSETS_3RD_URL . 'appmanifest.php" ';
467 }
468
469 $output = preg_replace("/(\<html([^>]+|)>)/", "<html " . $html . ">", $output, -1);
470
471 if (wpappninja_isIOS()) {
472 $wpmobile_reisze_ios = "";
473 if (wpmobile_need_old_ios_support()) {$wpmobile_reisze_ios = '<script>function wpappninja_correct_height() {width = screen.width;height = screen.height;newHeight = (window.orientation === 0 ? Math.max(width, height) : Math.min(width, height));document.documentElement.style.height = newHeight + "px";}wpappninja_correct_height();setTimeout(wpappninja_correct_height, 200);setTimeout(wpappninja_correct_height, 500);setTimeout(wpappninja_correct_height, 1000);window.addEventListener("orientationchange", function() {wpappninja_correct_height();});</script><style>html.with-statusbar.device-ios .statusbar {height:30px!important;}html.with-statusbar.device-ios .framework7-root {padding-top:30px;border-bottom: 20px solid #000;}</style>';}
474 $output = preg_replace("/(\<head([^>]+|)>)/", "$1" . $wpmobile_reisze_ios, $output, 1);
475 }
476
477 $output = preg_replace("/(\<body([^>]+|)>)/", "$1" . $wpmobile_inject_head, $output, 1);
478
479 return $output;
480 }
481
482 //add_action( 'wp', 'wpmobileapp_404_shortcode' );
483 function wpmobileapp_404_shortcode() {
484 global $post;
485 if (is_wpmobileapp_ready() && (isset($_GET['wpapp_shortcode']) || isset($_GET['wpappninja_read_push']))) {
486 global $wp_query;
487 $wp_query->set_404();
488 status_header(200);
489 }
490 }
491
492 function wpmobile_inject_head() {
493
494 ob_start();
495
496 $pages = wpappninja_get_pages();
497 $wpappninja_locale = "speed";
498
499 $homepage_wpapp = get_wpappninja_option('pageashome_' . $wpappninja_locale, "");
500
501 if (get_wpappninja_option('speed', '1') == '1' && !preg_match('#^http#', $homepage_wpapp)) {
502
503 if (preg_match('#^cat_#', $homepage_wpapp)) {
504
505 $homepage_wpapp = preg_replace('#^cat_#', '', $homepage_wpapp);
506 $taxonomy = wpappninja_get_all_taxonomy();
507
508 foreach ($taxonomy as $tax) {
509 $obj = get_term_by('id', $homepage_wpapp, $tax);
510 if (is_object($obj)) {
511 $homepage_wpapp = get_term_link($obj);
512 break;
513 }
514 }
515 } else {
516
517 if (get_permalink(intval($homepage_wpapp))) {
518 $homepage_wpapp = get_permalink(intval($homepage_wpapp));
519 }
520 }
521
522 if (!preg_match('#^http#', $homepage_wpapp)) {
523 $homepage_wpapp = wpappninja_get_home();
524 }
525 }
526
527 if (get_wpappninja_option('speed') == '1' && get_wpappninja_option('speed_trad') == 'manual') {
528 $homepage_wpapp = wpappninja_translate($homepage_wpapp);
529 }
530
531 if (is_user_logged_in()) {
532 if (get_wpappninja_option('login_redirect_after') != '') {
533 $homepage_wpapp = wpappninja_cache_friendly(wpmobile_weglot(get_wpappninja_option('login_redirect_after')));
534
535 if (get_wpappninja_option('speed') == '1' && get_wpappninja_option('speed_trad') == 'manual') {
536 $homepage_wpapp = wpappninja_translate(get_wpappninja_option('login_redirect_after'));
537 }
538 }
539 }
540
541 ?>
542 <div id="root" class="wpmobile-<?php the_ID(); ?> wpmobile-<?php echo md5($_SERVER['REQUEST_URI']);?> framework7-root">
543
544 <div class="statusbar" style="background:<?php echo get_wpappninja_option('css_74537a66b8370a71e9b05c3c4ddbf522');?>"></div>
545
546 <div class="panel-overlay"></div>
547 <div class="panel panel-left panel-cover">
548
549 <div class="menuwidget"><?php echo wpappninja_widget('menu-top'); ?></div>
550
551 <!-- Left menu -->
552 <div class="content-block">
553 <div class="list">
554 <ul>
555
556 <?php
557 foreach ($pages as $page) {
558 if (isset($page['menu']) && $page['menu'] == "menu") {
559
560 if (preg_match('#separator$#', $page['id'])) {
561 $uniqid = uniqid(); ?>
562
563 </ul>
564 <div class="item-content list-panel-all wpapp_toggle" onclick="jQuery('#sep_<?php echo $uniqid;?>').slideToggle();">
565 <div class="item-media notranslate" translate="no"><i class="icon f7-icons wpapp_icon_fill"><?php echo $page['icon_2'];?></i><i class="icon f7-icons wpapp_icon_nofill"><?php echo $page['icon'];?></i><?php echo wpappninja_woo_icon($page['id']);?></div>
566 <div class="item-inner">
567 <div class="item-title"><?php echo $page['label'];?></div>
568 <div class="item-after notranslate" translate="no"><i class="icon f7-icons">chevron_down</i></div>
569 </div>
570 </div>
571 <ul style="display:none" class="wpapp_sep" id="sep_<?php echo $uniqid;?>">
572
573 <?php } elseif (preg_match('#separatorend#', $page['link'])) {
574 $uniqid = uniqid(); ?>
575
576 </ul><ul>
577
578 <?php } else { ?>
579
580 <a id="wpm_left_<?php echo md5($page['link']);?>" href="<?php echo $page['link'];?>" style="color:initial" class="wpappninja_change_color <?php echo $page['class'];?>">
581 <li class="item-content list-panel-all">
582 <div class="item-media notranslate" translate="no"><i class="icon f7-icons wpapp_icon_fill"><?php echo $page['icon_2'];?></i><i class="icon f7-icons wpapp_icon_nofill"><?php echo $page['icon'];?></i><?php echo wpappninja_woo_icon($page['id']);?></div>
583 <div class="item-inner">
584 <div class="item-title"><?php echo $page['label'];?></div>
585 </div>
586 </li>
587 </a>
588
589 <?php }
590 }
591 } ?>
592
593 </ul>
594 </div>
595 </div>
596
597 <div class="menuwidget"><?php echo wpappninja_widget('menu-bottom'); ?></div>
598
599 </div>
600
601 <div class="view view-main ios-edges">
602 <div class="page">
603
604 <div class="navbar">
605 <div class="navbar-inner">
606 <div class="left">
607 <span class="link icon-only panel-open notranslate" translate="no" data-panel="left">
608 <i class="icon f7-icons">bars</i>
609 </span>
610 </div>
611 <?php if (!preg_match('#<form#', wpappninja_widget('navbar-middle'))) { ?><a href="<?php echo $homepage_wpapp;?>" style="color:initial" class="title"><div><?php } else { ?><div class="title"><?php } ?>
612
613
614 <?php echo preg_replace('#<img#', '<img data-nolazy', wpappninja_widget('navbar-middle')); ?>
615
616 </div>
617 <?php if (!preg_match('#<form#', wpappninja_widget('navbar-middle'))) { ?></a><?php } ?>
618
619 <div class="right">
620 <?php echo wpappninja_widget('navbar-right');
621
622 if (!defined("WPAPPNINJA_MAIN_APP") && isset($_SERVER['HTTP_X_WPAPPNINJA_DEMO']) && $_SERVER['HTTP_X_WPAPPNINJA_DEMO'] == "1" && 1<0) {
623
624 echo '<div class="wpappninja-hide-me" style="width:35px">
625 <a href="/?wpappninjalaunch=">
626 <div class="item-media notranslate" translate="no">
627 <i class="icon f7-icons">forward_fill</i>
628 </div>
629 </a>
630 </div>';
631
632 } ?>
633
634 </div>
635 </div>
636 </div>
637
638 <?php if (wpappninja_is_toolbar()) { ?>
639 <div class="toolbar tabbar-labels toolbar-bottom-md">
640 <div class="toolbar-inner">
641 <?php
642 foreach ($pages as $page) {
643 if ($page['menu'] == "tabbar") {
644 echo '<a id="wpm_float_'.md5($page['link']).'" href="' . $page['link'] . '" class="tab-link wpappninja_change_color '.$page['class'].'">
645 <i class="f7-icons wpapp_tabbar wpapp_icon_fill notranslate" translate="no">' . $page['icon_2'] . '</i><i class="f7-icons wpapp_tabbar wpapp_icon_nofill notranslate" translate="no">' . $page['icon'] . '</i>' . wpappninja_woo_icon($page['id']).'
646 <span class="tabbar-label wpapp_tabbar">' . $page['label'] . '</span>
647 </a>';
648 }
649 }
650 ?>
651 </div>
652 </div>
653 <?php } ?>
654
655 <?php if (wpappninja_is_fab()) {
656
657 $pages = wpappninja_get_pages();
658
659 $nbfab = 0;
660 foreach ($pages as $p) {
661
662 if ($p['menu'] == 'fab') {
663
664 $nbfab++;
665 }
666
667 }
668
669 if ($nbfab == 1) { ?>
670 <div class="fab fab-right-bottom notranslate" translate="no">
671
672 <?php foreach ($pages as $p) {
673
674 if ($p['menu'] == 'fab') {
675
676 echo '<a href="'.$p['link'].'">
677 <i class="icon f7-icons">' . $p['icon'] . '</i>
678 </a>';
679 }
680
681 }
682
683 ?>
684 </div>
685 <?php } elseif ($nbfab > 1) { ?>
686 <div class="fab fab-right-bottom notranslate" translate="no">
687 <a href="#">
688 <i class="icon f7-icons">add</i>
689 <i class="icon f7-icons">close</i>
690 </a>
691
692 <div class="fab-buttons fab-buttons-top">
693 <?php foreach ($pages as $p) {
694
695 if ($p['menu'] == 'fab') {
696
697 echo '<a href="'.$p['link'].'">
698 <i class="icon f7-icons">' . $p['icon'] . '</i>
699 </a>';
700 }
701
702 }
703
704 ?>
705 </div>
706 </div>
707 <?php } ?>
708 <?php } ?>
709
710 <div class="page-content <?php if (get_wpappninja_option('speed_reload', '1') == '1') { ?>ptr-content" data-ptr-distance="55<?php } ?>">
711
712 <div class="wpmobile_preload" style="max-height: 100%;overflow: hidden;position:absolute;top:0;right:0;left:0;bottom:0;margin:auto;display:block;z-index:2147483647;display:none">
713
714 <div class="load_container">
715 <div class="load_post">
716 <div class="load_avatar"></div>
717 <?php
718 for ($i = 0; $i<18; $i++) { ?>
719 <div class="load_line"></div>
720 <?php } ?>
721 </div>
722 </div>
723
724
725 </div>
726
727 <?php if (get_wpappninja_option('speed_reload', '1') == '1') { ?>
728 <div class="ptr-preloader">
729 <div class="preloader"></div>
730 <div class="ptr-arrow"></div>
731 </div>
732 <?php } ?>
733
734 <div class="wpappninja_loadme wpifs-loading"><br><center><span class="preloader"></span></center><br></div>
735
736 <?php echo wpappninja_widget('content-top');?>
737 <div class="posts" data-instant>
738 <?php
739
740 $before = "";
741 $after = "";
742 if (function_exists('is_woocommerce') && (is_woocommerce() || is_checkout() || is_cart())) {
743 $before = wpappninja_widget('woocommerce-top');
744 $after = wpappninja_widget('woocommerce-bottom');
745 } elseif( function_exists ( "bp_current_component" ) && bp_current_component()){
746 $before = wpappninja_widget('buddypress-top');
747 $after = wpappninja_widget('buddypress-bottom');
748 } elseif (is_page()) {
749 $before = wpappninja_widget('page-top');
750 $after = wpappninja_widget('page-bottom');
751 } elseif (is_single()) {
752 $before = wpappninja_widget('post-top');
753 $after = wpappninja_widget('post-bottom');
754 } elseif (!isset($_GET['wpapp_shortcode']) && !isset($_GET['wpappninja_read_push'])) {
755 $before = wpappninja_widget('list-top');
756 $after = wpappninja_widget('list-bottom');
757 }
758
759 echo $before;
760
761 if (isset($_GET['wpapp_shortcode'])) {
762
763 $content = "";
764
765 if ($_GET['wpapp_shortcode'] == 'wpapp_push' || $_GET['wpapp_shortcode'] == 'wpapp_config' || $_GET['wpapp_shortcode'] == 'wpapp_login') {
766 $content .= '<div class="post main-post">
767 <div class="wpapp-post-content">';
768 }
769
770 $allowed_shortcodes = [
771 'wpmobile_notification_badge',
772 'wpapp_recent',
773 'wpapp_home',
774 'wpapp_home_configure',
775 'wpapp_qrcode',
776 'wpmobile_qrcode',
777 'wpmobile_qrcode_2',
778 'wpapp_history',
779 'wpapp_share',
780 'wpapp_social',
781 'wpapp_search',
782 'wpapp_config',
783 'wpapp_push',
784 'wpapp_lang_selector',
785 'wpapp_login',
786 'wpappninja_push_config'
787 ];
788
789 $shortcode = isset($_GET['wpapp_shortcode']) ? $_GET['wpapp_shortcode'] : '';
790
791 if (in_array($shortcode, $allowed_shortcodes, true)) {
792 $content .= '<div data-instant>' . do_shortcode('[' . esc_html($shortcode) . ']') . '</div>';
793 }
794
795 if ($_GET['wpapp_shortcode'] == 'wpapp_push' || $_GET['wpapp_shortcode'] == 'wpapp_config' || $_GET['wpapp_shortcode'] == 'wpapp_login') {
796 $content .= '</div>
797 </div>';
798 }
799
800 echo $content;
801
802 echo '<div style="display:none">';
803
804 } else if(isset($_GET['wpappninja_read_push'])) {
805 $content = wpappninja_show_push();
806
807 echo $content;
808 echo '<div style="display:none">';
809 }
810
811
812
813 return '<!-- WPMobile.App -->' . ob_get_clean();
814 }
815