Skip to content

Instantly share code, notes, and snippets.

View adamclasic's full-sized avatar

Abderrahmane A Allalou adamclasic

View GitHub Profile
@adamclasic
adamclasic / .prettierrc.js
Created August 2, 2023 12:39 — forked from karpolan/.prettierrc.js
Prettier config for React App
module.exports = {
printWidth: 120, // max 120 chars in line, code is easy to read
useTabs: false, // use spaces instead of tabs
tabWidth: 2, // "visual width" of of the "tab"
trailingComma: 'es5', // add trailing commas in objects, arrays, etc.
semi: true, // add ; when needed
singleQuote: true, // '' for stings instead of ""
bracketSpacing: true, // import { some } ... instead of import {some} ...
arrowParens: 'always', // braces even for single param in arrow functions (a) => { }
jsxSingleQuote: false, // "" for react props, like in html
@adamclasic
adamclasic / AuthContext.js
Created November 12, 2022 11:09
React User Auth front end
import { createContext, useReducer, useEffect } from 'react';
import { getCookie } from '../utils/functions';
const AuthContext = createContext();
const authReducer = (state, action) => {
switch (action.type) {
case 'LOGIN':
return { user: action.payload };
case 'LOGOUT':
return { user: null };
@adamclasic
adamclasic / gist:4c97e7a9cd478cd692e02ac9680bea88
Created January 27, 2022 09:48
release template used by @Shopify CLI team
### Fixed
-
### Added
-
### Changed
-
// these are examples to put in the Inspector controle or the block controle (sidebar and tooltip)
// two more are missing: text, dropdown
import classnames from 'classnames';
import block_icons from '../icons/index';
const { registerBlockType } = wp.blocks;
const { InspectorControls } = wp.editor;
const { __ } = wp.i18n;
const { PanelBody, TextareaControl,
@adamclasic
adamclasic / gist:6dc6d1c819a2e64e7a917ac1fdb742cc
Last active January 27, 2021 08:56
Create a settings page using WP Settings API
<?php
// the original article URL: https://codesymphony.co/using-the-wordpress-settings-api/
/** Set Defaults **/
add_option( 'myplugin_field_1', 'some default value' );
add_option( 'myplugin_field_2', '1' );
add_option( 'myplugin_field_3', 'another default value' );
/** Add Settings Page **/
function myplugin_settings_menu() {
@adamclasic
adamclasic / Simple Ajax Login Form.php
Created January 18, 2021 07:44 — forked from cristianstan/Simple Ajax Login Form.php
Wordpress: Simple Ajax Login Form
<?php
//Simple Ajax Login Form
//Source: http://natko.com/wordpress-ajax-login-without-a-plugin-the-right-way/
?>
//html
<form id="login" action="login" method="post">
<h1>Site Login</h1>
<p class="status"></p>
<label for="username">Username</label>