Fix featured toggle not working

Hacky implementation, but it does the job.
This commit is contained in:
Bea 2021-04-27 00:21:57 +02:00 committed by GitHub
parent 440e7fc604
commit 4b8fc83816
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -208,11 +208,14 @@ function opalestate_toggle_featured_property() {
if ( $post->post_author == $user_id ) { if ( $post->post_author == $user_id ) {
$check = apply_filters( 'opalestate_set_feature_property_checked', false ); $isfeatured = get_post_meta( $property_id, OPALESTATE_PROPERTY_PREFIX . 'featured', true );
if ( $check ) { if( $isfeatured ) {
do_action( 'opalestate_toggle_featured_property_before', $user_id, $property_id ); update_post_meta( $property_id, OPALESTATE_PROPERTY_PREFIX . 'featured', '' );
echo json_encode( [ 'status' => false, 'msg' => esc_html__( 'Immobile tolto da evidenza', 'opalestate-pro' ) ] );
wp_die();
} else {
update_post_meta( $property_id, OPALESTATE_PROPERTY_PREFIX . 'featured', 'on' ); update_post_meta( $property_id, OPALESTATE_PROPERTY_PREFIX . 'featured', 'on' );
echo json_encode( [ 'status' => true, 'msg' => esc_html__( 'Could not set this as featured', 'opalestate-pro' ) ] ); echo json_encode( [ 'status' => false, 'msg' => esc_html__( 'Immobile messo in evidenza', 'opalestate-pro' ) ] );
wp_die(); wp_die();
} }
} }