__( 'Default' ), ); break; case 'donation_limit': $field['type'] = 'donation_limit'; break; } // End switch(). // CMB2 compatibility: Add support to define field description by desc & description param. // We encourage you to use description param. $field['description'] = ( ! empty( $field['description'] ) ? $field['description'] : ( ! empty( $field['desc'] ) ? $field['desc'] : '' ) ); // Call render function. if ( is_array( $func_name ) ) { $func_name[0]->{$func_name[1]}( $field ); } else { $func_name( $field ); } return true; } /** * Output a text input box. * * @since 1.8 * * @param array $field { * Optional. Array of text input field arguments. * * @type string $id Field ID. Default ''. * @type string $style CSS style for input field. Default ''. * @type string $wrapper_class CSS class to use for wrapper of input field. Default ''. * @type string $value Value of input field. Default ''. * @type string $name Name of input field. Default ''. * @type string $type Type of input field. Default 'text'. * @type string $before_field Text/HTML to add before input field. Default ''. * @type string $after_field Text/HTML to add after input field. Default ''. * @type string $data_type Define data type for value of input to filter it properly. Default ''. * @type string $description Description of input field. Default ''. * @type array $attributes List of attributes of input field. Default array(). * for example: 'attributes' => array( 'placeholder' => '*****', 'class' * => '****' ) * } * @return void */ function give_text_input( $field ) { global $thepostid, $post; $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; $field['value'] = give_get_field_value( $field, $thepostid ); $field['type'] = isset( $field['type'] ) ? $field['type'] : 'text'; $field['before_field'] = ''; $field['after_field'] = ''; $data_type = empty( $field['data_type'] ) ? '' : $field['data_type']; switch ( $data_type ) { case 'price' : $field['value'] = ( ! empty( $field['value'] ) ? give_format_decimal( give_maybe_sanitize_amount( $field['value'] ), false, false ) : $field['value'] ); $field['before_field'] = ! empty( $field['before_field'] ) ? $field['before_field'] : ( give_get_option( 'currency_position', 'before' ) == 'before' ? '' . give_currency_symbol() . '' : '' ); $field['after_field'] = ! empty( $field['after_field'] ) ? $field['after_field'] : ( give_get_option( 'currency_position', 'before' ) == 'after' ? '' . give_currency_symbol() . '' : '' ); break; case 'decimal' : $field['attributes']['class'] .= ' give_input_decimal'; $field['value'] = ( ! empty( $field['value'] ) ? give_format_decimal( give_maybe_sanitize_amount( $field['value'] ), false, false ) : $field['value'] ); break; default : break; } ?>
/> '; } /** * Output a chosen input box. * Note: only for internal use. * * @param array $field { * Optional. Array of text input field arguments. * * @type string $id Field ID. Default ''. * @type string $style CSS style for input field. Default ''. * @type string $wrapper_class CSS class to use for wrapper of input field. Default ''. * @type string $value Value of input field. Default ''. * @type string $name Name of input field. Default ''. * @type string $type Type of input field. Default 'text'. * @type string $before_field Text/HTML to add before input field. Default ''. * @type string $after_field Text/HTML to add after input field. Default ''. * @type string $data_type Define data type for value of input to filter it properly. Default ''. * @type string $description Description of input field. Default ''. * @type array $attributes List of attributes of input field. Default array(). * for example: 'attributes' => array( 'placeholder' => '*****', 'class' * => '****' ) * } * * @since 2.1 * * @return void */ function give_chosen_input( $field ) { global $thepostid, $post; $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; $field['before_field'] = ''; $field['after_field'] = ''; $placeholder = isset( $field['placeholder'] ) ? 'data-placeholder="' . $field['placeholder'] . '"' : ''; $data_type = ! empty( $field['data_type'] ) ? $field['data_type'] : ''; $type = ''; $allow_new_values = ''; $field['value'] = give_get_field_value( $field, $thepostid ); $field['value'] = is_array( $field['value'] ) ? array_fill_keys( array_filter( $field['value'] ), 'selected' ) : $field['value']; $title_prefixes_value = ( is_array( $field['value'] ) && count( $field['value'] ) > 0 ) ? array_merge( $field['options'], $field['value'] ) : $field['options']; // Set attributes based on multiselect datatype. if ( 'multiselect' === $data_type ) { $type = 'multiple'; $allow_new_values = 'data-allows-new-values="true"'; } ?>
array( 'placeholder' => '*****', 'class' * => '****' ) * } * * @return void */ function give_donation_limit( $field ) { global $thepostid, $post; // Get Give donation form ID. $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; // Default arguments. $default_options = array( 'style' => '', 'wrapper_class' => '', 'value' => give_get_field_value( $field, $thepostid ), 'data_type' => 'decimal', 'before_field' => '', 'after_field' => '', ); // Field options. $field['options'] = ! empty( $field['options'] ) ? $field['options'] : array(); // Default field option arguments. $field['options'] = wp_parse_args( $field['options'], array( 'display_label' => '', 'minimum' => give_format_decimal( '1.00', false, false ), 'maximum' => give_format_decimal( '999999.99', false, false ), ) ); // Set default field options. $field_options = wp_parse_args( $field, $default_options ); // Get default minimum value, if empty. $field_options['value']['minimum'] = ! empty( $field_options['value']['minimum'] ) ? $field_options['value']['minimum'] : $field_options['options']['minimum']; // Get default maximum value, if empty. $field_options['value']['maximum'] = ! empty( $field_options['value']['maximum'] ) ? $field_options['value']['maximum'] : $field_options['options']['maximum']; ?> array( 'placeholder' => '*****', 'class' * => '****' ) * } * @return void */ function give_hidden_input( $field ) { global $thepostid, $post; $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; $field['value'] = give_get_field_value( $field, $thepostid ); // Custom attribute handling $custom_attributes = array(); if ( ! empty( $field['attributes'] ) && is_array( $field['attributes'] ) ) { foreach ( $field['attributes'] as $attribute => $value ) { $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"'; } } ?> /> array( 'placeholder' => '*****', 'class' * => '****' ) * } * @return void */ function give_textarea_input( $field ) { global $thepostid, $post; $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; $field['value'] = give_get_field_value( $field, $thepostid ); $default_attributes = array( 'cols' => 20, 'rows' => 10 ); ?>
/> '; } /** * Output a select input box. * * @since 1.8 * * @param array $field { * Optional. Array of select field arguments. * * @type string $id Field ID. Default ''. * @type string $style CSS style for input field. Default ''. * @type string $wrapper_class CSS class to use for wrapper of input field. Default ''. * @type string $value Value of input field. Default ''. * @type string $name Name of input field. Default ''. * @type string $description Description of input field. Default ''. * @type array $attributes List of attributes of input field. Default array(). * for example: 'attributes' => array( 'placeholder' => '*****', 'class' * => '****' ) * @type array $options List of options. Default array(). * for example: 'options' => array( '' => 'None', 'yes' => 'Yes' ) * } * @return void */ function give_select( $field ) { global $thepostid, $post; $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; $field['value'] = give_get_field_value( $field, $thepostid ); $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; ?>
'; echo give_get_field_description( $field ); echo '
'; } /** * Output a radio input box. * * @since 1.8 * * @param array $field { * Optional. Array of radio field arguments. * * @type string $id Field ID. Default ''. * @type string $style CSS style for input field. Default ''. * @type string $wrapper_class CSS class to use for wrapper of input field. Default ''. * @type string $value Value of input field. Default ''. * @type string $name Name of input field. Default ''. * @type string $description Description of input field. Default ''. * @type array $attributes List of attributes of input field. Default array(). * for example: 'attributes' => array( 'placeholder' => '*****', 'class' * => '****' ) * @type array $options List of options. Default array(). * for example: 'options' => array( 'enable' => 'Enable', 'disable' => * 'Disable' ) * } * @return void */ function give_radio( $field ) { global $thepostid, $post; $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; $field['value'] = give_get_field_value( $field, $thepostid ); $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; echo ''; } /** * Output a colorpicker. * * @since 1.8 * * @param array $field { * Optional. Array of colorpicker field arguments. * * @type string $id Field ID. Default ''. * @type string $style CSS style for input field. Default ''. * @type string $wrapper_class CSS class to use for wrapper of input field. Default ''. * @type string $value Value of input field. Default ''. * @type string $name Name of input field. Default ''. * @type string $description Description of input field. Default ''. * @type array $attributes List of attributes of input field. Default array(). * for example: 'attributes' => array( 'placeholder' => '*****', 'class' * => '****' ) * } * @return void */ function give_colorpicker( $field ) { global $thepostid, $post; $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; $field['value'] = give_get_field_value( $field, $thepostid ); $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; $field['type'] = 'text'; ?>/> '; } /** * Output a file upload field. * * @since 1.8.9 * * @param array $field */ function give_file( $field ) { give_media( $field ); } /** * Output a media upload field. * * @since 1.8 * * @param array $field */ function give_media( $field ) { global $thepostid, $post; $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; $button_label = sprintf( __( 'Add or Upload %s', 'give' ), ( 'file' === $field['type'] ? __( 'File', 'give' ) : __( 'Image', 'give' ) ) ); $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; $field['value'] = give_get_field_value( $field, $thepostid ); $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; $field['attributes']['class'] = "{$field['attributes']['class']} give-text-medium"; // Allow developer to save attachment ID or attachment url as metadata. $field['fvalue'] = isset( $field['fvalue'] ) ? $field['fvalue'] : 'url'; $allow_media_preview_tags = array( 'jpg', 'jpeg', 'png', 'gif', 'ico' ); $preview_image_src = $field['value'] ? ( 'id' === $field['fvalue'] ? wp_get_attachment_url( $field['value'] ) : $field['value'] ) : '#'; $preview_image_extension = $preview_image_src ? pathinfo( $preview_image_src, PATHINFO_EXTENSION ) : ''; $is_show_preview = in_array( $preview_image_extension, $allow_media_preview_tags ); ?>
$option ) { $field['options'][ $key ] = $option['admin_label']; } } // Add a field to the Give Form admin single post view of this field if ( is_object( $post ) && 'give_forms' === $post->post_type ) { $field['options'] = array_merge( array( 'global' => esc_html__( 'Global Default', 'give' ) ), $field['options'] ); } // Render select field. give_select( $field ); } /** * Output the documentation link. * * @since 1.8 * * @param array $field { * Optional. Array of customizable link attributes. * * @type string $name Name of input field. Default ''. * @type string $type Type of input field. Default 'text'. * @type string $url Value to be passed as a link. Default 'https://givewp.com/documentation'. * @type string $title Value to be passed as text of link. Default 'Documentation'. * @type array $attributes List of attributes of input field. Default array(). * for example: 'attributes' => array( 'placeholder' => '*****', 'class' * => '****' ) * } * @return void */ function give_docs_link( $field ) { $field['url'] = isset( $field['url'] ) ? $field['url'] : 'https://givewp.com/documentation'; $field['title'] = isset( $field['title'] ) ? $field['title'] : 'Documentation'; echo '' . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $field['title'] ) . '
'; } /** * Output preview buttons. * * @since 2.0 * * @param $field */ function give_email_preview_buttons( $field ) { /* @var WP_Post $post */ global $post; $field_id = str_replace( array( '_give_', '_preview_buttons' ), '', $field['id'] ); ob_start(); echo ''; echo sprintf( '%2$s', wp_nonce_url( add_query_arg( array( 'give_action' => 'preview_email', 'email_type' => $field_id, 'form_id' => $post->ID, ), home_url() ), 'give-preview-email' ), $field['name'] ); echo sprintf( ' %3$s', wp_nonce_url( add_query_arg( array( 'give_action' => 'send_preview_email', 'email_type' => $field_id, 'give-messages[]' => 'sent-test-email', 'form_id' => $post->ID, ) ), 'give-send-preview-email' ), esc_attr__( 'Send Test Email.', 'give' ), esc_html__( 'Send Test Email', 'give' ) ); if ( ! empty( $field['description'] ) ) { echo '' . wp_kses_post( $field['desc'] ) . ''; } echo '
'; echo ob_get_clean(); } /** * Get setting field value. * * Note: Use only for single post, page or custom post type. * * @since 1.8 * @since 2.1 Added support for donation_limit. * * @param array $field * @param int $postid * * @return mixed */ function give_get_field_value( $field, $postid ) { if ( isset( $field['attributes']['value'] ) ) { return $field['attributes']['value']; } // If field is range slider. if ( 'donation_limit' === $field['type'] ) { // Get minimum value. $minimum = give_get_meta( $postid, $field['id'] . '_minimum', true ); // Give < 2.1 if ( '_give_custom_amount_range' === $field['id'] && empty( $minimum ) ) { $minimum = give_get_meta( $postid, '_give_custom_amount_minimum', true ); } $field_value = array( 'minimum' => $minimum, 'maximum' => give_get_meta( $postid, $field['id'] . '_maximum', true ), ); } else { // Get value from db. $field_value = give_get_meta( $postid, $field['id'], true ); } /** * Filter the field value before apply default value. * * @since 1.8 * * @param mixed $field_value Field value. */ $field_value = apply_filters( "{$field['id']}_field_value", $field_value, $field, $postid ); // Set default value if no any data saved to db. if ( ! $field_value && isset( $field['default'] ) ) { $field_value = $field['default']; } return $field_value; } /** * Get field description html. * * @since 1.8 * * @param $field * * @return string */ function give_get_field_description( $field ) { $field_desc_html = ''; $description = ''; // Check for both `description` and `desc`. if ( isset( $field['description'] ) ) { $description = $field['description']; } elseif ( isset( $field['desc'] ) ) { $description = $field['desc']; } // Set if there is a description. if ( ! empty( $description ) ) { $field_desc_html = '' . wp_kses_post( $description ) . ''; } return $field_desc_html; } /** * Get repeater field value. * * Note: Use only for single post, page or custom post type. * * @since 1.8 * * @param array $field * @param array $field_group * @param array $fields * * @return string */ function give_get_repeater_field_value( $field, $field_group, $fields ) { $field_value = ( isset( $field_group[ $field['id'] ] ) ? $field_group[ $field['id'] ] : '' ); /** * Filter the specific repeater field value * * @since 1.8 * * @param string $field_id */ $field_value = apply_filters( "give_get_repeater_field_{$field['id']}_value", $field_value, $field, $field_group, $fields ); /** * Filter the repeater field value * * @since 1.8 * * @param string $field_id */ $field_value = apply_filters( 'give_get_repeater_field_value', $field_value, $field, $field_group, $fields ); return $field_value; } /** * Get repeater field id. * * Note: Use only for single post, page or custom post type. * * @since 1.8 * * @param array $field * @param array $fields * @param int|bool $default * * @return string */ function give_get_repeater_field_id( $field, $fields, $default = false ) { $row_placeholder = false !== $default ? $default : '{{row-count-placeholder}}'; // Get field id. $field_id = "{$fields['id']}[{$row_placeholder}][{$field['id']}]"; /** * Filter the specific repeater field id * * @since 1.8 * * @param string $field_id */ $field_id = apply_filters( "give_get_repeater_field_{$field['id']}_id", $field_id, $field, $fields, $default ); /** * Filter the repeater field id * * @since 1.8 * * @param string $field_id */ $field_id = apply_filters( 'give_get_repeater_field_id', $field_id, $field, $fields, $default ); return $field_id; } /** * Get field name. * * @since 1.8 * * @param array $field * * @return string */ function give_get_field_name( $field ) { $field_name = esc_attr( empty( $field['repeat'] ) ? $field['id'] : $field['repeatable_field_id'] ); /** * Filter the field name. * * @since 1.8 * * @param string $field_name */ $field_name = apply_filters( 'give_get_field_name', $field_name, $field ); return $field_name; } /** * Output repeater field or multi donation type form on donation from edit screen. * Note: internal use only. * * @TODO : Add support for wysiwyg type field. * * @since 1.8 * * @param array $fields * * @return void */ function _give_metabox_form_data_repeater_fields( $fields ) { global $thepostid, $post; // Bailout. if ( ! isset( $fields['fields'] ) || empty( $fields['fields'] ) ) { return; } $group_numbering = isset( $fields['options']['group_numbering'] ) ? (int) $fields['options']['group_numbering'] : 0; $close_tabs = isset( $fields['options']['close_tabs'] ) ? (int) $fields['options']['close_tabs'] : 0; $wrapper_class = isset( $fields['wrapper_class'] ) ? $fields['wrapper_class'] : ''; ?>|
-
|
|
|
-
|
|
|
-
|
|