| 1 |
<?php |
| 2 |
/** |
| 3 |
* ConvertKit Admin Importer ActiveCampaign class. |
| 4 |
* |
| 5 |
* @package ConvertKit |
| 6 |
* @author ConvertKit |
| 7 |
*/ |
| 8 |
|
| 9 |
/** |
| 10 |
* Import and migrate data from ActiveCampaign to Kit. |
| 11 |
* |
| 12 |
* @package ConvertKit |
| 13 |
* @author ConvertKit |
| 14 |
*/ |
| 15 |
class ConvertKit_Admin_Importer_ActiveCampaign extends ConvertKit_Admin_Importer { |
| 16 |
|
| 17 |
/** |
| 18 |
* Holds the programmatic name of the importer (lowercase, no spaces). |
| 19 |
* |
| 20 |
* @since 3.1.7 |
| 21 |
* |
| 22 |
* @var string |
| 23 |
*/ |
| 24 |
public $name = 'activecampaign'; |
| 25 |
|
| 26 |
/** |
| 27 |
* Holds the title of the importer (for display in the importer list). |
| 28 |
* |
| 29 |
* @since 3.1.7 |
| 30 |
* |
| 31 |
* @var string |
| 32 |
*/ |
| 33 |
public $title = 'ActiveCampaign'; |
| 34 |
|
| 35 |
/** |
| 36 |
* Holds the shortcode name for ActiveCampaign forms. |
| 37 |
* |
| 38 |
* @since 3.1.7 |
| 39 |
* |
| 40 |
* @var string |
| 41 |
*/ |
| 42 |
public $shortcode_name = 'activecampaign'; |
| 43 |
|
| 44 |
/** |
| 45 |
* Holds the ID attribute name for ActiveCampaign forms. |
| 46 |
* |
| 47 |
* @since 3.1.7 |
| 48 |
* |
| 49 |
* @var string |
| 50 |
*/ |
| 51 |
public $shortcode_id_attribute = 'form'; |
| 52 |
|
| 53 |
/** |
| 54 |
* Holds the block name for ActiveCampaign forms. |
| 55 |
* |
| 56 |
* @since 3.1.7 |
| 57 |
* |
| 58 |
* @var string |
| 59 |
*/ |
| 60 |
public $block_name = 'activecampaign-form/activecampaign-form-block'; |
| 61 |
|
| 62 |
/** |
| 63 |
* Holds the ID attribute name for ActiveCampaign forms. |
| 64 |
* |
| 65 |
* @since 3.1.7 |
| 66 |
* |
| 67 |
* @var string |
| 68 |
*/ |
| 69 |
public $block_id_attribute = 'formId'; |
| 70 |
|
| 71 |
/** |
| 72 |
* Constructor |
| 73 |
* |
| 74 |
* @since 3.1.7 |
| 75 |
*/ |
| 76 |
public function __construct() { |
| 77 |
|
| 78 |
// Register this as an importer, if ActiveCampaign forms exist. |
| 79 |
add_filter( 'convertkit_get_form_importers', array( $this, 'register' ) ); |
| 80 |
|
| 81 |
} |
| 82 |
|
| 83 |
/** |
| 84 |
* Returns an array of ActiveCampaign form IDs and titles. |
| 85 |
* |
| 86 |
* @since 3.1.7 |
| 87 |
* |
| 88 |
* @return array |
| 89 |
*/ |
| 90 |
public function get_forms() { |
| 91 |
|
| 92 |
// Forms are cached in the Plugin Settings. |
| 93 |
$settings = get_option( 'settings_activecampaign' ); |
| 94 |
|
| 95 |
// Bail if the ActiveCampaign Plugin Settings are not set. |
| 96 |
if ( ! $settings ) { |
| 97 |
return array(); |
| 98 |
} |
| 99 |
|
| 100 |
// Bail if the ActiveCampaign Forms are not set. |
| 101 |
if ( ! array_key_exists( 'forms', $settings ) ) { |
| 102 |
return array(); |
| 103 |
} |
| 104 |
|
| 105 |
// Build array of forms. |
| 106 |
$forms = array(); |
| 107 |
foreach ( $settings['forms'] as $form ) { |
| 108 |
$forms[ $form['id'] ] = $form['name']; |
| 109 |
} |
| 110 |
|
| 111 |
return $forms; |
| 112 |
|
| 113 |
} |
| 114 |
|
| 115 |
} |
| 116 |
|