Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
bdb4155
Updated: Readme version and also pulled the latest trunk readme since…
DogByteMarketing May 28, 2025
1239df8
Updated: Distignore to exclude additional development files
DogByteMarketing May 28, 2025
665a4c7
Merge pull request #137 from DogByteMarketing/ci/distignore/5-28-25
RCheesley May 28, 2025
ad5b48f
Bugfix: distignore composer.lock ignored twice.
DogByteMarketing May 28, 2025
d8ccdf4
Removed: dry-run flag from trunk updater.
DogByteMarketing May 28, 2025
e99ec16
Bugfix: Main does not match the 2.4.2 tag.
DogByteMarketing May 28, 2025
968f8a8
Merge pull request #139 from DogByteMarketing/docs/readme/5-28-25
RCheesley Jul 16, 2025
f4ba31f
Merge pull request #142 from DogByteMarketing/main
RCheesley Jul 16, 2025
3b427b8
Updated: Gitignore to allow autoloader
DogByteMarketing Jul 31, 2025
90d26c4
Updated: Readme to 2.5.0
DogByteMarketing Jul 31, 2025
b31ca15
Refactored: Codebase to be OOP and PSR-4 compliant
DogByteMarketing Jul 31, 2025
85a38ef
Updated: distignore
DogByteMarketing Aug 3, 2025
492f250
Updated: Version
DogByteMarketing Aug 3, 2025
add42a7
Updated: Composer to not include dev files
DogByteMarketing Aug 3, 2025
fdcfa08
Merge branch 'main' into version/2.5.0/refactor
DogByteMarketing Aug 3, 2025
cc2b650
Added: Missing string translations
DogByteMarketing Aug 3, 2025
e3f1bca
Added: Ability for tracking image to replace mtc.js as the default an…
DogByteMarketing Aug 3, 2025
db31cad
Merge branch 'main' into version/2.5.0/translations
DogByteMarketing Oct 18, 2025
306cc31
Added: No opener and no referrer to _blank links
DogByteMarketing Oct 18, 2025
a237d2f
Updated: Visibility of wpmautic_track_logged_user method
DogByteMarketing Oct 18, 2025
9cc5aa3
Updated: Visibility for wpmautic_track_logged_user
DogByteMarketing Oct 18, 2025
e4fdab1
Merge branch 'main' into version/2.5.0/tracking-method
DogByteMarketing Oct 18, 2025
7021c0d
Apply suggestions from code review
RCheesley Oct 20, 2025
ee1fcf7
Fix grammar
RCheesley Oct 20, 2025
8c6c881
Merge pull request #145 from DogByteMarketing/version/2.5.0/refactor
RCheesley Oct 20, 2025
b548387
Fix typo
RCheesley Oct 20, 2025
0d58265
Merge pull request #147 from DogByteMarketing/version/2.5.0/translations
RCheesley Oct 20, 2025
3528fed
Merge branch 'main' into version/2.5.0/tracking-method
DogByteMarketing Oct 20, 2025
741aa4f
Merge pull request #148 from DogByteMarketing/version/2.5.0/tracking-…
RCheesley Jan 28, 2026
1af3786
Removed: Dry run
DogByteMarketing Feb 26, 2026
56d5360
Merge pull request #149 from DogByteMarketing/version/2.5.1
RCheesley Feb 26, 2026
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
22 changes: 21 additions & 1 deletion .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,46 @@
.github
.wordpress-org
.gitignore
.gitattributes
.distignore
.travis.yml

# Exclude development and build files
node_modules/
composer.json
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The composer.json file is being excluded from distribution via .distignore, but the generated vendor/composer files are included. This means users cannot see the dependency configuration or regenerate the autoloader if needed. Consider whether composer.json should be included in the distribution for transparency and to allow advanced users to regenerate autoload files if necessary.

Suggested change
composer.json

Copilot uses AI. Check for mistakes.
composer.lock
package-lock.json
webpack.config.js

# Exclude test files
dist/
tests/
vendor/bin
vendor/myclabs
vendor/phar-io
vendor/phpdocumentor
vendor/phpspec
vendor/phpunit
vendor/sebastian
vendor/squizlabs
vendor/symfony
vendor/theseer
vendor/webmozart
vendor/wp-coding-standards
phpcs.xml
phpunit.xml
phpunit.xml.dist

