Skip to content

Instantly share code, notes, and snippets.

View mahdiyazdani's full-sized avatar
:bowtie:
Still Rocking!

Mahdi Yazdani mahdiyazdani

:bowtie:
Still Rocking!
View GitHub Profile
@mahdiyazdani
mahdiyazdani / gutenberg-font-sizes.php
Last active October 1, 2019 16:47
Adding support for editor font sizes
<?php
function prefix_setup_theme() {
add_theme_support( 'editor-font-sizes', array(
array(
'name' => __( 'Small', 'themeLangDomain' ),
'size' => 12,
'slug' => 'small'
),
@mahdiyazdani
mahdiyazdani / gutenberg-color-palette.php
Last active October 1, 2019 16:47
Adding support for editor color palette
<?php
function prefix_setup_theme() {
add_theme_support( 'editor-color-palette', array(
array(
'name' => __( 'Strong Magenta', 'themeLangDomain' ),
'slug' => 'strong-magenta',
'color' => '#a156b4',
),
<?php
$mysqli = new mysqli( DB_HOST, DB_USER, DB_PASSWORD, DB_NAME ) or die( 'Could not connect' );
// Check connection
if ( mysqli_connect_errno() ) {
printf( "Connect failed: %s\n", mysqli_connect_error() );
exit();
}
@mahdiyazdani
mahdiyazdani / numeric-wordpress-pagination.php
Last active September 29, 2018 10:27
Numeric WordPress Pagination
<?php
function prefix_paginate_links() {
global $wp_query;
$big = 999999999; // This needs to be an unlikely integer
$args = array(
'base' => str_replace( $big, '%#%', get_pagenum_link($big) ),
@mahdiyazdani
mahdiyazdani / componentWillUnmount.jsx
Created September 25, 2018 21:59
componentWillUnmount
import React from 'react';
export class Example extends React.Component {
componentWillUnmount() {
alert('Goodbye world');
}
render() {
return <h1>Hello world</h1>;
}
@mahdiyazdani
mahdiyazdani / componentDidUpdate.jsx
Created September 25, 2018 21:54
componentDidUpdate
import React from 'react';
export class Example extends React.component {
componentDidUpdate(prevProps, prevState) {
alert('Component is done rendering!');
}
render() {
return <h1>Hello world</h1>;
}
@mahdiyazdani
mahdiyazdani / componentWillUpdate.jsx
Created September 25, 2018 21:51
componentWillUpdate
import React from 'react';
export class Example extends React.Component {
componentWillUpdate(nextProps, nextState) {
alert('Component is about to update! Any second now!');
}
render() {
return <h1>Hello world</h1>;
}
@mahdiyazdani
mahdiyazdani / shouldcomponentupdate.jsx
Created September 25, 2018 21:41
shouldComponentUpdate
import React from 'react';
export class Example extends React.Component {
constructor(props) {
super(props);
this.state = { subtext: 'Put me in an <h2> please.' };
}
shouldComponentUpdate(nextProps, nextState) {
@mahdiyazdani
mahdiyazdani / TopNumber.js
Last active September 25, 2018 21:50
componentWillReceiveProps
import React from 'react';
import ReactDOM from 'react-dom';
const yellow = 'rgb(255, 215, 18)';
export class TopNumber extends React.Component {
constructor(props) {
super(props);
this.state = { 'highest': 0 };
}
@mahdiyazdani
mahdiyazdani / componentdidmount.jsx
Created September 25, 2018 19:42
componentDidMount
import React from 'react';
import ReactDOM from 'react-dom';
export class Flashy extends React.Component {
componentWillMount() {
alert('AND NOW, FOR THE FIRST TIME EVER... FLASHY!!!!');
}
componentDidMount() {
alert('YOU JUST WITNESSED THE DEBUT OF... FLASHY!!!!!!!');