name = esc_html__( 'Payment', 'charitable' );
$this->slug = 'payment';
$this->icon = 'panel_payment.svg';
$this->order = 50;
$this->sidebar = true;
// This should never be called unless we are on the campaign builder page.
if ( campaign_is_campaign_builder_admin_page() ) {
$this->load_submenu_panels();
}
}
/**
* Enqueue assets for the Design panel.
*
* @since 1.8.0
*/
public function enqueues() {
}
/**
* Load panels.
*
* @since 1.8.0
* @version 1.8.7.1 - Square below Stripe.
*/
public function load_submenu_panels() {
$this->submenu_panels = apply_filters(
'charitable_builder_panels_payment',
array(
'stripe',
'square',
'paypal',
'braintree',
'mollie',
'gocardless',
'authorize-net',
'payfast',
'payrexx',
'paystack',
'payumoney',
'windcave',
'request',
)
);
foreach ( $this->submenu_panels as $panel ) {
$panel = sanitize_file_name( $panel );
$file = apply_filters( 'charitable_builder_panels_payment_classfile', charitable()->get_path( 'includes' ) . "admin/campaign-builder/panels/payment/class-payment-{$panel}.php", $panel );
if ( file_exists( $file ) ) {
require_once $file;
}
}
}
/**
* Output the Field panel sidebar.
*
* @since 1.8.0
*/
public function panel_sidebar() {
// This should never be called unless we are on the campaign builder page.
if ( ! campaign_is_campaign_builder_admin_page() ) {
return;
}
do_action( 'charitable_campaign_builder_payment_sidebar', $this->campaign_data );
}
/**
* Process payment for campaigns, mostly via the builder.
*
* @since 1.8.0
*
* @param string $field Field.
* @param string $section Payment section.
* @param string $top_level Level.
* @param string $meta_key Alt legacy location to try to pull payment.
*/
public function campaign_data_payment( $field = 'title', $section = 'general', $top_level = 'payment', $meta_key = false ) {
}
/**
* Process education payment text.
*
* @since 1.8.0
* @version 1.8.7.1 - Added Square to the list of gateways that are built in.
*
* @param string $label Reader friendly output of object.
* @param string $slug Object slug.
* @param string $type Type of request.
*/
public function education_payment_text( $label = false, $slug = false, $type = false ) {
$learn_more_url = charitable_ga_url(
'https://wpcharitable.com/lite-vs-pro/', // base url.
rawurlencode( esc_html( $label ) . ' Payment Page' ), // utm-medium.
rawurlencode( 'Learn More' ) // utm-content.
);
$big_icon = apply_filters( 'charitable_campaign_builder_payment_icon_url', charitable()->get_path( 'assets', false ) . 'images/campaign-builder/settings/payment/' . esc_attr( $slug ) . '_big.png', $slug );
?>
'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
endif;
?>
user_email ) ? $current_user->user_email : false;
?>
- , ,
-
Gift Aid addon, a tax incentive for UK charities, you can boost your donations by 25 percent.', 'charitable' );
?>
- , ,
-
Gift Aid addon, a tax incentive for UK charities, you can boost your donations by 25 percent.', 'charitable' );
?>
$search_slug,
),
admin_url( 'admin.php?page=charitable-addons' )
)
);
$addon_description = esc_html( $label ) . ' ' . esc_html__( 'allows you to easily reach more supporters and increase donations.', 'charitable' ); // default description.
// attempt to get the "slug" so we can eventually see if we can get the plugin description from the stored plugin versions in the databse.
$plugin_version_slug = explode( '/', $slug );
$plugin_version_slug_string = ! empty( $plugin_version_slug ) ? 'charitable-' . $plugin_version_slug[0] : '';
// start the output.
echo ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
?>
get_path( 'assets', false ) . 'images/campaign-builder/settings/payment/' . esc_attr( $marketing_item_slug ) . '_big.png" wdith="178" height="178" />'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
?>
' . esc_html( $button_label ) . '';
?>
get_path( 'assets', false ) . 'images/campaign-builder/settings/payment/' . esc_attr( $marketing_item_slug ) . '_big.png" wdith="178" height="178" />'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
// Determine if the plugin in question is installed and/or activated.
$status = $this->check_plugin_status( $addon_url );
$button_label = '';
switch ( $status ) {
case 'installed':
$button_label = esc_html__( 'Activate', 'charitable' );
$action_css_class = 'charitable-not-activated-button';
break;
case 'activated':
$button_label = esc_html__( 'View Settings', 'charitable' );
$action_css_class = 'charitable-view-settings-button';
break;
default:
// doesn't exist.
$button_label = esc_html__( 'Install And Activate', 'charitable' );
$action_css_class = 'charitable-not-installed-button';
break;
}
// Setup defaults for a few variables.
$settings_url = false;
$gateway_id = '';
$settings_url = '';
$enable_url = '';
// Get the gateway ID, which in this case is the first part of the addon_url before the '/' and remove the 'charitable-' prefix.
if ( ! empty( $addon_url ) ) {
$gateway_id = explode( '/', $addon_url );
$gateway_id = ! empty( $gateway_id ) ? str_replace( 'charitable-', '', $gateway_id[0] ) : '';
$gateway_id = str_replace( '-', '_', $gateway_id );
$settings_url = esc_url(
add_query_arg(
array(
'group' => 'gateways_' . $gateway_id,
),
admin_url( 'admin.php?page=charitable-settings&tab=gateways' )
)
);
}
if ( ! empty( $gateway_id ) ) {
$enable_url = esc_url(
add_query_arg(
array(
'charitable_action' => 'enable_gateway',
'gateway_id' => $gateway_id,
'_nonce' => wp_create_nonce( 'gateway' ),
),
admin_url( 'admin.php?page=charitable-settings&tab=gateways' )
)
);
}
// get license stuff once.
$charitable_addons = get_transient( '_charitable_addons' ); // @codingStandardsIgnoreLine - testing.
// Get addons data from transient or perform API query if no transient.
if ( false === $charitable_addons ) {
$charitable_addons = charitable_get_addons_data_from_server();
}
if ( empty( $addon_url ) ) {
return;
}
$addon_url_slug = explode( '/', $addon_url );
$addon_url_slug = $addon_url_slug[0]; // example: charitable-newsletter-connect.
$addon_information = array();
// Extract the correct addon data.
if ( ! empty( $charitable_addons ) ) {
foreach ( $charitable_addons as $addon ) {
if ( ! empty( $addon['slug'] ) && (string) $addon_url_slug === (string) $addon['slug'] ) {
$addon_information = $addon;
break;
}
}
}
$addon_information_install = ! empty( $addon_information['install'] ) ? $addon_information['install'] : '';
$addon_information_name = ! empty( $addon_information['name'] ) ? $addon_information['name'] : '';
?>
$button_url,
'button_label' => $button_label,
);
$helper = charitable_get_helper( 'gateways' );
$gateways = $helper->get_available_gateways();
foreach ( $gateways as $gateway_slug => $gateway ) :
if ( $gateway_slug !== $provider_slug ) {
continue;
}
$gateway = new $gateway();
$is_active = $helper->is_active_gateway( $gateway->get_gateway_id() );
if ( $is_active ) {
$action_url = esc_url(
add_query_arg(
array(
'group' => 'gateways_' . $gateway->get_gateway_id(),
),
admin_url( 'admin.php?page=charitable-settings&tab=gateways' )
)
);
$action_text = __( 'Go To Settings', 'charitable' );
} else {
$action_url = esc_url(
add_query_arg(
array(
'charitable_action' => 'enable_gateway',
'gateway_id' => $gateway->get_gateway_id(),
'_nonce' => wp_create_nonce( 'gateway' ),
),
admin_url( 'admin.php?page=charitable-settings&tab=gateways' )
)
);
$action_text = __( 'Enable Gateway', 'charitable' );
}
$button_info = array(
'button_url' => $action_url,
'button_label' => $action_text,
);
endforeach;
return $button_info;
}
/**
* Output the Field panel primary content.
*
* @since 1.8.0
*/
public function panel_content() {
// This should never be called unless we are on the campaign builder page.
if ( ! campaign_is_campaign_builder_admin_page() ) {
return;
}
do_action( 'charitable_campaign_builder_payment_panels', $this->campaign_data );
}
/**
* Builder field buttons.
*
* @since 1.8.0
*/
public function fields() {
}
/**
* Sort Add Field buttons by order provided.
*
* @since 1.8.0
*
* @param array $a First item.
* @param array $b Second item.
*
* @return array
*/
public function field_order( $a, $b ) {
return $a['order'] - $b['order'];
}
/**
* Check the installation and activation status of a plugin.
*
* @since 1.8.1.12
*
* @param string $plugin_slug The plugin slug, e.g., 'my-plugin/my-plugin.php'.
*
* @return string Status message indicating plugin state.
*/
public function check_plugin_status( $plugin_slug = '' ) {
if ( '' === $plugin_slug ) {
return 'nonexist';
}
// Check if the plugin is installed.
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$all_plugins = get_plugins();
$plugin_installed = array_key_exists( $plugin_slug, $all_plugins );
if ( $plugin_installed && is_plugin_active( $plugin_slug ) ) {
return 'activated';
} elseif ( $plugin_installed ) {
return 'installed';
} else {
return 'nonexist';
}
}
}
endif;
new Charitable_Builder_Panel_Payment();