DIGITAL_DEVIL_DATABASE Community Forum
January 06, 2009, 05:36:51 AM
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

News: If the forums are giving you trouble, try CTRL+SHIFT+R.
 
   Home   Help Search Calendar Login Register  
Pages: [1] Go Down
  Print  
Author Topic: yksehtniycul -- patron administrator (Read 519 times)
yksehtniycul
Karma King and new
Administrator
*****

offline Offline

MaleView Profile WWW
don't play with me 'cause you're playing with fire
yksehtniycul -- patron administrator
 « on: September 24, 2008, 03:50:50 AM »
Site Admin (not site owner)

I facilitate the site technically while doing my best to do little else smokin

 It's so easy to laugh
 It's so easy to hate
 It takes strength to be gentle and kind

 It takes guts to be gentle and kind

« Last Edit: September 25, 2008, 06:59:21 PM by yksehtniycul »


マィカェル アルケヂア
word to the wise -- nice people are not always good; and good people are not always nice -- think on it.

Logged
yksehtniycul has 1429 Posts (+0/-0 Karma)
yksehtniycul
Karma King and new
Administrator
*****

offline Offline

MaleView Profile WWW
don't play with me 'cause you're playing with fire
yksehtniycul says,
 « Reply #1 on: October 15, 2008, 12:16:35 AM »
administration notes:

Hacked wp-includes/classes.php

