Current Wordpress project is supported by the infamous Mystique template (http://digitalnature.eu/themes/mystique/) and the premium WPML (multilingual) plugin.
The WPML and the template aren’t playing nice together. For those who don’t know: WPML generates ghost pages and posts without actually cluttering your pages with translations. It’s a wonderful tool for running a mulitlingual WP. Each translated post and page gets an individual page_id and as an URL it is ‘put’ in a ghost folder such as /en/ for English, etc.
In Mystique, each widget can be made visible on specific pages which is wonderful. Less wonderful is that it only shows English pages and not the translated pages as options, so I can’t show translated widgets in pages of their own language. The same problem persists with the slider, which is not a widget, but a theme option.
http://www.grayscale.com.hk/images/wpml.png
This list appears underneath each widget area in Wordpress, but I can’t find it back in any of the widget php files.
I’ve been digging through all the PHP files, which for an extensive theme weren’t many. There is this list of files:
http://www.grayscale.com.hk/images/phphelp01.png
I’ve looked through all remotely related files, but none of them refer to the field I’m looking for.
Digging through functions.php gave noreferences to widget visibility. The entire functions.php is here: http://www.grayscale.com.hk/images/functions.txt
One very beefy file, Atom.php, contains references to widget visibility but nothing more than that, and certainly leaving me no ideas where to configure my widgets to also list translated pages.
I’ve copypasted some relevant codes (I think) from Atom.php here:
[php]
/**
- Get the status of a widgetized area (replaces wp’s is_active_sidebar)
- This function also verifies if the widgets inside the sidebar are visible to the current user or not (splitters are ignored)
- Note: If we’re in preview mode areas are always considered to be active, but the returned widget count may be 0 (boolean false).
- (we use type equivalence checking to avoid confusions)
- @since 1.0
- @global $wp_registered_widgets Stored registered widgets.
- @global $post Current post object
- @param string $index Area (sidebar) ID
-
@return int|bool false or the visible widget count, based on widget visibility settings and current user status
*/
public function isAreaActive($index){
global $wp_registered_widgets, $post;
// always return true if the layout options are not enabled. obviously, the css designer wants to handle this
if(!$this->isOptionEnabled('layout')) return true;
// -- same as getLayoutType() --
if(is_404()){
$layout = 'c1'; // 404 pages have 1 column layout
}else{
// the "layout" custom field - highest priority
if(isset($post->ID)) $layout = get_post_meta($post->ID, 'layout', true);
// custom page templates - lower priority
if(empty($layout) && (is_single() || is_page()) && ($page_template = sanitize_html_class(str_replace(array('page-', '.php'), '', get_post_meta($post->ID, '_wp_page_template', true)))))
if(in_array($page_template, $this->layout_types)) $layout = $page_template;
// if no template is defined so far, revert to the global layout option from the theme settings - lowest priority
if(empty($layout)) $layout = $this->options('layout');
}
// -- /same as getLayoutType() --
$index = (is_int($index)) ? "sidebar{$index}" : sanitize_html_class($index);
$sidebars_widgets = wp_get_sidebars_widgets();
$visible_widgets = 0;
// only check widget settings if we have widgets in this sidebar
if(!empty($sidebars_widgets[$index]))
foreach($sidebars_widgets[$index] as $i => $w)
if(isset($wp_registered_widgets[$w])){
$number = $wp_registered_widgets[$w]['params'][0]['number'];
$callback = AtomWidget::getObject($w);
if(!$callback) continue;
$options = get_option($callback->option_name);
// count only visible widgets that are not "splitters"
// @important atom_visibility_check() can also return array(), which means that the widget is there but it's settings are missing (like fallback widgets)
if((strpos($w, 'atom-splitter') === false) && atom_visibility_check($options[$number]) !== false) $visible_widgets++;
}
// always show active if we're in preview mode (eg. theme setting site preview), regardless of the contents
if(Atom::app()->previewMode()) return $visible_widgets;
// check free column(s) for sidebar(s)
if($index === 'sidebar1' && $layout === 'c1') return false;
if($index === 'sidebar2' && in_array($layout, array('c1', 'c2left', 'c2right'))) return false;
// get sidebar contents
$first_check = false;
if(!isset($this->widget_areas[$index]['output'])){
ob_start();
dynamic_sidebar($index);
$this->widget_areas[$index]['output'] = ob_get_clean();
$first_check = true;
}
[/php]
And this is the entire Atom.php : http://www.grayscale.com.hk/images/Atom.txt
And that’s pretty much it. Naturally I’ve contacted the theme builder but he’s not responsive. I’ve contacted WPML and they’ll gladly cooperate with the theme builder, who’s not responsive. I’m trapped in the middle with a finished website which I can’t make work if the widgets aren’t translated. This bit of code is really really crucial to me.
I’d much appreciate any constructive suggestion… Thanks in advance for reading!