wordpress-parsi / wp-parsidate

Integrates the Solar Hijri (Persian) calendar in WordPress
https://wp-parsi.com
GNU General Public License v2.0
52 stars 28 forks source link

Google robot does not compatible with Jalali date #3

Closed Sh4d0wHunt3rX closed 5 years ago

Sh4d0wHunt3rX commented 7 years ago

سلام. خسته نباشید من ۲ باگ رو معرفی کرده بودم در پلاگین به مرتضی جان. یکی اینکه تاریخ پلاگین یوست نباید شمسی شه. یکی هم اینکه ربات گوگل قادر به خوندن تاریخ انتشار مطلب نیست، چون اونم شمسی می شه با پلاگین شما. کد درستش هم فرستادم. قرار بود قبل از عید هم این آپدیت منتشر شه

الان این آپدیت شامل رفع اینها هست؟ چون در چنج لاگ چیزی ندیدم

mostafasoufi commented 7 years ago

Hi Amir,

Please explain more about your issue in the new ticket.

Regards

Sh4d0wHunt3rX commented 7 years ago

This is new one :)

mostafasoufi commented 7 years ago

رفع باگ Not a good title :)

Sh4d0wHunt3rX commented 7 years ago

It's ok now? :)

mostafasoufi commented 7 years ago

Is better like bellow title:

Google robot does not compatible with Jalali date

Here you get more information about github issues.

Sh4d0wHunt3rX commented 7 years ago

ok, done man :)

Sh4d0wHunt3rX commented 7 years ago

Any update on this?

Sh4d0wHunt3rX commented 7 years ago

It's funny, I paid someone to fix your code, gave you up the patch and you don't bother yourself to update it, But you care about the title of the ticket in github!

mostafasoufi commented 7 years ago

Please do not hurry. Will be fixed soon.

parsakafi commented 7 years ago

New version 2.3 updated and fix this bug

Sh4d0wHunt3rX commented 7 years ago

The issue has not yet been resolved yet completely.

Test this in google structured tools: (Test the code snippet to avoid caching issues) https://www.ajibtarin.com/one-pic/31053/

image

image

This is actually what "Schema App Structured Data" is fetching, the Shamsi date instead of Gregorian date for published posts parameter.

So, in general, you fixed the crawling problem and you fixed the date modified problem, but the published date has not been fixed, because it has error in google structured tools.

parsakafi commented 7 years ago

Where datePublished ? Printed by theme or plugin?

Sh4d0wHunt3rX commented 7 years ago

Your plugin should change the date to shamsi only for users not for google. When I enable your plugin, google reports error because it can't understand shamsi structure. When I disable your plugin everything is ok.

Sh4d0wHunt3rX commented 7 years ago

The issue is still there without any response from your side, I tried to know opinion of author of "Schema App Structured Data" plugin on why this happens, and I noticed your plugin is not compatible with none of schema plugins.

Here is his response:

Let me explain why it’s happening to our plugin:

https://plugins.trac.wordpress.org/browser/wp-parsidate/trunk/includes/fixes-dates.php line 19 is the hook and line 120 is the callback function.

In the code the wpp_fix_i18n function is specifically excluding the callback calls to WPSEO, WC and get_the_modified_date. We use get_the_modified_date for the dateModified but for datePublished the WP Function is get_the_date() which is not excluded. As far as I can tell, the parsidate plugin should be updated to include that function or modified to include Schema App Plugin.

What do you think? Can you fix this?

Thanks

P.s @mostafasoufi Please re open the bug as it has not been solved yet.

Sh4d0wHunt3rX commented 7 years ago

So no answer from 3 developers of this plugin?

man4toman commented 7 years ago

@amiremami

It's all about ordering! We must fix this conflict in WordPress SEO OpenGraph class. But some actions effect on functions order in classes. Also premium version of WPSEO has different functions order!

That is a big mess! :)

But we hope to find a fundamental solution for this case.

Regards

Sh4d0wHunt3rX commented 7 years ago

Hi Still no solution for this major problem?

man4toman commented 7 years ago

@amiremami

We are working for a solution that maybe fix this issue.

vandspot commented 6 years ago

Hey guys, I kinda found a workaround for this issue. Actually WP-SEO uses get_the_date and get_post_modified_time to retrieve the date and time. But we need to modify get_the_date so we must tell WP-SEO to use a mediator function. All you have to do is to add a function to your functions.php and use the exact code of get_the_date (https://codex.wordpress.org/Function_Reference/get_the_date). And you rename this new function to: get_the_orig_date(). Then you go to: wordpress-seo/frontend/class-opengraph.php and scroll to the line it's using get_the_date and change it to: $pub = get_the_orig_date( DATE_W3C ); Then go to: wp-parsidate/includes/fixes-dates.php and in the wpp_fix_i18n function use this constraint:

if (
            (isset($callers[6]['class']) && $callers[6]['class'] == 'WPSEO_OpenGraph') ||
            (isset($callers[6]['function']) && $callers[6]['function'] == 'get_the_orig_date') ||
            (isset($callers[6]['function']) && $callers[6]['function'] == 'get_post_modified_time')
        )
            return $format_string;

Output:

<meta property="article:published_time" content="2018-03-13T09:30:33+00:00" />
<meta property="article:modified_time" content="2018-04-03T09:00:51+00:00" />
<meta property="og:updated_time" content="2018-04-03T09:00:51+00:00" />

Finally, some parts of the Google Rich Snippets may come from other plugins or even your theme files. You can find where they're using get_the_date and rename it to get_the_orig_date wherever needed. For example I had to find a page in my theme where it messed with itemprop="datePublished", because that should be in Gregorian format. So I changed to get_the_orig_date it and here's the result:

<span class="date">
    <time class="entry-date updated" datetime="<?php echo get_the_orig_date('c'); ?>" itemprop="datePublished" ><?php echo get_the_date(); ?></time>
    <meta itemprop="dateModified" content="<?php echo get_the_orig_date('c'); ?>"/>
</span> 

Output:

<span class="date">
<time class="entry-date updated" datetime="2018-03-13T09:30:33+00:00" itemprop="datePublished" >22 اسفند 1396</time>
<meta itemprop="dateModified" content="2018-03-13T09:30:33+00:00"/>
</span>

Live output here

I know, if you update the WP-SEO, your edits will be overwritten, but at least it gives you a temporary answer.

man4toman commented 5 years ago

He @aminvanda We worked on new update and added new functionality for disable hooks. We will update the repo on this weekend.

Regards

saeedheidaricom commented 5 years ago

hi, guys still I have this problem how I fix?

fariborzasgarpour commented 8 months ago

function wpp_fix_post_date( $time, $format = '' ) { global $post; if ( empty( $post ) ) { return $time; } if ( empty( $format ) ) { $format = get_option( 'date_format' ); } if ( ! disable_wpp() ) { return date( $format, strtotime( $post->post_modified ) ); } if($format == "c") { return date( 'c', strtotime( $post->post_date )); } return parsidate( $format, date( 'Y-m-d H:i:s', strtotime( $post->post_date ) ), ! wpp_is_active( 'conv_dates' ) ? 'eng' : 'per' );}

در متد بالا کد زیر رو اضافه شده : if($format == "c") { return date( 'c', strtotime( $post->post_date )); } با این کار هر جا در وبسایت شما فرمت زمانی "c" باشه که برای اسکیما این فرمت قابل قبوله ، تغییر نمی کنه و میلادی باقی می مونه