Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions classes/controllers/FrmAddonsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -839,12 +839,11 @@ protected static function prepare_addon_link( &$link ) {
$link = $site_url . $link;
}
$link = FrmAppHelper::make_affiliate_url( $link );
$query_args = array(
'utm_source' => 'WordPress',
'utm_medium' => 'addons',
'utm_campaign' => 'liteplugin',

$utm = array(
'campaign' => 'addons',
);
$link = add_query_arg( $query_args, $link );
$link = FrmAppHelper::maybe_add_missing_utm( $link, $utm );
}

/**
Expand Down
16 changes: 13 additions & 3 deletions classes/controllers/FrmAppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,8 @@ public static function admin_init() {
if ( 'formidable-pro-upgrade' === FrmAppHelper::get_param( 'page' ) && ! FrmAppHelper::pro_is_installed() && current_user_can( 'frm_view_forms' ) ) {
$redirect = FrmSalesApi::get_best_sale_value( 'menu_cta_link' );
$utm = array(
'medium' => 'upgrade',
'content' => 'submenu-upgrade',
'campaign' => 'upgrade',
'content' => 'submenu-upgrade',
);

if ( $redirect ) {
Expand Down Expand Up @@ -1334,8 +1334,18 @@ private static function enqueue_floating_links( $plugin_url, $version ) {
wp_set_script_translations( 's11-floating-links-config', 's11-' );
}

$upgrade_utm = array(
'campaign' => 'floating-links',
'content' => 'floating-links-upgrade',
);
$docs_utm = array(
'campaign' => 'floating-links',
'content' => 'floating-links-docs',
);
$floating_links_data = array(
'proIsInstalled' => FrmAppHelper::pro_is_installed(),
'proIsInstalled' => FrmAppHelper::pro_is_installed(),
'upgradeUrl' => FrmAppHelper::admin_upgrade_link( $upgrade_utm ),
'documentationUrl' => FrmAppHelper::admin_upgrade_link( $docs_utm, 'knowledgebase/' ),
);
wp_localize_script( 's11-floating-links-config', 's11FloatingLinksData', $floating_links_data );

Expand Down
2 changes: 1 addition & 1 deletion classes/controllers/FrmDashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ private static function view_args_entries_placeholder( $forms_count ) {
$copy = sprintf(
/* translators: %1$s: HTML start of a tag, %2$s: HTML close a tag */
__( 'See the %1$sform documentation%2$s for instructions on publishing your form', 'formidable' ),
'<a target="_blank" href="' . FrmAppHelper::admin_upgrade_link( '', 'knowledgebase/publish-a-form/' ) . '">',
'<a target="_blank" href="' . esc_url( FrmAppHelper::admin_upgrade_link( '', 'knowledgebase/publish-a-form/' ) ) . '">',
'</a>'
);
return array(
Expand Down
16 changes: 15 additions & 1 deletion classes/controllers/FrmFormsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public static function update( $values = array() ) {
$message .= '<br/> ' . sprintf(
/* translators: %1$s: Start link HTML, %2$s: end link HTML */
__( 'However, your form is very long and may be %1$sreaching server limits%2$s.', 'formidable' ),
'<a href="https://formidableforms.com/knowledgebase/i-have-a-long-form-why-did-the-options-at-the-end-of-the-form-stop-saving/?utm_source=WordPress&utm_medium=builder&utm_campaign=liteplugin" target="_blank" rel="noopener">',
'<a href="' . esc_url( self::get_form_too_long_docs_url() ) . '" target="_blank" rel="noopener">',
'</a>'
);
}
Expand All @@ -318,6 +318,19 @@ public static function update( $values = array() ) {
self::get_edit_vars( $id, array(), $message );
}

/**
* @since x.x
*
* @return string
*/
private static function get_form_too_long_docs_url() {
$utm = array(
'campaign' => 'builder',
'content' => 'form-too-long',
);
return FrmAppHelper::admin_upgrade_link( $utm, 'knowledgebase/i-have-a-long-form-why-did-the-options-at-the-end-of-the-form-stop-saving/' );
}

/**
* Remove the draft flag from any new fields from this current session.
*
Expand Down Expand Up @@ -353,6 +366,7 @@ private static function maybe_remove_draft_option_from_fields( $form_id ) {
*
* @since 3.06.01
*
* @param array $values
* @return bool
*/
private static function is_too_long( $values ) {
Expand Down
118 changes: 77 additions & 41 deletions classes/helpers/FrmAppHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,77 +115,125 @@ public static function get_affiliate() {

/**
* @since 3.04.02
* @param array|string $args
*
* @param array|string $args If a string is passed, it is used for the utm_campaign attribute.
* @param string $page
*/
public static function admin_upgrade_link( $args, $page = '' ) {
if ( empty( $page ) ) {
$page = 'https://formidableforms.com/lite-upgrade/';
} else {
if ( $page ) {
$page = str_replace( 'https://formidableforms.com/', '', $page );
$page = 'https://formidableforms.com/' . $page;
} else {
$page = 'https://formidableforms.com/lite-upgrade/';
}

$anchor = '';
if ( is_array( $args ) ) {
$medium = $args['medium'] ?? '';
if ( isset( $args['content'] ) ) {
$content = $args['content'];
}
if ( isset( $args['anchor'] ) ) {
$anchor = '#' . $args['anchor'];
}
$args = self::adjust_legacy_utm_args( $args );
} else {
$medium = $args;
$args = array( 'campaign' => $args );
}

$query_args = array(
'utm_source' => 'WordPress',
'utm_medium' => $medium,
'utm_campaign' => 'liteplugin',
'utm_source' => 'plugin',
'utm_medium' => self::get_utm_medium(),
);
$query_args = self::maybe_add_utm_license( $query_args );

if ( isset( $args['campaign'] ) ) {
$query_args['utm_campaign'] = $args['campaign'];
}

if ( isset( $content ) ) {
$query_args['utm_content'] = $content;
if ( isset( $args['content'] ) ) {
$query_args['utm_content'] = $args['content'];
}

if ( is_array( $args ) && isset( $args['param'] ) ) {
if ( isset( $args['param'] ) ) {
$query_args['f'] = $args['param'];
}

if ( is_array( $args ) && ! empty( $args['plan'] ) ) {
if ( ! empty( $args['plan'] ) ) {
$query_args['plan'] = $args['plan'];
}

$link = add_query_arg( $query_args, $page ) . $anchor;
$link = add_query_arg( $query_args, $page );

if ( isset( $args['anchor'] ) ) {
$link .= '#' . $args['anchor'];
}

return self::make_affiliate_url( $link );
}

/**
* If medium is "pro", add an additional utm_license param with their active license type.
*
* @since x.x
*
* @param array $query_args
* @return array
*/
private static function maybe_add_utm_license( $query_args ) {
if ( 'pro' === $query_args['utm_medium'] && is_callable( 'FrmProAddonsController::get_readable_license_type' ) ) {
$query_args['utm_license'] = strtolower( FrmProAddonsController::get_readable_license_type() );
}

return $query_args;
}
Comment thread
Crabcyborg marked this conversation as resolved.

/**
* @since x.x
*
* @return string
*/
private static function get_utm_medium() {
return self::pro_is_connected() ? 'pro' : 'lite';
}

/**
* Change campaign from "liteplugin" to what we're currently using for medium.
*
* @since x.x
*
* @param array $args
* @return array
*/
private static function adjust_legacy_utm_args( $args ) {
if ( isset( $args['medium'] ) ) {
$args['campaign'] = $args['medium'];
unset( $args['medium'] );
}

return $args;
}

/**
* @since 6.21
*
* @param string $cta_link
* @param array $utm
*/
public static function maybe_add_missing_utm( $cta_link, $utm ) {
$utm = self::adjust_legacy_utm_args( $utm );
$query_args = array();

if ( false === strpos( $cta_link, 'utm_source' ) ) {
$query_args['utm_source'] = 'WordPress';
$query_args['utm_source'] = 'plugin';
}

if ( false === strpos( $cta_link, 'utm_campaign' ) ) {
$query_args['utm_campaign'] = 'liteplugin';
if ( false === strpos( $cta_link, 'utm_medium' ) ) {
$query_args['utm_medium'] = self::get_utm_medium();
}

if ( false === strpos( $cta_link, 'utm_medium' ) && isset( $utm['medium'] ) ) {
$query_args['utm_medium'] = $utm['medium'];
if ( false === strpos( $cta_link, 'utm_campaign' ) && isset( $utm['campaign'] ) ) {
$query_args['utm_campaign'] = $utm['campaign'];
}

if ( false === strpos( $cta_link, 'utm_content' ) && isset( $utm['content'] ) ) {
$query_args['utm_content'] = $utm['content'];
}

$query_args = self::maybe_add_utm_license( $query_args );

return $query_args ? add_query_arg( $query_args, $cta_link ) : $cta_link;
}

Expand Down Expand Up @@ -1462,8 +1510,8 @@ public static function print_admin_banner( $should_show_lite_upgrade ) {

$upgrade_link = FrmSalesApi::get_best_sale_value( 'lite_banner_cta_link' );
$utm = array(
'medium' => 'settings-license',
'content' => 'lite-banner',
'campaign' => 'settings-license',
'content' => 'lite-banner',
);

if ( $upgrade_link ) {
Expand Down Expand Up @@ -3679,19 +3727,7 @@ public static function min_pro_version_notice( $min_version ) {
return;
}

$expired = FrmAddonsController::is_license_expired();
?>
<div class="frm-banner-alert frm_error_style frm_previous_install">
<?php
esc_html_e( 'You are running a version of Formidable Forms that may not be compatible with your version of Formidable Forms Pro.', 'formidable' );
if ( empty( $expired ) ) {
echo ' Please <a href="' . esc_url( admin_url( 'plugins.php?s=formidable%20forms%20pro' ) ) . '">update now</a>.';
} else {
echo '<br/>Please <a href="https://formidableforms.com/account/downloads/?utm_source=WordPress&utm_medium=outdated">renew now</a> to get the latest version.';
}
?>
</div>
<?php
include self::plugin_path() . '/classes/views/addons/min-version-notice.php';
}

/**
Expand Down
4 changes: 2 additions & 2 deletions classes/helpers/FrmDashboardHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ public static function get_license_buttons() {

$upgrade_link = FrmSalesApi::get_best_sale_value( 'dashboard_license_cta_link' );
$utm = array(
'medium' => 'settings-license',
'content' => 'dashboard-license-box',
'campaign' => 'settings-license',
'content' => 'dashboard-license-box',
);

if ( $upgrade_link ) {
Expand Down
6 changes: 5 additions & 1 deletion classes/helpers/FrmEntriesListHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,14 @@ public function search_box( $text, $input_id ) {
protected function display_tablenav( $which ) {
$is_footer = ( $which !== 'top' );
if ( $is_footer && ! empty( $this->items ) ) {
$utm = array(
'campaign' => 'spam-protection',
'content' => 'entries-list-spam-protection',
);
?>
<p>
<?php esc_html_e( 'Getting spam form submissions?', 'formidable' ); ?>
<a href="https://formidableforms.com/knowledgebase/add-spam-protection/" target="_blank">
<a href="<?php echo esc_url( FrmAppHelper::admin_upgrade_link( $utm, 'knowledgebase/add-spam-protection/' ) ); ?>" target="_blank">
<?php esc_html_e( 'Learn how to prevent them.', 'formidable' ); ?>
</a>
</p>
Expand Down
4 changes: 4 additions & 0 deletions classes/models/fields/FrmFieldCaptcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ protected function recaptcha_api_url( $frm_settings ) {
$api_js_url .= '&hl=' . $lang;
}

// Since this URL initially ends with ? and we never use add_query_arg, remove the extra
// & that appears immediately after the ?
$api_js_url = str_replace( '?&', '?', $api_js_url );

/**
* @param string $api_js_url
*/
Expand Down
20 changes: 20 additions & 0 deletions classes/views/addons/min-version-notice.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( 'You are not allowed to call this page directly.' );
}
?>
<div class="frm-banner-alert frm_error_style frm_previous_install">
<?php esc_html_e( 'You are running a version of Formidable Forms that may not be compatible with your version of Formidable Forms Pro.', 'formidable' ); ?>

<?php if ( FrmAddonsController::is_license_expired() ) : ?>
<?php
$utm = array(
'campaign' => 'outdated',
'content' => 'min-pro-version-notice',
);
?>
Please <a href="<?php echo esc_url( FrmAppHelper::admin_upgrade_link( $utm, 'account/downloads/' ) ); ?>">renew now</a> to get the latest version.
<?php else : ?>
Please <a href="<?php echo esc_url( admin_url( 'plugins.php?s=formidable%20forms%20pro' ) ); ?>">update now</a>.
<?php endif; ?>
</div>
5 changes: 0 additions & 5 deletions classes/views/addons/upgrade_to_pro.php

This file was deleted.

4 changes: 2 additions & 2 deletions classes/views/dashboard/templates/pro-features-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

$discount_link = FrmSalesApi::get_best_sale_value( 'global_settings_upgrade_cta_link' );
$utm = array(
'medium' => 'dashboard-discount',
'content' => 'dashboard-defy-limits-cta',
'campaign' => 'dashboard-discount',
'content' => 'dashboard-defy-limits-cta',
);
if ( $discount_link ) {
$discount_link = FrmAppHelper::maybe_add_missing_utm( $discount_link, $utm );
Expand Down
6 changes: 5 additions & 1 deletion classes/views/frm-entries/no_entries.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,14 @@
</div>
<p class="frm_no_entries_text">
<?php
$utm = array(
'campaign' => 'entries',
'content' => 'no-entries',
);
printf(
/* translators: %1$s: Start link HTML, %2$s: End link HTML, %3$s: Line break HTML */
esc_html__( 'See the %1$sform documentation%2$s for instructions on publishing your form', 'formidable' ),
'<a href="https://formidableforms.com/knowledgebase/publish-your-forms/?utm_source=WordPress&utm_medium=entries&utm_campaign=liteplugin" target="_blank">',
'<a href="' . esc_url( FrmAppHelper::admin_upgrade_link( $utm, 'knowledgebase/publish-your-forms/' ) ) . '" target="_blank">',
'</a>'
);
?>
Expand Down
12 changes: 10 additions & 2 deletions classes/views/frm-settings/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,16 @@
</p>
<p class="frm-text-xs frm-mb-0">
<?php
// translators: %s: Knowledge base URL
printf( esc_html__( 'Learn more about our GDPR settings', 'formidable' ) . ' <a href="%s" target="_blank">%s</a>', 'https://formidableforms.com/knowledgebase/gdpr-settings/', esc_html__( 'here', 'formidable' ) );
$gdpr_utm = array(
'campaign' => 'gdpr-settings',
'content' => 'gdpr-settings-docs',
);
printf(
// translators: %1$s: Opening tag for a link, %2$s: Closing tag for a link
esc_html__( 'Learn more about our GDPR settings %1$shere%2$s', 'formidable' ),
'<a href="' . esc_url( FrmAppHelper::admin_upgrade_link( $gdpr_utm, 'knowledgebase/gdpr-settings/' ) ) . '" target="_blank">',
'</a>'
);
?>
</p>
<h3 class="frm-mt-xs"><?php esc_html_e( 'Other', 'formidable' ); ?></h3>
Expand Down
Loading