Skip to content

Instantly share code, notes, and snippets.

View ivo-ivanov's full-sized avatar
🚀

Ivo Ivanov ivo-ivanov

🚀
View GitHub Profile
@ivo-ivanov
ivo-ivanov / post_install.sh
Created August 27, 2022 19:17 — forked from waleedahmad/post_install.sh
Ubuntu post installation script for installing software of your choice.
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
else
#Update and Upgrade
echo "Updating and Upgrading"
apt-get update && sudo apt-get upgrade -y
@ivo-ivanov
ivo-ivanov / custom-meta-query.php
Created June 3, 2021 13:08
Custom Meta Query in WP #wp #query
$args = array(
'post_type' => 'objekt',
'posts_per_page' => -1,
'no_found_rows' => true,
'suppress_filters' => false,
//Se the meta query
'meta_query' => array(
//comparison between the inner meta fields conditionals
'relation' => 'AND',
//meta field condition one
@ivo-ivanov
ivo-ivanov / settings.json
Created May 24, 2021 16:34
Set Git Bash as default terminal in VScode
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
"icon": "terminal-powershell"
},
"Command Prompt": {
"path": [
"${env:windir}\\Sysnative\\cmd.exe",
"${env:windir}\\System32\\cmd.exe"
],
@ivo-ivanov
ivo-ivanov / enqueue-if-block-is-present.php
Last active April 8, 2021 06:09
Load script only if the block is on the page. #wordpress #gutenberg
function enqueue_if_block_is_present(){
if(is_singular()){
//We only want the script if it's a singular page
$id = get_the_ID();
$theme_version = wp_get_theme()->get( 'Version' );
//load only if the block is on the page
if(has_block('acf/slider',$id)){
wp_enqueue_script( 'swiper', get_template_directory_uri() . '/assets/js/swiper-bundle.min.js',
array(), $theme_version,
@ivo-ivanov
ivo-ivanov / disable-enable-scroll.js
Created March 8, 2021 08:00
Temporally disable scroll #js
// left: 37, up: 38, right: 39, down: 40,
// spacebar: 32, pageup: 33, pagedown: 34, end: 35, home: 36
var keys = {37: 1, 38: 1, 39: 1, 40: 1};
function preventDefault(e) {
e.preventDefault();
}
function preventDefaultForScrollKeys(e) {
@ivo-ivanov
ivo-ivanov / german-date-format.php
Last active April 8, 2021 06:08
Output ACF Date Field in german date format. #php #acf
<?php
// for example we start from a variable like this
$yyyymmdd = get_field('date');
// set the local time to italian
date_default_timezone_set('Europe/Zurich');
$loc_de = setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
// convert the variable $yyyymmdd to a real date with DateTime
@ivo-ivanov
ivo-ivanov / remove-any.php
Created December 2, 2020 17:49
Remove any placeholder from woocommerce filter
// Remove any placeholder from woocommerce filter
add_filter ( 'woocommerce_layered_nav_any_label' , 'remove_any' , 10 , 3 ) ;
function remove_any ( $sprintf , $taxonomy_label , $taxonomy ) {
$sprintf = sprintf ( __ ( '%s' , 'woocommerce' ) , $taxonomy_label );
return $sprintf ;
}
@ivo-ivanov
ivo-ivanov / check-subfield-exists.php
Created August 13, 2020 09:29
Check the value of a sub field, outside the while loop. #wordpress #acf
$found = false;
$value = 'Your value';
while ( have_rows( 'your_repeater_field' ) ) : the_row();
if ( get_sub_field( 'your_sub_field' ) == $value ) :
$found = true;
endif;
endwhile;
if ( $found ) {
// True
@ivo-ivanov
ivo-ivanov / mailchimp.php
Created June 25, 2020 11:05
Mailchimp embed form (cleaned) #mailchimp #php
<!-- Begin Mailchimp Signup Form -->
<div id="mc_embed_signup">
<form action="https://sozialprojekte.us20.list-manage.com/subscribe/post?u=c6a36bc935239fbad33999327&amp;id=1e6b4c0434" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
<div id="mc_embed_signup_scroll">
<div class="mc-field-group">
<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL" >
</div>
<div id="mce-responses" class="clear">
<div class="response" id="mce-error-response" style="display:none"></div>
<div class="response" id="mce-success-response" style="display:none"></div>
@ivo-ivanov
ivo-ivanov / heartbeat.css
Created June 22, 2020 07:52
Heartbeat css animation. #css #animations
.heartbeat {
animation: heartbeat 3s infinite;
}
@keyframes heartbeat {
0% {
transform: scale(1);
}
20% {