first commit

This commit is contained in:
2026-03-05 13:07:40 +01:00
commit 64ba0721ee
25709 changed files with 4691006 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
<?php
/**
* Integration for KingComposer
*
* @package PUM
* @copyright Copyright (c) 2023, Code Atlantic LLC
*/
class PUM_Integration_Builder_KingComposer extends PUM_Abstract_Integration {
/**
* @var string
*/
public $key = 'kingcomposer';
/**
* @var string
*/
public $type = 'builder';
/**
* @return string
*/
public function label() {
return 'King Composer';
}
/**
* @return bool
*/
public function enabled() {
return class_exists( 'KingComposer' ) || defined( 'KC_VERSION' );
}
}

View File

@@ -0,0 +1,35 @@
<?php
/**
* Integration for VisualComposer
*
* @package PUM
* @copyright Copyright (c) 2023, Code Atlantic LLC
*/
class PUM_Integration_Builder_VisualComposer extends PUM_Abstract_Integration {
/**
* @var string
*/
public $key = 'visualcomposer';
/**
* @var string
*/
public $type = 'builder';
/**
* @return string
*/
public function label() {
return 'Visual Composer';
}
/**
* @return bool
*/
public function enabled() {
return defined( 'WPB_VC_VERSION' ) || defined( 'FL_BUILDER_VERSION' );
}
}

View File

@@ -0,0 +1,108 @@
<?php
/**
* Integration for CalderaForms Form
*
* @package PUM
* @copyright Copyright (c) 2023, Code Atlantic LLC
*/
class PUM_Integration_Form_CalderaForms extends PUM_Abstract_Integration_Form {
/**
* @var string
*/
public $key = 'calderaforms';
public function __construct() {
add_action( 'caldera_forms_submit_complete', [ $this, 'on_success' ] );
}
/**
* @return string
*/
public function label() {
return 'Caldera Forms';
}
/**
* @return bool
*/
public function enabled() {
return defined( 'CFCORE_VER' ) && CFCORE_VER;
}
/**
* @return array
*/
public function get_forms() {
return Caldera_Forms_Forms::get_forms( true );
}
/**
* @param string $id
*
* @return mixed
*/
public function get_form( $id ) {
return Caldera_Forms_Forms::get_form( $id );
}
/**
* @return array
*/
public function get_form_selectlist() {
$form_selectlist = [];
$forms = $this->get_forms();
foreach ( $forms as $form ) {
$form_selectlist[ $form['ID'] ] = $form['name'];
}
return $form_selectlist;
}
/**
* @param array $form
*/
public function on_success( $form ) {
if ( ! self::should_process_submission() ) {
return;
}
$popup_id = self::get_popup_id();
self::increase_conversion( $popup_id );
pum_integrated_form_submission(
[
'popup_id' => $popup_id,
'form_provider' => $this->key,
'form_id' => $form['ID'],
]
);
}
/**
* @param array $js
*
* @return array
*/
public function custom_scripts( $js = [] ) {
return $js;
}
/**
* @param array $css
*
* @return array
*/
public function custom_styles( $css = [] ) {
$css[ $this->key ] = [
'content' => ".pac-container { z-index: 2000000000 !important; }\n",
'priority' => 8,
];
return $css;
}
}

View File

