Example #1
0
 public static function generate($text)
 {
     static $result;
     if (preg_match("/^(.*)\\{([^\\{\\}]+)\\}(.*)\$/isU", $text, $matches)) {
         $p = explode('|', $matches[2]);
         foreach ($p as $comb) {
             textGenerator::generate($matches[1] . $comb . $matches[3]);
         }
     } else {
         $result[] = $text;
         return 0;
     }
     $results = array_values(array_unique($result));
     return $results[rand(0, count($results) - 1)];
 }
Example #2
0
 public function generateTitle($term_id)
 {
     $wp_options = get_option('video_parser_options');
     $generator_options = isset($wp_options['video_parser_generator_list']) ? $wp_options['video_parser_generator_list'] : [];
     foreach ($generator_options as $key => $option) {
         if ($key == $term_id && strlen($option) > 0) {
             $generator_list = explode("\n", $option);
             $random_line = rand(0, count($generator_list) - 1);
             if ($generated_text = textGenerator::generate(trim($generator_list[$random_line]))) {
                 return $generated_text;
             } else {
                 return false;
             }
         }
     }
     return false;
 }