Image

How to shuffle Deck of Cards?

Tags

, , , ,

night

Hi Guys,

Today I will share my simple WordPress plugin on shuffling the card and distribute among  players,. Logic behind this is shuffling (total deck*52 card ) keeping their suit stick on it. So at the end we can extract the card on single player hand with their suit.

Output: Card Shuffle – NewsCorp.png

You can download this WordPress plugin Googledrive or can clone from git.

Installation

  1. Download the plugin from above link and install on your WordPress directory
  2. Create new page/post and paste this shortcode on the page content
    [cardshuffle]

This will shuffle one deck(52cards) among five players

3. You can shuffle any number of deck to any number of players by just adding these argument on above shortcode

[cardshuffle deck=”3″ players=”6″]

4. Finally get the hands of card on the desired players. Here the above output shows all the card that first players got in his hand. You can do it simply passing adding paramter on card_on_player_hand arguments.

[cardshuffle deck=”3″ players=”6″ card_on_player_hand=”1″]

Please feels free to download this plugins and provide any suggestion.

Thanks

Reference
– Straight : http://en.wikipedia.org/wiki/List_of_poker_hands

Advertisements

How to activate drift message box?

Hello Guys,

Today I will be sharing my experience on activating drift message box after certain specific time. I had achieved this by using javascript setTimeout() function. You can paste this code on theme custom js file or can use add_inline_script() function to add this script.

var showwelcome_msg = function () {
    setTimeout( function() { 
    	drift.on('ready', function(api, payload) {
    		api.showWelcomeMessage();
    	    
    	});
    }, 90000 );
    
}
window.onload = showwelcome_msg;

 

This above code will open drift message box after 90sec of page load , you can change time as per your requirement.

Let me know if you have any question or queries or any other best solution.You can ping me on adhsushil7@gmail.com

Best Regards
Sushil Adhikari

WooCommerce downloadable links lost?

Tags

, , , ,

downloadable-product-overview

Hello Everyone, Today I am going to share my experience of debugging WooCommerce download links which was lost after the transferring the host. Actually transferring the host  sometimes broke the serialised data and in our case serialised value of   _downloadable_files  meta key was broken. After detecting the issue was from broken serialised data I went to take help of plugin below which doesn’t help me on this case, So I went on development of module which will fix this error:

Note: Please keep backup of your database before applying this method

Plugins I tested with:

Please copy the codes below on to your theme functions.php file and saved it.

/**
* correct broken serialized data of woocommerce download meta data
*/
$args = array(
	'post_type' => 'product',
	'posts_per_page' => -1,
	'meta_key' => '_downloadable_files',
	'fields' => 'ids'
);

$product = get_posts( $args );
foreach ($product as $key => $product_id ) {
	$post_meta = get_post_meta( $product_id ); 
	$coorected_serialized_data = $post_meta[ '_downloadable_files' ];
	$unserialize = unserialize( themeslug_serialize_corrector( $coorected_serialized_data[0] ) );
	if( $unserialize  ) {
               //Comment out this loop if your server doesn't support SSL or you do not want to change your download links to https:
		foreach ($unserialize as $hash_key => $file_details ) {
			$file_details[ 'file' ] = esc_url_raw( preg_replace( '/http/', 'https', $file_details[ 'file' ] ) );
			//construct array
			$final_meta_value = array(
				$hash_key => $file_details
			);
		}
		
		//array variable will be automatically serialized before saving on to database.
		update_post_meta( absint( $product_id  ), '_downloadable_files', $unserialize  );
	}
	
}
/** 
* @return corrected serialised string 
*/
function themeslug_serialize_corrector($serialized_string){
    // at first, check if "fixing" is really needed at all. After that, security checkup.
    if ( @unserialize($serialized_string) !== true &&  preg_match('/^[aOs]:/', $serialized_string) ) {
         $serialized_string = preg_replace_callback( '/s\:(\d+)\:\"(.*?)\";/s',    function($matches){return 's:'.strlen($matches[2]).':"'.$matches[2].'";'; },   $serialized_string );
    }
    return $serialized_string;
}

Note: This code was tested with website of 50 products, So I highly encourage you to use cron job to implements this code on large store. Also please remove the code after the use.

Let me know if you have any question or queries or any other best solution.You can ping me on adhsushil7@gmail.com

Best Regards

How to use widget as a shortcode?

Hi Everyone,

Today I will be sharing my experience on building shortcode from registered widgets. I had developed this feature on Styled Store Pro making all the custom widgets available as shortcode. A shortcode can be very useful on using the dynamic content on post/pages content and text widgets.

I hope you guys know how to build custom widgets and shortcode. If not please go through these link:
Widgets API
Shortcode API

Here our logic is to developing shortcode calling the_widgets() template tags on our shortcode callback function. the_widgets() accepts the instance which we will be sending as shortcode parameter. So let’s use default WordPress recent posts widgets on the shortcode
Continue reading

Image

How to Add Metabox On Houzez Child Theme ?

houzez-preview

Hello everyone,
Today I am going to share my experience while adding metabox on child theme using metabox.io on Houzez child Theme
Houzez Theme use metabox.io plugin to create metabox field on custom post type property as well default WordPress Post type. While using “”rwmb_meta_boxes” filter hook on child theme I came to lost all the metafield created by Houzez Parent Theme. So I start to dig on the code and found that houzez theme provides “houzez_theme_meta” to extend metabox field. You can see this filed on this template:

houzez -> frameworkd -> metabox -> houzez-meta-boxes.php.

Continue reading

Image

How to use wp_dropdown_categories() on widget field?

usingwidgets

Hello Guys,

Let’s see how we can implement wp_dropdown_categories() on widget field.

Here I am implementing codex way of making widgets: see here for reference: https://codex.wordpress.org/Widgets_API

You can see more about wp_dropdown_categories() here: https://codex.wordpress.org/Function_Reference/wp_dropdown_categories

So here we go-> Continue reading