name = esc_html__( 'Donate Button', 'charitable' ); $this->type = 'donate-button'; $this->icon = 'fa-link'; $this->order = 60; $this->align_default = 'center'; // Edit/Duplication information. $this->can_be_edited = true; $this->can_be_deleted = true; $this->can_be_duplicated = true; $this->edit_label = esc_html__( 'Edit Donate Button', 'charitable' ); $this->edit_type = 'donate-button'; $this->edit_section = 'recommended'; // Misc. $this->tooltip = ''; // Define additional field properties. add_action( 'charitable_frontend_js', [ $this, 'frontend_js' ] ); } /** * Social Sharing options panel inside the builder. * * @since 1.8.0 * * @param array $field Donate Button settings. */ public function field_options( $field ) { /* * Basic field options. */ // Options open markup. } /** * Render the field. * * @since 1.8.0 * * @param array $field_data Any field data. * @param array $campaign_data Amount data and settings. * @param integer $field_id The field ID. * @param string $mode Where the field is being displayed ("preview" or "template"). * @param array $template_data Tempalate data. */ public function render( $field_data = false, $campaign_data = false, $field_id = false, $mode = 'template', $template_data = false ) { $button_label = ! empty( $field_data['button_label'] ) ? esc_html( $field_data['button_label'] ) : esc_html__( 'Donate', 'charitable' ); $html = '
' . $button_label . '
'; return $html; } /** * Social Sharing preview inside the builder. * * @since 1.8.0 * * @param array $field_data Field data and settings. * @param array $campaign_data Campaign data and settings. * @param array $field_id Field ID. * @param string $theme Template data. */ public function field_preview( $field_data = false, $campaign_data = false, $field_id = false, $theme = '' ) { if ( empty( $field_data['align'] ) ) { $field_data['align'] = $this->align_default; } $html = $this->field_title( $this->name ); $html .= $this->field_wrapper( $this->render( $field_data, $campaign_data, $field_id ), $field_data ); echo wp_kses_post( $html ); } /** * The display on the campaign front-end. * * @since 1.8.0 * * @param array $field Donate Button settings. * @param array $field_data Any field data. * @param array $campaign_data Form data and settings. * @param boolean $is_preview_page Is this being generated on a preview page. */ public function field_display( $field, $field_data = false, $campaign_data = false, $is_preview_page = false ) { $campaign = isset( $campaign_data['id'] ) && 0 !== intval( $campaign_data['id'] ) ? charitable_get_campaign( $campaign_data['id'] ) : false; if ( ! $campaign ) : return; endif; $button_label = ! empty( $field_data['button_label'] ) ? esc_html( $field_data['button_label'] ) : 'Donate'; $css_class = ! empty( $field_data['css_class'] ) ? ' class="' . esc_html( $field_data['css_class'] ) . '" ' : ''; $donation_form_display = charitable_get_option( 'donation_form_display', 'separate_page' ); // could also be same_page or modal. // We want the button to contain a donation amount, but we go with what is in the SESSION first, then the DEFAULT amount. $donation_amount = $campaign->get_donation_amount_in_session(); ob_start(); ?>
> can_receive_donations() && ! $is_preview_page ) { $charitable_campaign_button_closed_message = apply_filters( 'charitable_campaign_button_closed_message', esc_html__( 'This campaign is closed or goal has been reached.', 'charitable' ), $campaign ); ?>
aria-label="ID ) ) ); ?>">
aria-label="ID ) ) ); ?>" >
field_display_wrapper( $html, $field_data ); echo apply_filters( 'charitable_campaign_builder_' . $this->type . '_field_display', $html, $campaign_data ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } /** * The display on the form settings backend when the user clicks on the field/block. * * @since 1.8.0 * * @param array $field_id Field ID. * @param array $campaign_data Campaign data and settings. */ public function settings_display( $field_id = false, $campaign_data = false ) { if ( ! class_exists( 'Charitable_Builder_Form_Fields' ) ) { return; } $charitable_builder_form_fields = new Charitable_Builder_Form_Fields(); $settings = isset( $campaign_data['fields'][ $field_id ] ) ? $campaign_data['fields'][ $field_id ] : false; add_action( 'charitable_builder_' . $this->type . '_settings_display_start', [ $this, 'settings_section_top' ], 10, 2 ); add_action( 'charitable_builder_' . $this->type . '_settings_display_end', [ $this, 'settings_section_bottom' ], 10, 2 ); ob_start(); ?>

name ); ?> (ID: )

type . '_settings_display_start', $field_id, $campaign_data ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
generate_text( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped isset( $settings['button_label'] ) ? $settings['button_label'] : esc_html__( 'Donate', 'charitable' ), esc_html__( 'Button Label', 'charitable' ), array( 'id' => 'field_' . esc_attr( $this->type ) . '_button_label' . '_' . intval( $field_id ), // phpcs:ignore 'name' => array( '_fields', intval( $field_id ), 'button_label' ), 'class' => 'charitable-campaign-builder-donate-button-button-label', 'field_id' => intval( $field_id ), ) ); echo $charitable_builder_form_fields->generate_number_slider( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped isset( $settings['width_percentage'] ) ? $settings['width_percentage'] : 100, esc_html__( 'Width', 'charitable' ), array( 'id' => 'field_' . esc_attr( $this->type ) . '_width_percentage' . '_' . intval( $field_id ), // phpcs:ignore 'name' => array( '_fields', intval( $field_id ), 'width_percentage' ), 'field_type' => esc_attr( $this->type ), 'css_class' => 'charitable-indicator-on-hover', 'field_id' => intval( $field_id ), 'symbol' => '%', 'min' => 0, 'min_actual' => 20, ) ); echo $charitable_builder_form_fields->generate_align( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped isset( $settings['align'] ) ? $settings['align'] : esc_attr( $this->align_default ), esc_html__( 'Align', 'charitable' ), array( 'id' => 'field_' . esc_attr( $this->type ) . '_align' . '_' . intval( $field_id ), // phpcs:ignore 'name' => array( '_fields', intval( $field_id ), 'align' ), 'field_id' => intval( $field_id ), ) ); /* CSS CLASS */ echo $charitable_builder_form_fields->generate_text( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped isset( $settings['css_class'] ) ? $settings['css_class'] : false, esc_html__( 'CSS Class', 'charitable' ), array( 'id' => 'field_' . esc_attr( $this->type ) . '_css_class' . '_' . intval( $field_id ), 'name' => array( '_fields', intval( $field_id ), 'css_class' ), 'field_id' => intval( $field_id ), 'tooltip' => esc_html__( 'Add CSS classes (seperated by a space) for this field to customize it\'s appearance in your theme.', 'charitable' ), ) ); ?>
type . '_settings_display_end', $field_id, $campaign_data ); ?>