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 / 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
*/
@crewstyle
crewstyle / functions.php
Created April 20, 2016 08:30
WordPress ~ Remove dashboard menus to editor role - #backend #security
<?php
/**
* Remove dashboard menus to editor role.
*
* @uses current_user_can() To know if current user has permissions.
* @uses remove_menu_page() To remove a menu page.
* @uses remove_submenu_page() To remove a submenu page.
* @see https://github.com/crewstyle/clean-wordpress
*/
@crewstyle
crewstyle / functions.php
Created April 20, 2016 08:27
WordPress ~ Clean admin bar - #backend #optimisation
<?php
/**
* Remove menu items from WordPress admin bar.
*
* @uses remove_menu() To remove specific menu.
* @see https://github.com/crewstyle/clean-wordpress
*/
add_action('wp_before_admin_bar_render', '_cw_remove_bar_icons');
function _cw_remove_bar_icons()