function( $attributes, $content ) { ob_start(); do_action( 'wppb/login/render_callback', $attributes, $content ); return ob_get_clean(); }, ] ); add_action( 'admin_enqueue_scripts', function () { $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-login-editor-script', 'window.wppbLoginBlockConfig = ' . json_encode(array( 'wppb_paid' => defined( 'WPPB_PAID_PLUGIN_DIR' ), 'is_2fa_active' => wppb_is_2fa_active(), '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/login/render_callback', function( $attributes, $content ) { if ( isset($attributes['is_preview']) && $attributes['is_preview'] === 'true' ) { echo ' Login Block Preview '; } else { $atts = [ 'redirect_url' => $attributes['redirect_url'] !== '' ? ' redirect_url="' . esc_url( $attributes['redirect_url'] ) . '"' : '', 'logout_redirect_url' => $attributes['logout_redirect_url'] !== '' ? ' logout_redirect_url="' . esc_url( $attributes['logout_redirect_url'] ) . '"' : '', 'register_url' => $attributes['register_url'] !== '' ? ' register_url="' . esc_url( $attributes['register_url'] ) . '"' : '', 'lostpassword_url' => $attributes['lostpassword_url'] !== '' ? ' lostpassword_url="' . esc_url( $attributes['lostpassword_url'] ) . '"' : '', 'show_2fa_field' => $attributes['auth_field'] ? ' show_2fa_field="yes"' : '', 'block' => $attributes['is_editor'] ? ' block="true"' : '', 'ajax' => $attributes['ajax'] ? ' ajax="true"' : '', ]; echo '
' . do_shortcode( '[wppb-login' . $atts['redirect_url'] . $atts['logout_redirect_url'] . $atts['register_url'] . $atts['lostpassword_url'] . $atts['show_2fa_field'] . $atts['block'] . $atts['ajax'] . ' ]' ) . '
'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } } , 10, 2 );