Skip to content

Instantly share code, notes, and snippets.

View mingodev's full-sized avatar

Simon Domingue mingodev

  • Cook It
  • Montréal, QC, Canada
View GitHub Profile
@mingodev
mingodev / gist:c6df9b1a4ea0b1450d33f33aa7046f35
Created July 15, 2019 15:48
Get menu items from Wordpress DB
SELECT
p.ID,
m.meta_value,
md.post_author,
wp_users.user_nicename,
p.post_parent,
p.menu_order,
md.post_title
FROM
wp_posts AS p
<div class="row">
<div class="col-lg-12">
<form action="https://forms.octantis.ca/index.php" method="post" id="form">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<input class="form-control" id="firstname" name="firstname" type="text" placeholder="First Name *" data-required="true">
<p class="help-block text-danger"></p>
</div>
<div class="form-group">
@mingodev
mingodev / CSV report
Created August 23, 2019 14:22
Créer un rapport CSV vite fait
<?php
// output headers so that the file is downloaded rather than displayed
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=rapport.csv');
ob_start();
$dbHostName = '';
$dbDatabase = '';
$dbUsername = '';
$dbPassword = '';
#Force https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L,NE]
@mingodev
mingodev / gist:8496f799be421610455f47016c12e81e
Created October 7, 2019 18:07
Add category count to category menu items in Wordpress.
// Short code pour le nombre d'items dans une catégorie
add_shortcode('categoryCount', 'nbProductsCategoryShortcode');
function nbProductsCategoryShortcode ($attributes = []) {
global $wpdb;
$attributes = shortcode_atts([
'category' => null,
], $attributes);
$category = $attributes['category'];
@mingodev
mingodev / calendar-fix.js
Created December 18, 2019 16:58
Add start date to end date minimum in date input (Contact Form 7)
var medieval = medieval || {};
var start; var end;
medieval.calendarFix = function ($) {
"use strict";
let initialize = function () {
start = jQuery('input.date-start').first();
@mingodev
mingodev / functions.php
Created January 3, 2020 22:03
Hard-coded custom traductions in WP (for when WPML isn't enough)
<?php
// Custom translations
add_action('wp_enqueue_scripts', function(){
wp_enqueue_script('translations-js', get_stylesheet_directory_uri() . '/assets/js/translations.js');
});
?>
@mingodev
mingodev / functions.php
Last active January 21, 2020 20:21
Remove recaptcha from most pages
<?php
//Remove Google ReCaptcha code/badge everywhere apart from select pages
add_action('wp_print_scripts', function () {
//Add pages you want to allow to array
if ( !is_page( array( 'slugs-go-here' ) ) ){
wp_dequeue_script( 'google-recaptcha' );
//wp_dequeue_script( 'google-invisible-recaptcha' );
}
});
@mingodev
mingodev / footer.tpl
Last active March 19, 2020 17:23
Opencart popup
add_filter('posts_join_paged', function ($join) {
return "LEFT JOIN wpp1_postmeta ON ( wpp1_posts.ID = wpp1_postmeta.post_id AND wpp1_postmeta.meta_key = 'Date de l\'événement')";
});