@@ -0,0 +1,132 @@
<?php
/**
* Integration for ContactForm7 Form
*
* @package PUM
* @copyright Copyright (c) 2023, Code Atlantic LLC
*/
class PUM_Integration_Form_ContactForm7 extends PUM_Abstract_Integration_Form {
/**
* Unique key identifier for this provider.
*
* @var string
*/
public $key = 'contactform7';
/**
* Only used to hook in a custom action for non AJAX based submissions.
*
* Could be used for other initiations as well where needed.
*/
public function __construct() {
add_action( 'wpcf7_mail_sent', [ $this, 'on_success' ], 1 );
}
/**
* Text label that will be used throughout the various options screens.
*
* @return string
*/
public function label() {
return __( 'Contact Form 7' );
}
/**
* Should return true when the required form plugin is active.
*
* @return bool
*/
public function enabled() {
return class_exists( 'WPCF7' ) || ( defined( 'WPCF7_VERSION' ) && WPCF7_VERSION );
}
/**
* Return a useable array of all forms from this provider.
*
* @return array
*/
public function get_forms() {
return get_posts(
[
'post_type' => 'wpcf7_contact_form',
'posts_per_page' => - 1,
]
);
}
/**
* Return a single form by ID.
*
* @param string $id
*
* @return mixed
*/
public function get_form( $id ) {
return get_post( $id );
}
/**
* Returns an array of options for a select list.
*
* Should be in the format of $formId => $formLabel
*
* @return array
*/
public function get_form_selectlist() {
$form_selectlist = [];
$forms = $this->get_forms();
foreach ( $forms as $form ) {
$form_selectlist[ $form->ID ] = $form->post_title;
}
return $form_selectlist;
}
/**
* Hooks in a success functions specific to this provider for non AJAX submission handling.
*
* @param WPCF7_ContactForm $cfdata
*/
public function on_success( $cfdata ) {
if ( ! self::should_process_submission() ) {
return;
}
$popup_id = self::get_popup_id();
self::increase_conversion( $popup_id );
pum_integrated_form_submission(
[
'popup_id' => $popup_id,
'form_provider' => $this->key,
'form_id' => $cfdata->id(),
]
);
}
/**
* Load a custom script file to handle AJAX based submissions or other integrations with Popup Maker frontend.
*
* @param array $js
*
* @return array
*/
public function custom_scripts( $js = [] ) {
return $js;
}
/**
* Load custom styles for hacking some elements specifically inside popups, such as datepickers.
*
* @param array $css
*
* @return array
*/
public function custom_styles( $css = [] ) {
return $css;
}
}

View File

@@ -0,0 +1,135 @@
<?php
/**
* Integration for FormidableForms Form
*
* @package PUM
* @copyright Copyright (c) 2023, Code Atlantic LLC
*/
/**
* Handles the integration with Formidable Forms (https://wordpress.org/plugins/formidable/)
*
* @since 1.12
*/
class PUM_Integration_Form_FormidableForms extends PUM_Abstract_Integration_Form {
/**
* Unique key identifier for this provider.
*
* @var string
*/
public $key = 'formidableforms';
/**
* Only used to hook in a custom action for non AJAX based submissions.
*
* Could be used for other initiations as well where needed.
*/
public function __construct() {
add_action( 'frm_after_create_entry', [ $this, 'on_success' ], 1, 2 );
}
/**
* Text label that will be used throughout the various options screens.
*
* @return string
*/
public function label() {
return __( 'Formidable Forms' );
}
/**
* Should return true when the required form plugin is active.
*
* @return bool
*/
public function enabled() {
return class_exists( 'FrmEntry' );
}
/**
* Return a useable array of all forms from this provider.
*
* @return array
*/
public function get_forms() {
return FrmForm::getAll();
}
/**
* Return a single form by ID.
*
* @param string $id The ID of the form.
* @return mixed
*/
public function get_form( $id ) {
return FrmForm::getOne( intval( $id ) );
}
/**
* Returns an array of options for a select list.
* Should be in the format of $formId => $formLabel.
*
* @return array The array of options
*/
public function get_form_selectlist() {
$form_selectlist = [];
$forms = $this->get_forms();
foreach ( $forms as $form ) {
$form_selectlist[ $form->id ] = $form->name;
}
return $form_selectlist;
}
/**
* Hooks in a success functions specific to this provider for non AJAX submission handling.
*
* @param int $entry_id The ID of the entry added.
* @param int $form_id The ID of the form.
*/
public function on_success( $entry_id, $form_id ) {
// Determine if form has AJAX submission enabled. Only do our form submission method if AJAX is not enabled.
$form = $this->get_form( intval( $form_id ) );
if ( isset( $form->options['ajax_submit'] ) && true === $form->options['ajax_submit'] ) {
return;
}
if ( ! self::should_process_submission() ) {
return;
}
$popup_id = self::get_popup_id();
self::increase_conversion( $popup_id );
pum_integrated_form_submission(
[
'popup_id' => $popup_id,
'form_provider' => $this->key,
'form_id' => $form_id,
]
);
}
/**
* Load a custom script file to handle AJAX based submissions or other integrations with Popup Maker frontend.
*
* @param array $js All JS to be enqueued for popup.
* @return array
*/
public function custom_scripts( $js = [] ) {
return $js;
}
/**
* Load custom styles for hacking some elements specifically inside popups, such as datepickers.
*
* @param array $css All CSS enqueued for the popup.
* @return array
*/
public function custom_styles( $css = [] ) {
return $css;
}
}

