| @@ -228,77 +228,38 @@ | ||
| 228 | 228 | |
| 229 | 229 | return (array) $links; |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | -function wppb_sync_api( $action ) { | |
| 232 | +/** | |
| 233 | + * Send deactivation feedback from the plugins screen modal. | |
| 234 | + * | |
| 235 | + * @param array $reason_data Sanitized reason payload from the popup form. | |
| 236 | + */ | |
| 237 | +function wppb_send_deactivation_feedback( $reason_data ) { | |
| 233 | 238 | |
| 234 | - $base = 'https://usagetracker.cozmoslabs.com'; | |
| 235 | - $url = $base . '/syncPlugin'; | |
| 239 | + if ( ! is_array( $reason_data ) || empty( $reason_data['reason'] ) ) | |
| 240 | + return; | |
| 241 | + | |
| 236 | 242 | $body = array( |
| 237 | 243 | 'unique_identifier' => hash( 'sha256', home_url( '', 'https' ) ), |
| 238 | 244 | 'product' => 'wppb', |
| 239 | - 'action' => $action, | |
| 245 | + 'action' => 'end', | |
| 246 | + 'reason' => sanitize_key( $reason_data['reason'] ), | |
| 240 | 247 | ); |
| 241 | 248 | |
| 242 | - $body = apply_filters( 'wppb_sync_api_body', $body, $action ); | |
| 249 | + $reason_key = $reason_data['reason'] . '_reason'; | |
| 243 | 250 | |
| 244 | - wp_remote_post( $url, array( | |
| 251 | + if ( ! empty( $reason_data[ $reason_key ] ) ) | |
| 252 | + $body['extra_metadata'] = sanitize_text_field( $reason_data[ $reason_key ] ); | |
| 253 | + | |
| 254 | + wp_remote_post( 'https://usagetracker.cozmoslabs.com/syncPlugin', array( | |
| 245 | 255 | 'body' => $body, |
| 246 | 256 | 'timeout' => 3, |
| 247 | 257 | 'blocking' => false, |
| 248 | 258 | ) ); |
| 249 | - | |
| 250 | 259 | } |
| 251 | 260 | |
| 252 | -function wppb_handle_plugin_activation(){ | |
| 253 | - | |
| 254 | - $general_settings = get_option( 'wppb_general_settings' ); | |
| 255 | - | |
| 256 | - if( empty( $general_settings ) || !is_array( $general_settings ) || empty( $general_settings['extraFieldsLayout'] ) ){ | |
| 257 | - wppb_sync_api( 'start' ); | |
| 258 | - } | |
| 259 | - | |
| 260 | -} | |
| 261 | - | |
| 262 | -function wppb_handle_plugin_deactivation(){ | |
| 263 | - wppb_sync_api( 'end' ); | |
| 264 | -} | |
| 265 | - | |
| 266 | 261 | /** |
| 267 | - * Add the stored deactivation reason to the sync payload | |
| 268 | - * | |
| 269 | - * @param array $body Sync request body | |
| 270 | - * @param string $action Sync action slug | |
| 271 | - * | |
| 272 | - * @return array | |
| 273 | - */ | |
| 274 | -function wppb_add_deactivation_reason_to_sync_body( $body, $action ) { | |
| 275 | - | |
| 276 | - if ( $action !== 'end' ) | |
| 277 | - return $body; | |
| 278 | - | |
| 279 | - $reason_data = get_option( 'wppb_deactivation_reason', array() ); | |
| 280 | - | |
| 281 | - if ( ! is_array( $reason_data ) ) | |
| 282 | - $reason_data = array(); | |
| 283 | - | |
| 284 | - if ( empty( $reason_data['reason'] ) ) | |
| 285 | - $reason_data['reason'] = 'skip'; | |
| 286 | - | |
| 287 | - $body['reason'] = sanitize_key( $reason_data['reason'] ); | |
| 288 | - | |
| 289 | - $reason_key = $reason_data['reason'] . '_reason'; | |
| 290 | - | |
| 291 | - if ( ! empty( $reason_data[ $reason_key ] ) ) | |
| 292 | - $body['extra_metadata'] = sanitize_text_field( $reason_data[ $reason_key ] ); | |
| 293 | - | |
| 294 | - delete_option( 'wppb_deactivation_reason' ); | |
| 295 | - | |
| 296 | - return $body; | |
| 297 | -} | |
| 298 | -add_filter( 'wppb_sync_api_body', 'wppb_add_deactivation_reason_to_sync_body', 10, 2 ); | |
| 299 | - | |
| 300 | -/** | |
| 301 | 262 | * Store the deactivation reason selected in the popup |
| 302 | 263 | */ |
| 303 | 264 | function wppb_store_deactivation_reason() { |
| 304 | 265 | |
| @@ -338,9 +299,9 @@ | ||
| 338 | 299 | |
| 339 | 300 | if ( $reason === 'other' && ! empty( $_POST['other_reason'] ) ) |
| 340 | 301 | $reason_data['other_reason'] = sanitize_text_field( wp_unslash( $_POST['other_reason'] ) ); |
| 341 | 302 | |
| 342 | - update_option( 'wppb_deactivation_reason', $reason_data, false ); | |
| 303 | + wppb_send_deactivation_feedback( $reason_data ); | |
| 343 | 304 | |
| 344 | 305 | wp_send_json_success(); |
| 345 | 306 | } |
| 346 | 307 | add_action( 'wp_ajax_wppb_store_deactivation_reason', 'wppb_store_deactivation_reason' ); |
| @@ -451,10 +412,17 @@ | ||
| 451 | 412 | add_action('admin_head', 'wppb_maybe_remove_add_new_button_for_cpt' ); |
| 452 | 413 | function wppb_maybe_remove_add_new_button_for_cpt() { |
| 453 | 414 | |
| 454 | 415 | global $pagenow; |
| 455 | - | |
| 456 | - $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' ]; | |
| 457 | 425 | $current_slug = ''; |
| 458 | 426 | $pointer_content = ''; |
| 459 | 427 | |
| 460 | 428 | $correct_page = false; |
| @@ -475,22 +443,10 @@ | ||
| 475 | 443 | |
| 476 | 444 | if ( $correct_page ) { |
| 477 | 445 | $license_status = wppb_get_serial_number_status(); |
| 478 | 446 | |
| 479 | - if( $current_slug === 'wppb-rf-cpt' ) { | |
| 447 | + if( $current_slug === 'wppb-ul-cpt' ) { | |
| 480 | 448 | if( $license_status == 'missing' ) { |
| 481 | - $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>'; | |
| 482 | - } else { | |
| 483 | - $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>'; | |
| 484 | - } | |
| 485 | - } else if( $current_slug === 'wppb-epf-cpt' ) { | |
| 486 | - if( $license_status == 'missing' ) { | |
| 487 | - $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>'; | |
| 488 | - } else { | |
| 489 | - $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>'; | |
| 490 | - } | |
| 491 | - } else if( $current_slug === 'wppb-ul-cpt' ) { | |
| 492 | - if( $license_status == 'missing' ) { | |
| 493 | 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>'; |
| 494 | 450 | } else { |
| 495 | 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>'; |
| 496 | 452 | } |
| @@ -676,9 +632,10 @@ | ||
| 676 | 632 | |
| 677 | 633 | } |
| 678 | 634 | |
| 679 | 635 | function wppb_filter_own_post_creation( $data, $postarr ) { |
| 680 | - 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'] ) ) { | |
| 681 | 638 | |
| 682 | 639 | $license_status = wppb_get_serial_number_status(); |
| 683 | 640 | |
| 684 | 641 | if( $license_status != 'valid' ) { |
| @@ -735,57 +692,55 @@ | ||
| 735 | 692 | return $values; |
| 736 | 693 | |
| 737 | 694 | } |
| 738 | 695 | |
| 739 | -function wppb_international_telephone_input_admin_notification() { | |
| 696 | +function wppb_form_builder_transition_admin_notification() { | |
| 740 | 697 | |
| 741 | 698 | if( !current_user_can( 'manage_options' ) ) |
| 742 | 699 | return; |
| 743 | 700 | |
| 701 | + /* don't advertise the Form Builder unless it actually loaded */ | |
| 702 | + if( !function_exists( 'wppb_fb_loaded' ) ) | |
| 703 | + return; | |
| 704 | + | |
| 744 | 705 | /* initiate the plugin notifications class */ |
| 745 | 706 | $notifications = WPPB_Plugin_Notifications::get_instance(); |
| 746 | 707 | /* this must be unique */ |
| 747 | - $notification_id = 'wppb_international_telephone_input_notification_pb'; | |
| 708 | + $notification_id = 'wppb_form_builder_transition_notification'; | |
| 748 | 709 | |
| 749 | - $docs_url = 'https://www.cozmoslabs.com/docs/profile-builder/manage-user-fields/international-telephone-input/'; | |
| 750 | - $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' ); | |
| 751 | 711 | |
| 752 | - $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' ); | |
| 753 | 715 | |
| 754 | - $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>'; | |
| 755 | 717 | |
| 756 | - if( defined( 'WPPB_PAID_PLUGIN_DIR' ) ) { | |
| 757 | - $extra_message = sprintf( | |
| 758 | - /* translators: 1: documentation link (HTML), 2: opening Form Fields link, 3: closing Form Fields link */ | |
| 759 | - __( '%1$s to set it up, or add the field under %2$sProfile Builder → Form Fields%3$s.', 'profile-builder' ), | |
| 760 | - $docs_link, | |
| 761 | - '<a href="' . esc_url( admin_url( 'admin.php?page=manage-fields' ) ) . '">', | |
| 762 | - '</a>' | |
| 763 | - ); | |
| 764 | - } else { | |
| 765 | - $extra_message = sprintf( | |
| 766 | - /* translators: 1: documentation link (HTML), 2: opening upgrade link, 3: closing upgrade link */ | |
| 767 | - __( '%1$s. This field is available in Profile Builder Basic and Pro. %2$sUpgrade now%3$s to use it.', 'profile-builder' ), | |
| 768 | - $docs_link, | |
| 769 | - '<a href="' . esc_url( $buy_url ) . '" target="_blank" rel="noopener noreferrer">', | |
| 770 | - '</a>' | |
| 771 | - ); | |
| 772 | - } | |
| 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>'; | |
| 773 | 719 | |
| 774 | - $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>'; | |
| 775 | 728 | |
| 776 | - $ul_icon_url = ( file_exists( WPPB_PLUGIN_DIR . 'assets/images/pb-logo.svg' ) ) ? WPPB_PLUGIN_URL . 'assets/images/pb-logo.svg' : ''; | |
| 777 | - $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">' : ''; | |
| 778 | 731 | |
| 779 | - $message = $ul_icon; | |
| 780 | - $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>'; | |
| 781 | 735 | $message .= $notification_message; |
| 736 | + $message .= '</div>'; | |
| 782 | 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>'; |
| 783 | 738 | |
| 784 | - $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' ) ); | |
| 785 | 740 | |
| 786 | 741 | } |
| 787 | -add_action( 'admin_init', 'wppb_international_telephone_input_admin_notification' ); | |
| 742 | +add_action( 'admin_init', 'wppb_form_builder_transition_admin_notification' ); | |
| 788 | 743 | |
| 789 | 744 | /** |
| 790 | 745 | * Get the Profile Builder Page or Post slug |
| 791 | 746 | * |