Skip to content

Instantly share code, notes, and snippets.

@em-piguet
em-piguet / ytacfoembed.php
Created March 11, 2024 21:55 — forked from tallesairan/ytacfoembed.php
Youtube Video gallery acf oEmbed field
<?php
function get_youtube_video_ID($youtube_video_url) {
/**
* Pattern matches
* http://youtu.be/ID
* http://www.youtube.com/embed/ID
* http://www.youtube.com/watch?v=ID
* http://www.youtube.com/?v=ID
* http://www.youtube.com/v/ID
* http://www.youtube.com/e/ID
@em-piguet
em-piguet / membership-gift.php
Created May 9, 2022 12:26
If the post is a gift to the users, we remove the restriction on post content during 7 days
<?php
function acces_article_offert()
{
// only on post
if (is_singular('post')) {
// get the gift start date
$date_de_debut = get_field('article_gift');
if ($date_de_debut) {
$date_de_fin = date('Y-m-d', strtotime($date_de_debut . ' + 7 days'));
@em-piguet
em-piguet / medias.php
Last active September 20, 2021 10:35
<?php
/*
* ADD OEMBED TO RTS.CH
* Copied from : https://gist.github.com/marcwieland95/61074b488aae12460a17882aeb3e0fd8
*/
wp_embed_register_handler('srg', '#https?:\/\/(?:www\.)?(srf|rsi|rts|rtr)\.ch\/.*(?:detail\/|video:)((?:.{8}-.{4}-.{4}-.{4}-.{12})|\d*)(?:.startTime=(\d*)|.*)#i', function ($matches, $attr, $url, $rawattr) {
return sprintf(
'<div class="embed-container"><iframe width="560" height="315" src="https://%1$s.ch/play/embed?urn=urn:%1$s:video:%2$s" allowfullscreen allow="encrypted-media"></iframe></div>',
esc_attr($matches[1]),
esc_attr($matches[2]),
@em-piguet
em-piguet / civi-update.sh
Last active December 13, 2021 12:13
Update Civi in Worpress
#!/bin/bash
################################################
##
## Update CIVI plugin in Wordpress
##
## this script is called via
## $ ssh user@domain.ext 'bash -s -- sites/folder 5.41.0 SiteName' < civi-update.sh
##
################################################

Keybase proof

I hereby claim:

  • I am em-piguet on github.
  • I am empiguet (https://keybase.io/empiguet) on keybase.
  • I have a public key ASAPEZYVo58aN6f9tnXqg6SHBB-l2-NagjS7Pq1gwPkfqAo

To claim this, I am signing this object:

<?php
/**
* This is a muplugin
*
* Indexation des champs ACF "Auteurs" (relationnel) et "Année" (post_date) dans Elasticsearch index
* pour WPSOLR
*/
use wpsolr\core\classes\WPSOLR_Events;
@em-piguet
em-piguet / woocommerce_script_cleaner.php
Last active October 28, 2019 18:07
Manage WooCommerce styles and scripts
<?php
////////////////////////////////////////////
// Manage WooCommerce styles and scripts. //
////////////////////////////////////////////
function woocommerce_script_cleaner() {
// Remove the generator tag
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
// remove definitly, no need of this one
///////////////////////////////////////////////////
@em-piguet
em-piguet / add_tab_myaccount.php
Last active February 20, 2018 13:21
WOOCOMMERCE add page in my account
<?php
/**
* Ajoute un tab/endpoints dans la partie mon compte
* https://nicola.blog/2017/08/01/add-enquiry-form-my-account-woocommerce-contact-form-7/
*
*/
class WC_Custom_My_Account_Tabs extends WC_Query {
/**
* Adds main filters and actions and inits the endpoints.
@em-piguet
em-piguet / isdev.php
Last active February 8, 2017 17:38
Helper for dev in Wp
<?php
/*
* Returns true if we are working on a development server, determined by server's
* hostname. Will generate an error if run on an unknown host.
*/
function isdev()
{
$isdev = null;
// don't run function body more than once
@em-piguet
em-piguet / show_current_template.php
Last active February 8, 2017 17:39
Helper for dev in wordpress
<?php
function show_current_template($wp_admin_bar)
{
global $template;
$args = array(
'id' => 'current_template',
'title' => basename($template),
'meta' => array('title' => $template),
);
$wp_admin_bar->add_node($args);