Skip to content

Instantly share code, notes, and snippets.

Avatar
🍜
Ramen and Code

Guido Scialfa widoz

🍜
Ramen and Code
View GitHub Profile
@widoz
widoz / svn-helpers.sh
Last active Apr 15, 2020
Svn Helpers
View svn-helpers.sh
# Svn helpers
# To Add
svn st | grep ^? | sed 's/? //' | xargs svn add
# To Delete
svn st | grep ^! | awk '{print " --force "$2}' | xargs svn delete
# Update dir only
svn up --depth=infinity <directory-name>
@widoz
widoz / wp-block-post-type-revealer-filter.php
Created Feb 29, 2020
Show the Wp Block post type in admin context
View wp-block-post-type-revealer-filter.php
<?php
/**
* Show the `wp_block` post type in admin context.
* Allow you to edit shared wp blocks comfortably from post edit screen.
*/
add_filter(
'register_post_type_args',
function (array $arguments, string $postTypeName) {
if ('wp_block' !== $postTypeName) {
return $arguments;
@widoz
widoz / wp-admin-notice-callback.php
Created Feb 29, 2020
Helper function to show a WordPress admin notice
View wp-admin-notice-callback.php
<?php
function adminNotice(string $message, string $noticeType, array $allowedMarkup = []): void
{
add_action('admin_notices', function () use ($message, $noticeType, $allowedMarkup) {
?>
<div class="notice notice-<?= sanitize_html_class($noticeType) ?>">
<p><?= wp_kses($message, $allowedMarkup) ?></p>
</div>
<?php
});
@widoz
widoz / insertArrayPos.php
Last active Oct 22, 2018
Array Functions
View insertArrayPos.php
<?php
function arrayInsertInPos(
$needle,
array &$haystack,
$pos,
$preserve = false,
$recursive = false
): array {
$keys = array_filter(
View Collection.php
<?php
/**
* Collection
*
* @author Guido Scialfa <dev@guidoscialfa.com>
* @copyright Copyright (c) 2017, Guido Scialfa
* @license GNU General Public License, version 2
*
* Copyright (C) 2017 Guido Scialfa <dev@guidoscialfa.com>
*
View material-icons-list.php
$list = array(
'material-icons-3d_rotation' => 'e84d',
'material-icons-ac_unit' => 'eb3b',
'material-icons-access_alarm' => 'e190',
'material-icons-access_alarms' => 'e191',
'material-icons-access_time' => 'e192',
'material-icons-accessibility' => 'e84e',
'material-icons-accessible' => 'e914',
'material-icons-account_balance' => 'e84f',
'material-icons-account_balance_wallet' => 'e850',
@widoz
widoz / WooCommerceTemplateOverrider.php
Last active Feb 29, 2020
WooCommerce Template Override
View WooCommerceTemplateOverrider.php
<?php
declare(strict_type=1);
/**
* WooCommerce Template Override
*
* @author Guido Scialfa <dev@guidoscialfa.com>
* @license MIT
*
@widoz
widoz / ClassList.js
Last active Jun 20, 2017
JS Polyfills
View ClassList.js
/**
* ClassList Polifyll
*
* @link https://developer.mozilla.org/en/docs/Web/API/Element/classList
* @link https://gist.github.com/k-gun/c2ea7c49edf7b757fe9561ba37cb19ca (Forked)
*/
function ClassList(e)
{
this.element = e
}
@widoz
widoz / reorder.php
Last active Jun 1, 2017
Form Functions
View reorder.php
<?php
/**
* Re Order Files
*
* @since ${SINCE}
* @access private
*
* @param array $list An array $_FILES like to re-order
*
* @return array The re-order array list
@widoz
widoz / wpPostByName.php
Last active Feb 29, 2020
Wp Post by Name
View wpPostByName.php
<?php
/**
* Get post by name
*
* @since 2.0.0
*
* @param string $name The name ( slug ) of the post to retrieve.
* @param string $post_type The post type. Optional. Default to 'post'.
*
* @return WP_Post The post object