Translate a plugin using .po .mo files

The Editor There are others, but this is most used: Poedit, a cross-platform gettext catalogs (.po files) editor. The Formats .mo stands for Machine Object — compiled export of the .po file which is used by WordPress .po stands for Portable Object — editable text file with the translations strings — based on the master … Read more

What are the differences between WPINC and ABSPATH?

They are defined as follows: define( ‘ABSPATH’, dirname(dirname(__FILE__)) . “https://wordpress.stackexchange.com/” ); define( ‘WPINC’, ‘wp-includes’ ); dirname is a PHP function that returns the path of the parent directory, and wp-includes is pretty self explanatory. I would say ABSPATH is better because it’s one of the first things WP loads and it also looks better:) But … Read more

Get Product id from order id in Woocommerce [closed]

WooCommerce 3.0+ you can get the order items of an order by $order = wc_get_order( $order_id ); $items = $order->get_items(); then if you loop through the items, you can get all the relevant data: foreach ( $items as $item ) { $product_name = $item->get_name(); $product_id = $item->get_product_id(); $product_variation_id = $item->get_variation_id(); } a good tip is … Read more

What’s the preferred method of writing AJAX-enabled plugins?

the “safer and cleaner” way would be to use admin-ajax.php that comes with wordpress and wp_ajax hook to call your processing function from your plugin file and use wp-nonce to check the integrity of the call. for example: your ajax JQuery call would be <script type=”text/javascript” > jQuery(document).ready(function($) { var data = { action: ‘ACTION_NAME’, … Read more