function otw_sbm_index($index, $sidebars_widgets) { global $wp_registered_sidebars, $otw_replaced_sidebars; if (isset($otw_replaced_sidebars[$index])) { //we have set replacemend. $requested_objects = otw_get_current_object(); //check if the new sidebar is valid for the current requested resource foreach ($otw_replaced_sidebars[$index] as $repl_sidebar) { if (isset($wp_registered_sidebars[$repl_sidebar])) { if ($wp_registered_sidebars[$repl_sidebar]['status'] == 'active') { if (otw_filter_strict_sidebar_index($repl_sidebar)) { foreach ($requested_objects as $objects) { list($object, $object_id) = $objects; if ($object && $object_id) { $tmp_index = otw_validate_sidebar_index($repl_sidebar, $object, $object_id); if ($tmp_index) { if (!empty($sidebars_widgets[$tmp_index])) { $sidebars_widgets[$tmp_index] = otw_filter_siderbar_widgets($tmp_index, $sidebars_widgets); if (count($sidebars_widgets[$tmp_index])) { $index = $tmp_index; break 2; } } } } //end hs object and object id } //end loop requested objects } } } } } return $index; }
function otw_sbm_index($index, $sidebars_widgets) { global $wp_registered_sidebars, $otw_replaced_sidebars; if (isset($otw_replaced_sidebars[$index])) { //we have set replacemend. $requested_objects = otw_get_current_object(); //check if the new sidebar is valid for the current requested resource foreach ($otw_replaced_sidebars[$index] as $repl_sidebar) { if (isset($wp_registered_sidebars[$repl_sidebar])) { if ($wp_registered_sidebars[$repl_sidebar]['status'] == 'active') { if (otw_filter_strict_sidebar_index($repl_sidebar)) { foreach ($requested_objects as $objects) { list($object, $object_id, $object_type) = $objects; if ($object && $object_id && $object_type) { otw_sbm_log($repl_sidebar, "\n\n\n", 2); if (is_array($object_id)) { otw_sbm_log($repl_sidebar, '|1|->: validate sitebar index [' . $repl_sidebar . ',' . $object . ',' . implode(',', $object_id) . ',' . $object_type . ']...', 1, __FILE__, __LINE__); } else { otw_sbm_log($repl_sidebar, '|1|->: validate sitebar index [' . $repl_sidebar . ',' . $object . ',' . $object_id . ',' . $object_type . ']...', 1, __FILE__, __LINE__); } $tmp_index = otw_validate_sidebar_index($repl_sidebar, $object, $object_id); if (!$tmp_index) { otw_sbm_log($repl_sidebar, ' <-|1| not_found'); } else { otw_sbm_log($repl_sidebar, ' <-|1| ' . $tmp_index, ''); } if ($tmp_index) { if (!empty($sidebars_widgets[$tmp_index])) { $sidebars_widgets[$tmp_index] = otw_filter_siderbar_widgets($tmp_index, $sidebars_widgets); if (count($sidebars_widgets[$tmp_index])) { $index = $tmp_index; break 2; } } } } //end hs object and object id } //end loop requested objects } } } } } return $index; }