function( $attributes, $content ) { ob_start(); do_action( 'wppb/edit_profile/render_callback', $attributes, $content ); return ob_get_clean(); }, ] ); add_action( 'admin_enqueue_scripts', function () { $wppb_module_settings = get_option( 'wppb_module_settings', 'not_found' ); $registration_form_options[] = [ "label" => __( 'Default' , 'profile-builder' ), "value" => "" ]; if ( !( ( $wppb_module_settings !== 'not_found' && ( !isset( $wppb_module_settings['wppb_multipleEditProfileForms'] ) || $wppb_module_settings['wppb_multipleEditProfileForms'] !== 'show' ) ) || $wppb_module_settings === 'not_found' ) ){ $args = array( 'post_type' => 'wppb-epf-cpt', 'posts_per_page' => -1 ); $the_query = new WP_Query( $args ); if ( $the_query->have_posts() ) { foreach ( $the_query->posts as $post ) { $registration_form_options[] = [ "label" => esc_html( $post->post_title ) , "value" => esc_attr( Wordpress_Creation_Kit_PB::wck_generate_slug( $post->post_title ) ) ]; } wp_reset_postdata(); } } $args = array( 'post_type' => 'page', 'posts_per_page' => -1 ); if( function_exists( 'wc_get_page_id' ) ) $args['exclude'] = wc_get_page_id( 'shop' ); $all_pages = get_posts( $args ); $url_options[] = [ "label" => "", "value" => "" ]; if( !empty( $all_pages ) ) { foreach ( $all_pages as $page ) { $url_options[] = [ "label" => esc_html( $page->post_title ) , "value" => esc_url( get_page_link( $page->ID ) ) ]; } } // Add pre-loaded data for my-namespace/my-block wp_add_inline_script('wppb-register-editor-script', 'window.wppbEditProfileBlockConfig = ' . json_encode(array( 'wppb_paid' => defined( 'WPPB_PAID_PLUGIN_DIR' ), 'edit_profile_form_options' => $registration_form_options, 'button' => esc_url( admin_url( 'edit.php?post_type=wppb-epf-cpt' ) ), 'url_options' => $url_options, )), 'before'); } ); /** * Render: PHP. * * @param array $attributes Optional. Block attributes. Default empty array. * @param string $content Optional. Block content. Default empty string. */ add_action( 'wppb/edit_profile/render_callback', function( $attributes, $content ) { if ( isset($attributes['is_preview']) && $attributes['is_preview'] === 'true' ) { echo ' Edit Profile Block Preview '; } else { $form_name = ''; if ( array_key_exists( 'form_name', $attributes ) ) { $form_name = $attributes['form_name']; } if ( !$form_name || $form_name === '' ) { $atts = [ 'form_name' => '', 'redirect_url' => $attributes['redirect_url'] !== '' ? ' redirect_url="' . esc_url( $attributes['redirect_url'] ) . '"' : '', 'ajax' => $attributes['ajax'] ? ' ajax="true"' : '', ]; } else { $atts = [ 'form_name' => ' form_name="' . $form_name . '"', 'redirect_url' => '', 'ajax' => ' ajax="multiple-register-form"', ]; } echo '
' . do_shortcode( '[wppb-edit-profile' . $atts['form_name'] . $atts['redirect_url'] . $atts['ajax'] . ' ]' ) . '
'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } } , 10, 2 );