$menuItems) {
if ('st_options' === $menuName) {
$taxopress_settings = $taxopress_taxonomies = false;
$taxopress_submenus = $submenu['st_options'];
foreach($taxopress_submenus as $key => $taxopress_submenu){
if($taxopress_submenu[2] === 'st_options'){//settings
$taxopress_settings = $taxopress_submenu;
$taxopress_settings_key= $key;
unset($taxopress_submenus[$key]);
}
if($taxopress_submenu[2] === 'st_taxonomies'){//taxonomies
$taxopress_taxonomies = $taxopress_submenu;
$taxopress_taxonomies_key= $key;
unset($taxopress_submenus[$key]);
}
}
if($taxopress_settings && $taxopress_taxonomies ){
//swicth position
$taxopress_submenus[$taxopress_settings_key] = $taxopress_taxonomies;
$taxopress_submenus[$taxopress_taxonomies_key] = $taxopress_settings;
}
//resort array
ksort($taxopress_submenus);
$submenu['st_options'] = $taxopress_submenus;
break;
}
}
}
}
// Init TaxoPress
function init_simple_tags()
{
new SimpleTags_Client();
new SimpleTags_Client_TagCloud();
// Admin and XML-RPC
if (is_admin()) {
require STAGS_DIR . '/inc/class.admin.php';
new SimpleTags_Admin();
}
add_action('widgets_init', 'st_register_widget');
}
function taxopress_admin_pages(){
$taxopress_pages = [
'st_mass_terms',
'st_auto',
'st_options',
'st_manage',
'st_taxonomies',
'st_terms_display',
'st_post_tags',
'st_related_posts',
'st_autolinks',
'st_autoterms',
'st_suggestterms',
'st_terms'
];
return apply_filters('taxopress_admin_pages', $taxopress_pages);
}
function is_taxopress_admin_page(){
$taxopress_pages = taxopress_admin_pages();
$is_taxopress_page = false;
if ( isset( $_GET['page'] ) && in_array( $_GET['page'], $taxopress_pages )) {
$is_taxopress_page = true;
}
return apply_filters('is_taxopress_admin_page', $is_taxopress_page);
}
function taxopress_starts_with( $haystack, $needle ) {
$length = strlen( $needle );
return substr( $haystack, 0, $length ) === $needle;
}
function taxopress_is_html($string)
{
return preg_match("/<[^<]+>/",$string,$m) != 0;
}
function taxopress_is_screen_main_page(){
if(isset($_GET['action']) && $_GET['action'] === 'edit'){
return false;
}
if(isset($_GET['add']) && $_GET['add'] === 'new_item'){
return false;
}
if(isset($_GET['add']) && $_GET['add'] === 'taxonomy'){
return false;
}
return true;
}
function taxopress_format_class($class)
{
return esc_attr(ltrim($class, '.'));
}
function taxopress_add_class_to_format($xformat, $class) {
$classes = $class;
$html = $xformat;
$patterns = array();
$replacements = array();
// matches where anchor has existing classes contained in single quotes
$patterns[0] = '/]*)class=\'([^\']*)\'([^>]*)>/';
$replacements[0] = '';
// matches where anchor has existing classes contained in double quotes
$patterns[1] = '/]*)class="([^"]*)"([^>]*)>/';
$replacements[1] = '';
// matches where anchor tag has no existing classes
$patterns[2] = '/]*class)([^>]*)>/';
$replacements[2] = '';
$html = preg_replace($patterns, $replacements, $html);
return $html;
}
function taxopress_change_to_strings($join){
if(is_array($join)){
$join = join(", ", $join);
}
return $join;
}
function taxopress_change_to_array($array){
if(!is_array($array)){
$array = preg_split("/\s*,\s*/",$array);
}
return $array;
}
function taxopress_html_character_and_entity($enity_code_as_key = false){
#Source https://dev.w3.org/html5/html-author/charref
$character_set = [
//'&' => '&',
'<' => '<',
'>' => '>',
' ' => ' ',
'!' => '!',
'"' => '"',
'#' => '#',
'$'=> '$',
'%' => '%',
''' => ''',
'(' => '(',
')' => ')',
'* ' => '*',
'+' => '+',
',' => ',',
'.' => '.',
'/' => '/',
':' => ':',
';' => ';',
'=' => '=',
'?' => '?',
'@' => '@',
'[' => '[',
'\' => '\',
']' => ']',
'^' => '^',
'_' => '_',
'`' => '`',
'{' => '{',
'|' => '|',
'}' => '}',
'¡' => '¡',
'¢' => '¢',
'£' => '£',
'©' => '©',
'ª' => 'ª',
'«' => '«',
'®' => '®',
'°' => '°',
'±' => '±',
'²' => '²',
'³' => '³',
'´' => '´',
'¹' => '¹',
'º' => 'º',
'»' => '»',
'¼' => '¼',
'½' => '½',
'¾' => '¾',
'→' => '→',
'←' => '←',
'↑' => '↑',
'↓' => '↓',
'™' => '™',
'’' => '’',
'’' => '’',
'‘' => '‘',
'‚' => '‚',
];
if($enity_code_as_key){
$character_set = array_flip($character_set);
}
return $character_set;
}