Personal tools
You are here: Home Leocornus leocornus.tracclient Admin page to manage default templates

Admin page to manage default templates

wp-trac-client plugin offers the following wordpress page templates:

  • trac hompage
  • ticket page
  • my tickets

The Solution

We will use the following solutions:

  • using site option to save the page id for each template.
  • create empty pages during activation. using wp_insert_post
  • set initial values for each site option after page created.
  • page template page on dashboard to allow user to select different pages for each page templage. Using wp_dropdown_pages to list all available pages.
  • using WordPress filter template_include to apply the page template.
  • using is_main_site to make sure this is a page from main root site.
  • using WordPress function is_page to pick the right page.

List of site options to save the page id for each page template:

  • wptc_page_trac
  • wptc_page_trac_ticket
  • wptc_page_trac_mytickets

The default page slugs

  • trac
  • ticket
  • mytickets

post data for pages, place holder pages

$post_data = array(
    'post_status' => 'publish',
    'post_parent' => '',
    'post_type' => 'page',
    'ping_status' => get_option('default_ping_status'),
    'post_content' => ' ',
    'post_excerpt' => '',
    'post_title' => __('trac', 'wptc')
);
$id = wp_insert_post($post_data, false);

if you call the function wp_insert_post from network dashboard, the page will be created under root blog.

Handle form submition

  • as simple form with 3 dropdown selection element and a submit button
  • save the post data to site option.
  • show up confirmation message.

Tracking History

When Who What Done
2013-08-27 09:12 Sean Chen the page template pages is ready now. c32390d 7cccebd 420e48c 0e2a52d a62c2cd f6644ee
-- 4.0 Hours, 100.0% Done
Document Actions