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
1 changed files with 10 additions and 7 deletions

View File

@ -208,13 +208,16 @@ function opalestate_toggle_featured_property() {
if ( $post->post_author == $user_id ) {
$check = apply_filters( 'opalestate_set_feature_property_checked', false );
if ( $check ) {
do_action( 'opalestate_toggle_featured_property_before', $user_id, $property_id );
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' ) ] );
wp_die();
}
$isfeatured = get_post_meta( $property_id, OPALESTATE_PROPERTY_PREFIX . 'featured', true );
if( $isfeatured ) {
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' );
echo json_encode( [ 'status' => false, 'msg' => esc_html__( 'Immobile messo in evidenza', 'opalestate-pro' ) ] );
wp_die();
}
}
echo json_encode( [ 'status' => false, 'msg' => esc_html__( 'Could not set this as featured', 'opalestate-pro' ) ] );