little.chimp

Forum Replies Created

Viewing 15 posts - 1 through 15 (of 23 total)
  • Author
    Posts
  • in reply to: Disable plugin on specific pages #45900
    little.chimp
    Participant

    for my own reference…

    /function.php Line: 255-279 commented out. notification.js
    /function.php Line: 213
    if (is_single() || is_archive() || is_page('inbox')) {
    wp_enqueue_style( 'fep-common-style' );
    }

    in reply to: Redirect notification email #45835
    little.chimp
    Participant

    Or maybe the first message from any users is set to “pending” and then once approved any further new messages are automatically “published”?

    in reply to: Strip HTML from {{message}} #45828
    little.chimp
    Participant

    Originally, I only wanted to strip the HTML from the message of the email, but what I ended up with, striped it from the email and the website. Which worked out as it makes the site more secure, and I was able to modify my attached scam warning message with a bit of CSS, so it made sense on the website and in the email. The code in reply #45825 is simplified compared to the live code, to make it more generic and less specific to my website.

    in reply to: Strip HTML from {{message}} #45826
    little.chimp
    Participant
    This reply has been marked as private.
    in reply to: Strip HTML from {{message}} #45825
    little.chimp
    Participant

    I got it all working, I found the reference I need to understand the filter here.

    Here’s the working code.

    function fep_rip_tags($string, $rep = ' ') { 
    
        $string = preg_replace ('/<[^>]*>/', $rep, $string); 
        $string = str_replace("\r", '', $string);    // --- replace with empty space
        $string = str_replace("\n", $rep, $string);   // --- replace with space
        $string = str_replace("\t", $rep, $string);   // --- replace with space
        $string = trim(preg_replace('/ {2,}/', $rep, $string));
        return $string; 
    
    }
    
    function fep_strpos_arr($haystack) {
    	
    	$needle = array('a selection', 'of various', 'keywords', 'related to scams');
    	foreach($needle as $value) {
    		if (strpos($haystack, $value) !== false) {
    			return "<p><b>Warning!</b> This is a scam.</p>";
    		}
    	}
    	return false;
    
    }
    
    add_filter( 'fep_filter_message_before_send', function( $message ) {
    
    	$haystack = $message['message_content'];
    	$message['message_content'] = fep_strpos_arr($haystack) . fep_rip_tags( $message['message_content'] );
    	return $message;
    	
    }, 99);

    It was the $message['message_content']; bit that I was unable to find in the plugin code or docs. But now I know what to look for, it’s everywhere. I’ve return my class-fep-email-beautify.php back to it’s default state too, reenabling wpautop on the copy.

    in reply to: Strip HTML from {{message}} #45821
    little.chimp
    Participant

    I’ve realised I could drop $message = "{{message}}"; from the code and update the “New message content” in the settings to just be {{message}} and still have the message pulled in with just the $message variable. But I’m still unable to modify the $string via PHP functions, plus HTML that’s added to messages is sent through with the email, as I’m unable to strip it out.

    in reply to: Strip HTML from {{message}} #45820
    little.chimp
    Participant

    I’ve edit the code in class-fep-email-beautify.php to allow me to do some testing (I will change it back once I have a solution), which means I’ve been able to pull the message into the email template without the <p></p>.

    But even thought I have {{message}} in a $string, I’m still unable to modify or validate it using any sort of PHP function. It seems immune to my tinkering.

    This lot works as soon as I switch out {{message}} for the actual message copy, until then it comes back ‘false’ even when I know if should be ‘true’.

    function rip_tags($string, $rep = ' ') { 
        
        $string = preg_replace ('/<[^>]*>/', $rep, $string); 
        $string = str_replace("\r", '', $string);    // --- replace with empty space
        $string = str_replace("\n", $rep, $string);   // --- replace with space
        $string = str_replace("\t", $rep, $string);   // --- replace with space
        $string = trim(preg_replace('/ {2,}/', $rep, $string));
        
        return $string; 
    
    }
    
    /* strpos that takes an array of values to match against a string */
    function strpos_arr($haystack, $needle) {
    
    	foreach($needle as $value) {
    		if (strpos($haystack, $value) !== false) {
    			return "<p><b>Warning!</b></p>";
    		}
    	}
    	return false;
    	
    }
    
    $message = "{{message}}";
    $message = rip_tags($message);
    $needle = array('various scam', 'keywords', 'and other stuff');
    $haystack = $message;
    in reply to: Strip HTML from {{message}} #45818
    little.chimp
    Participant

    Is there a simple way to filter or stop the wpautop on line 116 of pro/includes/class-fep-email-beautify.php, while retaining HTML as the email format?

    in reply to: Strip HTML from {{message}} #45817
    little.chimp
    Participant

    $message = strip_tags( $message); should have shown $message = strip_tags('{{message}}');, I mistyped.

    in reply to: Blocked access to the WP REST API #45811
    little.chimp
    Participant

    I’ve got plugins conflicting with each other. I’m still working through them trying to untangle the mess. I’ll report back once I find the cause.

    in reply to: Blocked access to the WP REST API #45809
    little.chimp
    Participant

    I’ve got all of them unticked already, do you have a snippet that allows me to disable the calls?

    in reply to: Filter question for fep_form_fields message_to #40310
    little.chimp
    Participant

    Much appreciated. I’ll just comment out my customisations once you push the update. 🙂

    in reply to: Filter question for fep_form_fields message_to #40287
    little.chimp
    Participant

    So, as a work around?

    function message_to_placeholder_replace($output) {
    	if (is_page('messages')) {
    		$replace = array('#placeholder="Name of the recipient."#');
    		$string = 'placeholder="To"';
    		$output = preg_replace($replace, $string, $output, 1);
    		return $output;
    	}
    }
    function start_message_to_placeholder_replace() { 
    	ob_start("message_to_placeholder_replace"); 
    }
    add_action('wp_head','start_message_to_placeholder_replace');
    in reply to: Filter question for fep_form_fields message_to #40256
    little.chimp
    Participant

    Yep, screenshot attached. I’m hiding the labels with CSS at the moment, but everything in the fep_form_fields filter works apart from the message_to elements.

    Attachments:
    You must be logged in to view attached files.
    in reply to: Ajax replies? #39572
    little.chimp
    Participant

    Even with a vanilla installation, I can’t get it to work consistently. It may be my hosting or the caching system, but I’ve decided to go with a javascript reload to cover my bases.

    add_filter( 'fep_form_submit_button', function( $button, $where ){
    	if( 'reply' == $where ){
    		// $fep_message_id = fep_get_the_id();
    		// $website = site_url( '/messages/', 'https' ) . '?fepaction=viewmessage&fep_id=' . fep_get_parent_id($fep_message_id);
    		$button = '<button type="submit" onclick="setTimeout(location.reload.bind(location), 1500);" class="fep-button" name="fep_action" value="'. esc_attr( $where ) .'">Reply</button>';
    	}
    	return $button;
    }, 10, 2 );
Viewing 15 posts - 1 through 15 (of 23 total)