This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ "rules_notif_order_status_update_in_progress_or_completed" : { | |
"LABEL" : "Notification on order status update to \u0022in progress\u0022 or \u0022completed\u0022", | |
"PLUGIN" : "reaction rule", | |
"TAGS" : [ "Custom" ], | |
"REQUIRES" : [ "rules", "rules_i18n", "mimemail", "entity" ], | |
"ON" : [ "commerce_order_update" ], | |
"IF" : [ | |
{ "data_is" : { | |
"data" : [ "commerce-order:status" ], | |
"op" : "IN", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Converts numbers in string from western to eastern Arabic numerals. | |
* | |
* @param string $str Arbitrary text | |
* @return string Text with western Arabic numerals converted into eastern Arabic numerals. | |
*/ | |
function arabic_w2e($str) { | |
$arabic_eastern = array('٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Replace the last occurence of a string, useful if you want to replace the last comma with " and"... | |
* | |
* @param str needle The string to search | |
* @param str replacement The replacement string | |
* @param str str The subject | |
* @return str The new string | |
*/ | |
function str_replace_last(needle, replacement, str) { | |
var needle_index = str.lastIndexOf(needle); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function array_to_real_text (arr) { | |
txt = arr.join(", " ); | |
return txt = str_replace_last(', ', ' and ', txt); | |
} | |
function str_replace_last(needle, replacement, str) { | |
var needle_index = str.lastIndexOf(needle); | |
if (needle_index < 0) { | |
return str; | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add JavaScript code to the head section | |
* | |
* Add a custom field with the name "js" and this plugin will | |
* add it content to the head section of the page/post wrapped | |
* correctly inside <script> tags. | |
*/ | |
add_action('wp_head', 'per_post_head_js'); | |
function per_post_head_js() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* toggleAttr() jQuery Plugin | |
* | |
* Toggle checked, selected, disabled, checked, readonly, multiple, etc… | |
*/ | |
jQuery.fn.toggleAttr = function (attr) { | |
return this.each(function () { | |
var $this = $(this); | |
if ($this.attr(attr)) { | |
$this.removeAttr(attr); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var t = 200; // The interval at which new change ares detected | |
jQuery( document ).ready( function() { | |
// Detect remote change | |
$( 'input, textarea' ).each( function() { | |
var $this = $( this ); | |
$this.data( 'value', $this.val() ); | |
setInterval( function() { | |
if( $this.val() !== $this.data( 'value' ) ) { | |
// Do not trigger if element does not have focus |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @author Nabil Kadimi (nabil * at * kadimi * com) | |
* @link http://jsfiddle.net/nabil_kadimi/ftx9196o/ | |
*/ | |
function isURL( url ) { | |
var pattern = new RegExp('^(https?:\\/\\/)?' // protocol | |
+ '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' // domain name | |
+ '((\\d{1,3}\\.){3}\\d{1,3}))' // OR ip (v4) address | |
+ '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' // port and path | |
+ '(\\?[;&a-z\\d%_.~+=-]*)?' // query string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Calculate the difference in hue, saturation and lightness between two colors | |
* | |
* The function requires tinycolor (https://github.com/bgrins/TinyColor) | |
* Example: http://jsfiddle.net/nabil_kadimi/a9cqqth0/2/ | |
* | |
* @param {String} s Source color in hexadecimal | |
* @param {String} d Destination color in hexadecimal | |
* @return {Array} Array of differences [hue, saturtion, lightness] | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?pphp | |
/** | |
* Check if a number is a prime number | |
* @param int $n The number. | |
* @retun boolean True if $n is a prime number, false otherwise. | |
*/ | |
function is_prime_number($n) { | |
$is_prime = true; | |
$max_count = ceil($n/2); | |
for($i=2; $i<$max_count; $i++) { |
OlderNewer