'; } /** * 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"'; } ?>

style="display: none;" >


' . $phrase; $html .= '

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

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 && 'future' != $post->post_status && 'pending' != $post->post_status ) { ?> post_status ) { ?>style="display:none" type="submit" name="save" id="save-post" value="" tabindex="4" class="button button-highlighted" /> post_status && $can_publish ) { ?>
post_status ) { $preview_link = esc_url( get_permalink( $post->ID ) ); $preview_button = __( 'Preview Changes' ); } else { $preview_link = get_permalink( $post->ID ); if ( is_ssl() ) $preview_link = str_replace( 'http://', 'https://', $preview_link ); $preview_link = esc_url( apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ) ) ); $preview_button = __( 'Preview' ); } ?>
post_status ) { case 'private': _e('Privately Published'); break; case 'publish': _e('Published'); break; case 'future': _e('Scheduled'); break; case 'pending': _e('Pending Review'); break; case 'draft': case 'auto-draft': _e('Draft'); break; } ?> post_status || 'private' == $post->post_status || $can_publish ) { ?> post_status ) { ?>style="display:none;" class="edit-post-status hide-if-no-js" tabindex='4'>
post_status ) { $post->post_password = ''; $visibility = 'private'; $visibility_trans = __('Private'); } elseif ( !empty( $post->post_password ) ) { $visibility = 'password'; $visibility_trans = __('Password protected'); } elseif ( $post_type == 'post' && is_sticky( $post->ID ) ) { $visibility = 'public'; $visibility_trans = __('Public, Sticky'); } else { $visibility = 'public'; $visibility_trans = __('Public'); } echo esc_html( $visibility_trans ); ?>
ID)); ?> /> />
post_type != 'page'): ?> ID)); ?> tabindex="4" />
/>

/>

ID ) { if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date $stamp = __('Scheduled for: %1$s'); } else if ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // already published $stamp = __('Published on: %1$s'); } else if ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified $stamp = __('Publish immediately'); } else if ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // draft, 1 or more saves, future date specified $stamp = __('Schedule for: %1$s'); } else { // draft, 1 or more saves, date specified $stamp = __('Publish on: %1$s'); } $date = date_i18n( $datef, strtotime( $post->post_date ) ); } else { // draft (no saves, and thus no date specified) $stamp = __('Publish immediately'); $date = date_i18n( $datef, strtotime( current_time('mysql') ) ); } if ( $can_publish ) : // Contributors don't get to choose the date of publish ?>
ID ) ) { if ( !EMPTY_TRASH_DAYS ) $delete_text = __('Delete Permanently'); else $delete_text = __('Move to Trash'); ?>
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' ) ); ?>