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
const $element = $('#my-element'); | |
const $nodes = $element.contents(); | |
$nodes.each(function(index, element) { | |
const $el = $(element); | |
if(element.nodeType === 3 && $.trim($el.text())) { | |
$el.wrap('<span class="orphan" />'); | |
} | |
}); |
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 | |
// Define helper functions | |
/** | |
* Changes default WordPress headers to a custom ones | |
*/ | |
function change_cors_headers() { | |
remove_filter( 'rest_pre_serve_request', 'rest_send_cors_headers' ); | |
add_filter( 'rest_pre_serve_request', 'send_cors_headers' ); | |
} |
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
# Handy script to help move images created with a phone camera into date-based folders | |
# Accepts files in the format yyyymmddhhjjss.* | |
# creates subdirectories yyyy-mm-dd | |
# moves files into subdirectories renames them to yyyy-mm-dd-hh-jj-ss.* (extension is preserved) | |
# Tested against Bash v3.2.57, the expressions are overly verbose as the compact expressions | |
# do not produce the same results, in this environment | |
if [[ $(ls | grep -E "[0-9]{8}_.*") ]]; then | |
for name in [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_*.*; do | |
echo "$name" | |
new_dir=$(echo $name | sed -e 's/\([0-9][0-9][0-9][0-9]\)\([0-9][0-9]\)\([0-9][0-9]\)_\(.*\)/\1-\2-\3/g') |
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
/* | |
1. create custom user fields with wordpress (see https://gist.github.com/makbeta/5851535 ) | |
2. clone `register-form.php` from /wp-content/plugins/theme-my-login/templates to your theme | |
3. Add your new field to the registration template | |
*/ | |
<p> | |
<label for="subscription">Customer ID</label> | |
<input type="text" name="subscription" id="subscription<?php $template->the_instance(); ?>" class="input" value="<?php $template->the_posted_value( 'subscription' ); ?>" size="20" /><br /> | |
<span class="description">Please enter your customer ID.</span> |
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 | |
/** | |
* Quick script for stripping drupal hard set version number in .info.yml files that cause | |
* Drupal to incorrectly show status updates. | |
* Script is based on https://gist.github.com/joshkoenig/2588420 | |
* | |
* Run in the drupal root, or specify the root as an argument. E.g.: | |
* | |
* php d8-strip-version-from-info-yml.php path/to/drupal | |
* |
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
let countryCodeTopLevelDomains=[ | |
{ | |
"code": ".ac", | |
"country": "Ascension Island" | |
}, | |
{ | |
"code": ".ad", | |
"country": "Andorra" | |
}, | |
{ |
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
class="[[T9: | |
[[?x[[S4]]x::x41x::ecards::]] | |
[[?x[[S4]]x::x81x::profile::]] | |
[[?x[[S4]]x::x82x::interests::]] | |
[[?x[[S4]]x::x83x::unsubscribe::]] | |
[[?x[[S4]]x::x85x::preferences::]] | |
[[?x[[S4]]x::x5x::tell-a-friend::]] | |
[[?x[[S4]]x::x186x::service-center::]] | |
[[?x[[S4]]x::x10x::user-login [[?x[[S334:CMD]]x::xForgotPasswordx::password-recovery ::]][[?x[[S334:CMD]]x::xForgotLoginx::user-name-recovery ::]]::]] |
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 my_show_extra_profile_fields( $user ) { ?> | |
<div class="subscription-info"> | |
<h3>Subscription Information</h3> | |
<table class="form-table"> | |
<tr> | |
<th><label for="subscription">Customer ID</label></th> | |
<td> | |
<input type="text" name="subscription" id="subscription" value="<?php echo esc_attr( get_user_meta( $user->ID, 'subscription', 1) ); ?>" class="regular-text" /><br /> | |
<span class="description">Please enter your customer ID.</span> |
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
<t:if test="length > 0"><!-- is there a list? --> | |
<t:set id="iRandom" value="random(length)+1" /><!-- set a variable equal to a number between 1 and the length of the list --> | |
<!-- if random number is within 2 of the last item in the list, subtract 2 --> | |
<t:if test="iRandom >= (length-2) && iRandom <= length"> | |
<t:set id="iRandom" value="iRandom-2" /> | |
</t:if> | |
<!-- if the variable is now negative due to the subtraction above, reset it to 1 (the first list item) --> | |
<t:if test="iRandom <= 0"> |
NewerOlder