Visualizzazione dei risultati da 1 a 5 su 5
  1. #1

    %e %B %Y non mostra il formato del mese

    Utilizzando nelle impostazioni %e %B %Y dovrei avere come risultato 15 July 2011, invece ottengo 15 B 2011.

    Vi sarei davvero grato se poteste aiutarmi a risolvere il problema!

    Questo è il codice a mia disposizione:

    Codice PHP:
    <?php
    /*
    Plugin Name: Last modified items widget
    Plugin URI: [url]http://online-source.net/2010/11/17/last-modified-posts-widget/[/url]
    Description: Show the last modified items in a widget with several options.
    Author: Laurens ten Ham (MrXHellboy)
    Version: 1.1.5
    Author URI: [url]http://online-source.net[/url]
    */

    class Last_Modified extends WP_Widget 
    {

        function 
    Last_Modified() 
        {
            
    $widget_options = array(
                                
    'classname'         => 'last_modified_widget'
                                
    'description'       => 'Last modified items'
                                
    );
                                
            
    $this->WP_Widget('last-modifed''Last modified items'$widget_options);
        }
        
        function 
    GetLastModified($instance)
        {
            global 
    $wpdb;
                
    # Create variables from the array indexes
                # title, amount, post_type, text_between, date_format
                
    extract($instance);
                
                
    # Determine query
                
    $post_type = ($post_type == 'all') ? "post_type LIKE '%'" "post_type = '{$post_type}'";
                
                
    $LastModified $wpdb->get_results("SELECT ID, post_title, DATE_FORMAT(post_modified, '$date_format') AS date
                                                     FROM 
    {$wpdb->posts}
                                                     WHERE post_status = 'publish'
                                                     AND 
    {$post_type}
                                                     AND post_date <> post_modified
                                                     ORDER BY post_modified
                                                     DESC LIMIT 0 , "
    .$amount
                                                        
    );

            
    $LM_list =  '<ul>';
            foreach (
    $LastModified as $list)
            {
                
    $LM_list .= '[*][url="'get_permalink($list->ID) .'"]post_title.'">'.$list->post_title.'[/url] '.$text_between .' '. $list->date.'';
            }
            
    $LM_list .=  '[/list]';
            
            return 
    $LM_list;
        }
        
        function GetThePostTypes(
    $preselect)
        {
            # Empty string
            
    $options = '';
            
            # Get post types
            
    $CustomPostTypes = get_post_types(
                                                array(
                                                        'exclude_from_search' => false
                                                     ), 
                                                'names'
                                             );
            
            # Prepend all to the array                                   
            array_unshift(
    $CustomPostTypes, 'all');
                
                # Loop through the post types array
                foreach (
    $CustomPostTypes as $type)
                {
                    
    $options .= ($type == $preselect) ? '<option value="'.$type.'" selected="selected">'.$type.'</option>' : '<option value="'.$type.'">'.$type.'</option>';
                }
                
            return 
    $options;
        }

        function widget(
    $args$instance
        {
            extract(
    $args);

            
    $widget  = $before_widget;
            
    $widget .= $before_title . strip_tags(apply_filters('widget_title', $instance['title'])) . $after_title;
            
    $widget .= $this->GetLastModified($instance);
            
    $widget .= $after_widget;
                echo 
    $widget;
        }

        function update(
    $new_instance$old_instance
        {
            
    $instance                     = $old_instance;
            
    $instance['title']            = strip_tags($new_instance['title']);
            
    $instance['amount']           = strip_tags($new_instance['amount']);
            
    $instance['post_type']        = strip_tags($new_instance['post_type']);
            
    $instance['text_between']     = strip_tags($new_instance['text_between']);
            
    $instance['date_format']      = strip_tags($new_instance['date_format']);
              return 
    $instance;
        }

        function form(
    $instance
        {
            
    $instance             = wp_parse_args((array)$instance, array('title' => 'Last modified items', 'amount' => 5, 'post_type' => 'post', 'text_between' => 'at', 'date_format' => '%m-%d-%Y'));
            
    $title                = strip_tags($instance['title']);
            
    $amount               = strip_tags($instance['amount']);
            
    $PostType             = strip_tags($instance['post_type']);
            
    $text_between         = strip_tags($instance['text_between']);
            
    $date_format          = strip_tags($instance['date_format']);
    ?>
                


                    <label for="
    <?php echo $this->get_field_id('title'); ?>">Title:</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 attribute_escape($title); ?>" />
                </p>
                
                


                    <label for="<?php echo $this->get_field_id('amount'); ?>">Amount:</label>
                    <input class="widefat" id="<?php echo $this->get_field_id('amount'); ?>" name="<?php echo $this->get_field_name('amount'); ?>" type="text" value="<?php echo attribute_escape($amount); ?>" />
                </p>
                
                


                    <label for="<?php echo $this->get_field_id('text_between'); ?>">Text between title and date:</label>
                    <input class="widefat" id="<?php echo $this->get_field_id('text_between'); ?>" name="<?php echo $this->get_field_name('text_between'); ?>" type="text" value="<?php echo attribute_escape($text_between); ?>" />
                </p>
                
                


                    <label for="<?php echo $this->get_field_id('date_format'); ?>">Date format:</label>
                    <input class="widefat" id="<?php echo $this->get_field_id('date_format'); ?>" name="<?php echo $this->get_field_name('date_format'); ?>" type="text" value="<?php echo attribute_escape($date_format); ?>" />
                </p>
                
                


                    <label for="<?php echo $this->get_field_id('post_type'); ?>">Post type:</label>
                    <select id="<?php echo $this->get_field_id('post_type'); ?>" name="<?php echo $this->get_field_name('post_type'); ?>">
                                                                                            <?php echo $this->GetThePostTypes($PostType); ?>
                    </select>
                </p>
    <?php
        
    }
    }

    add_action('widgets_init''RegisterLastModifiedWidget');

    function 
    RegisterLastModifiedWidget() {
        
    register_widget('Last_Modified');
    }
    ?>

  2. #2
    uhm, in mysql il nome del mese mi pare si ottenga con %M non con %B
    « Se nella prima mezz'ora non capisci chi è il pollo, allora il pollo sei tu. » [Thomas "Amarillo Slim" Preston, campione del mondo di poker]

  3. #3
    Al limite sarebbe con la b minuscola (%b), comunque non capiscop perchè in questi casi non venga fatta la cosa più veloce, semplice e logica, tipo consultare la ducumentazione MySQL al riguardo Date and Time Functions avresti risolto in un attimo il tuo problema.
    "Mai discutere con un idiota. Ti trascina al suo livello e ti batte con l'esperienza." (Oscar Wilde)

  4. #4
    si ma la b minuscola (%b) restituisce il nome abbreviato, lui vuole il nome completo
    http://dev.mysql.com/doc/refman/5.5/...on_date-format
    « Se nella prima mezz'ora non capisci chi è il pollo, allora il pollo sei tu. » [Thomas "Amarillo Slim" Preston, campione del mondo di poker]

  5. #5
    Originariamente inviato da king size slim
    si ma la b minuscola (%b) restituisce il nome abbreviato, lui vuole il nome completo
    http://dev.mysql.com/doc/refman/5.5/...on_date-format
    Infatti ho scritto "al limite"
    "Mai discutere con un idiota. Ti trascina al suo livello e ti batte con l'esperienza." (Oscar Wilde)

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.