Hallo zusammen,
ich hoffe, dass ich hier Hilfe bekomme, denn wordpress ist für mich was neues.
Ich habe folgenden Plugin (siehe den code unten) selber erstellt und installiert, soweit alles gut. Nun möchte ich mit einem Button "Add new" mehrere Instanzen erstellen von diesem page, sodass wenn auf "add new" ancklicke, dann wird neues Page-instance erstellt und neben dem aktuellen erscheint. ich habe es damit versucht, funktioniert aber nicht:
PHP
<input type="button" name="newInstance" value="Add New"
onClick="<?php $test=new test()?>;">
</p>
</form>
hat jemand eine Idee?
Hier ist mein plugin:
PHP
<?php
/**
* @package test
* @version 1.0
*/
/*
Plugin Name: Test
Plugin URI: http://www.test.de
Description:
Author: das ist nur ein Test
Version: 1.0.0
Author URI:
*/
class test{
var $page=1;
function __construct() {
$this->page=$this->page+1;
add_action('admin_init', array( &$this, 'admin_init' ) );
add_action('admin_menu', array( &$this, 'options_add_menu'));
} // function
function admin_init() {
register_setting( 'cf7_sf_options', 'cf7_sf_options', array(&$this,'options_validate' ));
add_settings_field('cf7_sf_id', 'ID', array(&$this,'cf7_sf_id'), 'cf7_sf', 'cf7_sf_section_misc');
add_settings_section('cf7_sf_section_misc', 'Allgemein', array(&$this,'options_cf7_sf_misc_text'), $this->page);
add_settings_field('cf7_sf_debug_mail', 'Email', array(&$this,'cf7_sf_debug_mail'), $this->page, 'cf7_sf_section_misc');
}
function options_add_menu() {
add_options_page('Test', 'Test', 'manage_options', $this->page, array(&$this,'options_add_page'));
}
function options_add_page() {
?>
<div>
<h2>Test</h2>
<form action="<?php $test=new test()?>;">
<p>
<input type="button" name="newInstance" value="Add New"
onClick="<?php $test=new test()?>;">
</p>
</form>
<form action="options.php" method="post">
<?php settings_fields('cf7_sf_options');?>
<?php do_settings_sections($this->page);?>
<input name="Submit" type="submit" value="<?php esc_attr_e('Save Changes'); ?>" />
</form></div>
<?php
}
function options_cf7_sf_misc_text() {
echo '<p>Allgemeine Einstellungen</p>';
}
function cf7_sf_debug_mail() {
$options = get_option('cf7_sf_options');
$value = $options['debug_mail'];
echo "<input id='cf7_sf_options[debug_mail]' name='cf7_sf_options[debug_mail]' size='40' type='text' value='{$value}' />";
}
}
$test = new test;
?>
Alles anzeigen