Skip to content

Instantly share code, notes, and snippets.

View rumur's full-sized avatar
🏠
Working from home

rumur

🏠
Working from home
View GitHub Profile
@rumur
rumur / Arr.php
Created December 22, 2022 16:45
WordPress Array dot notation access.
<?php
/**
* Class Arr.
*/
class Arr {
/**
* Get an item from an array using `dot.key.notation`.
*
* @param array $array Target array.
@rumur
rumur / block.json
Created June 28, 2022 08:23
Block as Plugin Example
{
"$schema": "https://json.schemastore.org/block.json",
"apiVersion": 2,
"version": "1.0.0",
"title": "Core Query Block with Menu Order Extender.",
"name": "namespace/extensions",
"editorScript": "file:index.js"
}
@rumur
rumur / EP_Email.php
Last active June 3, 2019 11:18
WordPress wp_mail() Wrapping Class
<?php
class EP_Email
{
/** @var string Where to sent to */
protected $to;
/** @var string Where to sent to as a hidden copy */
protected $cc;
@rumur
rumur / README.md
Last active April 9, 2019 13:37
WordPress Custom HTTP Endpoints

How to Use

1. Register Routes that you want to use

/**
 * Registers Custom HTTP routes.
 *
 * @author rumur
@rumur
rumur / class-part-factory.php
Last active March 22, 2019 11:38
Helper class that works the same as a WP function `get_template_part`, but allows pass variables to that template.
<?php
class Part_Factory
{
protected $tpl;
protected $name;
protected $data = [];
/**
* Part_Factory constructor.
@rumur
rumur / .gitconfig
Created December 20, 2018 11:12
Use PHPStorm/WebStorm for git diff and merge tools
# ~/.gitconfig
# Add this to your global git configuration file
# Change pstorm to wstorm, if you use that.
# Diff and merge tool changes
# Run `git difftool <directory/file>...` or `git mergetool <directory/file>...`
[diff]
tool = pstorm
[difftool]
prompt = false
@rumur
rumur / mailcatcher.md
Last active September 16, 2020 18:21
Install the mailcatcher on macOS Mohave 10.14.2 without `sudo`

Install the mailcatcher on macOS Mohave 10.14.2 without sudo

1. Open the terminal or iTerm2

2. Run the command and wait for a while

$ gem install --user-install mailcatcher

3. Add Gem's bin directory to your path, open your ~/.zshrc or ~/.bash_profile with your editor

@rumur
rumur / admin-actions.php
Last active February 2, 2019 19:48
Update WordPress taxonomies(categories/tags) count field
<?php
/**
* Adds the button to the Category Screen and allows to reindex the Terms post count.
*
* @since v1.0 - 15.06.2018
*
* @author rumur
*/
add_action('current_screen', function($current_screen) {
<?php
/**
* Compiles html attributes for the entity.
*
* Example:
* $attributes = [
* 'id' => 'content',
* 'data-number' => 23,
* 'class' => [ 'container', 'maina-page' ],
* 'style' => [
@rumur
rumur / class-rum-admin-notice.php
Last active November 15, 2016 15:04
WordPress Admin Notice Wrapper
<?php
/**
* Class RUM_Admin_Notice
*
* Created by Rumur.
*
* @usage RUM_Admin_Notice::get_instance()->add_error( 'Error' );
* @usage RUM_Admin_Notice::get_instance()->add_warning( 'Warning' );
* @usage RUM_Admin_Notice::get_instance()->add_info( 'Info' );
* @usage RUM_Admin_Notice::get_instance()->add_success( 'Success' );