[英]Converting a jQuery plugin into a WordPress plugin
對於我的WordPress網站,我確實需要具有該庫提供的功能。
我的問題是,可以將jQuery插件轉換為可工作的WordPress插件嗎? 如果是這樣,怎么辦?
這是制作init.php文件的正確方法嗎?
<?php
/*
Plugin Name: jQuery Windows
Plugin URI: http://fstoke.me/jquery/window
Description: Sexy jQuery Windows.
Version: 5.03
Author: PC - Prashant Chaudhary
Author URI: http://fstoke.me/jquery/window
License: Creative Commons Attribution-ShareAlike
*/
wp_enqueue_style(
'jquerywindowstyles',
WP_PLUGIN_URL.'/jQuery-windows/css/jquery.window.css',
false,
all);
// Add the scripts to the footer
function jquerywindowjs(){
// Identify our javascript files
wp_register_script(
'jquery.window',
WP_PLUGIN_URL.'/jquery-windows/jquery.window.js',
array( 'jquery' ),
"2.1.4",
1 );
wp_register_script(
'jquery.window.min',
WP_PLUGIN_URL.'/jquery-windows/jquery.window.min.js',
array( 'jquery', 'jquery.window' ),
"1.0",
1 );
// Then enqueue them
wp_enqueue_script( 'jquery.window' );
}
// Action our scripts
add_action( 'wp_enqueue_scripts', 'jquerywindowjs' );
?>
直接答案是肯定的,這是可能的。 輕松地 如何做到這一點,是一個不同的問題,而且要詳盡得多。 但是,如果您需要在一個站點中一次性使用它-您始終可以選擇僅使用wp_enqueue_script()
包含腳本,並在您的functions.php
包含wp_enqueue_style()
樣式,然后按原樣使用。 。
但是,您已經有很多具有類似功能的wordpress插件..
參見: http : //wordpress.org/plugins/search.php?q=modal
要么
http://wordpress.org/plugins/search.php?q=popup
並不排除您可以找到與插件相同的腳本,因為實際上有數百個腳本。
當然,要將php / js代碼制作為Wordpress插件的全部工作就是給它提供插件標頭,設置將代碼插入到wordpress中的位置(動作),並可以選擇在PHP中為該插件創建配置頁面WordPress管理員
基本上,這意味着將當前的jquery插件重新包裝為wordpress插件。 它將用作將此插件安裝到wordpress中的一種方式。
WP有相當不錯的文檔: http : //codex.wordpress.org/Writing_a_Plugin
我發現從一個簡單的插件(一個php文件)開始,閱讀它,並查看它是如何工作的,這給了我足夠的信息,可以開始將我的代碼轉換為WP插件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.