'1. ' . __( 'Sample that simply displays a character string', 'luxeritas' ), 'enclosing_shortcode' => '2. ' . __( 'Sample using enclosing shortcode', 'luxeritas' ), 'shortcode_param' => '3. ' . __( 'Sample to display argument given to shortcode', 'luxeritas' ), 'balloon_left' => __( 'Speech balloon', 'luxeritas' ) . ' ( ' . __( 'Left', 'luxeritas' ) . ' ) ', 'balloon_right' => __( 'Speech balloon', 'luxeritas' ) . ' ( ' . __( 'Right', 'luxeritas' ) . ' ) ', 'ads' => 'Google Adsense', ); $shortcode_file_names += thk_syntax_highlighter_list(); $shortcodes_dir = TPATH . DSEP . 'samples' . DSEP . 'shortcodes' . DSEP; require_once( INC . 'shortcode-regist.php' ); thk_filesystem_init(); global $wp_filesystem; foreach( $shortcode_file_names as $key => $val ) { if( isset( $_POST['shortcode_' . $key . '_sample'] ) ) { if( file_exists( $shortcodes_dir . $key . '.json' ) ) { $contents = $wp_filesystem->get_contents( $shortcodes_dir . $key . '.json' ); $contents = str_replace( array( "\r\n", "\n" ), '_', $contents ); /* 吹き出しの項目置換 */ // 吹き出し左画像 $sbl_image_url = isset( $_POST['sbl_image_url'] ) ? $_POST['sbl_image_url'] : ''; $contents = str_replace( '<!-- sbl_image_url -->', $sbl_image_url, $contents ); // 吹き出し左キャプション $sbl_caption = isset( $_POST['sbl_caption'] ) ? $_POST['sbl_caption'] : ''; $contents = str_replace( '<!-- sbl_caption -->', $sbl_caption, $contents ); // 吹き出し右画像 $sbr_image_url = isset( $_POST['sbr_image_url'] ) ? $_POST['sbr_image_url'] : ''; $contents = str_replace( '<!-- sbr_image_url -->', $sbr_image_url, $contents ); // 吹き出し右キャプション $sbr_caption = isset( $_POST['sbr_caption'] ) ? $_POST['sbr_caption'] : ''; $contents = str_replace( '<!-- sbr_caption -->', $sbr_caption, $contents ); $a = (array)@json_decode( $contents ); if( !empty( $a ) ) { foreach( $a as $k => $v ) { $opts = (array)$v; $regist_name = $k; $shortcodes = array( 'label' => $val, 'php' => isset( $opts['php'] ) ? (bool)$opts['php'] : false, 'close' => isset( $opts['close'] ) ? (bool)$opts['close'] : false, 'hide' => isset( $opts['hide'] ) ? (bool)$opts['hide'] : false, 'active' => isset( $opts['active'] ) ? (bool)$opts['active'] : false, ); $code_text = isset( $opts['active'] ) ? unserialize( $opts['contents'] ) : ''; break; } thk_shortcode_regist( $regist_name, $shortcodes, $code_text ); } } } }