'', // lyrics ]); $optionGroup = 'general'; register_setting($optionGroup, self::PLUGIN_OPTION_NAME); $page = 'general'; add_settings_field('aikotobaLyrics', 'Ai Kotoba', 'AiKotoba::lyrics_callback', $page); } static function lyrics_callback() { if (!isset(self::$_option[self::ITEM_LYRICS])) { self::$_option[self::ITEM_LYRICS] = ""; } $textAreaName = sprintf("%s[%s]", self::PLUGIN_OPTION_NAME, self::ITEM_LYRICS); echo "

" . self::LYRICS_DESCRIPTION . "

"; // echo $text; } static function ai_kotoba_get_lyric() { /** These are the lyrics to Ai Kotoba */ if (!isset(self::$_option[self::ITEM_LYRICS])) { self::$_option[self::ITEM_LYRICS] = ""; } $lyrics = self::$_option[self::ITEM_LYRICS]; // Here we split it into lines $lyrics = explode( "\n,", $lyrics ); // And then randomly choose a line return wptexturize( $lyrics[ mt_rand( 0, count( $lyrics ) - 1 ) ] ); } // This just echoes the chosen line, we'll position it later static function ai_kotoba() { $chosen = self::ai_kotoba_get_lyric(); echo "

$chosen

"; } // We need some CSS to position the paragraph static function kotoba_css() { // This makes sure that the positioning is also good for right-to-left languages $x = is_rtl() ? 'left' : 'right'; echo " "; } } add_action('admin_init', 'AiKotoba::settings_api_init'); // Now we set that function up to execute when the admin_notices action is called add_action( 'admin_notices', 'AiKotoba::ai_kotoba' ); add_action( 'admin_head', 'AiKotoba::kotoba_css' ); ?>