function update_ptechsol_details(){
register_setting( 'ptechsol_copyright', 'ptechsolcopy_link');
register_setting( 'ptechsol_copyright', 'ptechsolcopy_name');
register_setting( 'ptechsol_copyright', 'ptechsolcopy_default');
register_setting( 'ptechsol_copyright', 'ptechsolcopy_year');
register_setting( 'ptechsol_copyright', 'ptechsolcopy_text');
}
function copyright() { ?>
<p><em><center><?php echo get_option('ptechsolcopy_default') ?> <?php echo the_date('Y');?> <a href="<?php echo get_option('ptechsolcopy_link'); ?>"><?php echo get_option('ptechsolcopy_name') ?></a> All Rights Reserved.</em></p></center>
<?php }
add_action('wp_footer',copyright);
function copyright_admin_page() {
?>
<div class="wrap">
<b>Pomegranate Technology Solutions Copyright Plugin</b>
<form method="post" action="options.php">
<?php settings_fields( 'ptechsol_copyright' );
global $ptechsolcopy_default;
$ptechsolcopy_default= "Copyright ©";
?>
<?php if(function_exists(do_settings)){do_settings( 'ptechsol_copyright' );} ?>
<input type="hidden" name="post_id" value="copyright_admin_setup" />
<table class="form-table setup">
<tr width="auto" >
<td width="auto">Copyright Injection By Default</td>
<td><input type="text" name="ptechsolcopy_default" value="<?php echo get_option('ptechsolcopy_default');?>" disabled="disabled"/></td></tr>
<tr><td width="auto">Year From:</td>
<td><input type="text" name="ptechsolcopy_year" value="<?php echo get_option('ptechsolcopy_year');?>"/> To: <?php echo Date('Y')?></td> </tr>
<tr>
<td width="auto">Anchor Text</td>
<td width="auto"><input type="text" name="ptechsolcopy_name" value="<?php echo get_option('ptechsolcopy_name');?>"/></td></tr>
<tr>
<td width="auto">Anchor URL</td>
<td width="auto">
<input type="text" name="ptechsolcopy_link" value="<?php echo get_option('ptechsolcopy_link'); ?>" />
</td></tr><tr>
<td width="auto">
Additional Text
</td><td><input type="text" name="ptechsolcopy_text" value="<?php echo get_option('ptechsolcopy_text'); ?>" /></td>
</tr>
</table>
<p class="submit">
<input type="submit" value="<?php _e('Save Changes') ?>" />
</p>
</form>
</div>
<?php
}
?>
嗨,这是我创建的版权插件的上述代码,我需要知道默认情况下如何设置版权注入的默认值。 我想设置像
如何在激活插件时制作默认版权,我对代码执行错误的帮助将会很棒。我为我的目的注册了设置。即使我尝试了默认值$ ptechsolcopy_default =“Copyright&amp; copy”并回调其工作我需要为将来的偏好做出可编辑的任何帮助都是fin
答案 0 :(得分:1)
您可以使用plugin activation hook设置激活插件时所需的值。将此插件添加到插件文件中,以便在插件激活时运行set_up_options
功能。
register_activation_hook( __FILE__, 'set_up_options' );
function set_up_options(){
add_option('name', 'value');
}