Skip to content

Instantly share code, notes, and snippets.

View Oliviercreativ's full-sized avatar

Démontant Oliviercreativ

View GitHub Profile
@spivurno
spivurno / gw-gravity-forms-dynamic-select.php
Last active May 17, 2021 18:55
Gravity Wiz // Gravity Forms // Dynamic Select (for Categories, Taxonomies and more)
<?php
/**
* Gravity Wiz // Gravity Forms // Dynamic Category Select
*
* Allows the user to drill down from a top level category to a child category.
*
* @version 1.0
* @author David Smith <david@gravitywiz.com>
* @license GPL-2.0+
* @link http://gravitywiz.com/.../
@thewebprincess
thewebprincess / dateform.js
Last active May 15, 2023 19:33
Gravity Forms - Datepicker extension for Date Range Fields
jQuery(function ($) {
var datepickerInArgs = {
minDate: 1,
defaultDate: 0,
dateFormat: 'dd/mm/yy',
changeMonth: true,
changeYear: true,
onClose: function( dateText, inst ) {
var d = $.datepicker.parseDate( inst.settings.dateFormat, dateText );
@hyptx
hyptx / gf-image-validation.php
Last active September 8, 2023 01:23
Gravity Forms Image Validation
<?php
/* Gravity Forms Image Validation ~~~~> */
/* Add to functions.php and add a css class to the input, abp-image herein */
function ter_limit_profile_image_size($validation_result){
$form = $validation_result['form'];
foreach($form['fields'] as &$field){
if(strpos($field['cssClass'],'abp-image') === false ) continue;
$is_hidden = RGFormsModel::is_field_hidden($form, $field, array());
if($is_hidden) continue;
$input_name = 'input_' . $field['id'];
@omurphy27
omurphy27 / wp_query_woocommerce_product_category.php
Last active November 9, 2023 23:05
Wordpress WP_Query in WooCommerce for a Product Category aka Taxonomy which is ordered by a Custom Field
<?php
$args = array(
'posts_per_page' => 7,
'post_type' => 'product',
'product_cat' => 'home-featured',
'meta_key' => 'home_featured_order',
'orderby' => 'meta_value_num',
'order' => 'DESC'
);
@shizhua
shizhua / like-it-enqueue.php
Last active September 25, 2023 12:48
Add a like button without a plugin in WordPress
add_action( 'wp_enqueue_scripts', 'pt_like_it_scripts' );
function pt_like_it_scripts() {
if( is_single() ) {
wp_enqueue_style( 'like-it', trailingslashit( plugin_dir_url( __FILE__ ) ).'css/like-it.css' );
if (!wp_script_is( 'jquery', 'enqueued' )) {
wp_enqueue_script( 'jquery' );// Comment this line if you theme has already loaded jQuery
}
wp_enqueue_script( 'like-it', trailingslashit( plugin_dir_url( __FILE__ ) ).'js/like-it.js', array('jquery'), '1.0', true );
@mattclements
mattclements / function.php
Last active June 12, 2024 00:06
Wordpress Disable Comments (add to function.php)
<?php
add_action('admin_init', function () {
// Redirect any user trying to access comments page
global $pagenow;
if ($pagenow === 'edit-comments.php') {
wp_redirect(admin_url());
exit;
}
@azizultex
azizultex / WordPress Shortcode with ob_start()
Created March 3, 2016 03:16
WordPress Shortcode with ob_start()
function custom_query_shortcode($atts) {
// EXAMPLE USAGE:
// [loop the_query="showposts=100&post_type=page&post_parent=453"]
// Defaults
extract(shortcode_atts(array(
"the_query" => ''
), $atts));
@Oliviercreativ
Oliviercreativ / README.md
Last active March 25, 2018 08:03
Installez un Webserver, Git, WiringPi, NodeJS et les Librairies Python pour votre Raspberry Pi

Installez rapidement un Serveur Web, git, des librairies python, WiringPi, nodejs et Node-RED pour votre Raspberry Pi. Pratique et utile quand vous venez d'installer Raspbian.

@Pross
Pross / sendy.php
Created April 26, 2016 19:14
Add to mu-plugins folder, auto add every new user to a sendy list. Works with default WordPress and Woocommerce registrations.
<?php
add_action( 'user_register', 'add_user_to_sendy_list' );
function add_user_to_sendy_list( $user_id ) {
$list = 'SENDY_LIST_ID';
$url = 'http://SENDY_INSTALL_URL/subscribe';
$user = get_userdata( $user_id );
$email = $user->data->user_email;
$name = $user->data->user_nicename;
@adamrosloniec
adamrosloniec / gist:58467267db06603dca73ff222e4b2e50
Created September 7, 2016 08:35
Wordpress with ACF - add background color to category / categories
function add_blog_category_color(){
$categories = get_categories(array( 'hide_empty' => 0, ));
if ( ! empty( $categories ) ) {
echo '<style type="text/css">';
foreach( $categories as $category ) {
$category_taxonomy = $category->taxonomy;
$category_id = $category->term_id;
$category_slug = $category->slug;
$category_color = get_field('blog_category_color',$category_taxonomy . '_' . $category_id);