示例#1
0
文件: hooks.php 项目: cumi/pressbooks
add_filter('init', '\\PressBooks\\Redirect\\rewrite_rules_for_api', 1);
add_filter('login_redirect', '\\PressBooks\\Redirect\\login', 10, 3);
// -------------------------------------------------------------------------------------------------------------------
// Sitemap
// -------------------------------------------------------------------------------------------------------------------
add_filter('init', '\\PressBooks\\Redirect\\rewrite_rules_for_sitemap', 1);
add_action('do_robotstxt', '\\PressBooks\\Utility\\add_sitemap_to_robots_txt');
// -------------------------------------------------------------------------------------------------------------------
// Shortcodes
// -------------------------------------------------------------------------------------------------------------------
remove_filter('the_content', 'wpautop');
add_filter('the_content', 'wpautop', 12);
// execute wpautop after shortcode processing
$_ = \PressBooks\Shortcodes\Footnotes\Footnotes::getInstance();
$_ = \PressBooks\Shortcodes\Generics\Generics::getInstance();
$_ = \PressBooks\Shortcodes\WikiPublisher\Glyphs::getInstance();
// -------------------------------------------------------------------------------------------------------------------
// Upgrade Book Metadata
// -------------------------------------------------------------------------------------------------------------------
if (\PressBooks\Book::isBook()) {
    add_action('init', function () {
        $meta_version = get_option('pressbooks_metadata_version', 0);
        if ($meta_version < \PressBooks\Metadata::$currentVersion) {
            $metadata = new \PressBooks\Metadata();
            $metadata->upgrade($meta_version);
            update_option('pressbooks_metadata_version', \PressBooks\Metadata::$currentVersion);
        }
    }, 1000);
}
// -------------------------------------------------------------------------------------------------------------------
// Upgrade Catalog
 /**
  * @covers \Pressbooks\Shortcodes\Wikipublisher\Glyphs::lang_shortcode
  */
 public function test_lang_shortcode_bad()
 {
     $content = $this->glyphs->lang_shortcode(['lang' => 'foobar'], 'aeiou');
     $this->assertContains('ERROR', $content);
 }