Skip to content

Instantly share code, notes, and snippets.

View ediamin's full-sized avatar
:octocat:
Exploring

Edi Amin ediamin

:octocat:
Exploring
View GitHub Profile
@ediamin
ediamin / erp-extra-country-states.php
Last active March 5, 2017 08:41
How to add more country states in WP ERP
<?php
// use `erp_states` filter hook to add country states
add_filter( 'erp_states', function ( $states ) {
$states['NL'] = [
'DR' => 'Drenthe',
'FL' => 'Flevoland',
'FR' => 'Fryslân (fy)',
'GE' => 'Gelderland',
'GR' => 'Groningen',
@ediamin
ediamin / wpautop.js
Created February 27, 2017 09:49
JavaScript version of WordPress wpautop function
// source: https://github.com/andymantell/node-wpautop
function _autop_newline_preservation_helper (matches) {
return matches[0].replace( "\n", "<WPPreserveNewline />" );
},
function wpautop(pee, br) {
if(typeof(br) === 'undefined') {
br = true;
}
@ediamin
ediamin / hooks.php
Created January 21, 2017 04:49
Hooks for saving WP ERP - CRM `photo_id` meta
<?php
/**
* $people_id = contact or company id
* meta data saved in 'PREFIX_erp_peoplemeta' table
* for hook documentation see `update_metadata` function located in `wp-includes/meta.php` WordPress core file
*/
add_filter( 'update_erp_people_metadata', function ( $check, $people_id, $meta_key, $meta_value, $prev_value ) {
if ( 'photo_id' === $meta_key ) {
@ediamin
ediamin / timezone.js
Created December 7, 2016 08:53
WordPress - Moment Timezone times
// required moment-timezone-with-data.js
String.prototype.toLocalTime = function() {
return moment(moment.tz(this, 'YYYY-MM-DD HH:mm:ss', wpTimezone))
.tz(moment.tz.guess())
.format('YYYY-MM-DD HH:mm:ss');
};
String.prototype.toWPTime = function() {
return moment(this, 'YYYY-MM-DD HH:mm:ss').tz(wpTimezone).format('YYYY-MM-DD HH:mm:ss');
};
@ediamin
ediamin / wordpress-colorized-button.less
Last active November 7, 2016 05:39
WordPress Colorized Button
.button-colorized(@baseColor) {
background: @baseColor;
border-color: darken(@baseColor, 5%) darken(@baseColor, 9%) darken(@baseColor, 9%);
-webkit-box-shadow: 0 1px 0 darken(@baseColor, 9%);
box-shadow: 0 1px 0 darken(@baseColor, 9%);
color: #fff;
text-decoration: none;
text-shadow: 0 -1px 1px darken(@baseColor, 9%), 1px 0 1px darken(@baseColor, 9%), 0 1px 1px darken(@baseColor, 9%), -1px 0 1px darken(@baseColor, 9%);
&.hover,
@ediamin
ediamin / colormeter.js
Created September 30, 2016 12:08 — forked from mailtruck/colormeter.js
Calculate difference in percentage between 2 hex colors
function color_meter(cwith, ccolor) {
if (!cwith && !ccolor) return;
var _cwith = (cwith.charAt(0)=="#") ? cwith.substring(1,7) : cwith;
var _ccolor = (ccolor.charAt(0)=="#") ? ccolor.substring(1,7) : ccolor;
var _r = parseInt(_cwith.substring(0,2), 16);
var _g = parseInt(_cwith.substring(2,4), 16);
var _b = parseInt(_cwith.substring(4,6), 16);
@ediamin
ediamin / keymap.cson
Created September 16, 2016 17:47
Atom - Custom Keymap
# Your keymap
#
# Atom keymaps work similarly to style sheets. Just as style sheets use
# selectors to apply styles to elements, Atom keymaps use selectors to associate
# keystrokes with events in specific contexts. Unlike style sheets however,
# each selector can only be declared once.
#
# You can create a new keybinding in this file by typing "key" and then hitting
# tab.
#
@ediamin
ediamin / snippets.cson
Last active September 13, 2016 16:22
Atom - Custom snippets
# Your snippets
#
# Atom snippets allow you to enter a simple prefix in the editor and hit tab to
# expand the prefix into a larger code block with templated values.
#
# You can create a new snippet in this file by typing "snip" and then hitting
# tab.
#
# An example CoffeeScript snippet to expand log to console.log:
#
@ediamin
ediamin / Sublime Text 3 Build 3103 License Key - CRACK
Created August 26, 2016 19:02
Sublime Text 3 Build 3103 License Key - CRACK
I use the first
—– BEGIN LICENSE —–
Michael Barnes
Single User License
EA7E-821385
8A353C41 872A0D5C DF9B2950 AFF6F667
C458EA6D 8EA3C286 98D1D650 131A97AB
AA919AEC EF20E143 B361B1E7 4C8B7F04
@ediamin
ediamin / wp-erp-extends.php
Created June 26, 2016 17:00
WP ERP - HRM: Custom employee types
<?php
/**
* Plugin Name: WP ERP Extends
* Description: Custom filters and hooks for WP ERP
*/
add_filter( 'erp_hr_employee_types', 'erp_hr_employee_types_custom_types' );
function erp_hr_employee_types_custom_types( $default_types ) {
$custom_types = [
'custom_type_1' => 'Custom Type 1',