Skip to content

Instantly share code, notes, and snippets.

View nvourva's full-sized avatar

nvourva nvourva

  • CSSIgniter.com
  • Thessaloniki, Greece
View GitHub Profile
@nvourva
nvourva / ci-comment-rating.php
Created March 9, 2021 17:38
Comment rating with all stars visible by default
<?php
/*
Plugin Name: CI Comment Rating
Description: Adds a star rating system to WordPress comments
Version: 1.0.0
Author: The CSSIgniter Team
Author URI: https://cssigniter.com/
*/
//Enqueue the plugin's styles.
@nvourva
nvourva / gist:32420d4c1385ddc33d9f05183347fe1b
Created April 22, 2020 10:33
Add blog link to WooCommerce breadcrumbs
add_filter( 'woocommerce_get_breadcrumb', function( $crumbs, $breadcrumb ) {
if( is_singular( 'post' ) || is_category() ) {
$new_breadcrumb = [
_x( 'Blog', 'woo-breadcrumb', 'ci-theme' ),
get_post_type_archive_link( 'post' ),
];
array_splice( $crumbs, 1, 0, [ $new_breadcrumb ] );
}
return $crumbs;
@nvourva
nvourva / gist:060a59970302b2c735ce62af9d0cceb4
Created November 7, 2019 14:35
Manage post list columns on Noozbeat
remove_filter( 'manage_edit-post_columns', 'ci_theme_post_edit_columns' );
add_filter( 'manage_edit-post_columns', 'ci_theme_post_edit_all_columns', 99 );
if ( ! function_exists( 'ci_theme_post_edit_all_columns' ) ) :
function ci_theme_post_edit_all_columns( $columns ) {
$new_column['in_front'] = __( 'In front page', 'ci-theme' );
array_splice( $columns, 2, 0, $new_column );
return $columns;
}
@nvourva
nvourva / ci-woo-gallery-thumb.php
Created June 25, 2019 09:21
Modify product gallery thumb aspect ratio
@nvourva
nvourva / gist:91212b6c07f59e45f40146dd8ff84054
Created June 4, 2019 13:32
Save average rating on post meta for ci-comment-rating
//Save the rating submitted by the user.
add_action( 'comment_post', 'ci_comment_rating_save_comment_rating' );
function ci_comment_rating_save_comment_rating( $comment_id ) {
if ( ( isset( $_POST['rating'] ) ) && ( '' !== $_POST['rating'] ) ) {
$rating = intval( $_POST['rating'] );
add_comment_meta( $comment_id, 'rating', $rating );
$postid = get_comment( $comment_id )->comment_post_ID;
if ( metadata_exists('post', $postid, 'post_average_rating') ) {
update_post_meta( $postid, 'post_average_rating', ci_comment_rating_get_average_ratings( $postid ) );
@nvourva
nvourva / woo-thumb-size.php
Last active April 30, 2019 14:43
Customize WooCommerce thumbnail size
<?php
add_filter( 'woocommerce_get_image_size_gallery_thumbnail', 'ci_theme_woo_gallery_thumb_size' );
function ci_theme_woo_gallery_thumb_size() {
return array(
'width' => 100,
'height' => 0,
'crop' => 0,
);
}
@nvourva
nvourva / wc-custom-product-fields.php
Last active April 16, 2019 10:13
Create a custom WooCommerce product field. It is added in the inventory tab and displayed below the single product title.
<?php
/**
* Plugin Name: Custom Product Fields for WooCommerce
* Description: This small plugin will generate and display a custom product field.
* Version: 1.0.0
* Author: nvourva
*/
add_action( 'woocommerce_product_options_stock_fields', 'my_restock_notice_field' );
@nvourva
nvourva / ci-star-rating.php
Created February 8, 2019 17:22
Ratings Plugin
<?php
/*
Plugin Name: CI Comment Rating
Description: Adds a star rating system to WordPress comments
Version: 1.0.0
Author: The CSSIgniter Team
Author URI: https://cssigniter.com/
*/
//Enqueue the plugin's styles.
<?php
/*
Plugin Name: CI Comment Rating
Description: Adds a star rating system to WordPress comments
Version: 1.0.0
Author: The CSSIgniter Team
Author URI: https://cssigniter.com/
*/
//Enqueue the plugin's styles.