Skip to content

Instantly share code, notes, and snippets.

View crewstyle's full-sized avatar
💭
Good mood! Wanna try new tools for WordPress

Achraf Chouk crewstyle

💭
Good mood! Wanna try new tools for WordPress
View GitHub Profile
@crewstyle
crewstyle / functions.php
Last active January 10, 2020 18:29
WordPress ~ Remove unnecessary details in body_class function - #frontend #security #optimisation
<?php
/**
* Remove unnecessary details from `body_class()`
*
* @param string $classes
* @param string $class
*
* @uses get_query_var()
* @uses get_user_by()
@crewstyle
crewstyle / shortcode.js
Created May 15, 2019 08:22
WordPress ~ Add shortcode button with title, list and image contents - #frontend #shortcode
/*!
* SHORTCODE
*
* Plugin Name: Shortcode
* Version: 1.0.0
* Description: Add shortcode button with title, list and image contents.
*
* Author: Achraf Chouk
* Author URI: https://github.com/crewstyle
* License: The MIT License (MIT)
@crewstyle
crewstyle / functions.php
Last active March 9, 2019 12:56
WordPress ~ Close database connections - #security #optimisation
<?php
/**
* Close database connections
*
* It's very dangerous to let connections opened. In a website
* with high traffic volume, you can kill your database just
* because of unclosed DB connections.
* This little snippet prevent that drama ;)
*
@crewstyle
crewstyle / functions.php
Last active September 30, 2018 07:00
WordPress ~ Clean head HTML tag - #frontend #optimisation
<?php
/**
* Define what to clean from the theme header frontend, via the "remove_action" hook.
*
* @see https://github.com/GetOlympus/Zeus-Core
*/
$optims = [
'adjacent_posts_rel', // Removes the next and previous post links from the header
@crewstyle
crewstyle / list.html.twig
Created January 29, 2018 16:05 — forked from garak/list.html.twig
Twig recursive macro
{% macro recursiveCategory(category) %}
{% import _self as self %}
<li>
<h4><a href="{{ path(category.route, category.routeParams) }}">{{ category }}</a></h4>
{% if category.children|length %}
<ul>
{% for child in category.children %}
{{ self.recursiveCategory(child) }}
{% endfor %}
@crewstyle
crewstyle / urls-create-sheet-ota.gs
Created April 1, 2017 21:37
Google Spreadsheet - How to create sheet on the air, using SpreadsheetApp and Utilities class services
/**
* This script has been especially made for a particular context.
* So use it with caution, and do not forget to customize it before any use.
*/
//globals
var sheet = SpreadsheetApp.getActiveSpreadsheet(),
sheets = sheet.getSheets();
/**
@crewstyle
crewstyle / urls-headers-cache-fetch.gs
Last active March 30, 2017 22:58
Google Spreadsheet - How to get data from URL's headers, using CacheService and UrlFetchApp class services
/**
* This script has been especially made for a particular context.
* So use it with caution, and do not forget to customize it before any use.
*/
//globals
var sheet = SpreadsheetApp.getActiveSpreadsheet(),
sheets = sheet.getSheets();
/**
@crewstyle
crewstyle / find-parameter-clientid-from-ga.js
Created February 15, 2017 10:03
How to get a parameter's value from URL and set a client ID into GA tracker, to retrieve it later
/**
* Retrieve parameter from URL
*/
function findParameter(param) {
var result = 0, tmp = [], BreakException = {};
// Iterate on all and breaks when param is found
// @see http://stackoverflow.com/a/2641374
try {
location.search
@crewstyle
crewstyle / wp-update.sh
Last active April 20, 2016 08:57
WordPress updater bash script on remote server - #optimisation #bash #remote
#!/bin/bash
####################################################################
# WordPress updater script
#
# This script has been made to update WordPress sites quickly
# and works on remote server.
#
# It works with this simple command line:
# /path/to/wp-update.sh folder_name user:group
@crewstyle
crewstyle / functions.php
Created April 20, 2016 08:33
WordPress ~ WP version check for admin role only - #backend #security
<?php
/**
* Sets up WP version check for admin role only.
*
* @uses current_user_can() To know if current user has permissions.
* @uses add_action() To add a hook action.
* @uses add_filter() To add a hook filter.
* @see https://github.com/crewstyle/clean-wordpress
*/