Skip to content

Instantly share code, notes, and snippets.

View dexit's full-sized avatar
🎯
Focusing

Rihards Mantejs dexit

🎯
Focusing
View GitHub Profile
<?php
add_filter( 'gform_form_post_get_meta', __NAMESPACE__ . '\\enforce_gravity_forms_anti_spam_honeypot' );
/**
* Enforce anti-spam honeypot on all Gravity forms.
*
* @param array $form The current form to be filtered.
*
* @return array
*/
<script>
(function( $ ) {
$( '.et_pb_toggle' ).hover(function() {
$( this ).children( 'h5' ).trigger( 'click' );
});
})( jQuery );
</script>
@dexit
dexit / shortcode_post_object.php
Created December 1, 2020 11:55 — forked from phucdohong96/shortcode_post_object.php
Shortcode Sample ACF Post Object & ACF Repeater
<?php
function shortcode_post_object_function() {
ob_start();
$count = 0;
//Get field
$post_objects = get_field ('post_objects');
if (!empty($post_objects)) {
foreach ($post_objects as $post_object) {
$id = $post_object->ID;
@dexit
dexit / woo-check-if-has-shipping-class.php
Created December 2, 2020 17:18 — forked from easaw/woo-check-if-has-shipping-class.php
Check if the Woocommerce cart has product with a certain Shipping Class
/**
* From https://isabelcastillo.com/woocommerce-check-shipping-class
* Check if the cart has product with a certain Shipping Class
* @param string $slug the shipping class slug to check for
* @return bool true if a product with the Shipping Class is found in cart
*/
function cart_has_product_with_shipping_class( $slug ) {
global $woocommerce;
@dexit
dexit / wp-config.php
Created December 2, 2020 17:19 — forked from easaw/wp-config.php
All those damned wp-config constants you can never remember.
<?php
// PHP memory limit for this site
define( 'WP_MEMORY_LIMIT', '128M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M' ); // Increase admin-side memory limit.
// Database
define( 'WP_ALLOW_REPAIR', true ); // Allow WordPress to automatically repair your database.
define( 'DO_NOT_UPGRADE_GLOBAL_TABLES', true ); // Don't make database upgrades on global tables (like users)
// Explicitely setting url
@dexit
dexit / wp-config.php
Created December 2, 2020 17:20 — forked from MikeNGarrett/wp-config.php
Disable admin-ajax on the front-end of WordPress sites and cache the resulting 404.
<?php
if(
strpos( $_SERVER['HTTP_REFERER'], 'wp-admin' ) === false &&
strpos( $_SERVER['REQUEST_URI'], 'admin-ajax.php' ) !== false
) {
header( 'Cache-Control: max-age=30000, must-revalidate' );
header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', strtotime( '+5000 minutes' ) ) . ' GMT' );
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s', strtotime( '-5000 minutes' ) ) . ' GMT' );
header( $_SERVER["SERVER_PROTOCOL"]." 404 Not Found" );
die;
@dexit
dexit / Function.php
Created December 2, 2020 21:34 — forked from phucdohong96/Function.php
Get ID from previous page
<?php
function get_featured_image_func() {
$postid = url_to_postid( $_SERVER['HTTP_REFERER'] );
$image = get_field('featured_image', $postid);
$image = '<img src="'.$image["url"].'" />';
return $image;
}
add_shortcode( 'get_featured_image_shortcode', 'get_featured_image_func' );
@dexit
dexit / wc-rename-tabs.php
Created February 1, 2021 14:30 — forked from woogists/wc-rename-tabs.php
[Frontend Snippets][Editing product data tabs] Renaming product data tabs
/**
* Rename product data tabs
*/
add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 );
function woo_rename_tabs( $tabs ) {
$tabs['description']['title'] = __( 'More Information' ); // Rename the description tab
$tabs['reviews']['title'] = __( 'Ratings' ); // Rename the reviews tab
$tabs['additional_information']['title'] = __( 'Product Data' ); // Rename the additional information tab
@dexit
dexit / wc-reorder-tabs.php
Created February 1, 2021 14:30 — forked from woogists/wc-reorder-tabs.php
[Frontend Snippets][Editing product data tabs] Reordering product data tabs
/**
* Reorder product data tabs
*/
add_filter( 'woocommerce_product_tabs', 'woo_reorder_tabs', 98 );
function woo_reorder_tabs( $tabs ) {
$tabs['reviews']['priority'] = 5; // Reviews first
$tabs['description']['priority'] = 10; // Description second
$tabs['additional_information']['priority'] = 15; // Additional information third
@dexit
dexit / wc-custom-tab.php
Created February 1, 2021 14:30 — forked from woogists/wc-custom-tab.php
[Frontend Snippets][Editing product data tabs] Customize a tab
/**
* Customize product data tabs
*/
add_filter( 'woocommerce_product_tabs', 'woo_custom_description_tab', 98 );
function woo_custom_description_tab( $tabs ) {
$tabs['description']['callback'] = 'woo_custom_description_tab_content'; // Custom description callback
return $tabs;
}