// [current_year] auto updates for footer
function current_year_shortcode() {
// Get the current year
$current_year = date('Y');
// Return the year inside a span
return '<span class="current-year">' . $current_year . '</span>';
}
add_shortcode('current_year', 'current_year_shortcode');
emily sparkle
masonry for wordpress gallery
remove default styles
galleryadd_filter( 'use_default_gallery_style', '__return_false' );masonry for wordpress gallery
css for basic masonry grid
.masonry-grid{margin:auto; column-count:3;column-gap:0;}
.masonry-grid img{max-width:100%;height:auto;border:none !important; padding: 1rem;}
.masonry-grid-item{margin:0;display:inline-block;width:100%;width:100%;margin-top:0;}
note column count
elementor flip card for masonry
enlarges elementor flip card background for masonry layouts.
(() => {
const elementorFlipBoxEls = document.querySelectorAll('.elementor-flip-box')
if (!elementorFlipBoxEls) {
return;
}
// match elementor flip card height setting
const outerHeight = 120;
elementorFlipBoxEls.forEach(flipBox => {
const imgEl = flipBox.querySelector('.elementor-flip-box__image img');
if (!imgEl) {
return;
}
flipBox.style.height = (imgEl.clientHeight + outerHeight) + 'px';
});
})();
gp control footer widths
.footer-widgets .footer-widget-1 {
flex-basis: 40%;
}
.footer-widgets .footer-widget-2 {
flex-basis: 20%;
}
.footer-widgets .footer-widget-3 {
flex-basis:30%;
}
.footer-widgets .footer-widget-4 {
flex-basis: 10%;
}
woo add to cart – display price in button with text according to category
add_filter( 'woocommerce_product_add_to_cart_text', 'custom_add_to_cart_price', 20, 2 ); // Shop and other archives pages
add_filter( 'woocommerce_product_single_add_to_cart_text', 'custom_add_to_cart_price', 20, 2 ); // Single product pages
function custom_add_to_cart_price( $button_text, $product ) {
// Check if the product belongs to a specific category (e.g., 'tickets' or 'camping')
$categories = array( 'tickets', 'camping' );
if ( has_term( $categories, 'product_cat', $product->get_id() ) ) {
$product_price = wc_price( wc_get_price_to_display( $product ) );
return strip_tags( $product_price ) . ' Per Person';
} elseif( $product->is_type('variable') ) {
// For variable products
if( ! is_product() ){
$product_price = wc_price( wc_get_price_to_display( $product, array( 'price' => $product->get_variation_price() ) ) );
return $button_text . ' - From ' . strip_tags( $product_price );
}
// Single product pages
else {
return $button_text;
}
} else {
// For all other product types
$product_price = wc_price( wc_get_price_to_display( $product ) );
return strip_tags( $product_price );
}
}
wp cli for hacked sites
rm -rf wp-admin
rm -rf wp-includes
wp core download --force --skip-content
wp core verify-checksums
wp plugin install $(wp plugin list --field=name) --force
wp theme install $(wp theme list --field=name) --force
(run wordfence scan)
wp user list --role=administrator
-remove spammy users
-verify default user role in General
-reset salts
woocommerce button color control
.woocommerce #content input.button.alt:hover, .woocommerce #respond input#submit.alt:hover, .woocommerce a.button.alt:hover, .woocommerce button.button.alt:hover, .woocommerce input.button.alt:hover, .woocommerce-page #content input.button.alt:hover, .woocommerce-page #respond input#submit.alt:hover, .woocommerce-page a.button.alt:hover, .woocommerce-page button.button.alt:hover, .woocommerce-page input.button.alt:hover {
background:#126b11;
background-color:#126b11;
color:white !important;
text-shadow: transparent !important;
box-shadow: none;
border-color:#126b11 !important;
}
.woocommerce #content input.button:hover, .woocommerce #respond input#submit:hover, .woocommerce a.button:hover, .woocommerce button.button:hover, .woocommerce input.button:hover, .woocommerce-page #content input.button:hover, .woocommerce-page #respond input#submit:hover, .woocommerce-page a.button:hover, .woocommerce-page button.button:hover, .woocommerce-page input.button:hover {
background:#126b11;
background-color:#126b11;
color:white !important;
text-shadow: transparent !important;
box-shadow: none;
border-color:#126b11 !important;
}
.woocommerce #content input.button, .woocommerce #respond input#submit, .woocommerce a.button, .woocommerce button.button, .woocommerce input.button, .woocommerce-page #content input.button, .woocommerce-page #respond input#submit, .woocommerce-page a.button, .woocommerce-page button.button, .woocommerce-page input.button {
background: #126b11 !important;
color:white !important;
text-shadow: transparent !important;
border-color:#126b11 !important;
}
.woocommerce #content input.button.alt:hover, .woocommerce #respond input#submit.alt:hover, .woocommerce a.button.alt:hover, .woocommerce button.button.alt:hover, .woocommerce input.button.alt:hover, .woocommerce-page #content input.button.alt:hover, .woocommerce-page #respond input#submit.alt:hover, .woocommerce-page a.button.alt:hover, .woocommerce-page button.button.alt:hover, .woocommerce-page input.button.alt:hover {
background: #126b11 !important;
box-shadow: none;
text-shadow: transparent !important;
color:white !important;
border-color:#126b11;
}
// GeneratePress Search Box Clear
add_filter( 'generate_navigation_search_output', 'tu_remove_search_query' );
function tu_remove_search_query() {
printf( // WPCS: XSS ok, sanitization ok.
'<form method="get" class="search-form navigation-search" action="%1$s">
<input type="search" class="search-field" value="" name="s" title="%2$s" />
</form>',
esc_url( home_url( '/' ) ),
esc_attr_x( 'Search', 'label', 'generatepress' )
);
}