Skip to content

Commit 8669fa3

Browse files
authored
Merge pull request #335 from Ecwid/dev
Dev
2 parents 4b062f6 + 0725405 commit 8669fa3

File tree

4 files changed

+42
-26
lines changed

4 files changed

+42
-26
lines changed

includes/class-ec-store-oembed.php

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static function get_content() {
4040
if ( ! empty( $categories->items ) ) {
4141
foreach ( $categories->items as $category ) {
4242
$category = Ecwid_Category::get_by_id( $category->id );
43-
$items[ $category->link ] = $category->name;
43+
$items[ $category->url ] = $category->name;
4444
if ( count( $items ) >= $max_items ) {
4545
$see_more = true;
4646
break;
@@ -71,7 +71,7 @@ public static function get_content() {
7171
if ( $products->items ) {
7272
foreach ( $products->items as $product ) {
7373
$product = Ecwid_Product::get_by_id( $product->id );
74-
$items[ $product->link ] = $product->name;
74+
$items[ $product->url ] = $product->name;
7575
if ( count( $items ) >= $max_items ) {
7676
$see_more = true;
7777
break;
@@ -102,15 +102,21 @@ public static function ecwid_oembed_url( $url, $permalink, $format ) {
102102
return $url;
103103
}
104104

105-
$params = Ecwid_Seo_Links::maybe_extract_html_catalog_params();
106-
107-
if ( $params['mode'] == 'product' ) {
108-
$product = Ecwid_Product::get_by_id( $params['id'] );
109-
$permalink = $product->link;
110-
} elseif ( $params['mode'] == 'category' ) {
111-
$category = Ecwid_Category::get_by_id( $params['id'] );
112-
$permalink = $category->link;
113-
}
105+
if( Ecwid_Seo_Links::is_slugs_without_ids_enabled() ) {
106+
$permalink = trailingslashit( $permalink );
107+
$slug = Ecwid_Static_Page::get_current_storefront_page_slug();
108+
$permalink .= $slug;
109+
} else {
110+
$params = Ecwid_Seo_Links::maybe_extract_html_catalog_params();
111+
112+
if ( $params['mode'] == 'product' ) {
113+
$product = Ecwid_Product::get_by_id( $params['id'] );
114+
$permalink = $product->link;
115+
} elseif ( $params['mode'] == 'category' ) {
116+
$category = Ecwid_Category::get_by_id( $params['id'] );
117+
$permalink = $category->link;
118+
}
119+
}
114120

115121
$url = add_query_arg(
116122
array(

includes/class-ecwid-html-meta.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,7 @@ public function wp_head_last() {
123123
protected function _print_description() {
124124
$description_html = false;
125125

126-
if( Ecwid_Seo_Links::is_slugs_without_ids_enabled() ) {
127-
$slug = Ecwid_Static_Page::get_current_storefront_page_slug();
128-
$noindex_pages = Ecwid_Seo_Links::get_noindex_pages();
129-
130-
$is_internal_catalog_page = ! empty( $slug ) && ! in_array( $slug, $noindex_pages );
131-
} else {
132-
$is_internal_catalog_page = Ecwid_Seo_Links::is_product_browser_url();
133-
}
134-
135-
if ( ecwid_is_applicable_escaped_fragment() || $is_internal_catalog_page ) {
126+
if ( ecwid_is_applicable_escaped_fragment() || Ecwid_Seo_Links::is_product_browser_url() ) {
136127
$description_html = Ecwid_Static_Page::get_meta_description_html();
137128
} elseif ( Ecwid_Store_Page::is_store_page() ) {
138129
$set_metadesc = false;

includes/class-ecwid-seo-links.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,11 +398,19 @@ public static function maybe_extract_html_catalog_params() {
398398
}
399399

400400
public static function is_product_browser_url( $url = '' ) {
401-
if ( ! $url ) {
402-
$url = add_query_arg( null, null );
403-
}
404401

405-
return preg_match( self::_get_pb_preg_pattern(), $url );
402+
if( Ecwid_Seo_Links::is_slugs_without_ids_enabled() ) {
403+
$slug = Ecwid_Static_Page::get_current_storefront_page_slug();
404+
$noindex_pages = Ecwid_Seo_Links::get_noindex_pages();
405+
406+
return ! empty( $slug ) && ! in_array( $slug, $noindex_pages );
407+
} else {
408+
if ( ! $url ) {
409+
$url = add_query_arg( null, null );
410+
}
411+
412+
return preg_match( self::_get_pb_preg_pattern(), $url );
413+
}
406414
}
407415

408416
public static function is_seo_link() {

includes/class-ecwid-static-page.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,18 @@ public static function get_js_code() {
397397
}
398398

399399
public static function get_title() {
400-
return self::get_data_field( 'title' );
400+
$title = self::get_data_field( 'title' );
401+
402+
if( empty( $title ) ) {
403+
$meta_description = self::get_data_field( 'metaDescriptionHtml' );
404+
405+
if( ! empty( $meta_description ) ) {
406+
$title = preg_replace( '/<title>(.*?)<\/title>(.*)/is', '$1', $meta_description );
407+
$title = trim( $title );
408+
}
409+
}
410+
411+
return $title;
401412
}
402413

403414
public static function get_meta_description_html() {

0 commit comments

Comments
 (0)