• Resolved vallo

    (@vallo)


    Hello, Im trying to figure out a way how to hide/disable or add a class to part of the text thats in event description.

    Description looks like that:
    “Some text some text [website link] some text [website link]”

    I need to filter out the links inside [] tags and get the result
    “Some text some text some text”

    Is there any way to do this with plugin options? I have tried dirty hacks with css and js search-replace, but no luck so far.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author room34

    (@room34)

    This really seems like more of a general CSS/jQuery type issue than anything related to this plugin, but you might be able to achieve it with something like this, in jQuery:

    jQuery('.ics-calendar .descloc a').each(function() {
        jQuery(this).replace(jQuery(this).text());
    });

    I haven’t actually tested this code to see if it works, but that’s where I’d start.

    Thread Starter vallo

    (@vallo)

    Thanks for the feedback! I’ll figure something out.

    It would be really helpful to be able to use regex on the events’ description at the server side. Using javascript can hide it from the user, but the info is still sent to the browser. Any one can see it on the page source, or worse, have private information indexed by Google. Adding an ‘apply_filter’ hook with the ics_data array as a parameter ($ics_data) before rendering the template (class-r34ics.php file, line 621) would be enough to enable this kind of filter.

    This is just a suggestion. I’ve been trying to do it in a safe way on the server side and it’s been really hard do to it without a filter hook.

    • This reply was modified 4 years, 7 months ago by renatobusatto.
    Plugin Author room34

    (@room34)

    @renatobusatto That’s a good idea. I’ve been approaching most feature requests from the perspective of users who are not comfortable writing server-side code, and the hooks I’ve added are mostly actions, not filters, because they were what I needed to tie in extra functionality in the Pro version. But I think it makes sense to add a filter here. I’m going to do that right now. Watch for an update shortly.

    The filter name is r34ics_display_calendar_filter_ics_data and it takes one parameter ($ics_data) so your code would look like this:

    add_filter('r34ics_display_calendar_filter_ics_data', 'YOUR_FILTER_FUNCTION', 10, 1);

    • This reply was modified 4 years, 7 months ago by room34.

    Thank you very much for your lightning quick fix, I’ve updated my code and it’s working perfectly!!

    If someone ever need, this is my code to remove URLs from the events’ description. I have added it using the Code Snippets plugin.

    function r34ics_ext_remove_url($ics_data){
      array_walk_recursive($ics_data['events'], function(&$value, $key) {
        if ($key=='eventdesc') {
          $value = preg_replace_callback(
            '/\w+:\/\/\S*\s+/',
            function ($m) { return ''; },
            $value
          );
        }
      });
      return $ics_data;
    }
    add_filter('r34ics_display_calendar_filter_ics_data', 'r34ics_ext_remove_url');
    
    Plugin Author room34

    (@room34)

    I’m glad it works, and thanks for sharing your code example! (I may actually look into adding a regular expression filtering option to the shortcode itself.)

    Plugin Author room34

    (@room34)

    (marked as resolved)

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Hide part of text from description’ is closed to new replies.