normalize() ); // anything under Loco's protected directory is our location for custom overrides $prefix = trailingslashit( loco_constant('LOCO_LANG_DIR') ); if( substr($path,0,strlen($prefix) ) === $prefix ){ return 'custom'; } // standard subdirectories of WP_LANG_DIR are under WordPress auto-update control $prefix = trailingslashit( loco_constant('WP_LANG_DIR') ); if( substr($path,0,strlen($prefix) ) === $prefix ){ if( $path === $prefix || $path === $prefix.'plugins/' || $path === $prefix.'themes/' ){ return 'wplang'; } } else { // anything under a registered theme directory is bundled $dirs = Loco_fs_Locations::getThemes(); if( $dirs->check($path) ){ return 'theme'; } // anything under a registered plugin directory is bundled $dirs = Loco_fs_Locations::getPlugins(); if( $dirs->check($path) ){ return 'plugin'; } } // anything else, which includes subdirectories of WP_LANG_DIR etc.. return 'other'; } /** * Get translated version of getTypeId * @return string */ public function getTypeLabel( $id ){ switch( $id ){ case 'theme': case 'plugin': // Translators: Refers to bundled plugin or theme translation files - i.e. those supplied by the author return _x('Author','File location','loco-translate'); case 'wplang': // Translators: Refers to system-installed translation files - i.e. those under WP_LANG_DIR return _x('System','File location','loco-translate'); case 'custom': // Translators: Refers to translation files in Loco's custom/protected directory return _x('Custom','File location','loco-translate'); case 'other': // Translators: Refers to translation files in an alternative location that isn't Author, System or Custom. return _x('Other','File location','loco-translate'); } throw new InvalidArgumentException('Invalid location type: '.$id ); } }