post_type ) {
return;
}
$coupon_count = wp_count_posts( 'wpaf_coupons' );
$coupon_number = $coupon_count->publish;
if ( $coupon_number >= 10 && get_option( 'wpaf_review_notify' ) == "no" ) {
?>
Congratulation!! You have already created %d coupons with the AffCoupon plugin - that’s awesome! Could you please do me a BIG favor and Review us on Trustpilot? Just to help us spread the word and boost our motivation.
~ William Jemes', 'affcoupon' ), $coupon_number ) );
?>
' . esc_html__( 'Full Coupon:', 'affcoupon' ) . ' [affcoupon id=' . absint( $post->ID ) . ']';
$only_code = '' . esc_html__( 'Only Coupon Code:', 'affcoupon' ) . ' [affcoupon_btn id=' . absint( $post->ID ) . ']';
$messages['wpaf_coupons'] = array(
0 => '', // Unused. Messages start at index 1.
1 => __( 'Coupon updated.', 'affcoupon' ),
2 => '',
3 => '',
4 => __( 'Coupon updated.', 'affcoupon' ),
// Revision restore message. The restore itself is performed and
// nonce-verified by WordPress core (wp-admin/revision.php); core then
// redirects back here. Rather than read the unverified `$_GET['revision']`
// request value, derive the title from the post's own latest revision so
// no request input is trusted.
5 => self::wpaf_revision_restored_message( $post ),
6 => sprintf(
/* translators: 1: Full coupon shortcode, 2: coupon-code-only shortcode. */
__( 'Coupon published.
Here are the shortcodes for this coupon: %1$s and %2$s ', 'affcoupon' ),
$full_coupon, $only_code
),
7 => __( 'Coupon saved.', 'affcoupon' ),
8 => __( 'Coupon submitted.', 'affcoupon' ),
9 => sprintf(
/* translators: %s: Dynamic value. */
__( 'Coupon scheduled for: %1$s.', 'affcoupon' ),
date_i18n( __( 'M j, Y @ G:i', 'affcoupon' ), strtotime( $post->post_date ) )
),
10 => __( 'Coupon draft updated.', 'affcoupon' )
);
return $messages;
}
/**
* Build the "restored to revision" admin message without trusting request input.
*
* WordPress core performs (and nonce-verifies) the actual revision restore in
* wp-admin/revision.php, then redirects back to the edit screen with
* `message=5`. Instead of reading the unverified `$_GET['revision']` value, we
* look up the post's own most recent revision and display its title, so no
* request superglobal is read here.
*
* @param WP_Post|null $post Current post object.
*
* @return string|false Message string, or false when there is no revision.
* @since 1.3
*/
private static function wpaf_revision_restored_message( $post ) {
if ( ! $post instanceof WP_Post ) {
return false;
}
$revisions = wp_get_post_revisions( $post->ID, array( 'posts_per_page' => 1 ) );
if ( empty( $revisions ) ) {
return false;
}
$revision = array_shift( $revisions );
return sprintf(
/* translators: %s: Revision title. */
__( 'Coupon restored to revision from %s', 'affcoupon' ),
wp_post_revision_title( $revision->ID, false )
);
}
}