投稿画面のタイトル入力域幅とビジュアルリッチエディタ入力域幅を変更するプラグイン : WordPress

Pocket

WordPressで簡単なプラグインの作成 : WordPressの実例として簡単なWordPressプラグインを作成。

機能

WordPressの投稿画面のタイトル入力域の幅とビジュアルリッチエディタ入力域の幅を変更する。

ダウンロード

»ダウンロード

ソースコード

<?php
/*
Plugin Name: Resize Edit Conten
Version: 0.1
Plugin URI: http://www.findxfine.net
Description: 投稿画面の入力域のサイズを変更する
Author: findxfine
Author URI: http://www.findxfine.net
*/



//--------------------------------------------------------------------------
//
//  管理画面>設定>プラグインの設定項目を追加
//
//--------------------------------------------------------------------------

// 管理メニューにプラグイン設定項目を追加するフック
add_action('admin_menu', 'resize_edit_content_admin_pages');

// 上のフックに対するaction関数
function resize_edit_content_admin_pages()
{
	// 管理画面>設定>プラグイン設定項目を追加
	add_options_page('Resize Edit Content', 'Resize Edit Content', 8, 'file', 'resize_edit_content_options_page');
}

// プラグイン設定画面を表示する関数。
function resize_edit_content_options_page()
{
	// 設定画面を表示する
?>
	<div class="wrap">
		<h2>Resize Edit Content</h2>
		<form method="post" action="options.php">
			<?php wp_nonce_field('update-options'); ?>
			<table class="form-table">
				<tr>
					<th>投稿画面横幅</th>
					<td><input type="text" name="postdivrichwidth" value="<?php echo get_option('postdivrichwidth'); ?>" size="4"/> px</td>
				</tr>
				<tr>
					<th>タイトル横幅</th>
					<td><input type="text" name="titlewrapwidth" value="<?php echo get_option('titlewrapwidth'); ?>" size="4"/> px</td>
				</tr>
			</table>
			<input type="hidden" name="action" value="update" />
			<input type="hidden" name="page_options" value="postdivrichwidth,titlewrapwidth" />
			<p class="submit">
				<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
			</p>
		</form>
	</div>
<?php
}
//--------------------------------------------------------------------------
//
//  プラグイン停止の際に追加したフィールドを削除
//
//--------------------------------------------------------------------------
add_action('deactivate_resize_edit_content/resize_edit_content.php', 'remove_resize_edit_content');
function remove_resize_edit_content()
{
	delete_option('postdivrichwidth');
	delete_option('titlewrapwidth');
}

//--------------------------------------------------------------------------
//
//  投稿エリアのサイズ変更
//
//--------------------------------------------------------------------------
add_action('admin_head', 'resizeEditContent');
function resizeEditContent()
{
	$titleAreaValue = get_option('titlewrapwidth'); // titlewrapwidthはWordPressが付けたタイトルに対するCSSのID名
	$postAreaValue = get_option('postdivrichwidth'); // postdivrichwidthはWordPressが付けたビジュアルリッチエディタに対するCSSのID名
	if($postAreaValue && $titleAreaValue)
	{
		echo "
			<style type='text/css'>
			div#postdivrich {
				width: {$postAreaValue}px;
				overflow: hidden;
			}
			div#titlewrap {
				width: {$titleAreaValue}px;
				overflow: hidden;
			}
			</style>
		";
	}
}

?>

コメント

Trackbacks

  1. […] 投稿画面のタイトル入力域の幅とビジュアルリッチエディタ入力域の幅を変更するWordPressプラグイン : WordPress,プラグイン […]

    ピンバックbyPHP & RUBY » Blog Archive » word press ビジュアルリッチエディタと独自プラグインの開発方法 — 2010-03-29 @ 5:11 PM

  2. […] FindxFineさんのサイトで紹介されている「投稿画面のタイトル入力域幅とビジュアルリッチエディタ入力域幅を変更するプラグイン」が非常に役に立っているので紹介します。 […]

    ピンバックbyビジュアルリッチエディターの表示幅を変更するプラグイン « 無料で使えるWordpressで1日5000円稼ぐためのショップ&HP作り研究サイト — 2013-03-28 @ 11:42 AM


コメントの投稿

改行と段落タグは自動で挿入されます。
メールアドレスは表示されません。