Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for aioseop_description filter #1468 #1470

Merged
merged 6 commits into from Jan 18, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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