Plugin Directory

Changeset 516756


Ignore:
Timestamp:
03/09/2012 01:46:14 PM (14 years ago)
Author:
VoxPelli
Message:

Only use the first 30 words of the post in the autosubmit buttons/links

File:
1 edited

Legend:

Unmodified
Added
Removed
  • flattr/trunk/flattr.php

    r508984 r516756  
    394394     */
    395395    public function injectIntoTheContent($content) {
     396        static $processingPosts = array();
     397
    396398        global $post;
    397399
     
    405407
    406408        if (in_array(get_post_type(), (array)get_option('flattr_post_types', array())) && !is_feed()) {
     409            if (isset($processingPosts[$post->ID])) {
     410                return $content;
     411            } else {
     412                $processingPosts[$post->ID] = true;
     413            }
    407414            $button = $this->getButton();
    408415            $button = '<p class="wp-flattr-button">'.$button.'</p>';
     
    414421                    $content = $content . $button;
    415422            }
     423            unset($processingPosts[$post->ID]);
    416424        }
    417425        return $content;
     
    456464                $hidden = get_option('flattr_hide', false);
    457465        }
     466
     467        $description = get_the_content('');
     468        $description = strip_shortcodes( $description );
     469        $description = apply_filters('the_content', $description);
     470        $description = str_replace(']]>', ']]&gt;', $description);
     471        $description = wp_trim_words( $description, 30, '...' );
    458472
    459473        $buttonData = array(
     
    466480                'category'  => $selectedCategory,
    467481                'title'     => strip_tags(get_the_title()),
    468                 'description'       => strip_tags(preg_replace('/\<br\s*\/?\>/i', "\n", $post->post_content)),
     482                'description' => $description,
    469483                'tags'      => trim(strip_tags(get_the_tag_list('', ',', '')) . ',' . $additionalTags, ', ')
    470484
Note: See TracChangeset for help on using the changeset viewer.