Skip to content

Instantly share code, notes, and snippets.

View alinademi's full-sized avatar

Ali Demi alinademi

  • Vancouver
View GitHub Profile

Font Face

A mixin for writing @font-face rules in SASS.

Usage

Create a font face rule. Embedded OpenType, WOFF2, WOFF, TrueType, and SVG files are automatically sourced.

@include font-face(Samplino, fonts/Samplino);
@alinademi
alinademi / _font-rem.scss
Created April 28, 2020 05:48 — forked from juanpujol/_font-rem.scss
Convert px units of font-size and line-height to rems with fallback to px for old browsers. Sass @mixin
/* ==========================
@mixin font-rem
=============================
Convert px units to rems with fallback to older browsers.
Sample:
h1 { @include font-rem(16px, 24px) };
Compiles to no CSS:
h1 {
add_action( 'wp_enqueue_scripts', 'enqueue_scripts', 1 );
function enqueue_scripts() {
if ( is_front_page() ) {
// On the home page, enqueue the home CSS, and don't defer it.
// Include the full stylesheet as well, for UX CSS (e.g., :hover), but DO defer it with a filter on style_loader_tag.
wp_enqueue_style( 'site-screen-home-no-defer', get_template_directory_uri() . '/css/style.home.css', null, false, 'screen' );
wp_enqueue_style( 'site-screen', get_template_directory_uri() . '/css/style.css', null, false, 'screen' );
} else {
wp_enqueue_style( 'site-screen-no-defer', get_template_directory_uri() . '/css/style.css', null, false, 'screen' );
@alinademi
alinademi / css-filter-generator-to-convert-from-black-to-target-hex-color.markdown
Created October 8, 2020 04:05
CSS filter generator to convert from black to target hex color
@alinademi
alinademi / AliMD-CSS-Layout-Debugger.md
Created December 11, 2020 01:12 — forked from AliMD/AliMD-CSS-Layout-Debugger.md
AliMD CSS Layout Debugger

CSS Layout Debugger AliMD Edition ;)

Outlines every DOM element on your page a random (valid) CSS hex color.

[].forEach.call($$('*'),el=>{el.style.outline=`1px solid hsl(${~~(Math.random()*360)},99%,50%)`})

screen shot 2018-02-10 at 2 01 00 pm

@alinademi
alinademi / gist:05b11a83c9300e35f0aae63d20e257eb
Created December 11, 2020 01:14 — forked from billerickson/gist:1325991
Menu With Description class
<?php
class Menu_With_Description extends Walker_Nav_Menu {
function start_el(&$output, $item, $depth, $args) {
global $wp_query;
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
$class_names = $value = '';
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
@alinademi
alinademi / Conditional tags for WP
Created December 21, 2020 19:19 — forked from sambody/Conditional tags for WP
WP: WordPress conditional tags summary (only works after posts_selection action hook, so not in functions.php?) See http://codex.wordpress.org/Conditional_Tags
======= admin
is_admin() - admin page, not public
======= posts and pages etc
is_home() - main blog page with latest posts (not necessarily front page)
is_front_page() - front of site (latest posts OR static page, see settings)
is_single() - single post/attachement/cpt (=custom post type), NOT for pages
@alinademi
alinademi / git-pushing-multiple.rst
Created December 31, 2020 05:41 — forked from rvl/git-pushing-multiple.rst
How to push to multiple git remotes at once. Useful if you keep mirrors of your repo.

Pushing to Multiple Git Repos

If a project has to have multiple git repos (e.g. Bitbucket and Github) then it's better that they remain in sync.

Usually this would involve pushing each branch to each repo in turn, but actually Git allows pushing to multiple repos in one go.

If in doubt about what git is doing when you run these commands, just

<?php
/*
* Plugin Name: WP REST API Demo
* Plugin URI: https://gist.github.com/wpscholar/693517420ca6c9e29e7719ef24e7e00f
* Description: A developer plugin designed for playing around with the WordPress REST API.
* Version: 1.0
* Author: Micah Wood
* Author URI: https://wpscholar.com
* License: GPL2
@alinademi
alinademi / nav-login-logout.php
Created January 29, 2021 01:39 — forked from wpscholar/nav-login-logout.php
Automatically append login and logout links to a specific menu location.
<?php
add_filter(
'wp_nav_menu_items',
function( $items, $args ) {
if ( 'primary_nav' === $args->theme_location ) {
if ( is_user_logged_in() ) {
$items .= '<li><a title="Log Out" href="' . esc_url( wp_logout_url() ) . '">' . __( 'Log Out', 'cobb-realtors' ) . '</a></li>';
} else {
$items .= '<li><a title="Login" href="' . esc_url( wp_login_url() ) . '">' . __( 'Login', 'cobb-realtors' ) . ' </a ></li >';