onOffice-Web-Org / oo-wp-plugin

onOffice for WP-Websites
https://wp-plugin.onoffice.com
GNU General Public License v3.0
9 stars 9 forks source link

Display "Pages that use the shortcode" is faulty #575

Open fredericalpers opened 1 year ago

fredericalpers commented 1 year ago

Discussed in https://github.com/onOffice-Web-Org/oo-wp-plugin/discussions/530

Originally posted by **fredericalpers** May 24, 2023 ### Current state At the moment it seems that the form & list shortcodes are permanently displayed for all languages. For example, if there is a form in DE and EN on the home page, "Home" is displayed 2 times. ![anzeige-shortcode1](https://github.com/onOffice-Web-Org/oo-wp-plugin/assets/88546396/7a3675e0-f6d2-4cde-b4b5-d16283d6dbe2) ### Desired state Only the pages for the currently selected / relevant language should be displayed.
dai-eastgate commented 10 months ago

@fredericalpers

  1. Did you create two "Home" pages that follow the steps I did in the video below?

https://github.com/onOffice-Web-Org/oo-wp-plugin/assets/106214469/14493651-f976-418b-b123-6a0282efd697

  1. We will have 2 cases that can happen:
    • Case 1: If you use "Site Language" to create two "Home" pages as mentioned in the video above. This is my solution: Desired state: Only the pages for the currently selected / relevant language should be displayed. Now, WordPress core does not support detecting the "language of page" when adding a new page.

=>We need to add a new table(table: see detail table below) to the database to detect the "language of page" when adding a new page.

Note: table wp_oo_plugin_detect_language_page detect_language_page_id (PRIMARY KEY), embed_shortcode_form_page_id (page id with embedded shortcode), locale

=> Do you agree with my solutions?

fredericalpers commented 10 months ago

@dai-eastgate I will be able to give you feedback tomorrow, thank you :)

fredericalpers commented 10 months ago

@dai-eastgate Please implement case 1 as suggested.

For case 2 we definitely want to support the most used multilingual plugins. Would it be easier for you to implement WPML first (WPML has priority since this is the plugin we are mostly using) and have a second issue for Polylang and maybe others later on/in the next milestones rather then implementing all at once?

dai-eastgate commented 10 months ago

@fredericalpers I will check and let you know soon.

dai-eastgate commented 9 months ago

@fredericalpers It will take me 5 days to implement and test for case 1 and the WPML plugin. Thanks!

dai-eastgate commented 9 months ago

@fredericalpers We have two solutions for "detecting language for page" Which Pages using the shortcode: Solution 1: We can add an option in the "onoffice > settings" as in the image below

image

=> detect language based on the "General settings of WordPress" or multilingual plugins (WPML, Polylang).

Solution 2: Detecting language allowed by prioritizing as follows: we will prioritize based on the multilingual plugin that the client installed. If no multilingual plugin is installed, we will detect by "Site Language" of "General Settings of Wordpress" image

dai-eastgate commented 9 months ago

@fredericalpers Which solution do you prefer us to implement?

fredericalpers commented 9 months ago

@dai-eastgate sorry for the late reply. We prefer solution 2.

Solution 2: Detecting language allowed by prioritizing as follows: we will prioritize based on the multilingual plugin that the client installed. If no multilingual plugin is installed, we will detect by "Site Language" of "General Settings of Wordpress"

Please go ahead and implement the suggested solution. Thank you :)

dai-eastgate commented 9 months ago

@dai-eastgate sorry for the late reply. We prefer solution 2.

Thanks! I will implement solution 2.

dai-eastgate commented 9 months ago

@fredericalpers Currently, I am checking issue #491 , which needs to be resolved before I can continue working on issue #575. Based on my estimation before, it is necessary to move the issue to the ramp-up week. Thanks!

dai-eastgate commented 9 months ago

@fredericalpers During implementation, I noticed the following problems: Problem 1: If no multilingual plugin is installed, we will detect by "Site Language" of "General Settings of WordPress" => Pages which are added by old users in different languages will only be detected as the current language ex: The current language which is set in "Site Language" of "General Settings of WordPress": English old users added "page English" in English old customers added "page Deutsch" in Deutsch => "page English", and "page Deutsch" will only be detected as pages added in "English language"

https://github.com/onOffice-Web-Org/oo-wp-plugin/assets/106214469/36c7702c-00f7-4f18-a084-f6f9513bbf90

Because we can only handle the "add new a page" action and save it to the current language "wp_oo_plugin_detect_language_page" table in the database.

image

You can see the code. image

=> There is no solution to this problem

Problem 2: Please provide me with the correct "Path to the plugin file relative to the plugins directory." of wpml. Currently, I am checking it like this "sitepress-multilingual-cms/sitepress.php". Is this correct?

Currently, we have completed 80% of this feature and are blocking the above 2 issues.

https://github.com/onOffice-Web-Org/oo-wp-plugin/assets/106214469/bcdc96b8-daa4-48af-ab45-147c91c8d638

https://github.com/onOffice-Web-Org/oo-wp-plugin/assets/106214469/cca7f77c-da92-4b62-a580-898aaae0d260

Please test the branch we are working on (35073-display-pages-that-use-the-shortcode-is-faulty) and give me your feedback. => We need 3 more days to be able to check this issue more specifically.

dai-eastgate commented 9 months ago

@fredericalpers When I tested on the master branch, I had the following states: I perform the following steps: Step 1: I create a new page, named as "list" and embed the [oo_estate view="list estate"] shortcode into the content of this page. => This page(named as "list") will be displayed in the "Pages using the shortcode" admin part of the estate list image

Step 2: I delete that shortcode in content of this page(named as "list") => This page(named as "list") still be displayed in the "Pages using the shortcode" admin part of the estate list. image

Please confirm: what attributes of a page will be displayed in the "Pages using the shortcode" admin part of the estate list?

According to my understanding: That page must have 2 attributes:

image

image

dai-eastgate commented 9 months ago

@fredericalpers Please confirm it for me so I can continue with the implementation. Thanks

fredericalpers commented 9 months ago

@fredericalpers Please confirm it for me so I can continue with the implementation. Thanks

@dai-eastgate sorry, I will get back to you asap