function widget($args, $instance) { global $post; $c = new ThemerexBanner(); if (!isset($args['widget_id'])) { $args['widget_id'] = $this->id; } extract($args, EXTR_SKIP); $ids = !empty($instance['ids']) ? $instance['ids'] : ''; $group = !empty($instance['group']) ? $instance['group'] : ''; $author = !empty($instance['author']) ? $instance['author'] : ''; $count = !empty($instance['count']) ? $instance['count'] : ''; $title = apply_filters('widget_title', isset($instance['title']) ? $instance['title'] : ''); $output = ''; $output .= $before_widget; if ($title) { $output .= $before_title . $title . $after_title; } $output .= $c->trex_banner_request($ids, $group, $author, $count); $output .= $after_widget; echo $output; }
function save_meta_box_banner($post_id) { $c = new ThemerexBanner(); $meta_box_banner = themerex_get_meta_box(); // verify nonce if (!isset($_POST['meta_box_post_nonce']) || !wp_verify_nonce($_POST['meta_box_post_nonce'], basename(__FILE__))) { return $post_id; } // check autosave if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return $post_id; } // check permissions if ('page' == $_POST['post_type']) { if (!current_user_can('edit_page', $post_id)) { return $post_id; } } else { if (!current_user_can('edit_post', $post_id)) { return $post_id; } } foreach ($meta_box_banner['fields'] as $key => $field) { $new = isset($_POST[$field['id']]) ? $_POST[$field['id']] : ''; if ($field['type'] == 'date') { if ($field['id'] == 'display_from') { if (empty($new)) { $new = '01/01/1900'; } } else { if ($field['id'] == 'display_till') { if (empty($new)) { $new = '01/01/2900'; } } } $new = $c->DateToSQL($new); } else { if ($field['type'] == 'text') { if ($field['id'] == 'banner_show') { $new = empty($new) ? 100000 : $new; } } } update_post_meta($post_id, $field['id'], $new); } }