Easy Table of Contents - Version 2.0-rc1

Version Description

Download this release

Release Info

Developer shazahm1@hotmail.com
Plugin Icon 128x128 Easy Table of Contents
Version 2.0-rc1
Comparing to
See all releases

Code changes from version 2.0-beta2 to 2.0-rc1

easy-table-of-contents.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Easy Table of Contents
4
  * Plugin URI: http://connections-pro.com/
5
  * Description: Adds a user friendly and fully automatic way to create and display a table of contents generated from the page content.
6
- * Version: 2.0-beta2
7
  * Author: Steven A. Zahm
8
  * Author URI: http://connections-pro.com/
9
  * Text Domain: easy-table-of-contents
@@ -26,7 +26,7 @@
26
  * @package Easy Table of Contents
27
  * @category Plugin
28
  * @author Steven A. Zahm
29
- * @version 2.0-beta2
30
  */
31
 
32
  // Exit if accessed directly
@@ -45,7 +45,7 @@ if ( ! class_exists( 'ezTOC' ) ) {
45
  * @since 1.0
46
  * @var string
47
  */
48
- const VERSION = '2.0-beta2';
49
 
50
  /**
51
  * Stores the instance of this class.
@@ -504,7 +504,7 @@ if ( ! class_exists( 'ezTOC' ) ) {
504
 
505
  if ( $run ) {
506
 
507
- $post = ezTOC_Post::get( get_the_ID() )->process();
508
  $out = $post->getTOC();
509
 
510
  $run = FALSE;
3
  * Plugin Name: Easy Table of Contents
4
  * Plugin URI: http://connections-pro.com/
5
  * Description: Adds a user friendly and fully automatic way to create and display a table of contents generated from the page content.
6
+ * Version: 2.0-rc1
7
  * Author: Steven A. Zahm
8
  * Author URI: http://connections-pro.com/
9
  * Text Domain: easy-table-of-contents
26
  * @package Easy Table of Contents
27
  * @category Plugin
28
  * @author Steven A. Zahm
29
+ * @version 2.0-rc1
30
  */
31
 
32
  // Exit if accessed directly
45
  * @since 1.0
46
  * @var string
47
  */
48
+ const VERSION = '2.0-rc1';
49
 
50
  /**
51
  * Stores the instance of this class.
504
 
505
  if ( $run ) {
506
 
507
+ $post = ezTOC_Post::get( get_the_ID() )->applyContentFilter()->process();
508
  $out = $post->getTOC();
509
 
510
  $run = FALSE;
includes/class.post.php CHANGED
@@ -104,8 +104,6 @@ class ezTOC_Post {
104
  /**
105
  * Apply `the_content` filter to the post content.
106
  *
107
- * The `the_content` filter will only be applied once, even if this method is called multiple times.
108
- *
109
  * @access public
110
  * @since 2.0
111
  *
@@ -113,19 +111,24 @@ class ezTOC_Post {
113
  */
114
  public function applyContentFilter() {
115
 
116
- static $run = TRUE;
 
 
 
117
 
118
- if ( $run && $this->post instanceof WP_Post ) {
 
 
 
 
 
119
 
120
- /*
121
- * Ensure the ezTOC content filter is not applied when running `the_content` filter.
122
- */
123
- remove_filter( 'the_content', array( 'ezTOC', 'the_content' ), 100 );
124
- $this->post->post_content = apply_filters( 'the_content', $this->post->post_content );
125
- add_filter( 'the_content', array( 'ezTOC', 'the_content' ), 100 );
126
 
127
- $run = FALSE;
128
- }
 
 
129
 
130
  return $this;
131
  }
104
  /**
105
  * Apply `the_content` filter to the post content.
106
  *
 
 
107
  * @access public
108
  * @since 2.0
109
  *
111
  */
112
  public function applyContentFilter() {
113
 
114
+ /*
115
+ * Ensure the ezTOC content filter is not applied when running `the_content` filter.
116
+ */
117
+ remove_filter( 'the_content', array( 'ezTOC', 'the_content' ), 100 );
118
 
119
+ /*
120
+ * Ensure the ezTOC shortcodes are not processed when applying `the_content` filter
121
+ * otherwise an infinite loop may occur.
122
+ */
123
+ remove_shortcode( 'ez-toc' ) ;
124
+ remove_shortcode( 'toc' );
125
 
126
+ $this->post->post_content = apply_filters( 'the_content', $this->post->post_content );
 
 
 
 
 
127
 
128
+ add_filter( 'the_content', array( 'ezTOC', 'the_content' ), 100 );
129
+
130
+ add_shortcode( 'ez-toc', array( 'ezTOC', 'shortcode' ) );
131
+ add_shortcode( apply_filters( 'ez_toc_shortcode', 'toc' ), array( 'ezTOC', 'shortcode' ) );
132
 
133
  return $this;
134
  }