Exemplo n.º 1
0
 /** 
  * Called via AJAX to submit the subscribe form. 
  *
  * @since 1.5.2
  * @return string The JSON encoded response.
  */
 public function submit()
 {
     $name = isset($_POST['name']) ? sanitize_text_field($_POST['name']) : false;
     $email = isset($_POST['email']) ? sanitize_email($_POST['email']) : false;
     $node_id = isset($_POST['node_id']) ? sanitize_text_field($_POST['node_id']) : false;
     $result = array('action' => false, 'error' => false, 'message' => false, 'url' => false);
     if ($email && $node_id) {
         $module = FLBuilderModel::get_module($node_id);
         $settings = $module->settings;
         // Subscribe.
         $instance = FLBuilderServices::get_service_instance($settings->service);
         $response = $instance->subscribe($settings, $email, $name);
         // Check for an error from the service.
         if ($response['error']) {
             $result['error'] = $response['error'];
         } else {
             $result['action'] = $settings->success_action;
             if ('message' == $settings->success_action) {
                 $result['message'] = $settings->success_message;
             } else {
                 $result['url'] = $settings->success_url;
             }
         }
     } else {
         $result['error'] = __('There was an error subscribing. Please try again.', 'fl-builder');
     }
     echo json_encode($result);
     die;
 }
Exemplo n.º 2
0
<div class="fl-builder-service-settings">
	<table class="fl-form-table">
		<?php 
// Get the service type.
$service_type = null;
if (isset($section['services']) && $section['services'] != 'all') {
    $service_type = $section['services'];
}
// Get the service data.
$services = FLBuilderServices::get_services_data($service_type);
// Remove services that don't meet the requirements.
if (isset($services['mailpoet']) && !class_exists('WYSIJA')) {
    unset($services['mailpoet']);
}
// Build the select options.
$options = array('' => __('Choose...', 'fl-builder'));
foreach ($services as $key => $service) {
    $options[$key] = $service['name'];
}
// Render the service select.
FLBuilder::render_settings_field('service', array('row_class' => 'fl-builder-service-select-row', 'class' => 'fl-builder-service-select', 'type' => 'select', 'label' => __('Service', 'fl-builder'), 'options' => $options, 'preview' => array('type' => 'none')), $settings);
?>
	</table>
</div>