Skip to content

Instantly share code, notes, and snippets.

@shirokoweb
shirokoweb / functions.php
Last active August 24, 2022 13:10
Sample functions.php
<?php
// remove API access
// https://developer.wordpress.org/rest-api/using-the-rest-api/frequently-asked-questions/
add_filter( 'rest_authentication_errors', function( $result ) {
if ( ! empty( $result ) ) {
return $result;
}
if ( ! is_user_logged_in() ) {
return new WP_Error( 'rest_not_logged_in', 'You are not currently logged in.', array( 'status' => 401 ) );
@shirokoweb
shirokoweb / footer.php
Created February 17, 2018 20:20
Load fonts async
@shirokoweb
shirokoweb / cronwpbkp.sh
Created February 17, 2018 21:14
Cron job daily backup wp on GitHub
#!/bin/bash
git add . && \
git commit -a -m "Dayly BKP `date`" && \
git push origin stage
@shirokoweb
shirokoweb / ytloader.js
Last active February 19, 2018 21:59
Load async YT videos
<script>
function init() {
var vidDefer = document.getElementsByTagName('iframe');
for (var i=0; i<vidDefer.length; i++) {
if(vidDefer[i].getAttribute('data-src')) {
vidDefer[i].setAttribute('src',vidDefer[i].getAttribute('data-src'));
} } }
window.onload = init;
</script>
@shirokoweb
shirokoweb / ytmodal.js
Created February 20, 2018 20:06
YT vids ina modal
<script type="text/javascript">
(function($){
$(document).ready(function() {
$('.ppyt').magnificPopup({
disableOn: 700,
type: 'iframe',
mainClass: 'mfp-fade',
removalDelay: 160,
preloader: false,
fixedContentPos: false
@shirokoweb
shirokoweb / videomodule.html
Last active March 5, 2020 23:33
Code Module for YT videos
<a class="ppyt" href="https://www.youtube.com/watch?v=s1T9bWKJW_g">
<img src="http://webplus.odns.fr/wp-content/uploads/2018/02/video-overlay.jpg" width="800" height="534" alt="" class="" />
</a>
@shirokoweb
shirokoweb / player.js
Created March 13, 2018 10:24
Embed YT videos
<div id="videosansson"></div>
<script async src="https://www.youtube.com/iframe_api"></script>
<script>
function onYouTubeIframeAPIReady() {
var player;
player = new YT.Player('videosansson', {
videoId: 'ID_DE_LA_VIDEO', // ID vidéo YT
width: 560, // Largeur player (en px)
height: 316, // Hauteur player (en px)
@shirokoweb
shirokoweb / div.html
Created March 13, 2018 10:27
YT video as background
<div style="position: fixed; z-index: -99; width: 100%; height: 100%">
<iframe frameborder="0" height="100%" width="100%"
src="https://youtube.com/embed/ID?autoplay=1&controls=0&showinfo=0&autohide=1">
</iframe>
</div>
@shirokoweb
shirokoweb / showids.php
Created March 25, 2018 07:58
WP Add column to display IDs
<?php
class Custom_WP_Show_IDs {
public function __construct() {
add_action( 'admin_init', array( $this, 'custom_objects' ) );
add_action( 'admin_head', array( $this, 'add_css' ) );
// For Post Management
@shirokoweb
shirokoweb / cookiepermission.json
Created April 30, 2018 13:10
GTM Cookiepermission GDPR
{
"exportFormatVersion": 2,
"exportTime": "2018-04-30 13:08:19",
"containerVersion": {
"path": "accounts/2719250224/containers/8610498/versions/13",
"accountId": "2719250224",
"containerId": "8610498",
"containerVersionId": "13",
"container": {
"path": "accounts/2719250224/containers/8610498",