| @@ -396,11 +396,9 @@ | ||
| 396 | 396 | $array_value = array(); |
| 397 | 397 | foreach ( $value as $v ) { |
| 398 | 398 | if ( ! empty( $v ) ) { |
| 399 | 399 | $data = $this->uwp_array_search( $option_values_arr, 'value', $v ); |
| 400 | - if ( ! empty( $data ) && isset( $data[0]['label'] ) ) { | |
| 401 | - $array_value[] = $data[0]['label']; | |
| 402 | - } | |
| 400 | + $array_value[] = $data[0]['label']; | |
| 403 | 401 | } |
| 404 | 402 | |
| 405 | 403 | } |
| 406 | 404 | if ( ! empty( $array_value ) ) { |
| @@ -1154,9 +1152,9 @@ | ||
| 1154 | 1152 | * @return string |
| 1155 | 1153 | */ |
| 1156 | 1154 | public function profile_slug( $slug = 'profile' ) { |
| 1157 | 1155 | if ( $page_id = uwp_get_page_id( 'profile_page', false ) ) { |
| 1158 | - if ( $_slug = get_page_uri( absint( $page_id ) ) ) { | |
| 1156 | + if ( $_slug = get_post_field( 'post_name', absint( $page_id ) ) ) { | |
| 1159 | 1157 | $slug = $_slug; |
| 1160 | 1158 | } |
| 1161 | 1159 | } |
| 1162 | 1160 | return apply_filters( 'uwp_rewrite_profile_slug', $slug ); |
| @@ -1510,19 +1508,10 @@ | ||
| 1510 | 1508 | * @package userswp |
| 1511 | 1509 | * @return void |
| 1512 | 1510 | */ |
| 1513 | 1511 | public function ajax_avatar_banner_upload() { |
| 1514 | - | |
| 1515 | - if ( ! isset( $_POST['security'] ) || ! wp_verify_nonce( $_POST['security'], 'uwp_avatar_banner_upload_nonce' ) ) { | |
| 1516 | - $result['error'] = aui()->alert( array( | |
| 1517 | - 'type' => 'danger', | |
| 1518 | - 'content' => __( "Security check failed.", "userswp" ) | |
| 1519 | - ) ); | |
| 1520 | - $return = json_encode( $result ); | |
| 1521 | - echo $return; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 1522 | - die(); | |
| 1523 | - } | |
| 1524 | - | |
| 1512 | + // Image upload handler | |
| 1513 | + // todo: security checks | |
| 1525 | 1514 | $type = strip_tags( esc_sql( $_POST['uwp_popup_type'] ) ); |
| 1526 | 1515 | $result = array(); |
| 1527 | 1516 | |
| 1528 | 1517 | if ( ! in_array( $type, array( 'banner', 'avatar' ) ) ) { |
| @@ -1762,16 +1751,8 @@ | ||
| 1762 | 1751 | * @return string Html. |
| 1763 | 1752 | */ |
| 1764 | 1753 | public function crop_submit_form( $type = 'avatar' ) { |
| 1765 | 1754 | |
| 1766 | - if ( is_admin() && defined( 'IS_PROFILE_PAGE' ) && IS_PROFILE_PAGE ) { | |
| 1767 | - $user_id = get_current_user_id(); | |
| 1768 | - } elseif ( is_admin() && current_user_can( 'manage_options' ) && ! empty( $_GET['user_id'] ) && is_numeric( $_GET['user_id'] ) ) { | |
| 1769 | - $user_id = absint( $_GET['user_id'] ); | |
| 1770 | - } else { | |
| 1771 | - $user_id = get_current_user_id(); | |
| 1772 | - } | |
| 1773 | - | |
| 1774 | 1755 | ob_start(); |
| 1775 | 1756 | |
| 1776 | 1757 | // get file sizes |
| 1777 | 1758 | $files = new UsersWP_Files(); |
| @@ -1778,14 +1759,12 @@ | ||
| 1778 | 1759 | $max_file_size = $files->uwp_get_max_upload_size( $type ); |
| 1779 | 1760 | |
| 1780 | 1761 | $design_style = uwp_get_option( "design_style", 'bootstrap' ); |
| 1781 | 1762 | $template = $design_style ? $design_style . "/modal-profile-image.php" : "modal-profile-image.php"; |
| 1782 | - uwp_get_template( $template, array( 'user_id' => $user_id ) ); | |
| 1763 | + uwp_get_template( $template ); | |
| 1783 | 1764 | |
| 1784 | 1765 | $content_wrap = $design_style == 'bootstrap' ? '.uwp-profile-image-change-modal .modal-content' : '#uwp-popup-modal-wrap'; |
| 1785 | 1766 | $bg_color = apply_filters('uwp_crop_image_bg_color', '', $type); |
| 1786 | - | |
| 1787 | - $ajax_nonce = wp_create_nonce( 'uwp_avatar_banner_upload_nonce' ); | |
| 1788 | 1767 | ?> |
| 1789 | 1768 | |
| 1790 | 1769 | <script type="text/javascript"> |
| 1791 | 1770 | (function ($, window, undefined) { |
| @@ -1825,10 +1804,8 @@ | ||
| 1825 | 1804 | fd.append('<?php echo esc_attr( $type ); ?>', file); |
| 1826 | 1805 | // our AJAX identifier |
| 1827 | 1806 | fd.append('action', 'uwp_avatar_banner_upload'); |
| 1828 | 1807 | fd.append('uwp_popup_type', '<?php echo esc_attr( $type ); ?>'); |
| 1829 | - // Add nonce for security | |
| 1830 | - fd.append('security', '<?php echo esc_js( $ajax_nonce ); ?>'); | |
| 1831 | 1808 | |
| 1832 | 1809 | $("#progressBar").show().removeClass('d-none'); |
| 1833 | 1810 | |
| 1834 | 1811 | $.ajax({ |
| @@ -1875,10 +1852,9 @@ | ||
| 1875 | 1852 | trueSize: [uwp_true_width, uwp_true_height], |
| 1876 | 1853 | minSize: [uwp_full_width, uwp_full_height] |
| 1877 | 1854 | }); |
| 1878 | 1855 | } |
| 1879 | - }, | |
| 1880 | - | |
| 1856 | + } | |
| 1881 | 1857 | }); |
| 1882 | 1858 | }); |
| 1883 | 1859 | |
| 1884 | 1860 | function showProgress(evt) { |