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 | |
// First we register the Google Recaptcha script as a dependency with an onload callback | |
wp_register_script( 'recaptcha_v2', add_query_arg(['render' => 'explicit', 'onload' => 'onloadRecaptchaCallback'], 'https://www.google.com/recaptcha/api.js'), [], null, true); | |
wp_enqueue_script( 'recaptcha_v2' ); | |
// Here we validate Google Recaptcha token issued on our frontend with Google servers using our custom 'validate_captcha' WP AJAX hook | |
function hh_validate_captcha() { | |
check_ajax_referer( 'hhsubscribe', '_ajax_nonce' ); |
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 | |
/* | |
Plugin Name: Activate Browsersync | |
Plugin URI: https://wordpress.org/plugins/trigger-browsersync/ | |
Description: Activates Browsersync. Doesn't do anything without <a href="https://wordpress.org/plugins/trigger-browsersync/">Trigger Browsersync</a> plugin. This plugin code should be only present in local environment. | |
Version: 0.0.1 | |
Author: Sami Greenbury | |
Author URI: https://www.patabugen.co.uk/ | |
*/ |
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
// A mixin that applies responsive spacing from a map | |
// Usage: @include u-set-spacing-style('page-spacing'); | |
@mixin u-set-spacing-style($group-name) { | |
$group: map-get($spacing, $group-name); | |
@each $property, $value in $group { | |
$is-breakpoint: variable-exists('breakpoints') and map-has-key($breakpoints, $property) and type-of($value) == 'map'; | |
@include u-set-breakpoint(if($is-breakpoint, $property, null)) { | |
@if ($is-breakpoint) { |
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
$colors-by-name: ( | |
dove-gray: #666666, | |
mine-shaft: #333333, | |
denim: #0f6bac, | |
niagara: #0fb3ac, | |
// ... | |
); | |
$colors-by-function: ( | |
buttons: ( |
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
// A mixin that allows to apply typographic styles from a map | |
// Supports applying a typographic style responsively, based on a map of media queries in a $breakpoints variable | |
@mixin u-set-typography($typeface-name: 'body', $style-name: 'regular') { | |
$this-typeface: map-get($font-styles, $typeface-name); | |
$this-style: map-get($this-typeface, $style-name); | |
@if $typeface-name == 'body' { | |
font-family: $font-body; | |
} |
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
@mixin c-component-a($base_class: &) { | |
// styling for the root tag | |
color:gray; | |
// styling for elements and modifiers | |
// it is contained within @at-root directive to lower specificity | |
@at-root { | |
#{$base}__element-a { | |
width:400px; |
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
// from ng-bootstrap. Is not publicly accessible starting from 3.0.0 unfortunately so we have to copy it (also is changed slighly) | |
export class Positioning { | |
private getAllStyles(element: HTMLElement) { return window.getComputedStyle(element); } | |
private getStyle(element: HTMLElement, prop: string): string { return this.getAllStyles(element)[prop]; } | |
private isStaticPositioned(element: HTMLElement): boolean { | |
return (this.getStyle(element, 'position') || 'static') === 'static'; | |
} |
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
// same as &, but applies the last (closest) parent only | |
// usage: @include u-direct-parent('.parent'<, ...>) {} | |
@mixin u-direct-parent($parent-selectors...) { | |
@each $parent-selector in $parent-selectors { | |
$current-sequences: &; | |
$new-sequences: (); | |
@each $sequence in $current-sequences { | |
$current-selector: nth($sequence, -1); | |
$prepended-selector: join($parent-selector, $current-selector); |
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 | |
// Retrieve a Gravity form by class (set in each form settings) 'js-overlay-form' | |
if ( class_exists( 'GFAPI' ) ) { | |
$forms = GFAPI::get_forms(); | |
$class_key = 'cssClass'; | |
$contactform_class = 'js-overlay-form'; | |
foreach ($forms as $form) { | |
if (array_key_exists($class_key, $form) && $form[$class_key] == $contactform_class) { | |
$contactform_id = $form['id']; | |
break; |
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 | |
// Remove current post from relationship fields which refer to the same post type | |
function remove_current_post_from_self_relationships($args, $field, $post_id) { | |
$args['post__not_in'] = array($post_id); | |
return $args; | |
} | |
$self_relationship_fields = array('relation_cases_cases'); | |
foreach ($self_relationship_fields as $key => $field_name) { |
NewerOlder