$eu_counries = array( 'AL' => 'Albania', 'AD' => 'Andorra', 'AM' => 'Armenia', 'AT' => 'Austria ', 'BY' => 'Belarus', 'BE' => 'Belgium', 'BA' => 'Bosnia and Herzegovina', 'BG' => 'Bulgaria', 'CH' => 'Switzerland', 'CY' => 'Cyprus', 'CZ' => 'Czech Republic', 'DE' => 'Germany', 'DK' => 'Denmark', 'EE' => 'Estonia', 'ES' => 'Spain', 'FO' => 'Faeroe Islands', 'FI' => 'Finland', 'FR' => 'France', 'GB' => 'United Kingdom', 'GE' => 'Georgia', 'GI' => 'Gibraltar', 'GR' => 'Greece', 'HU' => 'Hungary', 'HR' => 'Croatia', 'IE' => 'Ireland', 'IS' => 'Iceland', 'IT' => 'Italy', 'LI' => 'Liechtenstein', 'LT' => 'Lithuania', 'LU' => 'Luxembourg', 'LV' => 'Latvia', 'MC' => 'Monaco', 'MK' => 'Macedonia', 'MT' => 'Malta', 'NO' => 'Norway', 'NL' => 'Netherlands', 'PL' => 'Poland', 'PT' => 'Portugal', 'RO' => 'Romania', 'RU' => 'Russian Federation', 'SE' => 'Sweden', 'SI' => 'Slovenia', 'SK' => 'Slovakia', 'SM' => 'San Marino', 'TR' => 'Turkey', 'UA' => 'Ukraine', 'VA' => 'Vatican City State');
Disable Copy or Paste action for text box
jQuery(document).ready(function(){ jQuery('#input').bind('cut copy paste', function(e) { alert('copy and paste disabled'); e.preventDefault(); }); });
Sort custom post table rows in wp-admin
add_filter( 'manage_edit-{custom_post_type}_columns', 'edit_custom_columns' ) ; function edit_custom_columns( $columns ) { $columns = array( 'cb' => '<input type="checkbox" />', 'title' => __( 'Tite' ), 'category' => __( 'Category' ), 'date' => __( 'Date' ) ); return $columns; }
Rename Woo-commerce Order Status Programmatically
function aviweb_renaming_order_status( $order_statuses ) { foreach ( $order_statuses as $key => $status ) { if ( 'wc-processing' === $key ) { $order_statuses['wc-processing'] = _x( 'In progress', 'Order status', 'woocommerce' ); } if ( 'wc-completed' === $key ) { $order_statuses['wc-completed'] = _x( 'Delivered', 'Order status', 'woocommerce' ); } } return $order_statuses; } add_filter( 'wc_order_statuses', 'aviweb_renaming_order_status' );
Redirect website with WWW and without WWW using .htaccess
Redirect without WWW RewriteEngine on RewriteCond %{HTTP_HOST} ^www\.aviweb\.com [NC] RewriteRule ^(.*)$ http://aviweb.com/$1 [L,R=301] Redirect with WWW RewriteEngine on RewriteCond %{HTTP_HOST} ^aviweb\.com [NC] RewriteRule ^(.*)$ http://www.aviweb.com/$1 [L,R=301]
Custom post type redirect in WordPress
add_action( 'template_redirect', 'aviweb_redirect_post_type' ); function aviweb_redirect_post_type() { $queried_post_type = get_query_var('post_type'); if ( is_single() && 'custom_post' == $queried_post_type ) { $redirection_url = get_site_url() . '/custom_page'; wp_redirect( $redirection_url, 301 ); exit; } }
Get WooCommerce order information like billing, shipping & date.
$order_id = 1234; $order_data = new WC_Order($order_id); //Order Date $order_date = $order_data->order_date; //Billing information $billing = $order_data->get_address('billing'); //Shipping information $shipping = $order_data->get_address('shipping');