Skip to content

Instantly share code, notes, and snippets.

View Oliviercreativ's full-sized avatar

Démontant Oliviercreativ

View GitHub Profile
@zeshanshani
zeshanshani / events_start_end_date_WP_Query.php
Last active December 1, 2021 10:48
WP_Query 'meta_query' for "Date Start" and "Date End" custom fields. Conditions are (relation = 'OR'): 1. If "Date End" does not exist, compare "Date Start" only. 2. If "Date End" exists, show events in between that and "Date Start".
<?php
/**
* WP_Query 'meta_query' for "Date Start" and "Date End" custom fields.
* Conditions are (relation = 'OR'):
* 1. If "Date End" does not exist, compare "Date Start" only.
* 2. If "Date End" exists, show events in between that and "Date Start".
*/
'meta_query' => array(
@alexmustin
alexmustin / form-content.html
Created February 4, 2018 21:31
WordPress AJAX Live Search of Post Title
<!-- // The HTML (could be part of page content) // -->
<input type="text" name="keyword" id="keyword" onkeyup="fetch()"></input>
<div id="datafetch">Search results will appear here</div>
@alexwoollam
alexwoollam / function.php
Last active March 10, 2022 00:29 — forked from mattclements/function.php
Wordpress Disable Comments (add to function.php)
<?php
/**
* Disables comments, Add below to existing function.php file.
*/
/** Disable support for comments and trackbacks in post types. */
function df_disable_comments_post_types_support() {
$post_types = get_post_types();
foreach ( $post_types as $post_type ) {
if ( post_type_supports( $post_type, 'comments' ) ) {
@woogists
woogists / wc-auto-add-product-to-cart.php
Last active March 22, 2023 15:31
Automatically add product to cart on visit
/**
* Automatically add product to cart on visit
*/
add_action( 'template_redirect', 'add_product_to_cart' );
function add_product_to_cart() {
if ( ! is_admin() ) {
$product_id = 64; //replace with your own product id
$found = false;
//check if product already in cart
if ( sizeof( WC()->cart->get_cart() ) > 0 ) {
@karlhillx
karlhillx / macos_mojave_homebrew_apache_php_mariadb_2019.md
Last active February 21, 2024 09:51
macOS Mojave Setup: Homebrew + Apache + PHP + MariaDB (Regularly updated)

macOS Mojave Setup: Homebrew + Apache + PHP + MariaDB

This document provides help on getting your macOS development environment up and running with the latest versions of Homebrew, Apache, PHP, etc.

Homebrew Logo

Homebrew Installation

Homebrew is an excellent package manager for macOS; let's install it.

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
@yanknudtskov
yanknudtskov / functions.php
Last active June 20, 2023 19:30
WooCommerce Subscriptions check if the current user has an active subscription
<?php
function yanco_has_active_subscription( $user_id = '' ) {
if( function_exists( 'wcs_user_has_subscription' ) ) {
// When a $user_id is not specified, get the current user Id
if( '' == $user_id && is_user_logged_in() ) {
$user_id = get_current_user_id();
}
// User not logged in we return false
@Lysindr
Lysindr / collection.liquid
Last active September 29, 2023 14:59
Shopify AJAX filter collection page with TAGS
<div class="collection__main">
<!-- COLLECTION SIDEBAR -->
{%- capture categories -%}
{%- for tag in collections[collection.handle].tags -%}
{%- if tag contains 'categories' -%}
{%- assign tag_patterns = tag | split: '_' -%}
<li class="collection-sidebar__filter-item main-filter" data-tag="{{ tag | handle }}">{{ tag_patterns[1] }}</li>
{%- endif -%}
{%- endfor -%}
@iqbalrony
iqbalrony / wp-custom-reset-password-form.php
Last active March 6, 2024 16:09
WordPress custom reset password form
<?php
/*
*Example Follw:-https://code.tutsplus.com/tutorials/build-a-custom-wordpress-user-flow-part-3-password-reset--cms-23811
*/
// Create the custom pages at plugin activation
register_activation_hook( __FILE__, 'dgm_plugin_activated' );
function dgm_plugin_activated() {
// Information needed for creating the plugin's pages
$page_definitions = array(
@iqbalrony
iqbalrony / functions.php
Last active May 30, 2023 10:09
How to add/use/register elementor dynamic tag with elementor free version. This is a very easy and useful system of Elementor. Especially I feel the need for this when I use URL control. Help link -> (https://developers.elementor.com/dynamic-tags/)
<?php
/**
* Post URL list
*/
if (!function_exists('prefix_get_all_posts_url')) {
function prefix_get_all_posts_url($posttype = 'post') {
$args = array(
'post_type' => $posttype,
'post_status' => 'publish',
@wpchannel
wpchannel / mu-gravity-forms.php
Last active April 30, 2022 08:06
Best tweaks for Gravity Forms plugin for creating forms with WordPress. Enhance Bootstrap 4 compatibility and increase performances. More informations in this tutorial: https://wpchannel.com/wordpress/tutoriels-wordpress/astuces-optimiser-formulaires-gravity-forms
<?php if (!defined('ABSPATH')) die('Restricted Area');
/*
* Plugin Name: Gravity Forms Enhancements
* Description: Tweaks for Gravity Forms plugin.
* Version: 20191102
* Author: Aurélien Denis
* Author URI: https://wpchannel.com/
*/