Plugin Directory

Changeset 1403599


Ignore:
Timestamp:
04/25/2016 07:50:05 AM (10 years ago)
Author:
techxplorer
Message:

Update Techxplorer's Anime List to version 1.2.0

Location:
techxplorers-anime-list/trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • techxplorers-anime-list/trunk/admin/class-txp-anime-list-admin.php

    r1370047 r1403599  
    167167        // Display alternate titles.
    168168        $valid['alttitles'] = ( isset( $input['alttitles'] ) && ! empty( $input['alttitles'] ) ) ? 1 : 0;
     169
     170        // Sort title list alphabetically.
     171        $valid['sort'] = ( isset( $input['sort'] ) && ! empty( $input['sort'] ) ) ? 1 : 0;
    169172
    170173        // Hummingbird username.
     
    340343    public function get_hummingbird_data( $username ) {
    341344
     345        $records = array();
     346
    342347        // @codingStandardsIgnoreStart
    343348        // Ignore the warning about wp_remote_get and using vip_safe_wp_remote_get() instead.
     
    347352
    348353        if ( is_array( $response ) && ! is_wp_error( $response ) ) {
    349             return json_decode( wp_remote_retrieve_body( $response ) );
    350         }
    351 
    352         return array();
     354            $records = json_decode( wp_remote_retrieve_body( $response ) );
     355        }
     356
     357        // Put a custom element to sort by title if necessary.
     358        foreach ( $records as $record ) {
     359            $record->txp_title = $record->anime->title;
     360        }
     361
     362        return $records;
    353363    }
    354364
     
    389399        // Get the data from Hummingbird.
    390400        $records = $this->get_hummingbird_data( $options['username'] );
     401
     402        // Sort the list of titles if required
     403        if ( isset( $options['sort'] ) && ! empty( $options['sort'] ) ) {
     404            require_once __DIR__ . '/class-txp-util-array.php';
     405
     406            $records = Txp_Utils_Array::sort_array_by_element( $records, 'txp_title' );
     407        }
    391408
    392409        // Build the HTML.
  • techxplorers-anime-list/trunk/admin/partials/txp-anime-list-admin-display.php

    r1370047 r1403599  
    9595                                        </fieldset>
    9696                                    </li>
     97                                    <li>
     98                                        <!-- Sort titles alphabetically -->
     99                                        <fieldset>
     100                                            <legend class="screen-reader-text"><span><?php esc_html_e( 'Sort title list alphabetically.', $this->plugin_name ); ?></span></legend>
     101                                            <label for="<?php echo esc_html( $this->plugin_name ); ?>-sort">
     102                                                <input type="checkbox"
     103                                                     id="<?php echo esc_html( $this->plugin_name ); ?>-sort"
     104                                                     name="<?php echo esc_html( $this->plugin_name ); ?>[sort]"
     105                                                     value="1" <?php checked( $options['sort'], 1 ); ?>/>
     106                                                <span><?php esc_html_e( 'Sort anime list alphabetically, by canonical title.', $this->plugin_name ); ?></span>
     107                                            </label>
     108                                        </fieldset>
     109                                    </li>
    97110                                </ul>
    98111                            </div>
  • techxplorers-anime-list/trunk/public/js/txp-anime-list-public.js

    r1370047 r1403599  
    33
    44    $( '.widget_txp-anime-list' ).ready( function() {
    5         console.log( 'Yay!' );
    6         console.log(txp_anime_list);
    75
    86        $.ajax({
     
    3533                    $( '.txp-anime-list-load' ).hide();
    3634                }
    37                 console.log( response );
    3835            }
    3936        });
  • techxplorers-anime-list/trunk/txp-anime-list.php

    r1370047 r1403599  
    1111 * Plugin URI:        https://techxplorer.com/projects/txp-anime-list/
    1212 * Description:       Display a list of anime titles on your site via a shortcode or widget.
    13  * Version:           1.1.0
     13 * Version:           1.2.0
    1414 * Author:            techxplorer
    1515 * Author URI:        https://techxplorer.com
Note: See TracChangeset for help on using the changeset viewer.