Beispiel #1
0
 /**
  * Adds the test Gistpen data.
  *
  * ## EXAMPLES
  *
  *     wp wpgp add_test_data
  */
 function add_test_data($args, $assoc_args)
 {
     remove_filter('the_content', 'wpautop');
     remove_filter('the_content', 'wptexturize');
     remove_filter('the_content', 'capital_P_dangit');
     remove_filter('the_content', 'convert_chars');
     remove_filter('get_the_excerpt', 'wp_trim_excerpt');
     // Normal filtering
     remove_filter('title_save_pre', 'wp_filter_kses');
     // Comment filtering
     remove_filter('pre_comment_content', 'wp_filter_post_kses');
     remove_filter('pre_comment_content', 'wp_filter_kses');
     // Post filtering
     remove_filter('content_save_pre', 'wp_filter_post_kses');
     remove_filter('excerpt_save_pre', 'wp_filter_post_kses');
     remove_filter('content_filtered_save_pre', 'wp_filter_post_kses');
     foreach (Language::$supported as $lang => $slug) {
         $lang_model = new Language(\WP_Gistpen::$plugin_name, \WP_Gistpen::$version, $slug);
         // Code snippets sourced from: https://highlightjs.org/static/demo/
         $code = '';
         $fh = fopen(WP_GISTPEN_DIR . 'test/data/' . $slug, 'r');
         while ($line = fgets($fh)) {
             $code .= $line;
         }
         fclose($fh);
         $zip_data = array();
         $zip_data['status'] = 'publish';
         $zip_data['description'] = $lang . ' Example';
         $zip_data['files'] = array();
         $file = array();
         $file['code'] = trim($code);
         $file['slug'] = $slug . '-file.' . $lang_model->get_file_ext();
         $file['language'] = $slug;
         $zip_data['files'][] = $file;
         $this->save->update($zip_data);
         WP_CLI::success(__("Successfully added example for language {$lang}", \WP_Gistpen::$plugin_name));
         sleep(1);
     }
 }
 function test_fix_file_ext_sass()
 {
     $language = new Language(WP_Gistpen::$plugin_name, WP_Gistpen::$version, 'sass');
     $this->assertEquals('scss', $language->get_file_ext());
 }