Skip to content

Commit

Permalink
Merge pull request #6 from Automattic/add/markdownify-testing-list
Browse files Browse the repository at this point in the history
Beta Testing List: allow more formatting with Markdown
  • Loading branch information
samhotchkiss committed Jan 13, 2016
2 parents 372b3a4 + 506cefe commit 339ca10
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 25 deletions.
20 changes: 20 additions & 0 deletions admin/jpbeta-admin-main.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,26 @@
margin-top: 15px;
}

.jetpack_page_jetpack-beta .card ul {
list-style-type: disc;
}

.jetpack_page_jetpack-beta .card #jp_beta_choose_type ul {
list-style-type: none;
}

.j-beta-wrap .card pre code {
display: block;
}

.j-beta-wrap .card pre {
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}

.jetpack_page_jetpack-beta .card .feedback {
margin-top: 20px;
font-size: 18px;
Expand Down
72 changes: 47 additions & 25 deletions jetpack-beta.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,37 +96,59 @@ function load_debug_bar_jpa_info() {
add_action( 'admin_init', 'load_debug_bar_jpa_info' );

function jpbeta_get_testing_list() {
$test_list_path = WP_PLUGIN_DIR . '/jetpack/to-test.txt';
$test_list_path = WP_PLUGIN_DIR . '/jetpack/to-test.md';
if ( ! file_exists( $test_list_path ) ) {
return "You're not currently using a beta version of Jetpack";
}
$test_list_file = file_get_contents( $test_list_path );
$test_list_rows = explode( "\n", $test_list_file );


unset( $test_list_rows[0] );
unset( $test_list_rows[1] );
unset( $test_list_rows[2] );

$o = '';

foreach( $test_list_rows as $row ) {
if( strpos( $row, '===' ) === 0 ) {
if( $o ) {
$o .= '</ul>';
break;

$test_list_file = file_get_contents( $test_list_path );

if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'markdown' ) ) {

// We'll apply standard content filters to our content.
add_filter( 'jetpack_beta_test_content', 'wptexturize' );
add_filter( 'jetpack_beta_test_content', 'convert_smilies' );
add_filter( 'jetpack_beta_test_content', 'convert_chars' );
add_filter( 'jetpack_beta_test_content', 'wpautop' );
add_filter( 'jetpack_beta_test_content', 'shortcode_unautop' );
add_filter( 'jetpack_beta_test_content', 'prepend_attachment' );

// Then let's use Jetpack Markdown to process our content
jetpack_require_lib( 'markdown' );
$o = WPCom_Markdown::get_instance()->transform( $test_list_file, array('id'=>false,'unslash'=>false) );
$o = apply_filters( 'jetpack_beta_test_content', $o );

} else {

$test_list_rows = explode( "\n", $test_list_file );

unset( $test_list_rows[0] );
unset( $test_list_rows[1] );
unset( $test_list_rows[2] );

$o = sprintf(
__( "<h2>Please <a href='%s'>enable Jetpack's Markdown Module</a> for a better display of this list.</h2>", 'jpbeta' ),
Jetpack::admin_url( 'page=jetpack_modules' )
);

foreach( $test_list_rows as $row ) {
if( strpos( $row, '===' ) === 0 ) {
if( $o ) {
$o .= '</ul>';
break;
}
$o = '<h3 title="Testing items for Jetpack">Testing items for Jetpack ' . trim( str_replace( '===', '', $row ) ) . '</h3>';
$o .= '<ul>';
continue;
}
if( strpos( $row, '*' ) === 0 ) {
$o .= '<li><p><strong>' . trim( str_replace( '*', '', $row ) ) . '</strong></p>';
} else {
$o .= '<p>' . $row . '</p></li>';
}
$o = '<h3 title="Testing items for Jetpack">Testing items for Jetpack ' . trim( str_replace( '===', '', $row ) ) . '</h3>';
$o .= '<ul>';
continue;
}
if( strpos( $row, '*' ) === 0 ) {
$o .= '<li><p><strong>' . trim( str_replace( '*', '', $row ) ) . '</strong></p>';
} else {
$o .= '<p>' . $row . '</p></li>';
}

}

return $o;
}

Expand Down

0 comments on commit 339ca10

Please sign in to comment.