View File

@@ -0,0 +1,109 @@
<?php
/**
* Integration for GravityForms Form
*
* @package PUM
* @copyright Copyright (c) 2023, Code Atlantic LLC
*/
class PUM_Integration_Form_GravityForms extends PUM_Abstract_Integration_Form {
/**
* @var string
*/
public $key = 'gravityforms';
public function __construct() {
add_action( 'gform_after_submission', [ $this, 'on_success' ], 10, 2 );
}
/**
* @return string
*/
public function label() {
return 'Gravity Forms';
}
/**
* @return bool
*/
public function enabled() {
return class_exists( 'RGForms' );
}
/**
* @return array
*/
public function get_forms() {
return GFAPI::get_forms();
}
/**
* @param string $id
*
* @return mixed
*/
public function get_form( $id ) {
return GFAPI::get_forms( $id );
}
/**
* @return array
*/
public function get_form_selectlist() {
$form_selectlist = [];
$forms = $this->get_forms();
foreach ( $forms as $form ) {
$form_selectlist[ $form['id'] ] = $form['title'];
}
return $form_selectlist;
}
/**
* @param $entry
* @param $form
*/
public function on_success( $entry, $form ) {
if ( ! self::should_process_submission() ) {
return;
}
// This key is set when Gravity Forms is submitted via AJAX.
if ( isset( $_POST['gform_ajax'] ) && ! is_null( $_POST['gform_ajax'] ) ) {
return;
}
$popup_id = self::get_popup_id();
self::increase_conversion( $popup_id );
pum_integrated_form_submission(
[
'popup_id' => $popup_id,
'form_provider' => $this->key,
'form_id' => $form['id'],
]
);
}
/**
* @param array $js
*
* @return array
*/
public function custom_scripts( $js = [] ) {
return $js;
}
/**
* @param array $css
*
* @return array
*/
public function custom_styles( $css = [] ) {
return $css;
}
}

View File

@@ -0,0 +1,96 @@
<?php
/**
* Integration for MC4WP Form
*
* @package PUM
* @copyright Copyright (c) 2023, Code Atlantic LLC
*/
class PUM_Integration_Form_MC4WP extends PUM_Abstract_Integration_Form {
/**
* Unique key identifier for this provider.
*
* @var string
*/
public $key = 'mc4wp';
/**
* Text label that will be used throughout the various options screens.
*
* @return string
*/
public function label() {
return __( 'MailChimp for WordPress' );
}
/**
* Should return true when the required form plugin is active.
*
* @return bool
*/
public function enabled() {
return defined( 'MC4WP_VERSION' ) && MC4WP_VERSION;
}
/**
* Return a useable array of all forms from this provider.
*
* @return MC4WP_Form[]
*/
public function get_forms() {
return mc4wp_get_forms();
}
/**
* Return a single form by ID.
*
* @param string $id
*
* @return MC4WP_Form
*/
public function get_form( $id ) {
return mc4wp_get_form( $id );
}
/**
* Returns an array of options for a select list.
*
* Should be in the format of $formId => $formLabel
*
* @return array
*/
public function get_form_selectlist() {
$form_selectlist = [];
$forms = $this->get_forms();
foreach ( $forms as $form ) {
$form_selectlist[ $form->ID ] = $form->name;
}
return $form_selectlist;
}
/**
* Load a custom script file to handle AJAX based submissions or other integrations with Popup Maker frontend.
*
* @param array $js
*
* @return array
*/
public function custom_scripts( $js = [] ) {
return $js;
}
/**
* Load custom styles for hacking some elements specifically inside popups, such as datepickers.
*
* @param array $css
*
* @return array
*/
public function custom_styles( $css = [] ) {
return $css;
}
}

