Skip to content

Instantly share code, notes, and snippets.

View mark7651's full-sized avatar

Max mark7651

  • LPunity
View GitHub Profile
@mark7651
mark7651 / better-webfont-loading-with-localstorage-and-woff2.js
Created October 5, 2023 19:33 — forked from meritt/better-webfont-loading-with-localstorage-and-woff2.js
Улучшение загрузки веб-шрифтов с использованием localStorage и поддержкой формата WOFF2
// Этот скрипт должен быть размещён в <head> над всеми внешними объявлениями стилей (link[rel=stylesheet])
function loadFont(fontName, woffUrl, woff2Url) {
// 0. Многие неподдерживаемые браузеры должны останавливать работу тут.
var nua = navigator.userAgent;
var noSupport = !window.addEventListener // IE8 и ниже
|| (nua.match(/(Android (2|3|4.0|4.1|4.2|4.3))|(Opera (Mini|Mobi))/) && !nua.match(/Chrome/)) // Android Stock Browser до 4.4 и Opera Mini
if (noSupport) {
return;
}
@mark7651
mark7651 / install.php
Last active July 3, 2023 19:58 — forked from sinyavsky/install.php
A simple PHP script that automatically downloads and unzips the latest version of Wordpress in the current directory (./), so that I don't have to download it and upload it to my server through FTP manually.
<?php
// список плагинов для установки
$pluginsList = [
'safe-svg',
'cyr2lat',
'wp-hide-security-enhancer',
];
@mark7651
mark7651 / Hide Div When Clicked Outside It
Created February 24, 2023 14:07 — forked from slavapas/Hide Div When Clicked Outside It
Hide Div When Clicked Outside It
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Vanilla Javascript DropDown Menu Example</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="menu-dropdown">Menu &#9660;</div>
@mark7651
mark7651 / php-html-css-js-minifier.php
Created February 5, 2023 13:12 — forked from Rodrigo54/php-html-css-js-minifier.php
PHP Function to Minify HTML, CSS and JavaScript
<?php
/**
* -----------------------------------------------------------------------------------------
* Based on `https://github.com/mecha-cms/mecha-cms/blob/master/system/kernel/converter.php`
* -----------------------------------------------------------------------------------------
*/
// HTML Minifier
function minify_html($input) {
@mark7651
mark7651 / isElementInViewport.js
Created September 28, 2022 09:41 — forked from davidtheclark/isElementInViewport.js
JavaScript: Is element in viewport?
/*
No jQuery necessary.
Thanks to Dan's StackOverflow answer for this:
http://stackoverflow.com/questions/123999/how-to-tell-if-a-dom-element-is-visible-in-the-current-viewport
*/
function isElementInViewport(el) {
var rect = el.getBoundingClientRect();
return (
rect.top >= 0 &&
@mark7651
mark7651 / scripts-lazy-load.html
Created August 21, 2022 08:06 — forked from mihdan/scripts-lazy-load.html
Подключение скриптов с отложенной загрузкой
<!-- Див в котором будет отображаться виджет -->
<div id="vk_community_messages"></div>
<script type="text/javascript">
// откладываем по времени
setTimeout(function(){
// создаем элемент script и добавляем его асинхронно в DOM
var VKO = document.createElement("script");
VKO.src = 'https://vk.com/js/api/openapi.js';
VKO.async = true;
@mark7651
mark7651 / index.php
Created January 20, 2022 15:35 — forked from galengidman/index.php
get ACF image size URL by image object
<?php
// first, get the image object returned by ACF
$image_object = get_field('my_image_field');
// and the image size you want to return
$image_size = 'thumbnail';
// now, we'll exctract the image URL from $image_object
$image_url = $image_object['sizes'][$image_size];
@mark7651
mark7651 / .htaccess
Created October 15, 2021 06:54 — forked from cdwharton/.htaccess
.htaccess speed optimizations
# ----------------------------------------------------------------------
# | File access |
# ----------------------------------------------------------------------
# Block access to directories without a default document.
#
# You should leave the following uncommented, as you shouldn't allow
# anyone to surf through every directory on your server (which may
# includes rather private places such as the CMS's directories).
<?php
/*
* WordPress Breadcrumbs
* author: Dimox
* version: 2019.03.03
* license: MIT
*/
function dimox_breadcrumbs() {
/* === OPTIONS === */
@mark7651
mark7651 / functions.php
Created June 17, 2021 06:17 — forked from dariodev/functions.php
Programmatically Create a User in WordPress
<?php
// Programmatically Create a User in WordPress
add_action('init', 'prefix_add_user');
function prefix_add_user() {
$username = 'username123';
$password = 'pasword123';
$email = 'drew@example.com';
$user = get_user_by( 'email', $email );
if( ! $user ) {