aslında ben widget'lar hakkında Thw wordpress kodeksine bakarken bu soru dışarı attı ama bir PHP soru onun daha düşünüyorum. 3 soru burada aslında:
neden Widget contruct 2 görünüşte farklı yöntemler kullanarak kodeksi ve kitap. kodeks kullanımları
parent::WP_Widget(statik yöntem?) ve kitap kullanımları$this->WP_Widget(örnek yöntem?) herhangi bir fark olacak mı?Ben de PHP4 constructer
WP_Widgetolup__constructkullanıldığını fark ettim. ISIT sadece uyumluluk nedenleriyle? i$this->__constructçok doğru kullanabilirsiniz?ben denedim ...
// in pp_widget class extends WP_Widget function __construct() { $this->WP_Widget(...); // or $this->__construct(...) }
ve başarısız
Fatal error: Maximum function nesting level of '100' reached, aborting! in D:\Projects\Websites\wordpress\wp-content\plugins\post-product\post-product.php on line 137 Call Stack: 0.0002 331328 1. {main}() D:\Projects\Websites\wordpress\wp-admin\widgets.php:0 0.0008 331592 2. require_once('D:\Projects\Websites\wordpress\wp-admin\admin.php') D:\Projects\Websites\wordpress\wp-admin\widgets.php:10 0.0013 331848 3. require_once('D:\Projects\Websites\wordpress\wp-load.php') D:\Projects\Websites\wordpress\wp-admin\admin.php:20 0.0020 332224 4. require_once('D:\Projects\Websites\wordpress\wp-config.php') D:\Projects
wordpress kodeksi içinde:
class FooWidget extends WP_Widget {
/** constructor */
function FooWidget() {
parent::WP_Widget(false, $name = 'FooWidget');
}
ve kitap profesyonel wordpress den
class pp_widget extends WP_Widget {
function pp_widget() {
$this->wp_widget(...);
}
yapıcısı için temel wordpress kod
function WP_Widget( $id_base = false, $name, $widget_options = array(), $control_options = array() ) {
$this->__construct( $id_base, $name, $widget_options, $control_options );
}
...
function __construct( $id_base = false, $name, $widget_options = array(), $control_options = array() ) {
$this->id_base = empty($id_base) ? preg_replace( '/(wp_)?widget_/', '', strtolower(get_class($this)) ) : strtolower($id_base);
$this->name = $name;
$this->option_name = 'widget_' . $this->id_base;
$this->widget_options = wp_parse_args( $widget_options, array('classname' => $this->option_name) );
$this->control_options = wp_parse_args( $control_options, array('id_base' => $this->id_base) );
}