0
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 &copy";

        ?>
        <?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©" 的默认值并回调它的工作,我也需要为将来的偏好进行编辑,任何帮助都可以

4

1 回答 1

1

您可以使用插件激活挂钩来设置插件激活时所需的值。将此添加到您的插件文件以在set_up_options激活插件时运行该功能。

register_activation_hook( __FILE__, 'set_up_options' );

function set_up_options(){
  add_option('name', 'value');
}
于 2013-03-11T10:16:00.310 回答