Title: [291185] trunk/Websites/webkit.org
Revision
291185
Author
j...@apple.com
Date
2022-03-11 13:25:32 -0800 (Fri, 11 Mar 2022)

Log Message

Allow table of contents on posts in special cases
https://bugs.webkit.org/show_bug.cgi?id=237744

Reviewed by Devin Rousso.

* wp-content/plugins/table-of-contents.php:
* wp-content/themes/webkit/functions.php:
* wp-content/themes/webkit/single.php:

Modified Paths

Diff

Modified: trunk/Websites/webkit.org/ChangeLog (291184 => 291185)


--- trunk/Websites/webkit.org/ChangeLog	2022-03-11 21:08:46 UTC (rev 291184)
+++ trunk/Websites/webkit.org/ChangeLog	2022-03-11 21:25:32 UTC (rev 291185)
@@ -1,3 +1,14 @@
+2022-03-11  Jon Davis  <j...@apple.com>
+
+        Allow table of contents on posts in special cases
+        https://bugs.webkit.org/show_bug.cgi?id=237744
+
+        Reviewed by Devin Rousso.
+
+        * wp-content/plugins/table-of-contents.php:
+        * wp-content/themes/webkit/functions.php:
+        * wp-content/themes/webkit/single.php:
+
 2022-03-03  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         [Style] Forbid spaces between type names and protocol names in Objective-C

Modified: trunk/Websites/webkit.org/wp-content/plugins/table-of-contents.php (291184 => 291185)


--- trunk/Websites/webkit.org/wp-content/plugins/table-of-contents.php	2022-03-11 21:08:46 UTC (rev 291184)
+++ trunk/Websites/webkit.org/wp-content/plugins/table-of-contents.php	2022-03-11 21:25:32 UTC (rev 291185)
@@ -20,7 +20,18 @@
         add_filter( 'wp_insert_post_data', array( 'WebKitTableOfContents', 'wp_insert_post_data' ), 20, 2 );
         add_action( 'wp_insert_post', array( 'WebKitTableOfContents', 'wp_insert_post' ) );
     }
+    
+    public static function tocEnabled ($post_type) {
+        $build_toc = get_post_meta(get_the_ID(), 'build-table-of-contents', true);
+        if ($build_toc === 'enabled')
+            return true;
 
+        if (in_array($post_type, self::$supported_post_types))
+            return true;
+
+        return false;
+    }
+
     public static function hasIndex() {
         $toc = get_post_meta( get_the_ID(), 'toc', true );
         array_walk($toc, array('WebKitTableOfContents', 'filterIndex'));
@@ -33,10 +44,10 @@
     }
 
     public static function renderMarkup() {
-        if (!in_array(get_post_type(), self::$supported_post_types))
+        if (!self::tocEnabled(get_post_type()))
             return;
 
-        if ( empty(self::$toc) || ! self::hasIndex() )
+        if ( ! self::hasIndex() || empty(self::$toc) )
             return;
 
         $depth = 0;
@@ -74,7 +85,7 @@
     }
 
     public function wp_insert_post_data( $post_data, $record ) {
-        if (!in_array($post_data['post_type'], self::$supported_post_types))
+        if (!self::tocEnabled($post_data['post_type']))
             return $post_data;
 
         $post_data['post_content'] = self::parse($post_data['post_content']);

Modified: trunk/Websites/webkit.org/wp-content/themes/webkit/single.php (291184 => 291185)


--- trunk/Websites/webkit.org/wp-content/themes/webkit/single.php	2022-03-11 21:08:46 UTC (rev 291184)
+++ trunk/Websites/webkit.org/wp-content/themes/webkit/single.php	2022-03-11 21:25:32 UTC (rev 291185)
@@ -13,6 +13,8 @@
             </div>
 
             <div class="bodycopy">
+                <?php table_of_contents(); ?>
+                
                 <?php the_content('<p class="serif">Read the rest of this entry &gt;&gt;</p>'); ?>
 
                 <?php link_pages('<p><strong>Pages:</strong> ', '</p>', 'number'); ?>
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to