Plugin Directory

Changeset 2691524


Ignore:
Timestamp:
03/09/2022 02:35:50 PM (4 years ago)
Author:
idroj
Message:

Actualització 1.0.4

Location:
borrufa-widget/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • borrufa-widget/trunk/borrufa_widget.php

    r2012885 r2691524  
    55Description: Mètode senzill per afegir a la barra lateral o al peu del tema, les notícies de les comarques del Pirineu de Lleida, publicades diàriament a La borrufa, compatible per a qualsevol tema WordPress.
    66Author: Jordi Soler
    7 Version: 1.0.3
     7Version: 1.0.4
    88Author URI: https://laborrufa.com
    99License:   GPL2
     
    2020        register_widget("borrufa_widget_class");
    2121    }
     22       
     23        wp_enqueue_style( 'wp-color-picker' );
     24        wp_enqueue_script( 'wp-color-picker' );
    2225}
  • borrufa-widget/trunk/borrufa_widget_class.php

    r2012885 r2691524  
    1818        (
    1919            "titol" => __( 'Notícies La borrufa' ),
     20            "lb_widget_au" => false,
     21            "lb_widget_ar" => false,
     22            "lb_widget_pj" => false,
     23            "lb_widget_ps" => false,
     24            "lb_widget_va" => false,
     25            "lb_widget_esp" => false,
     26            "lb_widget_nat" => false,
     27            "lb_widget_mis" => false,
     28            "lb_num" => 1,
     29            "lb_data" => false,
     30            "lb_widget_target" => 1,
     31            "lb_color" => "#000000",
    2032        );
    2133        $instance = wp_parse_args((array)$instance,$defaults);
     
    3244        $lb_data = isset( $instance['lb_data'] ) ? (bool) $instance['lb_data'] : false;
    3345        $lb_widget_target = isset( $instance['lb_widget_target'] ) ? $instance['lb_widget_target'] : 1;
     46        $lb_color = isset( $instance['lb_color'] ) ? $instance['lb_color'] : "#000000";
    3447        ?>
    35         <p>Títol : <input type="text" name="<?php echo $this->get_field_name("titol")?>" value="<?php echo $titol?>" class="widefat" /></p>
     48        <p>Títol : <input type="text" name="<?php echo $this->get_field_name("titol")?>" value="<?php echo $titol; ?>" class="widefat" /></p>
    3649
    3750        <p><?php _e( 'Selecciona les comarques o categories que siguin del teu interès, per enllaçar amb les darreres notícies publicades a La borrufa.' ); ?></p>
     
    6578       
    6679        <p><label for="<?php echo $this->get_field_id( 'lb_num' ); ?>"><?php _e( 'Nombre de notícies que cal mostrar :' ); ?></label>
    67         <input class="tiny-text" id="<?php echo $this->get_field_id( 'lb_num' ); ?>" name="<?php echo $this->get_field_name( 'lb_num' ); ?>" type="number" step="1" min="1" value="<?php echo $lb_num; ?>" size="3" /></p>
     80        <input class="tiny-text" id="<?php echo $this->get_field_id( 'lb_num' ); ?>" name="<?php echo $this->get_field_name( 'lb_num' ); ?>" type="number" step="1" min="1" max= "8" value="<?php echo $lb_num; ?>" size="3" /></p>
    6881       
    6982        <p><input class="checkbox" type="checkbox"<?php checked( $lb_data ); ?> id="<?php echo $this->get_field_id( 'lb_data' ); ?>" name="<?php echo $this->get_field_name( 'lb_data' ); ?>" />
     
    7689                foreach ( $target_options as $target_value => $target_code ) {
    7790                    echo '<option value="' . $target_code . '" id="' . $target_code . '"', $lb_widget_target == $target_code ? ' selected="selected"' : '', '>', $target_value, '</option>';
     91                   
    7892                } ?>    </select>
    7993        </p>
    8094       
     95        <p><label for="<?php echo $this->get_field_id( 'lb_color' ); ?>"><?php _e( 'Color títol de comarques :' ); ?></label>
     96                    <input type="text" class="colorPickerBorrufa" name="<?php echo $this->get_field_name( 'lb_color' ); ?>"  id="<?php echo $this->get_field_id( 'lb_color' ); ?>" value="<?php echo $lb_color; ?>" data-default-color="#000000"/>
     97        </p>
     98        <script type="text/javascript">
     99          jQuery(document).ready(function() {
     100            //jQuery('.colorPickerBorrufa').wpColorPicker();
     101            jQuery('.colorPickerBorrufa').wpColorPicker({
     102                change: function(e, ui) {
     103                    jQuery( e.target ).val( ui.color.toString() );
     104                    jQuery( e.target ).trigger('change'); // enable widget "Save" button
     105                }
     106            });
     107           });
     108        </script>
    81109        <hr style="background: #ccc; border: 0; height: 1px; margin: 20px 0;" />
    82110       
     
    101129        $instance['lb_data'] = isset( $new_instance['lb_data'] ) ? (bool) $new_instance['lb_data'] : false;
    102130        $instance[ 'lb_widget_target' ] = $new_instance[ 'lb_widget_target' ];
     131        $instance['lb_color'] = isset( $new_instance['lb_color'] ) ? $new_instance['lb_color'] : "#000000";
    103132        return $instance;
    104133    }
     
    121150        $lb_data = isset( $instance['lb_data'] ) ? $instance['lb_data'] : false;
    122151        $lb_widget_target  = empty( $instance['lb_widget_target'] ) ? '&nbsp;' : $instance['lb_widget_target'];
     152        $lb_color = $instance['lb_color'];
    123153        echo $before_widget;
    124154        echo $before_title.$titol.$after_title;
     
    133163    <?php if (!empty($items)) { ?>
    134164        <br />
    135         <span><b>Alt Urgell</b></span>
    136     <?php
    137     foreach ( $items as $item ) : ?> 
    138     <div>
    139     <br />
    140        <a href='<?php echo $item['link']; ?>' title='<?php echo $item['title']; ?>'<?php if ( $lb_widget_target == 1 ) { ?> target="_blank" <?php } ?>><?php echo $item['title']; ?></a>&nbsp;<?php if ($lb_data){ echo date( 'd/m/Y', strtotime($item['pubdate'])); } ?>&nbsp;<span><?php _e( '[La borrufa | Pirineu comarques]' ); ?></span>
     165        <span style="color:<?php echo $lb_color; ?>"><b>Alt Urgell</b></span>
     166    <?php
     167    foreach ( $items as $item ) : ?> 
     168    <div>
     169    <br />
     170       <a href='<?php echo $item['link']; ?>' title='<?php echo $item['title']; ?>'<?php if ( $lb_widget_target == 1 ) { ?> target="_blank" <?php } ?>><?php echo $item['title']; ?></a>&nbsp;<span style="color:<?php echo $lb_color; ?>"><?php if ($lb_data){ echo date( 'd/m/Y', strtotime($item['pubdate'])); } ?>&nbsp;<?php _e( '[La borrufa | Pirineu comarques]' ); ?></span>
    141171    </div>
    142172    <?php endforeach; } } ?>
     
    150180    <?php if (!empty($items)) { ?>
    151181        <br />
    152         <span><b>Alta Ribagorça</b></span>
    153     <?php
    154     foreach ( $items as $item ) : ?> 
    155     <div>
    156     <br />
    157        <a href='<?php echo $item['link']; ?>' title='<?php echo $item['title']; ?>'<?php if ( $lb_widget_target == 1 ) { ?> target="_blank" <?php } ?>><?php echo $item['title']; ?></a>&nbsp;<?php if ($lb_data){ echo date( 'd/m/Y', strtotime($item['pubdate'])); } ?>&nbsp;<span><?php _e( '[La borrufa | Pirineu comarques]' ); ?></span>
     182        <span style="color:<?php echo $lb_color; ?>"><b>Alta Ribagorça</b></span>
     183    <?php
     184    foreach ( $items as $item ) : ?> 
     185    <div>
     186    <br />
     187       <a href='<?php echo $item['link']; ?>' title='<?php echo $item['title']; ?>'<?php if ( $lb_widget_target == 1 ) { ?> target="_blank" <?php } ?>><?php echo $item['title']; ?></a>&nbsp;<span style="color:<?php echo $lb_color; ?>"><?php if ($lb_data){ echo date( 'd/m/Y', strtotime($item['pubdate'])); } ?>&nbsp;<?php _e( '[La borrufa | Pirineu comarques]' ); ?></span>
    158188    </div>
    159189    <?php endforeach; } } ?>
     
    167197    <?php if (!empty($items)) { ?>
    168198        <br />
    169         <span><b>Pallars Jussà</b></span>
    170     <?php
    171     foreach ( $items as $item ) : ?> 
    172     <div>
    173     <br />
    174        <a href='<?php echo $item['link']; ?>' title='<?php echo $item['title']; ?>'<?php if ( $lb_widget_target == 1 ) { ?> target="_blank" <?php } ?>><?php echo $item['title']; ?></a>&nbsp;<?php if ($lb_data){ echo date( 'd/m/Y', strtotime($item['pubdate'])); } ?>&nbsp;<span><?php _e( '[La borrufa | Pirineu comarques]' ); ?></span>
     199        <span style="color:<?php echo $lb_color; ?>"><b>Pallars Jussà</b></span>
     200    <?php
     201    foreach ( $items as $item ) : ?> 
     202    <div>
     203    <br />
     204       <a href='<?php echo $item['link']; ?>' title='<?php echo $item['title']; ?>'<?php if ( $lb_widget_target == 1 ) { ?> target="_blank" <?php } ?>><?php echo $item['title']; ?></a>&nbsp;<span style="color:<?php echo $lb_color; ?>"><?php if ($lb_data){ echo date( 'd/m/Y', strtotime($item['pubdate'])); } ?>&nbsp;<?php _e( '[La borrufa | Pirineu comarques]' ); ?></span>
    175205    </div>
    176206    <?php endforeach; } } ?>
     
    184214    <?php if (!empty($items)) { ?>
    185215        <br />
    186         <span><b>Pallars Sobirà</b></span>
    187     <?php
    188     foreach ( $items as $item ) : ?> 
    189     <div>
    190     <br />
    191        <a href='<?php echo $item['link']; ?>' title='<?php echo $item['title']; ?>'<?php if ( $lb_widget_target == 1 ) { ?> target="_blank" <?php } ?>><?php echo $item['title']; ?></a>&nbsp;<?php if ($lb_data){ echo date( 'd/m/Y', strtotime($item['pubdate'])); } ?>&nbsp;<span><?php _e( '[La borrufa | Pirineu comarques]' ); ?></span>
     216        <span style="color:<?php echo $lb_color; ?>"><b>Pallars Sobirà</b></span>
     217    <?php
     218    foreach ( $items as $item ) : ?> 
     219    <div>
     220    <br />
     221       <a href='<?php echo $item['link']; ?>' title='<?php echo $item['title']; ?>'<?php if ( $lb_widget_target == 1 ) { ?> target="_blank" <?php } ?>><?php echo $item['title']; ?></a>&nbsp;<span style="color:<?php echo $lb_color; ?>"><?php if ($lb_data){ echo date( 'd/m/Y', strtotime($item['pubdate'])); } ?>&nbsp;<?php _e( '[La borrufa | Pirineu comarques]' ); ?></span>
    192222    </div>
    193223    <?php endforeach; } } ?>
     
    197227    $rss = fetch_rss('https://laborrufa.com/noticies/val-daran/feed/');
    198228    $items = $lb_num;
    199     $items = array_slice($rss->items, 0, $lb_num);
     229    if (is_array($rss->items)) {
     230    $items = array_slice($rss->items, 0, $lb_num);
     231    } else { var_dump($rss->items); }
    200232    ?>
    201233    <?php if (!empty($items)) { ?>
    202234        <br />
    203         <span><b>Val d'Aran</b></span>
    204     <?php
    205     foreach ( $items as $item ) : ?>
    206     <div>
    207     <br />
    208        <a href='<?php echo $item['link']; ?>' title='<?php echo $item['title']; ?>'<?php if ( $lb_widget_target == 1 ) { ?> target="_blank" <?php } ?>><?php echo $item['title']; ?></a>&nbsp;<?php if ($lb_data){ echo date( 'd/m/Y', strtotime($item['pubdate'])); } ?>&nbsp;<span><?php _e( '[La borrufa | Pirineu comarques]' ); ?></span>
     235        <span style="color:<?php echo $lb_color; ?>"><b>Val d'Aran</b></span>
     236    <?php
     237    foreach ( $items as $item ) : ?>
     238    <div>
     239    <br />
     240       <a href='<?php echo $item['link']; ?>' title='<?php echo $item['title']; ?>'<?php if ( $lb_widget_target == 1 ) { ?> target="_blank" <?php } ?>><?php echo $item['title']; ?></a>&nbsp;<span style="color:<?php echo $lb_color; ?>"><?php if ($lb_data){ echo date( 'd/m/Y', strtotime($item['pubdate'])); } ?>&nbsp;<?php _e( '[La borrufa | Pirineu comarques]' ); ?></span>
    209241    </div>
    210242    <?php endforeach; } } ?>
     
    218250    <?php if (!empty($items)) { ?>
    219251        <br />
    220         <span><b>Esports</b></span>
    221     <?php
    222     foreach ( $items as $item ) : ?>
    223     <div>
    224     <br />
    225        <a href='<?php echo $item['link']; ?>' title='<?php echo $item['title']; ?>'<?php if ( $lb_widget_target == 1 ) { ?> target="_blank" <?php } ?>><?php echo $item['title']; ?></a>&nbsp;<?php if ($lb_data){ echo date( 'd/m/Y', strtotime($item['pubdate'])); } ?>&nbsp;<span><?php _e( '[La borrufa | Pirineu comarques]' ); ?></span>
     252        <span style="color:<?php echo $lb_color; ?>"><b>Esports</b></span>
     253    <?php
     254    foreach ( $items as $item ) : ?>
     255    <div>
     256    <br />
     257       <a href='<?php echo $item['link']; ?>' title='<?php echo $item['title']; ?>'<?php if ( $lb_widget_target == 1 ) { ?> target="_blank" <?php } ?>><?php echo $item['title']; ?></a>&nbsp;<span style="color:<?php echo $lb_color; ?>"><?php if ($lb_data){ echo date( 'd/m/Y', strtotime($item['pubdate'])); } ?>&nbsp;<?php _e( '[La borrufa | Pirineu comarques]' ); ?></span>
    226258    </div>
    227259    <?php endforeach; } } ?>
     
    235267    <?php if (!empty($items)) { ?>
    236268        <br />
    237         <span><b>Natura</b></span>
    238     <?php
    239     foreach ( $items as $item ) : ?>
    240     <div>
    241     <br />
    242        <a href='<?php echo $item['link']; ?>' title='<?php echo $item['title']; ?>'<?php if ( $lb_widget_target == 1 ) { ?> target="_blank" <?php } ?>><?php echo $item['title']; ?></a>&nbsp;<?php if ($lb_data){ echo date( 'd/m/Y', strtotime($item['pubdate'])); } ?>&nbsp;<span><?php _e( '[La borrufa | Pirineu comarques]' ); ?></span>
     269        <span style="color:<?php echo $lb_color; ?>"><b>Natura</b></span>
     270    <?php
     271    foreach ( $items as $item ) : ?>
     272    <div>
     273    <br />
     274       <a href='<?php echo $item['link']; ?>' title='<?php echo $item['title']; ?>'<?php if ( $lb_widget_target == 1 ) { ?> target="_blank" <?php } ?>><?php echo $item['title']; ?></a>&nbsp;<span style="color:<?php echo $lb_color; ?>"><?php if ($lb_data){ echo date( 'd/m/Y', strtotime($item['pubdate'])); } ?>&nbsp;<?php _e( '[La borrufa | Pirineu comarques]' ); ?></span>
    243275    </div>
    244276    <?php endforeach; } } ?>
     
    252284    <?php if (!empty($items)) { ?>
    253285        <br />
    254         <span><b>Miscel·lani</b></span>
    255     <?php
    256     foreach ( $items as $item ) : ?>
    257     <div>
    258     <br />
    259        <a href='<?php echo $item['link']; ?>' title='<?php echo $item['title']; ?>'<?php if ( $lb_widget_target == 1 ) { ?> target="_blank" <?php } ?>><?php echo $item['title']; ?></a>&nbsp;<?php if ($lb_data){ echo date( 'd/m/Y', strtotime($item['pubdate'])); } ?>&nbsp;<span><?php _e( '[La borrufa | Pirineu comarques]' ); ?></span>
    260     </div>
     286        <span style="color:<?php echo $lb_color; ?>"><b>Miscel·lani</b></span>
     287    <?php
     288    foreach ( $items as $item ) : ?>
     289    <div>
     290    <br />
     291       <a href='<?php echo $item['link']; ?>' title='<?php echo $item['title']; ?>'<?php if ( $lb_widget_target == 1 ) { ?> target="_blank" <?php } ?>><?php echo $item['title']; ?></a>&nbsp;<span style="color:<?php echo $lb_color; ?>"><?php if ($lb_data){ echo date( 'd/m/Y', strtotime($item['pubdate'])); } ?>&nbsp;<?php _e( '[La borrufa | Pirineu comarques]' ); ?></span>
     292    </div>
     293
    261294    <?php endforeach; } } ?>
    262295    <?php }
    263296    }
     297
    264298    echo $after_widget;
    265299?>
  • borrufa-widget/trunk/readme.txt

    r2654772 r2691524  
    44Language: Català
    55Requires at least: 4.3
    6 Tested up to: 5.4
    7 Stable tag: 1.0.3
     6Tested up to: 5.9.1
     7Stable tag: 1.0.4
    88
    99
     
    3232
    3333== Changelog ==
     34= 1.0.2 =
     35* Primera versió del plugin borrufa-widget.
    3436= 1.0.3 =
    3537* Ampliació d'una nova categoria en les seccions de notícies .
    36 = 1.0.2 =
    37 * Primera versió del plugin borrufa-widget.
     38= 1.0.4 =
     39* Ampliació d'una paleta de color per a títols de notícies .
    3840
    3941
     
    4143
    4244--Jordi Soler
    43 http://laborrufa.com/
     45https://laborrufa.com/
    4446== Copyright © Serveis Publicitaris del Pirineu S.L. ==
Note: See TracChangeset for help on using the changeset viewer.