View File

@@ -0,0 +1,124 @@
<?php
/**
* Integration for NinjaForms Form
*
* @package PUM
* @copyright Copyright (c) 2023, Code Atlantic LLC
*/
class PUM_Integration_Form_NinjaForms extends PUM_Abstract_Integration_Form {
/**
* @var string
*/
public $key = 'ninjaforms';
public function __construct() {
add_action( 'ninja_forms_pre_process', [ $this, 'on_success_v2' ] );
add_action( 'ninja_forms_after_submission', [ $this, 'on_success_v3' ] );
}
/**
* @return string
*/
public function label() {
return 'Ninja Forms';
}
/**
* @return bool
*/
public function enabled() {
return class_exists( 'Ninja_Forms' ) && ! ( version_compare( get_option( 'ninja_forms_version', '0.0.0' ), '3.0', '<' ) || get_option( 'ninja_forms_load_deprecated', false ) );
}
/**
* @return array
*/
public function get_forms() {
return Ninja_Forms()->form()->get_forms();
}
/**
* @param string $id
*
* @return mixed
*/
public function get_form( $id ) {
return Ninja_Forms()->form( $id )->get();
}
/**
* @return array
*/
public function get_form_selectlist() {
$form_selectlist = [];
$forms = $this->get_forms();
foreach ( $forms as $form ) {
$form_selectlist[ $form->get_id() ] = $form->get_setting( 'title' );
}
return $form_selectlist;
}
/**
* @global $ninja_forms_processing
*/
public function on_success_v2() {
global $ninja_forms_processing;
if ( ! self::should_process_submission() ) {
return;
}
$popup_id = self::get_popup_id();
self::increase_conversion( $popup_id );
pum_integrated_form_submission(
[
'popup_id' => $popup_id,
'form_provider' => $this->key,
'form_id' => $ninja_forms_processing->get_form_ID(),
]
);
}
/**
* @param $form_data
*/
public function on_success_v3( $form_data ) {
if ( ! self::should_process_submission() ) {
return;
}
$popup_id = self::get_popup_id();
self::increase_conversion( $popup_id );
pum_integrated_form_submission(
[
'popup_id' => $popup_id,
'form_provider' => $this->key,
'form_id' => $form_data['form_id'],
]
);
}
/**
* @param array $js
*
* @return array
*/
public function custom_scripts( $js = [] ) {
return $js;
}
/**
* @param array $css
*
* @return array
*/
public function custom_styles( $css = [] ) {
return $css;
}
}

View File

