タグ :

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

投稿日 : 2009年8月24日 | 更新日 : 2011年03月04日 前のページへ戻る

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>
		";
	}
}

?>

WordPress | 固定リンク | Comments (1)

関連記事

このページの上へ移動

コメント

Trackbacks

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

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


コメントの投稿

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

 

 

 


トラックバックURL

http://www.findxfine.com/programming/wp/1428.html/trackback

このページの上へ