Skip to content

Instantly share code, notes, and snippets.

@grola
grola / conditional-notice.php
Created January 15, 2019 12:49
Conditional notice
<?php
function wpdesk_info_notice_for_administrator() {
$user = wp_get current_user();
if ( in_array( 'administrator', $user->roles ) ) {
?>
<div class="notice notice-info">
<p>Info notice for administrator.</p>
</div>
<?php
@grola
grola / info-notice.php
Created January 15, 2019 12:48
Info notice
<?php
function wpdesk_info_notice() {
?>
<div class="notice notice-info">
<p>Info notice.</p>
</div>
<?php
}
add_action( 'admin_notices', 'wpdesk_info_notice' );
@grola
grola / dismissible.html
Created January 15, 2019 12:47
Dismissible notice
<div class="notice notice-success is-dismissible">
<p>Success notice.</p>
</div>
@grola
grola / error.html
Created January 15, 2019 12:46
Error notice
<div class="notice notice-error">
<p>Error notice.</p>
</div>
@grola
grola / warning.html
Created January 15, 2019 12:45
Warning notice
<div class="notice notice-warning">
<p>Warning notice.</p>
</div>
@grola
grola / info.html
Created January 15, 2019 12:41
Info notice
<div class="notice notice-info">
<p>Info notice.</p>
</div>
@grola
grola / success.html
Created January 15, 2019 12:39
Success notice
<div class="notice notice-success">
<p>Success notice.</p>
</div>
@grola
grola / functions.php
Created January 6, 2019 20:51
function wpdesk_info_notice
<?php
function wpdesk_info_notice() {
?>
<div class="notice notice-info">
<p>Info notice.</p>
</div>
<?php
}
add_action( 'admin_notices', 'wpdesk_info_notice' );
@grola
grola / functions.php
Last active October 2, 2018 10:09
WP All Import - Allegro Stock
<?php
add_action( 'pmxi_saved_post', 'wpdesk_pmxi_saved_post_trigger_set_stock' );
/**
* Trigger set stock for product.
*
* @param int $post_id Post id.
*/
function wpdesk_pmxi_saved_post_trigger_set_stock( $post_id ) {
if ( function_exists( 'wc_get_product' ) ) {
@grola
grola / completed_stack_trace.php
Last active October 1, 2018 10:48
Stack trace on order completed
<?php
add_action( 'woocommerce_order_status_completed', 'test_woocommerce_order_status_completed');
function test_woocommerce_order_status_completed( $order_id ) {
$order = wc_get_order( $order_id );
$order->add_order_note( print_r( debug_backtrace(), true ) );
$order->save();
}