內容簡介
將 Canvas 整合到 WordPress 中
提供畫布短碼
在儲存畫布時提供過濾鉤子
支援滑鼠與觸控螢幕
支援管理畫面和公開畫面,公開畫面上的按鈕和選擇框的外觀取決於主題的 CSS。
如何使用畫布
過濾鉤子使用範例
顯示畫布的短碼
echo do_shortcode( '[freecanvas height=500]' );
短碼
屬性:預設值:說明
width:700:畫布寬度
height:700:畫布高度
name:載入畫布的日期和時間字串:為此畫布提供唯一名稱
form_name:null:你想獲取的表單值的名稱
form_name2:null:你想獲取的表單值的名稱
form_name3:null:你想獲取的表單值的名稱
過濾鉤子 & 函數
/**
* 過濾鉤子和輸出 PNG 圖像文件的函數 */
*
* @param string $image_data image_data。
* @param string $name name。
* @param string $form_value form_value。
* @param string $form_value2 form_value2。
* @param string $form_value3 form_value3。
*/
function canvas_save( $image_data, $name, $form_value, $form_value2, $form_value3 ) {
$wp_uploads = wp_upload_dir();
$relation_path_true = strpos( $wp_uploads['baseurl'], '../' );
if ( $relation_path_true > 0 ) {
$upload_dir = wp_normalize_path( realpath( $wp_uploads['basedir'] ) );
} else {
$upload_dir = wp_normalize_path( $wp_uploads['basedir'] );
}
$filename = $upload_dir . '/' . $name . '.png';
$image = imagecreatefromstring( $image_data );
imagepng( $image, $filename );
}
add_filter( 'free_canvas_save', 'canvas_save', 10, 5 );
過濾鉤子
變數:說明:來自
$image_data:經過 Base64 編碼的 PNG 圖像數據:畫布的值
$name:為此畫布提供唯一名稱:Free Canvas 的值
$form_value:從 form_name 獲取的表單值:表單的值
$form_value2:從 form_name2 獲取的表單值:表單的值
$form_value3:從 form_name3 獲取的表單值:表單的值
外掛標籤
開發者團隊
原文外掛簡介
Integrates Canvas into WordPress.
Provide canvas shortcode.
Provides a filter hook when saving the canvas.
It supports both mouse and touch.
It supports both the management screen and the public screen. The appearance of buttons and select boxes on the public screen depends on the CSS of the theme.
How to use the canvas
Sample of how to use the filter hook
Shortcode for canvas display
echo do_shortcode( '[freecanvas height=500]' );
shortcode
Attribute : Default : Description
width : 700 : Canvas width
height : 700 : Canvas height
name : The date and time string when the canvas was loaded : Unique name for this canvas
form_name: null : The name of the form value you want to get
form_name2: null : The name of the form value you want to get
form_name3: null : The name of the form value you want to get
Filter hook & Function
/**
* Filter hook & function for outputs a PNG image file */
*
* @param string $image_data image_data.
* @param string $name name.
* @param string $form_value form_value.
* @param string $form_value2 form_value2.
* @param string $form_value3 form_value3.
*/
function canvas_save( $image_data, $name, $form_value, $form_value2, $form_value3 ) {
$wp_uploads = wp_upload_dir();
$relation_path_true = strpos( $wp_uploads['baseurl'], '../' );
if ( $relation_path_true > 0 ) {
$upload_dir = wp_normalize_path( realpath( $wp_uploads['basedir'] ) );
} else {
$upload_dir = wp_normalize_path( $wp_uploads['basedir'] );
}
$filename = $upload_dir . '/' . $name . '.png';
$image = imagecreatefromstring( $image_data );
imagepng( $image, $filename );
}
add_filter( 'free_canvas_save', 'canvas_save', 10, 5 );
Filter hook
Variable : Description : From
$image_data : PNG image data by Base64 : Value of Canvas
$name : Unique name for this canvas : Value of Free Canvas
$form_value : Form value obtained from form_name : Value of Form
$form_value2 : Form value obtained from form_name2 : Value of Form
$form_value3 : Form value obtained from form_name3 : Value of Form
