• Hello,

    Thanks for the plugin – it’s a real time saver!

    I’m not sure if this is any help for you at all but I needed to adapt the plugin so that users don’t have to enter the shortcodes after the nextpage tags (believe it or not this is too complex for our users). So I changed your for loop in /includes/class-simple-paginated-posts.php on line 276 to get the first heading in the html block of each page as a title. I also added a check to make sure it gets a heading (or shortcode) and if not fill it with a default (Page 1, Page 2 etc.). The code is:

    for ( $i = 1; $i < ($numpages); $i = $i + 1 ) {
                    //Match headings
                    preg_match('|<h[^>]+>(.*)</h[^>]+>|iU',$pages[$i],$matchingHeadings[$i]);  
    
                    //If we found a match use it as our heading
                    if(!empty($matchingHeadings[$i])){
                        //TODO:Strip out any innerhtml that may be there (spans, links etc.)
                        $this->page_titles[] = trim($matchingHeadings[$i][1]);//1 is the inner part
                    }
                    else{
                        preg_replace_callback( "/$shortcode_pattern/s", array( $this, 'get_shortcode_atts' ), $pages[$i] );
                    }
    
                    //No title found use default
                    if(empty($this->page_titles[$i])){
                        $this->page_titles[] = __('Page ') . ($i + 1);
                    }
    			}

    I’d love to see this added into the plugin if possible.

    Thanks,
    James

    http://wordpress.org/extend/plugins/simple-paginated-posts/

Viewing 1 replies (of 1 total)
  • Thread Starter smartredfox

    (@smartredfox)

    Hello,

    Me again. I’ve spotted and fixed a bug where it looks like the auto/manual option wasn’t saving on the settings page.

    When the settings page saves it overwrites the tla_spp_options setting in the database that holds the version number. This means that the version number always shows as 0 after save, which then makes the version check code fire and update the auto/manual as auto again!

    Adding the version number in as a hidden field fixes this (added in /includes/class-spp-admin.php on line 145):

    echo "<input type='hidden' name='tla_spp_options[version]' value='" . $options['version'] . "'>";

    Thanks again,
    James

Viewing 1 replies (of 1 total)
  • The topic ‘Match by heading not shortcode’ is closed to new replies.