M.Javad 684 ارسال شده در آبان 94 گزارش بازنشر ارسال شده در آبان 94 سلام من میخوام یه ابزارک اختصاصی برای قالبم بسازم که مخصوص قرار دادن آدرس و لینک بنر تبلیغاتی هستشاین کد رو پیدا کردم خودم یکم سیخ کاری کردم ولی نفهمید آخرش باید چیکار کنملطفا اساتید کمک کنند بسازم این ابزارک رو ممنون میشم<?php// Creating the widgetclass wpb_widget extends WP_Widget {function __construct() {parent::__construct(// Base ID of your widget'wpb_widget',// Widget name will appear in UI__('ابزارک تبلیغات', 'bigtheme'),// Widget descriptionarray( 'description' => __( 'این ابزارک مخصوص بخش ابزارک چپ باریک می باشد', 'bigtheme' ), ));}// Creating widget front-end// This is where the action happenspublic function widget( $args, $instance ) {$title = apply_filters( 'widget_title', $instance['title'] );// before and after widget arguments are defined by themesecho $args['before_widget'];if ( ! empty( $title ) )echo $args['before_title'] . $title . $args['after_title'];// This is where you run the code and display the outputecho __( '<a href=""><img src="" width="120" height="auto" /></a>', 'bigtheme' );echo $args['after_widget'];}// Widget Backendpublic function form( $instance ) {if ( isset( $instance[ 'title' ] ) ) {$title = $instance[ 'title' ];}else {$title = __( 'عنوان ابزارک', 'bigtheme' );}// Widget admin form?><p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'آدرس تصویر بنر' ); ?></label><input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p><p><label for="<?php echo $this->get_field_id( 'title2' ); ?>"><?php _e( 'لینک بنر' ); ?></label><input id="<?php echo $this->get_field_id( 'title2' ); ?>" name="<?php echo $this->get_field_name( 'title2' ); ?>" type="text" value="<?php echo esc_attr( $title2 ); ?>" /></p><?php}// Updating widget replacing old instances with newpublic function update( $new_instance, $old_instance ) {$instance = array();$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';return $instance;}} // Class wpb_widget ends here// Register and load the widgetfunction wpb_load_widget() {register_widget( 'wpb_widget' );}add_action( 'widgets_init', 'wpb_load_widget' ); نقل قول لینک به ارسال
پست های پیشنهاد شده
به گفتگو بپیوندید
هم اکنون می توانید مطلب خود را ارسال نمایید و بعداً ثبت نام کنید. اگر حساب کاربری دارید، برای ارسال با حساب کاربری خود اکنون وارد شوید .