/** * Retrieves an array of post kind slugs. * * @param int|WP_Post $post A Post. * @param string $key Meta Key to Retrieve. If empty, retrieve all. * @return array The array of post kind slugs. */ function get_post_mf2meta($post, $key = '') { $meta = new Kind_Meta($post); if (empty($key)) { return $meta->get_all_meta(); } return $meta->get_key($key); }
public static function get_display($post_ID, $single = false) { $meta = new Kind_Meta($post_ID); $kind = get_post_kind_slug($post_ID); $cite = $meta->get_cite(); $hcard = 'Unknown Author'; $content = ''; switch ($kind) { case 'note': case 'article': case 'photo': break; default: include 'views/kind-default.php'; } return apply_filters('kind-response-display', $content); }
public static function save_post($post_id, $post) { /* * We need to verify this came from our screen and with proper authorization, * because the save_post action can be triggered at other times. */ // Check if our nonce is set. if (!isset($_POST['tabkind_metabox_nonce'])) { return; } // Verify that the nonce is valid. if (!wp_verify_nonce($_POST['tabkind_metabox_nonce'], 'tabkind_metabox')) { return; } // If this is an autosave, our form has not been submitted, so we don't want to do anything. if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return; } // Check the user's permissions. if (isset($_POST['post_type']) && 'page' == $_POST['post_type']) { if (!current_user_can('edit_page', $post_id)) { return; } } else { if (!current_user_can('edit_post', $post_id)) { return; } } $kind = get_post_kind_slug($post); $meta = new Kind_Meta($post); if (isset($_POST['time'])) { if (isset($_POST['time']['start_date']) || isset($_POST['time']['start_time'])) { $start = $meta->build_time($_POST['time']['start_date'], $_POST['time']['start_time'], $_POST['time']['start_offset']); } if (isset($_POST['time']['end_date']) || isset($_POST['time']['end_time'])) { $end = $meta->build_time($_POST['time']['end_date'], $_POST['time']['end_time'], $_POST['time']['end_offset']); } } if (isset($_POST['cite'])) { if (in_array($kind, array('like', 'reply', 'repost', 'favorite', 'bookmark'))) { if (!empty($start)) { $_POST['cite']['published'] = $start; error_log('Start: ' . $start); } if (!empty($end)) { $_POST['cite']['updated'] = $end; error_log('End: ' . $end); } } else { $meta->set_time($start, $end); } $meta->set_cite($_POST['cite']); } if (isset($_POST['author'])) { $meta->set_author($_POST['author']); } if (isset($_POST['url'])) { $meta->set_url($_POST['url']); } // This is temporary - planning on improving this later if (isset($_POST['duration'])) { $meta->set('duration', $_POST['duration']); } $meta->save_meta($post); }
public static function json_rest_add_kindmeta($_post, $post, $context) { $response = new Kind_Meta($post['ID']); if (!empty($response)) { $_post['mf2'] = $response->get_all_meta(); } return $_post; }