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 / german-post-date-wordpress.php
Created June 10, 2020 07:17
Post date in german format #wordpress
// setlocale(LC_TIME, 'de_DE', 'deu_deu');
<?php the_time('l, j. F Y') ?>
@ivo-ivanov
ivo-ivanov / google-fonts.php
Created June 6, 2020 15:01
Hook to proper load Google Font. (the fastest way 2020) #wordpress
function google_fonts() {
?>
<!-- [1] -->
<link rel="preconnect"
href="https://fonts.gstatic.com"
crossorigin />
<!-- [2] -->
<link rel="preload"
as="style"
@ivo-ivanov
ivo-ivanov / untitled
Created May 13, 2020 09:23
Media Queries for mobile devices #css #mediaquery
/* big tablets only */
@media only screen
and (min-width: 1024px)
and (max-height: 1366px)
and (-webkit-min-device-pixel-ratio: 1.5) {
}
/* tablet landscape */
@ivo-ivanov
ivo-ivanov / nav-reveal.css
Created April 29, 2020 12:59
Nav reveal css animation #css
.active-nav nav li {
animation: navreveal .25s;
animation-fill-mode: forwards;
animation-timing-function: ease;
transform: translateY(66%);
}
.active-nav nav li:nth-child(1) {
animation-delay: .6s;
@ivo-ivanov
ivo-ivanov / delete-acf-data-after-field-removal.php
Last active August 15, 2024 14:17
Delete all data from WP database when an ACF field is deleted. #wordpress #acf
/*Deleting content when an ACF field is deleted is easy, relatively. Please note that the use of this function cannot be undone and it will erase all traces of content for any ACF field that is deleted.
Please be sure that this is something that you want to do before implementing this and I would strongly suggest that this is only enabled during development and not on a live site. Should a client go into ACF for some reason and delete a field, there is nothing that you’d be able to do to recover form it. */
// this action is run by ACF whenever a field is deleted
// and is called for every field in a field group when a field group is deleted
add_action('acf/delete_field', 'delete_acf_content_on_delete_field');
function delete_acf_content_on_delete_field($field) {
// runs when acf deletes a field
@ivo-ivanov
ivo-ivanov / functions.php
Last active April 29, 2020 12:53
Rename post formats #wordpress
// Rename default post formats
add_filter(
'load_script_translations',
function( $translations, $file, $handle, $domain ) {
/**
* The post format labels used for the dropdown are defined in the
* "wp-editor" script.
*/
if ( 'wp-editor' === $handle ) {
/**
@ivo-ivanov
ivo-ivanov / untitled
Created April 16, 2020 16:30
Menu highlight post type and custom page template. #wordpress
add_action('nav_menu_css_class', 'add_current_nav_class', 10, 2 );
function add_current_nav_class($classes, $item) {
// Getting the current post
global $post;
$current_post_type = get_post_type($post->ID); // post, c45_project
$item_page_id = get_post_meta( $item->ID, '_menu_item_object_id', true );
@ivo-ivanov
ivo-ivanov / hide-all-products-from-category.php
Last active April 14, 2020 06:49
Hide all products from category. #woo #woocommerce #wordpress
/**
* @snippet Hide Products From Specific Category @ Shop
* @how-to Get CustomizeWoo.com FREE
* @author Rodolfo Melogli
* @compatible WooCommerce 3.6.3
* @donate $9 https://businessbloomer.com/bloomer-armada/
*/
add_action( 'woocommerce_product_query', 'bbloomer_hide_products_category_shop' );
@ivo-ivanov
ivo-ivanov / untitled
Created April 6, 2020 16:40
Format bytes #php
// format bytes in KB/MB
function formatBytes($bytes, $precision = 0) {
$units = array('B', 'KB', 'MB', 'GB', 'TB');
$bytes = max($bytes, 0);
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
$pow = min($pow, count($units) - 1);
// Uncomment one of the following alternatives
// $bytes /= pow(1024, $pow);
@ivo-ivanov
ivo-ivanov / aspect-ratios.css
Last active October 2, 2020 07:29
Popular aspect ratios #css
16:9 | 56.25%
4:3 | 75%
3:2 | 66.66%
8:5 | 62.5%