/** * If a project has `%portfolio_category%` or `%portfolio_tag%` in its permalink structure, * it must have a term set for the taxonomy. This function is a callback on `save_post` * that checks if a term is set. If not, it forces the first term of the taxonomy to be * the selected term. * * @since 1.0.0 * @access public * @param int $post_id * @return void */ function ccp_force_term_selection($post_id) { if (ccp_is_project($post_id)) { $project_base = ccp_get_project_rewrite_base(); $cat_tax = ccp_get_category_taxonomy(); $tag_tax = ccp_get_tag_taxonomy(); if (false !== strpos($project_base, "%{$cat_tax}%")) { ccp_set_term_if_none($post_id, $cat_tax, ccp_get_default_category()); } if (false !== strpos($project_base, "%{$tag_tax}%")) { ccp_set_term_if_none($post_id, $tag_tax, ccp_get_default_tag()); } } }
/** * Displays the permalinks help tab. * * @since 1.0.0 * @access public * @return void */ public function help_tab_permalinks() { ?> <ul> <li><?php _e('<strong>Portfolio Base:</strong> The primary URL for the portfolio section on your site. It lists your portfolio projects.', 'custom-content-portfolio'); ?> </li> <li> <?php _e('<strong>Project Slug:</strong> The slug for single portfolio projects. You can use something custom, leave this field empty, or use one of the following tags:', 'custom-content-portfolio'); ?> <ul> <li><?php printf(esc_html__('%s - The project author name.', 'custom-content-portfolio'), '<code>%author%</code>'); ?> </li> <li><?php printf(esc_html__('%s - The project category.', 'custom-content-portfolio'), '<code>%' . ccp_get_category_taxonomy() . '%</code>'); ?> </li> <li><?php printf(esc_html__('%s - The project tag.', 'custom-content-portfolio'), '<code>%' . ccp_get_tag_taxonomy() . '%</code>'); ?> </li> </ul> </li> <li><?php _e('<strong>Category Slug:</strong> The base slug used for portfolio category archives.', 'custom-content-portfolio'); ?> </li> <li><?php _e('<strong>Tag Slug:</strong> The base slug used for portfolio tag archives.', 'custom-content-portfolio'); ?> </li> <li><?php _e('<strong>Author Slug:</strong> The base slug used for portfolio author archives.', 'custom-content-portfolio'); ?> </li> </ul> <?php }
/** * Filters the term updated messages in the admin. * * @since 1.0.0 * @access public * @param array $messages * @return array */ function ccp_term_updated_messages($messages) { $cat_taxonomy = ccp_get_category_taxonomy(); $tag_taxonomy = ccp_get_tag_taxonomy(); // Add the portfolio category messages. $messages[$cat_taxonomy] = array(0 => '', 1 => __('Category added.', 'custom-content-portfolio'), 2 => __('Category deleted.', 'custom-content-portfolio'), 3 => __('Category updated.', 'custom-content-portfolio'), 4 => __('Category not added.', 'custom-content-portfolio'), 5 => __('Category not updated.', 'custom-content-portfolio'), 6 => __('Categories deleted.', 'custom-content-portfolio')); // Add the portfolio tag messages. $messages[$tag_taxonomy] = array(0 => '', 1 => __('Tag added.', 'custom-content-portfolio'), 2 => __('Tag deleted.', 'custom-content-portfolio'), 3 => __('Tag updated.', 'custom-content-portfolio'), 4 => __('Tag not added.', 'custom-content-portfolio'), 5 => __('Tag not updated.', 'custom-content-portfolio'), 6 => __('Tags deleted.', 'custom-content-portfolio')); return $messages; }
/** * Renders a tags dropdown below the table nav. * * @since 1.0.0 * @access public * @return void */ public function tags_dropdown() { $this->terms_dropdown(ccp_get_tag_taxonomy()); }
/** * Conditional tag to check if viewing a portfolio tag archive. * * @since 1.0.0 * @access public * @param mixed $term * @return bool */ function ccp_is_tag($term = '') { return apply_filters('ccp_is_tag', is_tax(ccp_get_tag_taxonomy(), $term)); }