diff --git a/.distignore b/.distignore
index 5c7e124..10f0fe3 100644
--- a/.distignore
+++ b/.distignore
@@ -3,16 +3,33 @@
.github
.wordpress-org
.gitignore
+.gitattributes
.distignore
+.travis.yml
# Exclude development and build files
node_modules/
+composer.json
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
@@ -20,9 +37,12 @@ phpunit.xml.dist
.env
*.log
+
# Exclude Git
LICENSE
TODO
CHANGELOG.md
+CONTRIBUTING.md
README.md
-UPGRADE.md
\ No newline at end of file
+UPGRADE.md
+Makefile
\ No newline at end of file
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index 2c549b0..1a5595f 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -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
# Steps can also set environment variables which can be configured in the Github settings for the
diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml
index 27ebe73..20a12e7 100644
--- a/.github/workflows/update.yml
+++ b/.github/workflows/update.yml
@@ -11,8 +11,6 @@ jobs:
- uses: actions/checkout@master
- name: WordPress.org plugin asset/readme update
uses: 10up/action-wordpress-plugin-asset-update@stable
- with:
- dry-run: true
env:
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
diff --git a/.gitignore b/.gitignore
index 95bda14..3812c43 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,6 @@
/.idea
-/vendor/
+/vendor/*
+!/vendor/autoload.php
+!/vendor/composer/
/phpunit.xml
/tests-coverage/
diff --git a/composer.json b/composer.json
index acd377a..9518f04 100644
--- a/composer.json
+++ b/composer.json
@@ -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/"
+ }
}
}
diff --git a/includes/classes/Backend/Admin.php b/includes/classes/Backend/Admin.php
new file mode 100644
index 0000000..a609adc
--- /dev/null
+++ b/includes/classes/Backend/Admin.php
@@ -0,0 +1,296 @@
+
+
+
+
+
+
+
+ -
[mautic type="form" id="1"]
+ -
[mautic type="content" slot="slot_name"][/mautic]
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+
+ array(),
+ 'code' => array(),
+ );
+
+ ?>
+
+ array(),
+ 'code' => array(),
+ );
+
+ ?>
+
+
+
+
+
+ checked
+ />
+
+ %s',
+ admin_url( 'options-general.php?page=wpmautic' ),
+ __( 'Settings', 'wp-mautic' )
+ );
+ // Add the settings link before other links.
+ array_unshift( $links, $settings_link );
+ }
+ return $links;
+ }
+
+}
\ No newline at end of file
diff --git a/includes/classes/Backend_Loader.php b/includes/classes/Backend_Loader.php
new file mode 100644
index 0000000..23d4f3d
--- /dev/null
+++ b/includes/classes/Backend_Loader.php
@@ -0,0 +1,28 @@
+load_admin();
+ }
+
+ /**
+ * Load Admin
+ *
+ * @return void
+ */
+ public function load_admin() {
+ $admin = new Admin();
+ $admin->init();
+ }
+
+}
\ No newline at end of file
diff --git a/includes/classes/Dependency_Loader.php b/includes/classes/Dependency_Loader.php
new file mode 100644
index 0000000..44c599f
--- /dev/null
+++ b/includes/classes/Dependency_Loader.php
@@ -0,0 +1,37 @@
+load_frontend();
+ $this->load_backend();
+ }
+
+ /**
+ * Load Frontend
+ *
+ * @return void
+ */
+ public function load_frontend() {
+ $frontend_loader = new Frontend_Loader();
+ $frontend_loader->init();
+ }
+
+ /**
+ * Load Backend
+ *
+ * @return void
+ */
+ public function load_backend() {
+ $backend_loader = new Backend_Loader();
+ $backend_loader->init();
+ }
+
+}
\ No newline at end of file
diff --git a/includes/classes/Frontend/Enqueue.php b/includes/classes/Frontend/Enqueue.php
new file mode 100644
index 0000000..51cda43
--- /dev/null
+++ b/includes/classes/Frontend/Enqueue.php
@@ -0,0 +1,222 @@
+enqueue();
+ }
+
+ /**
+ * Enqueue scripts and styles
+ *
+ * @return void
+ */
+ public function enqueue() {
+ $this->enqueue_scripts();
+ }
+
+ /**
+ * Enqueue scripts
+ *
+ * @return void
+ */
+ public function enqueue_scripts() {
+ $script_location = Options::get( 'script_location' );
+ $fallback = Options::get( 'fallback_activated', false );
+
+ if ('0' === $fallback || '1' === $fallback) {
+ if ( 'header' === $script_location ) {
+ add_action( 'wp_head', array( $this, 'wpmautic_inject_script' ) );
+ } else {
+ add_action( 'wp_footer', array( $this, 'wpmautic_inject_script' ) );
+ }
+
+ if ( 'disabled' !== $script_location && '1' === $fallback ) {
+ add_action( 'wp_footer', array( $this, 'wpmautic_inject_noscript' ) );
+ }
+ } elseif ('2' === $fallback) {
+ add_action( 'wp_footer', array( $this, 'wpmautic_inject_tracking_pixel' ) );
+ }
+ }
+
+ /**
+ * Writes Tracking JS to the HTML source
+ *
+ * @return void
+ */
+ public function wpmautic_inject_script() {
+ // Load the Mautic tracking library mtc.js if it is not disabled.
+ $base_url = $this->wpmautic_base_script();
+ $script_location = Options::get( 'script_location' );
+ $attrs = $this->wpmautic_get_tracking_attributes();
+ ?>
+
+ tags are not allowed in header !
+ *
+ * @return void
+ */
+ public function wpmautic_inject_noscript() {
+ $base_url = Options::get( 'base_url', '' );
+ if ( empty( $base_url ) ) {
+ return;
+ }
+
+ $url_query = $this->wpmautic_get_url_query();
+ $payload = rawurlencode( base64_encode( serialize( $url_query ) ) );
+ ?>
+
+ tags are not allowed in header !
+ *
+ * @return void
+ */
+ public function wpmautic_inject_tracking_pixel() {
+ $base_url = Options::get( 'base_url', '' );
+ if ( empty( $base_url ) ) {
+ return;
+ }
+
+ $url_query = $this->wpmautic_get_url_query();
+ $payload = rawurlencode( base64_encode( serialize( $url_query ) ) );
+ ?>
+
+ query_string, '', home_url( $wp->request ) );
+
+ $attrs = $this->wpmautic_get_tracking_attributes();
+
+ $attrs['language'] = get_locale();
+ $attrs['page_url'] = $current_url;
+ $attrs['page_title'] = function_exists( 'wp_get_document_title' )
+ ? wp_get_document_title()
+ : wp_title( '»', false );
+ $attrs['referrer'] = function_exists( 'wp_get_raw_referer' )
+ ? wp_get_raw_referer()
+ : null;
+ if ( false === $attrs['referrer'] ) {
+ $attrs['referrer'] = $current_url;
+ }
+
+ return $attrs;
+ }
+
+ /**
+ * Create custom query parameters to be injected inside tracking
+ *
+ * @return array
+ */
+ private function wpmautic_get_tracking_attributes() {
+ $attrs = $this->wpmautic_get_user_query();
+
+ /**
+ * Update / add data to be sent within Mautic tracker
+ *
+ * Default data only contains the 'language' key but every added key to the
+ * array will be sent to Mautic.
+ *
+ * @since 2.1.0
+ *
+ * @param array $attrs Attributes to be filters, default ['language' => get_locale()]
+ */
+ return apply_filters( 'wpmautic_tracking_attributes', $attrs );
+ }
+
+ /**
+ * Extract logged user information to be sent within Mautic tracker
+ *
+ * @return array
+ */
+ private function wpmautic_get_user_query() {
+ $attrs = array();
+
+ if (
+ true === Options::get( 'track_logged_user', false ) &&
+ is_user_logged_in()
+ ) {
+ $current_user = wp_get_current_user();
+ $attrs['email'] = $current_user->user_email;
+ $attrs['firstname'] = $current_user->user_firstname;
+ $attrs['lastname'] = $current_user->user_lastname;
+
+ // Following Mautic fields has to be created manually and the fields must match these names.
+ $attrs['wp_user'] = $current_user->user_login;
+ $attrs['wp_alias'] = $current_user->display_name;
+ $attrs['wp_registration_date'] = date(
+ 'Y-m-d',
+ strtotime( $current_user->user_registered )
+ );
+ }
+
+ return $attrs;
+ }
+
+}
\ No newline at end of file
diff --git a/includes/classes/Frontend/Shortcodes.php b/includes/classes/Frontend/Shortcodes.php
new file mode 100644
index 0000000..4073597
--- /dev/null
+++ b/includes/classes/Frontend/Shortcodes.php
@@ -0,0 +1,237 @@
+ null,
+ ),
+ $atts
+ );
+
+ switch ( $default['type'] ) {
+ case 'form':
+ return $this->wpmautic_form_shortcode( $atts );
+ case 'content':
+ return $this->wpmautic_dwc_shortcode( $atts, $content );
+ case 'video':
+ return $this->wpmautic_video_shortcode( $atts );
+ case 'tags':
+ return $this->wpmautic_tags_shortcode( $atts );
+ case 'focus':
+ return $this->wpmautic_focus_shortcode( $atts );
+ }
+
+ return false;
+ }
+
+ /**
+ * Handle mauticform shortcode
+ * example: [mautic type="form" id="1"]
+ *
+ * @param array $atts Shortcode attributes.
+ *
+ * @return string
+ */
+ public function wpmautic_form_shortcode( $atts ) {
+ $base_url = Options::get( 'base_url', '' );
+ if ( '' === $base_url ) {
+ return false;
+ }
+
+ $atts = shortcode_atts(
+ array(
+ 'id' => '',
+ ),
+ $atts
+ );
+
+ if ( empty( $atts['id'] ) ) {
+ return false;
+ }
+
+ return '';
+ }
+
+ /**
+ * Dynamic content shortcode handling
+ * example: [mautic type="content" slot="slot_name"]Default Content[/mautic]
+ *
+ * @param array $atts Shortcode attributes.
+ * @param string|null $content Default content to be displayed.
+ *
+ * @return string
+ */
+ public function wpmautic_dwc_shortcode( $atts, $content = null ) {
+ $atts = shortcode_atts(
+ array(
+ 'slot' => '',
+ ),
+ $atts,
+ 'mautic'
+ );
+
+ return sprintf(
+ '%s
',
+ esc_attr( $atts['slot'] ),
+ wp_kses( $content, wp_kses_allowed_html( 'post' ) )
+ );
+ }
+
+ /**
+ * Video shortcode handling
+ * example: [mautic type="video" gate-time="15" form-id="1" src="https://www.youtube.com/watch?v=QT6169rdMdk"]
+ *
+ * @param array $atts Shortcode attributes.
+ *
+ * @return string
+ */
+ public function wpmautic_video_shortcode( $atts ) {
+ $atts = shortcode_atts(
+ array(
+ 'gate-time' => 15,
+ 'form-id' => '',
+ 'src' => '',
+ 'video-type' => '',
+ 'mautic-video' => 'true',
+ 'width' => 640,
+ 'height' => 360,
+ ),
+ $atts
+ );
+
+ if ( empty( $atts['src'] ) ) {
+ return __( 'You must provide a video source. Add a src="URL" attribute to your shortcode. Replace URL with the source url for your video.', 'wp-mautic' );
+ }
+
+ if ( empty( $atts['form-id'] ) && 'true' !== $atts['mautic-video'] ) {
+ return __( 'You must provide a mautic form id. Add a form-id="#" attribute to your shortcode. Replace # with the id of the form you want to use.', 'wp-mautic' );
+ }
+
+ if ( preg_match( '/^.*((youtu.be)|(youtube.com))\/((v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))?\??v?=?([^#\&\?]*).*/', $atts['src'] ) ) {
+ $atts['video-type'] = 'youtube';
+ }
+ if ( preg_match( '/^.*(vimeo\.com\/)((channels\/[A-z]+\/)|(groups\/[A-z]+\/videos\/))?([0-9]+)/', $atts['src'] ) ) {
+ $atts['video-type'] = 'vimeo';
+ }
+ if ( strtolower( substr( $atts['src'], -3 ) ) === 'mp4' ) {
+ $atts['video-type'] = 'mp4';
+ }
+
+ if ( empty( $atts['video-type'] ) ) {
+ return __( 'Please define a valid video type with video-type="#".', 'wp-mautic' );
+ }
+
+ return sprintf(
+ '',
+ esc_attr( $atts['height'] ),
+ esc_attr( $atts['width'] ),
+ esc_attr( $atts['form-id'] ),
+ esc_attr( $atts['gate-time'] ),
+ esc_attr( $atts['mautic-video'] ),
+ esc_attr( $atts['video-type'] ),
+ esc_attr( $atts['src'] )
+ );
+ }
+
+ /**
+ * Handle mautic tags by WordPress shortcodes
+ * example: [mautic type="tags" values="addtag,-removetag"]
+ *
+ * @param array $atts Shortcode attributes.
+ *
+ * @return string
+ */
+ public function wpmautic_tags_shortcode( $atts ) {
+ $base_url = Options::get( 'base_url', '' );
+ if ( '' === $base_url ) {
+ return false;
+ }
+
+ $atts = shortcode_atts(
+ array(
+ 'values' => '',
+ ),
+ $atts
+ );
+
+ if ( empty( $atts['values'] ) ) {
+ return false;
+ }
+
+ return sprintf(
+ '
',
+ esc_url( $base_url ),
+ esc_attr( $atts['values'] ),
+ esc_attr__( 'Mautic Tags', 'wp-mautic' )
+ );
+ }
+
+ /**
+ * Handle mautic focus items on WordPress Page
+ * example: [mautic type="focus" id="1"]
+ *
+ * @param array $atts Shortcode attributes.
+ *
+ * @return string
+ */
+ public function wpmautic_focus_shortcode( $atts ) {
+ $base_url = Options::get( 'base_url', '' );
+ if ( '' === $base_url ) {
+ return false;
+ }
+
+ $atts = shortcode_atts(
+ array(
+ 'id' => '',
+ ),
+ $atts
+ );
+
+ if ( empty( $atts['id'] ) ) {
+ return false;
+ }
+
+ return '';
+ }
+
+}
\ No newline at end of file
diff --git a/includes/classes/Frontend_Loader.php b/includes/classes/Frontend_Loader.php
new file mode 100644
index 0000000..48d636e
--- /dev/null
+++ b/includes/classes/Frontend_Loader.php
@@ -0,0 +1,40 @@
+load_enqueue();
+ $this->load_shortcodes();
+ }
+
+ /**
+ * Enqueue
+ *
+ * @return void
+ */
+ public function load_enqueue() {
+ $enqueue = new Enqueue();
+ $enqueue->init();
+ }
+
+ /**
+ * Load Shortcodes
+ *
+ * @return void
+ */
+ public function load_shortcodes() {
+ $shortcodes = new Shortcodes();
+ $shortcodes->init();
+ }
+
+}
\ No newline at end of file
diff --git a/includes/classes/Utils/Options.php b/includes/classes/Utils/Options.php
new file mode 100644
index 0000000..d4b0e19
--- /dev/null
+++ b/includes/classes/Utils/Options.php
@@ -0,0 +1,45 @@
+\n"
+"Language-Team: LANGUAGE \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"POT-Creation-Date: 2025-08-03T19:55:07+00:00\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"X-Generator: WP-CLI 2.11.0\n"
+"X-Domain: wp-mautic\n"
+
+#. Plugin Name of the plugin
+#: wpmautic.php
+#: includes/classes/Backend/Admin.php:39
+msgid "WP Mautic"
+msgstr ""
+
+#. Plugin URI of the plugin
+#: wpmautic.php
+msgid "https://github.com/mautic/mautic-wordpress"
+msgstr ""
+
+#. Description of the plugin
+#: wpmautic.php
+msgid "This plugin will allow you to add Mautic (Free Open Source Marketing Automation) tracking to your site"
+msgstr ""
+
+#. Author of the plugin
+#: wpmautic.php
+msgid "Mautic community"
+msgstr ""
+
+#. Author URI of the plugin
+#: wpmautic.php
+msgid "http://mautic.org"
+msgstr ""
+
+#: includes/classes/Backend/Admin.php:25
+msgid "WP Mautic Settings"
+msgstr ""
+
+#: includes/classes/Backend/Admin.php:26
+msgid "WPMautic"
+msgstr ""
+
+#: includes/classes/Backend/Admin.php:40
+msgid "Add Mautic tracking capabilities to your website."
+msgstr ""
+
+#: includes/classes/Backend/Admin.php:46
+msgid "Shortcode Examples:"
+msgstr ""
+
+#: includes/classes/Backend/Admin.php:48
+msgid "Mautic Form Embed:"
+msgstr ""
+
+#: includes/classes/Backend/Admin.php:49
+msgid "Mautic Dynamic Content:"
+msgstr ""
+
+#: includes/classes/Backend/Admin.php:49
+msgid "Default Text"
+msgstr ""
+
+#: includes/classes/Backend/Admin.php:51
+msgid "Quick Links"
+msgstr ""
+
+#: includes/classes/Backend/Admin.php:54
+msgid "Plugin docs"
+msgstr ""
+
+#: includes/classes/Backend/Admin.php:57
+msgid "Plugin support"
+msgstr ""
+
+#: includes/classes/Backend/Admin.php:60
+msgid "Mautic project"
+msgstr ""
+
+#: includes/classes/Backend/Admin.php:63
+msgid "Mautic docs"
+msgstr ""
+
+#: includes/classes/Backend/Admin.php:66
+msgid "Mautic forum"
+msgstr ""
+
+#: includes/classes/Backend/Admin.php:82
+msgid "Main Settings"
+msgstr ""
+
+#: includes/classes/Backend/Admin.php:89
+msgid "Mautic URL"
+msgstr ""
+
+#: includes/classes/Backend/Admin.php:96
+msgid "Tracking script location"
+msgstr ""
+
+#: includes/classes/Backend/Admin.php:103
+msgid "Tracking image"
+msgstr ""
+
+#: includes/classes/Backend/Admin.php:110
+msgid "Logged user"
+msgstr ""
+
+#: includes/classes/Backend/Admin.php:163
+msgid "Added in the wp_head action.
Inserts the tracking code before the <head> tag; can be slightly slower since page load is delayed until all scripts in are loaded and processed."
+msgstr ""
+
+#: includes/classes/Backend/Admin.php:176
+msgid "Embedded within the wp_footer action.
Inserts the tracking code before the </body> tag; slightly better for performance but may track less reliably if users close the page before the script has loaded."
+msgstr ""
+
+#: includes/classes/Backend/Admin.php:189
+msgid "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 wpmautic_send() JavaScript function to start tracking."
+msgstr ""
+
+#: includes/classes/Backend/Admin.php:191
+msgid "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."
+msgstr ""
+
+#: includes/classes/Backend/Admin.php:210
+msgid "Disabled"
+msgstr ""
+
+#: includes/classes/Backend/Admin.php:211
+msgid "Only When JavaScript is Disabled"
+msgstr ""
+
+#: includes/classes/Backend/Admin.php:212
+msgid "Replace mtc.js"
+msgstr ""
+
+#: includes/classes/Backend/Admin.php:216
+msgid "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."
+msgstr ""
+
+#: includes/classes/Backend/Admin.php:218
+msgid "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."
+msgstr ""
+
+#: includes/classes/Backend/Admin.php:241
+msgid "Track user information for logged-in users"
+msgstr ""
+
+#: includes/classes/Backend/Admin.php:288
+msgid "Settings"
+msgstr ""
+
+#: includes/classes/Frontend/Enqueue.php:66
+msgid "WPMautic: mt not defined. Did you load mtc.js?"
+msgstr ""
+
+#: includes/classes/Frontend/Enqueue.php:107
+#: includes/classes/Frontend/Enqueue.php:127
+#: includes/classes/Frontend/Shortcodes.php:201
+msgid "Mautic Tags"
+msgstr ""
+
+#: includes/classes/Frontend/Shortcodes.php:137
+msgid "You must provide a video source. Add a src=\"URL\" attribute to your shortcode. Replace URL with the source url for your video."
+msgstr ""
+
+#: includes/classes/Frontend/Shortcodes.php:141
+msgid "You must provide a mautic form id. Add a form-id=\"#\" attribute to your shortcode. Replace # with the id of the form you want to use."
+msgstr ""
+
+#: includes/classes/Frontend/Shortcodes.php:155
+msgid "Please define a valid video type with video-type=\"#\"."
+msgstr ""
+
+#: includes/classes/Utils/Options.php:38
+msgid "You must give a valid option name !"
+msgstr ""
+
+#: wpmautic.php:22
+msgid "This file should not be accessed directly!"
+msgstr ""
diff --git a/options.php b/options.php
deleted file mode 100644
index 5209704..0000000
--- a/options.php
+++ /dev/null
@@ -1,260 +0,0 @@
-
-
-
-
-
-
-
- -
[mautic type="form" id="1"]
- -
[mautic type="content" slot="slot_name"][/mautic]
-
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
-
-
-
-
- array(),
- 'code' => array(),
- );
-
- ?>
-
- array(),
- 'code' => array(),
- );
-
- ?>
-
- checked
- />
-
-
-
- checked
- />
-
- null,
- ),
- $atts
- );
-
- switch ( $default['type'] ) {
- case 'form':
- return wpmautic_form_shortcode( $atts );
- case 'content':
- return wpmautic_dwc_shortcode( $atts, $content );
- case 'video':
- return wpmautic_video_shortcode( $atts );
- case 'tags':
- return wpmautic_tags_shortcode( $atts );
- case 'focus':
- return wpmautic_focus_shortcode( $atts );
- }
-
- return false;
-}
-
-/**
- * Handle mauticform shortcode
- * example: [mautic type="form" id="1"]
- *
- * @param array $atts Shortcode attributes.
- *
- * @return string
- */
-function wpmautic_form_shortcode( $atts ) {
- $base_url = wpmautic_option( 'base_url', '' );
- if ( '' === $base_url ) {
- return false;
- }
-
- $atts = shortcode_atts(
- array(
- 'id' => '',
- ),
- $atts
- );
-
- if ( empty( $atts['id'] ) ) {
- return false;
- }
-
- return '';
-}
-
-/**
- * Dynamic content shortcode handling
- * example: [mautic type="content" slot="slot_name"]Default Content[/mautic]
- *
- * @param array $atts Shortcode attributes.
- * @param string|null $content Default content to be displayed.
- *
- * @return string
- */
-function wpmautic_dwc_shortcode( $atts, $content = null ) {
- $atts = shortcode_atts(
- array(
- 'slot' => '',
- ),
- $atts,
- 'mautic'
- );
-
- return sprintf(
- '%s
',
- esc_attr( $atts['slot'] ),
- wp_kses( $content, wp_kses_allowed_html( 'post' ) )
- );
-}
-
-/**
- * Video shortcode handling
- * example: [mautic type="video" gate-time="15" form-id="1" src="https://www.youtube.com/watch?v=QT6169rdMdk"]
- *
- * @param array $atts Shortcode attributes.
- *
- * @return string
- */
-function wpmautic_video_shortcode( $atts ) {
- $atts = shortcode_atts(
- array(
- 'gate-time' => 15,
- 'form-id' => '',
- 'src' => '',
- 'video-type' => '',
- 'mautic-video' => 'true',
- 'width' => 640,
- 'height' => 360,
- ),
- $atts
- );
-
- if ( empty( $atts['src'] ) ) {
- return __( 'You must provide a video source. Add a src="URL" attribute to your shortcode. Replace URL with the source url for your video.', 'wp-mautic' );
- }
-
- if ( empty( $atts['form-id'] ) && 'true' !== $atts['mautic-video'] ) {
- return __( 'You must provide a mautic form id. Add a form-id="#" attribute to your shortcode. Replace # with the id of the form you want to use.', 'wp-mautic' );
- }
-
- if ( preg_match( '/^.*((youtu.be)|(youtube.com))\/((v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))?\??v?=?([^#\&\?]*).*/', $atts['src'] ) ) {
- $atts['video-type'] = 'youtube';
- }
- if ( preg_match( '/^.*(vimeo\.com\/)((channels\/[A-z]+\/)|(groups\/[A-z]+\/videos\/))?([0-9]+)/', $atts['src'] ) ) {
- $atts['video-type'] = 'vimeo';
- }
- if ( strtolower( substr( $atts['src'], -3 ) ) === 'mp4' ) {
- $atts['video-type'] = 'mp4';
- }
-
- if ( empty( $atts['video-type'] ) ) {
- return __( 'Please define a valid video type with video-type="#".', 'wp-mautic' );
- }
-
- return sprintf(
- '',
- esc_attr( $atts['height'] ),
- esc_attr( $atts['width'] ),
- esc_attr( $atts['form-id'] ),
- esc_attr( $atts['gate-time'] ),
- esc_attr( $atts['mautic-video'] ),
- esc_attr( $atts['video-type'] ),
- esc_attr( $atts['src'] )
- );
-}
-
-/**
- * Handle mautic tags by WordPress shortcodes
- * example: [mautic type="tags" values="addtag,-removetag"]
- *
- * @param array $atts Shortcode attributes.
- *
- * @return string
- */
-function wpmautic_tags_shortcode( $atts ) {
- $base_url = wpmautic_option( 'base_url', '' );
- if ( '' === $base_url ) {
- return false;
- }
-
- $atts = shortcode_atts(
- array(
- 'values' => '',
- ),
- $atts
- );
-
- if ( empty( $atts['values'] ) ) {
- return false;
- }
-
- return sprintf(
- '
',
- esc_url( $base_url ),
- esc_attr( $atts['values'] ),
- esc_attr__( 'Mautic Tags', 'wp-mautic' )
- );
-}
-
-/**
- * Handle mautic focus itens on WordPress Page
- * example: [mautic type="focus" id="1"]
- *
- * @param array $atts Shortcode attributes.
- *
- * @return string
- */
-function wpmautic_focus_shortcode( $atts ) {
- $base_url = wpmautic_option( 'base_url', '' );
- if ( '' === $base_url ) {
- return false;
- }
-
- $atts = shortcode_atts(
- array(
- 'id' => '',
- ),
- $atts
- );
-
- if ( empty( $atts['id'] ) ) {
- return false;
- }
-
- return '';
-}
diff --git a/tests/OptionsTest.php b/tests/OptionsTest.php
index d49ea4d..9fb1ae6 100644
--- a/tests/OptionsTest.php
+++ b/tests/OptionsTest.php
@@ -3,6 +3,8 @@
* @package wpmautic\tests
*/
+use Mautic\WP_Mautic\Utils\Options;
+
/**
* Test Mautic options management
*/
@@ -13,7 +15,7 @@ class OptionsTest extends WP_UnitTestCase
*/
public function test_invalid_option_name()
{
- wpmautic_option('azerty123456');
+ Options::get('azerty123456');
}
public function test_base_url_when_empty()
@@ -21,7 +23,7 @@ public function test_base_url_when_empty()
update_option('wpmautic_options', array(
'base_url' => ''
));
- $this->assertEmpty(wpmautic_option('base_url'));
+ $this->assertEmpty(Options::get('base_url'));
}
public function test_base_url_with_value()
@@ -29,13 +31,13 @@ public function test_base_url_with_value()
update_option('wpmautic_options', array(
'base_url' => 'http://example.com'
));
- $this->assertEquals('http://example.com', wpmautic_option('base_url'));
+ $this->assertEquals('http://example.com', Options::get('base_url'));
}
public function test_script_location_when_empty()
{
update_option('wpmautic_options', array());
- $this->assertEquals('header', wpmautic_option('script_location'));
+ $this->assertEquals('header', Options::get('script_location'));
}
public function test_script_location_with_value()
@@ -43,7 +45,7 @@ public function test_script_location_with_value()
update_option('wpmautic_options', array(
'script_location' => 'footer'
));
- $this->assertEquals('footer', wpmautic_option('script_location'));
+ $this->assertEquals('footer', Options::get('script_location'));
}
public function test_script_location_with_disabled_value()
@@ -51,13 +53,13 @@ public function test_script_location_with_disabled_value()
update_option('wpmautic_options', array(
'script_location' => 'disabled'
));
- $this->assertEquals('disabled', wpmautic_option('script_location'));
+ $this->assertEquals('disabled', Options::get('script_location'));
}
public function test_fallback_activated_when_empty()
{
update_option('wpmautic_options', array());
- $this->assertTrue(wpmautic_option('fallback_activated'));
+ $this->assertTrue(Options::get('fallback_activated'));
}
public function test_fallback_activated_with_value()
@@ -65,6 +67,6 @@ public function test_fallback_activated_with_value()
update_option('wpmautic_options', array(
'fallback_activated' => false
));
- $this->assertFalse(wpmautic_option('fallback_activated'));
+ $this->assertFalse(Options::get('fallback_activated'));
}
}
diff --git a/vendor/autoload.php b/vendor/autoload.php
new file mode 100644
index 0000000..f707bd8
--- /dev/null
+++ b/vendor/autoload.php
@@ -0,0 +1,25 @@
+
+ * Jordi Boggiano
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Composer\Autoload;
+
+/**
+ * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
+ *
+ * $loader = new \Composer\Autoload\ClassLoader();
+ *
+ * // register classes with namespaces
+ * $loader->add('Symfony\Component', __DIR__.'/component');
+ * $loader->add('Symfony', __DIR__.'/framework');
+ *
+ * // activate the autoloader
+ * $loader->register();
+ *
+ * // to enable searching the include path (eg. for PEAR packages)
+ * $loader->setUseIncludePath(true);
+ *
+ * In this example, if you try to use a class in the Symfony\Component
+ * namespace or one of its children (Symfony\Component\Console for instance),
+ * the autoloader will first look for the class under the component/
+ * directory, and it will then fallback to the framework/ directory if not
+ * found before giving up.
+ *
+ * This class is loosely based on the Symfony UniversalClassLoader.
+ *
+ * @author Fabien Potencier
+ * @author Jordi Boggiano
+ * @see https://www.php-fig.org/psr/psr-0/
+ * @see https://www.php-fig.org/psr/psr-4/
+ */
+class ClassLoader
+{
+ /** @var \Closure(string):void */
+ private static $includeFile;
+
+ /** @var string|null */
+ private $vendorDir;
+
+ // PSR-4
+ /**
+ * @var array>
+ */
+ private $prefixLengthsPsr4 = array();
+ /**
+ * @var array>
+ */
+ private $prefixDirsPsr4 = array();
+ /**
+ * @var list
+ */
+ private $fallbackDirsPsr4 = array();
+
+ // PSR-0
+ /**
+ * List of PSR-0 prefixes
+ *
+ * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
+ *
+ * @var array>>
+ */
+ private $prefixesPsr0 = array();
+ /**
+ * @var list
+ */
+ private $fallbackDirsPsr0 = array();
+
+ /** @var bool */
+ private $useIncludePath = false;
+
+ /**
+ * @var array
+ */
+ private $classMap = array();
+
+ /** @var bool */
+ private $classMapAuthoritative = false;
+
+ /**
+ * @var array
+ */
+ private $missingClasses = array();
+
+ /** @var string|null */
+ private $apcuPrefix;
+
+ /**
+ * @var array
+ */
+ private static $registeredLoaders = array();
+
+ /**
+ * @param string|null $vendorDir
+ */
+ public function __construct($vendorDir = null)
+ {
+ $this->vendorDir = $vendorDir;
+ self::initializeIncludeClosure();
+ }
+
+ /**
+ * @return array>
+ */
+ public function getPrefixes()
+ {
+ if (!empty($this->prefixesPsr0)) {
+ return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
+ }
+
+ return array();
+ }
+
+ /**
+ * @return array>
+ */
+ public function getPrefixesPsr4()
+ {
+ return $this->prefixDirsPsr4;
+ }
+
+ /**
+ * @return list
+ */
+ public function getFallbackDirs()
+ {
+ return $this->fallbackDirsPsr0;
+ }
+
+ /**
+ * @return list
+ */
+ public function getFallbackDirsPsr4()
+ {
+ return $this->fallbackDirsPsr4;
+ }
+
+ /**
+ * @return array Array of classname => path
+ */
+ public function getClassMap()
+ {
+ return $this->classMap;
+ }
+
+ /**
+ * @param array $classMap Class to filename map
+ *
+ * @return void
+ */
+ public function addClassMap(array $classMap)
+ {
+ if ($this->classMap) {
+ $this->classMap = array_merge($this->classMap, $classMap);
+ } else {
+ $this->classMap = $classMap;
+ }
+ }
+
+ /**
+ * Registers a set of PSR-0 directories for a given prefix, either
+ * appending or prepending to the ones previously set for this prefix.
+ *
+ * @param string $prefix The prefix
+ * @param list|string $paths The PSR-0 root directories
+ * @param bool $prepend Whether to prepend the directories
+ *
+ * @return void
+ */
+ public function add($prefix, $paths, $prepend = false)
+ {
+ $paths = (array) $paths;
+ if (!$prefix) {
+ if ($prepend) {
+ $this->fallbackDirsPsr0 = array_merge(
+ $paths,
+ $this->fallbackDirsPsr0
+ );
+ } else {
+ $this->fallbackDirsPsr0 = array_merge(
+ $this->fallbackDirsPsr0,
+ $paths
+ );
+ }
+
+ return;
+ }
+
+ $first = $prefix[0];
+ if (!isset($this->prefixesPsr0[$first][$prefix])) {
+ $this->prefixesPsr0[$first][$prefix] = $paths;
+
+ return;
+ }
+ if ($prepend) {
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
+ $paths,
+ $this->prefixesPsr0[$first][$prefix]
+ );
+ } else {
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
+ $this->prefixesPsr0[$first][$prefix],
+ $paths
+ );
+ }
+ }
+
+ /**
+ * Registers a set of PSR-4 directories for a given namespace, either
+ * appending or prepending to the ones previously set for this namespace.
+ *
+ * @param string $prefix The prefix/namespace, with trailing '\\'
+ * @param list|string $paths The PSR-4 base directories
+ * @param bool $prepend Whether to prepend the directories
+ *
+ * @throws \InvalidArgumentException
+ *
+ * @return void
+ */
+ public function addPsr4($prefix, $paths, $prepend = false)
+ {
+ $paths = (array) $paths;
+ if (!$prefix) {
+ // Register directories for the root namespace.
+ if ($prepend) {
+ $this->fallbackDirsPsr4 = array_merge(
+ $paths,
+ $this->fallbackDirsPsr4
+ );
+ } else {
+ $this->fallbackDirsPsr4 = array_merge(
+ $this->fallbackDirsPsr4,
+ $paths
+ );
+ }
+ } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
+ // Register directories for a new namespace.
+ $length = strlen($prefix);
+ if ('\\' !== $prefix[$length - 1]) {
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
+ }
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
+ $this->prefixDirsPsr4[$prefix] = $paths;
+ } elseif ($prepend) {
+ // Prepend directories for an already registered namespace.
+ $this->prefixDirsPsr4[$prefix] = array_merge(
+ $paths,
+ $this->prefixDirsPsr4[$prefix]
+ );
+ } else {
+ // Append directories for an already registered namespace.
+ $this->prefixDirsPsr4[$prefix] = array_merge(
+ $this->prefixDirsPsr4[$prefix],
+ $paths
+ );
+ }
+ }
+
+ /**
+ * Registers a set of PSR-0 directories for a given prefix,
+ * replacing any others previously set for this prefix.
+ *
+ * @param string $prefix The prefix
+ * @param list|string $paths The PSR-0 base directories
+ *
+ * @return void
+ */
+ public function set($prefix, $paths)
+ {
+ if (!$prefix) {
+ $this->fallbackDirsPsr0 = (array) $paths;
+ } else {
+ $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
+ }
+ }
+
+ /**
+ * Registers a set of PSR-4 directories for a given namespace,
+ * replacing any others previously set for this namespace.
+ *
+ * @param string $prefix The prefix/namespace, with trailing '\\'
+ * @param list|string $paths The PSR-4 base directories
+ *
+ * @throws \InvalidArgumentException
+ *
+ * @return void
+ */
+ public function setPsr4($prefix, $paths)
+ {
+ if (!$prefix) {
+ $this->fallbackDirsPsr4 = (array) $paths;
+ } else {
+ $length = strlen($prefix);
+ if ('\\' !== $prefix[$length - 1]) {
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
+ }
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
+ }
+ }
+
+ /**
+ * Turns on searching the include path for class files.
+ *
+ * @param bool $useIncludePath
+ *
+ * @return void
+ */
+ public function setUseIncludePath($useIncludePath)
+ {
+ $this->useIncludePath = $useIncludePath;
+ }
+
+ /**
+ * Can be used to check if the autoloader uses the include path to check
+ * for classes.
+ *
+ * @return bool
+ */
+ public function getUseIncludePath()
+ {
+ return $this->useIncludePath;
+ }
+
+ /**
+ * Turns off searching the prefix and fallback directories for classes
+ * that have not been registered with the class map.
+ *
+ * @param bool $classMapAuthoritative
+ *
+ * @return void
+ */
+ public function setClassMapAuthoritative($classMapAuthoritative)
+ {
+ $this->classMapAuthoritative = $classMapAuthoritative;
+ }
+
+ /**
+ * Should class lookup fail if not found in the current class map?
+ *
+ * @return bool
+ */
+ public function isClassMapAuthoritative()
+ {
+ return $this->classMapAuthoritative;
+ }
+
+ /**
+ * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
+ *
+ * @param string|null $apcuPrefix
+ *
+ * @return void
+ */
+ public function setApcuPrefix($apcuPrefix)
+ {
+ $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
+ }
+
+ /**
+ * The APCu prefix in use, or null if APCu caching is not enabled.
+ *
+ * @return string|null
+ */
+ public function getApcuPrefix()
+ {
+ return $this->apcuPrefix;
+ }
+
+ /**
+ * Registers this instance as an autoloader.
+ *
+ * @param bool $prepend Whether to prepend the autoloader or not
+ *
+ * @return void
+ */
+ public function register($prepend = false)
+ {
+ spl_autoload_register(array($this, 'loadClass'), true, $prepend);
+
+ if (null === $this->vendorDir) {
+ return;
+ }
+
+ if ($prepend) {
+ self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
+ } else {
+ unset(self::$registeredLoaders[$this->vendorDir]);
+ self::$registeredLoaders[$this->vendorDir] = $this;
+ }
+ }
+
+ /**
+ * Unregisters this instance as an autoloader.
+ *
+ * @return void
+ */
+ public function unregister()
+ {
+ spl_autoload_unregister(array($this, 'loadClass'));
+
+ if (null !== $this->vendorDir) {
+ unset(self::$registeredLoaders[$this->vendorDir]);
+ }
+ }
+
+ /**
+ * Loads the given class or interface.
+ *
+ * @param string $class The name of the class
+ * @return true|null True if loaded, null otherwise
+ */
+ public function loadClass($class)
+ {
+ if ($file = $this->findFile($class)) {
+ $includeFile = self::$includeFile;
+ $includeFile($file);
+
+ return true;
+ }
+
+ return null;
+ }
+
+ /**
+ * Finds the path to the file where the class is defined.
+ *
+ * @param string $class The name of the class
+ *
+ * @return string|false The path if found, false otherwise
+ */
+ public function findFile($class)
+ {
+ // class map lookup
+ if (isset($this->classMap[$class])) {
+ return $this->classMap[$class];
+ }
+ if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
+ return false;
+ }
+ if (null !== $this->apcuPrefix) {
+ $file = apcu_fetch($this->apcuPrefix.$class, $hit);
+ if ($hit) {
+ return $file;
+ }
+ }
+
+ $file = $this->findFileWithExtension($class, '.php');
+
+ // Search for Hack files if we are running on HHVM
+ if (false === $file && defined('HHVM_VERSION')) {
+ $file = $this->findFileWithExtension($class, '.hh');
+ }
+
+ if (null !== $this->apcuPrefix) {
+ apcu_add($this->apcuPrefix.$class, $file);
+ }
+
+ if (false === $file) {
+ // Remember that this class does not exist.
+ $this->missingClasses[$class] = true;
+ }
+
+ return $file;
+ }
+
+ /**
+ * Returns the currently registered loaders keyed by their corresponding vendor directories.
+ *
+ * @return array
+ */
+ public static function getRegisteredLoaders()
+ {
+ return self::$registeredLoaders;
+ }
+
+ /**
+ * @param string $class
+ * @param string $ext
+ * @return string|false
+ */
+ private function findFileWithExtension($class, $ext)
+ {
+ // PSR-4 lookup
+ $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
+
+ $first = $class[0];
+ if (isset($this->prefixLengthsPsr4[$first])) {
+ $subPath = $class;
+ while (false !== $lastPos = strrpos($subPath, '\\')) {
+ $subPath = substr($subPath, 0, $lastPos);
+ $search = $subPath . '\\';
+ if (isset($this->prefixDirsPsr4[$search])) {
+ $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
+ foreach ($this->prefixDirsPsr4[$search] as $dir) {
+ if (file_exists($file = $dir . $pathEnd)) {
+ return $file;
+ }
+ }
+ }
+ }
+ }
+
+ // PSR-4 fallback dirs
+ foreach ($this->fallbackDirsPsr4 as $dir) {
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
+ return $file;
+ }
+ }
+
+ // PSR-0 lookup
+ if (false !== $pos = strrpos($class, '\\')) {
+ // namespaced class name
+ $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
+ . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
+ } else {
+ // PEAR-like class name
+ $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
+ }
+
+ if (isset($this->prefixesPsr0[$first])) {
+ foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
+ if (0 === strpos($class, $prefix)) {
+ foreach ($dirs as $dir) {
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
+ return $file;
+ }
+ }
+ }
+ }
+ }
+
+ // PSR-0 fallback dirs
+ foreach ($this->fallbackDirsPsr0 as $dir) {
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
+ return $file;
+ }
+ }
+
+ // PSR-0 include paths.
+ if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
+ return $file;
+ }
+
+ return false;
+ }
+
+ /**
+ * @return void
+ */
+ private static function initializeIncludeClosure()
+ {
+ if (self::$includeFile !== null) {
+ return;
+ }
+
+ /**
+ * Scope isolated include.
+ *
+ * Prevents access to $this/self from included files.
+ *
+ * @param string $file
+ * @return void
+ */
+ self::$includeFile = \Closure::bind(static function($file) {
+ include $file;
+ }, null, null);
+ }
+}
diff --git a/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php
new file mode 100644
index 0000000..6d29bff
--- /dev/null
+++ b/vendor/composer/InstalledVersions.php
@@ -0,0 +1,378 @@
+
+ * Jordi Boggiano
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Composer;
+
+use Composer\Autoload\ClassLoader;
+use Composer\Semver\VersionParser;
+
+/**
+ * This class is copied in every Composer installed project and available to all
+ *
+ * See also https://getcomposer.org/doc/07-runtime.md#installed-versions
+ *
+ * To require its presence, you can require `composer-runtime-api ^2.0`
+ *
+ * @final
+ */
+class InstalledVersions
+{
+ /**
+ * @var mixed[]|null
+ * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array}|array{}|null
+ */
+ private static $installed;
+
+ /**
+ * @var bool
+ */
+ private static $installedIsLocalDir;
+
+ /**
+ * @var bool|null
+ */
+ private static $canGetVendors;
+
+ /**
+ * @var array[]
+ * @psalm-var array}>
+ */
+ private static $installedByVendor = array();
+
+ /**
+ * Returns a list of all package names which are present, either by being installed, replaced or provided
+ *
+ * @return string[]
+ * @psalm-return list
+ */
+ public static function getInstalledPackages()
+ {
+ $packages = array();
+ foreach (self::getInstalled() as $installed) {
+ $packages[] = array_keys($installed['versions']);
+ }
+
+ if (1 === \count($packages)) {
+ return $packages[0];
+ }
+
+ return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
+ }
+
+ /**
+ * Returns a list of all package names with a specific type e.g. 'library'
+ *
+ * @param string $type
+ * @return string[]
+ * @psalm-return list
+ */
+ public static function getInstalledPackagesByType($type)
+ {
+ $packagesByType = array();
+
+ foreach (self::getInstalled() as $installed) {
+ foreach ($installed['versions'] as $name => $package) {
+ if (isset($package['type']) && $package['type'] === $type) {
+ $packagesByType[] = $name;
+ }
+ }
+ }
+
+ return $packagesByType;
+ }
+
+ /**
+ * Checks whether the given package is installed
+ *
+ * This also returns true if the package name is provided or replaced by another package
+ *
+ * @param string $packageName
+ * @param bool $includeDevRequirements
+ * @return bool
+ */
+ public static function isInstalled($packageName, $includeDevRequirements = true)
+ {
+ foreach (self::getInstalled() as $installed) {
+ if (isset($installed['versions'][$packageName])) {
+ return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Checks whether the given package satisfies a version constraint
+ *
+ * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
+ *
+ * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
+ *
+ * @param VersionParser $parser Install composer/semver to have access to this class and functionality
+ * @param string $packageName
+ * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
+ * @return bool
+ */
+ public static function satisfies(VersionParser $parser, $packageName, $constraint)
+ {
+ $constraint = $parser->parseConstraints((string) $constraint);
+ $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
+
+ return $provided->matches($constraint);
+ }
+
+ /**
+ * Returns a version constraint representing all the range(s) which are installed for a given package
+ *
+ * It is easier to use this via isInstalled() with the $constraint argument if you need to check
+ * whether a given version of a package is installed, and not just whether it exists
+ *
+ * @param string $packageName
+ * @return string Version constraint usable with composer/semver
+ */
+ public static function getVersionRanges($packageName)
+ {
+ foreach (self::getInstalled() as $installed) {
+ if (!isset($installed['versions'][$packageName])) {
+ continue;
+ }
+
+ $ranges = array();
+ if (isset($installed['versions'][$packageName]['pretty_version'])) {
+ $ranges[] = $installed['versions'][$packageName]['pretty_version'];
+ }
+ if (array_key_exists('aliases', $installed['versions'][$packageName])) {
+ $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
+ }
+ if (array_key_exists('replaced', $installed['versions'][$packageName])) {
+ $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
+ }
+ if (array_key_exists('provided', $installed['versions'][$packageName])) {
+ $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
+ }
+
+ return implode(' || ', $ranges);
+ }
+
+ throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
+ }
+
+ /**
+ * @param string $packageName
+ * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
+ */
+ public static function getVersion($packageName)
+ {
+ foreach (self::getInstalled() as $installed) {
+ if (!isset($installed['versions'][$packageName])) {
+ continue;
+ }
+
+ if (!isset($installed['versions'][$packageName]['version'])) {
+ return null;
+ }
+
+ return $installed['versions'][$packageName]['version'];
+ }
+
+ throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
+ }
+
+ /**
+ * @param string $packageName
+ * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
+ */
+ public static function getPrettyVersion($packageName)
+ {
+ foreach (self::getInstalled() as $installed) {
+ if (!isset($installed['versions'][$packageName])) {
+ continue;
+ }
+
+ if (!isset($installed['versions'][$packageName]['pretty_version'])) {
+ return null;
+ }
+
+ return $installed['versions'][$packageName]['pretty_version'];
+ }
+
+ throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
+ }
+
+ /**
+ * @param string $packageName
+ * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
+ */
+ public static function getReference($packageName)
+ {
+ foreach (self::getInstalled() as $installed) {
+ if (!isset($installed['versions'][$packageName])) {
+ continue;
+ }
+
+ if (!isset($installed['versions'][$packageName]['reference'])) {
+ return null;
+ }
+
+ return $installed['versions'][$packageName]['reference'];
+ }
+
+ throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
+ }
+
+ /**
+ * @param string $packageName
+ * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
+ */
+ public static function getInstallPath($packageName)
+ {
+ foreach (self::getInstalled() as $installed) {
+ if (!isset($installed['versions'][$packageName])) {
+ continue;
+ }
+
+ return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
+ }
+
+ throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
+ }
+
+ /**
+ * @return array
+ * @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}
+ */
+ public static function getRootPackage()
+ {
+ $installed = self::getInstalled();
+
+ return $installed[0]['root'];
+ }
+
+ /**
+ * Returns the raw installed.php data for custom implementations
+ *
+ * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
+ * @return array[]
+ * @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array}
+ */
+ public static function getRawData()
+ {
+ @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
+
+ if (null === self::$installed) {
+ // only require the installed.php file if this file is loaded from its dumped location,
+ // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
+ if (substr(__DIR__, -8, 1) !== 'C') {
+ self::$installed = include __DIR__ . '/installed.php';
+ } else {
+ self::$installed = array();
+ }
+ }
+
+ return self::$installed;
+ }
+
+ /**
+ * Returns the raw data of all installed.php which are currently loaded for custom implementations
+ *
+ * @return array[]
+ * @psalm-return list}>
+ */
+ public static function getAllRawData()
+ {
+ return self::getInstalled();
+ }
+
+ /**
+ * Lets you reload the static array from another file
+ *
+ * This is only useful for complex integrations in which a project needs to use
+ * this class but then also needs to execute another project's autoloader in process,
+ * and wants to ensure both projects have access to their version of installed.php.
+ *
+ * A typical case would be PHPUnit, where it would need to make sure it reads all
+ * the data it needs from this class, then call reload() with
+ * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
+ * the project in which it runs can then also use this class safely, without
+ * interference between PHPUnit's dependencies and the project's dependencies.
+ *
+ * @param array[] $data A vendor/composer/installed.php data set
+ * @return void
+ *
+ * @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $data
+ */
+ public static function reload($data)
+ {
+ self::$installed = $data;
+ self::$installedByVendor = array();
+
+ // when using reload, we disable the duplicate protection to ensure that self::$installed data is
+ // always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not,
+ // so we have to assume it does not, and that may result in duplicate data being returned when listing
+ // all installed packages for example
+ self::$installedIsLocalDir = false;
+ }
+
+ /**
+ * @return array[]
+ * @psalm-return list}>
+ */
+ private static function getInstalled()
+ {
+ if (null === self::$canGetVendors) {
+ self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
+ }
+
+ $installed = array();
+ $copiedLocalDir = false;
+
+ if (self::$canGetVendors) {
+ $selfDir = strtr(__DIR__, '\\', '/');
+ foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
+ $vendorDir = strtr($vendorDir, '\\', '/');
+ if (isset(self::$installedByVendor[$vendorDir])) {
+ $installed[] = self::$installedByVendor[$vendorDir];
+ } elseif (is_file($vendorDir.'/composer/installed.php')) {
+ /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */
+ $required = require $vendorDir.'/composer/installed.php';
+ self::$installedByVendor[$vendorDir] = $required;
+ $installed[] = $required;
+ if (self::$installed === null && $vendorDir.'/composer' === $selfDir) {
+ self::$installed = $required;
+ self::$installedIsLocalDir = true;
+ }
+ }
+ if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) {
+ $copiedLocalDir = true;
+ }
+ }
+ }
+
+ if (null === self::$installed) {
+ // only require the installed.php file if this file is loaded from its dumped location,
+ // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
+ if (substr(__DIR__, -8, 1) !== 'C') {
+ /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */
+ $required = require __DIR__ . '/installed.php';
+ self::$installed = $required;
+ } else {
+ self::$installed = array();
+ }
+ }
+
+ if (self::$installed !== array() && !$copiedLocalDir) {
+ $installed[] = self::$installed;
+ }
+
+ return $installed;
+ }
+}
diff --git a/vendor/composer/LICENSE b/vendor/composer/LICENSE
new file mode 100644
index 0000000..f27399a
--- /dev/null
+++ b/vendor/composer/LICENSE
@@ -0,0 +1,21 @@
+
+Copyright (c) Nils Adermann, Jordi Boggiano
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is furnished
+to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php
new file mode 100644
index 0000000..f12bfb6
--- /dev/null
+++ b/vendor/composer/autoload_classmap.php
@@ -0,0 +1,17 @@
+ $vendorDir . '/composer/InstalledVersions.php',
+ 'Mautic\\WP_Mautic\\Backend\\Admin' => $baseDir . '/includes/classes/Backend/Admin.php',
+ 'Mautic\\WP_Mautic\\Backend_Loader' => $baseDir . '/includes/classes/Backend_Loader.php',
+ 'Mautic\\WP_Mautic\\Dependency_Loader' => $baseDir . '/includes/classes/Dependency_Loader.php',
+ 'Mautic\\WP_Mautic\\Frontend\\Enqueue' => $baseDir . '/includes/classes/Frontend/Enqueue.php',
+ 'Mautic\\WP_Mautic\\Frontend\\Shortcodes' => $baseDir . '/includes/classes/Frontend/Shortcodes.php',
+ 'Mautic\\WP_Mautic\\Frontend_Loader' => $baseDir . '/includes/classes/Frontend_Loader.php',
+ 'Mautic\\WP_Mautic\\Utils\\Options' => $baseDir . '/includes/classes/Utils/Options.php',
+);
diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php
new file mode 100644
index 0000000..15a2ff3
--- /dev/null
+++ b/vendor/composer/autoload_namespaces.php
@@ -0,0 +1,9 @@
+ array($baseDir . '/includes/classes'),
+);
diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php
new file mode 100644
index 0000000..f1e80ca
--- /dev/null
+++ b/vendor/composer/autoload_real.php
@@ -0,0 +1,38 @@
+register(true);
+
+ return $loader;
+ }
+}
diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php
new file mode 100644
index 0000000..16cfc55
--- /dev/null
+++ b/vendor/composer/autoload_static.php
@@ -0,0 +1,43 @@
+
+ array (
+ 'Mautic\\WP_Mautic\\' => 17,
+ ),
+ );
+
+ public static $prefixDirsPsr4 = array (
+ 'Mautic\\WP_Mautic\\' =>
+ array (
+ 0 => __DIR__ . '/../..' . '/includes/classes',
+ ),
+ );
+
+ public static $classMap = array (
+ 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
+ 'Mautic\\WP_Mautic\\Backend\\Admin' => __DIR__ . '/../..' . '/includes/classes/Backend/Admin.php',
+ 'Mautic\\WP_Mautic\\Backend_Loader' => __DIR__ . '/../..' . '/includes/classes/Backend_Loader.php',
+ 'Mautic\\WP_Mautic\\Dependency_Loader' => __DIR__ . '/../..' . '/includes/classes/Dependency_Loader.php',
+ 'Mautic\\WP_Mautic\\Frontend\\Enqueue' => __DIR__ . '/../..' . '/includes/classes/Frontend/Enqueue.php',
+ 'Mautic\\WP_Mautic\\Frontend\\Shortcodes' => __DIR__ . '/../..' . '/includes/classes/Frontend/Shortcodes.php',
+ 'Mautic\\WP_Mautic\\Frontend_Loader' => __DIR__ . '/../..' . '/includes/classes/Frontend_Loader.php',
+ 'Mautic\\WP_Mautic\\Utils\\Options' => __DIR__ . '/../..' . '/includes/classes/Utils/Options.php',
+ );
+
+ public static function getInitializer(ClassLoader $loader)
+ {
+ return \Closure::bind(function () use ($loader) {
+ $loader->prefixLengthsPsr4 = ComposerStaticInitcaa95701e2f1c035fc302847b2180a7e::$prefixLengthsPsr4;
+ $loader->prefixDirsPsr4 = ComposerStaticInitcaa95701e2f1c035fc302847b2180a7e::$prefixDirsPsr4;
+ $loader->classMap = ComposerStaticInitcaa95701e2f1c035fc302847b2180a7e::$classMap;
+
+ }, null, ClassLoader::class);
+ }
+}
diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json
new file mode 100644
index 0000000..f20a6c4
--- /dev/null
+++ b/vendor/composer/installed.json
@@ -0,0 +1,5 @@
+{
+ "packages": [],
+ "dev": false,
+ "dev-package-names": []
+}
diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php
new file mode 100644
index 0000000..7b9d054
--- /dev/null
+++ b/vendor/composer/installed.php
@@ -0,0 +1,23 @@
+ array(
+ 'name' => 'mautic/wordpress-plugin',
+ 'pretty_version' => 'dev-main',
+ 'version' => 'dev-main',
+ 'reference' => '492f250955a570e99cb13570c5e75ed686ca8bd3',
+ 'type' => 'library',
+ 'install_path' => __DIR__ . '/../../',
+ 'aliases' => array(),
+ 'dev' => false,
+ ),
+ 'versions' => array(
+ 'mautic/wordpress-plugin' => array(
+ 'pretty_version' => 'dev-main',
+ 'version' => 'dev-main',
+ 'reference' => '492f250955a570e99cb13570c5e75ed686ca8bd3',
+ 'type' => 'library',
+ 'install_path' => __DIR__ . '/../../',
+ 'aliases' => array(),
+ 'dev_requirement' => false,
+ ),
+ ),
+);
diff --git a/vendor/composer/platform_check.php b/vendor/composer/platform_check.php
new file mode 100644
index 0000000..6d3407d
--- /dev/null
+++ b/vendor/composer/platform_check.php
@@ -0,0 +1,26 @@
+= 70100)) {
+ $issues[] = 'Your Composer dependencies require a PHP version ">= 7.1.0". You are running ' . PHP_VERSION . '.';
+}
+
+if ($issues) {
+ if (!headers_sent()) {
+ header('HTTP/1.1 500 Internal Server Error');
+ }
+ if (!ini_get('display_errors')) {
+ if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
+ fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
+ } elseif (!headers_sent()) {
+ echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
+ }
+ }
+ trigger_error(
+ 'Composer detected issues in your platform: ' . implode(' ', $issues),
+ E_USER_ERROR
+ );
+}
diff --git a/wpmautic.php b/wpmautic.php
index 1dec80d..ae550c5 100644
--- a/wpmautic.php
+++ b/wpmautic.php
@@ -2,11 +2,10 @@
/**
* Plugin Name: WP Mautic
* Plugin URI: https://github.com/mautic/mautic-wordpress
- * Contributors: mautic,hideokamoto,shulard,escopecz,dbhurley,macbookandrew
+ * Contributors: mautic,hideokamoto,shulard,escopecz,dbhurley,macbookandrew,dogbytemarketing
* Description: This plugin will allow you to add Mautic (Free Open Source Marketing Automation) tracking to your site
- * Version: 2.4.3
+ * Version: 2.5.1
* Requires at least: 4.6
- * Tested up to: 6.1
* Author: Mautic community
* Author URI: http://mautic.org
* Text Domain: wp-mautic
@@ -16,258 +15,43 @@
* @package wp-mautic
*/
-// Prevent direct access to this file.
+namespace Mautic\WP_Mautic;
+
if ( ! defined( 'ABSPATH' ) ) {
- header( 'HTTP/1.0 403 Forbidden' );
- echo 'This file should not be accessed directly!';
exit; // Exit if accessed directly.
}
+require plugin_dir_path( __FILE__ ) . 'vendor/autoload.php';
+
// Store plugin directory.
define( 'VPMAUTIC_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
+
// Store plugin main file path.
define( 'VPMAUTIC_PLUGIN_FILE', __FILE__ );
-add_action( 'admin_menu', 'wpmautic_settings' );
-add_action( 'plugins_loaded', 'wpmautic_injector' );
-
-require_once VPMAUTIC_PLUGIN_DIR . '/shortcodes.php';
-
-/**
- * Declare option page
- */
-function wpmautic_settings() {
- include_once VPMAUTIC_PLUGIN_DIR . '/options.php';
-
- add_options_page(
- __( 'WP Mautic Settings', 'wp-mautic' ),
- __( 'WPMautic', 'wp-mautic' ),
- 'manage_options',
- 'wpmautic',
- 'wpmautic_options_page'
- );
-}
-
-/**
- * Settings Link in the ``Installed Plugins`` page
- *
- * @param array $links array of plugin action links.
- *
- * @return array
- */
-function wpmautic_plugin_actions( $links ) {
- if ( function_exists( 'admin_url' ) ) {
- $settings_link = sprintf(
- '%s',
- admin_url( 'options-general.php?page=wpmautic' ),
- __( 'Settings' )
- );
- // Add the settings link before other links.
- array_unshift( $links, $settings_link );
- }
- return $links;
-}
-add_filter( 'plugin_action_links_' . plugin_basename( VPMAUTIC_PLUGIN_FILE ), 'wpmautic_plugin_actions', 10, 2 );
-
-/**
- * Retrieve one of the wpmautic options but sanitized
- *
- * @param string $option Option name to be retrieved (base_url, script_location).
- * @param mixed $default Default option value return if not exists.
- *
- * @return string
- *
- * @throws InvalidArgumentException Thrown when the option name is not given.
- */
-function wpmautic_option( $option, $default = null ) {
- $options = get_option( 'wpmautic_options' );
-
- switch ( $option ) {
- case 'script_location':
- return ! isset( $options[ $option ] ) ? 'header' : $options[ $option ];
- case 'fallback_activated':
- return isset( $options[ $option ] ) ? (bool) $options[ $option ] : true;
- case 'track_logged_user':
- return isset( $options[ $option ] ) ? (bool) $options[ $option ] : false;
- default:
- if ( ! isset( $options[ $option ] ) ) {
- if ( isset( $default ) ) {
- return $default;
- }
-
- throw new InvalidArgumentException( 'You must give a valid option name !' );
- }
-
- return $options[ $option ];
- }
-}
-
-/**
- * Apply JS tracking to the right place depending script_location.
- *
- * @return void
- */
-function wpmautic_injector() {
- $script_location = wpmautic_option( 'script_location' );
- if ( 'header' === $script_location ) {
- add_action( 'wp_head', 'wpmautic_inject_script' );
- } else {
- add_action( 'wp_footer', 'wpmautic_inject_script' );
- }
-
- if ( 'disabled' !== $script_location && true === wpmautic_option( 'fallback_activated', false ) ) {
- add_action( 'wp_footer', 'wpmautic_inject_noscript' );
- }
-}
-
-/**
- * Generate the mautic script URL to be used outside of the plugin when
- * necessary
- *
- * @return string
- */
-function wpmautic_base_script() {
- $base_url = wpmautic_option( 'base_url', '' );
- if ( empty( $base_url ) ) {
- return;
- }
-
- return $base_url . '/mtc.js';
-}
-
-/**
- * Writes Tracking JS to the HTML source
- *
- * @return void
- */
-function wpmautic_inject_script() {
- // Load the Mautic tracking library mtc.js if it is not disabled.
- $base_url = wpmautic_base_script();
- $script_location = wpmautic_option( 'script_location' );
- $attrs = wpmautic_get_tracking_attributes();
- ?>
-
- tags are not allowed in header !
- *
- * @return void
- */
-function wpmautic_inject_noscript() {
- $base_url = wpmautic_option( 'base_url', '' );
- if ( empty( $base_url ) ) {
- return;
- }
-
- $url_query = wpmautic_get_url_query();
- $payload = rawurlencode( base64_encode( serialize( $url_query ) ) );
- ?>
-
- query_string, '', home_url( $wp->request ) );
-
- $attrs = wpmautic_get_tracking_attributes();
-
- $attrs['language'] = get_locale();
- $attrs['page_url'] = $current_url;
- $attrs['page_title'] = function_exists( 'wp_get_document_title' )
- ? wp_get_document_title()
- : wp_title( '»', false );
- $attrs['referrer'] = function_exists( 'wp_get_raw_referer' )
- ? wp_get_raw_referer()
- : null;
- if ( false === $attrs['referrer'] ) {
- $attrs['referrer'] = $current_url;
- }
-
- return $attrs;
-}
-
-/**
- * Create custom query parameters to be injected inside tracking
- *
- * @return array
- */
-function wpmautic_get_tracking_attributes() {
- $attrs = wpmautic_get_user_query();
-
- /**
- * Update / add data to be send withing Mautic tracker
- *
- * Default data only contains the 'language' key but every added key to the
- * array will be sent to Mautic.
- *
- * @since 2.1.0
- *
- * @param array $attrs Attributes to be filters, default ['language' => get_locale()]
- */
- return apply_filters( 'wpmautic_tracking_attributes', $attrs );
-}
-
-/**
- * Extract logged user informations to be send within Mautic tracker
- *
- * @return array
- */
-function wpmautic_get_user_query() {
- $attrs = array();
-
- if (
- true === wpmautic_option( 'track_logged_user', false ) &&
- is_user_logged_in()
- ) {
- $current_user = wp_get_current_user();
- $attrs['email'] = $current_user->user_email;
- $attrs['firstname'] = $current_user->user_firstname;
- $attrs['lastname'] = $current_user->user_lastname;
-
- // Following Mautic fields has to be created manually and the fields must match these names.
- $attrs['wp_user'] = $current_user->user_login;
- $attrs['wp_alias'] = $current_user->display_name;
- $attrs['wp_registration_date'] = date(
- 'Y-m-d',
- strtotime( $current_user->user_registered )
- );
- }
-
- return $attrs;
-}
+class WP_Mautic {
+
+
+ /**
+ * Init
+ *
+ * @return void
+ */
+ public function init() {
+ $this->load_dependencies();
+ }
+
+ /**
+ * Load dependencies
+ *
+ * @return void
+ */
+ public function load_dependencies() {
+ $dependency_loader = new Dependency_Loader();
+ $dependency_loader->init();
+ }
+
+}
+
+$wp_mautic = new WP_Mautic();
+$wp_mautic->init();
\ No newline at end of file