Skip to content

Instantly share code, notes, and snippets.

View stefanRepac's full-sized avatar
Fast forward

Stefan Repac stefanRepac

Fast forward
  • Novi Sad, Serbia
View GitHub Profile
@stefanRepac
stefanRepac / function.php
Created September 13, 2023 08:09
ACF WYSIWYG Editor add underline option
##-- ACF WYSIWYG Editor add underline option
add_filter( 'acf/fields/wysiwyg/toolbars', 'my_toolbars' );
function my_toolbars( $toolbars ) {
$toolbars['Full'][1][3] = 'underline';
return $toolbars;
}
@stefanRepac
stefanRepac / function.php
Created August 29, 2023 11:14
Check UserAgent if it's mobile in PHP
function isMobileDevice2() {
return preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]);
}
if( isMobileDevice2() === 1 || isMobileDevice2() === false) {
// Magic
}
@stefanRepac
stefanRepac / style.css
Created June 7, 2023 13:19
Gradient border with border radius
.btn-gradient-2 {
background: linear-gradient(white, white) padding-box,
linear-gradient(to right, darkblue, darkorchid) border-box;
border-radius: 30px;
border: 4px solid transparent;
}
@stefanRepac
stefanRepac / function.php
Created February 21, 2023 14:32
Remove <p> Paragraph around <img> image in Advanced Custom Field ( ACF ) WYSIWYG editor
<?php
// In this example we are adding <div> with class Figure around <img>
// If you want to remove <div> just simple delete open/close tag and leave $1 between ''
function img_unautop($pee) {
$pee = preg_replace('/<p>\\s*?(<a .*?><img.*?><\\/a>|<img.*?>)?\\s*<\\/p>/s', '<div class="figure">$1</div>', $pee);
return $pee;
}
add_filter( 'acf_the_content', 'img_unautop', 30 );
/*
+append will put images side by side, i.e. horizontally instead of vertically (with -append)
*/
// Terminal part
convert in.pdf +append out%d.png
@stefanRepac
stefanRepac / git-command.txt
Last active March 1, 2021 09:51
Exclude file to be tracked from Git
// Most important thing is to enter full path to the file from root directory path
git update-index --assume-unchanged rootFullPathToTheFile/file.extension
<?php
const CYR = array('а','б','в','г','д','ђ','е','ж','з','и','ј','к','л','љ','м','н','њ','о','п','р','с','т','ћ','у','ф','х','ц','ч','џ','ш','А','Б','В','Г','Д','Ђ','Е','Ж','З','И','Ј','К','Л','Љ','М','Н','Њ','О','П','Р','С','Т','Ћ','У','Ф','Х','Ц','Ч','Џ','Ш');
const LAT = array('a','b','v','g','d','đ','e','ž','z','i','j','k','l','lj','m','n','nj','o','p','r','s','t','ć','u','f','h','c','č','dž','š','A','B','V','G','D','Đ','E','Ž','Z','I','J','K','L','LJ','M','N','NJ','O','P','R','S','T','Ć','U','F','H','C','Č','DŽ','Š');
function cyr_to_latin( $string ) {
return str_replace(CYR, LAT, $string);
}
function latin_to_cyr( $string ) {
@stefanRepac
stefanRepac / states-cities-zip-all.json
Created November 18, 2020 09:04
List of cities with states and zip codes
This file has been truncated, but you can view the full file.
[
{
"max_zip": 99403,
"state_code": "WA",
"name": "Washington",
"cities": [
{
"zips": [
98360,
98321,
@stefanRepac
stefanRepac / states-cities-zip.json
Last active November 18, 2020 09:03
List of cities with states and zip codes. Population > 500.000 people
[
{
"name": "New York",
"state_code": "NY",
"min_zip": 10001,
"max_zip": 14692,
"cities": [
{
"name": "New York city",
"zips": [
@stefanRepac
stefanRepac / function.php
Created December 2, 2019 22:10
Remove the slug from published post permalinks. Only affect our CPT though.
function wpex_remove_cpt_slug( $post_link, $post, $leavename ) {
if ( 'yourCustomPostSlug' != $post->post_type || 'publish' != $post->post_status ) {
return $post_link;
}
$post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );
return $post_link;
}
add_filter( 'post_type_link', 'wpex_remove_cpt_slug', 10, 3 );