Plugin Directory

Changeset 352827


Ignore:
Timestamp:
02/28/2011 03:15:22 AM (15 years ago)
Author:
karunanidhi
Message:
  • Bug fix: The length of the excerpt of not correct when strip tags was set to NO
  • Bug fix: Added function to close any open html tags in the excerpt so that the excerpt is valid html
Location:
auto-post-images-api/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • auto-post-images-api/trunk/auto-post-images.php

    r352804 r352827  
    33Plugin Name: Auto Post Images (API)
    44Plugin URI: http://www.karthikeyankarunanidhi.com
    5 Version: 3.1.1
     5Version: 3.1.2
    66Author: <a href="http://www.karthikeyankarunanidhi.com">Karthikeyan Karunanidhi</a>
    77Description: Automatically adds images to posts without having to edit the post.
     
    15271527
    15281528                        $iHtmlLen = strlen($sContent);
    1529                         $iTextLen = strlen(strip_tags($sContent));
    1530                         $iNewLen = $iHtmlLen - $iTextLen;
    1531                         $iLength += $iNewLen;
    1532 
    1533                         $sContent = substr($sContent,0,$iLength);
     1529                        if ($iHtmlLen > $iLength) {
     1530
     1531                            $iCount = 0;
     1532                            for($i = 0; $i < $iHtmlLen && $iCount < $iLength; $i++) {
     1533
     1534                                if($sContent[$i] == '<') {
     1535
     1536                                    $bSkip = TRUE;
     1537
     1538                                } else if($sContent[$i] == '>') {
     1539
     1540                                    $bSkip = FALSE;
     1541
     1542                                } else {
     1543
     1544                                    if ($bSkip === FALSE) {
     1545
     1546                                        $iCount++;
     1547                                    }
     1548                                }
     1549                            }
     1550                        } else {
     1551
     1552                            $i = $iLength;
     1553                        }
     1554
     1555                        $sContent = $this->closetags(substr($sContent,0,$i));
    15341556
    15351557                    } else {
     
    15471569                }
    15481570            }
     1571
     1572            function closetags ( $html ) {
     1573
     1574                //put all opened tags into an array
     1575                //
     1576                preg_match_all ( "#<([a-z]+)( .*)?(?!/)>#iU", $html, $result );
     1577
     1578                $openedtags = $result[1];
     1579
     1580                //put all closed tags into an array
     1581                //
     1582                preg_match_all ( "#</([a-z]+)>#iU", $html, $result );
     1583                $closedtags = $result[1];
     1584                $len_opened = count ( $openedtags );
     1585
     1586                //all tags are closed
     1587                //
     1588                if( count ( $closedtags ) == $len_opened ) {
     1589
     1590                    return $html;
     1591                }
     1592
     1593                $openedtags = array_reverse ( $openedtags );
     1594
     1595                //close tags
     1596                //
     1597                for( $i = 0; $i < $len_opened; $i++ ) {
     1598
     1599                    if ( !in_array ( $openedtags[$i], $closedtags ) ) {
     1600
     1601                        $html .= "</" . $openedtags[$i] . ">";
     1602                    } else {
     1603
     1604                        unset ( $closedtags[array_search ( $openedtags[$i], $closedtags)] );
     1605                    }
     1606                }
     1607
     1608                return $html;
     1609            }
     1610
    15491611
    15501612        } // End Class KKAutoPostImages
  • auto-post-images-api/trunk/readme.txt

    r352806 r352827  
    66Tested on: 2.6.2, 2.7, 2.7.1, 2.8.4,2.8.6,2.9,3.0,3.0.1,3.0.3,3.1
    77Tested up to: 3.1
    8 Stable tag: 3.1.1
     8Stable tag: 3.1.2
    99
    1010Automatically insert images to posts without having to edit the post. Supports renaming images for search engine optimization (SEO).
     
    130130== Changelog ==
    131131
    132 = 3.1
     132= 3.1.2 =
     133* On Sunday, February 27, 2011
     134* Bug fix: The length of the excerpt of not correct when strip tags was set to NO
     135* Bug fix: Added function to close any open html tags in the excerpt so that the excerpt is valid html
     136
     137
     138= 3.1.1 =
     139* On Sunday, February 27, 2011
     140* Bug fix: The excerpt function was not being called if the post did not have images.
     141
     142= 3.1 =
    133143* On Sunday, February 27, 2011
    134144* Adding excerpt functionality.
     
    219229== Upgrade Notice ==
    220230
    221 = 3.1.1 =
    222 Enhancement: Adding excerpt functionality. Adding tabs to option page so that the setting page is more user friendly.
     231= 3.1.2 =
     232Enhancement: Adding excerpt functionality with support for generating excerpt of the required length after stripping out all html tags or retain html tags and generate excerpt of (roughly) the required length while still excluding html tags from the total length of the excerpt and also closing open html tags so that the html excerpt is valid html. Adding tabs to option page so that the setting page is more user friendly.
Note: See TracChangeset for help on using the changeset viewer.