Example #1
0
    function form($instance)
    {
        //Defaults
        $instance = wp_parse_args((array) $instance, array('title' => __('Subscribe', 'bloom'), 'optin_id' => 'empty'));
        $title = $instance['title'];
        $optin_id_saved = $instance['optin_id'];
        # Title
        printf('<p>
				<label for="%1$s">%2$s: </label>
				<input class="widefat" id="%1$s" name="%4$s" type="text" value="%3$s" />
			</p>', esc_attr($this->get_field_id('title')), esc_html__('Title', 'bloom'), esc_attr($title), esc_attr($this->get_field_name('title')));
        $optins_set = ET_Bloom::widget_optins_list();
        $optins_formatted = '';
        foreach ($optins_set as $optin_id => $name) {
            $optins_formatted .= sprintf('<option value="%1$s" %2$s>%3$s</option>', esc_attr($optin_id), selected($optin_id, $optin_id_saved, false), esc_html($name));
        }
        printf('<p>
				<label for="%1$s">%2$s: </label>
				<select class="widefat" id="%1$s" name="%4$s" type="text">%5$s</select>
			</p>', esc_attr($this->get_field_id('optin_id')), esc_html__('Select Optin', 'bloom'), esc_attr($title), esc_attr($this->get_field_name('optin_id')), $optins_formatted);
    }
Example #2
0
 public function update_account($name, $data_array = array())
 {
     global $et_bloom;
     $service = $this->slug;
     if (!empty($name)) {
         $name = str_replace(array('"', "'"), '', stripslashes($name));
         $options_array = ET_Bloom::get_bloom_options();
         $new_account['accounts'] = isset($options_array['accounts']) ? $options_array['accounts'] : array();
         $new_account['accounts'][$service][$name] = isset($new_account['accounts'][$service][$name]) ? array_merge($new_account['accounts'][$service][$name], $data_array) : $data_array;
         $et_bloom->update_option($new_account);
     }
 }
Example #3
0
 /**
  * Adds appropriate actions for Flyin, Popup, Below Content to wp_footer,
  * Adds custom_css function to wp_head
  * Adds trigger_bottom_mark to the_content filter for Flyin and Popup
  * Creates arrays with optins for for Flyin, Popup, Below Content to improve the performance during forms displaying
  */
 function frontend_register_locations()
 {
     $options_array = ET_Bloom::get_bloom_options();
     if (!is_admin() && !empty($options_array)) {
         add_action('wp_head', array($this, 'set_custom_css'));
         $flyin_count = 0;
         $popup_count = 0;
         $below_count = 0;
         $after_comment = 0;
         $after_purchase = 0;
         foreach ($options_array as $optin_id => $details) {
             if ('accounts' !== $optin_id) {
                 if (isset($details['optin_status']) && 'active' === $details['optin_status'] && empty($details['child_of'])) {
                     switch ($details['optin_type']) {
                         case 'flyin':
                             if (0 === $flyin_count) {
                                 add_action('wp_footer', array($this, "display_flyin"));
                                 $flyin_count++;
                             }
                             if (0 === $after_comment && isset($details['comment_trigger']) && true == $details['comment_trigger']) {
                                 add_filter('comment_post_redirect', array($this, 'after_comment_trigger'));
                                 $after_comment++;
                             }
                             if (0 === $after_purchase && isset($details['purchase_trigger']) && true == $details['purchase_trigger']) {
                                 add_action('woocommerce_thankyou', array($this, 'add_purchase_trigger'));
                                 $after_purchase++;
                             }
                             $this->flyin_optins[$optin_id] = $details;
                             break;
                         case 'pop_up':
                             if (0 === $popup_count) {
                                 add_action('wp_footer', array($this, "display_popup"));
                                 $popup_count++;
                             }
                             if (0 === $after_comment && isset($details['comment_trigger']) && true == $details['comment_trigger']) {
                                 add_filter('comment_post_redirect', array($this, 'after_comment_trigger'));
                                 $after_comment++;
                             }
                             if (0 === $after_purchase && isset($details['purchase_trigger']) && true == $details['purchase_trigger']) {
                                 add_action('woocommerce_thankyou', array($this, 'add_purchase_trigger'));
                                 $after_purchase++;
                             }
                             $this->popup_optins[$optin_id] = $details;
                             break;
                         case 'below_post':
                             if (0 === $below_count) {
                                 add_filter('the_content', array($this, 'display_below_post'), 9999);
                                 add_action('woocommerce_after_single_product_summary', array($this, 'display_on_wc_page'));
                                 $below_count++;
                             }
                             $this->below_post_optins[$optin_id] = $details;
                             break;
                     }
                 }
             }
         }
         if (0 < $flyin_count || 0 < $popup_count) {
             add_filter('the_content', array($this, 'trigger_bottom_mark'), 9999);
         }
     }
 }