function theme_is_displayed_widget($widget) { $id = $widget['name']; $show_on = theme_get_widget_meta_option($id, 'theme_widget_show_on'); $page_ids = explode(',', theme_get_widget_meta_option($id, 'theme_widget_page_ids_list')); $page_ids = array_map('trim', $page_ids); $page_ids = array_filter($page_ids, 'is_numeric'); $page_ids = array_map('intval', $page_ids); if ('all' != $show_on) { $selected = theme_get_widget_meta_option($id, 'theme_widget_front_page') && is_front_page() || theme_get_widget_meta_option($id, 'theme_widget_single_post') && is_single() || theme_get_widget_meta_option($id, 'theme_widget_single_page') && is_page() || theme_get_widget_meta_option($id, 'theme_widget_posts_page') && is_home() || theme_get_widget_meta_option($id, 'theme_widget_page_ids') && !empty($page_ids) && is_page($page_ids); if (!$selected && 'selected' == $show_on || $selected && 'none_selected' == $show_on) { return false; } } return true; }
function theme_get_widget_style($id, $style = null) { $result = theme_get_widget_meta_option($id, 'theme_widget_styles'); global $theme_widgets_style; if (!in_array($result, array_keys($theme_widgets_style))) { $result = 'default'; } if ($style != null) { if (!in_array($style, array('block', 'post', 'simple'))) { $style = 'block'; } if ($result == 'default') { $result = $style; } } return $result; }
function theme_print_meta_box($post_id, $meta_options) { // Use nonce for verification wp_nonce_field('theme_meta_options', 'theme_meta_noncename'); if (!isset($post_id)) { return; } foreach ($meta_options as $option) { $id = theme_get_array_value($option, 'id'); $name = theme_get_array_value($option, 'name'); $desc = theme_get_array_value($option, 'desc'); if (strpos($post_id, '-') === false) { $value = theme_get_meta_option($post_id, $id); } else { $value = theme_get_widget_meta_option($post_id, $id); } $necessary = theme_get_array_value($option, 'necessary'); if ($necessary && !current_user_can($necessary)) { continue; } echo '<p class="meta-options' . ($name ? ' named' : '') . '"><label class="selectit" for="' . $id . '"><strong>' . $name . '</strong></label><br />'; theme_print_option_control($option, $value); if ($desc) { echo '<em>' . $desc . '</em>'; } echo '</p>'; } }
function theme_print_widget($widget) { if (!is_array($widget)) { return false; } $widget_name = theme_get_array_value($widget, 'name', ''); if ($widget_name) { echo theme_get_widget_meta_option($widget_name, 'theme_widget_styling'); theme_wrapper(theme_get_array_value($widget, 'style', 'block'), $widget); } else { echo $widget['content']; } return true; }