__( 'Registration Form', 'profile-builder'), 'singular_name' => __( 'Registration Form', 'profile-builder'), 'add_new' => __( 'Add New', 'profile-builder' ), 'add_new_item' => __( 'Add new Registration Form', 'profile-builder' ), 'edit_item' => __( 'Edit the Registration Forms', 'profile-builder' ) , 'new_item' => __( 'New Registration Form', 'profile-builder' ), 'all_items' => __( 'Registration Forms', 'profile-builder' ), 'view_item' => __( 'View the Registration Form', 'profile-builder' ), 'search_items' => __( 'Search the Registration Forms', 'profile-builder' ), 'not_found' => __( 'No Registration Form found', 'profile-builder' ), 'not_found_in_trash' => __( 'No Registration Forms found in trash', 'profile-builder' ), 'parent_item_colon' => '', 'menu_name' => __( 'Registration Forms', 'profile-builder' ) ); $args = array( 'labels' => $labels, 'public' => false, 'publicly_queryable' => false, 'show_ui' => true, 'query_var' => true, 'show_in_menu' => 'profile-builder', 'has_archive' => false, 'hierarchical' => false, 'capability_type' => 'post', 'supports' => array( 'title' ) ); /* Free installs get the default forms only -- see form-builder-licensing.php. Same override the modern registration applies, so the gate holds in classic editor mode too. */ $wppb_fb_cap_overrides = function_exists( 'wppb_fb_form_cpt_capability_overrides' ) ? wppb_fb_form_cpt_capability_overrides() : array(); if ( ! empty( $wppb_fb_cap_overrides ) ) $args['capabilities'] = $wppb_fb_cap_overrides; /* hide from admin bar for non administrators */ if( !current_user_can( 'manage_options' ) ) $args['show_in_admin_bar'] = false; $wppb_addonOptions = get_option('wppb_module_settings'); if( !empty( $wppb_addonOptions['wppb_multipleRegistrationForms'] ) && $wppb_addonOptions['wppb_multipleRegistrationForms'] == 'show' ) register_post_type( 'wppb-rf-cpt', $args ); } add_action( 'init', 'wppb_create_registration_forms_cpt', 9); /* Register Form change classes based on Redirect field start */ add_filter( 'wck_add_form_class_wppb_rf_page_settings', 'wppb_register_add_form_change_class_based_on_redirect_field', 10, 3 ); function wppb_register_add_form_change_class_based_on_redirect_field($wck_update_container_css_class, $meta, $results ) { if( !empty( $results ) ){ $redirect = Wordpress_Creation_Kit_PB::wck_generate_slug( $results[0]["redirect"] ); return "update_container_$meta update_container_$redirect redirect_$redirect"; } } /* Register Form change classes based on Redirect field end */ /** * Remove view/trash row actions for Register Forms. * * @param array $actions * @return array */ function wppb_remove_rf_view_link( $actions ){ global $post; if ( ! empty( $post ) ) { if ( $post->post_type == 'wppb-rf-cpt' ){ unset( $actions['view'] ); if ( wppb_get_post_number ( $post->post_type, 'singular_action' ) ) unset( $actions['trash'] ); } } return $actions; } add_filter( 'post_row_actions', 'wppb_remove_rf_view_link', 10, 1 ); /** * Remove view/trash bulk actions for Register Forms. * * @param array $actions * @return array */ function wppb_remove_trash_bulk_option_rf( $actions ){ global $post; if( !empty( $post ) ){ if ( $post->post_type == 'wppb-rf-cpt' ){ unset( $actions['view'] ); if ( wppb_get_post_number ( $post->post_type, 'bulk_action' ) ) unset( $actions['trash'] ); } } return $actions; } add_filter( 'bulk_actions-edit-wppb-rf-cpt', 'wppb_remove_trash_bulk_option_rf' ); /** Hide publishing UI chrome on Register Form edit screens. */ function wppb_hide_rf_publishing_actions(){ global $post; if ( $post->post_type == 'wppb-rf-cpt' ){ echo ''; $rf = get_posts( array( 'posts_per_page' => -1, 'post_status' => apply_filters ( 'wppb_check_singular_rf_form_publishing_options', array( 'publish' ) ) , 'post_type' => 'wppb-rf-cpt' ) ); if ( count( $rf ) == 1 ) echo ''; } } add_action('admin_head-post.php', 'wppb_hide_rf_publishing_actions'); add_action('admin_head-post-new.php', 'wppb_hide_rf_publishing_actions'); /** * Add Shortcode column to Register Forms list. * * @param array $columns * @return array */ function wppb_add_extra_column_for_rf( $columns ){ $columns['rf-shortcode'] = __( 'Shortcode', 'profile-builder' ); return $columns; } add_filter( 'manage_wppb-rf-cpt_posts_columns', 'wppb_add_extra_column_for_rf' ); /** * Render Shortcode column content for Register Forms. * * @param string $column_name * @param integer $post_id */ function wppb_rf_custom_column_content( $column_name, $post_id ){ if( $column_name == 'rf-shortcode' ){ $post = get_post( $post_id ); if( empty( $post->post_title ) ) $post->post_title = __( '(no title)', 'profile-builder' ); // Default forms embed via a bare [wppb-register]; custom forms // keep their title-derived form_name. wppb_fb_build_form_shortcode() // owns that distinction. $shortcode = function_exists( 'wppb_fb_build_form_shortcode' ) ? wppb_fb_build_form_shortcode( $post ) : '[wppb-register form_name="' . Wordpress_Creation_Kit_PB::wck_generate_slug( $post->post_title ) . '"]'; // An unpublished form has no working shortcode (the front-end resolver is // publish-only), so offer a hint instead of an empty copy field. if ( $shortcode === '' ) { echo '— ' . esc_html__( 'available after publishing', 'profile-builder' ) . ''; return; } echo ""; echo ""; } } add_action("manage_wppb-rf-cpt_posts_custom_column", "wppb_rf_custom_column_content", 10, 2); /** * Add side metaboxes * * @since v.2.0 * * @return void */ function wppb_rf_content(){ global $post; $shortcode = function_exists( 'wppb_fb_build_form_shortcode' ) ? wppb_fb_build_form_shortcode( $post ) : '[wppb-register form_name="' . trim( Wordpress_Creation_Kit_PB::wck_generate_slug( $post->post_title ) ) . '"]'; $is_default = function_exists( 'wppb_fb_is_default_form' ) && wppb_fb_is_default_form( $post ); if ( $shortcode === '' ) { echo '
NOTE: ' . esc_html__( 'The shortcode will be available after you publish this form.', 'profile-builder' ) . '
'; } else { echo '' . esc_html__( 'Use this shortcode on the page you want the form to be displayed.', 'profile-builder' ) . '
'; echo ''. wp_kses_post( __( 'NOTE: Changing the form title also changes the shortcode!', 'profile-builder' ) ) .'
'; } echo '