Skip to content

Instantly share code, notes, and snippets.

@juliquiron
juliquiron / class-plugin-disabler.php
Created November 22, 2019 13:15
Disable plugins in specific URLs in Wordpress
<?php
/**
* Plugin disabler for specific URLs
*
* @package Timeular
* @author Julià Mestieri
* @version 0.1.0
* @license https://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License version 2 (GPLv2)
*/
@juliquiron
juliquiron / bash
Created August 28, 2019 08:03
Compiling vim with python3 support
./configure --with-python3-config-dir=/usr/lib/python3.8/config-3.8m-x86_64-linux-gnu/ --enable-python3interp --enable-fail-if-missing --without-x --with-python3-command=python3.8
make
sudo make install
@juliquiron
juliquiron / config.json
Last active August 12, 2019 13:58
BackstopJS configuration sample for WordPress
{
"id": "wordpress_visual_regression",
"viewports": [
{
"label": "mobile",
"width": 360,
"height": 480
}
{
"label": "tablet",
@juliquiron
juliquiron / fix-inline-woocommerce-js.php
Created August 2, 2019 11:57
Deferring WooCommerce inlined scripts
/**
* Minify to base64 URL and defer WooCommerce script.
*
* @param string $js The JS being rendered.
*/
function yournamespace_woocommerce_queued_js( string $js ) : string {
// Cleanup and get JS inside the wrapper <script> tag.
$remove_comments_regex = '/(?:(?:\/\*(?:[^*]|(?:\*+[^*\/]))*\*+\/)|(?:(?<!\:|\\\|\')\/\/.*))/';
$js = preg_replace( $remove_comments_regex, '', $js );
$js = str_replace( PHP_EOL, ' ', $js );
@juliquiron
juliquiron / gist:b5c287a1a1d2593d9373
Created February 9, 2016 16:35
Default dummy image for Drupal 7 tutorial #6
/**
* Implements hook_field_create_instance().
*/
function MY_DEPLOY_MODULE_field_create_instance($field) {
if($field['field_name'] == 'field_imagen') {
$source = drupal_get_path('module', 'MY_DEPLOY_MODULE') . '/dummy.jpg';
$file = new stdClass;
$file­>filename = 'dummy.jpg';
$file­>timestamp = REQUEST_TIME;
$file­>uri = $source;
@juliquiron
juliquiron / gist:6740ce32aab86a0a03bf
Created February 9, 2016 16:33
Default dummy image for Drupal 7 tutorial #5
field_update_field($field);
@juliquiron
juliquiron / gist:2c27b611d5265e8f21bc
Created February 9, 2016 16:32
Default dummy image for Drupal 7 tutorial #4
$field = field_info_field("field_imagen");
$field['settings']['default_image'] = $fid;
@juliquiron
juliquiron / gist:b94c1489bc51e92724bf
Created February 9, 2016 16:32
Default dummy image for Drupal 7 tutorial #3
$file = file_copy($file, 'public://default.jpg', FILE_EXISTS_REPLACE);
$fid = $file­>fid;
@juliquiron
juliquiron / gist:95d4b11647eab51164e9
Created February 9, 2016 16:32
Default dummy image for Drupal 7 tutorial #2
$file = new stdClass;
$file­>filename = 'dummy.jpg';
$file­>timestamp = REQUEST_TIME;
$file­>uri = $source;
$file­>filemime = file_get_mimetype($source);
$file­>uid = 1;
$file­>status = 1;
@juliquiron
juliquiron / gist:36902c675316beeebebf
Created February 9, 2016 16:31
Default dummy image for Drupal 7 tutorial #1
$source = drupal_get_path('module', 'MY_DEPLOY_MODULE') . '/dummy.jpg';