seve settings

'; } echo '
'; wp_nonce_field('wpasciidoc'); echo '

Mode:

'; echo '

'; echo '

If you want to set in each posts and pages, Please check here.

'; echo '
'; echo '

'; echo '

If you want use with "Front end editor" or "wordpress.com", must be check here.

'; echo '
'; echo '

Extra settings:

'; echo '

Use Asciidoc css

'; echo '

If you want use Asciidoc css, please check here.

'; echo '
'; echo '

Use Asciidoctor images format

'; echo '

If you want use Asciidoctor images format, please check here.

'; echo '
'; echo '

highlight.js

'; echo '

If you want use highlight.js, please check here.

'; echo '
'; echo '

Without paragraph in the tables cell

'; echo '

If you want without paragraph in the tables cell, please check here.

'; echo submit_button(); echo '
'; } add_action( 'wp_enqueue_scripts', 'asciidoc_css_and_scripts' ); //add css and script function asciidoc_css_and_scripts(){ $wpasc_check_highlight = get_option('wpasc_check_highlight'); if($wpasc_check_highlight == '1'){ wp_enqueue_style( 'github-gist.css', plugins_url('/css/github.css', __FILE__) , array(), '' ); wp_enqueue_script( 'highlight.js', plugins_url('/js/highlight.min.js', __FILE__) , array(), '' ); wp_enqueue_script( 'setting_highlight.js', plugins_url('/js/setting_highlight.js', __FILE__) , array(), '' ); } wp_enqueue_script( 'jquery' ); wp_enqueue_script( 'asciidoctor.js', plugins_url('/js/asciidoctor-all.min.js', __FILE__) , array(), '' ); wp_enqueue_script( 'setting.js', plugins_url('/js/setting.js', __FILE__) , array(), '' ); $wpasc_check_asciidoccss = get_option('wpasc_check_asciidoccss'); if($wpasc_check_asciidoccss == '1'){ wp_enqueue_style( 'asciidoctor.css', plugins_url('/js/css/asciidoctor.css', __FILE__) , array(), '' ); } $wpasc_check_table_paragraph = get_option('wpasc_check_table_paragraph'); if($wpasc_check_table_paragraph == '1'){ wp_enqueue_script( 'footer_setting.js', plugins_url('/js/footer_setting.js', __FILE__) , array(), '', true ); } } // if select Individual posts mode display check field in post edit pages $wpasc_mode_select = get_option('wpasc_mode_select'); if($wpasc_mode_select == '0'){ function add_wpasciidoc_custom_inputbox() { $screens = array( 'post', 'page','custom_post_type' ); foreach ( $screens as $screen ) { add_meta_box( 'wpasciidoc_id', __( 'Asciidoc', 'Asciidoc' ), 'wpasciidoc_custom_field', $screen, 'side', 'high' ); } } add_action('admin_menu', 'add_wpasciidoc_custom_inputbox'); add_action('save_post', 'save_wpasciidoc_custom_postdata'); // make custom field function wpasciidoc_custom_field(){ $id = get_the_ID(); $get_wpasciidoc_checkbox = get_post_meta($id,'wpasciidoc_checkbox',true); echo ''; } // update process function save_wpasciidoc_custom_postdata($post_id){ //input value $wpasciidoc_checkbox=sanitize_text_field($_POST['wpasciidoc_checkbox']) ? $_POST['wpasciidoc_checkbox']: null; //date on db $wpasciidoc_checkbox_ex = get_post_meta($post_id, 'wpasciidoc_checkbox', true); if($wpasciidoc_checkbox){ update_post_meta($post_id, 'wpasciidoc_checkbox',$wpasciidoc_checkbox); }else{ delete_post_meta($post_id, 'wpasciidoc_checkbox',$wpasciidoc_checkbox_ex); } } } //change asciidoc to html add_filter('the_content','wpasciidoc_custom'); function wpasciidoc_custom($contentData){ $id = get_the_ID(); $custom = get_post_meta($id, "wpasciidoc_checkbox", true); if (is_array($custom)) { $custom = implode($custom); } // make javascript after each post for quick change asciidoc to html $wpasc_mode_select = get_option('wpasc_mode_select'); if($wpasc_mode_select == '0'){ if($custom == "1"){ return '
'; }else{ $contentData = wpautop( $contentData ); $contentData = wptexturize( $contentData ); return $contentData; } }elseif ($wpasc_mode_select == '1') { return '
'; }else{ $contentData = wpautop( $contentData ); $contentData = wptexturize( $contentData ); return $contentData; } } //remove_filter wpautop and wptexturize add_action('init', function() { remove_filter('the_content', 'wpautop'); remove_filter('the_content', 'wptexturize'); }); add_filter('tiny_mce_before_init', function($init) { $init['wpautop'] = false; $init['apply_source_formatting'] = ture; return $init; }); //add asciidoctor image format $wpasc_check_image = get_option('wpasc_check_image'); if($wpasc_check_image == '1'){ function wpasciidoc_image_wrap($html, $id, $caption, $title, $align, $url, $size, $alt){ list( $img_src, $width, $height ) = image_downsize($id, $size); $media_array = array(); if ($width ==! ""){$width = 'width="'.$width.'"';$media_array[]=$width;} if ($height ==! ""){$height = 'height="'.$height.'"';$media_array[]=$height;} if ($alt ==! ""){$alt = 'alt="'.esc_attr($alt).'"';$media_array[]=$alt;} if ($url ==! ""){$url = 'link="'.$url.'"';$media_array[]=$url;} if ($align ==! ""){$align = 'align="'.$align.'"';$media_array[]=$align;} $comma_separated = implode(", ", $media_array); $html = 'image::' . esc_attr($img_src) . '['.$comma_separated.']'; return $html; } add_filter('image_send_to_editor','wpasciidoc_image_wrap',10,8); define('CAPTIONS_OFF', true); add_filter('disable_captions', create_function('','return true;')); } ?>