Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
andergmartins committed Feb 11, 2020
2 parents 57fe730 + 1cd1395 commit 4ea198d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 19 deletions.
2 changes: 1 addition & 1 deletion includes.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
);

// Define contants
define('PUBLISHPRESS_VERSION', '2.0.0');
define('PUBLISHPRESS_VERSION', '2.0.1');
define('PUBLISHPRESS_BASE_PATH', __DIR__);
define('PUBLISHPRESS_FILE_PATH', PUBLISHPRESS_BASE_PATH . '/publishpress.php');
define('PUBLISHPRESS_URL', plugins_url('/', __FILE__));
Expand Down
46 changes: 30 additions & 16 deletions modules/custom-status/custom-status.php
Original file line number Diff line number Diff line change
Expand Up @@ -851,13 +851,13 @@ protected function get_core_statuses($only_basic_data = false)
'description' => '-',
'color' => '',
'icon' => '',
'position' => 0,
'position' => 9,
];

if (!$only_basic_data) {
$status->color = get_option('psppno_status_publish_color', self::DEFAULT_COLOR);
$status->icon = get_option('psppno_status_publish_icon', 'dashicons-yes');
$status->position = get_option('psppno_status_publish_position', 0);
$status->position = get_option('psppno_status_publish_position', 9);
}

$all_statuses[] = $status;
Expand All @@ -870,13 +870,13 @@ protected function get_core_statuses($only_basic_data = false)
'description' => '-',
'color' => '',
'icon' => '',
'position' => 0,
'position' => 8,
];

if (!$only_basic_data) {
$status->color = get_option('psppno_status_private_color', '#000000');
$status->icon = get_option('psppno_status_private_icon', 'dashicons-lock');
$status->position = get_option('psppno_status_private_position', 0);
$status->position = get_option('psppno_status_private_position', 8);
}

$all_statuses[] = $status;
Expand All @@ -889,13 +889,13 @@ protected function get_core_statuses($only_basic_data = false)
'description' => '-',
'color' => '',
'icon' => '',
'position' => 0,
'position' => 7,
];

if (!$only_basic_data) {
$status->color = get_option('psppno_status_future_color', self::DEFAULT_COLOR);
$status->icon = get_option('psppno_status_future_icon', 'dashicons-calendar-alt');
$status->position = get_option('psppno_status_future_position', 0);
$status->position = get_option('psppno_status_future_position', 7);
}

$all_statuses[] = $status;
Expand Down Expand Up @@ -1196,15 +1196,14 @@ public function get_custom_statuses($args = [], $only_basic_info = false)
}
// We require the position key later on (e.g. management table)
if (!isset($status->position)) {
$status->position = false;
}
// Only add the status to the ordered array if it has a set position and doesn't conflict with another key
// Otherwise, hold it for later
if ($status->position && !array_key_exists($status->position, $orderedStatusList)) {
$orderedStatusList[(int)$status->position] = $status;
} else {
$hold_to_end[] = $status;
$slug = $status->slug === 'pending-review' ? 'pending':$status->slug;
if (array_key_exists($slug, $default_terms)) {
$status->position = $default_terms[$status->slug]['args']['position'];
} else {
$status->position = 99;
}
}
$this->addItemToArray($orderedStatusList, (int)$status->position, $status);

// Check if we need to set default colors and icons for current status
if (!isset($status->color) || empty($status->color)) {
Expand All @@ -1229,7 +1228,7 @@ public function get_custom_statuses($args = [], $only_basic_info = false)
// Add core statuses, custom properties saved on the config
$coreStatusList = $this->get_core_statuses($only_basic_info);
foreach ($coreStatusList as $coreStatus) {
$orderedStatusList[$coreStatus->position] = $coreStatus;
$this->addItemToArray($orderedStatusList, $coreStatus->position, $coreStatus);
}

// Sort the items numerically by key
Expand All @@ -1239,12 +1238,27 @@ public function get_custom_statuses($args = [], $only_basic_info = false)
$orderedStatusList[] = $unpositioned_status;
}


$this->custom_statuses_cache[$arg_hash] = $orderedStatusList;

return $orderedStatusList;
}

/**
* Add item to Array without overwrite any item, in case an item is already set for the position.
*
* @param $array
* @param $position
* @param $item
*/
private function addItemToArray(&$array, $position, $item)
{
if (isset($array[$position])) {
$this->addItemToArray($array, $position + 1, $item);
} else {
$array[$position] = $item;
}
}

/**
* Returns the a single status object based on ID, title, or slug
*
Expand Down
2 changes: 1 addition & 1 deletion publishpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Description: PublishPress helps you plan and publish content with WordPress. Features include a content calendar, notifications, and custom statuses.
* Author: PublishPress
* Author URI: https://publishpress.com
* Version: 2.0.0
* Version: 2.0.1
*
* Copyright (c) 2019 PublishPress
*
Expand Down
7 changes: 6 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Tags: notifications, Editorial Calendar, workflow, statuses, permissions
Requires at least: 4.6
Requires PHP: 5.6
Tested up to: 5.3
Stable tag: 2.0.0
Stable tag: 2.0.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -128,6 +128,11 @@ Not at all. You can set up everything your team needs without any coding knowled
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

= [2.0.1] - 2020-02-11 =

* Fixed: Fixed the hidden publish status and notifications for published posts;
* Fixed: Fixed the default order for custom statuses;

= [2.0.0] - 2020-02-06 =

* Fixed: Fixed the default status after sort statuses;
Expand Down

0 comments on commit 4ea198d

Please sign in to comment.