get_post_meta data with shortcode, is that possible - php

The question is about Wordpress custom meta fields. If my meta field has something in it, I want to display my meta values on my single.php, where I want to. I think it's possible with shortcodes.
function themedemocode($atts,$content = null ) {
return 'What should i do for displaying my meta values ?';
}
add_shortcode('demo', 'themedemocode');
My meta fields ids are ;
ThemeDemoUrl and ThemeDownloadUrl ?
-- SOLVED --
function examplewpkeep($atts, $content = null ) {
global $post;
$custom_content = get_post_custom($post->ID);
if (isset($custom_content["UygulamaDemo"])) {
$meta_content = $custom_content["UygulamaDemo"][0];
}
if (isset($custom_content["UygulamaKaynak"])) {
$meta_content = $custom_content["UygulamaKaynak"][0];
}
$meta_content = '<p style="text-align:center;width:600px;"><a class="informational-link" style="color:#fff;text-decoration:none;margin-right:20px;" href="http://www.fatihtoprak.com/git/'.$custom_content["UygulamaDemo"][0].'" target="_blank" />Önizleme.</a><a class="website-link" style="color:#fff;text-decoration:none;" href="http://www.fatihtoprak.com/git/'.$custom_content["UygulamaKaynak"][0].'" target="_blank" />Dosyaları indir.</a></p>';
return $meta_content;
}
add_shortcode('kaynak', 'examplewpkeep');

Untested, but something like this should work:
function themedemocode($atts, $content = null ) {
global $post;
$meta_content = '';
$custom_content = get_post_custom($post->ID);
if (isset($custom_content["ThemeDemoUrl"])) {
$meta_content .= $custom_content["ThemeDemoUrl"][0];
}
if (isset($custom_content["ThemeDownloadUrl "])) {
$meta_content .= $custom_content["ThemeDownloadUrl"][0];
}
return $meta_content;
}
Of course you can wrap your meta content like the following to apply some html / styling to it
$meta_content .= '<p>' . $custom_content["someKey"][0] . '</p>'.

Related

Send all of a dropdown in Contact Form 7

