Skip to content

Instantly share code, notes, and snippets.

View conditional-notice.php
<?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
View info-notice.php
<?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 Jan 15, 2019
Dismissible notice
View dismissible.html
<div class="notice notice-success is-dismissible">
<p>Success notice.</p>
</div>
View error.html
<div class="notice notice-error">
<p>Error notice.</p>
</div>
@grola
grola / warning.html
Created Jan 15, 2019
Warning notice
View warning.html
<div class="notice notice-warning">
<p>Warning notice.</p>
</div>
View info.html
<div class="notice notice-info">
<p>Info notice.</p>
</div>
@grola
grola / success.html
Created Jan 15, 2019
Success notice
View success.html
<div class="notice notice-success">
<p>Success notice.</p>
</div>
@grola
grola / functions.php
Created Jan 6, 2019
function wpdesk_info_notice
View functions.php
<?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 Oct 2, 2018
WP All Import - Allegro Stock
View functions.php
<?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 Oct 1, 2018
Stack trace on order completed
View completed_stack_trace.php
<?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();
}