Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter pako69

    (@pako69)

    ok, I made it work by adding the LSC plugin php into case 1,2 and 3 below.

    
    	switch ( $like_status ){
    		case 0:
    			$response = array(
    						'message' => wp_ulike_get_setting( 'wp_ulike_general', 'login_text', __( 'You Should Login To Submit Your Like', WP_ULIKE_SLUG ) ),
    						'btnText' => html_entity_decode( wp_ulike_get_setting( 'wp_ulike_general', 'button_text', __( 'Like', WP_ULIKE_SLUG ) ) ),
    						'data'    => NULL
    					);
    			break;
    		case 1:
    			$response = array(
    						'message' => wp_ulike_get_setting( 'wp_ulike_general', 'like_notice', __( 'Thanks! You Liked This.', WP_ULIKE_SLUG ) ),
    						'btnText' => html_entity_decode( wp_ulike_get_setting( 'wp_ulike_general', 'button_text', __( 'Like', WP_ULIKE_SLUG ) ) ),
    						'data'    => apply_filters( 'wp_ulike_respond_for_not_liked_data', $wp_ulike_class->wp_get_ulike( $args ), $post_ID )
    					);
    			if (method_exists( 'LiteSpeed_Cache_API', 'purge_post' ) == true) { LiteSpeed_Cache_API::purge_post( $post_ID ) ; }
    			break;
    		case 2:
    			$response = array(
    						'message' => wp_ulike_get_setting( 'wp_ulike_general', 'unlike_notice', __( 'Sorry! You unliked this.', WP_ULIKE_SLUG ) ),
    						'btnText' => html_entity_decode( wp_ulike_get_setting( 'wp_ulike_general', 'button_text', __( 'Like', WP_ULIKE_SLUG ) ) ),
    						'data'    => apply_filters( 'wp_ulike_respond_for_unliked_data', $wp_ulike_class->wp_get_ulike( $args ), $post_ID )
    					);
    			if (method_exists( 'LiteSpeed_Cache_API', 'purge_post' ) == true) { LiteSpeed_Cache_API::purge_post( $post_ID ) ; }
    			break;
    		case 3:
    			$response = array(
    						'message' => wp_ulike_get_setting( 'wp_ulike_general', 'like_notice', __( 'Thanks! You Liked This.', WP_ULIKE_SLUG ) ),
    						'btnText' => html_entity_decode(wp_ulike_get_setting( 'wp_ulike_general', 'button_text_u', __( 'Liked', WP_ULIKE_SLUG ) ) ),
    						'data'    => apply_filters( 'wp_ulike_respond_for_liked_data', $wp_ulike_class->wp_get_ulike( $args ), $post_ID )
    					);
    			if (method_exists( 'LiteSpeed_Cache_API', 'purge_post' ) == true) { LiteSpeed_Cache_API::purge_post( $post_ID ) ; }
    			break;
    		default:
    			$response = array(
    						'message' => wp_ulike_get_setting( 'wp_ulike_general', 'permission_text', __( 'You have not permission to unlike', WP_ULIKE_SLUG ) ),
    						'btnText' => html_entity_decode( wp_ulike_get_setting( 'wp_ulike_general', 'button_text', __( 'Liked', WP_ULIKE_SLUG ) ) ),
    						'data'    => NULL
    					);
    	}

    But if you have better solution maybe include it…?
    Thanks

    • This reply was modified 7 years, 8 months ago by pako69.
    Plugin Author Alimir

    (@alimir)

    Hi @pako69
    I think there’s a better way. Try the code below: 😉

    function wp_ulike_litespeed_purge_cache( $ID, $type ){
    	if(  $type === '_liked'  && method_exists( 'LiteSpeed_Cache_API', 'purge_post' ) ){
    			LiteSpeed_Cache_API::purge_post( $ID ) ;
    	}
    }
    add_action( 'wp_ulike_after_process', 'wp_ulike_litespeed_purge_cache'	, 10, 2 );
    Thread Starter pako69

    (@pako69)

    Hi Alimir,
    Thanks for the snippet 😉

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘How to make it compatible with LiteSpeed Cache plugin?’ is closed to new replies.