Skip to content

Instantly share code, notes, and snippets.

View nicomollet's full-sized avatar

Nico Mollet nicomollet

View GitHub Profile
@oranblackwell
oranblackwell / bootstrap-3-clearfix.md
Last active January 17, 2018 10:27
Auto clearfix for Bootstrap 3's cols. (From within a loop)

Auto-insert Bootstrap 3's clearfix for differnt viewport sizes.

<?php 
/**
 * Bootstrap auto clearfix from inside loops.
 * Put this function at the start of the loop before other bootstrap cols are called.
 *
 * @param       int   $i The count from within the loop where the function is called. Starting with 0.
 * @param       array $args ['xs'=> 12, 'sm' => 6, 'md' => 4, 'lg' => 3]
<?php
/**
* Includes a few useful predicates in the bootstrapped `infiniteScroll` JS object
* that is served along with the rest of the document upon initial page request.
*/
add_filter( 'infinite_scroll_js_settings', 'mcsf_extra_js_settings' );
function mcsf_extra_js_settings( $js_settings ) {
$js_settings['query_args']['extra'] = array(
'is_home' => is_home(),
@ronalfy
ronalfy / minit-jetpack-sharing.php
Last active May 31, 2016 13:20
Minit and Jetpack Sharing
<?php
/*
Place code in custom plugin
Get awesome minify plugin (Minit) by Kaspars D. - https://github.com/kasparsd/minit
to work with crazy, but often necessary, Jetpack Sharing - https://wordpress.org/plugins/jetpack/
Written by Ronald Huereca (@ronalfy). Powered by lack of Sleep(TM) and Vodka(R).
*/
@jubstuff
jubstuff / .htaccess
Last active August 29, 2015 14:08
wp-cli.yaml for single wordpress install
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
@ambroisemaupate
ambroisemaupate / security.conf
Last active July 22, 2025 15:18
Nginx CSP example
# config to don't allow the browser to render the page inside an frame or iframe
# and avoid clickjacking http://en.wikipedia.org/wiki/Clickjacking
# if you need to allow [i]frames, you can use SAMEORIGIN or even set an uri with ALLOW-FROM uri
# https://developer.mozilla.org/en-US/docs/HTTP/X-Frame-Options
add_header X-Frame-Options SAMEORIGIN;
# when serving user-supplied content, include a X-Content-Type-Options: nosniff header along with the Content-Type: header,
# to disable content-type sniffing on some browsers.
# https://www.owasp.org/index.php/List_of_useful_HTTP_headers
# currently suppoorted in IE > 8 http://blogs.msdn.com/b/ie/archive/2008/09/02/ie8-security-part-vi-beta-2-update.aspx
@jrnickell
jrnickell / create-project
Last active March 24, 2017 13:22
Nginx server config
#!/usr/bin/env bash
function create_index
{
cat <<- __EOF__
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>$PROJECT</title>
<?php
add_action( 'wp_enqueue_scripts', 'jt_enqueue_scripts' );
function jt_enqueue_scripts() {
wp_enqueue_script( 'wp-api' );
wp_enqueue_script( 'wp-util' );
}
add_action( 'wp_footer', 'jt_print_post_template', 25 );
@renchap
renchap / README.md
Last active February 14, 2025 13:25
One-line certificate generation/renews with Letsencrypt and nginx

Prerequisites : the letsencrypt CLI tool

This method allows your to generate and renew your Lets Encrypt certificates with 1 command. This is easily automatable to renew each 60 days, as advised.

You need nginx to answer on port 80 on all the domains you want a certificate for. Then you need to serve the challenge used by letsencrypt on /.well-known/acme-challenge. Then we invoke the letsencrypt command, telling the tool to write the challenge files in the directory we used as a root in the nginx configuration.

I redirect all HTTP requests on HTTPS, so my nginx config looks like :

server {
@herewithme
herewithme / wp-rocket-purge-all.php
Last active August 5, 2024 07:08
Purge all WP rocket cache when a post is modified/edited
<?php
/*
Plugin Name: Purge all WP Rocket cache
Plugin URI: http://www.beapi.fr
Description: Purge all WP rocket cache when a post is modified/edited
Version: 1.0
Author: BeAPI
Author URI: http://www.beapi.fr
Network: true
*/
@devinsays
devinsays / new-customer-coupon.php
Created January 4, 2016 04:56
Example for WooCommerce unit tests.
<?php
namespace WooCommerce\Tests\New_Customer_Coupon;
/**
* Class New_Customer_Coupon.
* @package WooCommerce\Tests\New_Customer_Coupon
*/
class New_Customer_Coupon extends \WC_Unit_Test_Case {