Skip to content

Instantly share code, notes, and snippets.

View Mahjouba91's full-sized avatar
🏠
Working from home

Florian TIAR Mahjouba91

🏠
Working from home
  • London / Paris
View GitHub Profile
@7studio
7studio / POST.md
Created June 2, 2018 16:51
Améliorer le choix des dispositions dans un contenu flexible ACF

Améliorer le choix des dispositions dans un contenu flexible ACF

ACF Flexible Content Enhancer

Je pense que tout est parti d'un screenshot que j'ai vu passer sur le slack WordPress-fr et où je me suis dit que ça serait génial d'avoir la même chose pour nos contributeurs 😍

Au boulot, nous adorons les contenus flexibles ACF mais il faut bien se l'avouer, la popin pour choisir les dispositions n'est pas très "sexy" pour l'utilisateur final.

Je pensais que cela serait assez simple car comme nous le savons tous, ACF est très extensible et bien codé, sauf qu'il a fallu réfléchir un peu plus que prévu 😅 ACF ne propose pas encore la possibilité d'ajouter une option à une disposition d'un contenu flexible. Pour les curieux, ça se passe ici : plugins/advanced-custom-fields-pro/pro/fields/class-acf-field-flexible-content.php#L564-648 et vraiment aucun hook dans les parages… De toute façon, en y réfléch

@royboy789
royboy789 / guten-vue.js
Created January 17, 2018 00:38
This is a Gutenberg Block built with Vue.js
( function( wp ) {
var el = wp.element.createElement;
var __ = wp.i18n.__;
wp.blocks.registerBlockType( 'learn-gutenberg/ex2-vue', {
title: __( 'Learn Gutenberg Example 2: VueJS', 'learn-gutenberg' ),
category: 'widgets',
supportHTML: false,
attributes: {
who: {
@stella-yc
stella-yc / dijkstra.js
Last active August 24, 2023 20:46
Dijkstra's Algorithm in Javascript using a weighted graph
const problem = {
start: {A: 5, B: 2},
A: {C: 4, D: 2},
B: {A: 8, D: 7},
C: {D: 6, finish: 3},
D: {finish: 1},
finish: {}
};
const lowestCostNode = (costs, processed) => {
@thierrypigot
thierrypigot / install-wp.sh
Last active July 28, 2021 10:28
Local by flywheel - Custom WordPress install script
#!/usr/bin/env bash
while ! mysqladmin ping --silent; do
sleep 1
done
if mysql -e "SELECT USER(),CURRENT_USER();" -proot 2> /dev/null
then
echo "mysql password: root"
mysql -e "DROP DATABASE IF EXISTS local; CREATE DATABASE local;" -proot
@bebaps
bebaps / load-more.js
Created February 21, 2017 14:54
AJAX load more button using the WP REST API
// This function implements a "Load More" button.
// It assumes that there is already a matching query that has executed on the page, so this AJAX call is just a continuation of that query to grab additional posts.
// There are no animations added here. For a smoother experience, it is a good idea to add animations to the button (ex. a loading icon during the request), or making the new posts animate in (ex, using Animate.css to fade them into the page)
$(function() {
// Grab the load more button, since I only want to run the code if the button is on the page
var loadMoreButton = $('#load-more');
if (loadMoreButton) {
// Because there are already posts on the page, we need to manually tell this query what page of results to grab so that is doesn't load duplicate posts
var loadPosts = function(page) {
@sonnygauran
sonnygauran / database-tables-size.sql
Created February 5, 2017 12:27
Show current database's table sizes in descending order. Usually ran inside Sequel Pro Based on http://stackoverflow.com/questions/9620198/how-to-get-the-sizes-of-the-tables-of-a-mysql-database.
SET @table=(SELECT DATABASE());
select @table;
SELECT
table_schema as `Database`,
table_name AS `Table`,
round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`
FROM information_schema.TABLES
WHERE table_schema = @table
ORDER BY (data_length + index_length) DESC;
@orottier
orottier / RetryTest.php
Last active July 21, 2023 10:10
Retry function for PHP with exponential backoff
<?php
class RetryTest extends TestCase
{
public function setUp()
{
parent::setUp();
// abuse superglobal to keep track of state
$_GET['a'] = 0;
}
@ahmedkaludi
ahmedkaludi / WordPress Loop with Google Structured Data.php
Created June 12, 2016 10:53
WordPress Loop with Google Structured Data
<?php
// checks if there are any posts that match the query
if ( have_posts() ) :
// If there are posts matching the query then start the loop
while ( have_posts() ) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" role="article" itemprop="hasPart" itemscope="" itemtype="http://schema.org/Article">
<meta itemscope='itemscope' itemprop='mainEntityOfPage' itemType='https://schema.org/WebPage'/>
@khromov
khromov / deploy.php
Created June 8, 2016 07:28
Deploy WordPress with Deployer on EasyEngine
<?php
require 'recipe/common.php';
// Set configurations
set('repository', 'ssh://gogs@git.server.com:22/user/repo.git');
set('shared_files', ['public/wp-config.php']);
set('shared_dirs', ['public/wp-content/uploads']);
set('writable_dirs', []);
set('keep_releases', 10);
set('composer_command', 'composer');
@mayukojpn
mayukojpn / shortcake-ui-demo.php
Last active March 28, 2017 21:47
ShortCake UI Demo Plugin
<?php
/**
* Plugin Name: Shortcake UI Pullquote Demo
* Plugin URI:
* Description: Try Shortcake with pull-quite shortcode
* Version: 1.0.0
* Author: Mte90
* License: GPL2
*/