# Exclude local environment files
.env
*.log


# Exclude Git
LICENSE
TODO
CHANGELOG.md
CONTRIBUTING.md
README.md
UPGRADE.md
UPGRADE.md
Makefile
1 change: 0 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ jobs:

# Steps can also provide arguments, so this configures 10up's action to also generate a zip file.
with:
dry-run: true
generate-zip: true
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of 'dry-run: true' from the deployment workflow means that deployments will now actually execute instead of being simulated. This is a significant operational change that could lead to unintended deployments if this workflow is triggered accidentally. Ensure that proper branch protection rules and approval processes are in place before merging this change.

Suggested change
generate-zip: true
generate-zip: true
dry-run: true

Copilot uses AI. Check for mistakes.

# Steps can also set environment variables which can be configured in the Github settings for the
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ jobs:
- uses: actions/checkout@master
- name: WordPress.org plugin asset/readme update
uses: 10up/action-wordpress-plugin-asset-update@stable
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of 'dry-run: true' from the asset update workflow means that asset updates will now actually be pushed to WordPress.org instead of being simulated. This operational change should be carefully coordinated to ensure it doesn't cause unintended updates to the WordPress.org plugin repository.

Suggested change
uses: 10up/action-wordpress-plugin-asset-update@stable
uses: 10up/action-wordpress-plugin-asset-update@stable
with:
dry-run: true

Copilot uses AI. Check for mistakes.
with:
dry-run: true
env:
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/.idea
/vendor/
/vendor/*
!/vendor/autoload.php
!/vendor/composer/
/phpunit.xml
/tests-coverage/
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,10 @@
"phpunit/phpunit": "^6.0",
"squizlabs/php_codesniffer": "^3.0",
"wp-coding-standards/wpcs": "^1.0"
},
"autoload": {
"psr-4": {
"Mautic\\WP_Mautic\\": "includes/classes/"
}
}
}
296 changes: 296 additions & 0 deletions includes/classes/Backend/Admin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,296 @@
<?php

namespace Mautic\WP_Mautic\Backend;

use Mautic\WP_Mautic\Utils\Options;

class Admin {

/**
* Init
*
* @return void
*/
public function init() {
add_action('admin_menu', array($this, 'wpmautic_settings'));
add_action('admin_init', array($this, 'wpmautic_admin_init'));
add_filter('plugin_action_links_' . plugin_basename(VPMAUTIC_PLUGIN_FILE), array($this, 'wpmautic_plugin_actions'), 10, 2);
}

/**
* Declare option page
*/
public function wpmautic_settings() {
add_options_page(
__( 'WP Mautic Settings', 'wp-mautic' ),
__( 'WPMautic', 'wp-mautic' ),
'manage_options',
'wpmautic',
array($this, 'wpmautic_options_page')
);
}

/**
* HTML for the Mautic option page
*/
public function wpmautic_options_page() {
?>
<div>
<h2><?php esc_html_e( 'WP Mautic', 'wp-mautic' ); ?></h2>
<p><?php esc_html_e( 'Add Mautic tracking capabilities to your website.', 'wp-mautic' ); ?></p>
<form action="options.php" method="post">
<?php settings_fields( 'wpmautic' ); ?>
<?php do_settings_sections( 'wpmautic' ); ?>
<?php submit_button(); ?>
</form>
<h3><?php esc_html_e( 'Shortcode Examples:', 'wp-mautic' ); ?></h3>
<ul>
<li><?php esc_html_e( 'Mautic Form Embed:', 'wp-mautic' ); ?> <code>[mautic type="form" id="1"]</code></li>
<li><?php esc_html_e( 'Mautic Dynamic Content:', 'wp-mautic' ); ?> <code>[mautic type="content" slot="slot_name"]<?php esc_html_e( 'Default Text', 'wp-mautic' ); ?>[/mautic]</code></li>
</ul>
<h3><?php esc_html_e( 'Quick Links', 'wp-mautic' ); ?></h3>
<ul>
<li>
<a href="https://github.com/mautic/mautic-wordpress#mautic-wordpress-plugin" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Plugin docs', 'wp-mautic' ); ?></a>
</li>
<li>
<a href="https://github.com/mautic/mautic-wordpress/issues" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Plugin support', 'wp-mautic' ); ?></a>
</li>
<li>
<a href="https://mautic.org" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Mautic project', 'wp-mautic' ); ?></a>
</li>
<li>
<a href="http://docs.mautic.org/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Mautic docs', 'wp-mautic' ); ?></a>
</li>
<li>
<a href="https://www.mautic.org/community/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Mautic forum', 'wp-mautic' ); ?></a>
</li>
</ul>
</div>
<?php
}


