Skip to content

Commit

Permalink
Merge pull request #1470 from EkoJr/i-1468-desc-update
Browse files Browse the repository at this point in the history
fix for aioseop_description filter #1468
  • Loading branch information
michaeltorbert committed Jan 18, 2018
2 parents 3be22f9 + 8663ce1 commit 320efb4
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions aioseop_class.php
Expand Up @@ -2436,6 +2436,7 @@ function get_archive_title_format() {
/**
* @since 2.3.14 #932 Adds filter "aioseop_description", removes extra filtering.
* @since 2.4 #951 Trim/truncates occurs inside filter "aioseop_description".
* @since 2.4.4.1 #1395 Longer Meta Descriptions & don't trim manual Descriptions.
*
* @param null $post
*
Expand Down Expand Up @@ -2472,6 +2473,22 @@ function get_main_description( $post = null ) {
$description = $this->internationalize( $description );
}

$truncate = false;
$aioseop_desc = '';
if ( ! empty( $post->ID ) ) {
$aioseop_desc = get_post_meta( $post->ID, '_aioseop_description', true );
}

if ( empty ( $aioseop_desc ) && 'on' === $aioseop_options['aiosp_generate_descriptions'] && empty( $aioseop_options['aiosp_dont_truncate_descriptions'] ) ) {
$truncate = true;
}

$description = apply_filters(
'aioseop_description',
$description,
$truncate
);

return $description;
}

Expand Down Expand Up @@ -2503,6 +2520,9 @@ function get_page_number() {
}

/**
* @since ?
* @since 2.4 #1395 Longer Meta Descriptions & don't trim manual Descriptions.
*
* @param null $post
*
* @return mixed|string
Expand Down Expand Up @@ -2561,11 +2581,6 @@ function get_post_description( $post ) {
}
$description = $this->trim_text_without_filters_full_length( $this->internationalize( $content ) );
}
$description = apply_filters(
'aioseop_description',
$description,
empty( $aioseop_options['aiosp_dont_truncate_descriptions'] )
);
}

return $description;
Expand Down Expand Up @@ -4938,7 +4953,7 @@ public function filter_description( $value, $truncate = false ) {
// Internal whitespace trim.
$value = preg_replace( '/\s\s+/u', ' ', $value );
// Truncate / crop
if ( ! empty( $truncate ) )
if ( ! empty( $truncate ) && $truncate )
$value = $this->trim_excerpt_without_filters( $value );
// Encode to valid SEO html entities
return $this->seo_entity_encode( $value );
Expand Down

0 comments on commit 320efb4

Please sign in to comment.