Skip to content

Instantly share code, notes, and snippets.

@wlarch
wlarch / .php_cs.dist
Created Apr 28, 2021
.php_cs.dist (centiva-core)
View .php_cs.dist
<?php
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
$rules = [
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => [
'default' => 'single_space',
'operators' => ['=>' => 'align_single_space_minimal'],
View categories.php
<?php
require "StringHelper.php";
$helper = new StringHelper();
$categories = [];
$news = new stdClass();
$news->names = ["fr" => "Actualités", "en" => "News"];
$categories[] = $news;
View StringHelper.php
<?php
class StringHelper
{
/**
* Compare an associative multidimensionnal array by specific object value
*
* @param array &$array Reference of the array we want to sort
* @param string $element Element from which we want to order by specific key from
View mod_expires and mod_deflate for caching assets in .htaccess
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/vtt
AddOutputFilterByType DEFLATE text/x-component
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
@wlarch
wlarch / iframe.js
Last active Nov 22, 2020
Overwrite/bypass <iframe></iframe> height limit imposed by Wordpress
View iframe.js
/**
* Overwrite/bypass <iframe></iframe> height limit imposed by Wordpress
* Original idea from bypass-iframe-height-limit plugin by Justin Carboneau
* Adapted from original /wp-includes/js/wp-embed.js
*/
(function(window, document) {
'use strict';
var supportedBrowser = false;
@wlarch
wlarch / functions.php
Last active Apr 3, 2020
wordpress-iframe-1
View functions.php
add_action( 'wp_enqueue_scripts', 'child_theme_enqueue_scripts', PHP_INT_MAX);
function child_theme_enqueue_scripts() {
wp_enqueue_script('iframe-script', get_stylesheet_directory_uri() . '/js/iframe.js', ['jquery'], uniqid(), true);
}
@wlarch
wlarch / wp-embed.js
Created Mar 26, 2020
wordpress-iframe-1
View wp-embed.js
/* Resize the iframe on request. */
if ( 'height' === data.message ) {
height = parseInt( data.value, 10 );
if ( height > 1000 ) {
height = 1000;
} else if ( ~~height < 200 ) {
height = 200;
}