This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 | |
function mytheme_responsive_preprocess_html(&$variables, $hook) { | |
$body_classes = array($variables['classes_array']); | |
// The body tag's classes are controlled by the $classes_array variable. To | |
// remove a class from $classes_array, use array_diff(). | |
//$variables['classes_array'] = array_diff($variables['classes_array'], array('class-to-remove')); | |
if ($variables['user']) { | |
foreach ($variables['user']->roles as $key => $role) { | |
$role_class = 'role-' . str_replace(' ', '-', $role); |
This file contains hidden or 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 | |
/** | |
* Implement hook_element_info_alter() | |
* Enable custom processing of a field in authoring form before it is rendered to the user | |
* | |
* @param array $elements | |
*/ | |
function my_module_element_info_alter(&$elements) { | |
array_unshift($elements['text_format']['#pre_render'], 'my_module_process_text_format'); | |
} |
This file contains hidden or 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 | |
THEME_preprocess_node(&$variables, $hook) { | |
if ($variables['submitted']) { | |
$variables['submitted'] = t('Posted by !username !datetime', array('!username' => $variables['name'], '!datetime' => format_date($variables['node']->created, 'custom', 'F j, Y'))); | |
} | |
} | |
?> |
This file contains hidden or 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
if(typeof(CKEDITOR) !== 'undefined') { | |
CKEDITOR.stylesSet.add( 'drupal', [ | |
// Block-level styles | |
{ name: 'Float Left', element: 'p', attributes: { 'class': 'left'} }, | |
{ name: 'Float Right' , element: 'p', attributes: { 'class': 'right'} }, | |
// Inline styles | |
{ name: 'Small Text', element: 'small' } | |
] ); |
This file contains hidden or 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 | |
function XXX_enter_title_here( $title ){ | |
$screen = get_current_screen(); | |
if ( 'custom_post_type' == $screen->post_type ) { | |
$title = 'Custom Post Type Title Text'; | |
} | |
return $title; | |
} |
NewerOlder