Edit File by line
/home/barbar84/www/wp-conte.../plugins/updraftp.../central/modules
File: posts.php
foreach ($authors as $user) {
[1500] Fix | Delete
$item = array(
[1501] Fix | Delete
'id' => $user->ID,
[1502] Fix | Delete
'name' => $user->display_name,
[1503] Fix | Delete
);
[1504] Fix | Delete
$author_options[] = $item;
[1505] Fix | Delete
}
[1506] Fix | Delete
[1507] Fix | Delete
$response = array(
[1508] Fix | Delete
'page' => $page_options,
[1509] Fix | Delete
'author' => $author_options,
[1510] Fix | Delete
'template' => $template_options,
[1511] Fix | Delete
'date' => $this->get_date_options($type),
[1512] Fix | Delete
);
[1513] Fix | Delete
[1514] Fix | Delete
if ('post' == $type) {
[1515] Fix | Delete
$categories = get_categories(array('hide_empty' => false, 'orderby' => 'name', 'order' => 'ASC'));
[1516] Fix | Delete
$tags = get_tags(array('hide_empty' => false));
[1517] Fix | Delete
[1518] Fix | Delete
$category_options = array();
[1519] Fix | Delete
foreach ($categories as $category) {
[1520] Fix | Delete
$item = array(
[1521] Fix | Delete
'id' => $category->term_id,
[1522] Fix | Delete
'name' => $category->name,
[1523] Fix | Delete
'parent' => $category->parent
[1524] Fix | Delete
);
[1525] Fix | Delete
$category_options[] = $item;
[1526] Fix | Delete
}
[1527] Fix | Delete
[1528] Fix | Delete
$tag_options = array();
[1529] Fix | Delete
foreach ($tags as $tag) {
[1530] Fix | Delete
$item = array(
[1531] Fix | Delete
'id' => $tag->term_id,
[1532] Fix | Delete
'name' => $tag->name,
[1533] Fix | Delete
);
[1534] Fix | Delete
$tag_options[] = $item;
[1535] Fix | Delete
}
[1536] Fix | Delete
[1537] Fix | Delete
$response['category'] = $category_options;
[1538] Fix | Delete
$response['tag'] = $tag_options;
[1539] Fix | Delete
}
[1540] Fix | Delete
[1541] Fix | Delete
return $response;
[1542] Fix | Delete
}
[1543] Fix | Delete
[1544] Fix | Delete
/**
[1545] Fix | Delete
* Changes the state/status of the given post based from the submitted action/request
[1546] Fix | Delete
*
[1547] Fix | Delete
* @param int $id The ID of the current page to work on
[1548] Fix | Delete
* @param string $action The type of change that the current request is going to apply
[1549] Fix | Delete
* @param string $type The type of the module that the current request is processing
[1550] Fix | Delete
*
[1551] Fix | Delete
* @return array
[1552] Fix | Delete
*/
[1553] Fix | Delete
protected function apply_state($id, $action, $type = 'post') {
[1554] Fix | Delete
if (empty($id)) return false;
[1555] Fix | Delete
[1556] Fix | Delete
$post = get_post($id);
[1557] Fix | Delete
if (!empty($post)) {
[1558] Fix | Delete
$previous_status = $post->post_status;
[1559] Fix | Delete
$deleted = false;
[1560] Fix | Delete
[1561] Fix | Delete
switch ($action) {
[1562] Fix | Delete
case 'draft':
[1563] Fix | Delete
$args = array('ID' => $id, 'post_status' => 'draft');
[1564] Fix | Delete
wp_update_post($args);
[1565] Fix | Delete
break;
[1566] Fix | Delete
case 'trash':
[1567] Fix | Delete
wp_trash_post($id);
[1568] Fix | Delete
break;
[1569] Fix | Delete
case 'publish':
[1570] Fix | Delete
$args = array('ID' => $id, 'post_status' => 'publish');
[1571] Fix | Delete
wp_update_post($args);
[1572] Fix | Delete
break;
[1573] Fix | Delete
case 'restore':
[1574] Fix | Delete
$args = array('ID' => $id, 'post_status' => 'pending');
[1575] Fix | Delete
wp_update_post($args);
[1576] Fix | Delete
break;
[1577] Fix | Delete
case 'delete':
[1578] Fix | Delete
$result = wp_delete_post($id, true);
[1579] Fix | Delete
if (!empty($result)) $deleted = true;
[1580] Fix | Delete
break;
[1581] Fix | Delete
default:
[1582] Fix | Delete
break;
[1583] Fix | Delete
}
[1584] Fix | Delete
[1585] Fix | Delete
$postdata = $this->get_postdata($post);
[1586] Fix | Delete
if (!empty($postdata) || $deleted) {
[1587] Fix | Delete
$data = $deleted ? $id : $postdata;
[1588] Fix | Delete
$result = array(
[1589] Fix | Delete
'id' => $id,
[1590] Fix | Delete
'previous_status' => $previous_status
[1591] Fix | Delete
);
[1592] Fix | Delete
[1593] Fix | Delete
$result[$type] = $data;
[1594] Fix | Delete
return $result;
[1595] Fix | Delete
}
[1596] Fix | Delete
}
[1597] Fix | Delete
[1598] Fix | Delete
return false;
[1599] Fix | Delete
}
[1600] Fix | Delete
[1601] Fix | Delete
/**
[1602] Fix | Delete
* Imports image from UpdraftCentral's page/post editor
[1603] Fix | Delete
*
[1604] Fix | Delete
* @param string $image_url The URL of the image to import
[1605] Fix | Delete
* @param string $image_data The image data to save. If empty, image_url will be used to download the image
[1606] Fix | Delete
* @param int $post_id The ID of the page where this image is to be attached
[1607] Fix | Delete
*
[1608] Fix | Delete
* @return integer
[1609] Fix | Delete
*/
[1610] Fix | Delete
protected function attach_remote_image($image_url, $image_data, $post_id) {
[1611] Fix | Delete
if (empty($image_url) || empty($post_id)) return;
[1612] Fix | Delete
[1613] Fix | Delete
$image = pathinfo($image_url);
[1614] Fix | Delete
$image_name = $image['basename'];
[1615] Fix | Delete
$upload_dir = wp_upload_dir();
[1616] Fix | Delete
[1617] Fix | Delete
if (empty($image_data)) {
[1618] Fix | Delete
$response = wp_remote_get($image_url);
[1619] Fix | Delete
if (!is_wp_error($response)) {
[1620] Fix | Delete
$image_data = wp_remote_retrieve_body($response);
[1621] Fix | Delete
}
[1622] Fix | Delete
} else {
[1623] Fix | Delete
$image_data = base64_decode($image_data);
[1624] Fix | Delete
}
[1625] Fix | Delete
[1626] Fix | Delete
$media_id = 0;
[1627] Fix | Delete
if (!empty($image_data)) {
[1628] Fix | Delete
$unique_file_name = wp_unique_filename($upload_dir['path'], $image_name);
[1629] Fix | Delete
$filename = basename($unique_file_name);
[1630] Fix | Delete
[1631] Fix | Delete
if (wp_mkdir_p($upload_dir['path'])) {
[1632] Fix | Delete
$file = $upload_dir['path'] . '/' . $filename;
[1633] Fix | Delete
} else {
[1634] Fix | Delete
$file = $upload_dir['basedir'] . '/' . $filename;
[1635] Fix | Delete
}
[1636] Fix | Delete
[1637] Fix | Delete
file_put_contents($file, $image_data);
[1638] Fix | Delete
$wp_filetype = wp_check_filetype($filename, null);
[1639] Fix | Delete
[1640] Fix | Delete
$attachment = array(
[1641] Fix | Delete
'post_mime_type' => $wp_filetype['type'],
[1642] Fix | Delete
'post_title' => sanitize_file_name($filename),
[1643] Fix | Delete
'post_content' => '',
[1644] Fix | Delete
'post_status' => 'inherit'
[1645] Fix | Delete
);
[1646] Fix | Delete
[1647] Fix | Delete
$media_id = wp_insert_attachment($attachment, $file, $post_id);
[1648] Fix | Delete
require_once(ABSPATH . 'wp-admin/includes/image.php');
[1649] Fix | Delete
[1650] Fix | Delete
$attach_data = wp_generate_attachment_metadata($media_id, $file);
[1651] Fix | Delete
wp_update_attachment_metadata($media_id, $attach_data);
[1652] Fix | Delete
set_post_thumbnail($post_id, $media_id);
[1653] Fix | Delete
}
[1654] Fix | Delete
[1655] Fix | Delete
return $media_id;
[1656] Fix | Delete
}
[1657] Fix | Delete
[1658] Fix | Delete
/**
[1659] Fix | Delete
* Checks whether we have the required fields submitted and the user has
[1660] Fix | Delete
* the capabilities to execute the requested action
[1661] Fix | Delete
*
[1662] Fix | Delete
* @param array $capabilities The capabilities to check and validate
[1663] Fix | Delete
*
[1664] Fix | Delete
* @return array|void
[1665] Fix | Delete
*/
[1666] Fix | Delete
protected function _validate_capabilities($capabilities) {
[1667] Fix | Delete
foreach ($capabilities as $capability) {
[1668] Fix | Delete
if (!current_user_can($capability)) return $this->_generic_error_response('insufficient_permission');
[1669] Fix | Delete
}
[1670] Fix | Delete
}
[1671] Fix | Delete
}
[1672] Fix | Delete
[1673] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function