setLabel( 'Sitemap Generator' ); $this->addHook( APEX_TOOLBOX_HOOK_FILTER, 'init', 'sitemapSetup', Array( 'label' => 'Enable Sitemap Generator', 'description' => 'Creates a shortcode to be used for generating HTML sitemap pages' ) ); } /** * Setup the site map settings or register the shortcode if needed * * @param array $args Any arguments passed to the callback * * @author Nigel Wells * @version 0.3.8.16.12.21 * @return void; */ public function sitemapSetup( $args = Array() ) { // Create hooks depending on where we are at if ( is_admin() ) { add_action( 'admin_menu', Array( $this, 'sitemapSetupAdmin' ) ); } else { // Register shortcode if ( $this->Toolbox->isHookEnabled( 'sitemap', 'sitemapSetup' ) ) { add_shortcode( $this->Toolbox->getShortCode( 'sitemap' ), Array( $this, 'sitemapShortcode' ) ); } } } /** * Setup the site map settings * * @param array $args Any arguments passed to the callback * * @author Nigel Wells * @return void; */ public function sitemapSetupAdmin( $args = Array() ) { $this->Toolbox->addPage( 'Sitemap Generator', Array( $this, 'sitemapSetupOutput' ) ); // Register the submission callback add_action( 'admin_action_sitemapSetup', Array( $this, 'sitemapSetupSubmission' ) ); // Create settings $this->Toolbox->addSetting( Array( 'name' => 'sitemap_exclude_ids', 'label' => 'Exclude IDs', 'type' => 'string', 'value' => $this->Toolbox->getOption( 'sitemap_exclude_ids' ), 'description' => 'Comma seperated list of IDs to exclude from the sitemap' ), $this->getLabel() ); $this->Toolbox->addSetting( Array( 'name' => 'sitemap_post_types', 'label' => 'Post Types', 'type' => 'checkbox', 'range' => get_post_types(), 'value' => $this->Toolbox->getOption( 'sitemap_post_types' ), 'description' => 'Select which post types to include' ), $this->getLabel() ); $this->Toolbox->addSetting( Array( 'name' => 'sitemap_taxonomy', 'label' => 'Taxonomies', 'type' => 'checkbox', 'range' => get_taxonomies(), 'value' => $this->Toolbox->getOption( 'sitemap_taxonomy' ), 'description' => 'Select which taxonomies to include' ), $this->getLabel() ); } /** * Outputs the settings page HTML * * @author Nigel Wells * @return void; */ function sitemapSetupOutput() { echo '
Creates a shortcode that can be added to any page to generate a sitemap based on the hierarchy of post types and taxonomies setup on the website. The sitemap page itself will always be excluded from the list of pages.
Add the shortcode [' . $this->Toolbox->getShortCode( 'sitemap' ) . '] to any page you want the sitemap displayed on.