Ejemplo n.º 1
0
 /**
  * Modify options before template
  *
  * Only if one of the email templates are run, so as not to waste processing time,
  * and check if REQUEST fields are being posted and rather use those.
  *
  * @date	20-08-2014
  * @since	1.0
  */
 function ec_before_template_filter_options($template_name, $template_path, $located, $args)
 {
     if (FALSE !== strrpos($template_name, 'email')) {
         // Get active templates.
         $ec_template_selected = false;
         if (get_option("ec_template")) {
             $ec_template_selected = get_option("ec_template");
         }
         if (isset($_REQUEST['ec_email_template'])) {
             $ec_template_selected = $_REQUEST['ec_email_template'];
         }
         // Modify if theres preview fields.
         $settings = ec_get_settings($ec_template_selected);
         if ($settings) {
             foreach ($settings as $setting_key => $setting_value) {
                 $field_id = $setting_value["id"];
                 $field_type = $setting_value["type"];
                 add_filter("default_option_{$field_id}", array('EC_Settings', 'ec_default_option'));
                 add_filter("option_{$field_id}", create_function('$field_value', 'return EC_Settings::ec_render_option("' . $field_id . '", $field_value ); '));
             }
         }
         // Only do this once, the first time an email template is called.
         remove_filter('woocommerce_before_template_part', array($this, 'ec_before_template_filter_options'));
     }
 }
Ejemplo n.º 2
0
 /**
  * Get a setting from the settings API.
  *
  * @param 	mixed $option
  * @return	string Value of the option.
  */
 public static function get_option_array($option_name, $option_key = false)
 {
     global $ec_cache_options;
     $return_value = false;
     if (!isset($ec_cache_options)) {
         $ec_cache_options = ec_get_settings();
     }
     if (isset($ec_cache_options[$option_name])) {
         $return_value = $ec_cache_options[$option_name];
     }
     // No option array found return false
     if (!$return_value) {
         return false;
     }
     $defaults = array('type' => '', 'default' => '');
     $return_value = wp_parse_args($return_value, $defaults);
     if ($option_key) {
         if (isset($return_value[$option_key])) {
             $return_value = $return_value[$option_key];
         } else {
             $return_value = false;
         }
     }
     return $return_value;
 }
Ejemplo n.º 3
0
                    $form_sub_class = "ec_settings_form_sub ";
                    $form_sub_class .= "ec_settings_form_sub_" . $ec_email_template_id . " ";
                    $form_sub_class .= "ec_settings_form_sub_" . $ec_email_template_id . "_" . $ec_email_template_kind . " ";
                    ?>

											
											<div id="<?php 
                    echo $form_sub_id;
                    ?>
" class="<?php 
                    echo $form_sub_class;
                    ?>
" >
												
												<?php 
                    EC_Settings::output_fields(ec_get_settings($ec_email_template_id, array('group' => $ec_email_template_kind)));
                    ?>

												
											</div>
											
											<?php 
                }
            }
            ?>

									
									<!--
									<input type="hidden" name="ec_email_type" value="<?php 
            echo $ec_email_template_kind;
            ?>