Skip to content

Instantly share code, notes, and snippets.

@tdmrhn
tdmrhn / blc_shortcode_offset_last_five.php
Last active October 18, 2021 15:48
Posts Shortcode Offset 5
<?php
add_filter('blocksy:general:shortcodes:blocksy-posts:args', function ($args) {
$args['offset'] = 5;
return $args;
} );
@tdmrhn
tdmrhn / blocksy-blog-archive-simple-two-columns.css
Created June 30, 2021 07:35
Blocksy Blog Archive Simple Type 2 Columns
@media (min-width: 1000px) {
.entries[data-layout="simple"] {
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-column-gap: var(--grid-columns-gap, 30px);
}
}
@tdmrhn
tdmrhn / blocksy-blog-archive-simple-disable-mobile.css
Last active April 3, 2023 14:05
Blocksy Blog Archive Simple Type Disable Mobile Responsive
@media (max-width: 690px) {
[data-layout="simple"] article { flex-direction: initial !important; }
[data-layout="simple"] article > .ct-image-container { margin-bottom: 0; margin-right: 0; max-width: 30%; }
[data-layout="simple"] article > .ct-image-container img { height: auto !important; }
}
@tdmrhn
tdmrhn / gutenberg-responsive-embed-support.php
Created July 1, 2021 15:59
Gutenberg Responsive Embed Support
<?php
add_action( 'after_setup_theme', function() {
add_theme_support( 'responsive-embeds' );
} );
@tdmrhn
tdmrhn / phpmailer_smtp.php
Last active August 4, 2022 11:37
PHPmailer SMTP function
<?php
add_action( 'phpmailer_init', function ( $phpmailer ) {
$phpmailer->isSMTP();
$phpmailer->IsHTML(true);
$phpmailer->Host = "smtp.suprd.com";
$phpmailer->Port = "465";
$phpmailer->Username = "[email protected]";
$phpmailer->Password = "xxx";
$phpmailer->SMTPAuth = true;
$phpmailer->SMTPSecure = "ssl";
@tdmrhn
tdmrhn / any-href-div-tabs.js
Created July 8, 2021 13:33
Simple jQuery Tabs Code Built for GB
jQuery(document).ready(function($) {
$(".tabcontents .content").hide();
$(".tabs a:first").addClass("active").show();
$(".tabcontents .content").hide().filter(":first").show();
$(".tabs a").click(function() {
$(".tabs > a").removeClass("active");
$(this).addClass("active");
$(".tabcontents .content").hide();
var activeTab = $(this).attr("href");
$(activeTab).show();
@tdmrhn
tdmrhn / blc-add-text-field-registration.php
Created July 13, 2021 15:12
Add Text Field to Modal Registration
<?php
add_action( 'register_form', 'blc_registration_form' );
function blc_registration_form() {
$year = ! empty( $_POST['year_of_birth'] ) ? intval( $_POST['year_of_birth'] ) : '';
?>
<p>
<label for="year_of_birth"><?php esc_html_e( 'Year of birth', 'blc' ) ?><br/>
<input type="number"
@tdmrhn
tdmrhn / add_description_to_product_card.php
Last active July 17, 2021 16:10
Add Description to Product Card
<?php
add_action('woocommerce_after_shop_loop_item_title', 'add_description_to_product_card', 3 );
function add_description_to_product_card() {
global $product;
$limit = 10;
$description = $product->get_description();
if (str_word_count($description, 0) > $limit) {
$words = str_word_count($description, 2);
$pos = array_keys($words);
$excerpt = substr($description, 0, $pos[$limit]) . '...';
@tdmrhn
tdmrhn / marge_decription_reviews_tabs.php
Created July 19, 2021 21:37
Marge Description & Review Tabs
<?php
add_filter( 'woocommerce_product_tabs', 'blc_marge_decription_reviews_tabs', 99 );
function blc_marge_decription_reviews_tabs( $tabs ) {
unset( $tabs['reviews'] );
$tabs['description']['callback'] = function() {
global $post, $product;
the_content();
echo '<h2>Reviews</h2>';
comments_template();
};
@tdmrhn
tdmrhn / woo-custom-thank-you-redirect.php
Created July 21, 2021 07:58
Woo Custom Thank You Redirect
<?php
add_action( 'template_redirect', 'woo_custom_redirect_after_purchase' );
function woo_custom_redirect_after_purchase() {
global $wp;
if ( is_checkout() && !empty( $wp->query_vars['order-received'] ) ) {
wp_redirect( '/custom-thank-you/' );
exit;
}
}