an error occured! You may not be able to access this plugin via direct URL...'; exit(); } else if (!defined('ABSPATH')) { echo '

an error occured! You may not be able to access this plugin via direct URL...

'; exit(); } /*Define Consts*/ if (!defined('WPJSLOADBYMDZ_VER')) { define('WPJSLOADBYMDZ_VER', '1.7.77'); } if (!defined('WPJSLOADBYMDZ_PATH')) { define('WPJSLOADBYMDZ_PATH', trailingslashit(plugin_dir_path(__FILE__))); } if (!defined('WPJSLOADBYMDZ_URL')) { define('WPJSLOADBYMDZ_URL', trailingslashit(plugin_dir_url(__FILE__))); } if (!defined('WPJSLOADBYMDZ_PLG')) { define('WPJSLOADBYMDZ_PLG', __FILE__); } /**/ /*add settings btn*/ if(!function_exists('wpjsloadbymdz_addsettingsbtn')) { function wpjsloadbymdz_addsettingsbtn( array $links ) { $url = get_admin_url() . 'tools.php?page=wp-js-loader-bymdz'; $settings_link = '' . esc_html__('Settings', 'wpjs-loader-bymdez'). ''; $links[] = $settings_link; return $links; } }add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'wpjsloadbymdz_addsettingsbtn' ); /**/ /*Translations*/ if (!function_exists('wpjsloadbymdz_i18n')) { function wpjsloadbymdz_i18n() { $test = load_plugin_textdomain( 'wpjs-loader-bymdez', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); } }add_action('init', 'wpjsloadbymdz_i18n'); /**/ /*Admin*/ if(is_admin()) { include_once WPJSLOADBYMDZ_PATH.DIRECTORY_SEPARATOR.'admin'.DIRECTORY_SEPARATOR.'admin-ajax.php'; include_once WPJSLOADBYMDZ_PATH.DIRECTORY_SEPARATOR.'admin'.DIRECTORY_SEPARATOR.'class-admin.php'; } /**/ //Fetch Some Settings $is_active = get_option('wpjsloadbymdz_activate'); $use_skl_load = get_option('wpjsloader_use_sklload'); $dis_sklload_elementor = 0; $dis_sklload_guten = 0; if($is_active == 1 && $use_skl_load == 1){ $dis_sklload_elementor = get_option('wpjsloader_dis_sklload_elem'); if($dis_sklload_elementor != 1){ include_once WPJSLOADBYMDZ_PATH.DIRECTORY_SEPARATOR.'elementor'.DIRECTORY_SEPARATOR.'core.php'; } $dis_sklload_guten = get_option('wpjsloader_dis_sklload_guten'); if($dis_sklload_guten != 1){ include_once WPJSLOADBYMDZ_PATH.DIRECTORY_SEPARATOR.'gutenberg'.DIRECTORY_SEPARATOR.'core.php'; } } /***/ /*Core*/ if(!is_admin()) { if($is_active == '1') {//dont run anything on the front if plugin is deactive if(!function_exists('wpjsloadbymdz_def_settings')) { function wpjsloadbymdz_def_settings() { //helpers function wpjsloadbymdz_normalize_url($url) { $url_arr = str_split($url); $arrlen = count($url_arr); //add `/` at the end of url! if(isset($url_arr[$arrlen-1])){ $last_inx = $url_arr[$arrlen-1]; if($last_inx != '/'){ $url_arr[] = '/'; $url = implode('', $url_arr); } } /***/ //remove `https` OR `http` at the begining of url if(strpos($url, 'https://') !== false){ $url = explode('https://', $url); if(isset($url[1])){ $url = $url[1]; } }else if(strpos($url, 'http://') !== false){ $url = explode('http://', $url); if(isset($url[1])){ $url = $url[1]; } } /***/ return $url; } /***/ //Fetch Settings $is_active = get_option('wpjsloadbymdz_activate'); $doon_scroll = get_option('wpjsloadbymdz_doon_scroll'); $loader_css = get_option('wpjsloadbymdz_loadercss'); $loader_effect = get_option('wpjsloadbymdz_loadereffect'); $apply_on_exts = get_option('wpjsloadbymdz_applyonexts'); $a_tags_exc_classes = get_option('wpjsloadbymdz_clasesexc'); $a_tags_exc_attrs = get_option('wpjsloadbymdz_attrsexc'); $a_tags_exc_par_css = get_option('wpjsloadbymdz_par_classexc'); $a_tags_exc_par_attr = get_option('wpjsloadbymdz_par_attrexc'); $is_cache = get_option('wpjsloadbymdz_cache'); $cache_time = get_option('wpjsloadbymdz_cache_time'); $cache_exc_pages = get_option('wpjsloadbymdz_cache_excpages'); $cache_on_loggedins = get_option('wpjsloadbymdz_cacheon_users'); $don_cache_queries = get_option('wpjsloadbymdz_dont_cachequeries'); $cache_force_remove = get_option('wpjsloadbymdz_cache_remover'); $ajax_cache = get_option('wpjsloadbymdz_ajax_cache'); $dis_pwa = get_option('wpjsloader_dispwa'); $pwa_param = get_option('wpjsloadbymdz_pwaparam'); $is_drag_detect = get_option('wpjsloader_is_dragdetect'); $drag_threshold = get_option('wpjsloadbymdz_dragthreshold'); $no_top_scroll = get_option('wpjsloadbymdz_notopscroll'); $run_when_wpdashbar_exist = get_option('wpjsloader_is_actonwpadmindash'); $trans_time = get_option('wpjsloadbymdz_trans_time'); $is_ss_plc = 19; if(defined('WPJSLOADBPROYMDZ_VER')){ $is_ss_plc = 8; } $fetch_mtd = 'default'; $write_mtd = 'default'; $use_dash_loader = 0; $dash_height = 3.5; $dash_pos = 'top'; $dash_bg = '#ffffff'; $dash_color = '#ff0000'; $dash_dir = 'ltr'; $dash_roundness = 10;//in-px $use_prod_load = 0; $prod_load_img_src = ''; $prod_mbg = '#4f6eed3d'; $prod_m_glass = 1; $prod_ibg = '#ffffffd1'; $prod_bcolor = '#54515180'; $prod_load_img_wid = 77; $prod_load_img_hei = 77; $prod_items_pos = 'row'; $prod_load_slogan = esc_html__('Powered by Ajax Loader !', 'wpjs-loader-bymdez'); $prod_load_slogan_color = '#000000'; $clr = 0; $exc_by_a_urls = ''; if($is_ss_plc != 19){ $fetch_mtd = get_option('wpjsloader_load_mtd'); $write_mtd = get_option('wpjsloader_write_mtd'); $use_dash_loader = get_option('wpjsloader_adddash_loader'); if($use_dash_loader == 1){ $dash_height = get_option('wpjsloader_dash_h'); $dash_pos = get_option('wpjsloader_dash_pos'); $dash_bg = get_option('wpjsloader_dash_bg'); $dash_color = get_option('wpjsloader_dash_color'); $dash_dir = get_option('wpjsloader_dash_dir'); $dash_roundness = get_option('wpjsloader_dash_round'); if(empty($dash_bg)){ $dash_bg = '#ffffff'; } if(empty($dash_roundness)){ $dash_roundness = 10; } } $use_prod_load = get_option('wpjsloader_addprod_load'); if(defined('WPJSLOADPROBYMDZ_URL')){ $prod_load_img_src = WPJSLOADPROBYMDZ_URL.'assets/img/test-loader.svg'; } if($use_prod_load == 1){ $prod_mbg = get_option('wpjsloader_prod_mbg'); $prod_m_glass = get_option('wpjsloader_prod_glass'); $prod_ibg = get_option('wpjsloader_prod_ibg'); $prod_bcolor = get_option('wpjsloader_prod_bcolor'); $prod_load_img_src = get_option('wpjsloader_prod_imgsrc'); $prod_load_img_wid = get_option('wpjsloader_prod_imgw'); $prod_load_img_hei = get_option('wpjsloader_prod_imgh'); $prod_load_slogan = get_option('wpjsloader_prod_slogan'); $prod_items_pos = get_option('wpjsloader_prod_itemspos'); $prod_load_slogan_color = get_option('wpjsloader_prod_slogan_color'); if(empty($prod_load_img_src)){ $prod_load_img_src = WPJSLOADPROBYMDZ_URL.'assets/img/test-loader.svg'; } if(empty($prod_load_slogan)){ $prod_load_slogan = esc_html__('Powered by Ajax Loader !', 'wpjs-loader-bymdez'); } } $clr = get_option('wpjsloader_cln_urls'); $exc_by_a_urls = get_option('wpjsloader_exc_byurl'); $exc_by_a_urls = explode("\n", $exc_by_a_urls); $exc_by_a_urls = implode('|', $exc_by_a_urls); } $use_vis_vika = 'yes'; if(defined('WPJSLOADBPROYMDZ_VER')){ $exc_pages = get_option('wpjsloader_exc_pages'); if(!empty($exc_pages)){ $exc_pages_arr = explode("\n", $exc_pages); if(is_front_page()){ $curr_url = home_url(); }else { $curr_url = (empty($_SERVER['HTTPS']) ? 'http' : 'https') . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; if(strpos($curr_url, '?') !== false){ $curr_url = explode('?',$curr_url); if(isset($curr_url[0])){ $curr_url = $curr_url[0]; } } } $curr_url = wpjsloadbymdz_normalize_url($curr_url); foreach($exc_pages_arr as $tmp_page){ $test_url = wpjsloadbymdz_normalize_url($tmp_page); if($test_url == $curr_url){ $use_vis_vika = 'no'; } } } } if($trans_time === NULL || $trans_time == '' || $trans_time == ' ' || !is_numeric($trans_time)) { $trans_time = '.5'; }else $trans_time = $trans_time/1000; switch($loader_effect) { case 'simple': $class_to_print = ' .waiting-for-ajx1 { opacity: .5 !important; pointer-events: none !important; } '; break; case 'glassy': $class_to_print = ' .waiting-for-ajx2 { opacity: .5 !important; pointer-events: none !important; filter: blur(3px) !important; } '; break; case 'fantasy': $class_to_print = ' .waiting-for-ajx3 { filter: hue-rotate(45deg) !important; pointer-events: none !important; } '; break; case 'xray': $class_to_print = ' .waiting-for-ajx4 { opacity: .77 !important; filter: invert(1) !important; pointer-events: none !important; } '; break; case 'dark': $class_to_print = ' .waiting-for-ajx5 { filter: brightness(0.5) !important; pointer-events: none !important; } '; break; case 'sepia': $class_to_print = ' .waiting-for-ajx6 { opacity: .9 !important; filter: sepia(1) !important; pointer-events: none !important; } '; break; case 'black': $class_to_print = ' .waiting-for-ajx7 { opacity: .5 !important; filter: grayscale(1) !important; pointer-events: none !important; } '; break; case 'blackglass': $class_to_print = ' .waiting-for-ajx8 { filter: brightness(0.3)blur(3px) !important; pointer-events: none !important; } '; break; } //Print options (for the JS file) ob_start(); ?> true, ]; $is_no_compress = get_option('wpjsloader_add_nocompress'); $is_tmp_plg = 6;//means if is this plugin is avtive if(defined('WPJSLOADBPROYMDZ_VER')){ $is_tmp_plg = 4; $jsfiles_load_mtd = get_option('wpjsloader_jsfiles_load'); $js_file1_fetch_mtd = get_option('wpjsloader_jsfile1_fetchprio'); $file1_opt_arr = [ 'in_footer' => true, 'strategy' => $jsfiles_load_mtd, 'fetchpriority' => $js_file1_fetch_mtd, ]; } if($is_no_compress == '1') { if($is_tmp_plg == 6){ wp_enqueue_script('wpjsloadermdz', WPJSLOADBYMDZ_URL.'loader-notmin.js', array('jquery'), WPJSLOADBYMDZ_VER, $file1_opt_arr); }else if($is_tmp_plg == 4){ wp_enqueue_script('wpjsloadermdz', WPJSLOADPROBYMDZ_URL.'assets/libs/axios/orio-rio-notmin.js', array('jquery'), WPJSLOADBYMDZ_VER, $file1_opt_arr); } }else { if($is_tmp_plg == 6){ wp_enqueue_script('wpjsloadermdz', WPJSLOADBYMDZ_URL.'loader.js', array('jquery'), WPJSLOADBYMDZ_VER, $file1_opt_arr); }else if($is_tmp_plg == 4){ wp_enqueue_script('wpjsloadermdz', WPJSLOADPROBYMDZ_URL.'assets/libs/axios/orio-yo-js.js', array('jquery'), WPJSLOADBYMDZ_VER, $file1_opt_arr); } } } } add_action('wp_enqueue_scripts', 'wpjsloadbymdz_add_assets', 9990 , 0); $use_cust_codes = get_option('wpjsloader_cust_scr'); if($use_cust_codes == 1){ add_action('wp_footer', function(){ if(defined('WPJSLOADBPROYMDZ_VER')){ $unfiltered_js_codes = get_option('wpjsloader_unf_js'); $user_codes2 = get_option('wpjsloader_cust_jscode2'); if(!empty($user_codes2)): if($unfiltered_js_codes != 1){ $user_codes2 = esc_js($user_codes2); $user_codes2 = str_replace('"', '"', $user_codes2); $user_codes2 = str_replace('\n', "\n", $user_codes2); $user_codes2 = str_replace("\'", "'", $user_codes2); $user_codes2 = str_replace('&', '&', $user_codes2); $user_codes2 = str_replace('<', '<', $user_codes2); $user_codes2 = str_replace('>', '>', $user_codes2); } ?> ', $user_codes); } ?> $plc_hei){ $plc_hei = (100*$plc_hei)/$plc_wid; //$plc_txt_y = ($plc_hei/2).'%25'; $plc_hei = $plc_hei.'%25'; $plc_wid = '100%25'; }else { $plc_wid = (100*$plc_wid)/$plc_hei; //$plc_txt_x = ($plc_wid/2).'%25'; $plc_wid = $plc_wid.'%25'; $plc_hei = '100%25'; } $plc_wid = esc_attr($plc_wid); $plc_hei = esc_attr($plc_hei); //$plc_txt_x = esc_attr($plc_txt_x); //$plc_txt_y = esc_attr($plc_txt_y); } } } /***/ //$placeholder = "data:image/svg+xml;utf8,".$plc_txt."";//Deprecated Since: 1.6.15 //$placeholder = "data:image/svg+xml;utf8,";//Deprecated Since: 1.6.15 $placeholder = "data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 ".$plc_wid." ".$plc_hei."'><rect width='100%' height='100%' fill='%23e0e0e0'/></svg>"; } $key_word = 'img'; if($is_src == 2){ $placeholder = 'nop'; }//for `sizes` attribute! break; case '2': case 2: if(defined('WPJSLOADPROBYMDZ_URL')){ $placeholder = WPJSLOADPROBYMDZ_URL.'assets/video/tiny-audio.m4a'; } $key_word = 'audio'; break; case '3': case 3: if(defined('WPJSLOADPROBYMDZ_URL')){ $placeholder = WPJSLOADPROBYMDZ_URL.'assets/video/tiny-vid.mp4'; } $key_word = 'video'; break; case '4': case 4: $placeholder = '#'; if(defined('WPJSLOADPROBYMDZ_URL')){ $placeholder = WPJSLOADPROBYMDZ_URL.'assets/html/index.html'; } $key_word = 'iframe'; break; case '5': case 5: $key_word = 'embed'; break; case '6': case 6: $key_word = 'input type="image"'; break; } //fix all PHP Warnings & Notices if(!isset($wid_mathces[0])){ $wid_mathces[0] = ''; } if(!isset($matches[1])){ $matches[1] = ''; } if(!isset($matches[2])){ $matches[2] = ''; } if(!isset($matches[3])){ $matches[3] = ''; } /***/ //To resolve some PHP fatal errors on `sprintf` with `%` real chars! if(strpos($wid_mathces[0], '%') !== false){ $wid_mathces[0] = str_replace('%', '%%', $wid_mathces[0]); } if(strpos($matches[1], '%') !== false){ $matches[1] = str_replace('%', '%%', $matches[1]); } if(strpos($matches[2], '%') !== false){ $matches[2] = str_replace('%', '%%', $matches[2]); } if(strpos($matches[3], '%') !== false){ $matches[3] = str_replace('%', '%%', $matches[3]); } /***/ //$matches[1] = 'tested!'; if($is_src == 1){ //src $html = sprintf( '<'.$key_word.' %1$s decoding="async" src="%4$s" wpjs-laze-src=%2$s%3$s dont-placeholder="%5$s" '.$wid_mathces[0].'>', $matches[1], $matches[2], $matches[3], $placeholder, $dont_use_placeholder); }else if($is_src == 0){ //srcset $html = sprintf( '<'.$key_word.' %1$s decoding="async" srcset="%4$s" wpjs-laze-srcset=%2$s%3$s dont-placeholder="%5$s" '.$wid_mathces[0].'>', $matches[1], $matches[2], $matches[3], $placeholder, $dont_use_placeholder); }else if($is_src == 2){ //sizes $html = sprintf( '<'.$key_word.' %1$s decoding="async" sizes="%4$s" wpjs-laze-sizes=%2$s%3$s dont-placeholder="%5$s" '.$wid_mathces[0].'>', $matches[1], $matches[2], $matches[3], $placeholder, $dont_use_placeholder); } $html_noscript = ''; if($mode != 4 && $is_src == 1){ $html_noscript = sprintf( '', $matches[1], $matches[2], $matches[3] ); } return $html . $html_noscript; }else { $key_word = ''; switch($mode){ case '1': case 1: $key_word = 'img'; break; case '2': case 2: $key_word = 'audio'; break; case '3': case 3: $key_word = 'video'; break; case '4': case 4: $key_word = 'iframe'; break; case '5': case 5: $key_word = 'embed'; break; case '6': case 6: $key_word = 'input type="image"'; break; } $html = sprintf( '<'.$key_word.'%1$s wpjsload-is-excluded="1" wpjs-laze-src="none" src=%2$s%3$s>', $matches[1], $matches[2], $matches[3]); return $html;//No Changes! } } } if(!function_exists('wpjsloadbymdz_laze')){ function wpjsloadbymdz_laze($html) { if(defined('WPJSLOADBPROYMDZ_VER')){ //settings $dont_use_placeholder = get_option('wpjsloader_laze_noplc'); $plc_txt = ''; if($dont_use_placeholder != 1){ $plc_txt = get_option('wpjsloader_laze_txt'); } $use_exceptions = get_option('wpjsloader_laze_use_excs'); //var_dump($use_exceptions); $exc_tags_keywords = ''; if($use_exceptions == 1){ $exc_tags_keywords = get_option('wpjsloader_exc_laze_tags'); } /***/ $html = preg_replace_callback( '#]*) src=("(?:[^"]+)"|\'(?:[^\']+)\'|(?:[^ >]+))([^>]*)>#', function($matches)use($dont_use_placeholder, $plc_txt, $use_exceptions, $exc_tags_keywords){ return wpjsloadbymdz_laze_loader($matches, 1, $dont_use_placeholder, $plc_txt, $use_exceptions, $exc_tags_keywords); }, $html ); $html = preg_replace_callback( '#]*) srcset=("(?:[^"]+)"|\'(?:[^\']+)\'|(?:[^ >]+))([^>]*)>#', function($matches)use($dont_use_placeholder, $plc_txt, $use_exceptions, $exc_tags_keywords){ return wpjsloadbymdz_laze_loader($matches, 1, $dont_use_placeholder, $plc_txt, $use_exceptions, $exc_tags_keywords, 0); }, $html ); $html = preg_replace_callback( '#]*) sizes=("(?:[^"]+)"|\'(?:[^\']+)\'|(?:[^ >]+))([^>]*)>#', function($matches)use($dont_use_placeholder, $plc_txt, $use_exceptions, $exc_tags_keywords){ return wpjsloadbymdz_laze_loader($matches, 1, $dont_use_placeholder, $plc_txt, $use_exceptions, $exc_tags_keywords, 2); }, $html ); $html = preg_replace_callback( '#]*) src=("(?:[^"]+)"|\'(?:[^\']+)\'|(?:[^ >]+))([^>]*)>#', function($matches)use($dont_use_placeholder, $plc_txt, $use_exceptions, $exc_tags_keywords){ return wpjsloadbymdz_laze_loader($matches, 1, $dont_use_placeholder, $plc_txt, $use_exceptions, $exc_tags_keywords); }, $html ); $html = preg_replace_callback( '#]*) srcset=("(?:[^"]+)"|\'(?:[^\']+)\'|(?:[^ >]+))([^>]*)>#', function($matches)use($dont_use_placeholder, $plc_txt, $use_exceptions, $exc_tags_keywords){ return wpjsloadbymdz_laze_loader($matches, 1, $dont_use_placeholder, $plc_txt, $use_exceptions, $exc_tags_keywords, 0); }, $html ); $html = preg_replace_callback( '#]*) src=("(?:[^"]+)"|\'(?:[^\']+)\'|(?:[^ >]+))([^>]*)>#', function($matches)use($use_exceptions, $exc_tags_keywords){ return wpjsloadbymdz_laze_loader($matches, 2, 1, '', $use_exceptions, $exc_tags_keywords); }, $html ); $html = preg_replace_callback( '#]*) src=("(?:[^"]+)"|\'(?:[^\']+)\'|(?:[^ >]+))([^>]*)>#', function($matches)use($use_exceptions, $exc_tags_keywords){ return wpjsloadbymdz_laze_loader($matches, 3, 1, '', $use_exceptions, $exc_tags_keywords); }, $html ); $html = preg_replace_callback( '#]*) src=("(?:[^"]+)"|\'(?:[^\']+)\'|(?:[^ >]+))([^>]*)>#', function($matches)use($use_exceptions, $exc_tags_keywords){ return wpjsloadbymdz_laze_loader($matches, 4, 1, '', $use_exceptions, $exc_tags_keywords); }, $html ); $html = preg_replace_callback( '#]*) src=("(?:[^"]+)"|\'(?:[^\']+)\'|(?:[^ >]+))([^>]*)>#', function($matches)use($use_exceptions, $exc_tags_keywords){ return wpjsloadbymdz_laze_loader($matches, 5, 1, '', $use_exceptions, $exc_tags_keywords); }, $html ); $html = preg_replace_callback( '#]*) type="image"* src=("(?:[^"]+)"|\'(?:[^\']+)\'|(?:[^ >]+))([^>]*)>#', function($matches)use($use_exceptions, $exc_tags_keywords){ return wpjsloadbymdz_laze_loader($matches, 6, 1, '', $use_exceptions, $exc_tags_keywords); }, $html ); } return $html; } } /** * Start output buffering early to capture all HTML. */ add_action( 'template_redirect', function(){ if(defined('WPJSLOADBPROYMDZ_VER')){ob_start('wpjsloadbymdz_laze');} }, 1); // Fires before any HTML is sent. add_action('wp_head', function(){ $dont_use_placeholder = get_option('wpjsloader_laze_noplc'); $placeholder_txt = get_option('wpjsloader_laze_txt'); if($dont_use_placeholder != 1): $plc_txt_font_family = get_option('wpjsloader_laze_txt_ff'); if(empty($plc_txt_font_family)){ $plc_txt_font_family = 'sans-serif'; } ?> true, 'strategy' => $jsfiles_load_mtd, 'fetchpriority' => $js_file2_fetch_mtd, ]; $is_no_compress = get_option('wpjsloader_add_nocompress'); if($is_no_compress == 1){ wp_enqueue_script('wpjsloadermdz-lazyloader', WPJSLOADPROBYMDZ_URL.'assets/libs/hex/mtpms-runner-notmin.js', [], WPJSLOADBYMDZ_VER, $file2_opt_arr); }else { wp_enqueue_script('wpjsloadermdz-lazyloader', WPJSLOADPROBYMDZ_URL.'assets/libs/hex/mtpms-runner.js', [], WPJSLOADBYMDZ_VER, $file2_opt_arr); } } }, 99 , 0); } if($use_skl_load == 1){ include_once WPJSLOADBYMDZ_PATH.DIRECTORY_SEPARATOR.'extra'.DIRECTORY_SEPARATOR.'skeleton-loader'.DIRECTORY_SEPARATOR.'core.php'; wpjsload_skl_loader::get_instance(); } }//Endof if (is_active) } /* Omit closing PHP tag to avoid "Headers already sent" issues. */