public static function change_title($data, $postarr) { // If it is our form has not been submitted, so we dont want to do anything if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return; } if (!empty($data['post_title'])) { return $data; } $kind_strings = Kind_Taxonomy::get_strings(); $kind = get_term_by(taxonomy_id, $_POST['tax_input']['kind'], 'kind'); $title = $kind_strings[$kind->slug]; if (!empty($_POST['cite_name'])) { $title .= ' - ' . $_POST['cite_name']; } $data['post_title'] = $title; $data['post_name'] = sanitize_title($data['post_title']); return $data; }
/** * Assign a kind to a post * * @param int|object $post The post for which to assign a kind. * @param string $kind A kind to assign. Using an empty string or array will default to note. * @return mixed WP_Error on error. Array of affected term IDs on success. */ function set_post_kind($post, $kind) { return Kind_Taxonomy::set_post_kind($post, $kind); }
/** * Sets URL. * * @param $url string|array Either a string indicating the URL or an array of URLs. */ public function set_url($url) { if (empty($url)) { return; } $url = self::sanitize_text($url); $kind = get_post_kind_slug($this->post); $map = array_diff(Kind_Taxonomy::get_kind_properties(), array('')); if (array_key_exists($kind, $map)) { $this->meta[$map[$kind]] = $url; } if (!array_key_exists('cite', $this->meta)) { $this->meta['url'] = $url; } }
/** * Generate Options Form. * @access public */ public static function options_form() { Kind_Taxonomy::kind_defaultterms(); echo '<div class="wrap">'; echo '<h2>' . esc_html__('Indieweb Post Kinds', 'Post kinds') . '</h2>'; echo '<p>'; esc_html_e('Adds support for responding and interacting with other sites.', 'Post kinds'); echo '</p><hr />'; echo '<form method="post" action="options.php">'; settings_fields('iwt_options'); do_settings_sections('iwt_options'); submit_button(); echo '</form></div>'; }