Plugin Directory

Changeset 1031720


Ignore:
Timestamp:
11/24/2014 12:27:35 PM (11 years ago)
Author:
ohayo-web
Message:

Adding version 1.3 of afables widget

Location:
afables/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • afables/trunk/afables.php

    r940105 r1031720  
    22/*
    33 Plugin Name: Afables
    4  Plugin URI: http://wordpress.org/plugins/afables/
    54 Description: Widget para wordpress de Afables
    65 Author: OhayoWeb
    76 Author URI: http://www.ohayoweb.com/
    8  Version: 0.1
     7 Version: 1.3
    98*/
    109
    1110
    12 define('AFABLES_PLUGIN_VERSION','0.1');
     11define('AFABLES_PLUGIN_VERSION','1.3');
    1312define('AFABLES_USERAGENT','Afables Wordpress Plugin '.AFABLES_PLUGIN_VERSION);
    1413
     
    2625define('AFABLES_RSS_CHANNEL',   'http://www.afables.com/rss/rsschannel');
    2726
    28 define('AFABLES_CACHE_FOLDER',plugin_dir_path( __FILE__ ).'/cache');
    29 define('AFABLES_CACHE_DURATION','21600'); # 6 horas // 21600
     27define('AFABLES_CACHE_FOLDER',plugin_dir_path( __FILE__ ).'cache');
     28define('AFABLES_CACHE_DURATION',21600); # 6 horas // 21600
    3029
    3130/** Load languages **/
  • afables/trunk/inc/afables-install.php

    r936600 r1031720  
    55function afables_activate(){
    66   
     7    $notices= get_option('afables_admin_notices', array());
     8   
    79    // AFABLES_CACHE_FOLDER
    8    
    910    if(!file_exists(AFABLES_CACHE_FOLDER)){
    1011        // creamos el directorio
    11         if(mkdir(AFABLES_CACHE_FOLDER,0777))
    12             echo 'Directorio creado';
    13         else echo 'Error';
     12        if(mkdir(AFABLES_CACHE_FOLDER,0777)){
     13            $notices[]= "<div class='updated'><p>Directorio cache creado con éxito.</p></div>";
     14           
     15        }else{
     16            $notices[]= "<div class='error'><p>No se pudo crear el directorio <strong>".AFABLES_CACHE_FOLDER."</strong>.</p><p>Necesitara crearlo manualmente para el correcto funcionamiento del plugin.</p></div>";
     17        }
    1418       
    1519    }
    1620   
     21    update_option('afables_admin_notices', $notices);
    1722}
    1823
     24
     25add_action ('admin_notices' , 'afables_notices');
     26
     27function afables_notices(){
     28   
     29    if ($notices = get_option('afables_admin_notices')) {
     30        foreach ($notices as $notice) {
     31            //echo "<div class='updated'><p>$notice</p></div>";
     32            echo $notice;
     33        }
     34        delete_option('afables_admin_notices');
     35    }
     36   
     37}
    1938?>
  • afables/trunk/inc/afables-widget.php

    r936600 r1031720  
    66class Afables_Widget extends WP_Widget {
    77
     8    static $instances=array();
     9   
    810    public function __construct() {
    911       
     
    2022    }
    2123
     24    public function add_options_to_script(){
     25        //If there is data to add, add it
     26        //wp_localize_script( 'my_script', 'my_var', self::$variables);
     27        wp_localize_script('afables-widget', 'afablesObject', self::$instances );
     28       
     29    }
     30   
    2231    public function widget( $args, $instance ) {
    2332
     
    2837        endif;
    2938       
    30         wp_enqueue_script('jquery');
    31        
    32         //wp_enqueue_script( 'afables-widget', plugins_url( '../js/afables-widget.js' , __FILE__ ), array('jquery'), AFABLES_PLUGIN_VERSION ,true );
     39        //wp_enqueue_script('jquery');
     40       
     41        wp_register_script( 'afables-widget', plugins_url( '../js/afables-widget.js' , __FILE__ ), array('jquery'), AFABLES_PLUGIN_VERSION ,true );
     42        //$translation_array = array();
     43        //$idInstance = array ('widgetId' => $this->id);
     44        //$translation_array[] = $idInstance;
     45        //wp_localize_script('afables-widget', 'afablesObject', $translation_array );
     46       
     47        add_action('wp_footer', array(__CLASS__, 'add_options_to_script'));
     48       
     49        wp_enqueue_script('afables-widget');
     50       
     51        $id = $this->id;
     52        self::$instances[$id] = '#'. $this->id;
     53       
    3354       
    3455        $before_texto = '<div class="afables-wrapper-widget">';
     
    107128       
    108129       
    109         <?php include(plugin_dir_path( __FILE__ ).'../js/afables-widget-js.php'); ?>
     130        <?php //include(plugin_dir_path( __FILE__ ).'../js/afables-widget-js.php'); ?>
    110131       
    111132       
     
    202223            <select class="widefat" id="<?php echo $this->get_field_id( 'channel' ); ?>" name="<?php echo $this->get_field_name( 'channel' ); ?>">
    203224                <?php $channels = $this->load_feed(AFABLES_RSS_CHANNEL);?>
    204                 <option value="none" <?php echo ($channel == 'none') ? $selected : null ?>><?php _e('All', 'afables');?></option>
     225                <option value="none" <?php echo (!$channels) ? $selected : null ?>><?php _e('All', 'afables');?></option>
    205226               
    206227                <?php foreach ($channels as $key => $item): ?>
     
    264285    public function load_feed($url){
    265286
    266         //include_once plugin_dir_path( __FILE__ ).'load_SimplePie.php';
    267         require ABSPATH . WPINC . '/class-simplepie.php';
     287        //include_once plugin_dir_path( __FILE__ ).'../rss-robot/inc/load_SimplePie.php';
     288        include_once plugin_dir_path( __FILE__ ).'load_SimplePie.php';
    268289       
    269290        $channel_feed = new SimplePie();
  • afables/trunk/js/afables-widget.js

    r936600 r1031720  
    22   
    33    var active = 0; // starts at zero
    4     var list = $('ul.afables-result');
    54   
     5    var list = [];
    66    var filter = '';
    77   
    8     list.children('.afables-result li').eq('0').siblings().hide(); // Hide all except first list element
     8    $.each(afablesObject, function( index, value ) {
     9        list[index] =  $(value+' ul.afables-result');
     10        list[index].children(value +' .afables-result li'+filter).eq('0').siblings().hide(); // Hide all except first list element
     11    });
     12   
     13    $.each(list, function( index, value ) {
     14        console.log(index);
     15    });
     16   
    917
    10     $('.afables-wrapper-widget input[name=type]').bind('click', function(){
    11         filter = $('.afables-wrapper-widget input[name=type]:checked').val();
    12         //list = $('ul.afables-result li.'+filter);
    13         //list.children('.afables-result li.'+filter).eq('0').siblings().hide();
     18    $.each(afablesObject, function( index, value ) {
     19       
     20        $(value+' .afables-wrapper-widget input[name=type]').bind('click', function(){
     21            filter[index] = $(value+' .afables-wrapper-widget input[name=type]:checked').val();
     22            list[index].children(value+' .afables-result li'+filter[index]).eq('0').siblings().hide();
     23            active = 0;
     24        });
     25       
     26        $(value+' .afables-next').bind('click', function(event) {
     27            event.preventDefault();
     28            active = active == list[index].children(value+' .afables-result li'+filter[index]).length-1 ? 0 : active + 1;
     29        });
     30
     31        $(value+' .afables-previous').bind('click', function(event) {
     32            event.preventDefault();
     33            active = active == 0 ? list[index].children(value+' .afables-result li'+filter[index]).length-1 : active - 1;
     34        });
     35       
     36
     37       
     38        $(value+' .afables-previous,'+ value +' .afables-next,'+ value +' .afables-wrapper-widget input[name=type]').bind('click', function() {
     39            getActive(index,value).show().siblings().hide();
     40        });
     41       
     42        $(value +" .afables-wrapper-widget a[rel='afable']").click(function () {
     43            var caracteristicas = "titlebar=no,toolbar=no,location=no,status=no,menubar=no,height=500,width=1000,scrollTo,resizable=1,scrollbars=1,location=0";
     44                nueva=window.open(this.href, 'Afable Single', caracteristicas);
     45            return false;
     46        });
     47
     48        $(value +" .afables-wrapper-widget button.view-details").click(function () {
     49            url = $(this).attr('rel');
     50            var caracteristicas = "titlebar=no,toolbar=no,location=no,status=no,menubar=no,height=500,width=1000,scrollTo,resizable=1,scrollbars=1,location=0";
     51                nueva=window.open(url, 'Afable Single', caracteristicas);
     52            return false;
     53        });
    1454       
    1555    });
    1656   
    17     $('.afables-next').bind('click', function(event) {
    18         event.preventDefault();
    19         active = active == list.children('.afables-result li').length-1 ? 0 : active + 1;
    20     });
    21 
    22     $('.afables-previous').bind('click', function(event) {
    23         event.preventDefault();
    24         active = active == 0 ? list.children('.afables-result li').length-1 : active - 1;
    25     });
    26 
    27     var getActivebyFilter = function() {
    28         filter = $('.afables-wrapper-widget input[name=type]:checked').val();
    29         return list.children('.afables-result li.'+filter).eq(active);
     57   
     58    var getActive = function(index,value) {
     59        return list[index].children(value+' .afables-result li'+filter).eq(active);
    3060    };
    3161   
    32     var getActive = function() {
    33         return list.children('.afables-result li').eq(active);
    34     };
     62   
    3563
    36     $('.afables-previous,.afables-next,.afables-wrapper-widget input[name=type]').bind('click', function() {
    37         if (filter == '')   getActive().show().siblings().hide();
    38         else getActivebyFilter().show().siblings().hide();
    39         //getActive().fadeIn().siblings().fadeOut();
    40     });
    41    
    42     $(".afables-wrapper-widget a[rel='afable']").click(function () {
    43         var caracteristicas = "height=500,width=800,scrollTo,resizable=1,scrollbars=1,location=0";
    44             nueva=window.open(this.href, 'Afable Single', caracteristicas);
    45         return false;
    46     });
    4764
    48     $(".afables-wrapper-widget button.view-details").click(function () {
    49         url = $(this).attr('rel');
    50         var caracteristicas = "height=500,width=800,scrollTo,resizable=1,scrollbars=1,location=0";
    51             nueva=window.open(url, 'Afable Single', caracteristicas);
    52         return false;
    53     });
    5465   
    5566});
  • afables/trunk/readme.txt

    r940107 r1031720  
    33Tags: afables, feed, widget, sidebar, city, channel
    44Requires at least: 3.7.1
    5 Tested up to: 3.7.1
     5Tested up to: 3.9.1
    66License: GPLv2 or later
     7Stable tag: 1.3
    78
    89== Description ==
     
    4445== Changelog ==
    4546
     47= 1.3 =
     48* Fixed an error loading multiple instances of the widget on the same page.
     49* Removed an additional slash in the rss address.
     50* Fixed an error when jQuery is loaded in the footer.
     51
    4652= 0.1 =
    4753* Released
Note: See TracChangeset for help on using the changeset viewer.