Skip to content

Instantly share code, notes, and snippets.

@derpixler
Created May 26, 2011 12:28
Show Gist options
  • Save derpixler/993032 to your computer and use it in GitHub Desktop.
Save derpixler/993032 to your computer and use it in GitHub Desktop.
Wordpress: hook in the tag-list table
add_filter( 'manage_category_custom_column','myTestC');
function myTestC($content){
return $content;
}
@bueltge
Copy link

bueltge commented May 26, 2011

    /**
     * hook inside the rows of wp
     *
     */
    public function add_id_row() {

        // on screen: edit-snippets
        add_action( 'manage_edit-' . $this->post_type_1 . '_columns', array( &$this, 'add_columns' ) );
        add_filter( 'manage_posts_custom_column', array( &$this, 'return_custom_columns' ), 10, 3 );
    }

    /**
     * Return content of new raw in the table
     * 
     * @param $column_name
     * @param $id
     * @return integer $id
     */
    public function return_custom_columns($column_name, $id) {

        $id = (int) $id;

        switch( $column_name ) {
            case $this->taxonomy_type_1:
                $structure = '';
                $taxonomys = get_the_term_list($id, $this->taxonomy_type_1, '', ', ', '' );
                if ( isset($taxonomys[0]) )
                    $structure = $taxonomys;
                else
                    $structure = __( 'No Structure', $this->textdomain );
                $value = $structure;
                break;
            case 'id':
                $value = $id;
                break;
        }

        if ( isset($value) )
            echo $value;
    }

@bueltge
Copy link

bueltge commented May 26, 2011

@bueltge
Copy link

bueltge commented May 26, 2011

add_filter( 'manage_category_custom_column', 'myTestC', 10, 2 );

function myTestC( $column, $id ) {
if ( 'my_content' === $column )
echo 'my_value';
}

@derpixler
Copy link
Author

add_filter( "manage_category_custom_column", array( &$this, 'myTestC' ), 10, 2 );

function myTestC($column_name, $id){
var_dump($column_name, $id);
#return $content;
}

@bueltge
Copy link

bueltge commented May 26, 2011

Als Erläuterung, aus dem Core:
apply_filters( "manage_{$screen->taxonomy}_custom_column", '', $column_name, $tag->term_id );
Das ist dein Hook, category ist ja nur eine der Taxonomien, und dann kommen die beiden Werte, name der Spalte und Id

@bueltge
Copy link

bueltge commented May 26, 2011

add_filter( "manage_category_custom_column", 'myTestC', 10, 2 );

function myTestC($column_name, $id){
var_dump($column_name, $id);

return $content;

}

@derpixler
Copy link
Author

add_action( 'manage_edit-category_columns', 'myTest');
function myTest($content){
$content['test'] = 'hallo';
return $content;
}

@derpixler
Copy link
Author

add_filter( "manage_category_custom_column", 'myTestC', 10, 3 );

function myTestC($column_name, $id, $der){
var_dump($column_name, $id, $der);

return $content;

}

@derpixler
Copy link
Author

//create a new row
add_action( 'manage_edit-category_columns', 'myTest');
function myTest($content){
$content['test'] = 'hallo';
return $content;
}

//fill the row with content
add_filter( "manage_category_custom_column", 'myTestC', 10, 3 );
function myTestC($column_name, $columid, $termId){
var_dump($column_name, $id, $termId);
}

@bueltge
Copy link

bueltge commented May 26, 2011

this works, with WP Codex ;)
//create a new row
add_action( 'manage_edit-category_columns', 'my_test' );
function my_test( $column ) {
$column['test'] = 'hallo';
return $column;
}

//fill the row with content
add_filter( 'manage_category_custom_column', 'my_test_c', 10, 3 );
function my_test_c( $foo, $column_name, $term_id ) {
var_dump( $column_name, $term_id );
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment