Skip to content

Commit

Permalink
v1.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
65 committed Jun 1, 2022
2 parents 3343461 + ca92fb0 commit 524a2ce
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 25 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Fathom Analytics Conversions

[![GitHub issues](https://img.shields.io/github/issues/65/fathom-analytics-conversions)](https://github.com/65/fathom-analytics-conversions/issues)

# Fathom Analytics Conversions

This plugin makes it easy to add conversions that you used to have in Google Analytics into [Fathom Analytics](https://usefathom.com). Whilst they have produced a WordPress plugin to make it easy to place their tracking code on the page, the ability to add conversions still requires some level of technical knowledge and this plugin aims to reduce that.

## *Warning* BETA API in use
This plugin uses the Beta Fathom Analytics API, which is still in early access, and subject to changes in the future, this plugin could stop working without warning if updates occur.


## Download
Get the plugin from the [WordPress Repository](https://wordpress.org/plugins/fathom-analytics-conversions/) for download and installation instructions.

Expand Down
5 changes: 4 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate link: https://www.fathomconversions.com
Tags: analytics, events, conversions, fathom
Requires at least: 5.9
Tested up to: 6.0
Stable tag: 1.0.3
Stable tag: 1.0.4
Requires PHP: 7.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Expand All @@ -19,6 +19,9 @@ The official Fathom Analytics plugin makes it easy to place the tracking code on

Fathom Analytics Conversions is the no code answer for WordPress and Fathom Analytics users. You need to technical knowledge to implement events.

= Warning BETA API in use =
This plugin uses the Beta Fathom Analytics API, which is still in early access, and subject to changes in the future, this plugin could stop working without warning if updates occur.

= Key Features =

* Automated backend creation of events for your forms
Expand Down
44 changes: 27 additions & 17 deletions admin/class-fathom-analytics-conversions-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ public function fac4wp_admin_output_field($args) {
array(
'a' => array(
'href' => true,
'target' => true,
'rel' => true,
),
));

Expand Down Expand Up @@ -198,7 +200,18 @@ public function fac4wp_admin_output_field($args) {
echo '<input type="checkbox" id="' . esc_attr(FAC4WP_OPTIONS . '[' . $args['option_field_id'] . ']').'" name="' . esc_attr(FAC4WP_OPTIONS . '[' . $args['option_field_id'] . ']').'" value="1" ' . checked( 1, $opt_val, false ) . ' /><br />' . esc_html($args['description']);

if ( isset( $args['plugin_to_check'] ) && ( $args['plugin_to_check'] != '' ) ) {
if ( is_plugin_active( $args['plugin_to_check'] ) ) {
$is_plugin_active = 0;
if ( is_array( $args['plugin_to_check'] ) ) {
foreach ( $args['plugin_to_check'] as $plugin ) {
if ( is_plugin_active( $plugin ) ) {
$is_plugin_active = 1;
}
}
}
elseif ( is_plugin_active( $args['plugin_to_check'] ) ) {
$is_plugin_active = 1;
}
if ( $is_plugin_active ) {
echo '<br />';
echo wp_kses(
__( 'This plugin is <strong class="fac4wp-plugin-active">active</strong>, it is strongly recommended to enable this integration!', 'fathom-analytics-conversions' ),
Expand All @@ -219,7 +232,7 @@ public function fac4wp_admin_output_field($args) {
],
]
),
$args['plugin_to_check']
is_array( $args['plugin_to_check'] ) ? implode( ' or ', $args['plugin_to_check'] ) : $args['plugin_to_check']
);
}
}
Expand Down Expand Up @@ -316,7 +329,7 @@ public function fac4wp_admin_init() {
'label' => __( 'WPForms', 'fathom-analytics-conversions' ),
'description' => __( 'Check this to add conversation a successful form submission.', 'fathom-analytics-conversions' ),
'phase' => FAC4WP_PHASE_STABLE,
'plugin_to_check' => 'wpforms/wpforms.php',
'plugin_to_check' => ['wpforms/wpforms.php', 'wpforms-lite/wpforms.php'],
),
);
global $fac4wp_integrate_field_texts;
Expand Down Expand Up @@ -491,7 +504,7 @@ public function fac_cf7_meta_box($panels) {
}

public function fac_cf7_box($args) {
$cf7_id = $args->id;
$cf7_id = $args->id();
$fac_cf7_defaults = array();
$fac_cf7 = get_option( 'fac_cf7_'.$cf7_id, $fac_cf7_defaults );
$fac_cf7_event_id = isset($fac_cf7['event_id']) ? $fac_cf7['event_id'] : '';
Expand All @@ -507,12 +520,10 @@ public function fac_cf7_box($args) {
</label>
</th>
<td>
<input type="text" id="fac_cf7_event_id" name="fac_cf7[event_id]" class="" value="<?php echo esc_attr($fac_cf7_event_id);?>">
<p>
<a href="https://app.tango.us/app/workflow/Creating-Events-with-Fathom-94b0b00ff9b04b548bf4910188f97902" target="_blank">
<?php echo esc_html__('Creating Events with Fathom', 'fathom-analytics-conversions');?>
</a>
</p>
<input type="text" id="fac_cf7_event_id" name="fac_cf7[event_id]" class="" value="<?php echo esc_attr($fac_cf7_event_id);?>" readonly>

<p class="note">This event id is created for you automatically, and maintained by the Fathom Analytics Conversions plugin. You can refer to it in your Fathom Analytics settings.</p>

</td>
</tr>
</tbody>
Expand All @@ -524,21 +535,21 @@ public function fac_cf7_box($args) {

// save FAC CF7 options
public function fac_cf7_save_options($args) {
if(!empty($_POST)){
if ( ! empty( $_POST ) && isset( $_POST['fac_cf7'] ) ){

$default = array () ;
//$fac_cf7 = get_option( 'fac_cf7'.$args->id(), $default );

$fac_cf7_val = fac_array_map_recursive( 'esc_attr', $_POST['fac_cf7'] );

update_option( 'fac_cf7_'.$args->id(), $fac_cf7_val );
update_option( 'fac_cf7_' . $args->id(), $fac_cf7_val );
}
}

// check to add/update event id to new cf7 form
public function fac_wpcf7_after_save($args) {
$form_id = $args->id;
$title = wp_slash( $args->title );
$form_id = $args->id();
$title = wp_slash( $args->title() );

$fac_cf7 = get_option( 'fac_cf7_'.$form_id, [] );
$fac_cf7_event_id = isset($fac_cf7['event_id']) ? $fac_cf7['event_id'] : '';
Expand Down Expand Up @@ -619,9 +630,8 @@ public function fac_wpforms_form_settings_panel_content($settings) {
'input_class' => 'wpforms-panel-field-confirmations-redirect',
'parent' => 'settings',
'subsection' => $id,*/
'after' => '<p class="note"><a href="https://app.tango.us/app/workflow/Creating-Events-with-Fathom-94b0b00ff9b04b548bf4910188f97902" target="_blank">'.
esc_html__('Creating Events with Fathom', 'fathom-analytics-conversions')
. '</a>' . '</p>',
'readonly' => 'readonly',
'after' => '<p class="note">This event id is created for you automatically, and maintained by the Fathom Analytics Conversions plugin. You can refer to it in your Fathom Analytics settings.</p>',
)
);
}
Expand Down
4 changes: 2 additions & 2 deletions fathom-analytics-conversions.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Plugin Name: Fathom Analytics Conversions
* Plugin URI: https://www.fathomconversions.com
* Description: Easily add event conversions in WordPress plugins to Fathom Analytics
* Version: 1.0.3
* Version: 1.0
* Author: SixFive Pty Ltd
* Author URI: https://www.sixfive.com.au
* License: GPL-2.0+
Expand All @@ -35,7 +35,7 @@
* Start at version 1.0.0 and use SemVer - https://semver.org
* Rename this for your plugin and update it as you release new versions.
*/
define( 'FATHOM_ANALYTICS_CONVERSIONS_VERSION', '1.0.3' );
define( 'FATHOM_ANALYTICS_CONVERSIONS_VERSION', '1.0.4' );
define( 'FAC4WP_PATH', plugin_dir_path( __FILE__ ) );

global $fac4wp_plugin_url, $fac4wp_plugin_basename;
Expand Down
8 changes: 5 additions & 3 deletions includes/fac-core-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ function fac_check_cf7_forms() {
//echo '<pre>';print_r($form);echo '</pre>';
$form_id = $form->ID;
$fac_cf7 = get_option( 'fac_cf7_' . $form_id, [] );
$fac_cf7_event_id = isset( $fac_cf7['event_id'] ) ? $fac_cf7['event_id'] : '';
$fac_cf7_event_id = is_array( $fac_cf7 ) && isset( $fac_cf7['event_id'] ) ? $fac_cf7['event_id'] : '';
$title = $form->post_title;
if ( empty( $fac_cf7_event_id ) ) {
fa_add_event_id_to_cf7( $form_id, $title );
Expand All @@ -291,8 +291,10 @@ function fa_add_event_id_to_cf7( $form_id = 0, $title = '' ) {
$event_id = isset( $event_body->id ) ? $event_body->id : '';
if ( ! empty( $event_id ) ) {
$fac_cf7 = get_option( 'fac_cf7_' . $form_id, [] );
$fac_cf7['event_id'] = $event_id;
update_option( 'fac_cf7_' . $form_id, $fac_cf7 );
if ( is_array( $fac_cf7 ) ) {
$fac_cf7['event_id'] = $event_id;
update_option( 'fac_cf7_' . $form_id, $fac_cf7 );
}
}
}
//echo '<pre>';print_r($event_body);echo '</pre>';
Expand Down

0 comments on commit 524a2ce

Please sign in to comment.