> */ public static function declarations() { $declarations = array( self::SITE_CONTEXT => array( 'blogname' => true, 'blogdescription' => true, 'date_format' => true, 'time_format' => true, ), self::WIDGET_CONTEXT => array( /* * Every widget type stores its instances in `widget_{$id_base}`, * numbered by instance, so one wildcard covers the widgets a site * has today and the ones it adds later. Only the text-bearing * fields are named; a widget's post counts, menu IDs, and feed * URLs are left alone. */ 'widget_*' => array( '*' => array( 'title' => true, 'text' => true, 'content' => true, ), ), ), ); /** * Filters the options ShapeTranslate registers for translation on its own. * * The array is keyed by context, then by option name or wildcard, then by * the nested keys to translate inside that option. Use `true` to translate * every plain text value below a key. * * add_filter( 'shapetranslate_core_string_catalog', function ( $catalog ) { * $catalog['Acme'] = array( * 'acme_settings' => array( 'header_text' => true ), * ); * return $catalog; * } ); * * @param array> $declarations Declarations keyed by context. */ $filtered = apply_filters( 'shapetranslate_core_string_catalog', $declarations ); return self::normalize( is_array( $filtered ) ? $filtered : $declarations ); } /** * Drops entries a filter could have made unusable. * * @param array $declarations Raw declarations. * @return array> */ private static function normalize( array $declarations ) { $normalized = array(); foreach ( $declarations as $context => $options ) { $context = trim( (string) $context ); if ( '' === $context || ! is_array( $options ) ) { continue; } foreach ( $options as $name => $keys ) { $name = trim( (string) $name ); if ( '' === $name ) { continue; } $normalized[ $context ][ $name ] = is_array( $keys ) ? $keys : true; } } return $normalized; } }