Skip to content

Instantly share code, notes, and snippets.

View mtx-z's full-sized avatar

Mtx Z mtx-z

View GitHub Profile
@mtx-z
mtx-z / wp-bootstrap4.4-pagination.php
Last active April 4, 2023 12:55
Wordpress 5.4 Bootstrap 4.4 pagination (with custom WP_Query() and global $wp_query support) (UPDATED for Bootstrap 5: https://gist.github.com/mtx-z/af85d3abd4c19a84a9713e69956e1507)
<?php
/**
* @param WP_Query|null $wp_query
* @param bool $echo
* @param array $params
*
* @return string|null
*
* UPDATE for Bootstrap 5.0: https://gist.github.com/mtx-z/af85d3abd4c19a84a9713e69956e1507
*
Download Google Drive files with WGET
- replace FILEID with your Google Drive FILEID
- Google Drive file must have a public shared URL (file share options)
- will create a /tmp/cookies.txt to save cookies, and handle Google Drive "Big files" download verification
wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=FILEID' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=FILEID" -O FILENAME && rm -rf /tmp/cookies.txt
@mtx-z
mtx-z / wordpress-acf-term-meta.php
Created May 27, 2018 17:24
WordPress\ACF - set real term_meta on ACF terms custom fields on update/create
<?php
/**
* ACF fix for term meta
* replace {{custom_term_meta_x}} by your ACF term custom field name
* TODO: loop over all term_meta to auto-generate filters
*
* https://support.advancedcustomfields.com/forums/topic/how-to-use-wp-term-meta-on-acf-the-easy-way/
*/
function acf_update_term_meta( $value, $post_id, $field ) {
@mtx-z
mtx-z / wordpress-remove-author-page.php
Last active August 21, 2019 14:19
Wordpress/Woocommerce- redirect (remove) author pages
<?php
/**
* Disable access to Wordpress author page
*/
function remove_author_pages_page() {
global $wp_query;
if ( is_author() ) {
$wp_query->set_404();
@mtx-z
mtx-z / wordpres-various-removers.php
Created May 27, 2018 17:27
WordPress - various removers
<?php
/**
* Various removers
* todo: all may not be still needed/usefull/correct
*/
/**
* @param $headers
*
@mtx-z
mtx-z / acf-json-sage9.php
Created June 2, 2018 10:30
ACF-json with Roots Sage 9 - get_stylesheet_directory() point to theresources/ folder. From local JSON ACF documentation.
/**
* ACF save json folder
*/
add_filter( 'acf/settings/save_json', 'my_acf_json_save_point' );
function my_acf_json_save_point( $path ) {
return get_stylesheet_directory() . '/acf-json-custom-folder';
}
/**
@mtx-z
mtx-z / [nginx] laravel remove index.php from url
Last active February 11, 2021 19:43 — forked from slow-is-fast/laravel remove index.php from url.md
[nginx] laravel remove index.php from url
# Remove index.php$
if ($request_uri ~* "^(.*/)index\.php$") {
return 301 $1;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
# Remove from everywhere index.php
if ($request_uri ~* "^(.*/)index\.php(/?)(.*)") {
@mtx-z
mtx-z / wp-woocommerce-edit-product-loop-thumbnail-template.php
Last active February 22, 2024 08:47
Woocommerce (3.8.1-6.2.2) edit product loop thumbnail template (allows to had/edit HTML outputted by Woocommerce to generate the product loop thumbnail image area, as there is no dedicated template file to override) - Wordpress / WooCommerce 3.8.1-6.2.2
<?php
/**
* Edit default Woocommerce product loop thumbnail template
* As there is no dedicated Woocommerce template (eg wp-content/plugins/woocommerce/templates/loop/price.php)
* because it's generated using filter, we must remove Woocommerce hook, and add our own "at the same place"
* to edit the product loop thumbnail template
* tested up to
* 14/07/2023 :
* Woocommerce 6.2.2
* 12/10/2020 :
@mtx-z
mtx-z / wp5.3-boostrap4.4-collapse-navwalker.php
Last active August 12, 2021 16:48
Wordpress 5.3 NavWalker with Bootstrap 4.4 collapse with correct parent ".collapsed" class and ".active" classes (custom Wordpress nav walker class + example)
<?php
/**
* Class Name: Bootstrap_Collapse_NavWalker
* GitHub URI: https://gist.github.com/mtx-z/db34d68364108c0285e6e3e721630846
* Description: A custom WordPress 5.3 nav walker class for Bootstrap 4.4 nav menus in a custom theme using the WordPress built in menu manager
* Version: 0.1
* Author: Mtxz
* Source: https://github.com/filipszczepanski/wp-bootstrap4-collapse-navwalker
* Tested only with 1 sublevel, but should work with as many level as you want
@mtx-z
mtx-z / wp-woocommerce-checkout-form-bootstrap4.4.php
Created December 11, 2019 11:16
Add bootstrap 4.4 styling to Woocommerce checkout shipping and billing form
<?php
/**
* Edit checkout form inputs
* source: https://gist.github.com/nickkuijpers/5d07ecf9b0a0678b4f4c
*/
add_filter('woocommerce_checkout_fields', 'addBootstrapToCheckoutFields' );
/**
* @param $fields
* @return mixed
*/