@@ -0,0 +1,171 @@
<?php
/**
* Integration for PirateForms Form
*
* @package PUM
* @copyright Copyright (c) 2023, Code Atlantic LLC
*/
class PUM_Integration_Form_PirateForms extends PUM_Abstract_Integration_Form {
/**
* @var string
*/
public $key = 'pirateforms';
public function __construct() {
// add_action( 'wpforms_process_complete', array( $this, 'on_success' ), 10, 4 );
}
/**
* @return string
*/
public function label() {
return 'Pirate Forms';
}
/**
* @return bool
*/
public function enabled() {
return defined( 'PIRATE_FORMS_VERSION' ) && PIRATE_FORMS_VERSION;
}
/**
* @return array
*/
public function get_forms() {
// Union those arrays, as array_merge() does keys reindexing.
$forms = $this->get_default_forms() + $this->get_pro_forms();
// Sort by IDs ASC.
ksort( $forms );
return $forms;
}
/**
* Pirate Forms has a default form, which doesn't have an ID.
*
* @since 1.4.9
*
* @return array
*/
protected function get_default_forms() {
$form = PirateForms_Util::get_form_options();
// Just make sure that it's there and not broken.
if ( empty( $form ) ) {
return [];
}
return [ 0 => esc_html__( 'Default Form', 'wpforms-lite' ) ];
}
/**
* Copy-paste from Pro plugin code, it doesn't have API to get this data easily.
*
* @since 1.4.9
*
* @return array
*/
protected function get_pro_forms() {
$forms = [];
$query = new WP_Query(
[
'post_type' => 'pf_form',
'post_status' => 'publish',
'posts_per_page' => - 1,
'update_post_meta_cache' => false,
'update_post_term_cache' => false,
]
);
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
$forms[ get_the_ID() ] = get_the_title();
}
}
return $forms;
}
/**
* Get a single form options.
*
* @since 1.4.9
*
* @param int $id Form ID.
*
* @return array
*/
public function get_form( $id ) {
return PirateForms_Util::get_form_options( (int) $id );
}
/**
* @return array
*/
public function get_form_selectlist() {
$form_selectlist = [];
$forms = $this->get_forms();
foreach ( $forms as $form ) {
$form_selectlist[ $form['ID'] ] = $form['name'];
}
return $form_selectlist;
}
/**
* @link https://wpforms.com/developers/wpforms_process_complete/
*
* @param array $fields Sanitized entry field values/properties.
* @param array $entry Original $_POST global.
* @param array $form_data Form data and settings.
* @param int $entry_id Entry ID. Will return 0 if entry storage is disabled or using WPForms Lite.
*/
public function on_success( $fields, $entry, $form_data, $entry_id ) {
if ( ! self::should_process_submission() ) {
return;
}
$popup_id = self::get_popup_id();
self::increase_conversion( $popup_id );
pum_integrated_form_submission(
[
'popup_id' => $popup_id,
'form_provider' => $this->key,
'form_id' => $form_data['id'],
]
);
}
/**
* @param array $js
*
* @return array
*/
public function custom_scripts( $js = [] ) {
return $js;
}
/**
* @param array $css
*
* @return array
*/
public function custom_styles( $css = [] ) {
$css[ $this->key ] = [
'content' => ".pac-container { z-index: 2000000000 !important; }\n",
'priority' => 8,
];
return $css;
}
}

View File

@@ -0,0 +1,113 @@
<?php
/**
* Integration for WPForms Form
*
* @package PUM
* @copyright Copyright (c) 2023, Code Atlantic LLC
*/
class PUM_Integration_Form_WPForms extends PUM_Abstract_Integration_Form {
/**
* @var string
*/
public $key = 'wpforms';
public function __construct() {
add_action( 'wpforms_process_complete', [ $this, 'on_success' ], 10, 4 );
}
/**
* @return string
*/
public function label() {
return 'WP Forms';
}
/**
* @return bool
*/
public function enabled() {
return defined( 'WPFORMS_VERSION' ) && WPFORMS_VERSION;
}
/**
* @return array|bool|null|WP_Post[]
*/
public function get_forms() {
return wpforms()->form->get( null, [ 'posts_per_page' => - 1 ] );
}
/**
* @param int|string $id
*
* @return array|bool|null|WP_Post
*/
public function get_form( $id ) {
return wpforms()->form->get( $id );
}
/**
* @return array
*/
public function get_form_selectlist() {
$form_selectlist = [];
$forms = $this->get_forms();
if ( is_array( $forms ) ) {
foreach ( $forms as $form ) {
$form_selectlist[ $form->ID ] = $form->post_title;
}
}
return $form_selectlist;
}
/**
* @link https://wpforms.com/developers/wpforms_process_complete/
*
* @param array $fields Sanitized entry field values/properties.
* @param array $entry Original $_POST global.
* @param array $form_data Form data and settings.
* @param int $entry_id Entry ID. Will return 0 if entry storage is disabled or using WPForms Lite.
*/
public function on_success( $fields, $entry, $form_data, $entry_id ) {
if ( ! self::should_process_submission() ) {
return;
}
$popup_id = self::get_popup_id();
self::increase_conversion( $popup_id );
pum_integrated_form_submission(
[
'popup_id' => $popup_id,
'form_provider' => $this->key,
'form_id' => $form_data['id'],
]
);
}
/**
* @param array $js
*
* @return array
*/
public function custom_scripts( $js = [] ) {
return $js;
}
/**
* @param array $css
*
* @return array
*/
public function custom_styles( $css = [] ) {
// $css[ $this->key ] = [
// 'content' => ".pac-container { z-index: 2000000000 !important; }\n",
// 'priority' => 8,
// ];
return $css;
}
}

