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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions admin/importers/class-convertkit-admin-importer-activecampaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@
*/
class ConvertKit_Admin_Importer_ActiveCampaign extends ConvertKit_Admin_Importer {

/**
* Holds the programmatic name of the importer (lowercase, no spaces).
*
* @since 3.1.7
*
* @var string
*/
public $name = 'activecampaign';

/**
* Holds the title of the importer (for display in the importer list).
*
* @since 3.1.7
*
* @var string
*/
public $title = 'ActiveCampaign';

/**
* Holds the shortcode name for MC4WP forms.
*
Expand Down Expand Up @@ -50,6 +68,18 @@ class ConvertKit_Admin_Importer_ActiveCampaign extends ConvertKit_Admin_Importer
*/
public $block_id_attribute = 'formId';

/**
* Constructor
*
* @since 3.1.7
*/
public function __construct() {

// Register this as an importer, if ActiveCampaign forms exist.
add_filter( 'convertkit_get_form_importers', array( $this, 'register' ) );

}

/**
* Returns an array of MC4WP form IDs and titles.
*
Expand Down
30 changes: 30 additions & 0 deletions admin/importers/class-convertkit-admin-importer-aweber.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@
*/
class ConvertKit_Admin_Importer_AWeber extends ConvertKit_Admin_Importer {

/**
* Holds the programmatic name of the importer (lowercase, no spaces).
*
* @since 3.1.7
*
* @var string
*/
public $name = 'aweber';

/**
* Holds the title of the importer (for display in the importer list).
*
* @since 3.1.7
*
* @var string
*/
public $title = 'AWeber';

/**
* Holds the shortcode name for AWeber forms.
*
Expand Down Expand Up @@ -50,6 +68,18 @@ class ConvertKit_Admin_Importer_AWeber extends ConvertKit_Admin_Importer {
*/
public $block_id_attribute = 'selectedShortCode';

/**
* Constructor
*
* @since 3.1.7
*/
public function __construct() {

// Register this as an importer, if AWeber forms exist.
add_filter( 'convertkit_get_form_importers', array( $this, 'register' ) );

}

/**
* Returns an array of AWeber form IDs and titles.
*
Expand Down
30 changes: 30 additions & 0 deletions admin/importers/class-convertkit-admin-importer-mailpoet.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@
*/
class ConvertKit_Admin_Importer_Mailpoet extends ConvertKit_Admin_Importer {

/**
* Holds the programmatic name of the importer (lowercase, no spaces).
*
* @since 3.1.7
*
* @var string
*/
public $name = 'mailpoet';

/**
* Holds the title of the importer (for display in the importer list).
*
* @since 3.1.7
*
* @var string
*/
public $title = 'Mailpoet';

/**
* Holds the shortcode name for Mailpoet forms.
*
Expand Down Expand Up @@ -50,6 +68,18 @@ class ConvertKit_Admin_Importer_Mailpoet extends ConvertKit_Admin_Importer {
*/
public $block_id_attribute = 'formId';

/**
* Constructor
*
* @since 3.1.7
*/
public function __construct() {

// Register this as an importer, if Mailpoet forms exist.
add_filter( 'convertkit_get_form_importers', array( $this, 'register' ) );

}

/**
* Returns an array of Mailpoet form IDs and titles.
*
Expand Down
30 changes: 30 additions & 0 deletions admin/importers/class-convertkit-admin-importer-mc4wp.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@
*/
class ConvertKit_Admin_Importer_MC4WP extends ConvertKit_Admin_Importer {

/**
* Holds the programmatic name of the importer (lowercase, no spaces).
*
* @since 3.1.7
*
* @var string
*/
public $name = 'mc4wp';

/**
* Holds the title of the importer (for display in the importer list).
*
* @since 3.1.7
*
* @var string
*/
public $title = 'MC4WP';

/**
* Holds the shortcode name for MC4WP forms.
*
Expand Down Expand Up @@ -50,6 +68,18 @@ class ConvertKit_Admin_Importer_MC4WP extends ConvertKit_Admin_Importer {
*/
public $block_id_attribute = 'id';

/**
* Constructor
*
* @since 3.1.7
*/
public function __construct() {

// Register this as an importer, if MC4WP forms exist.
add_filter( 'convertkit_get_form_importers', array( $this, 'register' ) );

}

/**
* Returns an array of MC4WP form IDs and titles.
*
Expand Down
30 changes: 30 additions & 0 deletions admin/importers/class-convertkit-admin-importer-newsletter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@
*/
class ConvertKit_Admin_Importer_Newsletter extends ConvertKit_Admin_Importer {

/**
* Holds the programmatic name of the importer (lowercase, no spaces).
*
* @since 3.1.7
*
* @var string
*/
public $name = 'newsletter';

/**
* Holds the title of the importer (for display in the importer list).
*
* @since 3.1.7
*
* @var string
*/
public $title = 'Newsletter';

/**
* Holds the shortcode name for Newsletter forms.
*
Expand All @@ -32,6 +50,18 @@ class ConvertKit_Admin_Importer_Newsletter extends ConvertKit_Admin_Importer {
*/
public $block_name = 'tnp/minimal';

/**
* Constructor
*
* @since 3.1.7
*/
public function __construct() {

// Register this as an importer, if Newsletter forms exist.
add_filter( 'convertkit_get_form_importers', array( $this, 'register' ) );

}

/**
* Returns an array of the Newsletter Default Form, if the shortcode
* or block is used.
Expand Down
66 changes: 66 additions & 0 deletions admin/importers/class-convertkit-admin-importer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@
*/
abstract class ConvertKit_Admin_Importer {

/**
* Holds the importer name.
*
* @since 3.1.7
*
* @var string
*/
public $name = '';

/**
* Holds the importer title.
*
* @since 3.1.7
*
* @var string
*/
public $title = '';

/**
* Holds the shortcode name for the third party Form plugin.
*
Expand Down Expand Up @@ -59,6 +77,54 @@ abstract class ConvertKit_Admin_Importer {
*/
abstract public function get_forms();

/**
* Registers the importer if third party forms exist.
*
* @since 3.1.7
*
* @param array $importers Importers.
* @return array
*/
public function register( $importers ) {

// Bail if no third party forms exist in posts.
if ( ! $this->has_forms_in_posts() ) {
return $importers;
}

// Bail if no third party forms exist for this importer.
if ( ! $this->has_forms() ) {
return $importers;
}

// Add this importer to the list of importers.
$importers[ $this->name ] = array(
'name' => $this->name,
'title' => $this->title,
'forms' => $this->get_forms(),
);

return $importers;

}

/**
* Replaces third party form shortcodes and blocks with Kit form shortcodes and blocks.
*
* @since 3.1.7
*
* @param array $mappings Mappings.
*/
public function import( $mappings ) {

// Iterate through the mappings, replacing the third party form shortcodes and blocks with the Kit form shortcodes and blocks.
foreach ( $mappings as $third_party_form_id => $kit_form_id ) {
$this->replace_blocks_in_posts( (int) $third_party_form_id, (int) $kit_form_id );
$this->replace_shortcodes_in_posts( (int) $third_party_form_id, (int) $kit_form_id );
}

}

/**
* Returns an array of post IDs that contain the third party form block or shortcode.
*
Expand Down
Loading