Skip to content

Instantly share code, notes, and snippets.

View rwkyyy's full-sized avatar
🏠
Working from home

Eduard “RwkY” Doloc rwkyyy

🏠
Working from home
View GitHub Profile
@rwkyyy
rwkyyy / gist:f8997d3fdbea4bb36941ad7d4ef20064
Created December 19, 2018 15:10
Show empty stars onwards (CSSIgniter response)
//Display the rating on a submitted comment.
add_filter( 'comment_text', 'ci_comment_rating_display_rating' );
function ci_comment_rating_display_rating( $comment_text ) {
if ( $rating = get_comment_meta( get_comment_ID(), 'rating', true ) ) {
$stars = '<p class="stars">';
for ( $i = 1; $i <= 5 ; $i ++ ) {
if ( $i <= $rating ) {
$stars .= '<span class="dashicons dashicons-star-filled"></span>';
} else {
@rwkyyy
rwkyyy / gist:e022149949206faa2265acb01b69e604
Created December 11, 2018 09:57
change query of comments in wordpress (globally)
function rwk_change_query( $comments ) {
$comments->query_vars['order'] = 'DESC';
$comments->meta_query->parse_query_vars( $comments->query_vars );
}
add_action( 'pre_get_comments', 'rwk_change_query' );
function hide_update_notice_to_all_users() {
remove_action( 'admin_notices', 'update_nag', 3 );
add_action('init', create_function('$a',"remove_action( 'init', 'wp_version_check' );"),2);
add_filter('pre_option_update_core','__return_null');
add_filter('pre_site_transient_update_core','__return_null');
}
add_action( 'admin_head', 'hide_update_notice_to_all_users', 1 );
@rwkyyy
rwkyyy / gist:310a747be43774ee3171637fe04b4b2d
Created November 16, 2018 19:07
remove add to cart button
function WC() {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart');
return WooCommerce::instance();
}
@rwkyyy
rwkyyy / gist:869d300080ab989c72aadfd4db362591
Created November 7, 2018 13:51
add a button on product page description
add_action( 'woocommerce_single_product_summary', 'add_after_description_rwk', 25 );
function add_after_description_rwk() {
?>
<div class="button">HIT ME</div>
<?php }
@rwkyyy
rwkyyy / gist:88fe965f8815b381615208657b458b4b
Created October 26, 2018 18:21
cf7 dom event + jquery.post for sending data to external api via URL
document.addEventListener( 'wpcf7mailsent', function( event ) {
var name = jQuery("input[name=your-name]").val();
var email = jQuery("input[name=your-email]").val();
var phone = jQuery("input[name=tel-151]").val();
var date = jQuery("input[name=date-146]").val();
var msg = jQuery("textarea[name=your-message]").val();
jQuery.post ('http:/url.tld?' + 'username=static_value' + '&password=static_value' + '&source=static_value' + '&clientName=' + name + '&clientEmail=' + email + '&clientPhone=' + phone + '&programmingDate=' + date + '&message=' + msg );}, false );
@rwkyyy
rwkyyy / gist:a138c27bcbaccac631fe6282f0ecc29c
Last active February 24, 2021 10:02
Show the order phone number in the woocommerce order list
// add the column, we need to display it, right?
function wc_order_extras_column_evd( $columns ) {
$new_columns = array();
foreach ( $columns as $column_name => $column_info ) {
$new_columns[ $column_name ] = $column_info;
if ( 'order_total' === $column_name ) {
$new_columns['order_phone'] = __( 'Phone no.', 'rwky_ro' );
}
}
return $new_columns;
@rwkyyy
rwkyyy / gist:d43053675af6cfa89eda0d9d505865ee
Created October 15, 2018 09:13
remove the damn notices for non-admin.
// remove admin notices except admin
add_action('admin_head', function() {
if(!current_user_can('manage_options')){
remove_action( 'admin_notices', 'update_nag', 3 );
remove_action( 'admin_notices', 'maintenance_nag', 5 );
echo "<style>.notice, .update-nag , .error, .updated{ display:none!important; }</style>";
}
});
@todo: find all actions and remove them and if it's not enough, CSS will do the trick!
@rwkyyy
rwkyyy / gist:8cad5438e4f80293e2b23034c13fe955
Last active September 22, 2018 14:31
clean orphaned _postmeta
select post_id from wprh_postmeta pm where pm.post_in not in (select ID from wprh_posts)
@rwkyyy
rwkyyy / gist:80254548374ffeab7a95bec03e37f7c6
Created September 21, 2018 09:14
Show number of failed orders
add_action( 'woocommerce_admin_order_data_after_order_details', 'failed_orders_evd', 10, 2 );
function failed_orders_evd( $order ) {
$customer_orders = get_posts( array(
'numberposts' => -1,
// 'meta_key' => '_customer_user',
'meta_value' => $order->get_billing_email(),
'post_type' => 'shop_order',
'post_status' => array('wc-failed'),
) );