/**
* Define admin_init hook logic
*/
public function wpmautic_admin_init() {
register_setting( 'wpmautic', 'wpmautic_options', array($this, 'wpmautic_options_validate') );

add_settings_section(
'wpmautic_main',
__( 'Main Settings', 'wp-mautic' ),
array($this, 'wpmautic_section_text'),
'wpmautic'
);

add_settings_field(
'wpmautic_base_url',
__( 'Mautic URL', 'wp-mautic' ),
array($this, 'wpmautic_base_url'),
'wpmautic',
'wpmautic_main'
);
add_settings_field(
'wpmautic_script_location',
__( 'Tracking script location', 'wp-mautic' ),
array($this, 'wpmautic_script_location'),
'wpmautic',
'wpmautic_main'
);
add_settings_field(
'wpmautic_fallback_activated',
__( 'Tracking image', 'wp-mautic' ),
array($this, 'wpmautic_fallback_activated'),
'wpmautic',
'wpmautic_main'
);
add_settings_field(
'wpmautic_track_logged_user',
__( 'Logged user', 'wp-mautic' ),
array($this, 'wpmautic_track_logged_user'),
'wpmautic',
'wpmautic_main'
);
}

/**
* Section text
*/
public function wpmautic_section_text() {
}

/**
* Define the input field for Mautic base URL
*/
public function wpmautic_base_url() {
$url = Options::get( 'base_url', '' );

?>
<input
id="wpmautic_base_url"
name="wpmautic_options[base_url]"
size="40"
type="text"
placeholder="https://..."
value="<?php echo esc_url_raw( $url, array( 'http', 'https' ) ); ?>"
/>
<?php
}

/**
* Define the input field for Mautic script location
*/
public function wpmautic_script_location() {
$position = Options::get( 'script_location', '' );
$allowed_tags = array(
'br' => array(),
'code' => array(),
);

?>
<fieldset id="wpmautic_script_location">
<label>
<input
type="radio"
name="wpmautic_options[script_location]"
value="header"
<?php
if ( 'footer' !== $position && 'disabled' !== $position ) :
?>
checked<?php endif; ?>
/>
<?php echo wp_kses( __( 'Added in the <code>wp_head</code> action.<br/>Inserts the tracking code before the <code>&lt;head&gt;</code> tag; can be slightly slower since page load is delayed until all scripts in <code><head></code> are loaded and processed.', 'wp-mautic' ), $allowed_tags ); ?>
</label>
<br/>
<label>
<input
type="radio"
name="wpmautic_options[script_location]"
value="footer"
<?php
if ( 'footer' === $position ) :
?>
checked<?php endif; ?>
/>
<?php echo wp_kses( __( 'Embedded within the <code>wp_footer</code> action.<br/>Inserts the tracking code before the <code>&lt;/body&gt;</code> tag; slightly better for performance but may track less reliably if users close the page before the script has loaded.', 'wp-mautic' ), $allowed_tags ); ?>
</label>
<br />
<label>
<input
type="radio"
name="wpmautic_options[script_location]"
value="disabled"
<?php
if ( 'disabled' === $position ) :
?>
checked<?php endif; ?>
/>
<?php echo wp_kses( __( 'Visitor will not be tracked when rendering the page. Use this option to comply with GDPR regulations. If the visitor accept cookies you must execute the <code>wpmautic_send()</code> JavaScript function to start tracking.', 'wp-mautic' ), $allowed_tags ); ?>
<br/>
<?php echo wp_kses( __( 'However when using shortcodes, a tracking cookie will be added everytime even when tracking is disabled. This is because loading a Mautic resource (javascript or image) generate that cookie.', 'wp-mautic' ), $allowed_tags ); ?>
</label>
</fieldset>
<?php
}


