Skip to content

Instantly share code, notes, and snippets.

View lagenceoueb's full-sized avatar

Jm Silone lagenceoueb

View GitHub Profile
@lagenceoueb
lagenceoueb / func_bordering_areas.php
Last active July 18, 2022 16:48
Return bordering French area from one area number
<?php
/**
* Return bordering french area from one area number
* Thanks to https://gist.github.com/sunny/13803 for inspiration
*
* @param $areaNumber
* @return mixed
*/
function bordering_areas($areaNumber) {
$borderingAreas = [
@lagenceoueb
lagenceoueb / functions.php
Last active April 7, 2022 07:29
Retirer le style natif Gutenberg (wp 5.9 )
<?php
/**
* Remove default style (Geutenberg preset) in WordPress 5.9 theme
**/
add_action( 'wp_enqueue_scripts', function(){
wp_dequeue_style( 'global-styles' );
}, 100 );
@lagenceoueb
lagenceoueb / _func_ajax_filter_by_categories.php
Last active February 23, 2022 10:51
Add a dynamic ajax filter on top of posts' list template (WordPress). This function must be required on functions.php in your active thème and you have to create an action hook on your template to render input and result
<?php
/**
* The function to display filter args for posts.
* @author jm silone
* needs to add a hook on your view (template) in this exampl we used
* a do_action('filter_by_categories',10); hook on target template
*/
/**
@lagenceoueb
lagenceoueb / .lando.yml
Created March 7, 2022 10:44
WordPress Lando recipe
name: nom_du_projet
recipe: wordpress # configure appserver for WP
config:
php: '8.1' # or maybe PHP 8.0?
via: nginx
database: mysql:5.7
webroot: public # where my site files live
xdebug: true # easy debugging
services:
appserver: # the php/nginx server
<!DOCTYPE html>
<html>
<head>
<title>My centered div wider than the parent div</title>
<style>
* {
box-sizing: border-box;
}
.parent {
max-width: 400px;
<?php
/**
* ADD IMAGE META ON CATEGORIES
* @from : https://yourblogcoach.com/how-to-add-taxonomy-images-in-wordpress/#Add_Taxonomy_Images_to_Default_Taxonomy_Category
*/
add_action( 'category_add_form_fields', 'add_category_image', 10, 2 );
/**
* Add image field on category
* @param $taxonomy
* @return void
@lagenceoueb
lagenceoueb / autowp.sh
Created September 7, 2023 12:22 — forked from davidroberto/autowp.sh
Bash script for wp install : create database, start mamp, download WP, define wp debug, generate password, install wp, clone a gulp based blank theme, generate posts etc...
#!/bin/bash -e
# define developpement root path
devdir=''
# define commercial dir
commdir=''
# define database root password
dbpass=''
@lagenceoueb
lagenceoueb / functions.php
Last active October 3, 2024 09:58
Add a star review system on a php based page
<?php
/**
* Generates the star rating based on the number of reviews.
*
* @param int $reviews The number of reviews to calculate the star rating.
* @return string The HTML representation of the star rating.
*/
function stars( $reviews )
{
$stars = '';