本次研究的插件是backupbuddy,WordPress后台首页widget如下图,看看backupbuddy是怎么写的
首先找到了它的显示代码,用于输出widget内容
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
<?php class pb_backupbuddy_dashboard extends pb_backupbuddy_dashboardcore {//继承pb_backupbuddy_dashboardcore类 /* stats() * * Displays (echos out) an overview of stats into the WordPress Dashboard. * * @return null */ function stats() { echo '<style type="text/css">'; echo ' .pb_fancy {'; echo ' font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;'; echo ' font-size: 18px;'; echo ' color: #21759B;'; echo ' }'; echo '</style>'; echo '<div>'; $backup_url = 'admin.php?page=pb_backupbuddy_backup'; $files = glob( backupbuddy_core::getBackupDirectory() . 'backup*.zip' );//搜索备份文件 if ( !is_array( $files ) || empty( $files ) ) {//判断是否有备份 $files = array();//没有则初始化$files为数组 } echo sprintf( __('You currently have %s stored backups.', 'it-l10n-backupbuddy' ), '<span class="pb_fancy"><a href="' . $backup_url . '">' . count( $files ) . '</a></span>'); if ( pb_backupbuddy::$options['last_backup_finish'] == 0 ) { echo ' ', __( 'You have not successfully created any backups.', 'it-l10n-backupbuddy' ); } else { echo ' ', sprintf( __(' Your most recent successful backup was %s ago.', 'it-l10n-backupbuddy' ), '<span class="pb_fancy"><a href="' . $backup_url . '">' . pb_backupbuddy::$format->time_ago( pb_backupbuddy::$options['last_backup_finish'] ) . '</a></span>'); } echo ' ', sprintf( __('There have been %s post/page modifications since your last backup.', 'it-l10n-backupbuddy' ), '<span class="pb_fancy"><a href="' . $backup_url . '">' . pb_backupbuddy::$options['edits_since_last'] . '</a></span>' ); echo ' <span class="pb_fancy"><a href="' . $backup_url . '">', __('Go create a backup!', 'it-l10n-backupbuddy' ), '</a></span>'; echo '</div>'; } } ?> |
这段代码只是负责在调用的时候输出显示,下面来找一下
There are no comments yet