/**
 * Filter for the "Tags" metabox in post edit. Does NOT affect the "Categories" metabox.
 * @see   get_terms_to_edit() wp-admin\includes\taxonomy.php
 * @scope admin
 * @since 1.6.4
 */
if ((empty($_GET['wpglobus']) || 'off' !== $_GET['wpglobus']) && is_admin() && WPGlobus_WP::is_pagenow('post.php')) {
    add_filter('terms_to_edit', array('WPGlobus_Filters', 'filter__terms_to_edit'), 5);
}
/**
 * Filter for the "Tags" box in edit.php page.
 * @see filter 'pre_insert_term' in wp-includes\taxonomy.php
 * @scope admin
 * @since 1.6.6
 */
if (WPGlobus_WP::is_http_post_action('inline-save') && false !== strpos($_SERVER['HTTP_REFERER'], 'edit.php')) {
    add_filter('pre_insert_term', array('WPGlobus_Filters', 'filter__pre_insert_term'), 5, 2);
}
/**
 * Full description is in @see WPGlobus_Filters::filter__sanitize_title
 * @scope both
 */
add_filter('sanitize_title', array('WPGlobus_Filters', 'filter__sanitize_title'), 0);
/**
 * Used by @see get_terms (3 places in the function)
 * @scope both
 * -
 * Example of WP core using this filter: @see _post_format_get_terms
 * -
 * Set priority to 11 for case ajax-tag-search action from post.php screen
 * @see   wp_ajax_ajax_tag_search() in wp-admin\includes\ajax-actions.php
 /**
  * @covers WPGlobus_WP::is_http_post_action
  */
 public function test_is_http_post_action()
 {
     $_POST['action'] = 'unit-test-action';
     self::assertTrue(WPGlobus_WP::is_http_post_action('unit-test-action'));
     self::assertFalse(WPGlobus_WP::is_http_post_action(''));
     self::assertFalse(WPGlobus_WP::is_http_post_action(null));
     self::assertFalse(WPGlobus_WP::is_http_post_action(3.14));
     $bad_boy = new stdClass();
     self::assertFalse(WPGlobus_WP::is_http_post_action($bad_boy));
     $_POST['action'] = 'not-unit-test-action';
     self::assertFalse(WPGlobus_WP::is_http_post_action('unit-test-action'));
     unset($_POST['action']);
     self::assertFalse(WPGlobus_WP::is_http_post_action('unit-test-action'));
     $_POST['action'] = 'unit-test-action';
     self::assertTrue(WPGlobus_WP::is_http_post_action(array('unit-test-action', 'not-unit-test-action')));
     $_POST['action'] = array('this-should-not-be-an-array');
     self::assertFalse(WPGlobus_WP::is_http_post_action('unit-test-action'));
 }
 /**
  * Localize home_url
  * Should be processed on:
  * - front
  * - AJAX, except for several specific actions
  *
  * @param string $url
  *
  * @return string
  */
 public static function filter__home_url($url)
 {
     /**
      * @internal note
      * Example of URL in admin:
      * When admin interface is not in default language, we still should not see
      * any permalinks with language prefixes.
      * For that, we could check if we are at the 'post.php' screen:
      * if ( 'post.php' == $pagenow ) ....
      * However, we do not need it, because we disallowed almost any processing in admin.
      */
     /**
      * 1. Do not work in admin
      */
     $need_to_process = !is_admin();
     if (WPGlobus_WP::is_pagenow('admin-ajax.php')) {
         /**
          * 2. But work in AJAX, which is also admin
          */
         $need_to_process = true;
         /**
          * 3. However, don't convert url for these AJAX actions:
          */
         if (WPGlobus_WP::is_http_post_action(array('heartbeat', 'sample-permalink', 'add-menu-item'))) {
             $need_to_process = false;
         }
     }
     if ($need_to_process) {
         $url = WPGlobus_Utils::localize_url($url);
     }
     return $url;
 }