Skip to content

Instantly share code, notes, and snippets.

View muks999's full-sized avatar

Muks999 muks999

View GitHub Profile
@atelierbram
atelierbram / wp-img-data-src-function.php
Last active September 5, 2021 13:06
Set data-src attribute in a function for lazy-loading of image (WordPress)
function rchv_projects_link() { ?>
<a class="grid_item-link gallery_item-link" href="<?php the_permalink(); ?>" aria-hidden="true" tabindex="-1">
<?php $imgPlaceholder = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk2A8AAMUAwUPJ2C4AAAAASUVORK5CYII="; ?>
<figure class="grid_item-figure gallery_item-figure">
<?php if( !empty(get_the_post_thumbnail()) ) {
the_post_thumbnail( 'post-thumbnail', array(
'alt' => the_title_attribute( array(
'echo' => false,
) ),
'src' => $imgPlaceholder,
@atelierbram
atelierbram / querySelectorAll_Looping.js
Created November 14, 2018 20:07
A common need when writing vanilla JavaScript is to find a selection of elements in the DOM and loop over them. For example, finding instances of a button and attaching a click handler to them.
let buttons = document.querySelectorAll("button");
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of
// http://kangax.github.io/compat-table/es6/#for..of_loops
for (const button of buttons) {
button.addEventListener('click', () => {
console.log("for of worked");
});
}
@atelierbram
atelierbram / wp-single-post-nav.php
Created September 9, 2018 15:35
WordPress Single Post Nav
<?php
if ( ! function_exists( 'mytheme_post_nav' ) ) :
/**
* Display navigation to next/previous post when applicable.
*
* @return void
*/
function mytheme_post_nav() {
// Don't print empty markup if there's nowhere to navigate.
$previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true );
@artikus11
artikus11 / .htaccess
Created June 29, 2018 09:19
Редирект с http На https
#Вариант 1
RewriteCond %{HTTP:X-HTTPS} !1
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
#Вариант 2
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
<?php
if ( ! isset( $content_width ) ) $content_width = 1080;
function et_setup_theme() {
global $themename, $shortname, $et_store_options_in_one_row, $default_colorscheme;
$themename = 'Divi';
$shortname = 'divi';
$et_store_options_in_one_row = true;
/*
* Function for post duplication. Dups appear as drafts. User is redirected to the edit screen
*/
function rd_duplicate_post_as_draft(){
global $wpdb;
if (! ( isset( $_GET['post']) || isset( $_POST['post']) || ( isset($_REQUEST['action']) && 'rd_duplicate_post_as_draft' == $_REQUEST['action'] ) ) ) {
wp_die('No post to duplicate has been supplied!');
}
/*
@atelierbram
atelierbram / convert-markdown-to-html-css-with-pandoc.md
Created April 2, 2017 10:46
Convert markdown files to html with Pandoc

Convert Markdown to html+css with Pandoc

Convert single markdown file to html from commandline:

  pandoc -f markdown -t html5 -o output.html input.md -c style.css

Convert multiple markdown files

@artikus11
artikus11 / .htaccess
Last active January 14, 2022 08:51
Заготовка для подключения браузерного кеширования
Включение кеша браузера
=====
Вариант 1
===
<ifModule mod_headers.c>
<FilesMatch "\.(js|css|txt)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
<FilesMatch "\.(flv|swf|ico|gif|jpg|jpeg|png)$">
Header set Cache-Control "max-age=2592000"
@mikeoberdick
mikeoberdick / divi_mobile_menu_fix.css
Last active March 11, 2019 05:18
A jQuery fix for the Divi Theme mobile menu that collapses all of the submenus
.et_mobile_menu .menu-item-has-children > a {
background-color: transparent;
}
#main-header .et_mobile_menu li ul.sub-menu.hide {
display: none !important;
visibility: hidden !important;
transition: all 1.5s ease-in-out;
}
@philbar
philbar / Magnific Popup - Youtube.html
Last active December 10, 2022 08:18
Runs a Youtube Video in Magnific Popup.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="//www.youtube.com/iframe_api"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.0.0/jquery.magnific-popup.min.js"></script>
<script>
$(document).ready(function() {
// Initializes Magnific Popup
$('#lp-pom-image-202 a, #lp-pom-box-218 a, #lp-pom-box-217 a').magnificPopup({
disableOn: 700,