/** * Use custom callback for outputting snippet * * @param $buf * @param $args * * @return string */ function custom_output_option($buf, $args) { if ('aiosp_snippet' === $args['name']) { $args['options']['type'] = 'html'; $args['options']['nowrap'] = false; $args['options']['save'] = false; $info = $this->get_page_snippet_info(); extract($info); } else { return ''; } if ($this->strlen($title) > 70) { $title = $this->trim_excerpt_without_filters($title, 70) . '...'; } if ($this->strlen($description) > 156) { $description = $this->trim_excerpt_without_filters($description, 156) . '...'; } $extra_title_len = 0; if (empty($title_format)) { $title = '<span id="' . $args['name'] . '_title">' . esc_attr(wp_strip_all_tags(html_entity_decode($title))) . '</span>'; } else { if (strpos($title_format, '%blog_title%') !== false) { $title_format = str_replace('%blog_title%', get_bloginfo('name'), $title_format); } $title_format = $this->apply_cf_fields($title_format); $replace_title = '<span id="' . $args['name'] . '_title">' . esc_attr(wp_strip_all_tags(html_entity_decode($title))) . '</span>'; if (strpos($title_format, '%post_title%') !== false) { $title_format = str_replace('%post_title%', $replace_title, $title_format); } if (strpos($title_format, '%page_title%') !== false) { $title_format = str_replace('%page_title%', $replace_title, $title_format); } if ($w->is_category || $w->is_tag || $w->is_tax) { if (AIOSEOPPRO && !empty($_GET) && !empty($_GET['taxonomy']) && !empty($_GET['tag_ID']) && function_exists('wp_get_split_terms')) { $term_id = intval($_GET['tag_ID']); $was_split = get_term_meta($term_id, '_aioseop_term_was_split', true); if (!$was_split) { $split_terms = wp_get_split_terms($term_id, $_GET['taxonomy']); if (!empty($split_terms)) { foreach ($split_terms as $new_tax => $new_term) { $this->split_shared_term($term_id, $new_term); } } } } if (strpos($title_format, '%category_title%') !== false) { $title_format = str_replace('%category_title%', $replace_title, $title_format); } if (strpos($title_format, '%taxonomy_title%') !== false) { $title_format = str_replace('%taxonomy_title%', $replace_title, $title_format); } } else { if (strpos($title_format, '%category%') !== false) { $title_format = str_replace('%category%', $category, $title_format); } if (strpos($title_format, '%category_title%') !== false) { $title_format = str_replace('%category_title%', $category, $title_format); } if (strpos($title_format, '%taxonomy_title%') !== false) { $title_format = str_replace('%taxonomy_title%', $category, $title_format); } if (AIOSEOPPRO) { if (strpos($title_format, '%tax_') && !empty($p)) { $taxes = get_object_taxonomies($p, 'objects'); if (!empty($taxes)) { foreach ($taxes as $t) { if (strpos($title_format, "%tax_{$t->name}%")) { $terms = $this->get_all_terms($p->ID, $t->name); $term = ''; if (count($terms) > 0) { $term = $terms[0]; } $title_format = str_replace("%tax_{$t->name}%", $term, $title_format); } } } } } } if (strpos($title_format, '%taxonomy_description%') !== false) { $title_format = str_replace('%taxonomy_description%', $description, $title_format); } $title_format = preg_replace('/%([^%]*?)%/', '', $title_format); $title = $title_format; $extra_title_len = strlen(str_replace($replace_title, '', $title_format)); } $args['value'] = sprintf($args['value'], $title, esc_url($url), esc_attr(wp_strip_all_tags($description))); $extra_title_len = (int) $extra_title_len; $args['value'] .= "<script>var aiosp_title_extra = {$extra_title_len};</script>"; $buf = $this->get_option_row($args['name'], $args['options'], $args); return $buf; }
/** * Get the new term ID corresponding to a previously split term. * * @since 4.2.0 * * @param int $old_term_id Term ID. This is the old, pre-split term ID. * @param string $taxonomy Taxonomy that the term belongs to. * @return int|false If a previously split term is found corresponding to the old term_id and taxonomy, * the new term_id will be returned. If no previously split term is found matching * the parameters, returns false. */ function wp_get_split_term($old_term_id, $taxonomy) { $split_terms = wp_get_split_terms($old_term_id); $term_id = false; if (isset($split_terms[$taxonomy])) { $term_id = (int) $split_terms[$taxonomy]; } return $term_id; }
public function test_wp_get_split_terms() { $found = wp_get_split_terms($this->terms['t1']['term_id']); $expected = array('wptests_tax_2' => $this->terms['t2']['term_id'], 'wptests_tax_3' => $this->terms['t3']['term_id']); $this->assertEqualSets($expected, $found); }