Skip to content

Instantly share code, notes, and snippets.

View Vincent-gv's full-sized avatar

Vincent-gv

View GitHub Profile
<?php
$featured_image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'img_post' );
// img_post is name of my thumbnail size ( I've added my own in functions.php )
$focuskw = get_post_meta(get_the_ID(), ‘_yoast_wpseo_focuskw’, true);
// It's focus keyword that you enter in Yoast Metabox in post edit page, it's really important
$primary_cat = get_post_meta(get_the_ID(), ‘_yoast_wpseo_primary_category’, true);
// Primary Category is important, for permalink format and meta keywords
if($primary_cat == NULL && $primary_cat == ''){
@Vincent-gv
Vincent-gv / iterators.js
Created December 15, 2018 19:37
.forEach() .map() .filter() .reduce()
// .forEach()
const artists = ['Picasso', 'Kahlo', 'Matisse', 'Utamaro'];
artists.forEach(artist => {
console.log(artist + ' is one of my favorite artists.');
});
// expected output:
// "Picasso is one of my favorite artists."
// "Kahlo is one of my favorite artists."
// "Matisse is one of my favorite artists."
// "Utamaro is one of my favorite artists."
@Vincent-gv
Vincent-gv / normalize.css
Created December 13, 2018 13:50
Normalize.css makes browsers render all elements more consistently and in line with modern standards. It precisely targets only the styles that need normalizing.
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
/* Document
========================================================================== */
/**
* 1. Correct the line height in all browsers.
* 2. Prevent adjustments of font size after orientation changes in iOS.
*/
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Students</title>
<link rel="stylesheet" href="css/reset.css">
<link rel="stylesheet" href="css/design.css">
<style id="jsbin-css">
body{
@Vincent-gv
Vincent-gv / querySelector.js
Last active December 9, 2018 22:53
-- NOTES -- querySelector
console.log(document.body.childNodes[5].childNodes[1]);
var titresElts = document.getElementsByTagName("h2"); // Tous les titres h2
console.log(titresElts[0]); // Affiche le premier titre h2
console.log(titresElts.length); // Affiche 3
// Tous les éléments ayant la classe "merveilles"
var merveillesElts = document.getElementsByClassName("merveilles");
for (var i = 0; i < merveillesElts.length; i++) {
console.log(merveillesElts[i]);
/*
Exercice : questions de quiz
*/
// Liste des questions à afficher. Une question est définie par son énoncé et sa réponse
var questions = [
{
enonce: "Combien font 2+2 ?",
reponse: "2+2 = 4"
},
/*
Exercice : modifier une liste
<ul id="desserts"></ul>
<button>Ajouter un dessert</button>
*/
document.querySelector("button").addEventListener("click", function () {
var nomDessert = prompt("Entrez le nom du nouveau dessert :");
var dessertElt = document.createElement("li");
@Vincent-gv
Vincent-gv / click.js
Last active December 9, 2018 22:52
-- NOTES -- Gestion du clic souris
function clic() {
console.log("Clic !");
}
var boutonElt = document.getElementById("bouton");
// Ajout d'un gestionnaire pour l'évènement click
boutonElt.addEventListener("click", clic);
/*var boutonElt = document.getElementById("bouton");
// Ajout d'un gestionnaire pour l'évènement click
/*
Exercice : compter les clics
*/
function clic() {
compteurClics++;
document.getElementById("compteurClics").textContent = compteurClics;
}
var compteurClics = 0;
@Vincent-gv
Vincent-gv / colors.js
Last active December 9, 2018 22:21
Changer la couleur des divs selon la touche pressée : https://oc-courses.github.io/javascript-web/chapitre_5/html/couleurs.html
/*
Changer la couleur des divs :
*/
document.addEventListener("keypress", function (e) {
var touche = String.fromCharCode(e.charCode); // Récupération de la touche pressée
touche = touche.toUpperCase(); // Pour gérer indifféremment minuscules et majuscules
var couleur = "";
switch (touche) {
case "B":