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 formattedString($string) { | |
return str_replace([''', '"'], "'", filter_var($string, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH)); | |
} |
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
.grid-tiles { | |
width: 100%; | |
display: grid; | |
// grid-template-columns: repeat(4, 1fr); // <- it doesn't wrap elements | |
grid-template-columns: repeat(4, minmax(calc(#{percentage(1/4)} - #{pxToRem(16)}), 1fr)); // <- it wrap! | |
grid-column-gap: pxToRem(16); | |
grid-row-gap: pxToRem(16); | |
} |
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
# How to fix error - gyp: No Xcode or CLT version detected! | |
# source: https://stackoverflow.com/questions/60573595/npm-install-fails-on-node-gyp-rebuild-with-gyp-no-xcode-or-clt-version-detec | |
# 1. | |
xcode-select --print-path | |
# in my case /Library/Developer/CommandLineTools | |
# 2. | |
# the next line deletes the path returned by the command above | |
sudo rm -rf $(xcode-select --print-path) |
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 addRelPreloadTagToEnqueueStyles($html, $handle) { | |
// Put to array all styles which you want to add tag rel="preload" | |
$styles = ['app', 'wp-block-library', 'contact-form-7', 'cf7cf-style']; | |
foreach ($styles as $singleStyle) { | |
$html = preg_replace("/id='" . $singleStyle . "-css'/", " id='" . $singleStyle . "-css' rel='preload' as='style' ", $html); | |
} | |
return $html; | |
} | |
add_filter('style_loader_tag', 'addRelPreloadTagToEnqueueStyles'); |
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
// Source: https://stackoverflow.com/a/10173268 | |
function get_the_excerpt_with_characters_limit($text, $length) { | |
// Don't cut if too short | |
if (strlen($text) < $length + 10) { | |
return $text; | |
} | |
// Find next space after desired length | |
$break_pos = strpos($text, ' ', $length); | |
$visible = substr($text, 0, $break_pos); |
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
useEffect(() => { | |
// componentDidMount | |
InitAnyFunctionAfterDidMount(); | |
// componentWillUnmount | |
return () => { | |
InitAnyFunctionAfterUnmount(); | |
}; | |
}, []); |
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 convertState(state) { | |
const states = { | |
'new-south-wales': 'NSW', | |
'queensland': 'QLD', | |
'south-australia': 'SA', | |
'western-australia': 'WA', | |
'northern-territory': 'NT', | |
'victoria': 'VIC', | |
'tasmania': 'TAS', | |
'australian-capital-territory': 'ACT', |
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 | |
function hide_login_page_and_show_only_rest_api_endpoints() { | |
// work only on productions sites | |
if ( | |
!stristr($_SERVER['SERVER_NAME'], 'local') | |
&& !is_user_logged_in() | |
) { | |
if ( | |
( |
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 theme_disallow_indexing_for_staging() { | |
if ( | |
str_ireplace(array('staging-subdomain-1.com', 'dev-subdomain-2.net'), '', $_SERVER['SERVER_NAME']) != $_SERVER['SERVER_NAME'] | |
&& get_option('blog_public') == '1' | |
) { | |
add_action('pre_option_blog_public', '__return_zero'); | |
} | |
} | |
add_action('init', 'theme_disallow_indexing_for_staging'); |
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
get_posts(array( | |
'posts_per_page' => -1, | |
'post_parent' => 0, | |
'post_type' => 'sanctuary', // post type slug | |
'tax_query' => array( | |
array( | |
'taxonomy' => 'territory', // taxonomy slug | |
'operator' => 'EXISTS' | |
), | |
), |
NewerOlder