getPrefixedThemePostMetaName( 'cta_data_nonce' ) ] ) ) { return; } if ( ! wp_verify_nonce( $_POST[ ace()->getPrefixedThemePostMetaName( 'cta_data_nonce' ) ], ace()->getPrefixedThemePostMetaName( 'save_to_cta_data' ) ) ) { return; } if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } if ( isset( $_POST['post_type'] ) && 'ace-cta' === $_POST['post_type'] ) { if ( ! current_user_can( 'edit_page', $post_id ) ) { return; } } else { if ( ! current_user_can( 'edit_post', $post_id ) ) { return; } } if ( ! isset( $_POST[ ace()->getPrefixedThemePostMetaName( 'for_cta' ) ] ) ) { return; } $for_cta = $_POST[ ace()->getPrefixedThemePostMetaName( 'for_cta' ) ]; if ( ! is_array( $for_cta ) || 0 >= count( $for_cta ) ) { return; } // Update $saved_data = []; if ( ! is_array( $for_cta ) || 0 >= count( $for_cta ) ) { return; } foreach ( $for_cta as $key => $value ) { if ( in_array( $key, array( 'title', 'hide_title', 'button' ) ) ) { $saved_data[ $key ] = sanitize_text_field( $value ); } elseif ( in_array( $key, array( 'description' ) ) ) { $saved_data[ $key ] = sanitize_text_field( $value ); } elseif ( in_array( $key, array( 'link' ) ) ) { $saved_data[ $key ] = esc_url( $value ); } } $saved_data = wp_parse_args( $saved_data, array( 'title' => '', 'hide_title' => '', 'description' => '', 'button' => '', 'link' => '', ) ); $saved_data = json_encode( $saved_data, JSON_UNESCAPED_UNICODE ); update_post_meta( $post_id, ace()->getPrefixedThemePostMetaName( 'for_cta' ), $saved_data );