Plugin Directory

Changeset 1232305


Ignore:
Timestamp:
08/27/2015 04:12:43 PM (11 years ago)
Author:
Webblerock
Message:

create custom post type to store glossary definitions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • simple-wp-glossary/trunk/simple-wp-glossary.php

    r1232303 r1232305  
    1111add_filter( 'the_content', 'wr_swpg_add_definitions' );
    1212add_action( 'wp_enqueue_scripts', 'wr_swpg_enqueue_js' );
     13add_action( 'init', 'wr_swpg_cpt' );
    1314
    1415function wr_swpg_add_definitions( $content ) {
     
    2122            $replacements[] = "<dfn title=\"{$definition}\">$1</dfn>";
    2223        }
    23         return preg_replace( $regex, $replacements, $content, 1 ); 
     24        return preg_replace( $regex, $replacements, $content, 1 );
    2425    } else {
    2526        return $content;
     
    2829
    2930function wr_swpg_get_glossary_items() {
    30     $args = array( 
     31    $args = array(
    3132                    'post_type' => 'glossary',
    3233                    'post_status' => 'publish',
     
    5051    wp_enqueue_style( 'wr-swpg', $src, false, null );
    5152}
     53
     54function wr_swpg_cpt() {
     55    $labels = array(
     56        'name' => 'Glossary items',
     57        'singular_name' => 'Glossary item',
     58        );
     59
     60    $args = array(
     61                'labels' => $labels,
     62                'description' => 'Defining terms',
     63                'public' => true,
     64                'show_ui' => true,
     65                'has_archive' => false,
     66                'show_in_menu' => true,
     67                'exclude_from_search' => false,
     68                'capability_type' => 'post',
     69                'map_meta_cap' => true,
     70                'hierarchical' => false,
     71                'rewrite' => array( 'slug' => 'glossary', 'with_front' => true ),
     72                'query_var' => true,
     73                'supports' => array( 'title', 'excerpt' ),
     74            );
     75
     76    register_post_type( 'glossary', $args );
     77}
Note: See TracChangeset for help on using the changeset viewer.