/**
* Define the input field for Mautic fallback flag
*/
public function wpmautic_fallback_activated() {
$flag = Options::get( 'fallback_activated', false );
$allowed_tags = array(
'br' => array(),
'code' => array(),
);

?>
<select id="wpmautic_fallback_activated" name="wpmautic_options[fallback_activated]">
<option value="0" <?php selected( $flag, '0' ); ?>><?php esc_html_e( 'Disabled', 'wp-mautic' ); ?></option>
<option value="1" <?php selected( $flag, '1' ); ?>><?php esc_html_e( 'Only When JavaScript is Disabled', 'wp-mautic' ); ?></option>
<option value="2" <?php selected( $flag, '2' ); ?>><?php esc_html_e( 'Replace mtc.js', 'wp-mautic' ); ?></option>
</select>
<br />
<label for="wpmautic_fallback_activated">
<?php echo wp_kses( __( 'Use "Replace mtc.js" if you want to use the tracking pixel as the default and only way to track even if JavaScript is enabled/disabled.', 'wp-mautic' ), $allowed_tags ); ?>
<br />
<?php echo wp_kses( __( 'Be warned, that the tracking image will always generate a cookie on the user browser side. If you want to control cookies and comply to GDPR, you must use JavaScript instead.', 'wp-mautic' ), $allowed_tags ); ?>
</label>
<?php
}

/**
* Define the input field for Mautic logged user tracking flag
*/
public function wpmautic_track_logged_user() {
$flag = Options::get( 'track_logged_user', false );

?>
<input
id="wpmautic_track_logged_user"
name="wpmautic_options[track_logged_user]"
type="checkbox"
value="1"
<?php
if ( true === $flag ) :
?>
checked<?php endif; ?>
/>
<label for="wpmautic_track_logged_user">
<?php esc_html_e( 'Track user information for logged-in users', 'wp-mautic' ); ?>
</label>
<?php
}

/**
* Validate base URL input value
*
* @param array $input Input data.
* @return array
*/
public function wpmautic_options_validate( $input ) {
$options = get_option( 'wpmautic_options' );

$input['base_url'] = isset( $input['base_url'] )
? trim( $input['base_url'], " \t\n\r\0\x0B/" )
: '';

$options['base_url'] = esc_url_raw( trim( $input['base_url'], " \t\n\r\0\x0B/" ) );
$options['script_location'] = isset( $input['script_location'] )
? trim( $input['script_location'] )
: 'header';
if ( ! in_array( $options['script_location'], array( 'header', 'footer', 'disabled' ), true ) ) {
$options['script_location'] = 'header';
}

if ( isset( $input['fallback_activated'] ) && in_array( $input['fallback_activated'], array( '0', '1', '2' ), true ) ) {
$options['fallback_activated'] = sanitize_text_field($input['fallback_activated']);
} else {
$options['fallback_activated'] = '0'; // Default to disabled
}

Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The track_logged_user option is not being validated or saved in the wpmautic_options_validate method. Lines 267-271 handle fallback_activated, but there's no corresponding code to handle track_logged_user from the input. This means changes to the "Track user information for logged-in users" checkbox won't be saved. Add validation for the track_logged_user option similar to the pattern used in the removed options.php file.

Suggested change
// Track logged-in user information (checkbox).
if ( isset( $input['track_logged_user'] ) && '1' === $input['track_logged_user'] ) {
$options['track_logged_user'] = true;
} else {
$options['track_logged_user'] = false;
}

Copilot uses AI. Check for mistakes.
return $options;
}

/**
* Settings Link in the ``Installed Plugins`` page
*
* @param array $links array of plugin action links.
*
* @return array
*/
public function wpmautic_plugin_actions( $links ) {
if ( function_exists( 'admin_url' ) ) {
$settings_link = sprintf(
'<a href="%s">%s</a>',
admin_url( 'options-general.php?page=wpmautic' ),
__( 'Settings', 'wp-mautic' )
);
// Add the settings link before other links.
array_unshift( $links, $settings_link );
}
return $links;
}

}
Comment on lines +7 to +296
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent indentation: The class uses mixed indentation with both tabs and spaces. Lines 15-17 use tabs, while other parts use 2-space indentation. WordPress Coding Standards require consistent use of tabs for indentation. The entire class should be reformatted to use tabs consistently.

Copilot uses AI. Check for mistakes.
Loading
Loading