• Hoi,

    Ik ben bezig om een plugin te maken zodat ik een archief kan maken wat er zo uitziet ( http://floatleft.com/notebook/wordpress-year-month-archives/)

    De code ziet er zo uit :

    <?php
    /*
    Plugin Name: Custom archive plugin
    Plugin URI: http://www.wpexplorer.com/
    Description: A simple plugin that adds a simple widget
    Version: 1.0
    Author: WPExplorer
    Author URI: http://www.wpexplorer.com/
    License: GPL2
     */
    ?>
    
    claas custom_archive extends WP_Widget {
    
    	// constructor
    	function custom_archive() {
    		parent::WP_Widget(false, $name = __('My Widget', 'custom_archive') );
    	}
    
    	// widget form creation
    	function form($instance) {
    	  // Check values
            if( $instance) {
                 $title = esc_attr($instance['title']);
                 $text = esc_attr($instance['text']);
                 $textarea = esc_textarea($instance['textarea']);
            } else {
                 $title = '';
                 $text = '';
                 $textarea = '';
             }
             ?>
             <p>
                <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Widget Title', 'wp_widget_plugin'); ?></label>
                <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
             </p>
             <p>
                <label for="<?php echo $this->get_field_id('text'); ?>"><?php _e('Text:', 'wp_widget_plugin'); ?></label>
                <input class="widefat" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>" type="text" value="<?php echo $text; ?>" />
             </p>
             <p>
                <label for="<?php echo $this->get_field_id('textarea'); ?>"><?php _e('Textarea:', 'wp_widget_plugin'); ?></label>
                <textarea class="widefat" id="<?php echo $this->get_field_id('textarea'); ?>" name="<?php echo $this->get_field_name('textarea'); ?>"><?php echo $textarea; ?></textarea>
            </p>
            <?php
            }
    
    	// widget update
    	function update($new_instance, $old_instance) {
               $instance = $old_instance;
              // Fields
              $instance['title'] = strip_tags($new_instance['title']);
              $instance['text'] = strip_tags($new_instance['text']);
              $instance['textarea'] = strip_tags($new_instance['textarea']);
             return $instance;
    	}
    
    	// widget display
    	function widget($args, $instance) {
    	  <?php
             $year_prev = null;
              $months = $wpdb->get_results(	"SELECT DISTINCT MONTH( post_date ) AS month ,
    								YEAR( post_date ) AS year,
    								COUNT( id ) as post_count FROM $wpdb->posts
    								WHERE post_status = 'publish' and post_date <= now( )
    								and post_type = 'post'
    								GROUP BY month , year
    								ORDER BY post_date DESC");
               foreach($months as $month) :
    	          $year_current = $month->year;
    	          if ($year_current != $year_prev){
    		        if ($year_prev != null){?>
    		         </ul>
    		            <?php } ?>
    	                   <h3><?php echo $month->year; ?></h3>
    	                   <ul class="archive-list">
    	                   <?php } ?>
    	                   <li>
    		               <a href="<?php bloginfo('url') ?>/<?php echo $month->year; ?>/<?php echo date("m", mktime(0, 0, 0, $month->month, 1, $month->year)) ?>">
    			        <span class="archive-month"><?php echo date("F", mktime(0, 0, 0, $month->month, 1, $month->year)) ?></span>
    			        <span class="archive-count"><?php echo $month->post_count; ?></span>
    		               </a>
    	                  </li>
                             <?php $year_prev = $year_current;
                endforeach; ?>
                </ul>
    	}
    }
    
    // register widget
    add_action('widgets_init', create_function('', 'return register_widget("custom_archive");'));
    
    ?>

    Maar nu krijg ik deze foutmelding als ik de plugin wil activeren:

    Parse error: syntax error, unexpected ‘}’ in /home/vhosting/c/vhost0008707/domains/tamarawobben.nl/htdocs/test/wp-content/plugins/custom_archive/archive_custom.php on line 46

    Wie kan me helpen dit werkend te krijgen ?

    Groetjes,

    Roelof

4 reacties aan het bekijken - 1 tot 4 (van in totaal 4)
4 reacties aan het bekijken - 1 tot 4 (van in totaal 4)
  • Het onderwerp ‘zelf ontwikkelde plugin werkt niet’ is gesloten voor nieuwe reacties.