button.button[data-name='custom_map'] { display: none; } ", [ 'style' => [], 'button' => [] ] ); } } } wp_enqueue_style( 'wpuf-sweetalert2', WPUF_ASSET_URI . '/vendor/sweetalert2/sweetalert2.css', [], '11.4.8' ); wp_enqueue_script( 'wpuf-sweetalert2', WPUF_ASSET_URI . '/vendor/sweetalert2/sweetalert2.js', [], '11.4.8', true ); wp_enqueue_script( 'wpuf-upload', WPUF_ASSET_URI . '/js/upload.js', ['jquery', 'plupload-handlers'] ); wp_localize_script( 'wpuf-upload', 'wpuf_frontend_upload', [ 'confirmMsg' => __( 'Are you sure?', 'wp-user-frontend' ), 'delete_it' => __( 'Yes, delete it', 'wp-user-frontend' ), 'cancel_it' => __( 'No, cancel it', 'wp-user-frontend' ), 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'wpuf_nonce' ), 'plupload' => [ 'url' => admin_url( 'admin-ajax.php' ) . '?nonce=' . wp_create_nonce( 'wpuf-upload-nonce' ), 'flash_swf_url' => includes_url( 'js/plupload/plupload.flash.swf' ), 'filters' => [['title' => __( 'Allowed Files', 'wp-user-frontend' ), 'extensions' => '*']], 'multipart' => true, 'urlstream_upload' => true, 'warning' => __( 'Maximum number of files reached!', 'wp-user-frontend' ), 'size_error' => __( 'The file you have uploaded exceeds the file size limit. Please try again.', 'wp-user-frontend' ), 'type_error' => __( 'You have uploaded an incorrect file type. Please try again.', 'wp-user-frontend' ), ], ] ); } /** * Meta box for all Post form selection * * Registers a meta box in public post types to select the desired WPUF * form select box to assign a form id. * * @since 2.5.2 * * @return void */ public function add_meta_box_form_select() { $post_types = get_post_types( ['public' => true] ); foreach ( $post_types as $post_type ) { add_meta_box( 'wpuf-select-form', __( 'WPUF Form', 'wp-user-frontend' ), [$this, 'form_selection_metabox'], $post_type, 'side', 'high' ); } } /** * Form selection meta box in post types * * Registered via $this->add_meta_box_form_select() * * @since 2.5.2 * * @global object $post */ public function form_selection_metabox() { global $post; $forms = get_posts( ['post_type' => 'wpuf_forms', 'numberposts' => '-1'] ); $selected = get_post_meta( $post->ID, '_wpuf_form_id', true ); ?>
ID; } $nonce = isset( $_POST['wpuf_form_select_nonce'] ) ? sanitize_key( wp_unslash( $_POST['wpuf_form_select_nonce'] ) ) : ''; if ( isset( $nonce ) && !wp_verify_nonce( $nonce , plugin_basename( __FILE__ ) ) ) { return $post->ID; } // Is the user allowed to edit the post or page? if ( !current_user_can( 'edit_post', $post->ID ) ) { return $post->ID; } $wpuf_form_select = isset( $_POST['wpuf_form_select'] ) ? sanitize_text_field( wp_unslash( $_POST['wpuf_form_select'] ) ) : ''; update_post_meta( $post->ID, '_wpuf_form_id', $wpuf_form_select ); } /** * Meta box for post lock * * Registers a meta box in public post types to select the desired WPUF * form select box to assign a form id. * * @since 3.0.2 * * @return void */ public function add_meta_box_post_lock() { $post_types = get_post_types( ['public' => true] ); foreach ( $post_types as $post_type ) { add_meta_box( 'wpuf-post-lock', __( 'WPUF Lock User', 'wp-user-frontend' ), [$this, 'post_lock_metabox'], $post_type, 'side', 'high' ); } } /** * Post lock meta box in post types * * Registered via $this->add_meta_box_post_lock() * * @since 3.0.2 * * @global object $post */ public function post_lock_metabox() { global $post; $msg = ''; $edit_post_lock = get_post_meta( $post->ID, '_wpuf_lock_editing_post', true ); $edit_post_lock_time = get_post_meta( $post->ID, '_wpuf_lock_user_editing_post_time', true ); if ( empty( $edit_post_lock_time ) ) { $is_locked = false; } if ( ( !empty( $edit_post_lock_time ) && $edit_post_lock_time < time() ) || $edit_post_lock == 'yes' ) { $is_locked = true; $msg = sprintf( // translators: %s is the Post ID __( 'Post is locked, to allow user to edit this post Click here', 'wp-user-frontend' ), $post->ID ); } if ( !empty( $edit_post_lock_time ) && $edit_post_lock_time > time() ) { $is_locked = false; $time = date( 'Y-m-d H:i:s', $edit_post_lock_time ); // phpcs:ignore $local_time = get_date_from_gmt( $time, get_option( 'date_format' ) . ' ' . get_option( 'time_format' ) ); $msg = sprintf( // translators: %1$s is local time and %2$ is Post ID __( 'Frontend edit access for this post will be automatically locked after %1$s, Clear Lock Or,', 'wp-user-frontend' ), $local_time, $post->ID ); } ?>[ 'href' => [], 'id' => [], 'data' => [], ] ] ); ?>
ID; } $nonce = isset( $_POST['wpuf_lock_editing_post_nonce'] ) ? sanitize_key( wp_unslash( $_POST['wpuf_lock_editing_post_nonce'] ) ) : ''; if ( isset( $nonce ) && !wp_verify_nonce( $nonce, plugin_basename( __FILE__ ) ) ) { return $post->ID; } // Is the user allowed to edit the post or page? if ( !current_user_can( 'edit_post', $post->ID ) ) { return $post->ID; } $wpuf_lock_post = isset( $_POST['wpuf_lock_post'] ) ? sanitize_text_field( wp_unslash( $_POST['wpuf_lock_post'] ) ) : ''; update_post_meta( $post->ID, '_wpuf_lock_editing_post', $wpuf_lock_post ); } /** * Meta box to show WPUF Custom Fields * * Registers a meta box in public post types to show WPUF Custom Fields * * @since 2.5 * * @return void */ public function add_meta_boxes() { $post_types = get_post_types( ['public' => true] ); foreach ( $post_types as $post_type ) { add_meta_box( 'wpuf-custom-fields', __( 'WPUF Custom Fields', 'wp-user-frontend' ), [$this, 'render_form'], $post_type, 'normal', 'high' ); } } /** * function to hide form custom field * * @since 2.5 * * @return void */ public function hide_form() { ?> ID, '_wpuf_form_id', true ); $form_settings = wpuf_get_form_settings( $form_id ); /** * There may be incompatibilities with WPUF metabox display when Advanced Custom Fields * is active. By default WPUF metaboxes will be hidden when ACF is detected. However, * you can override that by using the following filter. */ $hide_with_acf = class_exists( 'acf' ) ? apply_filters( 'wpuf_hide_meta_when_acf_active', true ) : false; $acf_enable = wpuf_get_option( 'wpuf_compatibility_acf', 'wpuf_general', 'yes' ); if ( 'yes' === $acf_enable && $hide_with_acf ) { $hide_with_acf = false; } // hide the metabox itself if no form ID is set if ( ! $form_id || $hide_with_acf ) { $this->hide_form(); return; } list( $post_fields, $taxonomy_fields, $custom_fields ) = $this->get_input_fields( $form_id ); if ( empty( $custom_fields ) ) { esc_html_e( 'No custom fields found.', 'wp-user-frontend' ); return; } ?>