Menus > Pages.
add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) );
// Add all available upgradable fields.
add_action( 'ur_after_other_form_fields_printed', array( $this, 'add_upgradable_other_fields' ) ); // Adds fields in the `Extra Fields` section.
add_action( 'user_registration_extra_fields', array( $this, 'add_upgradable_extra_fields' ) );
}
/**
* Add Upgradable other fields.
*/
public function add_upgradable_other_fields() {
$fields = array(
array(
'id' => 'user_registration_file',
'label' => 'File Upload',
'icon' => 'ur-icon ur-icon-file-upload',
'field_class' => 'UR_File',
'plan' => 'Personal Plan',
'slug' => 'file-upload',
'video_id' => 'pzhJ3qjQfC4',
'name' => __( 'User Registration - File Upload', 'user-registration' ),
),
array(
'id' => 'user_registration_invite_code',
'label' => 'Invitation Code',
'icon' => 'ur-icon ur-icon-invite-codes',
'field_class' => 'UR_Form_Field_Invite_Code',
'plan' => 'ThemeGrill Agency Plan or Professional Plan or Plus Plan',
'slug' => 'invite-codes',
'video_id' => 'IhqQLAc-yuQ',
'name' => __( 'User Registration Invite Codes', 'user-registration' ),
),
array(
'id' => 'user_registration_learndash',
'label' => 'LearnDash Course',
'icon' => 'ur-icon ur-icon-course',
'field_class' => 'UR_Form_Field_Learndash_Course',
'plan' => 'ThemeGrill Agency Plan or Professional Plan or Plus Plan',
'slug' => 'learndash',
'name' => __( 'User Registration LearnDash', 'user-registration' ),
),
array(
'id' => 'user_registration_stripe_gateway',
'label' => 'Stripe Gateway',
'icon' => 'ur-icon ur-icon-credit-card',
'field_class' => 'UR_Form_Field_Stripe_Gateway',
'plan' => 'ThemeGrill Agency Plan or Professional Plan or Plus Plan',
'video_id' => 'TxmXryAqhXE',
'slug' => array( 'stripe' ),
'name' => array( __( 'User Registration Stripe', 'user-registration' ) ),
),
);
foreach ( $fields as $field ) {
if ( 'user_registration_learndash' === $field['id'] ) {
if ( ! defined( 'LEARNDASH_VERSION' ) ) {
continue;
}
}
if ( ! class_exists( $field['field_class'] ) ) {
$this->render_upgradable_field( $field );
}
}
}
/**
* Add Upgradable extra fields.
*/
public function add_upgradable_extra_fields() {
$field_sections = array(
array(
'section_title' => 'Advanced Fields',
'fields_parent_class' => 'URAF_Admin',
'plan' => 'Personal Plan',
'slug' => 'advanced-fields',
'name' => __( 'User Registration-Advanced Fields', 'user-registration' ),
'fields' => array(
array(
'id' => 'user_registration_section_title',
'label' => 'Section Title',
'video_id' => 'fp04hfHF_zU',
'icon' => 'ur-icon ur-icon-section-title',
),
array(
'id' => 'user_registration_html',
'label' => 'HTML',
'video_id' => 'vuQhnp2s24U',
'icon' => 'ur-icon ur-icon-code',
),
array(
'id' => 'user_registration_timepicker',
'label' => 'Time Picker',
'video_id' => 'Z8F7h9_d_rc',
'icon' => 'ur-icon ur-icon-time-picker',
),
array(
'id' => 'user_registration_phone',
'label' => 'Phone',
'video_id' => '3yS0s1LYI-I',
'icon' => 'ur-icon ur-icon-phone',
),
array(
'id' => 'user_registration_wysiwyg',
'label' => 'WYSIWYG',
'video_id' => 'LR_RZ8Xn1RA',
'icon' => 'ur-icon ur-icon-text-editor',
),
array(
'id' => 'user_registration_select2',
'label' => 'Select2',
'video_id' => 'wzcUYN-ToTA',
'icon' => 'ur-icon ur-icon-select2',
),
array(
'id' => 'user_registration_multi_select2',
'label' => 'Multi Select2',
'video_id' => '6o1beUJ26b8',
'icon' => 'ur-icon ur-icon-multi-select',
),
array(
'id' => 'user_registration_profile_picture',
'label' => 'Profile Picture',
'video_id' => 'Ev-_bnuVaGQ',
'icon' => 'ur-icon ur-icon-user-display-name',
),
array(
'id' => 'user_registration_range',
'label' => 'Range',
'video_id' => 'MCfHeWGIOmk',
'icon' => 'ur-icon ur-icon-range',
),
array(
'id' => 'user_registration_custom_url',
'label' => 'Custom URL',
'video_id' => 'yei0lH9esaQ',
'icon' => 'ur-icon ur-icon-website',
),
array(
'id' => 'user_registration_hidden',
'label' => 'Hidden Field',
'video_id' => 'WtLSzeL17-s',
'icon' => 'ur-icon ur-icon-hidden-field',
),
),
),
array(
'section_title' => 'WooCommerce Billing Address',
'fields_parent_class' => 'URWC_Admin',
'plan' => 'Personal Plan',
'slug' => 'woocommerce',
'name' => __( 'User Registration - WooCommerce', 'user-registration' ),
'fields' => array(
array(
'id' => 'user_registration_billing_address_title',
'label' => 'Billing Address',
'video_id' => 'CujmKsb6zTk',
'icon' => 'ur-icon ur-icon-bill',
),
array(
'id' => 'user_registration_billing_country',
'label' => 'Country',
'video_id' => '6POWImSKKMI',
'icon' => 'ur-icon ur-icon-flag',
),
array(
'id' => 'user_registration_billing_first_name',
'label' => 'First Name',
'video_id' => 'MmBF9WH3bG4',
'icon' => 'ur-icon ur-icon-input-first-name',
),
array(
'id' => 'user_registration_billing_last_name',
'label' => 'Last Name',
'video_id' => 'ZprJivoQmYk',
'icon' => 'ur-icon ur-icon-input-last-name',
),
array(
'id' => 'user_registration_billing_company',
'label' => 'Company',
'video_id' => 'fdK38cCrybI',
'icon' => 'ur-icon ur-icon-buildings',
),
array(
'id' => 'user_registration_billing_address_1',
'label' => 'Address 1',
'video_id' => 'CujmKsb6zTk',
'icon' => 'ur-icon ur-icon-map-one',
),
array(
'id' => 'user_registration_billing_address_2',
'label' => 'Address 2',
'video_id' => 'CujmKsb6zTk',
'icon' => 'ur-icon ur-icon-map-two',
),
array(
'id' => 'user_registration_billing_city',
'label' => 'Town / City',
'video_id' => '224NTyvz5-g',
'icon' => 'ur-icon ur-icon-buildings',
),
array(
'id' => 'user_registration_billing_state',
'label' => 'State / County',
'video_id' => 'YtamDyhfFcc',
'icon' => 'ur-icon ur-icon-state',
),
array(
'id' => 'user_registration_billing_postcode',
'label' => 'Postcode / Zip',
'video_id' => 'sgaJNqkrX4E',
'icon' => 'ur-icon ur-icon-zip-code',
),
array(
'id' => 'user_registration_billing_email',
'label' => 'Email',
'video_id' => '3LV1lYJZ4k0',
'icon' => 'ur-icon ur-icon-email',
),
array(
'id' => 'user_registration_billing_phone',
'label' => 'Phone',
'video_id' => 'mU9k3EufPUQ',
'icon' => 'ur-icon ur-icon-phone',
),
array(
'id' => 'user_registration_separate_shipping',
'label' => 'Separate Shipping',
'video_id' => '4ZA6byVHm30',
'icon' => 'ur-icon ur-icon-bill',
),
),
),
array(
'section_title' => 'WooCommerce Shipping Address',
'fields_parent_class' => 'URWC_Admin',
'plan' => 'Personal Plan',
'slug' => 'woocommerce',
'name' => __( 'User Registration - WooCommerce', 'user-registration' ),
'fields' => array(
array(
'id' => 'user_registration_shipping_address_title',
'label' => 'Shipping Address',
'video_id' => 'CujmKsb6zTk',
'icon' => 'ur-icon ur-icon-bill',
),
array(
'id' => 'user_registration_shipping_country',
'label' => 'Country',
'video_id' => '6POWImSKKMI',
'icon' => 'ur-icon ur-icon-flag',
),
array(
'id' => 'user_registration_shipping_first_name',
'label' => 'First Name',
'video_id' => 'MmBF9WH3bG4',
'icon' => 'ur-icon ur-icon-input-first-name',
),
array(
'id' => 'user_registration_shipping_last_name',
'label' => 'Last Name',
'video_id' => 'ZprJivoQmYk',
'icon' => 'ur-icon ur-icon-input-last-name',
),
array(
'id' => 'user_registration_shipping_company',
'label' => 'Company',
'video_id' => 'fdK38cCrybI',
'icon' => 'ur-icon ur-icon-buildings',
),
array(
'id' => 'user_registration_shipping_address_1',
'label' => 'Address 1',
'video_id' => 'CujmKsb6zTk',
'icon' => 'ur-icon ur-icon-map-one',
),
array(
'id' => 'user_registration_shipping_address_2',
'label' => 'Address 2',
'video_id' => 'CujmKsb6zTk',
'icon' => 'ur-icon ur-icon-map-two',
),
array(
'id' => 'user_registration_shipping_city',
'label' => 'Town / City',
'video_id' => '224NTyvz5-g',
'icon' => 'ur-icon ur-icon-buildings',
),
array(
'id' => 'user_registration_shipping_state',
'label' => 'State / County',
'video_id' => 'YtamDyhfFcc',
'icon' => 'ur-icon ur-icon-state',
),
array(
'id' => 'user_registration_shipping_postcode',
'label' => 'Postcode / Zip',
'video_id' => 'sgaJNqkrX4E',
'icon' => 'ur-icon ur-icon-zip-code',
),
),
),
array(
'section_title' => 'Payment Fields',
'fields_parent_class' => 'User_Registration_Payments_Admin',
'plan' => 'ThemeGrill Agency Plan or Professional Plan or Plus Plan',
'slug' => array( 'payments', 'stripe' ),
'name' => array( __( 'User Registration Payments', 'user-registration' ), __( 'User Registration Stripe', 'user-registration' ) ),
'fields' => array(
array(
'id' => 'user_registration_single_item',
'label' => 'Single Item',
'video_id' => 'xH_lLxg8zsQ',
'icon' => 'ur-icon ur-icon-file-dollar',
),
array(
'id' => 'user_registration_multiple_choice',
'label' => 'Multiple Choice',
'video_id' => '_vu87WQBbx8',
'icon' => 'ur-icon ur-icon-multichoice',
),
array(
'id' => 'user_registration_subscription_plan',
'label' => 'Subscription Plan',
'video_id' => 'h__3fJu5Bvo',
'icon' => 'ur-icon ur-icon-subscription-plan',
),
array(
'id' => 'user_registration_total',
'label' => 'Total',
'video_id' => 'wsaxpXXbE6c',
'icon' => 'ur-icon ur-icon-total',
),
array(
'id' => 'user_registration_quantity',
'label' => 'Quantity',
'video_id' => 'Hjml64__-6c',
'icon' => 'ur-icon ur-icon-quantity',
),
),
),
);
foreach ( $field_sections as $section ) {
$class_to_check = $section['fields_parent_class'];
if ( ! class_exists( $class_to_check ) ) {
$fields = $section['fields'];
$plan = isset( $section['plan'] ) ? $section['plan'] : '';
$slug = isset( $section['slug'] ) ? $section['slug'] : '';
$name = isset( $section['name'] ) ? $section['name'] : '';
$fields_count = count( $fields );
// Set the same plan for all the section's fields.
for ( $i = 0; $i < $fields_count; $i++ ) {
$fields[ $i ]['plan'] = $plan;
$fields[ $i ]['slug'] = $slug;
$fields[ $i ]['name'] = $name;
}
echo '
' . esc_html( $section['section_title'] ) . ' ';
echo ' ';
$this->render_upgradable_fields( $fields );
echo ' ';
}
}
}
/**
* Render multiple upgradable fields.
*
* @param array $fields Field.
*/
public function render_upgradable_fields( $fields ) {
foreach ( $fields as $field ) {
$this->render_upgradable_field( $field );
}
}
/**
* Render an upgradable field.
*
* @param array $args Args Data.
*/
public function render_upgradable_field( $args ) {
$id = $args['id'];
$icon = $args['icon'];
$label = $args['label'];
$plan = isset( $args['plan'] ) ? $args['plan'] : '';
$video_id = isset( $args['video_id'] ) ? $args['video_id'] : '';
$name = isset( $args['name'] ) ? ( is_array( $args['name'] ) ? implode( ', and ', $args['name'] ) : $args['name'] ) : '';
if ( isset( $args['slug'] ) ) {
if ( is_array( $args['slug'] ) ) {
$new_args_slug = array();
foreach ( $args['slug'] as $args_slug ) {
array_push( $new_args_slug, 'user-registration-' . $args_slug );
}
$slug = implode( ' ', $new_args_slug );
} else {
$slug = 'user-registration-' . $args['slug'];
}
}
echo ' ' . esc_html( $label ) . ' ';
}
/**
* Returns a base64 URL for the SVG for use in the menu.
*
* @param bool $base64 Whether or not to return base64-encoded SVG.
* @return string
*/
private function get_icon_svg( $base64 = true ) {
$svg = ' ';
if ( $base64 ) {
return 'data:image/svg+xml;base64,' . base64_encode( $svg );
}
return $svg;
}
/**
* Add menu items.
*/
public function admin_menu() {
$registration_page = add_menu_page( 'User Registration', 'User Registration & Membership', 'manage_user_registration', 'user-registration', array( $this, 'registration_page' ), $this->get_icon_svg(), '55.8' );
add_action( 'load-' . $registration_page, array( $this, 'registration_page_init' ) );
add_submenu_page(
'user-registration',
__( 'All Forms', 'user-registration' ),
__( 'All Forms', 'user-registration' ),
'manage_user_registration',
'user-registration',
array(
$this,
'registration_page',
)
);
if ( isset( $_GET['page'] ) && ( 'user-registration' === $_GET['page'] || 'user-registration-registration-forms' === $_GET['page'] || 'user-registration-login-forms' === $_GET['page'] ) ) {
add_submenu_page( 'user-registration', __( 'Registration Forms', 'user-registration' ), ' ⤷ ' . __( 'Registration Forms', 'user-registration' ), 'manage_user_registration', 'user-registration', array( $this, 'registration_page' ) );
add_submenu_page( 'user-registration', __( 'Login Form', 'user-registration' ), ' ⤷ ' . __( 'Login Form', 'user-registration' ), 'manage_user_registration', 'user-registration-login-forms', array( $this, 'registration_page' ) );
}
}
/**
* Loads screen options into memory.
*/
public function registration_page_init() {
global $registration_table_list;
if ( ! isset( $_GET['add-new-registration'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification
$registration_table_list = new UR_Admin_Registrations_Table_List();
$registration_table_list->process_actions();
// Add screen option.
add_screen_option(
'per_page',
array(
'default' => 20,
'option' => 'user_registration_per_page',
)
);
}
}
/**
* Add settings menu item.
*/
public function settings_menu() {
add_submenu_page(
'user-registration',
__( 'User Registration settings', 'user-registration' ),
__( 'Settings', 'user-registration' ),
'manage_user_registration',
'user-registration-settings',
array(
$this,
'settings_page',
)
);
}
/**
* Add status menu item.
*/
public function status_menu() {
add_submenu_page(
'user-registration',
__( 'User Registration Tools', 'user-registration' ),
__( 'Tools', 'user-registration' ),
'manage_user_registration',
'user-registration-status',
array(
$this,
'status_page',
)
);
}
/**
* Add dashboard sub menu.
*/
public function dashboard_menu() {
add_submenu_page(
'user-registration',
__( 'User Registration Dashboard', 'user-registration' ),
__( 'Dashboard', 'user-registration' ),
'manage_user_registration',
'user-registration-dashboard',
array(
$this,
'dashboard_page',
),
-1
);
}
/**
* Add new registration menu items.
*/
public function add_registration_menu() {
add_submenu_page(
'user-registration',
esc_html__( 'Add New', 'user-registration' ),
esc_html__( 'Add New', 'user-registration' ),
'manage_user_registration',
'add-new-registration',
array(
$this,
'add_registration_page',
)
);
}
/**
* Upgrade to pro menu items.
*/
public function user_registration_upgrade_to_pro_menu() {
add_submenu_page(
'user-registration',
esc_html__( 'Upgrade to Pro', 'user-registration' ),
sprintf(
'%s ',
esc_html__( 'Upgrade to Pro', 'user-registration' )
),
'manage_options',
esc_url_raw( 'https://wpuserregistration.com/pricing/?utm_source=ur-submenu&utm_medium=upgrade-link&utm_campaign=' . UR()->utm_campaign )
);
}
/**
* Addons menu item.
*/
public function addons_menu() {
add_submenu_page(
'user-registration',
__( 'User Registration extensions', 'user-registration' ),
sprintf( '%s ', esc_html__( 'Extensions', 'user-registration' ) ),
'manage_options',
'user-registration-addons',
array( $this, 'redirect_to_addons_page' )
);
}
/**
* Addons page redirection.
*/
public function redirect_to_addons_page() {
wp_safe_redirect( esc_url_raw( admin_url( 'admin.php?page=user-registration-dashboard#features' ) ) );
exit;
}
/**
* Validate screen options on update.
*
* @param mixed $status Status.
* @param mixed $option Option.
* @param mixed $value Value.
*/
public function set_screen_option( $status, $option, $value ) {
if ( in_array( $option, array( 'user_registration_per_page' ), true ) ) {
return $value;
}
return $status;
}
/**
* Init the settings page.
*/
public function registration_page() {
global $registration_table_list;
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
if ( isset( $_GET['page'] ) && 'user-registration-login-forms' === $_GET['page'] ) { //phpcs:ignore WordPress.Security.NonceVerification
wp_enqueue_script( 'user-registration-settings', UR()->plugin_url() . '/assets/js/admin/settings' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker', 'jquery-ui-sortable', 'iris', 'tooltipster' ), UR_VERSION, true );
wp_enqueue_script( 'user-registration-login-settings', UR()->plugin_url() . '/assets/js/admin/login-settings' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker', 'jquery-ui-sortable', 'iris', 'tooltipster' ), UR_VERSION, true );
wp_enqueue_style( 'user-registration-css', UR()->plugin_url() . '/assets/css/user-registration.css', array(), UR_VERSION );
$ur_login_form_params = array(
'ajax_url' => admin_url( 'admin-ajax.php' ),
'ur_login_settings_save' => wp_create_nonce( 'ur_login_settings_save_nonce' ),
'login_settings' => get_login_options_settings(),
'is_login_settings_page' => isset( $_GET['page'] ) && 'user-registration-login-forms' === $_GET['page'] ? true : false,
'i18n_admin' => array(
'i18n_settings_successfully_saved' => _x( 'Settings successfully saved.', 'user registration admin', 'user-registration' ),
'i18n_success' => _x( 'Success', 'user registration admin', 'user-registration' ),
'i18n_error' => _x( 'Error', 'user registration admin', 'user-registration' ),
),
'user_registration_lost_password_selection_validator_nonce' => wp_create_nonce( 'user_registration_lost_password_selection_validator' ),
'user_registration_membership_redirect_default_page_message' => esc_html__( 'Please select a page for redirection', 'user-registration' ),
);
wp_localize_script(
'user-registration-login-settings',
'ur_login_form_params',
$ur_login_form_params
);
wp_localize_script(
'user-registration-settings',
'ur_login_form_params',
array(
'user_registration_my_account_selection_validator_nonce' => wp_create_nonce( 'user_registration_my_account_selection_validator' ),
)
);
$login_form_settings = get_login_options_settings();
include_once __DIR__ . '/views/html-login-page-forms.php';
} else {
$registration_table_list->display_page();
}
}
/**
* Init the add registration page.
*/
public function add_registration_page() {
$form_id = isset( $_GET['edit-registration'] ) ? absint( $_GET['edit-registration'] ) : 0; //phpcs:ignore WordPress.Security.NonceVerification
$form_data = ( $form_id ) ? UR()->form->get_form( $form_id ) : array();
$save_label = __( 'Create Form', 'user-registration' );
if ( ! empty( $form_data ) ) {
$save_label = __( 'Update form', 'user-registration' );
$preview_link = add_query_arg(
array(
'ur_preview' => 'true',
'form_id' => $form_id,
),
home_url()
);
}
if ( isset( $_GET['onboarding-skipped'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
update_option( 'user_registration_onboarding_skipped', true );
}
wp_enqueue_script( 'ur-setup' );
wp_localize_script(
'ur-setup',
'ur_setup_params',
array(
'ajax_url' => admin_url( 'admin-ajax.php' ),
'create_form_nonce' => wp_create_nonce( 'user_registration_create_form' ),
'template_licence_check_nonce' => wp_create_nonce( 'user_registration_template_licence_check' ),
'captcha_setup_check_nonce' => wp_create_nonce( 'user_registration_captcha_setup_check' ),
'i18n_form_name' => esc_html__( 'Give it a name.', 'user-registration' ),
'i18n_form_error_name' => esc_html__( 'You must provide a Form name', 'user-registration' ),
'i18n_install_only' => esc_html__( 'Activate Plugins', 'user-registration' ),
'i18n_activating' => esc_html__( 'Activating', 'user-registration' ),
'i18n_activating_text' => esc_html__( 'Please wait until the plugin is being activated', 'user-registration' ),
'i18n_install_activate' => esc_html__( 'Install & Activate', 'user-registration' ),
'i18n_installing' => esc_html__( 'Installing', 'user-registration' ),
'i18n_ok' => esc_html__( 'OK', 'user-registration' ),
/**
* Filter the Upgrade URL
*
* @param string Upgrade URL
*/
'upgrade_url' => apply_filters( 'user_registration_upgrade_url', 'https://wpuserregistration.com/pricing/?utm_source=form-template&utm_medium=button&utm_campaign=' . UR()->utm_campaign ),
'upgrade_button' => esc_html__( 'Upgrade Plan', 'user-registration' ),
'upgrade_message' => esc_html__( 'This template requires premium addons. Please upgrade to the Premium plan to unlock all these awesome Templates.', 'user-registration' ),
'upgrade_title' => esc_html__( 'is a Premium Template', 'user-registration' ),
'i18n_form_ok' => esc_html__( 'Continue', 'user-registration' ),
'i18n_form_placeholder' => esc_html__( 'Untitled Form', 'user-registration' ),
'i18n_form_title' => esc_html__( 'Uplift your form experience to the next level.', 'user-registration' ),
'download_failed' => esc_html__( 'Download Failed. Please download and activate addon manually.', 'user-registration' ),
'download_successful_title' => esc_html__( 'Installation Successful.', 'user-registration' ),
'download_successful_message' => esc_html__( 'Addons have been installed and Activated. You have to reload the page.', 'user-registration' ),
'save_changes_text' => esc_html__( 'Save Changes and Reload', 'user-registration' ),
'save_changes_warning' => esc_html__( 'Save changes before activating the plugin', 'user-registration' ),
'reload_text' => esc_html__( 'Just Reload', 'user-registration' ),
)
);
if ( isset( $_GET['edit-registration'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
// Forms view.
include_once __DIR__ . '/views/html-admin-page-forms.php';
} else {
UR_Admin_Form_Templates::load_template_view();
}
// Forms view.
include_once __DIR__ . '/views/html-admin-page-forms.php';
}
/**
* Init the settings page.
*/
public function settings_page() {
UR_Admin_Settings::output();
}
/**
* Init the status page.
*/
public function status_page() {
UR_Admin_Status::output();
}
/**
* Init the dashboard page.
*/
public function dashboard_page() {
UR_Admin_Dashboard::output();
}
/**
* Add custom nav meta box.
*
* Adapted from http://www.johnmorrisonline.com/how-to-add-a-fully-functional-custom-meta-box-to-wordpress-navigation-menus/.
*/
public function add_nav_menu_meta_boxes() {
add_meta_box(
'user_registration_endpoints_nav_link',
__( 'User Registration endpoints', 'user-registration' ),
array(
$this,
'nav_menu_links',
),
'nav-menus',
'side',
'low'
);
}
/**
* Output menu links.
*/
public function nav_menu_links() {
// Get items from account menu.
$endpoints = ur_get_account_menu_items();
// Remove dashboard item.
if ( isset( $endpoints['dashboard'] ) ) {
unset( $endpoints['dashboard'] );
}
// Include missing lost password.
$endpoints['ur-lost-password'] = __( 'Lost password', 'user-registration' );
/**
* Filter to get the custom Navigation Menu Endpoints
*
* @param array $endpoints Endpoints
*/
$endpoints = apply_filters( 'user_registration_custom_nav_menu_items', $endpoints );
?>
post_content;
$form_row_ids = get_post_meta( $form_data->ID, 'user_registration_form_row_ids', true );
$form_row_data = get_post_meta( $form_data->ID, 'user_registration_form_row_data', true );
} else {
$form_data_content = '';
$form_row_ids = '';
$form_row_data = '';
}
try {
$form_data_content = str_replace( '"noopener noreferrer"', "'noopener noreferrer'", $form_data_content );
$form_data_array = json_decode( $form_data_content );
if ( json_last_error() !== JSON_ERROR_NONE ) {
throw new Exception( '' );
}
} catch ( Exception $e ) {
$form_data_array = array();
}
try {
$form_row_ids_array = json_decode( $form_row_ids );
if ( json_last_error() !== JSON_ERROR_NONE ) {
throw new Exception( '' );
}
} catch ( Exception $e ) {
$form_row_ids_array = array();
}
try {
$form_row_data_array = json_decode( $form_row_data, true );
if ( json_last_error() !== JSON_ERROR_NONE ) {
throw new Exception( esc_html__( 'Row data not found', 'user-registration' ) );
}
} catch ( Exception $e ) {
$form_row_data_array = array();
}
echo '';
echo '';
echo '';
}
/**
* Get admin field.
*
* @param object $single_field Single field.
* @throws Exception Throw exception if empty form data.
*/
public static function get_admin_field( $single_field ) {
if ( empty( $single_field->field_key ) ) {
throw new Exception( esc_html__( 'Empty form data', 'user-registration' ) );
}
$class_name = 'UR_Form_Field_' . ucwords( $single_field->field_key );
if ( class_exists( $class_name ) ) {
return $class_name::get_instance()->get_admin_template( $single_field ); // @codingStandardsIgnoreLine
}
/* Backward Compat since 1.4.0 */
$class_name_old = 'UR_' . ucwords( $single_field->field_key );
if ( class_exists( $class_name_old ) ) {
return $class_name_old::get_instance()->get_admin_template( $single_field );
}
/* Backward compat end */
}
/**
* Get registered user form fields.
*/
private function get_registered_user_form_fields() {
$registered_form_fields = ur_get_user_field_only();
echo ' ';
foreach ( $registered_form_fields as $field ) {
$this->ur_get_list( $field );
}
echo ' ';
}
/**
* Get Registered other form field.
*/
private function get_registered_other_form_fields() {
$registered_form_fields = ur_get_other_form_fields();
echo ' ';
foreach ( $registered_form_fields as $field ) {
$this->ur_get_list( $field );
}
/**
* Action to perform after printing other form field
*/
do_action( 'ur_after_other_form_fields_printed' );
echo ' ';
}
/**
* Get Admin field List.
*
* @param mixed $field Fields.
*/
public function ur_get_list( $field ) {
$class_name = ur_load_form_field_class( $field );
if ( null !== $class_name ) {
echo wp_kses_post( $class_name::get_instance()->get_registered_admin_fields() );
}
}
}
endif;
return new UR_Admin_Menus();