Plugin Directory

Changeset 1434444


Ignore:
Timestamp:
06/10/2016 12:03:15 PM (10 years ago)
Author:
xnicoco
Message:

torrent-listing, missing admin style file, and other bug fixes

Location:
katracker/trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • katracker/trunk/README.txt

    r1433922 r1434444  
    7171
    7272== Changelog ==
     73= 1.0.8 =
     74* Bug fixes (note to self: do not commit after 2AM)
     75
    7376= 1.0.7 =
    7477* Simplified magnet links support
  • katracker/trunk/functions.php

    r1433917 r1434444  
    6666                                    ) ) : null,
    6767        'meta_query'      => array(
    68                                 !$args['untracked'] ?
     68                                $args['untracked'] ?
    6969                                    array(
    7070                                        'key'    => KATRACKER_META_PREFIX . 'track',
  • katracker/trunk/katracker.php

    r1433917 r1434444  
    55 * Description: The only full and all powerful, complete bittorrent tracker integration for wordpress.
    66 * Author: nicoco
    7  * Version: 1.0.7
     7 * Version: 1.0.8
    88 * Author URI: kateam.org
    99 * License: GPL2
  • katracker/trunk/shortcode/katracker-shortcode.php

    r1416926 r1434444  
    33
    44// for [torrent] shortcode
    5 if ($single_torrent):
     5function katracker_shortcode_single( $atts ) {
     6    $atts = shortcode_atts( array(
     7        'id'     => isset( $atts['hash'] ) ? get_torrent_id_from_hash( $atts['hash'] ) : null,
     8        'title'  => get_the_title( $atts['id'] ),
     9        'stats'  => 1,
     10        'files'  => 0
     11    ), $atts );
    612
    7 $atts = shortcode_atts( array(
    8     'id'     => isset( $atts['hash'] ) ? get_torrent_id_from_hash( $atts['hash'] ) : null,
    9     'title'  => get_the_title( $atts['id'] ),
    10     'stats'  => 1,
    11     'files'  => 0
    12 ), $atts );
    13 
    14 if ( isset( $atts['id'] ) ) {
    15     katracker_shortcode_print_torrent( $atts );
     13    if ( isset( $atts['id'] ) ) {
     14        katracker_shortcode_print_torrent( $atts );
     15    }
     16    return;
    1617}
    17 return;
    1818
    1919// for [torrents] shortcode
    20 else:
    21 $atts = shortcode_atts( array(
    22     'numtorrents'      => -1,
    23     'project_order'  => 'name',
    24     'torrent_order'  => 'title',
    25     'category'       => null,
    26     'stats'          => 1,
    27     'files'          => 1
    28 ), $atts );
     20function katracker_shortcode_many( $atts ) {
     21    $atts = shortcode_atts( array(
     22        'numtorrents'      => -1,
     23        'project_order'  => 'name',
     24        'torrent_order'  => 'title',
     25        'category'       => null,
     26        'stats'          => 1,
     27        'files'          => 0
     28    ), $atts );
    2929
    30 if ( isset( $atts['category'] )) {
    31     return katracker_shortcode_print_torrents( get_torrents( array(
    32             'orderby'      => $atts['torrent_order'],
    33             'numtorrents'  => $atts['numtorrents'],
    34             'category'     => $atts['category'],
    35         ) ) , $atts);
    36 }
     30    if ( isset( $atts['category'] )) {
     31        return katracker_shortcode_print_torrents( get_torrents( array(
     32                'orderby'      => $atts['torrent_order'],
     33                'numtorrents'  => $atts['numtorrents'],
     34                'category'     => $atts['category'],
     35            ) ) , $atts);
     36    }
    3737
    38 if ( isset( $atts['id'] ))
    39     return katracker_shortcode_print_torrents( get_torrents( array(
    40             'orderby'      => $atts['torrent_order'],
    41             'numtorrents'  => $atts['numtorrents'],
    42             'post__in'     => $atts['id']
    43         ) ) , $atts);
     38    if ( isset( $atts['id'] ))
     39        return katracker_shortcode_print_torrents( get_torrents( array(
     40                'orderby'      => $atts['torrent_order'],
     41                'numtorrents'  => $atts['numtorrents'],
     42                'post__in'     => $atts['id']
     43            ) ) , $atts);
    4444
    45 if ( $categories = get_katracker_categories() ): ?>
     45    $categories = get_katracker_categories();
     46    if ( !empty( $categories ) ):
     47    ?>
    4648
    47 <div class="<?php echo KATRACKER_PRE . '-torrent-list'; ?>">
    48     <?php
    49     $excluded = array();
    50     foreach ( $categories as $category ) {
    51         $metadata = get_option( 'taxonomy_' . $category->term_id );
    52         $second_name = !empty( $metadata['second_name'] ) ? ' / ' . $metadata['second_name'] : '';
    53         $torrents = get_torrents( array( 'orderby' => $atts['torrent_order'], 'category' => $category->term_id, 'bonus' => false ) );
    54         $bonuses = get_torrents( array( 'orderby' => $atts['torrent_order'], 'category' => $category->term_id, 'bonus' => true ) );
    55         if ( !empty( $torrents ) || !empty( $bonuses ) ): ?>
     49    <div class="<?php echo KATRACKER_PRE . '-torrent-list'; ?>">
     50        <?php
     51        $excluded = array();
     52        foreach ( $categories as $category ) {
     53            $metadata = get_option( 'taxonomy_' . $category->term_id );
     54            $second_name = !empty( $metadata['second_name'] ) ? ' / ' . $metadata['second_name'] : '';
     55            $torrents = get_torrents( array( 'orderby' => $atts['torrent_order'], 'category' => $category->term_id, 'bonus' => false ) );
     56            $bonuses = get_torrents( array( 'orderby' => $atts['torrent_order'], 'category' => $category->term_id, 'bonus' => true ) );
     57            if ( !empty( $torrents ) || !empty( $bonuses ) ): ?>
     58                <div>
     59                    <h2><a href="<?php echo get_category_link( $category->term_id ); ?>"><?php echo $category->name . $second_name; ?></a></h2>
     60                    <?php
     61                    katracker_shortcode_print_torrents( $torrents, $atts );
     62                    if ( !empty( $bonuses ) ) {
     63                        katracker_shortcode_print_torrents( $bonuses, array_merge( $atts, array( 'bonus' => true ) ) );
     64                        $torrents = array_merge( $torrents, $bonuses );
     65                    }
     66                    ?>
     67                </div>
     68            <?php
     69                foreach( $torrents as $torrent ) {
     70                    $excluded[] = $torrent->ID;
     71                }
     72            endif;
     73        }
     74
     75        $torrents = get_torrents( array( 'orderby' => $atts['torrent_order'], 'exclude' => $excluded ) );
     76        if ( !empty( $torrents ) ) { ?>
    5677            <div>
    57                 <h2><a href="<?php echo get_category_link( $category->term_id ); ?>"><?php echo $category->name . $second_name; ?></a></h2>
    58                 <?php
    59                 katracker_shortcode_print_torrents( $torrents, $atts );
    60                 if ( !empty( $bonuses ) ) {
    61                     katracker_shortcode_print_torrents( $bonuses, array_merge( $atts, array( 'bonus' => true ) ) );
    62                     $torrents = array_merge( $torrents, $bonuses );
    63                 }
    64                 ?>
     78                <h2><?php _e( 'Other', 'katracker' ); ?></h2>
     79                <?php katracker_shortcode_print_torrents( $torrents, $atts ); ?>
    6580            </div>
    6681        <?php
    67             foreach( $torrents as $torrent ) {
    68                 $excluded[] = $torrent->ID;
    69             }
    70         endif;
    71     }
     82        }
     83    ?>
     84    </div>
    7285
    73     $torrents = get_torrents( array( 'orderby' => $atts['torrent_order'], 'exclude' => $excluded ) );
    74     if ( !empty( $torrents ) ) { ?>
    75         <div>
    76             <h2><?php _e( 'Other', 'katracker' ); ?></h2>
    77             <?php katracker_shortcode_print_torrents( $torrents ); ?>
    78         </div>
    79     <?php
    80     }
    81 ?>
    82 </div>
    83 
    84 <?php endif;
    85 
    86 endif; // single_torrent
     86    <?php endif;
     87}
    8788
    8889/**
  • katracker/trunk/shortcode/shortcode.php

    r1416912 r1434444  
    1010    }
    1111    // Load Style
    12     wp_enqueue_style( 'katracker-shortcode-style' );
     12    wp_enqueue_style( KATRACKER_PRE . '-shortcode-style' );
    1313   
    1414    ob_start();
    1515    require_once $template_part;
     16    katracker_shortcode_single( $atts );
    1617    $content = ob_get_contents();
    1718    ob_end_clean();
     
    2728        $template_part = plugin_dir_path( __FILE__ ) . KATRACKER_PRE . '-shortcode.php';
    2829    }
    29 
    3030    // Load Style
    31     wp_enqueue_style( 'katracker-shortcode-style' );
     31    wp_enqueue_style( KATRACKER_PRE . '-shortcode-style' );
    3232
    3333    ob_start();
    3434    require_once $template_part;
     35    katracker_shortcode_many( $atts );
    3536    $content = ob_get_contents();
    3637    ob_end_clean();
     
    4849        $template_part = get_template_directory_uri() . '/' . KATRACKER_PRE . '-shortcode.css';
    4950    }
    50     wp_register_style( 'katracker-shortcode-style', $template_part );
     51    wp_register_style( KATRACKER_PRE . '-shortcode-style', $template_part );
    5152} );
    5253
Note: See TracChangeset for help on using the changeset viewer.