Skip to content

Instantly share code, notes, and snippets.

View igorveremsky's full-sized avatar
🇺🇦
#standwithukraine

Igor Veremsky igorveremsky

🇺🇦
#standwithukraine
View GitHub Profile
<gmap-info-box :visible="infoWinOpen" :marker="infoWinPos" :offset-y="infoWinOffset.y" :offset-x="infoWinOffset.x">
<div>
CONTENT FOR INFOBOX
</div>
</gmap-info-box>
@igorveremsky
igorveremsky / _easing.scss
Created April 16, 2018 12:15
Transition Timing Functions Variables SCSS
// Linear
$linear : cubic-bezier(0.250, 0.250, 0.750, 0.750);
// Ease (defaults)
$ease : cubic-bezier(0.250, 0.100, 0.250, 1.000);
$easeIn : cubic-bezier(0.420, 0.000, 1.000, 1.000);
$easeOut : cubic-bezier(0.000, 0.000, 0.580, 1.000);
$easeInOut : cubic-bezier(0.420, 0.000, 0.580, 1.000);
// Cubic
@igorveremsky
igorveremsky / catalog-template.php
Created October 30, 2017 10:37
Terms Alphabet Catalog for Wordpress
<?php
/* Template Name: Catalog Template */
function renderAlphabetTermsCatalog($terms, $maxTermCountForLetter = 5) {
$termsTitle = array_map(function($term) {
return mb_convert_encoding($term->name, 'utf-8');
}, $terms);
$lastLetter = '';
@igorveremsky
igorveremsky / functions.php
Last active October 24, 2017 19:08
Custom Excerpt for Wordpress
<?php
/**
* Excerpt content
*/
function iv_excerpt($excerpt_length, $added)
{
$text = apply_filters( 'the_excerpt', get_the_excerpt() );
$text = preg_replace('/\[.+\]/', '', $text );
$chars_text = strlen($text);
$text = $text." ";
@igorveremsky
igorveremsky / index.php
Created October 11, 2017 13:58
Get Primary Category for Post Wordpress, Yoast
<?php
$primary_cat_id = get_post_meta(get_the_ID(), '_yoast_wpseo_primary_category', true);
if ( $primary_cat_id != null ) {
$category = get_category($primary_cat_id);
} else {
$categories = get_the_category();
$category = $categories[0];
}
@igorveremsky
igorveremsky / functions.php
Created October 11, 2017 13:15
Remove '/category/' from category archive url Wordpress
<?php
/*
* Remove '/category/' from category archive url
* */
function remcat_function($link) {
return str_replace("/category/", "/", $link);
}
add_filter('user_trailingslashit', 'remcat_function');
function remcat_flush_rules() {
@igorveremsky
igorveremsky / functions.php
Created October 11, 2017 13:14
Search only in posts Wordpress
<?php
/*
* Search only in posts
* */
function search_only_in_posts($query) {
if ($query->is_search) {
$query->set('post_type', 'post');
}
return $query;
}
@igorveremsky
igorveremsky / functions.php
Last active April 11, 2018 06:10
Post Gallery AJAX Loading Wordpress
<?php
/**
* Custom AJAX Action
*/
function load_more_post_gallery_image_callback() {
$url = wp_get_referer();
$post_id = url_to_postid( $url );
$imageInitialCount = intval( $_POST['imageInitialCount'] );
$imageLoadingCount = intval( $_POST['imageLoadingCount'] );
@igorveremsky
igorveremsky / header.php
Last active October 6, 2017 15:12
Custom Style for Menu Item with Categories in Wordpress, connected with https://gist.github.com/igorveremsky/63692b1e4718849c3f93992bc7ad783e
<?php
class CustomStyleForMenuItemWalker extends Walker_Nav_Menu {
function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
// add classes for menu item
$class_names = join( ' ', $item->classes );
$class_names = ' class="' .esc_attr( $class_names ). '"';
$output.= '<li id="menu-item-' . $item->ID . '"' .$class_names. '>';
//first get the current category ID
$cat_id = $item->object_id;
@igorveremsky
igorveremsky / functions.php
Last active November 17, 2018 21:05
Extra fields for post category in WordPress
<?php
//add extra fields to category edit form callback function
function extra_category_fields( $tag ) { //check for existing featured ID
$t_id = $tag->term_id;
$cat_meta = get_option( "category_$t_id");
?>
<tr class="form-field">
<th scope="row" valign="top"><label for="cat_meta[custom_color]"><?php _e('Custom Color'); ?></label></th>
<td>
<input type="text" name="cat_meta[custom_color]" id="cat_meta[custom_color]" value="<?php echo $cat_meta['custom_color'] ? $cat_meta['custom_color'] : ''; ?>"><br />