Skip to content

Instantly share code, notes, and snippets.

Avatar

Necat Bolpaça anova

View GitHub Profile
@anova
anova / mac-font-smoothing-antialiased.css
Created May 3, 2021
MAC renders fonts heavier, this trick solves
View mac-font-smoothing-antialiased.css
/* https://www.c2software.com/c2-blog/fonts-appearing-bold-on-mac.aspx */
.selector {
-webkit-font-smoothing: antialiased;
}
@anova
anova / custom-media-upload.js
Last active Feb 19, 2021
Custom media upload component for Wordpress Gutenberg.
View custom-media-upload.js
import { MediaUpload } from '@wordpress/block-editor';
import { Button } from '@wordpress/components';
function CustomMediaUpload(props){
return <MediaUpload
onSelect={ media => { props.onMediaSelected(media.url) } }
type="image"
value={ props.mediaUrl }
render={
({open}) => {
View gulpfile-sass-autoprefixer-browsersync.js
'use strict';
const { series, parallel, src, watch, dest } = require('gulp');
const sass = require('gulp-sass');
const autoprefixer = require('gulp-autoprefixer');
sass.compiler = require('dart-sass');
const browserSync = require('browser-sync').create();
const sass_src = 'wp-content/themes/theme-name/sass/**/{*.scss,_*.scss}';
View wordpress-get-pages-with-specific-template.php
<?php
$pages = get_pages( [
'meta_key' => '_wp_page_template',
'meta_value' => 'template-example.php',
] );
//$pages now contains pages which uses `template-example.php` as template.
$pages = get_pages([
'child_of' => get_the_ID(),
'meta_key' => '_wp_page_template',
@anova
anova / table-to-array.js
Created Dec 3, 2020
Extract table text into nested arrays.
View table-to-array.js
[...document.querySelector('table').querySelectorAll('tr')].map(tr => [...tr.querySelectorAll('td')].map(td => td.innerText))
@anova
anova / .htaccess
Last active Nov 30, 2020
Multisite and giving wordpress its own directory
View .htaccess
<IfModule mod_rewrite.c>
# not localhost:
# RewriteCond %{HTTP_HOST} \.
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
#eliminate root path access denied: (without placeholder index.php)
RewriteRule ^(/)?$ wp/index.php [L]
# add a trailing slash to /wp-admin
@anova
anova / img-tags-without-an-alt-attribute.md
Created Nov 26, 2020
Using regular expressions to find img tags without an alt attribute
View zend-framework-1-set-include-path.php
<?php
// https://stackoverflow.com/a/6840407
set_include_path(implode(PATH_SEPARATOR, array(
__DIR__ . '/',
get_include_path()
)));
@anova
anova / _Rating.cshtml
Created Oct 14, 2020
Pass a variable to partial (asp.net razor c# cshtml)
View _Rating.cshtml
@{
double rating = 0;
if (this.ViewData.ContainsKey("Rating"))
{
rating = Convert.ToDouble(ViewData["Rating"]);
}
}
@anova
anova / shortenName.js
Created Sep 26, 2020
Name Surname -> N. S.
View shortenName.js
function shortenName(name) {
return name.split(' ').map(word => `${word.charAt(0)}.`).join(' ');
}