Skip to content

Instantly share code, notes, and snippets.

@brynzovskii
brynzovskii / woo-events.js
Created Mar 29, 2022 — forked from bagerathan/woo-events.js
[Woocommerce Javascript events] #woo
View woo-events.js
//Woocommerce Checkout JS events
$( document.body ).trigger( 'init_checkout' );
$( document.body ).trigger( 'payment_method_selected' );
$( document.body ).trigger( 'update_checkout' );
$( document.body ).trigger( 'updated_checkout' );
$( document.body ).trigger( 'checkout_error' );
//Woocommerce cart page JS events
$( document.body ).trigger( 'wc_cart_emptied' );
$( document.body ).trigger( 'update_checkout' );
@brynzovskii
brynzovskii / redirect-wp-post.php
Created Jan 30, 2020 — forked from Bobz-zg/redirect-wp-post.php
Redirects wordpress posts to new url: site.com/blog/post-name
View redirect-wp-post.php
<?php
/**
* Add new rewrite rule
*/
function create_new_url_querystring() {
add_rewrite_rule(
'blog/([^/]*)$',
'index.php?name=$matches[1]',
'top'
);
View gist:0a44d203c586516bc7f02ed6b4c853f0
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
@brynzovskii
brynzovskii / flexbox.scss
Created Jul 8, 2018 — forked from richardtorres314/flexbox.scss
CSS Flexbox - Sass Mixins
View flexbox.scss
// --------------------------------------------------
// Flexbox SASS mixins
// The spec: http://www.w3.org/TR/css3-flexbox
// --------------------------------------------------
// Flexbox display
@mixin flexbox() {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
View WordPress get tags
<?php
$tags = get_tags();
if ($tags) {
foreach ($tags as $tag) {
echo '<p>Tag: <a href="' . get_tag_link( $tag->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $tag->name ) . '" ' . '>' . $tag->name.'</a> </p> ';
}
}
?>
<?php
$tags = wp_get_post_tags($post->ID);
@brynzovskii
brynzovskii / get-ip-address-optimized.php
Created May 1, 2018 — forked from cballou/get-ip-address-optimized.php
PHP - Advanced Method to Retrieve Client IP Address
View get-ip-address-optimized.php
<?php
function get_ip_address() {
$ip_keys = array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR');
foreach ($ip_keys as $key) {
if (array_key_exists($key, $_SERVER) === true) {
foreach (explode(',', $_SERVER[$key]) as $ip) {
// trim for safety measures
$ip = trim($ip);
// attempt to validate IP
if (validate_ip($ip)) {
@brynzovskii
brynzovskii / youtube_id_regex.php
Created Jan 30, 2018 — forked from ghalusa/youtube_id_regex.php
Extract the YouTube Video ID from a URL in PHP
View youtube_id_regex.php
<?php
// Here is a sample of the URLs this regex matches: (there can be more content after the given URL that will be ignored)
// http://youtu.be/dQw4w9WgXcQ
// http://www.youtube.com/embed/dQw4w9WgXcQ
// http://www.youtube.com/watch?v=dQw4w9WgXcQ
// http://www.youtube.com/?v=dQw4w9WgXcQ
// http://www.youtube.com/v/dQw4w9WgXcQ
// http://www.youtube.com/e/dQw4w9WgXcQ
// http://www.youtube.com/user/username#p/u/11/dQw4w9WgXcQ
@brynzovskii
brynzovskii / loop-custom.php
Created Jan 21, 2018 — forked from kevinwhoffman/loop-custom.php
WordPress - Custom Post Type Loop
View loop-custom.php
<?php
$loop = new WP_Query( array(
'post_type' => 'Property',
'posts_per_page' => -1
)
);
?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
@brynzovskii
brynzovskii / brand.php
Created Jan 20, 2018 — forked from smutek/brand.php
Filter WordPress Custom Logo
View brand.php
<?php
/**
* Site Brand
*
* Output site branding
*
* Use native WordPress site logo with custom (bootstrap friendly) markup
* Falls back to text title if logo is not set.
*
* @param $html
@brynzovskii
brynzovskii / yoast
Created Dec 18, 2017 — forked from aderaaij/yoast
Wordpress - Move yoast seo boxes to bottom of post/page
View yoast
// Move Yoast to bottom
function yoasttobottom() {
return 'low';
}
add_filter( 'wpseo_metabox_prio', 'yoasttobottom');