Skip to content

Instantly share code, notes, and snippets.

View cristianstan's full-sized avatar
🎯
Focusing

Cristian Stan cristianstan

🎯
Focusing
View GitHub Profile
@cristianstan
cristianstan / WooCommerce Simple Auctions (Show outbid notice all the time).php
Last active March 2, 2022 12:23
WooCommerce Simple Auctions (Show outbid notice all the time).php
<?php
// For iBid Auctions theme: https://themeforest.net/item/ibid-multi-vendor-auctions-woocommerce-theme/24923136
function ibid_outbid_always_notice_product_page() {
if (is_user_logged_in() && is_singular('product')) {
$user_id = get_current_user_id();
$notice_type = 'error';
// if ($user_id == '35') {
@cristianstan
cristianstan / WPML Update 'locale' user meta on language switch.php
Created March 1, 2022 12:11
WPML Update 'locale' user meta on language switch.php
<?php
function ibid_update_language_wpml_option() {
if(is_user_logged_in()){
$user_id = get_current_user_id();
$language_value = ICL_LANGUAGE_CODE;
update_user_meta( $user_id, 'locale', sanitize_text_field( $language_value ) );
}
}
@cristianstan
cristianstan / CM2 default post id with suffix or prefix.php
Last active June 3, 2021 19:33
CM2 default post id with suffix or prefix
<?php
// CMB2 with Prefix
function prefix_default_offer_id_by_offer_id( $field_args, $field ) {
return 'prefix_'. $field->object_id;
}
$cmb->add_field( array(
'name' => esc_html__( 'Nr. Oferta', 'cmb2' ),
'id' => 'woopog_offer_id',
'type' => 'text',
select {
background-image: linear-gradient( 45deg,transparent 50%,gray 0),linear-gradient( 135deg,gray 50%,transparent 0),linear-gradient( 90deg,#ccc,#ccc);
background-position: calc(100% - 18px) calc(1em + 1px),calc(100% - 13px) calc(1em + 1px),calc(100% - 2.5em) .5em;
background-size: 6px 5px,6px 5px,0 1.5em;
width: 100%;
background-repeat: no-repeat;
appearance: none !important;
-moz-appearance: none !important;
-o-appearance: none !important;
-webkit-appearance: none !important;
/*Variations on single product*/
.single-product .variations .variation-radios input[type='radio']{
display: none;
}
.single-product .variations .variation-radios label {
border: 2px solid #ddd;
border-radius: 4px;
cursor: pointer;
padding: 3px 6px;
margin-right: 5px;
<?php
/**
* @snippet WooCommerce How To Add New Tab @ My Account
* @how-to Watch tutorial @ https://techiesandesh.com
* @author Sandesh Jangam
* @compatible WooCommerce 3.6.2
* @donate $7 https://www.paypal.me/SandeshJangam/7
*/
/**
@cristianstan
cristianstan / Wordpress Override Custom Post Tyle Slug.php
Created May 30, 2020 15:54
Wordpress Override Custom Post Tyle Slug.php
<?php
add_filter( 'register_post_type_args', 'modeltheme_register_post_type_args', 10, 2 );
function modeltheme_register_post_type_args( $args, $post_type ) {
if ( 'mt_listing' === $post_type ) {
$args['rewrite']['slug'] = 'new-casino-slug'; /*ADD YOUR OWN SERMON SLUG ONLY ON THIS LINE */
}
return $args;
}
@cristianstan
cristianstan / WordPress Override Taxonomy Slug.php
Last active May 30, 2020 15:46
WordPress Override Taxonomy Slug.php
<?php
function modeltheme_update_taxonomy_slug() {
// Current taxonomy name (not slug) -> 'mt-listing-payment-methods'
$sermon_category_args = get_taxonomy( 'mt-listing-payment-methods' ); // returns an object
$sermon_category_args->show_admin_column = true;
// Here we will add the new slug 'payment' instead of 'payment-methods'
$sermon_category_args->rewrite['slug'] = 'payment'; /* HERE WE ADDED THE NEW LINK ------*/
$sermon_category_args->rewrite['with_front'] = false;
@cristianstan
cristianstan / Get Deepest category id of a product (WooCommerce).php
Created March 4, 2020 20:22
Get Deepest category id of a product (WooCommerce)
<?php
/**
*
* Get deepest product category woocommerce
* @param $product_id is the id of a product
*
*/
function prefix_get_deepest_product_category($product_id = ''){
// get all product cats for the current post
$categories = get_the_terms( $product_id, 'product_cat' );
@cristianstan
cristianstan / CMB2 repeatable fields.php
Created October 9, 2019 13:23
CMB2 repeatable fields.php
<?php
add_action( 'cmb2_admin_init', 'yourprefix_register_repeatable_group_field_metabox' );
/**
* Hook in and add a metabox to demonstrate repeatable grouped fields
*/
function yourprefix_register_repeatable_group_field_metabox() {
/**
* Repeatable Field Groups