'', 'message' => '', 'class' => false, 'is_dismissible' => true, ) ); $default_class = 'updated'; // One message as string if ( is_string( $r['message'] ) ) { $message = '
' . $this->esc_notice( $r['message'] ) . '
'; } elseif ( is_array( $r['message'] ) ) { $message = '' . implode( '
', array_map( array( $this, 'esc_notice' ), $r['message'] ) ) . '
'; // Messages as objects } elseif ( is_wp_error( $r['message'] ) ) { $default_class = 'is-error'; $errors = $r['message']->get_error_messages(); switch ( count( $errors ) ) { case 0: return false; case 1: $message = '' . $this->esc_notice( $errors[0] ) . '
'; break; default: $escaped = array_map( array( $this, 'esc_notice' ), $errors ); $message = '' . $upload_directory . '
' ),
__( 'To protect them, you must add this NGINX redirect rule.', 'easy-digital-downloads' ),
sprintf( __( 'If you have already done this, or it does not apply to your site, you may permenently %s.', 'easy-digital-downloads' ), '' . __( 'dismiss this notice', 'easy-digital-downloads' ) . '' )
)
) );
}
// Running Apache
if ( ! empty( $GLOBALS['is_apache'] ) && ! edd_htaccess_exists() && ! get_user_meta( get_current_user_id(), '_edd_htaccess_missing_dismissed', true ) ) {
$dismiss_notice_url = wp_nonce_url( add_query_arg( array(
'edd_action' => 'dismiss_notices',
'edd_notice' => 'htaccess_missing'
) ), 'edd_notice_nonce' );
$this->add_notice( array(
'id' => 'edd-apache',
'class' => 'error',
'is_dismissible' => false,
'message' => array(
sprintf( __( 'The .htaccess file is missing from: %s', 'easy-digital-downloads' ), '' . $upload_directory . '' ),
sprintf( __( 'First, please resave the Misc settings tab a few times. If this warning continues to appear, create a file called ".htaccess" in the %s directory, and copy the following into it:', 'easy-digital-downloads' ), '' . $upload_directory . '' ),
sprintf( __( 'If you have already done this, or it does not apply to your site, you may permenently %s.', 'easy-digital-downloads' ), '' . __( 'dismiss this notice', 'easy-digital-downloads' ) . '' ),
'' . edd_get_htaccess_rules() . '' ) ) ); } } /** * Notices about data (migrations, etc...) * * @since 3.0 */ private function add_data_notices() { // Recount earnings if ( class_exists( 'EDD_Recount_Earnings' ) ) { $this->add_notice( array( 'id' => 'edd-recount-earnings', 'class' => 'error', 'is_dismissible' => false, 'message' => sprintf( __( 'Easy Digital Downloads 2.5 contains a built in recount tool. Please deactivate the Easy Digital Downloads - Recount Earnings plugin', 'easy-digital-downloads' ), esc_url( edd_get_admin_url( array( 'page' => 'edd-tools', 'tab' => 'general' ) ) ), esc_url( admin_url( 'plugins.php' ) ) ) ) ); } } /** * Adds a notice about the deprecated Default Rate for Taxes. * * @since 3.0 * @since 3.0.2 - We've found a way to add default tax rates. Leaving the method in case anyone (for some reason) is calling it. */ private function add_tax_rate_notice() { // Default tax rate not detected. if ( false === edd_get_option( 'tax_rate' ) ) { return; } // On Rates page, settings notice is shown. if ( ! empty( $_GET['page'] ) && 'edd-settings' === $_GET['page'] && ! empty( $_GET['section'] ) && 'rates' === $_GET['section'] ) { return; } // URL to fix this $url = edd_get_admin_url( array( 'page' => 'edd-settings', 'tab' => 'taxes', 'section' => 'rates' ) ); // Link $link = '' . __( 'Review Tax Rates', 'easy-digital-downloads' ) . ''; // Add the notice $this->add_notice( array( 'id' => 'edd-default-tax-rate', 'class' => 'error', /* translators: Link to review existing tax rates. */ 'message' => '' . __( 'A default tax rate was detected.', 'easy-digital-downloads' ) . '
' . __( 'This setting is no longer used in this version of Easy Digital Downloads. Please confirm your regional tax rates are properly configured and update tax settings to remove this notice.', 'easy-digital-downloads' ) . '
' . $link, 'is_dismissible' => false ) ); } /** * Notices about settings (updating, etc...) * * @since 3.0 */ private function add_settings_notices() { // Settings area if ( ! empty( $_GET['page'] ) && ( 'edd-settings' === $_GET['page'] ) ) { // Settings updated if ( ! empty( $_GET['settings-updated'] ) ) { $this->add_notice( array( 'id' => 'edd-notices', 'message' => __( 'Settings updated.', 'easy-digital-downloads' ) ) ); } // No payment gateways are enabled if ( ! edd_get_option( 'gateways' ) && edd_is_test_mode() ) { // URL to fix this $url = edd_get_admin_url( array( 'page' => 'edd-settings', 'tab' => 'gateways', ) ); // Link $link = '' . __( 'Fix this', 'easy-digital-downloads' ) . ''; // Add the notice $this->add_notice( array( 'id' => 'edd-gateways', 'class' => 'error', 'message' => sprintf( __( 'No payment gateways are enabled. %s.', 'easy-digital-downloads' ), $link ), 'is_dismissible' => false ) ); } } } /** * Notices about actions that the user has taken * * @since 3.0 * * @param string $notice */ private function add_user_action_notices( $notice = '' ) { // Sanitize notice key $notice = sanitize_key( $notice ); // Bail if notice is empty if ( empty( $notice ) ) { return; } // Shop discounts errors if ( current_user_can( 'manage_shop_discounts' ) ) { switch ( $notice ) { case 'discount_added' : $this->add_notice( array( 'id' => 'edd-discount-added', 'message' => __( 'Discount code added.', 'easy-digital-downloads' ) ) ); break; case 'discount_add_failed' : $this->add_notice( array( 'id' => 'edd-discount-add-fail', 'message' => __( 'There was a problem adding that discount code, please try again.', 'easy-digital-downloads' ), 'class' => 'error' ) ); break; case 'discount_exists' : $this->add_notice( array( 'id' => 'edd-discount-exists', 'message' => __( 'A discount with that code already exists, please use a different code.', 'easy-digital-downloads' ), 'class' => 'error' ) ); break; case 'discount_updated' : $this->add_notice( array( 'id' => 'edd-discount-updated', 'message' => __( 'Discount code updated.', 'easy-digital-downloads' ) ) ); break; case 'discount_not_changed' : $this->add_notice( array( 'id' => 'edd-discount-not-changed', 'message' => __( 'No changes were made to that discount code.', 'easy-digital-downloads' ) ) ); break; case 'discount_update_failed' : $this->add_notice( array( 'id' => 'edd-discount-updated-fail', 'message' => __( 'There was a problem updating that discount code, please try again.', 'easy-digital-downloads' ), 'class' => 'error' ) ); break; case 'discount_validation_failed' : $this->add_notice( array( 'id' => 'edd-discount-validation-fail', 'message' => __( 'The discount code could not be added because one or more of the required fields was empty, please try again.', 'easy-digital-downloads' ), 'class' => 'error' ) ); break; case 'discount_invalid_code': $this->add_notice( array( 'id' => 'edd-discount-invalid-code', 'message' => __( 'The discount code entered is invalid; only alphanumeric characters are allowed, please try again.', 'easy-digital-downloads' ), 'class' => 'error' ) ); break; case 'discount_invalid_amount' : $this->add_notice( array( 'id' => 'edd-discount-invalid-amount', 'message' => __( 'The discount amount must be a valid percentage or numeric flat amount. Please try again.', 'easy-digital-downloads' ), 'class' => 'error' ) ); break; case 'discount_deleted': $this->add_notice( array( 'id' => 'edd-discount-deleted', 'message' => __( 'Discount code deleted.', 'easy-digital-downloads' ) ) ); break; case 'discount_delete_failed': $this->add_notice( array( 'id' => 'edd-discount-delete-fail', 'message' => __( 'There was a problem deleting that discount code, please try again.', 'easy-digital-downloads' ), 'class' => 'error' ) ); break; case 'discount_activated': $this->add_notice( array( 'id' => 'edd-discount-activated', 'message' => __( 'Discount code activated.', 'easy-digital-downloads' ) ) ); break; case 'discount_activation_failed': $this->add_notice( array( 'id' => 'edd-discount-activation-fail', 'message' => __( 'There was a problem activating that discount code, please try again.', 'easy-digital-downloads' ), 'class' => 'error' ) ); break; case 'discount_deactivated': $this->add_notice( array( 'id' => 'edd-discount-deactivated', 'message' => __( 'Discount code deactivated.', 'easy-digital-downloads' ) ) ); break; case 'discount_deactivation_failed': $this->add_notice( array( 'id' => 'edd-discount-deactivation-fail', 'message' => __( 'There was a problem deactivating that discount code, please try again.', 'easy-digital-downloads' ), 'class' => 'error' ) ); break; } } // Shop reports errors if ( current_user_can( 'view_shop_reports' ) ) { switch( $notice ) { case 'refreshed-reports' : $this->add_notice( array( 'id' => 'edd-refreshed-reports', 'message' => __( 'The reports have been refreshed.', 'easy-digital-downloads' ) ) ); break; } } // Shop settings errors if ( current_user_can( 'manage_shop_settings' ) ) { switch( $notice ) { case 'settings-imported' : $this->add_notice( array( 'id' => 'edd-settings-imported', 'message' => __( 'The settings have been imported.', 'easy-digital-downloads' ) ) ); break; case 'api-key-generated' : $this->add_notice( array( 'id' => 'edd-api-key-generated', 'message' => __( 'API keys successfully generated.', 'easy-digital-downloads' ) ) ); break; case 'api-key-exists' : $this->add_notice( array( 'id' => 'edd-api-key-exists', 'message' => __( 'The specified user already has API keys.', 'easy-digital-downloads' ), 'class' => 'error' ) ); break; case 'api-key-regenerated' : $this->add_notice( array( 'id' => 'edd-api-key-regenerated', 'message' => __( 'API keys successfully regenerated.', 'easy-digital-downloads' ) ) ); break; case 'api-key-revoked' : $this->add_notice( array( 'id' => 'edd-api-key-revoked', 'message' => __( 'API keys successfully revoked.', 'easy-digital-downloads' ) ) ); break; case 'test-purchase-email-sent': $this->add_notice( array( 'id' => 'edd-test-purchase-receipt-sent', 'message' => __( 'The test email was sent successfully.', 'easy-digital-downloads' ) ) ); break; case 'test-summary-email-sent': $this->add_notice( array( 'id' => 'edd-test-summary-email-sent', 'message' => __( 'The test email summary was sent successfully.', 'easy-digital-downloads' ) ) ); break; case 'missing-pass-key': $this->add_notice( array( 'id' => 'edd-missing-pass-key', 'message' => __( 'Your extensions could not be refreshed because you have not verified your license key.', 'easy-digital-downloads' ), 'class' => 'error', ) ); break; } } // Shop payments errors if ( current_user_can( 'edit_shop_payments' ) ) { switch( $notice ) { case 'note-added' : $this->add_notice( array( 'id' => 'edd-note-added', 'message' => __( 'The note has been added successfully.', 'easy-digital-downloads' ) ) ); break; case 'payment-updated' : $this->add_notice( array( 'id' => 'edd-payment-updated', 'message' => __( 'The order has been updated successfully.', 'easy-digital-downloads' ) ) ); break; case 'order_added' : $this->add_notice( array( 'id' => 'edd-order-added', 'message' => __( 'Order successfully created.', 'easy-digital-downloads' ) ) ); break; case 'order_trashed' : $this->add_notice( array( 'id' => 'edd-order-trashed', 'message' => __( 'The order has been moved to the trash.', 'easy-digital-downloads' ) ) ); break; case 'order_restored' : $this->add_notice( array( 'id' => 'edd-order-restored', 'message' => __( 'The order has been restored.', 'easy-digital-downloads' ) ) ); break; case 'payment_deleted' : $this->add_notice( array( 'id' => 'edd-payment-deleted', 'message' => __( 'The order has been deleted.', 'easy-digital-downloads' ) ) ); break; case 'email_sent' : $this->add_notice( array( 'id' => 'edd-payment-sent', 'message' => __( 'The purchase receipt has been resent.', 'easy-digital-downloads' ) ) ); break; case 'email_send_failed': $this->add_notice( array( 'id' => 'edd-payment-sent', 'message' => __( 'Failed to send purchase receipt.', 'easy-digital-downloads' ) ) ); break; case 'payment-note-deleted' : $this->add_notice( array( 'id' => 'edd-note-deleted', 'message' => __( 'The order note has been deleted.', 'easy-digital-downloads' ) ) ); break; } } // Customer Notices if ( current_user_can( 'edit_shop_payments' ) ) { switch( $notice ) { case 'customer-deleted' : $this->add_notice( array( 'id' => 'edd-customer-deleted', 'message' => __( 'Customer successfully deleted.', 'easy-digital-downloads' ), ) ); break; case 'user-verified' : $this->add_notice( array( 'id' => 'edd-user-verified', 'message' => __( 'User successfully verified.', 'easy-digital-downloads' ), ) ); break; case 'email-added' : $this->add_notice( array( 'id' => 'edd-customer-email-added', 'message' => __( 'Customer email added.', 'easy-digital-downloads' ), ) ); break; case 'email-removed' : $this->add_notice( array( 'id' => 'edd-customer-email-removed', 'message' => __( 'Customer email deleted.', 'easy-digital-downloads' ), ) ); break; case 'email-remove-failed' : $this->add_notice( array( 'id' => 'edd-customer-email-remove-failed', 'message' => __( 'Failed to delete customer email.', 'easy-digital-downloads' ), 'class' => 'error', ) ); break; case 'primary-email-updated' : $this->add_notice( array( 'id' => 'eddedd-customer-primary-email-updated', 'message' => __( 'Primary email updated for customer.', 'easy-digital-downloads' ) ) ); break; case 'primary-email-failed' : $this->add_notice( array( 'id' => 'edd-customer-primary-email-failed', 'message' => __( 'Failed to set primary email.', 'easy-digital-downloads' ), 'class' => 'error', ) ); break; case 'address-removed' : $this->add_notice( array( 'id' => 'edd-customer-address-removed', 'message' => __( 'Customer address deleted.', 'easy-digital-downloads' ) ) ); break; case 'address-remove-failed' : $this->add_notice( array( 'id' => 'edd-customer-address-remove-failed', 'message' => __( 'Failed to delete customer address.', 'easy-digital-downloads' ), 'class' => 'error', ) ); break; } } if ( 'one-click-upgrade' === $notice && edd_is_pro() && current_user_can( 'install_plugins' ) && edd_is_admin_page( 'settings' ) ) { $this->add_notice( array( 'id' => 'edd-upgraded', 'message' => sprintf( /* Translators: 1. opening strong tag, do not translate; 2. closing strong tag, do not translate */ __( 'Congratulations! You are now running %1$sEasy Digital Downloads (Pro)%2$s.', 'easy-digital-downloads' ), '', '' ), ) ); } } /** * Show a notice if debugging is enabled in the EDD settings. * Does not show if only the `EDD_DEBUG_MODE` constant is defined. * * @since 2.11.5 * @return void */ private function show_debugging_notice() { if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { return; } if ( ! current_user_can( 'manage_shop_settings' ) ) { return; } if ( ! edd_get_option( 'debug_mode', false ) ) { return; } /** * The notices JS needs to be output wherever the notice is displayed, not just EDD screens. * If more notices add to the script then this enqueue will need to be moved. * * @since 3.0 */ wp_enqueue_script( 'edd-admin-notices', EDD_PLUGIN_URL . 'assets/js/edd-admin-notices.js', array( 'jquery' ), EDD_VERSION, true ); $view_url = add_query_arg( array( 'post_type' => 'download', 'page' => 'edd-tools', 'tab' => 'debug_log', ), admin_url( 'edit.php' ) ); ?>
clear_log_file(); wp_send_json_success( wpautop( __( 'The debug log has been cleared and logging has been disabled.', 'easy-digital-downloads' ) ) ); } /** * Escape message string output * * @since 2.6.0 bbPress (r6775) * * @param string $message * * @return string */ private function esc_notice( $message = '' ) { $tags = wp_kses_allowed_html( 'post' ); $text = wp_kses( $message, $tags ); return $text; } }