Skip to content

Instantly share code, notes, and snippets.

@ptesei
ptesei / searchwp-customizations.php
Created February 8, 2021 15:58
Search WP Add child PDF snippets to SearchWP result excerpt .
//Add child PDF snippets to SearchWP result excerpt .
add_filter(
'get_the_excerpt',
function ( $excerpt ) {
global $post;
if ( ! $post instanceof WP_Post || ! is_search() || post_password_required() || $post->searchwp_excerpt_found ) {
return $excerpt;
}
@ptesei
ptesei / mosne_carousel.html
Created February 21, 2021 20:52
Mosne Accessible Carousel : CSS scroll-snap + IntersectionObserver
@ptesei
ptesei / template-example.php
Created March 12, 2021 11:02
Tribe Event Calendar pro load a v2 template / switch view example
use Tribe\Events\Pro\Views\V2\Views\Photo_View;
use Tribe\Events\Views\V2\Template;
$view = new Photo_View();
$template = new Template( $view );
$v2_event = tribe_get_event( $event );
$template->template( 'photo/event', [ 'event' => $v2_event ] );
@ptesei
ptesei / arduino-d1-mini-mhz19b.ino
Last active April 11, 2021 21:13
Arduino Co2 detector MH-Z19b connected to Blynk via ESP8266
#define BLYNK_PRINT Serial
#include <SoftwareSerial.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <MHZ19PWM.h>
MHZ19PWM mhz(D5, MHZ_DELAYED_MODE);
char auth[] = "dM-aERE2i1ZZd-aauogHCQXcGloNdNSi";
char ssid[] = "Mosne_2G";
@ptesei
ptesei / gist:5cd3cfddf2b503ac4e9e654c6d6aadcc
Created November 5, 2021 16:28
diable searchwp in rest
// Don't use SearchWP for search query
add_filter( 'posts_pre_query', function( $posts, $query ) {
$query->set( 'searchwp', false );
$query->set( 'using_searchwp', false );
return $posts;
}, 5, 2);
@ptesei
ptesei / gist:f4cdc3101943022d3c7db0969a2c479d
Created December 3, 2021 23:15
stylelint-config-recess-order for phpstorm
all
position
top
right
bottom
left
z-index
box-sizing
display
flex
@ptesei
ptesei / gist:6924167b815c230ac907d31cfe1974d9
Created December 4, 2021 10:03
.editorconfig phpstorm
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
max_line_length = 120
tab_width = 4
trim_trailing_whitespace = true
ij_continuation_indent_size = 8
@ptesei
ptesei / karabiner.json
Last active April 6, 2022 20:12
Easy à-é-ì-ò-ù-ç-€ using Capslock from US layout to FR/IT - for Karabiner-Elements
{
"global": {
"check_for_updates_on_startup": true,
"show_in_menu_bar": true,
"show_profile_name_in_menu_bar": false
},
"profiles": [
{
"complex_modifications": {
"parameters": {
@ptesei
ptesei / example-innerblocks-patterns.php
Created May 17, 2022 07:07
example innerblocks patterns
add_action('acf/init', 'my_acf_init_blocks');
function my_acf_init_blocks() {
// Check function exists.
if( function_exists('acf_register_block_type') ) {
// Register a restricted block.
acf_register_block_type(array(
'name' => 'restricted',
@ptesei
ptesei / inner-example-template.php
Created May 17, 2022 07:13
inner-example-template.php
<?php
/**
* Restricted Block Template.
*
* @param array $block The block settings and attributes.
* @param string $content The block inner HTML (empty).
* @param bool $is_preview True during AJAX preview.
* @param (int|string) $post_id The post ID this block is saved to.
*/