Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-inclu...
File: class-wp-xmlrpc-server.php
} else {
[1500] Fix | Delete
$post_data['post_author'] = $user->ID;
[1501] Fix | Delete
}
[1502] Fix | Delete
[1503] Fix | Delete
if ( 'open' !== $post_data['comment_status'] && 'closed' !== $post_data['comment_status'] ) {
[1504] Fix | Delete
unset( $post_data['comment_status'] );
[1505] Fix | Delete
}
[1506] Fix | Delete
[1507] Fix | Delete
if ( 'open' !== $post_data['ping_status'] && 'closed' !== $post_data['ping_status'] ) {
[1508] Fix | Delete
unset( $post_data['ping_status'] );
[1509] Fix | Delete
}
[1510] Fix | Delete
[1511] Fix | Delete
// Do some timestamp voodoo.
[1512] Fix | Delete
if ( ! empty( $post_data['post_date_gmt'] ) ) {
[1513] Fix | Delete
// We know this is supposed to be GMT, so we're going to slap that Z on there by force.
[1514] Fix | Delete
$dateCreated = rtrim( $post_data['post_date_gmt']->getIso(), 'Z' ) . 'Z';
[1515] Fix | Delete
} elseif ( ! empty( $post_data['post_date'] ) ) {
[1516] Fix | Delete
$dateCreated = $post_data['post_date']->getIso();
[1517] Fix | Delete
}
[1518] Fix | Delete
[1519] Fix | Delete
// Default to not flagging the post date to be edited unless it's intentional.
[1520] Fix | Delete
$post_data['edit_date'] = false;
[1521] Fix | Delete
[1522] Fix | Delete
if ( ! empty( $dateCreated ) ) {
[1523] Fix | Delete
$post_data['post_date'] = iso8601_to_datetime( $dateCreated );
[1524] Fix | Delete
$post_data['post_date_gmt'] = iso8601_to_datetime( $dateCreated, 'gmt' );
[1525] Fix | Delete
[1526] Fix | Delete
// Flag the post date to be edited.
[1527] Fix | Delete
$post_data['edit_date'] = true;
[1528] Fix | Delete
}
[1529] Fix | Delete
[1530] Fix | Delete
if ( ! isset( $post_data['ID'] ) ) {
[1531] Fix | Delete
$post_data['ID'] = get_default_post_to_edit( $post_data['post_type'], true )->ID;
[1532] Fix | Delete
}
[1533] Fix | Delete
$post_id = $post_data['ID'];
[1534] Fix | Delete
[1535] Fix | Delete
if ( 'post' === $post_data['post_type'] ) {
[1536] Fix | Delete
$error = $this->_toggle_sticky( $post_data, $update );
[1537] Fix | Delete
if ( $error ) {
[1538] Fix | Delete
return $error;
[1539] Fix | Delete
}
[1540] Fix | Delete
}
[1541] Fix | Delete
[1542] Fix | Delete
if ( isset( $post_data['post_thumbnail'] ) ) {
[1543] Fix | Delete
// Empty value deletes, non-empty value adds/updates.
[1544] Fix | Delete
if ( ! $post_data['post_thumbnail'] ) {
[1545] Fix | Delete
delete_post_thumbnail( $post_id );
[1546] Fix | Delete
} elseif ( ! get_post( absint( $post_data['post_thumbnail'] ) ) ) {
[1547] Fix | Delete
return new IXR_Error( 404, __( 'Invalid attachment ID.' ) );
[1548] Fix | Delete
}
[1549] Fix | Delete
set_post_thumbnail( $post_id, $post_data['post_thumbnail'] );
[1550] Fix | Delete
unset( $content_struct['post_thumbnail'] );
[1551] Fix | Delete
}
[1552] Fix | Delete
[1553] Fix | Delete
if ( isset( $post_data['custom_fields'] ) ) {
[1554] Fix | Delete
$this->set_custom_fields( $post_id, $post_data['custom_fields'] );
[1555] Fix | Delete
}
[1556] Fix | Delete
[1557] Fix | Delete
if ( isset( $post_data['terms'] ) || isset( $post_data['terms_names'] ) ) {
[1558] Fix | Delete
$post_type_taxonomies = get_object_taxonomies( $post_data['post_type'], 'objects' );
[1559] Fix | Delete
[1560] Fix | Delete
// Accumulate term IDs from terms and terms_names.
[1561] Fix | Delete
$terms = array();
[1562] Fix | Delete
[1563] Fix | Delete
// First validate the terms specified by ID.
[1564] Fix | Delete
if ( isset( $post_data['terms'] ) && is_array( $post_data['terms'] ) ) {
[1565] Fix | Delete
$taxonomies = array_keys( $post_data['terms'] );
[1566] Fix | Delete
[1567] Fix | Delete
// Validating term IDs.
[1568] Fix | Delete
foreach ( $taxonomies as $taxonomy ) {
[1569] Fix | Delete
if ( ! array_key_exists( $taxonomy, $post_type_taxonomies ) ) {
[1570] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, one of the given taxonomies is not supported by the post type.' ) );
[1571] Fix | Delete
}
[1572] Fix | Delete
[1573] Fix | Delete
if ( ! current_user_can( $post_type_taxonomies[ $taxonomy ]->cap->assign_terms ) ) {
[1574] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign a term to one of the given taxonomies.' ) );
[1575] Fix | Delete
}
[1576] Fix | Delete
[1577] Fix | Delete
$term_ids = $post_data['terms'][ $taxonomy ];
[1578] Fix | Delete
$terms[ $taxonomy ] = array();
[1579] Fix | Delete
foreach ( $term_ids as $term_id ) {
[1580] Fix | Delete
$term = get_term_by( 'id', $term_id, $taxonomy );
[1581] Fix | Delete
[1582] Fix | Delete
if ( ! $term ) {
[1583] Fix | Delete
return new IXR_Error( 403, __( 'Invalid term ID.' ) );
[1584] Fix | Delete
}
[1585] Fix | Delete
[1586] Fix | Delete
$terms[ $taxonomy ][] = (int) $term_id;
[1587] Fix | Delete
}
[1588] Fix | Delete
}
[1589] Fix | Delete
}
[1590] Fix | Delete
[1591] Fix | Delete
// Now validate terms specified by name.
[1592] Fix | Delete
if ( isset( $post_data['terms_names'] ) && is_array( $post_data['terms_names'] ) ) {
[1593] Fix | Delete
$taxonomies = array_keys( $post_data['terms_names'] );
[1594] Fix | Delete
[1595] Fix | Delete
foreach ( $taxonomies as $taxonomy ) {
[1596] Fix | Delete
if ( ! array_key_exists( $taxonomy, $post_type_taxonomies ) ) {
[1597] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, one of the given taxonomies is not supported by the post type.' ) );
[1598] Fix | Delete
}
[1599] Fix | Delete
[1600] Fix | Delete
if ( ! current_user_can( $post_type_taxonomies[ $taxonomy ]->cap->assign_terms ) ) {
[1601] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign a term to one of the given taxonomies.' ) );
[1602] Fix | Delete
}
[1603] Fix | Delete
[1604] Fix | Delete
/*
[1605] Fix | Delete
* For hierarchical taxonomies, we can't assign a term when multiple terms
[1606] Fix | Delete
* in the hierarchy share the same name.
[1607] Fix | Delete
*/
[1608] Fix | Delete
$ambiguous_terms = array();
[1609] Fix | Delete
if ( is_taxonomy_hierarchical( $taxonomy ) ) {
[1610] Fix | Delete
$tax_term_names = get_terms(
[1611] Fix | Delete
array(
[1612] Fix | Delete
'taxonomy' => $taxonomy,
[1613] Fix | Delete
'fields' => 'names',
[1614] Fix | Delete
'hide_empty' => false,
[1615] Fix | Delete
)
[1616] Fix | Delete
);
[1617] Fix | Delete
[1618] Fix | Delete
// Count the number of terms with the same name.
[1619] Fix | Delete
$tax_term_names_count = array_count_values( $tax_term_names );
[1620] Fix | Delete
[1621] Fix | Delete
// Filter out non-ambiguous term names.
[1622] Fix | Delete
$ambiguous_tax_term_counts = array_filter( $tax_term_names_count, array( $this, '_is_greater_than_one' ) );
[1623] Fix | Delete
[1624] Fix | Delete
$ambiguous_terms = array_keys( $ambiguous_tax_term_counts );
[1625] Fix | Delete
}
[1626] Fix | Delete
[1627] Fix | Delete
$term_names = $post_data['terms_names'][ $taxonomy ];
[1628] Fix | Delete
foreach ( $term_names as $term_name ) {
[1629] Fix | Delete
if ( in_array( $term_name, $ambiguous_terms, true ) ) {
[1630] Fix | Delete
return new IXR_Error( 401, __( 'Ambiguous term name used in a hierarchical taxonomy. Please use term ID instead.' ) );
[1631] Fix | Delete
}
[1632] Fix | Delete
[1633] Fix | Delete
$term = get_term_by( 'name', $term_name, $taxonomy );
[1634] Fix | Delete
[1635] Fix | Delete
if ( ! $term ) {
[1636] Fix | Delete
// Term doesn't exist, so check that the user is allowed to create new terms.
[1637] Fix | Delete
if ( ! current_user_can( $post_type_taxonomies[ $taxonomy ]->cap->edit_terms ) ) {
[1638] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, you are not allowed to add a term to one of the given taxonomies.' ) );
[1639] Fix | Delete
}
[1640] Fix | Delete
[1641] Fix | Delete
// Create the new term.
[1642] Fix | Delete
$term_info = wp_insert_term( $term_name, $taxonomy );
[1643] Fix | Delete
if ( is_wp_error( $term_info ) ) {
[1644] Fix | Delete
return new IXR_Error( 500, $term_info->get_error_message() );
[1645] Fix | Delete
}
[1646] Fix | Delete
[1647] Fix | Delete
$terms[ $taxonomy ][] = (int) $term_info['term_id'];
[1648] Fix | Delete
} else {
[1649] Fix | Delete
$terms[ $taxonomy ][] = (int) $term->term_id;
[1650] Fix | Delete
}
[1651] Fix | Delete
}
[1652] Fix | Delete
}
[1653] Fix | Delete
}
[1654] Fix | Delete
[1655] Fix | Delete
$post_data['tax_input'] = $terms;
[1656] Fix | Delete
unset( $post_data['terms'], $post_data['terms_names'] );
[1657] Fix | Delete
}
[1658] Fix | Delete
[1659] Fix | Delete
if ( isset( $post_data['post_format'] ) ) {
[1660] Fix | Delete
$format = set_post_format( $post_id, $post_data['post_format'] );
[1661] Fix | Delete
[1662] Fix | Delete
if ( is_wp_error( $format ) ) {
[1663] Fix | Delete
return new IXR_Error( 500, $format->get_error_message() );
[1664] Fix | Delete
}
[1665] Fix | Delete
[1666] Fix | Delete
unset( $post_data['post_format'] );
[1667] Fix | Delete
}
[1668] Fix | Delete
[1669] Fix | Delete
// Handle enclosures.
[1670] Fix | Delete
$enclosure = isset( $post_data['enclosure'] ) ? $post_data['enclosure'] : null;
[1671] Fix | Delete
$this->add_enclosure_if_new( $post_id, $enclosure );
[1672] Fix | Delete
[1673] Fix | Delete
$this->attach_uploads( $post_id, $post_data['post_content'] );
[1674] Fix | Delete
[1675] Fix | Delete
/**
[1676] Fix | Delete
* Filters post data array to be inserted via XML-RPC.
[1677] Fix | Delete
*
[1678] Fix | Delete
* @since 3.4.0
[1679] Fix | Delete
*
[1680] Fix | Delete
* @param array $post_data Parsed array of post data.
[1681] Fix | Delete
* @param array $content_struct Post data array.
[1682] Fix | Delete
*/
[1683] Fix | Delete
$post_data = apply_filters( 'xmlrpc_wp_insert_post_data', $post_data, $content_struct );
[1684] Fix | Delete
[1685] Fix | Delete
// Remove all null values to allow for using the insert/update post default values for those keys instead.
[1686] Fix | Delete
$post_data = array_filter(
[1687] Fix | Delete
$post_data,
[1688] Fix | Delete
static function ( $value ) {
[1689] Fix | Delete
return null !== $value;
[1690] Fix | Delete
}
[1691] Fix | Delete
);
[1692] Fix | Delete
[1693] Fix | Delete
$post_id = $update ? wp_update_post( $post_data, true ) : wp_insert_post( $post_data, true );
[1694] Fix | Delete
if ( is_wp_error( $post_id ) ) {
[1695] Fix | Delete
return new IXR_Error( 500, $post_id->get_error_message() );
[1696] Fix | Delete
}
[1697] Fix | Delete
[1698] Fix | Delete
if ( ! $post_id ) {
[1699] Fix | Delete
if ( $update ) {
[1700] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, the post could not be updated.' ) );
[1701] Fix | Delete
} else {
[1702] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, the post could not be created.' ) );
[1703] Fix | Delete
}
[1704] Fix | Delete
}
[1705] Fix | Delete
[1706] Fix | Delete
return (string) $post_id;
[1707] Fix | Delete
}
[1708] Fix | Delete
[1709] Fix | Delete
/**
[1710] Fix | Delete
* Edits a post for any registered post type.
[1711] Fix | Delete
*
[1712] Fix | Delete
* The $content_struct parameter only needs to contain fields that
[1713] Fix | Delete
* should be changed. All other fields will retain their existing values.
[1714] Fix | Delete
*
[1715] Fix | Delete
* @since 3.4.0
[1716] Fix | Delete
*
[1717] Fix | Delete
* @param array $args {
[1718] Fix | Delete
* Method arguments. Note: arguments must be ordered as documented.
[1719] Fix | Delete
*
[1720] Fix | Delete
* @type int $0 Blog ID (unused).
[1721] Fix | Delete
* @type string $1 Username.
[1722] Fix | Delete
* @type string $2 Password.
[1723] Fix | Delete
* @type int $3 Post ID.
[1724] Fix | Delete
* @type array $4 Extra content arguments.
[1725] Fix | Delete
* }
[1726] Fix | Delete
* @return true|IXR_Error True on success, IXR_Error on failure.
[1727] Fix | Delete
*/
[1728] Fix | Delete
public function wp_editPost( $args ) {
[1729] Fix | Delete
if ( ! $this->minimum_args( $args, 5 ) ) {
[1730] Fix | Delete
return $this->error;
[1731] Fix | Delete
}
[1732] Fix | Delete
[1733] Fix | Delete
$this->escape( $args );
[1734] Fix | Delete
[1735] Fix | Delete
$username = $args[1];
[1736] Fix | Delete
$password = $args[2];
[1737] Fix | Delete
$post_id = (int) $args[3];
[1738] Fix | Delete
$content_struct = $args[4];
[1739] Fix | Delete
[1740] Fix | Delete
$user = $this->login( $username, $password );
[1741] Fix | Delete
if ( ! $user ) {
[1742] Fix | Delete
return $this->error;
[1743] Fix | Delete
}
[1744] Fix | Delete
[1745] Fix | Delete
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
[1746] Fix | Delete
do_action( 'xmlrpc_call', 'wp.editPost', $args, $this );
[1747] Fix | Delete
[1748] Fix | Delete
$post = get_post( $post_id, ARRAY_A );
[1749] Fix | Delete
[1750] Fix | Delete
if ( empty( $post['ID'] ) ) {
[1751] Fix | Delete
return new IXR_Error( 404, __( 'Invalid post ID.' ) );
[1752] Fix | Delete
}
[1753] Fix | Delete
[1754] Fix | Delete
if ( isset( $content_struct['if_not_modified_since'] ) ) {
[1755] Fix | Delete
// If the post has been modified since the date provided, return an error.
[1756] Fix | Delete
if ( mysql2date( 'U', $post['post_modified_gmt'] ) > $content_struct['if_not_modified_since']->getTimestamp() ) {
[1757] Fix | Delete
return new IXR_Error( 409, __( 'There is a revision of this post that is more recent.' ) );
[1758] Fix | Delete
}
[1759] Fix | Delete
}
[1760] Fix | Delete
[1761] Fix | Delete
// Convert the date field back to IXR form.
[1762] Fix | Delete
$post['post_date'] = $this->_convert_date( $post['post_date'] );
[1763] Fix | Delete
[1764] Fix | Delete
/*
[1765] Fix | Delete
* Ignore the existing GMT date if it is empty or a non-GMT date was supplied in $content_struct,
[1766] Fix | Delete
* since _insert_post() will ignore the non-GMT date if the GMT date is set.
[1767] Fix | Delete
*/
[1768] Fix | Delete
if ( '0000-00-00 00:00:00' === $post['post_date_gmt'] || isset( $content_struct['post_date'] ) ) {
[1769] Fix | Delete
unset( $post['post_date_gmt'] );
[1770] Fix | Delete
} else {
[1771] Fix | Delete
$post['post_date_gmt'] = $this->_convert_date( $post['post_date_gmt'] );
[1772] Fix | Delete
}
[1773] Fix | Delete
[1774] Fix | Delete
/*
[1775] Fix | Delete
* If the API client did not provide 'post_date', then we must not perpetuate the value that
[1776] Fix | Delete
* was stored in the database, or it will appear to be an intentional edit. Conveying it here
[1777] Fix | Delete
* as if it was coming from the API client will cause an otherwise zeroed out 'post_date_gmt'
[1778] Fix | Delete
* to get set with the value that was originally stored in the database when the draft was created.
[1779] Fix | Delete
*/
[1780] Fix | Delete
if ( ! isset( $content_struct['post_date'] ) ) {
[1781] Fix | Delete
unset( $post['post_date'] );
[1782] Fix | Delete
}
[1783] Fix | Delete
[1784] Fix | Delete
$this->escape( $post );
[1785] Fix | Delete
$merged_content_struct = array_merge( $post, $content_struct );
[1786] Fix | Delete
[1787] Fix | Delete
$retval = $this->_insert_post( $user, $merged_content_struct );
[1788] Fix | Delete
if ( $retval instanceof IXR_Error ) {
[1789] Fix | Delete
return $retval;
[1790] Fix | Delete
}
[1791] Fix | Delete
[1792] Fix | Delete
return true;
[1793] Fix | Delete
}
[1794] Fix | Delete
[1795] Fix | Delete
/**
[1796] Fix | Delete
* Deletes a post for any registered post type.
[1797] Fix | Delete
*
[1798] Fix | Delete
* @since 3.4.0
[1799] Fix | Delete
*
[1800] Fix | Delete
* @see wp_delete_post()
[1801] Fix | Delete
*
[1802] Fix | Delete
* @param array $args {
[1803] Fix | Delete
* Method arguments. Note: arguments must be ordered as documented.
[1804] Fix | Delete
*
[1805] Fix | Delete
* @type int $0 Blog ID (unused).
[1806] Fix | Delete
* @type string $1 Username.
[1807] Fix | Delete
* @type string $2 Password.
[1808] Fix | Delete
* @type int $3 Post ID.
[1809] Fix | Delete
* }
[1810] Fix | Delete
* @return true|IXR_Error True on success, IXR_Error instance on failure.
[1811] Fix | Delete
*/
[1812] Fix | Delete
public function wp_deletePost( $args ) {
[1813] Fix | Delete
if ( ! $this->minimum_args( $args, 4 ) ) {
[1814] Fix | Delete
return $this->error;
[1815] Fix | Delete
}
[1816] Fix | Delete
[1817] Fix | Delete
$this->escape( $args );
[1818] Fix | Delete
[1819] Fix | Delete
$username = $args[1];
[1820] Fix | Delete
$password = $args[2];
[1821] Fix | Delete
$post_id = (int) $args[3];
[1822] Fix | Delete
[1823] Fix | Delete
$user = $this->login( $username, $password );
[1824] Fix | Delete
if ( ! $user ) {
[1825] Fix | Delete
return $this->error;
[1826] Fix | Delete
}
[1827] Fix | Delete
[1828] Fix | Delete
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
[1829] Fix | Delete
do_action( 'xmlrpc_call', 'wp.deletePost', $args, $this );
[1830] Fix | Delete
[1831] Fix | Delete
$post = get_post( $post_id, ARRAY_A );
[1832] Fix | Delete
if ( empty( $post['ID'] ) ) {
[1833] Fix | Delete
return new IXR_Error( 404, __( 'Invalid post ID.' ) );
[1834] Fix | Delete
}
[1835] Fix | Delete
[1836] Fix | Delete
if ( ! current_user_can( 'delete_post', $post_id ) ) {
[1837] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) );
[1838] Fix | Delete
}
[1839] Fix | Delete
[1840] Fix | Delete
$result = wp_delete_post( $post_id );
[1841] Fix | Delete
[1842] Fix | Delete
if ( ! $result ) {
[1843] Fix | Delete
return new IXR_Error( 500, __( 'Sorry, the post could not be deleted.' ) );
[1844] Fix | Delete
}
[1845] Fix | Delete
[1846] Fix | Delete
return true;
[1847] Fix | Delete
}
[1848] Fix | Delete
[1849] Fix | Delete
/**
[1850] Fix | Delete
* Retrieves a post.
[1851] Fix | Delete
*
[1852] Fix | Delete
* @since 3.4.0
[1853] Fix | Delete
*
[1854] Fix | Delete
* The optional $fields parameter specifies what fields will be included
[1855] Fix | Delete
* in the response array. This should be a list of field names. 'post_id' will
[1856] Fix | Delete
* always be included in the response regardless of the value of $fields.
[1857] Fix | Delete
*
[1858] Fix | Delete
* Instead of, or in addition to, individual field names, conceptual group
[1859] Fix | Delete
* names can be used to specify multiple fields. The available conceptual
[1860] Fix | Delete
* groups are 'post' (all basic fields), 'taxonomies', 'custom_fields',
[1861] Fix | Delete
* and 'enclosure'.
[1862] Fix | Delete
*
[1863] Fix | Delete
* @see get_post()
[1864] Fix | Delete
*
[1865] Fix | Delete
* @param array $args {
[1866] Fix | Delete
* Method arguments. Note: arguments must be ordered as documented.
[1867] Fix | Delete
*
[1868] Fix | Delete
* @type int $0 Blog ID (unused).
[1869] Fix | Delete
* @type string $1 Username.
[1870] Fix | Delete
* @type string $2 Password.
[1871] Fix | Delete
* @type int $3 Post ID.
[1872] Fix | Delete
* @type array $4 Optional. The subset of post type fields to return.
[1873] Fix | Delete
* }
[1874] Fix | Delete
* @return array|IXR_Error Array contains (based on $fields parameter):
[1875] Fix | Delete
* - 'post_id'
[1876] Fix | Delete
* - 'post_title'
[1877] Fix | Delete
* - 'post_date'
[1878] Fix | Delete
* - 'post_date_gmt'
[1879] Fix | Delete
* - 'post_modified'
[1880] Fix | Delete
* - 'post_modified_gmt'
[1881] Fix | Delete
* - 'post_status'
[1882] Fix | Delete
* - 'post_type'
[1883] Fix | Delete
* - 'post_name'
[1884] Fix | Delete
* - 'post_author'
[1885] Fix | Delete
* - 'post_password'
[1886] Fix | Delete
* - 'post_excerpt'
[1887] Fix | Delete
* - 'post_content'
[1888] Fix | Delete
* - 'link'
[1889] Fix | Delete
* - 'comment_status'
[1890] Fix | Delete
* - 'ping_status'
[1891] Fix | Delete
* - 'sticky'
[1892] Fix | Delete
* - 'custom_fields'
[1893] Fix | Delete
* - 'terms'
[1894] Fix | Delete
* - 'categories'
[1895] Fix | Delete
* - 'tags'
[1896] Fix | Delete
* - 'enclosure'
[1897] Fix | Delete
*/
[1898] Fix | Delete
public function wp_getPost( $args ) {
[1899] Fix | Delete
if ( ! $this->minimum_args( $args, 4 ) ) {
[1900] Fix | Delete
return $this->error;
[1901] Fix | Delete
}
[1902] Fix | Delete
[1903] Fix | Delete
$this->escape( $args );
[1904] Fix | Delete
[1905] Fix | Delete
$username = $args[1];
[1906] Fix | Delete
$password = $args[2];
[1907] Fix | Delete
$post_id = (int) $args[3];
[1908] Fix | Delete
[1909] Fix | Delete
if ( isset( $args[4] ) ) {
[1910] Fix | Delete
$fields = $args[4];
[1911] Fix | Delete
} else {
[1912] Fix | Delete
/**
[1913] Fix | Delete
* Filters the default post query fields used by the given XML-RPC method.
[1914] Fix | Delete
*
[1915] Fix | Delete
* @since 3.4.0
[1916] Fix | Delete
*
[1917] Fix | Delete
* @param array $fields An array of post fields to retrieve. By default,
[1918] Fix | Delete
* contains 'post', 'terms', and 'custom_fields'.
[1919] Fix | Delete
* @param string $method Method name.
[1920] Fix | Delete
*/
[1921] Fix | Delete
$fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPost' );
[1922] Fix | Delete
}
[1923] Fix | Delete
[1924] Fix | Delete
$user = $this->login( $username, $password );
[1925] Fix | Delete
if ( ! $user ) {
[1926] Fix | Delete
return $this->error;
[1927] Fix | Delete
}
[1928] Fix | Delete
[1929] Fix | Delete
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
[1930] Fix | Delete
do_action( 'xmlrpc_call', 'wp.getPost', $args, $this );
[1931] Fix | Delete
[1932] Fix | Delete
$post = get_post( $post_id, ARRAY_A );
[1933] Fix | Delete
[1934] Fix | Delete
if ( empty( $post['ID'] ) ) {
[1935] Fix | Delete
return new IXR_Error( 404, __( 'Invalid post ID.' ) );
[1936] Fix | Delete
}
[1937] Fix | Delete
[1938] Fix | Delete
if ( ! current_user_can( 'edit_post', $post_id ) ) {
[1939] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
[1940] Fix | Delete
}
[1941] Fix | Delete
[1942] Fix | Delete
return $this->_prepare_post( $post, $fields );
[1943] Fix | Delete
}
[1944] Fix | Delete
[1945] Fix | Delete
/**
[1946] Fix | Delete
* Retrieves posts.
[1947] Fix | Delete
*
[1948] Fix | Delete
* @since 3.4.0
[1949] Fix | Delete
*
[1950] Fix | Delete
* @see wp_get_recent_posts()
[1951] Fix | Delete
* @see wp_getPost() for more on `$fields`
[1952] Fix | Delete
* @see get_posts() for more on `$filter` values
[1953] Fix | Delete
*
[1954] Fix | Delete
* @param array $args {
[1955] Fix | Delete
* Method arguments. Note: arguments must be ordered as documented.
[1956] Fix | Delete
*
[1957] Fix | Delete
* @type int $0 Blog ID (unused).
[1958] Fix | Delete
* @type string $1 Username.
[1959] Fix | Delete
* @type string $2 Password.
[1960] Fix | Delete
* @type array $3 Optional. Modifies the query used to retrieve posts. Accepts 'post_type',
[1961] Fix | Delete
* 'post_status', 'number', 'offset', 'orderby', 's', and 'order'.
[1962] Fix | Delete
* Default empty array.
[1963] Fix | Delete
* @type array $4 Optional. The subset of post type fields to return in the response array.
[1964] Fix | Delete
* }
[1965] Fix | Delete
* @return array|IXR_Error Array containing a collection of posts.
[1966] Fix | Delete
*/
[1967] Fix | Delete
public function wp_getPosts( $args ) {
[1968] Fix | Delete
if ( ! $this->minimum_args( $args, 3 ) ) {
[1969] Fix | Delete
return $this->error;
[1970] Fix | Delete
}
[1971] Fix | Delete
[1972] Fix | Delete
$this->escape( $args );
[1973] Fix | Delete
[1974] Fix | Delete
$username = $args[1];
[1975] Fix | Delete
$password = $args[2];
[1976] Fix | Delete
$filter = isset( $args[3] ) ? $args[3] : array();
[1977] Fix | Delete
[1978] Fix | Delete
if ( isset( $args[4] ) ) {
[1979] Fix | Delete
$fields = $args[4];
[1980] Fix | Delete
} else {
[1981] Fix | Delete
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
[1982] Fix | Delete
$fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPosts' );
[1983] Fix | Delete
}
[1984] Fix | Delete
[1985] Fix | Delete
$user = $this->login( $username, $password );
[1986] Fix | Delete
if ( ! $user ) {
[1987] Fix | Delete
return $this->error;
[1988] Fix | Delete
}
[1989] Fix | Delete
[1990] Fix | Delete
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
[1991] Fix | Delete
do_action( 'xmlrpc_call', 'wp.getPosts', $args, $this );
[1992] Fix | Delete
[1993] Fix | Delete
$query = array();
[1994] Fix | Delete
[1995] Fix | Delete
if ( isset( $filter['post_type'] ) ) {
[1996] Fix | Delete
$post_type = get_post_type_object( $filter['post_type'] );
[1997] Fix | Delete
if ( ! ( (bool) $post_type ) ) {
[1998] Fix | Delete
return new IXR_Error( 403, __( 'Invalid post type.' ) );
[1999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function