', thk_simple_css_minify( $admin_inline_styles ), ''; } }, 99 ); /*--------------------------------------------------------------------------- * admin_print_scripts / admin_print_styles *---------------------------------------------------------------------------*/ /* jquery-ui script */ add_action( 'admin_print_scripts', function() { if( _is_block_editor() === false || ( isset( $_GET['page'] ) && stripos( $_GET['page'], 'luxe_' ) === 0 ) ) { wp_enqueue_script( 'thk-jquery-ui-script', TURI . '/js/jquery-ui.min.js', array( 'jquery' ), false, false ); } }, 99 ); if( current_user_can( 'edit_published_posts' ) === true ) { // イメージセレクター用 Javascript add_action( 'admin_print_scripts', function() { wp_enqueue_media(); wp_enqueue_script( 'thk-imgselector-script', get_template_directory_uri() . '/js/thk-imgselector.js', array( 'media-views' ), false ); wp_localize_script( 'media-views', '_thkImageViewsL10n', array( 'setImage' => __( 'Set image', 'luxeritas' ) ) ); }); // イメージセレクター用 CSS add_action( 'admin_print_styles', function() { wp_register_style( 'thk-imgselector-style', get_template_directory_uri() . '/css/thk-imgselector.css', false, false ); wp_enqueue_style( 'thk-imgselector-style' ); }); // メディア画面で ALT 属性を自動設定 /* if( isset( $luxe['media_alt_auto_input'] ) ) { add_filter( 'wp_prepare_attachment_for_js', function( $args, $attachment, $meta ) { if( empty( $args['alt'] ) ) $args['alt'] = $args['title']; return $args; }, 10, 3 ); } */ } /*--------------------------------------------------------------------------- * 管理画面で使う CSS の読み込み *---------------------------------------------------------------------------*/ if( function_exists( 'thk_add_admin_inline_css' ) === false ): function thk_add_admin_inline_css( $css_path ) { if( file_exists( $css_path ) === true ) { ob_start(); require( $css_path ); $css = ob_get_clean(); return $css; } return ''; } endif; /*--------------------------------------------------------------------------- * ブロックエディタかどうかを判別する関数 *---------------------------------------------------------------------------*/ if( function_exists( '_is_block_editor' ) === false ): function _is_block_editor() { global $post; if( apply_filters( 'replace_editor', false, $post ) !== true ) { if( function_exists( 'use_block_editor_for_post' ) === true ) { if( use_block_editor_for_post( $post ) ) { return true; } else { return false; } } } else { return false; } } endif; /*--------------------------------------------------------------------------- * wp_dropdown_pages の投稿ページ版 *---------------------------------------------------------------------------*/ if( function_exists( 'thk_dropdown_posts' ) === false ): function thk_dropdown_posts( $args = '' ) { $defaults = array( 'selected' => false, 'pagination' => false, 'post_type' => 'post', 'posts_per_page' => - 1, 'post_status' => 'publish', 'cache_results' => true, 'cache_post_meta_cache' => true, 'echo' => 1, 'select_name' => 'post_id', 'id' => '', 'class' => '', 'show' => 'post_title', 'show_callback' => null, 'show_option_all' => null, 'show_option_none' => null, 'option_none_value' => '', 'multi' => false, 'value_field' => 'ID', 'order' => 'ASC', 'orderby' => 'post_title', ); $r = wp_parse_args( $args, $defaults ); $posts = get_posts( $r ); $output = ''; $show = $r['show']; if( !empty( $posts ) ) { $name = esc_attr( $r['select_name'] ); if( $r['multi'] && ! $r['id'] ) { $id = ''; } else { $id = $r['id'] ? " id='" . esc_attr( $r['id'] ) . "'" : " id='$name'"; } $output = ""; } $ret = apply_filters( 'thk_dropdown_posts', $output, $r, $posts ); if( $r['echo'] ) echo $ret; return $ret; } endif; /*--------------------------------------------------------------------------- * 投稿画面のボタン配列 *---------------------------------------------------------------------------*/ // TinyMCE ボタン 1段目 if( function_exists( 'thk_mce_buttons_1' ) === false ): function thk_mce_buttons_1() { return array( 'formatselect' => '
', 'thk-phrase-button' => '', 'thk-shortcode-button' => '', 'thk-blogcard-button' => '', 'visualblocks' => '', 'bold' => '', 'italic' => '', 'bullist' => '', 'numlist' => '', 'blockquote' => '', 'alignleft' => '', 'aligncenter' => '', 'alignright' => '', 'link' => '', 'unlink' => '', 'table' => '', 'thk_emoji' => '', 'wp_more' => '', 'wp_page' => '', //'spellchecker' => true, // 元の配列には存在するけど表示はされない (TinyMCE のプラグインが入ってない。日本語チェックできないからイラネ) /* 以下、常に表示させるので配列から削除 */ //'kitchensink' => true, // 2段目を表示・非表示するやつ //'wp_adv' => true, // kitchen sink のエイリアス (ツールチップの名前が違う) //'dfw' => true, // distraction free writing mode (集中執筆モード) ); } endif; // TinyMCE ボタン 2段目 if( function_exists( 'thk_mce_buttons_2' ) === false ): function thk_mce_buttons_2() { return array( 'fontsizeselect' => '', 'fontselect' => '', 'strikethrough' => '', 'underline' => '', 'hr' => '', 'forecolor' => '', 'backcolor' => '', 'pastetext' => '', 'removeformat' => '', 'charmap' => '', 'outdent' => '', 'indent' => '', 'undo' => '', 'redo' => '', 'searchreplace' => '', 'wp_help' => '', 'thk-mce-settings-button' => '', ); } endif; // TinyMCE ボタン 未使用(ごみ箱) if( function_exists( 'thk_mce_buttons_d' ) === false ): function thk_mce_buttons_d() { return array( 'toc' => '', 'copy' => '', 'paste' => '', 'cut' => '', 'nonbreaking' => '', 'anchor' => '', 'insertdatetime' => '', 'ltr' => '', 'rtl' => '', 'wp_code' => '', 'alignjustify' => '', 'visualchars' => '', 'superscript' => '', 'subscript' => '', 'image' => '', 'media' => '', 'print' => '', 'fullscreen' => '', ); } endif; // テキスト入力ボタン if( function_exists( 'thk_txt_buttons_1' ) === false ): function thk_txt_buttons_1() { $ret = array(); $ids = array( 'thk-b' => 'b', 'em' => 'i', 'thk-strong' => 'strong', 'link' => 'link', 'thk-div' => 'div', 'thk-span' => 'span', 'block' => 'b-quote', 'thk-h2' => 'h2', 'thk-h3' => 'h3', 'thk-h4' => 'h4', 'thk-hr' => 'hr', 'del' => 'del', 'ins' => 'ins', 'img' => 'img', 'ul' => 'ul', 'ol' => 'ol', 'li' => 'li', 'thk-pre' => 'pre', 'code' => 'code', 'thk-next' => 'nextpage', 'more' => 'more', 'thk-phrase' => __( 'HTML patterns', 'luxeritas' ), 'thk-shortcode' => __( 'Shortcode', 'luxeritas' ), 'thk-blogcard' => __( 'Blog Card', 'luxeritas' ), 'close' => __( 'close tags', 'luxeritas' ), ); foreach( $ids as $key => $val ) { $ret[$key] = ''; } return $ret; } endif;