Skip to content

Instantly share code, notes, and snippets.

View mariomelchor's full-sized avatar

Mario Melchor | Senior Web Developer mariomelchor

View GitHub Profile
@jo-snips
jo-snips / events-conditional-wrappers.php
Last active December 21, 2023 12:27
The Events Calendar: Basic Conditional Wrappers
<?php
/*-----------------------------------------------------------------------------------*/
/* Conditional Logic to Detect Various Event Related Views/Pages
/*-----------------------------------------------------------------------------------*/
if( tribe_is_month() && !is_tax() ) { // Month View Page
echo 'were on the month view page';
} elseif( tribe_is_month() && is_tax() ) { // Month View Category Page
@BFTrick
BFTrick / woothemes-features-replace-image.php
Last active April 22, 2019 09:52
A bit of PHP you can put in your functions.php to modify the default Features by WooThemes template.
<?php
/**
* Modify the default Features by WooThemes template
*/
function my_features_item_template( $tpl, $args ) {
$tpl = str_replace( '%%IMAGE%%', '<div class="feature-icon">
%%IMAGE%%
<div class="animation animation-1"></div>
<div class="animation animation-2"></div>
</div>', $tpl );
add_action('woothemes_features_item_template', 'woo_features_template_order');
function woo_features_template_order ( $tpl ) {
$tpl = '<div class="%%CLASS%%"><h3 class="feature-title">%%TITLE%%</h3><div class="feature-image">%%IMAGE%%</div><div class="feature-content">%%CONTENT%%</div></div>';
return $tpl;
}
@banago
banago / infinite-previous-next-looping.php
Last active March 28, 2024 11:31
Infinite next and previous post looping in WordPress
<?php
/**
* Infinite next and previous post looping in WordPress
*/
if( get_adjacent_post(false, '', true) ) {
previous_post_link('%link', '&larr; Previous Post');
} else {
$first = new WP_Query('posts_per_page=1&order=DESC'); $first->the_post();
echo '<a href="' . get_permalink() . '">&larr; Previous Post</a>';
wp_reset_query();
@toshimaru
toshimaru / jquery-scroll-bottom.js
Last active May 31, 2022 10:55
Detect the scrolling to bottom of the page using jQuery.
$(window).on("scroll", function() {
var scrollHeight = $(document).height();
var scrollPosition = $(window).height() + $(window).scrollTop();
if ((scrollHeight - scrollPosition) / scrollHeight === 0) {
// when scroll to bottom of the page
}
});
@zoerooney
zoerooney / no-li-nav-menu-v1.php
Last active February 3, 2020 08:49
Create an arguably cleaner nav menu in WordPress. Version 1 replacing the LI elements in a WordPress menu with SPAN elements, while maintaining classes, etc., while version 2 results in just A elements, still maintaining all the classes, etc. Post: http://zoerooney.com/blog/tutorials/removing-list-items-wordpress-menus/
<?php
// first let's get our nav menu using the regular wp_nav_menu() function with special parameters
$cleanmenu = wp_nav_menu( array(
'theme_location' => 'social', // we've registered a theme location in functions.php
'container' => false, // this is usually a div outside the menu ul, we don't need it
'items_wrap' => '<nav id="%1$s" class="%2$s">%3$s</nav>', // replacing the ul with nav
'echo' => false, // don't display it just yet
) );
@paulallies
paulallies / gist:0052fab554b14bbfa3ef
Last active November 12, 2023 23:00
Remove node_modules from git repo
#add 'node_modules' to .gitignore file
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin <branch-name>
@yoren
yoren / functions.php
Last active February 17, 2019 20:03
Return the right previous_post_link / next_post_link when change posts order
<?php
function my_previous_post_where() {
global $post, $wpdb;
return $wpdb->prepare( "WHERE p.menu_order < %s AND p.post_type = %s AND p.post_status = 'publish'", $post->menu_order, $post->post_type);
}
add_filter( 'get_previous_post_where', 'my_previous_post_where' );
@ericakfranz
ericakfranz / envira-hide-from-search-results.php
Created May 8, 2015 00:17
Exclude Envira Galleries from search results.
add_filter( 'envira_gallery_post_type_args', 'filter_envira_search' );
function filter_envira_search( $args ) {
$args['exclude_from_search'] = true;
return $args;
}
@claudiosanches
claudiosanches / functions.php
Last active June 4, 2022 07:52
WooCommerce - Add Order Again button to My Orders actions
<?php
/**
* Add order again button in my orders actions.
*
* @param array $actions
* @param WC_Order $order
* @return array
*/
function cs_add_order_again_to_my_orders_actions( $actions, $order ) {
if ( $order->has_status( 'completed' ) ) {