Code:
<?php 
if(get_post_meta($page->ID,'blank',true)=='yes'//don't display as link

$output .= $indent '<li class="' $css_class '" title="' $page->post_name '">' apply_filters('the_title'$page->post_title);
else 
$output .= $indent '<li class="' $css_class '"><a href="' get_page_link($page->ID) . '" title="' $page->post_name '">' apply_filters('the_title'$page->post_title) . '</a>';
?>


This allows pages to be marked as blank, so they will not generate links in the sidebar (so users time isn't wasted clicking on them)

Also changed the title attribute to be the page name, rather than repeating the page title.

edited: Btw, in order to mark a page as blank, a meta key called 'blank' must be added to the page with a value of 'yes'.

« Last Edit: October 16, 2008, 03:01:59 AM by yksehtniycul »


マィカェル アルケヂア
word to the wise -- nice people are not always good; and good people are not always nice -- think on it.

Logged
yksehtniycul has 1429 Posts (+0/-0 Karma)
yksehtniycul
Karma King and new
Administrator
*****

offline Offline

MaleView Profile WWW
don't play with me 'cause you're playing with fire
yksehtniycul says,
 « Reply #2 on: October 16, 2008, 03:01:02 AM »
administration notes:

Hacked wp-includes/widgets.php

Code:
<?php if(get_post_meta(get_the_ID(),'sticky',true)=='yes') continue; ?>

This excludes announcement/sticky posts from the "Recent News" widget in the sidebar.

In order to exclude the post a meta key called 'sticky' must be added to the post with a value of 'yes'. Just using the sticky plugin won't suffice.



マィカェル アルケヂア
word to the wise -- nice people are not always good; and good people are not always nice -- think on it.

Logged
yksehtniycul has 1429 Posts (+0/-0 Karma)
yksehtniycul
Karma King and new
Administrator
*****

offline Offline

MaleView Profile WWW
don't play with me 'cause you're playing with fire
yksehtniycul says,
 « Reply #3 on: October 16, 2008, 03:32:18 AM »
administration notes:

Hacked wp-includes/widgets.php

Code:
'depth' => 1

This manually sets a hidden argument for the page and category listing widgets (in two separate lines)

I tried to make this an option in the interface (it definitely should be) but the hack became overly elaborate for an include file, and I couldn't get controller code to reliably add/update the depth option to the database.

This btw limits the hierarchical listings to one level. For my next trick I plan on trying to add subpage counters to the page listing.



マィカェル アルケヂア
word to the wise -- nice people are not always good; and good people are not always nice -- think on it.

Logged
yksehtniycul has 1429 Posts (+0/-0 Karma)
yksehtniycul
Karma King and new
Administrator
*****

offline Offline

MaleView Profile WWW
don't play with me 'cause you're playing with fire
yksehtniycul says,
 « Reply #4 on: October 16, 2008, 04:17:23 AM »
administration notes:

Hacked wp-includes/classes.php

Code:
<?php
if($this->tree_type=='page'&&$depth+1==$max_depth)
{
global 
$wpdb;
 
$page =& $element;

if(
get_post_meta($page->ID,'unlisted',true)=='yes') return; 



call_user_func_array(array(&$this'start_el'), $cb_args);



$subpages $wpdb->get_var("
SELECT COUNT(*) FROM $wpdb->posts 
WHERE post_parent = '{$page->ID}' AND post_status = 'publish' AND post_type = 'page'&#160; &#160; &#160; 
"
);

//$subpages = $wpdb->get_var("
// SELECT COUNT(*) FROM $wpdb->posts p LEFT JOIN $wpdb->postmeta m ON p.ID = m.post_id
// WHERE m.post_id IS NULL AND p.post_parent = '{$page->ID}' AND p.post_status = 'publish' AND p.post_type = 'page'&#160; &#160; &#160; 
// ");

$subpages+=get_post_meta($page->ID,'subadjust',true); //hack

if($subpages$output .= ' (' . ($subpages) . ')';
}
else 
call_user_func_array(array(&$this'start_el'), $cb_args);
?>


This counts the number of subpages in the page listing widget and appends the number in parenthesis to each listing (if subpages exist)


« Last Edit: November 26, 2008, 08:10:57 PM by yksehtniycul »


マィカェル アルケヂア
word to the wise -- nice people are not always good; and good people are not always nice -- think on it.

Logged
yksehtniycul has 1429 Posts (+0/-0 Karma)
yksehtniycul
Karma King and new
Administrator
*****

offline Offline

MaleView Profile WWW
don't play with me 'cause you're playing with fire
yksehtniycul says,
 « Reply #5 on: October 29, 2008, 11:39:23 AM »
administration notes:

Hacked wp-includes/post.php

Code:
<?php
/**
 * get_page_children() - Retrieve child pages
 *
 * {@internal Missing Long Description}}
 *
 * @package WordPress
 * @subpackage Post
 * @since 1.5.1
 *
 * @param int $page_id page ID
 * @param array $pages list of pages
 * @return array {@internal Missing Description}}
 */
function &get_page_children($page_id$pages$depth 0) {
$page_list = array();
foreach ( $pages as $page ) {
if ( $page->post_parent == $page_id ) {
$page_list[] = $page;
if(
$depth<=0||$depth>1)
if ( $children get_page_children($page->ID$pages$depth-) )
$page_list array_merge($page_list$children);
}
}
return $page_list;
}

/**
 * get_pages() - Retrieve a list of pages
 *
 * {@internal Missing Long Description}}
 *
 * @package WordPress
 * @subpackage Post
 * @since 1.5
 * @uses $wpdb
 *
 * @param mixed $args Optional. Array or string of options
 * @return array List of pages matching defaults or $args
 */
function &get_pages($args '') {
global $wpdb;

$defaults = array(
'child_of' => 0'sort_order' => 'ASC',
'sort_column' => 'post_title''hierarchical' => 1,
'exclude' => '''include' => '',
'meta_key' => '''meta_value' => '',
'authors' => '''depth' => 0
);

$r wp_parse_args$args$defaults );
extract$rEXTR_SKIP );

$key md5serialize$r ) );
if ( $cache wp_cache_get'get_pages''posts' ) )
if ( isset( $cache$key ] ) )
return apply_filters('get_pages'$cache$key ], $r );

$inclusions '';
if ( !empty($include) ) {
$child_of 0//ignore child_of, exclude, meta_key, and meta_value params if using include
$exclude '';
$meta_key '';
$meta_value '';
$hierarchical false;
$incpages preg_split('/[\s,]+/',$include);
if ( count($incpages) ) {
foreach ( $incpages as $incpage ) {
if (empty($inclusions))
$inclusions $wpdb->prepare(' AND ( ID = %d '$incpage);
else
$inclusions .= $wpdb->prepare(' OR ID = %d '$incpage);
}
}
}
if (!empty($inclusions))
$inclusions .= ')';

$exclusions '';
if ( !empty($exclude) ) {
$expages preg_split('/[\s,]+/',$exclude);
if ( count($expages) ) {
foreach ( $expages as $expage ) {
if (empty($exclusions))
$exclusions $wpdb->prepare(' AND ( ID <> %d '$expage);
else
$exclusions .= $wpdb->prepare(' AND ID <> %d '$expage);
}
}
}
if (!empty($exclusions))
$exclusions .= ')';

$author_query '';
if (!empty($authors)) {
$post_authors preg_split('/[\s,]+/',$authors);

if ( count($post_authors) ) {
foreach ( $post_authors as $post_author ) {
//Do we have an author id or an author login?
if ( == intval($post_author) ) {
$post_author get_userdatabylogin($post_author);
if ( empty($post_author) )
continue;
if ( empty($post_author->ID) )
continue;
$post_author $post_author->ID;
}

if ( '' == $author_query )
$author_query $wpdb->prepare(' post_author = %d '$post_author);
else
$author_query .= $wpdb->prepare(' OR post_author = %d '$post_author);
}
if ( '' != $author_query )
$author_query " AND ($author_query)";
}
}

$join '';
$where "$exclusions $inclusions ";
if ( ! empty( $meta_key ) || ! empty( $meta_value ) ) {
$join " LEFT JOIN $wpdb->postmeta ON ( $wpdb->posts.ID = $wpdb->postmeta.post_id )";

// meta_key and met_value might be slashed 
$meta_key stripslashes($meta_key);
$meta_value stripslashes($meta_value);
if ( ! empty( $meta_key ) )
$where .= $wpdb->prepare(" AND $wpdb->postmeta.meta_key = %s"$meta_key);
if ( ! empty( $meta_value ) )
$where .= $wpdb->prepare(" AND $wpdb->postmeta.meta_value = %s"$meta_value);

}
$query "SELECT * FROM $wpdb->posts $join WHERE (post_type = 'page' AND post_status = 'publish') $where ";
$query .= $author_query;
$query .= " ORDER BY " $sort_column " " $sort_order ;

$pages $wpdb->get_results($query);

if ( empty($pages) )
return apply_filters('get_pages', array(), $r);

// Update cache.
update_page_cache($pages);

if ( $child_of || $hierarchical )
$pages = & get_page_children($child_of$pages$depth);

$cache$key ] = $pages;
wp_cache_set'get_pages'$cache'posts' );

$pages apply_filters('get_pages'$pages$r);

return $pages;
}
?>


This adds depth limiting to get_pages().

Note, Wordpress does not assign an ID to the top-level page, therefore it is not possible to request only the top-level pages. It just happens passing the argument hierarchical=1 (a boolean flag) has the side effect of procuring the top-level pages while the child_of argument is 0 (which normally disables parent based pruning -- and conveniently the parent ID you'll end up with for top-level pages)

It's worth noting there is no reason to presume this behavior will not change in future version of Wordpress. For now however hierarchical is equivalent to passing a non-zero child_of, so it is safe to combine the two this way.

This hack is used to generate an array of sibling pages from which the "prev" and "next" page flippers atop each page can be practically retrieved.

« Last Edit: November 30, 2008, 08:26:30 PM by yksehtniycul »


マィカェル アルケヂア
word to the wise -- nice people are not always good; and good people are not always nice -- think on it.

Logged
yksehtniycul has 1429 Posts (+0/-0 Karma)
Pages: [1] Go Up
  Print  
 
Jump to:

Powered by MySQL Powered by PHP Powered by SMF 1.1.5 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.242 seconds with 23 queries.