'; } /** * Adds the meta box containers */ function add_advsp_pub_box() { remove_meta_box('linkxfndiv', 'link', 'normal'); if ( function_exists('add_meta_box') ) { add_meta_box('add_advsp_pub_box', __( 'Advanced Sticky Posts'), array( &$this, 'render_advsp_box_content' ), 'post', 'normal', 'low'); add_meta_box('linkxfndiv', __('Link Relationship (XFN)'), array( &$this, 'render_advsp_link_box' ), 'link', 'normal', 'high'); } } /** * Helper Function */ function array_remove_keys($array, $keys = array()) { if(empty($array) || (! is_array($array))) { return $array; } if(is_string($keys)) { $keys = explode(',', $keys); } if(! is_array($keys)) { return $array; } $assocKeys = array(); foreach($keys as $key) { $assocKeys[$key] = true; } return array_diff_key($array, $assocKeys); } /** * Flter the Loop */ function alt_loop($content) { global $wpdb; $stickies = get_option('sticky_posts'); $count = $content->post_count; $posts = $content->posts; $new_posts = $posts; foreach($posts as $post) { if(in_array($post->ID, $stickies)) { // get $indx = array_keys($posts, $post->ID); // the stick post $sticky = array_splice($new_posts, $indx, 1); // insert position $pos = get_post_meta($post->ID, '_advsp_post_pos', true); // remove sticky post $new_posts = $this->array_remove_keys($new_posts, $indx); // add it back in array_splice($new_posts, $pos, 0, $sticky); } } $content->posts = $new_posts; return $content; } /** * Render Meta Box content */ function render_advsp_box_content() { global $post; $post_id = $post; if (is_object($post_id)) $post_id = $post_id->ID; $content = get_post_meta($post_id, '_advsp_content', true); $class = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_advsp_class', true))); $pos = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_advsp_pos', true))); // post position //$post_count = wp_count_posts('post')->publish; $tmp = wp_count_posts('post'); $post_count = $tmp->publish; $post_pos = get_post_meta($post_id, '_advsp_post_pos', true); $post_pos = (int)$post_pos; // show only on homepage $hp = get_post_meta($post_id, '_advsp_hp', true); $checked = !empty($hp) ? 'checked="checked"' : ''; // get sticky $sticky = get_post_meta($post_id, '_advsp_sticky', true); $stuck = ''; if(is_sticky()) { $stuck = 'checked="checked"'; } ?>

style="display: none;" >


' . $phrase; $html .= '

'; if( $pos == "1") { $ret = $html.$content; } else { $ret = $content.$html; } //print_r(get_option('sticky_posts')); if(!empty($hp) && !is_single()) { return $ret; }else { return $content; } } /** * Display xfn form fields. */ function render_advsp_link_box($link) { ?>

XFN.'); ?>