| @@ -412,10 +412,17 @@ | ||
| 412 | 412 | add_action('admin_head', 'wppb_maybe_remove_add_new_button_for_cpt' ); |
| 413 | 413 | function wppb_maybe_remove_add_new_button_for_cpt() { |
| 414 | 414 | |
| 415 | 415 | global $pagenow; |
| 416 | - | |
| 417 | - $target_slugs = [ 'wppb-rf-cpt', 'wppb-epf-cpt', 'wppb-ul-cpt' ]; | |
| 416 | + | |
| 417 | + // Registration ('wppb-rf-cpt') and Edit Profile ('wppb-epf-cpt') forms are deliberately excluded: form | |
| 418 | + // creation is gated on an active paid VERSION at the CPT capability level (see | |
| 419 | + // wppb_fb_multiple_forms_available() in form-builder/form-builder-licensing.php), not on the LICENSE. Gating | |
| 420 | + // them here would disable a button an expired-but-paid install may still use, and -- since the capability gate | |
| 421 | + // makes core skip the button entirely on free -- would inject an empty, label-less stand-in next to the page | |
| 422 | + // title (no button left to read a label from). The free-tier stand-in comes from | |
| 423 | + // wppb_fb_enqueue_locked_add_new_button() instead. Same narrowing as wppb_filter_own_post_creation() below. | |
| 424 | + $target_slugs = [ 'wppb-ul-cpt' ]; | |
| 418 | 425 | $current_slug = ''; |
| 419 | 426 | $pointer_content = ''; |
| 420 | 427 | |
| 421 | 428 | $correct_page = false; |
| @@ -436,22 +443,10 @@ | ||
| 436 | 443 | |
| 437 | 444 | if ( $correct_page ) { |
| 438 | 445 | $license_status = wppb_get_serial_number_status(); |
| 439 | 446 | |
| 440 | - if( $current_slug === 'wppb-rf-cpt' ) { | |
| 447 | + if( $current_slug === 'wppb-ul-cpt' ) { | |
| 441 | 448 | if( $license_status == 'missing' ) { |
| 442 | - $pointer_content .= '<p>' . sprintf( __( 'Please %1$senter your license key%2$s first, to add new User Registration Forms.', 'profile-builder' ), '<a href="'. admin_url( 'admin.php?page=profile-builder-general-settings' ) .'">', '</a>' ) . '</p>'; | |
| 443 | - } else { | |
| 444 | - $pointer_content .= '<p>' . sprintf( __( 'You need an active license to add new User Registration Forms. %1$sRenew%2$s or %3$spurchase a new one%4$s.', 'profile-builder' ), '<a href="https://www.cozmoslabs.com/account/?utm_source=pb-registration-forms&utm_medium=client-site&utm_campaign=pb-expired-license">', '</a>', '<a href="https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=pb-registration-forms&utm_medium=client-site&utm_campaign=pb-multi-registration-addon#pricing" target="_blank">', '</a>' ) . '</p>'; | |
| 445 | - } | |
| 446 | - } else if( $current_slug === 'wppb-epf-cpt' ) { | |
| 447 | - if( $license_status == 'missing' ) { | |
| 448 | - $pointer_content .= '<p>' . sprintf( __( 'Please %1$senter your license key%2$s first, to add new Edit Profile Forms.', 'profile-builder' ), '<a href="'. admin_url( 'admin.php?page=profile-builder-general-settings' ) .'">', '</a>' ) . '</p>'; | |
| 449 | - } else { | |
| 450 | - $pointer_content .= '<p>' . sprintf( __( 'You need an active license to add new Edit Profile Forms. %1$sRenew%2$s or %3$spurchase a new one%4$s.', 'profile-builder' ), '<a href="https://www.cozmoslabs.com/account/?utm_source=pb-edit-profile-forms&utm_medium=client-site&utm_campaign=pb-expired-license">', '</a>', '<a href="https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=pb-edit-profile-forms&utm_medium=client-site&utm_campaign=pb-multi-edit-profile-addon#pricing" target="_blank">', '</a>' ) . '</p>'; | |
| 451 | - } | |
| 452 | - } else if( $current_slug === 'wppb-ul-cpt' ) { | |
| 453 | - if( $license_status == 'missing' ) { | |
| 454 | 449 | $pointer_content .= '<p>' . sprintf( __( 'Please %1$senter your license key%2$s first, to add new User Listing.', 'profile-builder' ), '<a href="'. admin_url( 'admin.php?page=profile-builder-general-settings' ) .'">', '</a>' ) . '</p>'; |
| 455 | 450 | } else { |
| 456 | 451 | $pointer_content .= '<p>' . sprintf( __( 'You need an active license to add a new User Listing. %1$sRenew%2$s or %3$spurchase a new one%4$s.', 'profile-builder' ), '<a href="https://www.cozmoslabs.com/account/?utm_source=pb-user-listing&utm_medium=client-site&utm_campaign=pb-expired-license">', '</a>', '<a href="https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=pb-user-listing&utm_medium=client-site&utm_campaign=pb-user-listing-addon#pricing" target="_blank">', '</a>' ) . '</p>'; |
| 457 | 452 | } |
| @@ -637,9 +632,10 @@ | ||
| 637 | 632 | |
| 638 | 633 | } |
| 639 | 634 | |
| 640 | 635 | function wppb_filter_own_post_creation( $data, $postarr ) { |
| 641 | - if ( in_array( $data['post_type'], [ 'wppb-rf-cpt', 'wppb-epf-cpt', 'wppb-ul-cpt' ] ) && empty( $postarr['ID'] ) ) { | |
| 636 | + // Only User Listing still needs a valid license here; RF/EPF free/multiple-forms gating lives in form-builder-licensing.php. | |
| 637 | + if ( in_array( $data['post_type'], [ 'wppb-ul-cpt' ] ) && empty( $postarr['ID'] ) ) { | |
| 642 | 638 | |
| 643 | 639 | $license_status = wppb_get_serial_number_status(); |
| 644 | 640 | |
| 645 | 641 | if( $license_status != 'valid' ) { |
| @@ -696,57 +692,55 @@ | ||
| 696 | 692 | return $values; |
| 697 | 693 | |
| 698 | 694 | } |
| 699 | 695 | |
| 700 | -function wppb_international_telephone_input_admin_notification() { | |
| 696 | +function wppb_form_builder_transition_admin_notification() { | |
| 701 | 697 | |
| 702 | 698 | if( !current_user_can( 'manage_options' ) ) |
| 703 | 699 | return; |
| 704 | 700 | |
| 701 | + /* don't advertise the Form Builder unless it actually loaded */ | |
| 702 | + if( !function_exists( 'wppb_fb_loaded' ) ) | |
| 703 | + return; | |
| 704 | + | |
| 705 | 705 | /* initiate the plugin notifications class */ |
| 706 | 706 | $notifications = WPPB_Plugin_Notifications::get_instance(); |
| 707 | 707 | /* this must be unique */ |
| 708 | - $notification_id = 'wppb_international_telephone_input_notification_pb'; | |
| 708 | + $notification_id = 'wppb_form_builder_transition_notification'; | |
| 709 | 709 | |
| 710 | - $docs_url = 'https://www.cozmoslabs.com/docs/profile-builder/manage-user-fields/international-telephone-input/'; | |
| 711 | - $notification_message = '<p style="font-size: 15px; margin-top:4px;">' . __( 'Let users pick their country, see flags and placeholders, and validate numbers in a familiar format.', 'profile-builder' ) . '</p>'; | |
| 710 | + $forms_url = admin_url( 'edit.php?post_type=wppb-rf-cpt' ); | |
| 712 | 711 | |
| 713 | - $docs_link = sprintf( __( '%1$sRead the documentation%2$s', 'profile-builder' ), '<a href="' . esc_url( $docs_url ) . '" target="_blank" rel="noopener noreferrer">', '</a>' ); | |
| 712 | + /* Filterable so the documentation link can be pointed at the Form Builder | |
| 713 | + * article without a code change. */ | |
| 714 | + $docs_url = apply_filters( 'wppb_fb_transition_notice_docs_url', 'https://www.cozmoslabs.com/docs/profile-builder/manage-user-fields/?utm_source=wpbackend&utm_medium=clientsite&utm_content=form_builder_transition_notification&utm_campaign=PBDocs' ); | |
| 714 | 715 | |
| 715 | - $buy_url = 'https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=wpbackend&utm_medium=clientsite&utm_content=international_telephone_input_notification&utm_campaign=PBFree#pricing'; | |
| 716 | + $notification_message = '<p style="font-size: 15px; margin-top:4px;">' . esc_html__( 'Registration and Edit Profile forms are now built with a drag-and-drop editor: pick fields from the inserter, arrange them on the canvas, and edit each one in place.', 'profile-builder' ) . '</p>'; | |
| 716 | 717 | |
| 717 | - if( defined( 'WPPB_PAID_PLUGIN_DIR' ) ) { | |
| 718 | - $extra_message = sprintf( | |
| 719 | - /* translators: 1: documentation link (HTML), 2: opening Form Fields link, 3: closing Form Fields link */ | |
| 720 | - __( '%1$s to set it up, or add the field under %2$sProfile Builder → Form Fields%3$s.', 'profile-builder' ), | |
| 721 | - $docs_link, | |
| 722 | - '<a href="' . esc_url( admin_url( 'admin.php?page=manage-fields' ) ) . '">', | |
| 723 | - '</a>' | |
| 724 | - ); | |
| 725 | - } else { | |
| 726 | - $extra_message = sprintf( | |
| 727 | - /* translators: 1: documentation link (HTML), 2: opening upgrade link, 3: closing upgrade link */ | |
| 728 | - __( '%1$s. This field is available in Profile Builder Basic and Pro. %2$sUpgrade now%3$s to use it.', 'profile-builder' ), | |
| 729 | - $docs_link, | |
| 730 | - '<a href="' . esc_url( $buy_url ) . '" target="_blank" rel="noopener noreferrer">', | |
| 731 | - '</a>' | |
| 732 | - ); | |
| 733 | - } | |
| 718 | + $notification_message .= '<p style="font-size: 15px; margin-top:4px;">' . esc_html__( 'Your existing forms and fields carried over automatically, and your live forms keep rendering exactly as before.', 'profile-builder' ) . '</p>'; | |
| 734 | 719 | |
| 735 | - $notification_message .= '<p style="font-size: 15px; margin-top:4px; padding-left: 77px;">' . $extra_message . '</p>'; | |
| 720 | + $notification_message .= '<p style="font-size: 15px; margin-top:4px;">' . wp_kses_post( sprintf( | |
| 721 | + /* translators: 1: opening Forms link (HTML), 2: closing Forms link, 3: opening documentation link (HTML), 4: closing documentation link */ | |
| 722 | + __( 'Open %1$sProfile Builder → Forms%2$s to take a look, or %3$sread the documentation%4$s.', 'profile-builder' ), | |
| 723 | + '<a href="' . esc_url( $forms_url ) . '">', | |
| 724 | + '</a>', | |
| 725 | + '<a href="' . esc_url( $docs_url ) . '" target="_blank" rel="noopener noreferrer">', | |
| 726 | + '</a>' | |
| 727 | + ) ) . '</p>'; | |
| 736 | 728 | |
| 737 | - $ul_icon_url = ( file_exists( WPPB_PLUGIN_DIR . 'assets/images/pb-logo.svg' ) ) ? WPPB_PLUGIN_URL . 'assets/images/pb-logo.svg' : ''; | |
| 738 | - $ul_icon = ( !empty( $ul_icon_url ) ) ? '<img src="' . esc_url( $ul_icon_url ) . '" width="64" height="64" style="float: left; margin: 15px 12px 15px 0; max-width: 100px;" alt="Profile Builder">' : ''; | |
| 729 | + $pb_icon_url = ( file_exists( WPPB_PLUGIN_DIR . 'assets/images/pb-logo.svg' ) ) ? WPPB_PLUGIN_URL . 'assets/images/pb-logo.svg' : ''; | |
| 730 | + $pb_icon = ( !empty( $pb_icon_url ) ) ? '<img src="' . esc_url( $pb_icon_url ) . '" width="64" height="64" style="float: left; margin: 15px 12px 15px 0; max-width: 100px;" alt="Profile Builder">' : ''; | |
| 739 | 731 | |
| 740 | - $message = $ul_icon; | |
| 741 | - $message .= '<h3 style="margin-bottom: 0;">' . esc_html__( 'New field: International Telephone Input.', 'profile-builder' ) . '</h3>'; | |
| 732 | + $message = $pb_icon; | |
| 733 | + $message .= '<div style="overflow: hidden;">'; | |
| 734 | + $message .= '<h3 style="margin-bottom: 0;">' . esc_html__( 'Introducing the new Profile Builder Form Builder.', 'profile-builder' ) . '</h3>'; | |
| 742 | 735 | $message .= $notification_message; |
| 736 | + $message .= '</div>'; | |
| 743 | 737 | $message .= '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wppb_dismiss_admin_notification' => $notification_id ) ), 'wppb_plugin_notice_dismiss' ) ) . '" type="button" class="notice-dismiss"><span class="screen-reader-text">' . esc_html__( 'Dismiss this notice.', 'profile-builder' ) . '</span></a>'; |
| 744 | 738 | |
| 745 | - $notifications->add_notification( $notification_id, $message, 'wppb-notice notice notice-info', true, array( 'manage-fields' ) ); | |
| 739 | + $notifications->add_marketing_notification( $notification_id, $message, 'wppb-notice notice notice-info', true, array( 'edit.php?post_type=wppb-rf-cpt' ) ); | |
| 746 | 740 | |
| 747 | 741 | } |
| 748 | -add_action( 'admin_init', 'wppb_international_telephone_input_admin_notification' ); | |
| 742 | +add_action( 'admin_init', 'wppb_form_builder_transition_admin_notification' ); | |
| 749 | 743 | |
| 750 | 744 | /** |
| 751 | 745 | * Get the Profile Builder Page or Post slug |
| 752 | 746 | * |