WC_Helper::_get_return_notices() │ private static │ WC 1.0
Various success/error notices.
Runs during admin page render, so no headers/redirects here.
Method of the class: WC_Helper{}
No Hooks.
Return
Array
. Array pairs of message/type strings with notices.
Usage
$result = WC_Helper::_get_return_notices();
WC_Helper::_get_return_notices() WC Helper:: get return notices code WC 7.7.0
private static function _get_return_notices() { $return_status = isset( $_GET['wc-helper-status'] ) ? wc_clean( wp_unslash( $_GET['wc-helper-status'] ) ) : null; $notices = array(); switch ( $return_status ) { case 'activate-success': $product_id = isset( $_GET['wc-helper-product-id'] ) ? absint( $_GET['wc-helper-product-id'] ) : 0; $subscription = self::_get_subscriptions_from_product_id( $product_id ); $notices[] = array( 'type' => 'updated', 'message' => sprintf( /* translators: %s: product name */ __( '%s activated successfully. You will now receive updates for this product.', 'woocommerce' ), '<strong>' . esc_html( $subscription['product_name'] ) . '</strong>' ), ); break; case 'activate-error': $product_id = isset( $_GET['wc-helper-product-id'] ) ? absint( $_GET['wc-helper-product-id'] ) : 0; $subscription = self::_get_subscriptions_from_product_id( $product_id ); $notices[] = array( 'type' => 'error', 'message' => sprintf( /* translators: %s: product name */ __( 'An error has occurred when activating %s. Please try again later.', 'woocommerce' ), '<strong>' . esc_html( $subscription['product_name'] ) . '</strong>' ), ); break; case 'deactivate-success': $product_id = isset( $_GET['wc-helper-product-id'] ) ? absint( $_GET['wc-helper-product-id'] ) : 0; $subscription = self::_get_subscriptions_from_product_id( $product_id ); $local = self::_get_local_from_product_id( $product_id ); $message = sprintf( /* translators: %s: product name */ __( 'Subscription for %s deactivated successfully. You will no longer receive updates for this product.', 'woocommerce' ), '<strong>' . esc_html( $subscription['product_name'] ) . '</strong>' ); if ( $local && is_plugin_active( $local['_filename'] ) && current_user_can( 'activate_plugins' ) ) { $deactivate_plugin_url = add_query_arg( array( 'page' => 'wc-addons', 'section' => 'helper', 'filter' => self::get_current_filter(), 'wc-helper-deactivate-plugin' => 1, 'wc-helper-product-id' => $subscription['product_id'], 'wc-helper-nonce' => wp_create_nonce( 'deactivate-plugin:' . $subscription['product_id'] ), ), admin_url( 'admin.php' ) ); $message = sprintf( /* translators: %1$s: product name, %2$s: deactivate url */ __( 'Subscription for %1$s deactivated successfully. You will no longer receive updates for this product. <a href="%2$s">Click here</a> if you wish to deactivate the plugin as well.', 'woocommerce' ), '<strong>' . esc_html( $subscription['product_name'] ) . '</strong>', esc_url( $deactivate_plugin_url ) ); } $notices[] = array( 'message' => $message, 'type' => 'updated', ); break; case 'deactivate-error': $product_id = isset( $_GET['wc-helper-product-id'] ) ? absint( $_GET['wc-helper-product-id'] ) : 0; $subscription = self::_get_subscriptions_from_product_id( $product_id ); $notices[] = array( 'type' => 'error', 'message' => sprintf( /* translators: %s: product name */ __( 'An error has occurred when deactivating the subscription for %s. Please try again later.', 'woocommerce' ), '<strong>' . esc_html( $subscription['product_name'] ) . '</strong>' ), ); break; case 'deactivate-plugin-success': $product_id = isset( $_GET['wc-helper-product-id'] ) ? absint( $_GET['wc-helper-product-id'] ) : 0; $subscription = self::_get_subscriptions_from_product_id( $product_id ); $notices[] = array( 'type' => 'updated', 'message' => sprintf( /* translators: %s: product name */ __( 'The extension %s has been deactivated successfully.', 'woocommerce' ), '<strong>' . esc_html( $subscription['product_name'] ) . '</strong>' ), ); break; case 'deactivate-plugin-error': $product_id = isset( $_GET['wc-helper-product-id'] ) ? absint( $_GET['wc-helper-product-id'] ) : 0; $subscription = self::_get_subscriptions_from_product_id( $product_id ); $notices[] = array( 'type' => 'error', 'message' => sprintf( /* translators: %1$s: product name, %2$s: plugins screen url */ __( 'An error has occurred when deactivating the extension %1$s. Please proceed to the <a href="%2$s">Plugins screen</a> to deactivate it manually.', 'woocommerce' ), '<strong>' . esc_html( $subscription['product_name'] ) . '</strong>', admin_url( 'plugins.php' ) ), ); break; case 'helper-connected': $notices[] = array( 'message' => __( 'You have successfully connected your store to WooCommerce.com', 'woocommerce' ), 'type' => 'updated', ); break; case 'helper-disconnected': $notices[] = array( 'message' => __( 'You have successfully disconnected your store from WooCommerce.com', 'woocommerce' ), 'type' => 'updated', ); break; case 'helper-refreshed': $notices[] = array( 'message' => __( 'Authentication and subscription caches refreshed successfully.', 'woocommerce' ), 'type' => 'updated', ); break; } return $notices; }