Skip to content

Instantly share code, notes, and snippets.

View luiseduardobraschi's full-sized avatar
🤓
Updating knowledgebase...

Luis Braschi luiseduardobraschi

🤓
Updating knowledgebase...
View GitHub Profile
@yaph
yaph / phpmyadmin file name template
Created March 8, 2011 15:40
File name template for phpMyAdmin with today's date and database name
%Y_%m_%d___DB__
@windyjonas
windyjonas / wordpress-escaping.md
Last active September 21, 2020 16:10
Most of the escaping functions in WordPress, with a short explanation and example.

WordPress escaping functions

By: Jonas Nordström, @windyjonas
Date: 2013-04-16

esc_attr( $text );
Encodes the <, >, &, " and ' (less than, greater than, ampersand, double quote and single quote) characters. Will never double encode entities.
Example:

@sepehr
sepehr / in_arrayi.php
Created August 27, 2013 09:12
PHP: Case-insensitive in_array()
<?php
/**
* Case-insensitive in_array() wrapper.
*
* @param mixed $needle Value to seek.
* @param array $haystack Array to seek in.
*
* @return bool
*/
@maxrice
maxrice / gist:7918315
Created December 11, 2013 20:55
Get SKU from products in an order
<?php
$order = new WC_Order( $order_id );
foreach ( $order->get_items() as $item_key => $item ) {
$product = $order->get_product_from_item( $item );
$sku = $product->get_sku();
@jplhomer
jplhomer / disable-comments.sh
Created February 25, 2015 16:38
Disable all comments/pings in WordPress with WP-CLI
$ wp post list --format=ids | xargs wp post update --comment_status=closed
# Output:
# Success: Updated post 2514.
# Success: Updated post 2511.
# Success: Updated post 2504.
# Success: Updated post 2499.
# Success: Updated post 2441.
# etc...
@salcode
salcode / .gitignore
Last active July 10, 2024 14:28
Please see https://salferrarello.com/wordpress-gitignore/ for the canonical version of this WordPress .gitignore file. Note: I do not receive notifications for comments here (because GitHub does not send notifications on Gists)
# -----------------------------------------------------------------
# .gitignore for WordPress @salcode
# ver 20180808
#
# From the root of your project run
# curl -O https://gist.githubusercontent.com/salcode/b515f520d3f8207ecd04/raw/.gitignore
# to download this file
#
# By default all files are ignored. You'll need to whitelist
# any mu-plugins, plugins, or themes you want to include in the repo.
@babeuloula
babeuloula / in_arrayi.php
Last active April 5, 2018 21:24 — forked from sepehr/in_arrayi.php
PHP: Case-insensitive in_array()
<?php
/**
* Case-insensitive in_array() wrapper.
*
* @param mixed $needle Value to seek.
* @param array $haystack Array to seek in.
* @param bool $strict If the third parameter strict is set to TRUE then the in_array() function will also check the types of the needle in the haystack.
*
* @return bool
@LeonardoCardoso
LeonardoCardoso / gitzip.sh
Last active October 9, 2023 22:38
Zip folder ignoring files listed on .gitignore
#...
function gitzip() {
git archive -o [email protected] HEAD
}
#... gitzip ZIPPED_FILE_NAME
@luiseduardobraschi
luiseduardobraschi / changing-form-fields-after-user-log-in.php
Last active August 25, 2017 06:05
Since WordPress uses difrerent templates for both logged and not logged-in users, I ended up having to use some other hooks other than the default filter.
<?php
function alter_comment_form_fields($fields){
$commenter = wp_get_current_commenter();
$fields['author'] = '<p class="comment-form-input comment-form-author"><label for="author">' . __( 'This is a fancy label', 'your-text-domain' ) . '</label><input id="author" required name="author" type="text" placeholder="Seu nome" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" aria-required="true" /></p>';
return $fields;
}
@ahmadawais
ahmadawais / .zshrc
Created April 24, 2016 19:52
WP CLI Plugin & Theme Install/Activate Aliases for ZSH/BASH
# WP Plugin: Install & Acticate
# Usage: wpp plugin-slug
alias wpp="wp plugin install $* --activate"
# WP Theme: Install
# Usage: wpt plugin-slug
alias wpt="wp theme install $* --activate"
# WP Theme: Activate
# Usage: wpta plugin-slug