Instantly share code, notes, and snippets.
Created Aug 1, 2014
投稿画面にテキストやボタンを挿入してポップアップウィンドウを開く(iframe)クラス化#WordPressプラグイン
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: paka3_editer_media_button | |
Plugin URI: http://www.paka3.com/wpplugin | |
Description: 投稿画面にテキストやボタンを挿入してポップアップウィンドウを開く | |
Author: Shoji ENDO | |
Version: 0.1 | |
Author URI:http://www.paka3.com/ | |
*/ | |
$p3EMB= new Paka3EditerMediaButton(); | |
class Paka3EditerMediaButton | |
{ | |
public function __construct(){ | |
add_filter( "media_buttons_context" , array( &$this, "paka3_media_buttons_context" ) ); | |
//ポップアップウィンドウ | |
//media_upload_{ $type } | |
add_action('media_upload_paka3Type', array( &$this,'paka3_wp_iframe' ) ); | |
} | |
//########################## | |
//メディアボタンの表示 | |
//########################## | |
public function paka3_media_buttons_context ( $context ) { | |
$img = plugin_dir_url( __FILE__ ) ."icon.png"; | |
$link = "media-upload.php?tab=paka3Tab&type=paka3Type&TB_iframe=true&width=600&height=550"; | |
$context .= <<<EOS | |
<a href='{$link}' | |
class='thickbox' title='お助けウィンドウ'> | |
<img src='{$img}' /></a> | |
EOS; | |
return $context; | |
} | |
//########################## | |
//ポップアップウィンドウ | |
//########################## | |
function paka3_wp_iframe() { | |
wp_iframe(array( $this , 'media_upload_paka3_form' ) ); | |
} | |
//関数名をmedia_***としないとスタイルシートが適用されない謎 | |
function media_upload_paka3_form() { | |
add_filter( "media_upload_tabs", array( &$this, "paka3_upload_tabs" ) ,1000); | |
media_upload_header(); | |
echo <<< EOS | |
<div id="paka3_popup_window"> | |
<h2>ココには何かが書かれています</h2> | |
<p>とりあえず、実用性は置いといてね。次で。 | |
こんなこと<br /> | |
あんなこと<br /> | |
そんなこと</p> | |
</div> | |
EOS; | |
} | |
//########################## | |
//ポップアップウィンドウのタブ | |
//########################## | |
function paka3_upload_tabs( $tabs ) | |
{ | |
$tabs = array(); | |
$tabs[ "paka3Tab" ] = "文字だけ表示してるよ" ; | |
return $tabs; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment