WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
[resolved] Striving for Polylang compatibility (5 posts)

  1. filip.jnc
    Member
    Posted 6 months ago #

    Hello again,

    I'm sorry for posting again on this topic, but this time the purpose is different. I thought that since Events Manager and Polylang are ones of the most popular plugins in their particular category, let's get together and make the compatibility possible. I almost understood how EM works with Polylang and what should we concentrate on.

    1. First thing what should be done in order for others to work is forcing EM to scan the translated pages (Events, -Categories, -Locations, and so on) for the word "CONTENTS" and replace it with the necessary content.

    2. Then when you go to that /events/ or /events-ru/ page with the list of all events, EM should see what language is set on the website and filter them (right now it's displayed from both languages):
    http://bikeportal.md/events/ (original page with "CONTENTS" in it) or http://bikeportal.md/events-ru (translated page with [category_list] shortcode in it)

    ! On both pages from above, if you open the ro_RO events the website turns (or remains) in ro_RO, and if you open the ru_RU events the website turns (or remains) in ru_RU. So this is already covered by Polylang.

    3. Synchronize Location and Date/Time (Category is synchronized by Polylang already) when you create the translation of an event. The first two are probably not synchronized because Polylang doesn't see them as custom taxonomies or whatever they are.

    There are some other minor problems but I think they are related to the first problem with scanning the "CONTENTS" word from translated pages. I personally think this is not a big deal for a skilled php programmer and for you guys that created this awesome plugin. I'm willing to do the testing on my website. Let's get to work?

    https://wordpress.org/plugins/events-manager/

  2. filip.jnc
    Member
    Posted 6 months ago #

    1. For the first one I figure out that the function we should edit is em_content from /em-events.php. More specifically, from line 32:

    if ( $post->ID == $events_page_id && $events_page_id != 0 ) {

    which I believe in the end fires this:

    //Now, we either replace CONTENTS or just replace the whole page
    			if( preg_match('/CONTENTS/', $page_content) ){
    				$content = str_replace('CONTENTS',$content,$page_content);
    			}

    if $post->ID is the ID of the events page we selected in the admin settings, we probably need to implement some of Polylang functions here.

    Maybe something related to 'pll_get_post()' which returns the translation of the current page: pll_get_post($post->ID)...

    I'm a rookie in this stuff, so please help me guys...

  3. filip.jnc
    Member
    Posted 6 months ago #

    I tried to edit that piece of code that replaces CONTENTS with the actual events list, but still on the russian page the CONTENTS word is not replaced:

    //Now, we either replace CONTENTS or just replace the whole page
    
    				//changed_core //polylang
    				global $polylang;
    				$translated_post_id = pll_get_post($events_page_id, 'ru');
    				$translated_page = get_page($translated_post_id);
    				$translated_page_content = $translated_page->post_content;
    
    			if( preg_match('/CONTENTS/', $page_content) ){
    				$content = str_replace('CONTENTS',$content,$page_content);
    			}
    			elseif ( preg_match('/CONTENTS/', $translated_page_content) ) {
    				$content = str_replace('CONTENTS',$content,$translated_page_content);
    			}
  4. filip.jnc
    Member
    Posted 6 months ago #

    Ok this is my em-events.php that makes Events Manager scan for "CONTENTS" in the russian parallel page: http://pastebin.com/ZEMhmFfL (the lines I changed are marked with //core_changed//polylang)
    This works for Events and -Categories but now it still displays CONTENTS when you open a translated category. I noticed this is due to the file /classes/em-category-taxonomies.php:

    function the_content($content){
    		global $wp_query, $EM_Category, $post, $em_category_id;
    		$is_categories_page = $post->ID == get_option('dbem_categories_page');
    		$category_flag = (!empty($wp_query->em_category_id) || !empty($em_category_id));
    		if( ($is_categories_page && $category_flag) || (empty($post->ID) && $category_flag) ){
    			$EM_Category = empty($wp_query->em_category_id) ? em_get_category($em_category_id):em_get_category($wp_query->em_category_id);
    			ob_start();
    			em_locate_template('templates/category-single.php',true);
    			return ob_get_clean();
    		}
    		return $content;
    	}

    There's so much to edit and I fear a new version of Events Manager will require this hard work again. Maybe EM team comes with a rational solution? Thanks.

  5. angelo
    NetWebLogic Support
    Posted 5 months ago #

    am afraid that can't help you with this one since I haven't tried Polylang plugin before.

    sorry.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.