• Resolved dhyanakendra

    (@dhyanakendra)


    Hi
    I am not sure if the issue is directly related to GP or not and whether I should be putting up this query in this forum. I have recently installed WPFORO forum plugin and everything works fine with GP theme. However, I am facing issues in executing a particular PHP code snippet. I am using Code Snippets and GP Child Theme

    add_filter('wpforo_content_after', 'wpforo_default_attachment_image_embed', 11);
    function wpforo_default_attachment_image_embed( $content ){
        if( preg_match_all('|<a class=\"wpforo\-default\-attachment\" href\=\"([^\"\']+)\"[^><]*>.+?<\/a>|is', $content, $data, PREG_SET_ORDER) ){
            foreach($data as $array){
                if(isset($array[1])){
                    $file = $array[1];
                    $e = strtolower(substr(strrchr($file, '.'), 1));
                    if( $e == 'jpg' || $e == 'jpeg' || $e == 'png' || $e == 'gif' ){
                        $filename = explode('/', $file); $filename = end($filename);
                        $html = '<a href="' . esc_url($file) . '" target="_blank"><img class="wpforo-default-image-attachment" src="' . esc_url($file) . '" alt="' . esc_attr($filename) . '" title="' . esc_attr($filename) . '" /></a>';
                        $content = str_replace($array[0], $html, $content);
                    }
                }
            }
        }
        return $content;
    }

    Link: https://wpforo.com/community/how-to-and-troubleshooting-2/uploading-and-embedding-images/

    I got in touch with WPForo Support and they have replied that the code works fine at their end.

    Screenshots:
    https://prnt.sc/nz4ezp
    https://prnt.sc/nz4f4a

    Warmest Regards
    BM

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Theme Author Tom

    (@edge22)

    Hi there,

    What’s the exact error you’re getting?

    Have they tested the code with the Code Snippets plugin?

    Let me know ??

    Thread Starter dhyanakendra

    (@dhyanakendra)

    Hi Tom
    I suppose the above snippet has been abandoned as the required feature has been implemented in the latest update of the said plugin.

    Thank you very much for your time. Have a nice and wonderful day!

    Regards
    BM

    Theme Author Tom

    (@edge22)

    No problem! You too ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘PHP Code snippet execution error’ is closed to new replies.