' . "\n"; echo '' . "\n"; } add_action('wp_head','aa_output_head'); function aa_output_footer() { global $aa_settings; echo '' . "\n"; } add_action('wp_footer','aa_output_footer'); function aa_get_parameters($shortcode_params = false, $widget_params = false, $tool_key) { global $post, $aa_settings; $request_parameters = array(); //Set client type if($tool_key == 'lister') { $request_parameters['aClientType'] = 'WPJS'; } elseif($tool_key == 'banner') { $request_parameters['aClientType'] = 'WPIF'; } //If shortcode data if(is_array($shortcode_params)) { //Validate and re-camel case shortcode attributes $input_names = aa_get_input_names(); $allowable_shortcode_params = array(); foreach($shortcode_params as $attr_key => $attr_value) { //If allowable if(array_key_exists($attr_key, $input_names)) { $allowable_shortcode_params[$input_names[$attr_key]] = $attr_value; } } //If widget data } elseif(is_array($widget_params)) { $widget_params_unprefixed = array(); foreach($widget_params as $attr_key => $attr_value) { $attr_key = aa_unprefix($attr_key); $widget_params_unprefixed[$attr_key] = $attr_value; } } //Build request URL from user options foreach($aa_settings['custom_field_inputs'] as $field) { $prefixed_field_name = aa_prefix($field['name'], $tool_key); //Don't add client options to URL, also check this param is valid for the tool if(($field['name'][0] == 'e' || $field['name'][0] == 'a') && $field[$tool_key . '_param'] == true) { //WIDGET //There are widget params and this one is a non-empty string value if(isset($widget_params_unprefixed) && array_key_exists($field['name'], $widget_params_unprefixed) && $widget_params_unprefixed[$field['name']] !== '') { $request_parameters[$field['name']] = $widget_params_unprefixed[$field['name']]; //SHORTCODE //There are shortcode params and this one is allowed } elseif(isset($allowable_shortcode_params) && array_key_exists($field['name'], $allowable_shortcode_params)) { //Add to URL $request_parameters[$field['name']] = $allowable_shortcode_params[$field['name']]; //CUSTOM FIELD //The value for this param is not an empty string and we aren't dealing with a wiget } elseif(($field_value = get_post_meta($post->ID, $prefixed_field_name, true)) !== '' && ! isset($widget_params_unprefixed)) { //Add to URL $request_parameters[$field['name']] = $field_value; } } } return $request_parameters; } function aa_output_html($request_parameters = false, $tool_key = false){ global $aa_settings; //Lister if($tool_key == 'lister') { $aHash = md5(serialize($request_parameters)); $request_parameters['aHash'] = $aHash; $width = ''; $output_html = ''; //Edit some user parameters foreach($request_parameters as $data_key => &$data_value) { switch($data_key) { //Add % symbol case 'aWidth': $width = $data_value; if(is_numeric($width)) { $width .= '%'; } $width = ' style="width:' . $width . ';margin:auto"'; break; //Remove hash case 'aColourP': case 'aColourS': case 'aColourB': $data_value = str_replace('#', '', $data_value); break; } } $output_html .= '