Skip to content

Instantly share code, notes, and snippets.

View pablo-sg-pacheco's full-sized avatar

Pablo dos Santos Gonçalves Pacheco pablo-sg-pacheco

View GitHub Profile
@omurphy27
omurphy27 / PHP Wordpress Removing Contact Form 7 Br tags when adding to template.html
Created March 15, 2013 00:27
PHP Wordpress Removing Contact Form 7 Br tags when adding to template
<!-- adding Contact Form 7 into Wordpress Template and removing <br> tags
add the following to the wordpress template -->
<?php echo do_shortcode('[contact-form-7 id="211" title="Spanish Contact Form"]') ; ?>
<!-- add the following into the wp-config.php -->
define ('WPCF7_AUTOP', false );
<!-- This will remove the <br> tags that get added automatically when you call Contact Form 7 from the template via shortcode-->
@BFTrick
BFTrick / woocommerce-settings-tab-demo.php
Last active March 26, 2024 10:48
A plugin demonstrating how to add a WooCommerce settings tab.
<?php
/**
* Plugin Name: WooCommerce Settings Tab Demo
* Plugin URI: https://gist.github.com/BFTrick/b5e3afa6f4f83ba2e54a
* Description: A plugin demonstrating how to add a WooCommerce settings tab.
* Author: Patrick Rauland
* Author URI: http://speakinginbytes.com/
* Version: 1.0
*
* This program is free software: you can redistribute it and/or modify
@leereamsnyder
leereamsnyder / wp_get_current_page_url.php
Last active March 26, 2024 15:59
In WordPress, get current URL including query string
<?php
/**
Re-use some existing WordPress functions so you don't have to write a bunch of raw PHP to check for SSL, port numbers, etc
Place in your functions.php (or re-use in a plugin)
If you absolutely don't need or want any query string, use home_url(add_query_arg(array(),$wp->request));
Hat tip to:
+ http://kovshenin.com/2012/current-url-in-wordpress/
@jnlsn
jnlsn / functions.php
Last active February 20, 2022 20:28
WP Query Orderby Taxonomy Term Name
add_filter('posts_clauses', 'posts_clauses_with_tax', 10, 2);
function posts_clauses_with_tax( $clauses, $wp_query ) {
global $wpdb;
//array of sortable taxonomies
$taxonomies = array('example-taxonomy', 'other-taxonomy');
if (isset($wp_query-&gt;query['orderby']) &amp;&amp; in_array($wp_query-&gt;query['orderby'], $taxonomies)) {
$clauses['join'] .= "
LEFT OUTER JOIN {$wpdb-&gt;term_relationships} AS rel2 ON {$wpdb-&gt;posts}.ID = rel2.object_id
LEFT OUTER JOIN {$wpdb-&gt;term_taxonomy} AS tax2 ON rel2.term_taxonomy_id = tax2.term_taxonomy_id
LEFT OUTER JOIN {$wpdb-&gt;terms} USING (term_id)
@TimBHowe
TimBHowe / functions.php
Created March 8, 2016 17:54
Forcibly remove the tax line item and calculation from the cart. (suggest just using the GEO setting in WooCommerce)
<?php
// Remove the Tax Line item from the cart.
function wc_remove_cart_tax_totals( $tax_totals, $instance ) {
if( is_cart() ) {
$tax_totals = array();
}
return $tax_totals;
}
@claudiosanches
claudiosanches / custom-my-account-endpoint.php
Last active November 6, 2023 20:10
Example of custom My Account endpoint.
<?php
class My_Custom_My_Account_Endpoint {
/**
* Custom endpoint name.
*
* @var string
*/
public static $endpoint = 'my-custom-endpoint';
@neilgee
neilgee / woo-endpoint-custom.php
Last active November 22, 2022 13:34
WooCommerce Endpoint Order and Rename - My Account Page v2.6+
<?php
/*
Plugin Name: WooCustom My Account
Plugin URI: http://wpbeaches.com/
Description: WooCustom - add a custom area in my-account
Author: Neil Gee
Version: 1.0.0
Author URI: http://wpbeaches.com
License: GPL-2.0+
@slushman
slushman / customizer-links.php
Last active September 23, 2023 13:03
How to link into the WordPress Customizer
@tripflex
tripflex / functions.php
Last active February 13, 2024 19:03
WordPress Remove Filter (remove_filter converted to remove_class_filter) to remove Filter/Action without Class Object access. Works with WordPress 1.2+ (4.7+ support added 9-19-2016)
<?php
/**
* Make sure the function does not exist before defining it
*/
if( ! function_exists( 'remove_class_filter' ) ){
/**
* Remove Class Filter Without Access to Class Object
*
* In order to use the core WordPress remove_filter() on a filter added with the callback
@rilwis
rilwis / admin-menu.php
Last active February 13, 2024 12:42
Move the admin menu for custom taxonomy in WordPress
<?php
add_action( 'admin_menu', 'prefix_move_taxonomy_menu' );
function prefix_move_taxonomy_menu() {
add_submenu_page( 'edit.php?post_type=quiz', esc_html__( 'Sections', 'mb-quiz' ), esc_html__( 'Sections', 'mb-quiz' ), 'manage_categories', 'edit-tags.php?taxonomy=question_section' );
}