Skip to content

Instantly share code, notes, and snippets.

View gagimilicevic's full-sized avatar

Milicevic Dragan gagimilicevic

View GitHub Profile
@bryceadams
bryceadams / gist:db6c8669e9e99cb2808c
Last active October 9, 2023 13:55
Clear WooCommerce Cart (when not cart/checkout)
/**
* Clears WC Cart on Page Load
* (Only when not on cart/checkout page)
*/
add_action( 'wp_head', 'bryce_clear_cart' );
function bryce_clear_cart() {
if ( wc_get_page_id( 'cart' ) == get_the_ID() || wc_get_page_id( 'checkout' ) == get_the_ID() ) {
return;
}
@nikola0203
nikola0203 / repeater-loop-even-number.php
Last active March 6, 2018 11:45
Repeater field ACF count in while loop even and odd number and display in different order.
<?php
if( have_rows('repeater_field') ):
$postCount = 1;
while( have_rows('repeater_field') ) : the_row(); ?>
<?php
$repeater_sub_field_1 = get_sub_field('repeater_sub_field_1');
$repeater_sub_field_2 = get_sub_field('repeater_sub_field_2');
$repeater_sub_field_3 = get_sub_field('repeater_sub_field_3');
@nikola0203
nikola0203 / functions.php
Created July 13, 2017 08:23 — forked from gagimilicevic/functions.php
Detect RTL on website
function wp_is_rtl( $locale = '' ) {
static $rtl_locales = array(
'ar' => 'Arabic',
'ary' => 'Moroccan Arabic',
'azb' => 'South Azerbaijani',
'fa_IR' => 'Persian',
'haz' => 'Hazaragi',
'he_IL' => 'Hebrew',
'ps' => 'Pashto',
'ug_CN' => 'Uighur',
@nikola0203
nikola0203 / ajax.js
Created October 7, 2017 10:31
Wordpress, AJAX call, Bootsrap modal popup. AJAX function to retrieve, WooCommerce single product page, through the Bootstrap modal popup.
jQuery(document).ready(function($){
// Quick view ajax function on products page
$('.quick-view-link, .quick-view-button').on('click', function() {
var post_id = $(this).data('id');
$.ajax({
url : modal_ajax.url,
type : 'post',
data : {
@nikola0203
nikola0203 / archive.php
Created October 20, 2017 18:58
Dynamic category filter
<?php $category = get_the_category(); ?>
<div class="col-md-6 filter <?php echo esc_attr( $category[0]->slug ); ?>">
// Content
</div>
@nikola0203
nikola0203 / wc_functions.php
Last active March 6, 2018 11:45
WooCommerce Customer/Order XML Export Suite - change root element of XML document.
// Change first letter of XML tag <Orders> to lowercase.
function custom_xml_root_element( $export_type ) {
return lcfirst( $export_type );
}
add_filter( 'wc_customer_order_xml_export_suite_xml_root_element', 'custom_xml_root_element', 10, 1 );
// Change <Order> tage name.
function custom_order_format_tag_name( $orders_format, $orders ) {
$orders_format = array(
'order' => $orders,