Support » Plugin: Events Manager » Striving for Polylang compatibility

  • Resolved filip.jnc


    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): (original page with “CONTENTS” in it) or (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?

Viewing 4 replies - 1 through 4 (of 4 total)
  • 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…

    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);

    Ok this is my em-events.php that makes Events Manager scan for “CONTENTS” in the russian parallel page: (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);
    			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.



    NetWebLogic Support

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


Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Striving for Polylang compatibility’ is closed to new replies.