'; } /** * Adds the meta box containers */ function add_advsp_pub_box() { remove_meta_box('linkxfndiv', 'link', 'normal'); if ( function_exists('add_meta_box') ) { $post_types = get_post_types('','names'); foreach ($post_types as $post_type ) { if($post_type != "page") { add_meta_box('add_advsp_pub_box', __( 'Advanced Sticky Posts'), array( &$this, 'render_advsp_box_content' ), $post_type, 'normal', 'low'); /* post_type stickiness coming soon! */ //add_meta_box('submitdiv', __( 'Publish'), array( &$this, 'render_advsp_publish_box' ), $post_type, 'side', 'high'); } } // Link settings 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); } /** * Filter the Loop */ function alt_loop($content) { global $wpdb; $stickies = get_option('sticky_posts'); // print_r($stickies); $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); //print_r($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; //Get post_type $post_type = $post->post_type; $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))); //Get posts published posts of this post_type $tmp = wp_count_posts($post_type); $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"'; } ?>
|
|
|||||||||||||||||
XFN.'); ?>
post_type; $post_type_object = get_post_type_object($post_type); $can_publish = current_user_can($post_type_object->cap->publish_posts); ?>
post_status, array('publish', 'future', 'private') ) || 0 == $post->ID ) {
if ( $can_publish ) :
if ( !empty($post->post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?>
'5', 'accesskey' => 'p' ) ); ?>
'5', 'accesskey' => 'p' ) ); ?>
'5', 'accesskey' => 'p' ) ); ?>