2012年12月3日

wp plugin -9

摘要: do_action_ref_array( $tag, $args );$tag — The name of the action hook.$args — An array of arguments passed to actions registered for the hook. Generally, thiswould be an object that actions can change.< ?phpdo_action_ref_array( ‘pre_get_posts’, array( & $this ) );add_action( ‘pre_get_posts’, 阅读全文

posted @ 2012-12-03 21:01 kalintw 阅读(116) 评论(0) 推荐(0)

wp plugin -8

摘要: do_action( $tag, $arg = ‘’ );$tag — The name of the action hook.$arg — Value(s) passed to registered actions. It looks like a single parameter, but this isn ’ talways the case. Action hooks have the option to pass any number of parameters or noparameters at all. You need to check the WordPress sourc 阅读全文

posted @ 2012-12-03 18:10 kalintw 阅读(98) 评论(0) 推荐(0)

wp plugin -7

摘要: Deactivate Is Not UninstallTwo uninstall methods:(1) Uninstall.php:< ?php// If uninstall not called from WordPress exitif( !defined( ‘WP_UNINSTALL_PLUGIN’ ) )exit ();// Delete option from options tabledelete_option( ‘boj_myplugin_options’ );//remove any additional options and custom tables? >( 阅读全文

posted @ 2012-12-03 15:49 kalintw 阅读(119) 评论(0) 推荐(0)

wp plugin -6

摘要: Deactivation:Deactivation时会触发register_deactivation_hook()。register_ deactivation_hook( $file, $function )$file - (string) (required) — Path to the primary plugin fi le$function - (string) (required) — The function to be executed when the plugin is activated例如:< ?phpregister_deactivation_hook( __F 阅读全文

posted @ 2012-12-03 13:19 kalintw 阅读(140) 评论(0) 推荐(0)

wp plugin -5

摘要: options激活时可以设置option:< ?phpregister_activation_hook( __FILE__, ‘boj_install’ );function boj_install() {$boj_myplugin_options = array(‘view’ = > ‘grid’,‘food’ = > ‘bacon’,‘mode’ = > ‘zombie’);update_option( ‘boj_myplugin_options’, $boj_myplugin_options );}? > 阅读全文

posted @ 2012-12-03 13:12 kalintw 阅读(95) 评论(0) 推荐(0)

wp plugin -4

摘要: plugin激活插件激活时,plugin activation function将会被触发。register_activation_hook()。主要用于设置默认options、检测版本兼容等。register_activation_hook( $file, $function );$file - (string) (required) — Path to the primary plugin file$function - (string) (required) — The function to be executed when the plugin is activated例如:< 阅读全文

posted @ 2012-12-03 13:06 kalintw 阅读(103) 评论(0) 推荐(0)

wp plugin -3

摘要: PathsLocal path:plugin_dir_path( __FILE__ );plugin_dir_path( __FILE__ ) .’js/scripts.js’;URL path:plugins_url(),Full plugins directory URL, example:http://example.com/wp-content/pluginsincludes_url(),http://example.com/wp-includescontent_url(), http://example.com/wp-contentadmin_url(), http://exampl 阅读全文

posted @ 2012-12-03 12:46 kalintw 阅读(172) 评论(0) 推荐(0)

wp plugin -2

摘要: Sanity practices:(1)命名前缀。plugin范围内,变量、函数名、文件名加一个唯一前缀。(2)文件组织。至少应该有两个文件:主要的php文件和一个uninstall.php。主要的php可以细分为更多的小文件,便于update和性能。(3)目录结构。example:primary.phpuninstall.php/js/css/includes/imagesHeader:< ?php/*Plugin Name: My PluginPlugin URI: http://example.com/wordpress-plugins/my-pluginDescription: 阅读全文

posted @ 2012-12-03 12:06 kalintw 阅读(120) 评论(0) 推荐(0)

2012年12月2日

wp plugin -1

摘要: plugin本质上就是写一个函数并使用hook注册plugin consists of:(1) header(2) functionregister_activation_hook( $file, $function )register_deactivation_hook($file, $function) 阅读全文

posted @ 2012-12-02 22:31 kalintw 阅读(128) 评论(0) 推荐(0)

2012年9月21日

js lib

摘要: jqueryYUIlightboxscript.aculo.usmoo.fxCurvyCornershtml5: modernizr------------------caniuse.com 阅读全文

posted @ 2012-09-21 16:34 kalintw 阅读(235) 评论(0) 推荐(0)

导航