/**
 * Removes a project from the list of sticky projects.
 *
 * @since  1.0.0
 * @access public
 * @param  int    $project_id
 * @return bool
 */
function ccp_remove_sticky_project($project_id)
{
    $project_id = ccp_get_project_id($project_id);
    if (ccp_is_project_sticky($project_id)) {
        $stickies = ccp_get_sticky_projects();
        $key = array_search($project_id, $stickies);
        if (isset($stickies[$key])) {
            unset($stickies[$key]);
            return update_option('ccp_sticky_projects', array_unique($stickies));
        }
    }
    return false;
}
 /**
  * Callback function for handling post status changes.
  *
  * @since  1.0.0
  * @access public
  * @return void
  */
 public function handler()
 {
     // Checks if the sticky toggle link was clicked.
     if (isset($_GET['action']) && 'ccp_toggle_sticky' === $_GET['action'] && isset($_GET['project_id'])) {
         $project_id = absint(ccp_get_project_id($_GET['project_id']));
         // Verify the nonce.
         check_admin_referer("ccp_toggle_sticky_{$project_id}");
         if (ccp_is_project_sticky($project_id)) {
             ccp_remove_sticky_project($project_id);
         } else {
             ccp_add_sticky_project($project_id);
         }
         // Redirect to correct admin page.
         $redirect = add_query_arg(array('updated' => 1), remove_query_arg(array('action', 'project_id', '_wpnonce')));
         wp_safe_redirect(esc_url_raw($redirect));
         // Always exit for good measure.
         exit;
     }
     return;
 }
/**
 * Returns the project end_date.
 *
 * @since  1.0.0
 * @access public
 * @param  array  $args
 * @return string
 */
function ccp_get_project_end_date($args = array())
{
    $html = '';
    $defaults = array('post_id' => ccp_get_project_id(), 'text' => '%s', 'format' => get_option('date_format'), 'before' => '', 'after' => '', 'wrap' => '<span %s>%s</span>');
    $args = wp_parse_args($args, $defaults);
    $end_date = ccp_get_project_meta($args['post_id'], 'end_date');
    if ($end_date) {
        $datetime = sprintf('datetime="%s"', mysql2date('Y-m-d\\TH:i:sP', $end_date, true));
        $text = sprintf('<time class="project-data" %s>%s</time>', $datetime, mysql2date($args['format'], $end_date, true));
        $text = sprintf($args['text'], $text);
        $html .= $args['before'];
        $html .= sprintf($args['wrap'], 'class="project-end-date"', $text);
        $html .= $args['after'];
    }
    return apply_filters('ccp_get_project_end_date', $html, $args['post_id']);
}