View File

@@ -0,0 +1,113 @@
<?php
/**
* Integration for GoogleFonts
*
* @package PUM
* @copyright Copyright (c) 2023, Code Atlantic LLC
*/
class PUM_Integration_GoogleFonts {
/**
* @var string
*/
private static $default_api_key = 'AIzaSyA1Q0uFOhEh3zv_Pk31FqlACArFquyBeQU';
/**
* @var string
*/
public static $api_key;
/**
*
*/
public static function init() {
// Set the API key based on options first then default second.
self::$api_key = pum_get_option( 'google_fonts_api_key', self::$default_api_key );
add_filter( 'pum_theme_font_family_options', [ __CLASS__, 'font_family_options' ], 20 );
}
/**
* Loads a static backup list of Google Fonts in case the API is not responding.
*
* @return array|mixed|object
*/
public static function load_backup_fonts() {
$json_data = file_get_contents( Popup_Maker::$DIR . 'includes/google-fonts.json' );
return json_decode( $json_data, true );
}
/**
* Fetch list of Google Fonts or fallback to local list.
*
* @param string $sort
*
* @return array|mixed
*/
public static function fetch_fonts( $sort = 'alpha' ) {
if ( false !== $font_list = get_site_transient( 'pum_google_fonts_list' ) ) {
return $font_list;
}
$google_api_url = 'https://www.googleapis.com/webfonts/v1/webfonts?key=' . self::$api_key . '&sort=' . $sort;
$response = wp_remote_retrieve_body( wp_remote_get( $google_api_url, [ 'sslverify' => false ] ) );
if ( ! is_wp_error( $response ) ) {
$data = json_decode( $response, true );
}
// Store transient for a long time after fetching from Google to save API key hits.
$transient_time = self::$api_key === self::$default_api_key ? 8 * WEEK_IN_SECONDS : 1 * WEEK_IN_SECONDS;
if ( ! empty( $data['errors'] ) || empty( $data['items'] ) ) {
$data = self::load_backup_fonts();
// Store transient for short period.
$transient_time = 1 * DAY_IN_SECONDS;
}
$items = $data['items'];
$font_list = [];
if ( count( $items ) ) {
foreach ( $items as $item ) {
$font_list[ $item['family'] ] = $item;
}
}
set_site_transient( 'pum_google_fonts_list', $font_list, $transient_time );
return $font_list;
}
/**
* Adds options to the font family dropdowns.
*
* @param $options
*
* @return array
*/
public static function font_family_options( $options ) {
$font_list = self::fetch_fonts();
if ( empty( $font_list ) ) {
return $options;
}
$new_options = [];
// $options = array_merge( $options, array(
// '' => __( 'Google Web Fonts', 'popup-maker' ) . ' &#10549;',
// ) );
foreach ( $font_list as $font_family => $font ) {
$new_options[ $font_family ] = $font_family;
}
$options[ __( 'Google Web Fonts', 'popup-maker' ) ] = $new_options;
return $options;
}
}