Changeset 61224
- Timestamp:
- 11/12/2025 02:47:59 PM (5 months ago)
- File:
-
- 1 edited
-
trunk/src/wp-admin/includes/ajax-actions.php (modified) (60 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/ajax-actions.php
r60639 r61224 216 216 if ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate' ) && function_exists( 'gzdeflate' ) && ! $force_gzip ) { 217 217 header( 'Content-Encoding: deflate' ); 218 $out = gzdeflate( $test_str, 1 );218 $output = gzdeflate( $test_str, 1 ); 219 219 } elseif ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip' ) && function_exists( 'gzencode' ) ) { 220 220 header( 'Content-Encoding: gzip' ); 221 $out = gzencode( $test_str, 1 );221 $output = gzencode( $test_str, 1 ); 222 222 } else { 223 223 wp_die( -1 ); 224 224 } 225 225 226 echo $out ;226 echo $output; 227 227 wp_die(); 228 228 } elseif ( 'no' === $_GET['test'] ) { … … 481 481 $counts = wp_count_comments(); 482 482 483 $ x= new WP_Ajax_Response(483 $response = new WP_Ajax_Response( 484 484 array( 485 485 'what' => 'comment', … … 505 505 ) 506 506 ); 507 $ x->send();507 $response->send(); 508 508 } 509 509 … … 553 553 $counts = wp_count_comments(); 554 554 555 $ x= new WP_Ajax_Response(555 $response = new WP_Ajax_Response( 556 556 array( 557 557 'what' => 'comment', … … 575 575 ) 576 576 ); 577 $ x->send();577 $response->send(); 578 578 } 579 579 … … 613 613 $popular_ids = wp_popular_terms_checklist( $taxonomy->name, 0, 10, false ); 614 614 615 foreach ( $names as $cat _name ) {616 $cat _name = trim( $cat_name );617 $category_nicename = sanitize_title( $cat _name );615 foreach ( $names as $category_name ) { 616 $category_name = trim( $category_name ); 617 $category_nicename = sanitize_title( $category_name ); 618 618 619 619 if ( '' === $category_nicename ) { … … 621 621 } 622 622 623 $cat _id = wp_insert_term( $cat_name, $taxonomy->name, array( 'parent' => $parent ) );624 625 if ( ! $cat _id || is_wp_error( $cat_id ) ) {623 $category_id = wp_insert_term( $category_name, $taxonomy->name, array( 'parent' => $parent ) ); 624 625 if ( ! $category_id || is_wp_error( $category_id ) ) { 626 626 continue; 627 627 } else { 628 $cat _id = $cat_id['term_id'];629 } 630 631 $checked_categories[] = $cat _id;628 $category_id = $category_id['term_id']; 629 } 630 631 $checked_categories[] = $category_id; 632 632 633 633 if ( $parent ) { // Do these all at once in a second. … … 641 641 array( 642 642 'taxonomy' => $taxonomy->name, 643 'descendants_and_self' => $cat _id,643 'descendants_and_self' => $category_id, 644 644 'selected_cats' => $checked_categories, 645 645 'popular_cats' => $popular_ids, … … 651 651 $add = array( 652 652 'what' => $taxonomy->name, 653 'id' => $cat _id,653 'id' => $category_id, 654 654 'data' => str_replace( array( "\n", "\t" ), '', $data ), 655 655 'position' => -1, … … 707 707 wp_dropdown_categories( $parent_dropdown_args ); 708 708 709 $sup = ob_get_clean();710 711 $add['supplemental'] = array( 'newcat_parent' => $sup );712 713 $ x= new WP_Ajax_Response( $add );714 $ x->send();709 $supplemental = ob_get_clean(); 710 711 $add['supplemental'] = array( 'newcat_parent' => $supplemental ); 712 713 $response = new WP_Ajax_Response( $add ); 714 $response->send(); 715 715 } 716 716 … … 742 742 } 743 743 744 $r = wp_trash_comment( $comment );744 $result = wp_trash_comment( $comment ); 745 745 } elseif ( isset( $_POST['untrash'] ) && '1' === $_POST['untrash'] ) { 746 746 if ( 'trash' !== $status ) { … … 748 748 } 749 749 750 $r = wp_untrash_comment( $comment );750 $result = wp_untrash_comment( $comment ); 751 751 752 752 // Undo trash, not in Trash. … … 759 759 } 760 760 761 $r = wp_spam_comment( $comment );761 $result = wp_spam_comment( $comment ); 762 762 } elseif ( isset( $_POST['unspam'] ) && '1' === $_POST['unspam'] ) { 763 763 if ( 'spam' !== $status ) { … … 765 765 } 766 766 767 $r = wp_unspam_comment( $comment );767 $result = wp_unspam_comment( $comment ); 768 768 769 769 // Undo spam, not in spam. … … 772 772 } 773 773 } elseif ( isset( $_POST['delete'] ) && '1' === $_POST['delete'] ) { 774 $r = wp_delete_comment( $comment );774 $result = wp_delete_comment( $comment ); 775 775 } else { 776 776 wp_die( -1 ); 777 777 } 778 778 779 if ( $r ) {779 if ( $result ) { 780 780 // Decide if we need to send back '1' or a more complicated response including page links and comment counts. 781 781 _wp_ajax_delete_comment_response( $comment->comment_ID, $delta ); … … 985 985 986 986 if ( ! $comment ) { 987 $ x= new WP_Ajax_Response(987 $response = new WP_Ajax_Response( 988 988 array( 989 989 'what' => 'comment', … … 995 995 ) 996 996 ); 997 $ x->send();997 $response->send(); 998 998 } 999 999 … … 1017 1017 1018 1018 if ( is_wp_error( $result ) ) { 1019 $ x= new WP_Ajax_Response(1019 $response = new WP_Ajax_Response( 1020 1020 array( 1021 1021 'what' => 'comment', … … 1023 1023 ) 1024 1024 ); 1025 $ x->send();1025 $response->send(); 1026 1026 } 1027 1027 … … 1051 1051 } 1052 1052 1053 $names = explode( ',', wp_unslash( $_POST['newcat'] ) );1054 $ x= new WP_Ajax_Response();1055 1056 foreach ( $names as $cat _name ) {1057 $cat _name = trim( $cat_name );1058 $slug = sanitize_title( $cat_name );1053 $names = explode( ',', wp_unslash( $_POST['newcat'] ) ); 1054 $response = new WP_Ajax_Response(); 1055 1056 foreach ( $names as $category_name ) { 1057 $category_name = trim( $category_name ); 1058 $slug = sanitize_title( $category_name ); 1059 1059 1060 1060 if ( '' === $slug ) { … … 1062 1062 } 1063 1063 1064 $cat _id = wp_insert_term( $cat_name, 'link_category' );1065 1066 if ( ! $cat _id || is_wp_error( $cat_id ) ) {1064 $category_id = wp_insert_term( $category_name, 'link_category' ); 1065 1066 if ( ! $category_id || is_wp_error( $category_id ) ) { 1067 1067 continue; 1068 1068 } else { 1069 $cat _id = $cat_id['term_id'];1070 } 1071 1072 $cat _name = esc_html( $cat_name );1073 1074 $ x->add(1069 $category_id = $category_id['term_id']; 1070 } 1071 1072 $category_name = esc_html( $category_name ); 1073 1074 $response->add( 1075 1075 array( 1076 1076 'what' => 'link-category', 1077 'id' => $cat _id,1078 'data' => "<li id='link-category-$cat _id'><label for='in-link-category-$cat_id' class='selectit'><input value='" . esc_attr( $cat_id ) . "' type='checkbox' checked='checked' name='link_category[]' id='in-link-category-$cat_id'/> $cat_name</label></li>",1077 'id' => $category_id, 1078 'data' => "<li id='link-category-$category_id'><label for='in-link-category-$category_id' class='selectit'><input value='" . esc_attr( $category_id ) . "' type='checkbox' checked='checked' name='link_category[]' id='in-link-category-$category_id'/> $category_name</label></li>", 1079 1079 'position' => -1, 1080 1080 ) 1081 1081 ); 1082 1082 } 1083 $x->send(); 1083 1084 $response->send(); 1084 1085 } 1085 1086 … … 1099 1100 } 1100 1101 1101 $ x= new WP_Ajax_Response();1102 $response = new WP_Ajax_Response(); 1102 1103 1103 1104 $tag = wp_insert_term( $_POST['tag-name'], $taxonomy, $_POST ); … … 1119 1120 } 1120 1121 1121 $ x->add(1122 $response->add( 1122 1123 array( 1123 1124 'what' => 'taxonomy', … … 1125 1126 ) 1126 1127 ); 1127 $ x->send();1128 $response->send(); 1128 1129 } 1129 1130 1130 1131 $wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => $_POST['screen'] ) ); 1131 1132 1132 $level = 0;1133 $no parents = '';1133 $level = 0; 1134 $no_parents = ''; 1134 1135 1135 1136 if ( is_taxonomy_hierarchical( $taxonomy ) ) { … … 1137 1138 ob_start(); 1138 1139 $wp_list_table->single_row( $tag, $level ); 1139 $no parents = ob_get_clean();1140 $no_parents = ob_get_clean(); 1140 1141 } 1141 1142 … … 1153 1154 } 1154 1155 1155 $ x->add(1156 $response->add( 1156 1157 array( 1157 1158 'what' => 'taxonomy', … … 1159 1160 'supplemental' => array( 1160 1161 'parents' => $parents, 1161 'noparents' => $no parents,1162 'noparents' => $no_parents, 1162 1163 'notice' => $message, 1163 1164 ), … … 1165 1166 ); 1166 1167 1167 $ x->add(1168 $response->add( 1168 1169 array( 1169 1170 'what' => 'term', … … 1173 1174 ); 1174 1175 1175 $ x->send();1176 $response->send(); 1176 1177 } 1177 1178 … … 1277 1278 } 1278 1279 1279 $ x= new WP_Ajax_Response();1280 $response = new WP_Ajax_Response(); 1280 1281 1281 1282 ob_start(); … … 1289 1290 $comment_list_item = ob_get_clean(); 1290 1291 1291 $ x->add(1292 $response->add( 1292 1293 array( 1293 1294 'what' => 'comments', … … 1296 1297 ); 1297 1298 1298 $ x->send();1299 $response->send(); 1299 1300 } 1300 1301 … … 1427 1428 $comment_list_item = ob_get_clean(); 1428 1429 1429 $response = array(1430 $response_data = array( 1430 1431 'what' => 'comment', 1431 1432 'id' => $comment->comment_ID, … … 1434 1435 ); 1435 1436 1436 $counts = wp_count_comments(); 1437 $response['supplemental'] = array( 1437 $counts = wp_count_comments(); 1438 1439 $response_data['supplemental'] = array( 1438 1440 'in_moderation' => $counts->moderated, 1439 1441 'i18n_comments_text' => sprintf( … … 1450 1452 1451 1453 if ( $comment_auto_approved ) { 1452 $response ['supplemental']['parent_approved'] = $parent->comment_ID;1453 $response ['supplemental']['parent_post_id'] = $parent->comment_post_ID;1454 } 1455 1456 $ x= new WP_Ajax_Response();1457 $ x->add( $response);1458 $ x->send();1454 $response_data['supplemental']['parent_approved'] = $parent->comment_ID; 1455 $response_data['supplemental']['parent_post_id'] = $parent->comment_post_ID; 1456 } 1457 1458 $response = new WP_Ajax_Response(); 1459 $response->add( $response_data ); 1460 $response->send(); 1459 1461 } 1460 1462 … … 1504 1506 $comment_list_item = ob_get_clean(); 1505 1507 1506 $ x= new WP_Ajax_Response();1507 1508 $ x->add(1508 $response = new WP_Ajax_Response(); 1509 1510 $response->add( 1509 1511 array( 1510 1512 'what' => 'edit_comment', … … 1515 1517 ); 1516 1518 1517 $ x->send();1519 $response->send(); 1518 1520 } 1519 1521 … … 1576 1578 1577 1579 foreach ( (array) $item_ids as $menu_item_id ) { 1578 $menu_obj = get_post( $menu_item_id );1579 1580 if ( ! empty( $menu_obj ->ID ) ) {1581 $menu_obj = wp_setup_nav_menu_item( $menu_obj);1582 $menu_obj ->title = empty( $menu_obj->title ) ? __( 'Menu Item' ) : $menu_obj->title;1583 $menu_obj ->label = $menu_obj->title; // Don't show "(pending)" in ajax-added items.1584 $menu_items[] = $menu_obj;1580 $menu_object = get_post( $menu_item_id ); 1581 1582 if ( ! empty( $menu_object->ID ) ) { 1583 $menu_object = wp_setup_nav_menu_item( $menu_object ); 1584 $menu_object->title = empty( $menu_object->title ) ? __( 'Menu Item' ) : $menu_object->title; 1585 $menu_object->label = $menu_object->title; // Don't show "(pending)" in ajax-added items. 1586 $menu_items[] = $menu_object; 1585 1587 } 1586 1588 } … … 1615 1617 function wp_ajax_add_meta() { 1616 1618 check_ajax_referer( 'add-meta', '_ajax_nonce-add-meta' ); 1617 $c = 0;1618 $p id= (int) $_POST['post_id'];1619 $post = get_post( $pid );1619 $count = 0; 1620 $post_id = (int) $_POST['post_id']; 1621 $post = get_post( $post_id ); 1620 1622 1621 1623 if ( isset( $_POST['metakeyselect'] ) || isset( $_POST['metakeyinput'] ) ) { 1622 if ( ! current_user_can( 'edit_post', $p id ) ) {1624 if ( ! current_user_can( 'edit_post', $post_id ) ) { 1623 1625 wp_die( -1 ); 1624 1626 } … … 1632 1634 $post_data = array(); 1633 1635 $post_data['action'] = 'draft'; // Warning fix. 1634 $post_data['post_ID'] = $p id;1636 $post_data['post_ID'] = $post_id; 1635 1637 $post_data['post_type'] = $post->post_type; 1636 1638 $post_data['post_status'] = 'draft'; … … 1644 1646 ); 1645 1647 1646 $p id = edit_post( $post_data );1647 1648 if ( $p id ) {1649 if ( is_wp_error( $p id ) ) {1650 $ x= new WP_Ajax_Response(1648 $post_id = edit_post( $post_data ); 1649 1650 if ( $post_id ) { 1651 if ( is_wp_error( $post_id ) ) { 1652 $response = new WP_Ajax_Response( 1651 1653 array( 1652 1654 'what' => 'meta', 1653 'data' => $p id,1655 'data' => $post_id, 1654 1656 ) 1655 1657 ); 1656 $ x->send();1658 $response->send(); 1657 1659 } 1658 1660 1659 $mid = add_meta( $pid ); 1660 if ( ! $mid ) { 1661 $meta_id = add_meta( $post_id ); 1662 1663 if ( ! $meta_id ) { 1661 1664 wp_die( __( 'Please provide a custom field value.' ) ); 1662 1665 } … … 1665 1668 } 1666 1669 } else { 1667 $mid = add_meta( $pid ); 1668 if ( ! $mid ) { 1670 $meta_id = add_meta( $post_id ); 1671 1672 if ( ! $meta_id ) { 1669 1673 wp_die( __( 'Please provide a custom field value.' ) ); 1670 1674 } 1671 1675 } 1672 1676 1673 $meta = get_metadata_by_mid( 'post', $mid );1674 $p id= (int) $meta->post_id;1675 $meta = get_object_vars( $meta );1676 1677 $ x= new WP_Ajax_Response(1677 $meta = get_metadata_by_mid( 'post', $meta_id ); 1678 $post_id = (int) $meta->post_id; 1679 $meta = get_object_vars( $meta ); 1680 1681 $response = new WP_Ajax_Response( 1678 1682 array( 1679 1683 'what' => 'meta', 1680 'id' => $m id,1681 'data' => _list_meta_row( $meta, $c ),1684 'id' => $meta_id, 1685 'data' => _list_meta_row( $meta, $count ), 1682 1686 'position' => 1, 1683 'supplemental' => array( 'postid' => $p id ),1687 'supplemental' => array( 'postid' => $post_id ), 1684 1688 ) 1685 1689 ); 1686 1690 } else { // Update? 1687 $m id= (int) key( $_POST['meta'] );1688 $key = wp_unslash( $_POST['meta'][ $mid ]['key'] );1689 $value = wp_unslash( $_POST['meta'][ $mid ]['value'] );1691 $meta_id = (int) key( $_POST['meta'] ); 1692 $key = wp_unslash( $_POST['meta'][ $meta_id ]['key'] ); 1693 $value = wp_unslash( $_POST['meta'][ $meta_id ]['value'] ); 1690 1694 1691 1695 if ( '' === trim( $key ) ) { … … 1693 1697 } 1694 1698 1695 $meta = get_metadata_by_mid( 'post', $m id );1699 $meta = get_metadata_by_mid( 'post', $meta_id ); 1696 1700 1697 1701 if ( ! $meta ) { … … 1708 1712 1709 1713 if ( $meta->meta_value !== $value || $meta->meta_key !== $key ) { 1710 $u = update_metadata_by_mid( 'post', $mid, $value, $key ); 1711 if ( ! $u ) { 1714 $update_result = update_metadata_by_mid( 'post', $meta_id, $value, $key ); 1715 1716 if ( ! $update_result ) { 1712 1717 wp_die( 0 ); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems). 1713 1718 } 1714 1719 } 1715 1720 1716 $ x= new WP_Ajax_Response(1721 $response = new WP_Ajax_Response( 1717 1722 array( 1718 1723 'what' => 'meta', 1719 'id' => $m id,1720 'old_id' => $m id,1724 'id' => $meta_id, 1725 'old_id' => $meta_id, 1721 1726 'data' => _list_meta_row( 1722 1727 array( 1723 1728 'meta_key' => $key, 1724 1729 'meta_value' => $value, 1725 'meta_id' => $m id,1730 'meta_id' => $meta_id, 1726 1731 ), 1727 1732 $c … … 1732 1737 ); 1733 1738 } 1734 $x->send(); 1739 1740 $response->send(); 1735 1741 } 1736 1742 … … 1758 1764 wp_die( 0 ); 1759 1765 } elseif ( is_wp_error( $user_id ) ) { 1760 $ x= new WP_Ajax_Response(1766 $response = new WP_Ajax_Response( 1761 1767 array( 1762 1768 'what' => 'user', … … 1764 1770 ) 1765 1771 ); 1766 $ x->send();1772 $response->send(); 1767 1773 } 1768 1774 … … 1772 1778 $role = current( $user_object->roles ); 1773 1779 1774 $ x= new WP_Ajax_Response(1780 $response = new WP_Ajax_Response( 1775 1781 array( 1776 1782 'what' => 'user', … … 1787 1793 ) 1788 1794 ); 1789 $ x->send();1795 $response->send(); 1790 1796 } 1791 1797 … … 2081 2087 2082 2088 $last = wp_check_post_lock( $post_id ); 2089 2083 2090 if ( $last ) { 2084 2091 $last_user = get_userdata( $last ); … … 2262 2269 } 2263 2270 2264 $html = '<table class="widefat"><thead><tr><th class="found-radio"><br /></th><th>' . __( 'Title' ) . '</th><th class="no-break">' . __( 'Type' ) . '</th><th class="no-break">' . __( 'Date' ) . '</th><th class="no-break">' . __( 'Status' ) . '</th></tr></thead><tbody>';2265 $alt = '';2271 $html = '<table class="widefat"><thead><tr><th class="found-radio"><br /></th><th>' . __( 'Title' ) . '</th><th class="no-break">' . __( 'Type' ) . '</th><th class="no-break">' . __( 'Date' ) . '</th><th class="no-break">' . __( 'Status' ) . '</th></tr></thead><tbody>'; 2272 $alternate = ''; 2266 2273 foreach ( $posts as $post ) { 2267 $title = trim( $post->post_title ) ? $post->post_title : __( '(no title)' );2268 $alt = ( 'alternate' === $alt) ? '' : 'alternate';2274 $title = trim( $post->post_title ) ? $post->post_title : __( '(no title)' ); 2275 $alternate = ( 'alternate' === $alternate ) ? '' : 'alternate'; 2269 2276 2270 2277 switch ( $post->post_status ) { … … 2291 2298 } 2292 2299 2293 $html .= '<tr class="' . trim( 'found-posts ' . $alt ) . '"><td class="found-radio"><input type="radio" id="found-' . $post->ID . '" name="found_post_id" value="' . esc_attr( $post->ID ) . '"></td>';2300 $html .= '<tr class="' . trim( 'found-posts ' . $alternate ) . '"><td class="found-radio"><input type="radio" id="found-' . $post->ID . '" name="found_post_id" value="' . esc_attr( $post->ID ) . '"></td>'; 2294 2301 $html .= '<td><label for="found-' . $post->ID . '">' . esc_html( $title ) . '</label></td><td class="no-break">' . esc_html( $post_types[ $post->post_type ]->labels->singular_name ) . '</td><td class="no-break">' . esc_html( $time ) . '</td><td class="no-break">' . esc_html( $stat ) . ' </td></tr>' . "\n\n"; 2295 2302 } … … 2319 2326 2320 2327 foreach ( wp_unslash( $_POST['sidebars'] ) as $key => $val ) { 2321 $s b= array();2328 $sidebar = array(); 2322 2329 2323 2330 if ( ! empty( $val ) ) { … … 2329 2336 } 2330 2337 2331 $s b[ $k ] = substr( $v, strpos( $v, '_' ) + 1 );2338 $sidebar[ $k ] = substr( $v, strpos( $v, '_' ) + 1 ); 2332 2339 } 2333 2340 } 2334 $sidebars[ $key ] = $s b;2341 $sidebars[ $key ] = $sidebar; 2335 2342 } 2336 2343 … … 2689 2696 require_once ABSPATH . 'wp-admin/includes/image-edit.php'; 2690 2697 2691 $m sg= false;2698 $message = false; 2692 2699 2693 2700 switch ( $_POST['do'] ) { 2694 2701 case 'save': 2695 $m sg= wp_save_image( $attachment_id );2696 if ( ! empty( $m sg->error ) ) {2697 wp_send_json_error( $m sg);2702 $message = wp_save_image( $attachment_id ); 2703 if ( ! empty( $message->error ) ) { 2704 wp_send_json_error( $message ); 2698 2705 } 2699 2706 2700 wp_send_json_success( $m sg);2707 wp_send_json_success( $message ); 2701 2708 break; 2702 2709 case 'scale': 2703 $m sg= wp_save_image( $attachment_id );2710 $message = wp_save_image( $attachment_id ); 2704 2711 break; 2705 2712 case 'restore': 2706 $m sg= wp_restore_image( $attachment_id );2713 $message = wp_restore_image( $attachment_id ); 2707 2714 break; 2708 2715 } 2709 2716 2710 2717 ob_start(); 2711 wp_image_editor( $attachment_id, $m sg);2718 wp_image_editor( $attachment_id, $message ); 2712 2719 $html = ob_get_clean(); 2713 2720 2714 if ( ! empty( $m sg->error ) ) {2721 if ( ! empty( $message->error ) ) { 2715 2722 wp_send_json_error( 2716 2723 array( 2717 'message' => $m sg,2724 'message' => $message, 2718 2725 'html' => $html, 2719 2726 ) … … 2723 2730 wp_send_json_success( 2724 2731 array( 2725 'message' => $m sg,2732 'message' => $message, 2726 2733 'html' => $html, 2727 2734 ) … … 3040 3047 ); 3041 3048 3042 foreach ( get_taxonomies_for_attachments( 'objects' ) as $t ) {3043 if ( $t ->query_var && isset( $query[ $t->query_var ] ) ) {3044 $keys[] = $t ->query_var;3049 foreach ( get_taxonomies_for_attachments( 'objects' ) as $taxonomy ) { 3050 if ( $taxonomy->query_var && isset( $query[ $taxonomy->query_var ] ) ) { 3051 $keys[] = $taxonomy->query_var; 3045 3052 } 3046 3053 } … … 3162 3169 3163 3170 if ( wp_attachment_is( 'audio', $post['ID'] ) ) { 3164 $changed = false;3165 $id3 data = wp_get_attachment_metadata( $post['ID'] );3166 3167 if ( ! is_array( $id3 data ) ) {3168 $changed = true;3169 $id3 data = array();3171 $changed = false; 3172 $id3_data = wp_get_attachment_metadata( $post['ID'] ); 3173 3174 if ( ! is_array( $id3_data ) ) { 3175 $changed = true; 3176 $id3_data = array(); 3170 3177 } 3171 3178 3172 3179 foreach ( wp_get_attachment_id3_keys( (object) $post, 'edit' ) as $key => $label ) { 3173 3180 if ( isset( $changes[ $key ] ) ) { 3174 $changed = true;3175 $id3 data[ $key ] = sanitize_text_field( wp_unslash( $changes[ $key ] ) );3181 $changed = true; 3182 $id3_data[ $key ] = sanitize_text_field( wp_unslash( $changes[ $key ] ) ); 3176 3183 } 3177 3184 } 3178 3185 3179 3186 if ( $changed ) { 3180 wp_update_attachment_metadata( $id, $id3 data );3187 wp_update_attachment_metadata( $id, $id3_data ); 3181 3188 } 3182 3189 } … … 3433 3440 3434 3441 // Figure out what filter to run: 3435 $type = 'file';3436 $ext = preg_replace( '/^.+?\.([^.]+)$/', '$1', $src );3437 if ( $ext ) {3438 $ext _type = wp_ext2type( $ext);3439 if ( 'audio' === $ext _type || 'video' === $ext_type ) {3440 $type = $ext _type;3442 $type = 'file'; 3443 $extension = preg_replace( '/^.+?\.([^.]+)$/', '$1', $src ); 3444 if ( $extension ) { 3445 $extension_type = wp_ext2type( $extension ); 3446 if ( 'audio' === $extension_type || 'video' === $extension_type ) { 3447 $type = $extension_type; 3441 3448 } 3442 3449 } … … 4900 4907 */ 4901 4908 function wp_ajax_edit_theme_plugin_file() { 4902 $ r= wp_edit_theme_plugin_file( wp_unslash( $_POST ) ); // Validation of args is done in wp_edit_theme_plugin_file().4903 4904 if ( is_wp_error( $ r) ) {4909 $edit_result = wp_edit_theme_plugin_file( wp_unslash( $_POST ) ); // Validation of args is done in wp_edit_theme_plugin_file(). 4910 4911 if ( is_wp_error( $edit_result ) ) { 4905 4912 wp_send_json_error( 4906 4913 array_merge( 4907 4914 array( 4908 'code' => $ r->get_error_code(),4909 'message' => $ r->get_error_message(),4915 'code' => $edit_result->get_error_code(), 4916 'message' => $edit_result->get_error_message(), 4910 4917 ), 4911 (array) $ r->get_error_data()4918 (array) $edit_result->get_error_data() 4912 4919 ) 4913 4920 );
Note: See TracChangeset
for help on using the changeset viewer.