I need to send a full array of custom field to a mail (dynamicaly populate) with contact Form 7 to work it here before sending :
// define the wpcf7_posted_data callback
function action_wpcf7_posted_data($array)
{
$a = get_field('date')
//WORK HERE
$array['Nom & Prénom'] = $array['name'];
unset($array['name']);
$array['E-mail'] = $array['email'];
unset($array['email']);
$array['Téléphone'] = $array['tel'];
unset($array['tel']);
$array['Profession'] = $array['job'];
unset($array['job']);
$array['Session'] = $array['upcoming-gigs'];
unset($array['upcoming-gigs']);
unset($array['privacy']);
return $array;
}
add_filter('wpcf7_posted_data', 'action_wpcf7_posted_data', 10, 1);
Because it's before sending a mail I can't call anything to compare before sending.
So I want to send all the data in a hidden input next to compare it.
This the two input in contact Form 7 :
[select upcoming-gigs data:gigs id:date] [hidden select upcoming-gigs2 data:gigs2]
My goal here is to send all the data of the hidden select.
I don't find a way to send all input in the mail.
Is it possible ? There is a better way ?
Thx
EDIT :
My question mark2 :
The goal is to send a mail with the date of the session and the id of it.
I use ACF and I have :
And after a dynamic dropdown, it's look like this for the user :
The problem is I don't have the id of the session, only the date.
To know the id I need to compar to the array of all the custom field, I can't import it during wpcf7_posted_data.
I think if I send all the data of the array in a hidden field, I could remake the array and find the id of the session my user choose.
I hope I'm clearer.
(I can't make a request in php during wpcf7_posted_data. Can I make an ajax request ?)
EDIT2 :
This my hidden select with session and text
This is the html of contact form 7 the rest is div for CSS
[select upcoming-date data:date id:date] [hidden select upcoming-date2 data:date2]
EDIT3 :
Okay get it.
The custom fields I use to make the dropdown are in two part id and text. I have the text part I need the id.
If I send every text and id in the mail I can compare to the answer of the user et add to the mail the right id.
Here the generated html : http://www.sharemycode.fr/5ax
EDIT 4 :
That where I write the id and text of the dropdown :
That where I create the select :
add_filter('wpcf7_form_tag_data_option', function ($n, $options, $args) {
$ses = (array)get_field('date_new');
$sesCount = count($ses);
$gigs = [];
$gigs2 = [];
if (in_array('gigs', $options)) {
for ($i = 0; $i < $sesCount; $i++) {
if ($ses[$i]['date_start'] > date('d-m-Y', time())) {
$a = "A réaliser entre le " . $ses[$i]['date_start'] . " et le " . $ses[$i]['date_end'] ." | bla";
array_push($gigs, $a);
}
}
return $gigs;
}
}
It looks like this is supported by Contact Form 7 natively, it's just not very obvious on how to make it happen.
Here's a documentation page explaining the functionality: http://contactform7.com/selectable-recipient-with-pipes/
Basically all you have to do is put the values like so:
Visible Value|actual-form-value
What comes before the pipe "|" character will be shown in the form, and what comes after will be the actual value filled in for the form.
EDIT kanarpp :
I add my code here to separate the answer of HowardE.
This is how I dynamicaly create my select :
add_filter('wpcf7_form_tag_data_option', function ($n, $options, $args) {
$ses = (array)get_field('date');
$sesCount = count($ses);
$date= [];
if (in_array('date', $options)) {
for ($i = 0; $i < $sesCount; $i++) {
if ($ses[$i]['date_start'] > date('d-m-Y', time())) {
$a = "A réaliser entre le " . $ses[$i]['date_start'] . " et le " . $ses[$i]['date_end'] ." | bla";
array_push($date, $a);
}
}
return $date;
}
It's not working, I use Smart Grid-Layout Design for Contact Form 7 to create dynmicaly my select
I would create a custom form tag for the select. The following code will create a custom form tag called [gigs] which would be used like this:
[gigs upcoming-gigs]
I've also included ability to add the * and make it required.
My assumptions are how you're actually getting the ACF fields, which I can't actually do, since I don't have them, and you haven't completely shared how it's stored. You would add this to your functions.php.
add_action('wpcf7_init', function (){
wpcf7_add_form_tag( array('gigs', 'gigs*'), 'dd_cf7_upcoming_gigs' , array('name-attr' => true) );
});
function dd_cf7_upcoming_gigs($tag) {
if ( empty( $tag->name ) ) {
return '';
}
$validation_error = wpcf7_get_validation_error( $tag->name );
$class = wpcf7_form_controls_class( $tag->type );
if ( $validation_error ) {
$class .= ' wpcf7-not-valid';
}
$atts = array();
$atts['class'] = $tag->get_class_option( $class );
$atts['id'] = $tag->get_id_option();
$atts['tabindex'] = $tag->get_option( 'tabindex', 'signed_int', true );
if ( $tag->is_required() ) {
$atts['aria-required'] = 'true';
}
if ( $validation_error ) {
$atts['aria-invalid'] = 'true';
$atts['aria-describedby'] = wpcf7_get_validation_error_reference(
$tag->name
);
} else {
$atts['aria-invalid'] = 'false';
}
// Make first option unselected and please choose
$html = '<option value="">- - '. __('Please Choose', 'text-domain'). ' - -</option>';
// This part you may have to update with your custom fields
$ses = (array)get_field('date_new');
$sesCount = count($ses);
for ($i = 0; $i < $sesCount; $i++) {
if ($ses[$i]['date_start'] > date('d-m-Y', time())) {
$a = "A réaliser entre le " . $ses[$i]['date_start'] . " et le " . $ses[$i]['date_end'];
// if session ID is in fact $ses[$i]['session']
$html .= sprintf( '<option %1$s>%2$s</option>',
$ses[$i]['session'], $a );
}
}
foreach ($gigs as $key => $value){
$html .= sprintf( '<option %1$s>%2$s</option>',
$key, $value );
}
$atts['name'] = $tag->name;
$atts = wpcf7_format_atts( $atts );
$html = sprintf(
'<span class="wpcf7-form-control-wrap %1$s"><select %2$s>%3$s</select>%4$s</span>',
sanitize_html_class( $tag->name ), $atts, $html, $validation_error
);
return $html;
}
add_filter( 'wpcf7_validate_gigs', 'dd_validate_gigs_filter', 10, 2 );
add_filter( 'wpcf7_validate_gigs*', 'dd_validate_gigs_filter', 10, 2 );
function dd_validate_gigs_filter( $result, $tag ) {
$name = $tag->name;
$has_value = isset( $_POST[$name] ) && '' !== $_POST[$name];
if ( $has_value and $tag->has_option( 'multiple' ) ) {
$vals = array_filter( (array) $_POST[$name], function( $val ) {
return '' !== $val;
} );
$has_value = ! empty( $vals );
}
if ( $tag->is_required() and ! $has_value ) {
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
}
return $result;
}

Remove Quantity number before stock status in Woocommerce?

i use plugin called WC Product Stock Status into my Woocommerce site, and want to remove number before stock status. I tryed to see if quantity number is set in different CSS class, but seems that is all in one class, so hidding via CSS looks not possible.
.woocommerce div.product p.stock
{font-size: .92em;}
.woocommerce div.product .s_in_stock_color {
color:#77a464;
}
Unfortinally this plugin is outdated and looks no longer supported be author, so asking question on plugin page, is useless. So i want just to remove number of quantity that is in stock, and keep the label, like on image bellow:
I checked into code and found that that table is generated fetching this data in class-variable-status.php file:
public function print_stock_status(){
global $product;
if($product->is_type( 'variable' ) ) {
$childrens = $product->get_children();
$values = array();
foreach($childrens as $child){
$prod = wc_get_product($child);
$search_replace = array();
$search_replace['%formatted_name%'] = $prod->get_formatted_name();
$search_replace['%name%'] = wc_get_formatted_variation($prod);
$search_replace['%sku%'] = $prod->get_sku();
$search_replace['%id%'] = $prod->get_id();
$format = wc_pstocks_option('variable_title');
$format = str_replace(array_keys($search_replace),array_values($search_replace),$format);
$status = $prod->get_availability();;
$status['title'] = $format;
$status['ID'] = $child;
$status['formatted_name'] = $prod->get_formatted_name();
$status['name'] = wc_get_formatted_variation($prod);
$status['sku'] = $prod->get_sku();
$status['id'] = $prod->get_id();
$values[$child] = $status;
}
$this->generate_table($values);
}
}
public function generate_table($values){
wc_pstocks_get_template('stock-variation-
table.php',array("args"=>$values));
}
and this is code from stock-variation-
table.php
<?php
foreach($args as $arr){
$text = empty($arr['availability']) ? '' : '<p class="stock '.esc_attr($arr['class']).'">'.$arr['availability'].'</p>';
echo '<tr>';
echo '<td>'.$arr['title'].'</td>';
echo '<td>'.$text.'</td>';
echo '</tr>';
}
?>
I think that something neeed to be updated into this line:
$text = empty($arr['availability']) ? '' : '<p class="stock '.esc_attr($arr['class']).'">'.$arr['availability'].'</p>';
Any help how to remove that?
I was able to fix myself.. This is what i do:
From Woocommerce settings goes to Products>Inventory and just set this:
Now showing statuses, but without quantity.

How to get attribute for shortcode in wordpress?

I have constructed a shortcode like this:
[myshortcode id="4"]content[/myshortcode]
with this:
<?php
function f_shortcode($atts, $content = null) {
$returned_string = '<div class="wrap">';
$returned_string .= '<div class="frame">'.$content.'</div>';
$returned_string .= '</div>';
return $returned_string;
}
add_shortcode('myshortcode', 'f_shortcode');
?>
What i need from my shortcode is to retrieve a record from option table in the database (i.e retrieve content based on the id given in the shortcode)
In the options table i have this:
a:1:{i:0;O:8:"stdClass":4:{s:2:"id";s:1:"4";s:9:"title";s:5:"test";s:11:"content";s:5:"test content";s:13:"shortcode";s:29:"[myshortcode id="4"][/myshortcode id="4"]";}}
So to retrieve the content i have added this peace of code to my function:
extract(shortcode_atts(array(
'id' => 'id'
), $atts));
if(get_option('results_options') && get_option('results_options') != ''){
$results = get_option('results_options');
foreach ($results as $result){
if($result->id == '{$id}'){
$content = $result->content;
continue;
}
}
}
In my table the content is there, but it doesnt display or it doesnt even be retrieved, Is there a problem with my code ?
How to get the id="4" parametre inside the function to retrieve the record from the database with it ?

PHP widget use class selector instead of <tag> to build menu

I hope on of you clever chaps might be able to answer this riddle.
I have an excellent widget I am trying to integrate into my site. It creates menus from <H1>, <H2> etc, tags in the document. This is very useful as I can create sub menu navigation for each of my pages by styling the titles.
I am however using a wordpress theme that has extensions added to the editor that style various parts of the pages, including for example titles.
So the output from how it styles the title in HTML output is as follows for example:
<h1 class="grve-element grve-align-left grve-title-striped" style="">Visit</h1>
The PHP script I will load in below, the relevant section it appears to grab tags is:
$tags_to_parse = "<h1>";
Is there a way I can tell this PHP script to grab this particular H1 class?
Cheers,
Tomek
<?php
/*
Plugin Name: Anchors Menu
Description: Check Wordpress static pages content and create a widget menu with links that point to words between the HTML tags you chose.
Author: Gonçalo Rodrigues
Version: 1.2
Author URI: http://www.goncalorodrigues.com
*/
/* Copyright 2010 Gonçalo Rodrigues (email : gonafr [AT] gmail [DOT] com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
//ERROR_REPORTING(E_ALL);
$count = -1;
add_action("init", "anc_insert_init");
add_filter("the_content", "anc_add_link_text");
// renders the list in your theme;
function anc_insert()
{
$tags_to_parse = "<h1>";
$current_page_id = get_the_ID();
$page_data = get_page($current_page_id);
$current_page_name = $page_data->post_name;
$current_page_cat_id = get_cat_ID($current_page_name);
$page_id = get_the_ID();
// if it's blog style page
if (is_home()){
$count = 0;
$content = "";
if ( have_posts() ) : while ( have_posts() ) : the_post();
$id_post = get_the_ID();
$post = get_post($id_post);
$content .= "<a name=\"$count\"></a>";
$content .= $post->post_content;
$count++;
endwhile; else:
//_e("Sorry, no posts matched your criteria.");
endif;
anc_list_menu($content);
//echo "Sorry but this plugin only work on Wordpress pages.";
}
//if it's page style page
else if(is_page()){
$page_id = get_the_ID();
$page_data = get_page( $page_id );
//$title = $page_data->post_title; // Get title
$content = $page_data->post_content;
//if content is empty i will fetch all pages that are child of the current page and get their titles
$fetch_children_pages = true;
if (fetch_children_pages == true && $content==""){
$content = "";
$pages = get_pages('child_of='.$page_id.'&sort_column=post_date&sort_order=desc');
foreach($pages as $page)
{
$content .= "<".$tags_to_parse.">".$page->post_title."</".$tags_to_parse.">";
if(!$content)
continue;
$count++;
}
}
anc_list_menu($content);
}
// if it's single post
else if (is_single()){
$content = "";
$content .= get_the_content();
anc_list_menu($content);
//echo "Sorry but this plugin only work on Wordpress pages.";
}
//if it's a category page
else if(is_category){
//echo $current_page_cat_id;
//echo $current_page_name;
//echo $current_page_id;
$current_cat = get_the_category();
//echo 'teste'.$current_cat[0]->cat_name;
$current_cat_id = get_cat_ID($current_cat[0]->cat_name);
$posts = get_posts('$category_name='.$current_cat[0]->cat_name);
$content = "";
if ( have_posts() ) : while ( have_posts() ) : the_post();
$id_post = get_the_ID();
$post = get_post($id_post);
$content .= "<".$tags_to_parse.">".$post->post_title."</".$tags_to_parse.">";
endwhile; else:
//_e("Sorry, no posts matched your criteria.");
endif;
anc_list_menu($content);
//echo "Sorry but this plugin only work on Wordpress pages.";
}
else {
//_e("Error: This page is not a tradicional Wordpress Page or a Wordpress Blog!");
}
}
// prints the menu with the links to the titles
function anc_list_menu($content){
// list all tags
$foo_tags = anc_get_tags($content);
if($foo_tags[1] != 0){
$foo = -1;
echo "<ul>";
foreach($foo_tags[0] as $key => $val){
$foo++;
echo "<li>".$val."</li>";
}
echo "</ul>";
}else{
//no tags found
//_e("Not found any tag of the type that was selected to be parsed.");
}
}
// retrieve all words between tags
function anc_get_tags($content){
global $tags_to_parse;
$options = get_option("anc_tags");
$tags_to_parse = $options["anc_tags"];
$pattern_search = "/(<".$tags_to_parse.".*>)(.*)(<\/".$tags_to_parse.">)/isxmU";
preg_match_all($pattern_search, $content, $patterns);
$res = array();
array_push($res, $patterns[2]);
array_push($res, count($patterns[2]));
return $res;
}
// insert widget
function anc_insert_init()
{
//register the widget
register_sidebar_widget("Anchors Menu", "anc_widget_insert");
//register the widget control
register_widget_control("Anchors Menu", "anc_widget_insert_control");
}
function anc_widget_insert($args) {
global $title, $tags_to_parse;
extract($args);
//get our options
$options = get_option("anc_title");
$title = $options["anc_title"];
$options = get_option("anc_tags");
$tags_to_parse = $options["anc_tags"];
echo $before_widget;
/*Insert any headers you want in the next line, between "?>" and "<?". Leave blank for no header. */
echo $before_title . $title . $after_title;
anc_insert();
echo $after_widget;
}
// responsable for options in backoffice
function anc_widget_insert_control() {
global $title, $tags_to_parse;
//get saved options if user change things
//handle user input
if (isset($_POST["anc_insert_submit"])){
$foo_title = strip_tags(stripslashes($_POST["anc_title"]));
$foo_tags = strtolower(stripslashes($_POST["anc_tags"]));
$options["anc_title"] = $foo_title;
$options["anc_tags"] = $foo_tags;
update_option("anc_title", $options);
update_option("anc_tags", $options);
}
else {
//default options
$options["anc_title"] = "Menu";
$options["anc_tags"] = "h2";
update_option("anc_title", $options);
update_option("anc_tags", $options);
}
//get our options
$options = get_option("anc_title");
$title = $options["anc_title"];
$options = get_option("anc_tags");
$tags_to_parse = $options["anc_tags"];
//print the widget control
include("anc-insert-widget-control.php");
}
// adds anchors to content tags
function anc_add_link_text($content){
global $tags_to_parse, $count;
$options = get_option("anc_tags");
$tags_to_parse = $options["anc_tags"];
$pattern_search = array();
$pattern_search = "/(<".$tags_to_parse.".*>)(.*)(<\/".$tags_to_parse.">)/isxmU";
return preg_replace_callback($pattern_search, "anc_replacement", $content, -1);
}
// aux funtion to add_link_text
function anc_replacement($matches){
global $tags_to_parse, $count;
$count++;
return "<a name=\"".$count."\"></a>"."<".$tags_to_parse.">".$matches[2]."</".$tags_to_parse.">";
}
?>
Replace your $pattern_search variable with this:
$pattern_search = "/(<h1 .*(".$tags_to_parse.")+ .*>)+(.*)+(<\/h1>)/isxmU";
Now you can pass class to your function:
$tags_to_parse = "grve-element";
Update
$tags_to_parse = "grve-element";
$content = '<h1 class="grve-element grve-align-left grve-title-striped" style="">Visit</h1>sf efew <h1 grve-element>rffef</h1>';
$pattern_search = "/\<h1 .(".$tags_to_parse.")?[^\>]*\>(.*?)\<\/h1\>/";
preg_match_all($pattern_search, $content, $patterns);
print_r($patterns[2]);
Output
Array ( [0] => Visit [1] => rffef )

Hide language WPML

I am using WPML language, and cant find solution for next thing:
On the Language switcher i want to hide language, lets say for example - "he", if current language is lets say for example "ar", so when we on arabic site we will not see on the selector the Hebrew, and same thing if we on Hebrew, the arabic will not display.
On shorten words: what i want is - if we on arabic site - the hebrew flag will be hidden.
What i tried:
function language_selector_flags(){
$languages = icl_get_languages('skip_missing=0');
if(!empty($languages)){
if(ICL_LANGUAGE_CODE=='en')
{
$order = array('ar'); //Specify your sort order here
}
elseif(ICL_LANGUAGE_CODE=='he')
{
$order = array('en', 'ar'); //Specify your sort order here
}
foreach ($order as $l) {
if (isset($languages[$l])) {
$l = $languages[$l]; //grab this language from the unsorted array that is returned by icl_get_languages()
//Display whatever way you want -- I'm just displaying flags in anchors (CSS: a {float:left; display:block;width:18px;height:12px;margin:0 2px;overflow:hidden;line-height:100px;})
if($l['active']) { $class = "active"; $url=""; } else { $class = ''; $url = 'href="'.$l['url'].'"'; }
echo '<a '.$url.' style="background:url('.$l['country_flag_url'].') no-repeat;" class="flag '.$class.'">';
echo $l['language_code'].'';
}
}
}
}
Its not affect at all the selector.
You can check out the plugin WPML Flag In Menu.
You could use the plugin_wpml_flag_in_menu() function from the plugin (see source code here) and replace:
// Exclude current viewing language
if( $l['language_code'] != ICL_LANGUAGE_CODE )
{
// ...
}
with
// Include only the current language
if( $l['language_code'] == ICL_LANGUAGE_CODE )
{
// ...
}
to show only the current language/flag, if I understand you correctly.
ps: If you need further assistance, you could for exampe show us the output of this debug function for the active language:
function debug_icl_active_language()
{
$languages = icl_get_languages( 'skip_missing=0' );
foreach( (array) $languages as $l )
{
if( $l['active'] )
{
printf( '<pre> Total languages: %d - Active: %s </pre>',
count( $languages ),
print_r( $l, TRUE ) );
}
}
}
i have some useful link for you, please go through it first:
http://wpml.org/forums/topic/hide-language-vs-display-hidden-languages-in-your-profile-not-working/
http://wpml.org/forums/topic/hide-one-language/
http://wpml.org/forums/topic/hiding-active-language-in-menu/
http://wpml.org/forums/topic/language-selector-how-to-hide-one-language/
thanks
function language_selector_flags(){
$languages = icl_get_languages('skip_missing=0');
if(!empty($languages)){
$filter = array();
$filter['ar'] = array( 'he' );
// set your other filters here
$active_language = null;
foreach ($languages as $l)
if($l['active']) {
$active_language = $l['language_code'];
break;
}
$filter = $active_language && isset( $filter[$active_language] ) ? $filter[$active_language] : array();
foreach ($languages as $l) {
//Display whatever way you want -- I'm just displaying flags in anchors (CSS: a {float:left; display:block;width:18px;height:12px;margin:0 2px;overflow:hidden;line-height:100px;})
if( in_array( $l['language_code'], $filter) )
continue;
if($l['active']) { $class = "active"; $url=""; } else { $class = ''; $url = 'href="'.$l['url'].'"'; }
echo '<a '.$url.' class="flag '.$class.'"><img src="', $l['country_flag_url'], '" alt="', esc_attr( $l['language_code'] ), '" /></a>';
}
}
}
EDIT: If I get this right, your client(I assume) doesn't want his customers (Israelis especiay) to know that he offer service also to the arabic speaking cusomers. If it so then you can parse the Accept-Language header and filter the language selector according the result.
I have a similar problem/issue:
On this website: https://neu.member-diving.com/
I have languages I not need in the switcher. I tried the code above, but it nothing changed so far.
So, what I would like to do is, When a client is on the one "german" page, the other german languages in the switcher should not need to be there, only the english one and the actual german one.
Where do I need to put code like
function language_selector_flags(){
$languages = icl_get_languages('skip_missing=0');
if(!empty($languages)){
$filter = array();
$filter['ar'] = array( 'he' );
// set your other filters here
$active_language = null;
foreach ($languages as $l)
if($l['active']) {
$active_language = $l['language_code'];
break;
}
$filter = $active_language && isset( $filter[$active_language] ) ? $filter[$active_language] : array();
foreach ($languages as $l) {
//Display whatever way you want -- I'm just displaying flags in anchors (CSS: a {float:left; display:block;width:18px;height:12px;margin:0 2px;overflow:hidden;line-height:100px;})
if( in_array( $l['language_code'], $filter) )
continue;
if($l['active']) { $class = "active"; $url=""; } else { $class = ''; $url = 'href="'.$l['url'].'"'; }
echo '<a '.$url.' class="flag '.$class.'"><img src="', $l['country_flag_url'], '" alt="', esc_attr( $l['language_code'] ), '" /></a>';
}
}
}

Categories