Plugin Directory

Changeset 2473441


Ignore:
Timestamp:
02/12/2021 02:08:49 AM (5 years ago)
Author:
Ryan Bayne
Message:

Single important bug fix

Location:
twitchpress
Files:
399 added
8 edited

Legend:

Unmodified
Added
Removed
  • twitchpress/trunk/functions.php

    r2472434 r2473441  
    214214        'bits:read'                  => array(),// View Bits information for your channel.
    215215        'clips:edit'                 => array(),// Manage a clip object.
     216        'moderation:read'            => array(),// View a channel’s moderation data including Moderators, Bans, Timeouts, and Automod settings
    216217        'user:edit'                  => array(),// Manage a user object.
    217218        'user:edit:broadcast'        => array(),// Edit your channels broadcast configuration, including extension configuration. (This scope implies user:read:broadcast capability.)
     
    248249    $scope['bits:read']['label']                  = __( 'New Helix Scope', 'twitchpress' );
    249250    $scope['clips:edit']['label']                 = __( 'New Helix Scope', 'twitchpress' );
     251    $scope['moderation:read']['label']            = __( 'Access Moderating Data', 'twitchpress' );
    250252    $scope['user:edit']['label']                  = __( 'New Helix Scope', 'twitchpress' );     
    251253    $scope['user:edit:broadcast']['label']        = __( 'New Helix Scope', 'twitchpress' );
     
    276278    $scope['bits:read']['apidesc']                  = __( 'New Helix Scope', 'twitchpress' );
    277279    $scope['clips:edit']['apidesc']                 = __( 'New Helix Scope', 'twitchpress' );
     280    $scope['moderation:read']['apidesc']            = __( 'View a channel’s moderation data including Moderators, Bans, Timeouts, and Automod settings.', 'twitchpress' );   
    278281    $scope['user:edit']['apidesc']                  = __( 'New Helix Scope', 'twitchpress' );
    279282    $scope['user:edit:broadcast']['apidesc']        = __( 'New Helix Scope', 'twitchpress' );
     
    304307    $scope['bits:read']['userdesc']                  = __( 'New Helix Scope', 'twitchpress' );
    305308    $scope['clips:edit']['userdesc']                 = __( 'New Helix Scope', 'twitchpress' );
     309    $scope['moderation:read']['apidesc']             = __( 'View a channel’s moderation data including Moderators, Bans, Timeouts, and Automod settings.', 'twitchpress' );   
    306310    $scope['user:edit']['userdesc']                  = __( 'New Helix Scope', 'twitchpress' );
    307311    $scope['user:edit:broadcast']['userdesc']        = __( 'New Helix Scope', 'twitchpress' );
  • twitchpress/trunk/includes/admin/class.twitchpress-admin-quicktools.php

    r2472434 r2473441  
    3535    public $return_tool_info = false;
    3636                 
    37     /**
    38     * Mainly for hooks.
    39     */
    40     public static function init() {               
    41         add_action( 'admin_init', array( __CLASS__, 'admin_request_listener' )  );     
    42     }
    43    
    4437    public function url( $tool_name ) {
    4538        $nonce = wp_create_nonce( 'tool_action' );       
     
    881874        }
    882875    }   
     876   
     877    /**
     878    * Starts a commercial on the main channel.
     879    *
     880    * @version 1.0
     881    */
     882    public function tool_start_commercial() {
     883        $tool_info = array(
     884            'title'       => __( 'Star Commercial', 'multitool' ),
     885            'description' => __( 'Starts a commercial on the main channel.', 'multitool' ),
     886            'version'     => '1.1',
     887            'author'      => 'Ryan Bayne',
     888            'url'         => '',
     889            'category'    => 'moderation',
     890            'capability'  => 'activate_plugins',
     891            'option'      => null,
     892            'function'    => __FUNCTION__,
     893            'plugin'      => 'TwitchPress',
     894        );
     895       
     896        if( $this->return_tool_info ){ return $tool_info; }     
     897       
     898        if( !current_user_can( $tool_info['capability'] ) ) { return; }
     899
     900        $notices = new TwitchPress_Admin_Notices();
     901       
     902        $helix = new TWITCHPRESS_Twitch_API();
     903       
     904        $helix->start_commercial( twitchpress_get_main_channels_twitchid(), $length = 30 );
     905       
     906        $notices->error( __( 'EXAMPLE Application Not Ready', 'twitchpress-sync' ), __( 'A message here.', 'twitchpress' ) );
     907
     908               
     909        /*
     910            Your tools unique code goes here. Make it do something!
     911        */
     912    }
     913   
    883914}
    884915
     
    886917
    887918$QuickTools = new TwitchPress_Tools();
    888 $QuickTools->init();
     919add_action( 'init', array( $QuickTools, 'admin_request_listener' ), 5  );
    889920unset($QuickTools);
  • twitchpress/trunk/includes/admin/class.twitchpress-admin-setup-wizard.php

    r2472434 r2473441  
    225225        <?php if( $this->optional ) { ?>
    226226       
    227         <p><?php _e( 'Thank you for choosing TwitchPress! The setup wizard will walk you through some essential settings and explain the changes being made to your blog. <strong>It’s completely optional and shouldn’t take longer than five minutes.</strong>', 'twitchpress' ); ?></p>
    228         <p><?php _e( 'No time right now? If you dont want to go through the wizard, you can skip and return to the WordPress dashboard. You will be able to use the plugin but you might miss some features!', 'twitchpress' ); ?></p>
     227        <p><?php _e( 'Thank you for choosing TwitchPress! The setup wizard will walk you through some essential settings and explain the changes being made to your blog. <strong>It’s completely optional and shouldn’t take longer than five minutes.</strong>', 'twitchpress' ); ?></p>
     228        <p><?php _e( 'No time right now? If you don’t want to go through the wizard, you can skip and return to the WordPress dashboard. You will be able to use the plugin but you might miss some features!', 'twitchpress' ); ?></p>
    229229        <p class="twitchpress-setup-actions step">
    230230            <a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" class="button-primary button button-large button-next"><?php _e( 'Let\'s Go!', 'twitchpress' ); ?></a>
     
    234234        <?php } else { ?>
    235235           
    236         <p><?php _e( 'Thank you for choosing TwitchPress! The setup wizard will walk you through some essential settings and explain the changes being made to your blog. <strong>It is required before you can use the plugin but it shouldnt take longer than five minutes.</strong> You will be asked to enter your Twitch Application credentials. If you do not have time to do this right now. Please click on the "Not Right Now" button below.', 'twitchpress' ); ?></p>
     236        <p><?php _e( 'Thank you for choosing TwitchPress! The setup wizard will walk you through some essential settings and explain the changes being made to your blog. <strong>It is required before you can use the plugin but it shouldn’t take longer than five minutes.</strong> You will be asked to enter your Twitch Application credentials. If you do not have time to do this right now. Please click on the "Not Right Now" button below.', 'twitchpress' ); ?></p>
    237237               
    238238        <h1><?php _e( 'Twitch Developer Services Agreement', 'twitchpress' ); ?></h1>
     
    380380                    <td>
    381381                        <input type="checkbox" id="twitchpress_scope_communities_edit" name="twitchpress_scopes[]" class="input-checkbox" value="communities_edit" <?php checked( get_option( 'twitchpress_scope_communities_edit' ), 'yes', true ); ?> />
    382                         <label for="twitchpress_scope_communities_edit"><?php _e( 'Manage a users communities.', 'twitchpress' ); ?></label>
     382                        <label for="twitchpress_scope_communities_edit"><?php _e( 'Manage a user’s communities.', 'twitchpress' ); ?></label>
    383383                    </td>
    384384                </tr>
     
    394394                    <td>
    395395                        <input type="checkbox" id="twitchpress_scope_collections_edit" name="twitchpress_scopes[]" class="input-checkbox" value="collections_edit" <?php checked( get_option( 'twitchpress_scope_collections_edit' ), 'yes', true ); ?> />
    396                         <label for="twitchpress_scope_collections_edit"><?php _e( 'Manage a users collections (of videos).', 'twitchpress' ); ?></label>
     396                        <label for="twitchpress_scope_collections_edit"><?php _e( 'Manage a user’s collections (of videos).', 'twitchpress' ); ?></label>
    397397                    </td>
    398398                </tr>     
     
    439439                    </td>
    440440                </tr>
     441                <tr>
     442                    <th scope="row"><label for="twitchpress_scope_moderation_read"><?php _e( 'moderation:read', 'twitchpress' ); ?></label></th>
     443                    <td>
     444                        <input type="checkbox" id="twitchpress_scope_moderation_read" name="twitchpress_scopes[]" class="input-checkbox" value="moderation_read" <?php checked( get_option( 'twitchpress_scope_moderation_read' ), 'yes', true ); ?> />
     445                        <label for="twitchpress_scope_moderation_read"><?php _e( 'View a channel’s moderation data including Moderators, Bans, Timeouts, and Automod settings.', 'twitchpress' ); ?></label>
     446                    </td>
     447                </tr>               
    441448                <tr>
    442449                    <th scope="row"><label for="twitchpress_scope_user_edit"><?php _e( 'user:edit', 'twitchpress' ); ?></label></th>
     
    575582                    <td>
    576583                        <input type="checkbox" id="twitchpress_visitor_scope_communities_edit" name="twitchpress_visitor_scopes[]" class="input-checkbox" value="communities_edit" <?php checked( get_option( 'twitchpress_visitor_scope_communities_edit' ), 'yes', true ); ?> />
    577                         <label for="twitchpress_visitor_scope_communities_edit"><?php _e( 'Manage a users communities.', 'twitchpress' ); ?></label>
     584                        <label for="twitchpress_visitor_scope_communities_edit"><?php _e( 'Manage a user’s communities.', 'twitchpress' ); ?></label>
    578585                    </td>
    579586                </tr>
     
    589596                    <td>
    590597                        <input type="checkbox" id="twitchpress_visitor_scope_collections_edit" name="twitchpress_visitor_scopes[]" class="input-checkbox" value="collections_edit" <?php checked( get_option( 'twitchpress_visitor_scope_collections_edit' ), 'yes', true ); ?> />
    591                         <label for="twitchpress_visitor_scope_collections_edit"><?php _e( 'Manage a users collections (of videos).', 'twitchpress' ); ?></label>
     598                        <label for="twitchpress_visitor_scope_collections_edit"><?php _e( 'Manage a user’s collections (of videos).', 'twitchpress' ); ?></label>
    592599                    </td>
    593600                </tr>     
     
    632639                        <input type="checkbox" id="twitchpress_visitor_scope_clips_edit" name="twitchpress_visitor_scopes[]" class="input-checkbox" value="clips_edit" <?php checked( get_option( 'twitchpress_visitor_scope_clips_edit' ), 'yes', true ); ?> />
    633640                        <label for="twitchpress_visitor_scope_clips_edit"><?php _e( 'New Helix Scope.', 'twitchpress' ); ?></label>
     641                    </td>
     642                </tr>               
     643                <tr>
     644                    <th scope="row"><label for="twitchpress_visitor_scope_moderation_read"><?php _e( 'moderation:read', 'twitchpress' ); ?></label></th>
     645                    <td>
     646                        <input type="checkbox" id="twitchpress_visitor_scope_moderation_read" name="twitchpress_visitor_scopes[]" class="input-checkbox" value="clips_edit" <?php checked( get_option( 'twitchpress_visitor_scope_moderation_read' ), 'yes', true ); ?> />
     647                        <label for="twitchpress_visitor_scope_moderation_read"><?php _e( 'View a channel’s moderation data including Moderators, Bans, Timeouts, and Automod settings.', 'twitchpress' ); ?></label>
    634648                    </td>
    635649                </tr>
  • twitchpress/trunk/includes/admin/settings/class.twitchpress-settings-kraken.php

    r2472434 r2473441  
    414414                    'scope'           => 'clips_edit',
    415415                ),
     416                               
     417                array(
     418                    'desc'            => __( 'moderation:read: View moderation data.', 'twitchpress' ),
     419                    'id'              => 'twitchpress_scope_moderation_read',
     420                    'default'         => $default,
     421                    'type'            => 'scopecheckbox',
     422                    'checkboxgroup'   => '',
     423                    'show_if_checked' => 'yes',
     424                    'autoload'        => false,
     425                    'scope'           => 'moderation_read',
     426                ),
    416427               
    417428                array(
     
    701712                    'autoload'        => false,
    702713                    'scope'           => 'clips_edit',
     714                ),
     715               
     716                array(
     717                    'desc'            => __( 'moderation:read: Get moderation data.', 'twitchpress' ),
     718                    'id'              => 'twitchpress_visitor_scope_moderation_read',
     719                    'default'         => $default,
     720                    'type'            => 'scopecheckboxpublic',
     721                    'checkboxgroup'   => '',
     722                    'show_if_checked' => 'yes',
     723                    'autoload'        => false,
     724                    'scope'           => 'moderation_read',
    703725                ),
    704726               
  • twitchpress/trunk/includes/classes/class.twitchpress-set-user-auth.php

    r2472434 r2473441  
    1919    public $wp_user_id = null;
    2020
    21     function set( $wp_user_id ) {     
     21    function set( $wp_user_id ) { 
    2222        $this->user_twitch_id    = get_user_meta( $wp_user_id, 'twitchpress_twitch_id', true );       
    2323        $this->user_bio          = get_user_meta( $wp_user_id, 'twitch_bio', true );       
     
    5050endif;
    5151
     52/**
     53* Setup te current users oAuth2 credentials.
     54*
     55* @version 2.0
     56*/
    5257function twitchpress_init_current_user_twitch_oauth() {   
    5358    if( !is_user_logged_in() ) { return; }
    5459    $set_user = new TwitchPress_Set_User();
    55     $set_user->set( wp_get_current_user() );
     60    $set_user->set( wp_get_current_user()->ID );
    5661    TwitchPress_Object_Registry::add( 'currentusertwitch', $set_user );
    5762    unset( $set_user );   
  • twitchpress/trunk/includes/libraries/twitch/helix/class.twitch-api.php

    r2472434 r2473441  
    281281   
    282282    /**
     283    *       NEWER APPROACH  ------ STILL DOESNT WORK
     284    *
    283285    * Alternative approach to requests...
    284286    *
     
    299301    */
    300302    public function Twitch_Request( $type, $endpoint, $headers = array(), $body = array(), $additional = array() ) {
     303       
     304        /*  NEWER APPROACH  ------ STILL DOESNT WORK */
     305       
    301306        // Create new curl object for performing an API call...
    302307        $new_curl = new TwitchPress_Extend_WP_Http_Curl();
     
    689694
    690695        $this->curl( __FILE__, __FUNCTION__, __LINE__, 'POST', $endpoint );
    691                  
    692         //$this->curl_object->grant_type = 'refresh_token';
    693        
    694         //$this->curl_object->refresh_token = $token_refresh;
    695        
    696696        $this->curl_object->client_secret = twitchpress_get_app_secret();
    697        
    698697        $this->curl_object->scope = twitchpress_prepare_scopes( twitchpress_get_visitor_scopes() );
    699        
    700         //$this->curl_object->add_headers( array( 'Client_Secret' => twitchpress_get_app_secret() ) );
    701 
    702698        $this->call();
    703699
     
    18701866        return $this->curl_object->curl_reply_body; 
    18711867    }
     1868   
     1869    /**
     1870    * Starts a commercial on a specified channel.
     1871    *
     1872    * @link https://dev.twitch.tv/docs/api/reference#start-commercial
     1873    *
     1874    * @param mixed $broadcaster_id
     1875    * @param mixed $length
     1876    *
     1877    * @version 1.0
     1878    */
     1879    public function start_commercial( $broadcaster_id, $length = 30 ) {
     1880        $endpoint = 'https://api.twitch.tv/helix/channels/commercial';
     1881        $endpoint = add_query_arg( array(
     1882            'broadcaster_id' => $broadcaster_id,
     1883            'length'         => $length,
     1884        ), $endpoint );
     1885
     1886        $this->curl( __FILE__, __FUNCTION__, __LINE__, 'POST', $endpoint );
     1887       
     1888        $this->curl_object->add_headers( array(
     1889            "Authorization" => 'Bearer ' . twitchpress_get_user_token( 1 ),
     1890            "Client-ID" => twitchpress_get_app_id( true ),       
     1891        ) );
     1892       
     1893        $this->call();
     1894
     1895        twitchpress_var_dump_safer( $this );
     1896       
     1897        if( $this->curl_object->call_result == true )
     1898        {     
     1899            return $this->curl_object->curl_reply_body;
     1900        }
     1901        else
     1902        {         
     1903            return false;   
     1904        }       
     1905    }
    18721906}
    18731907
  • twitchpress/trunk/readme.txt

    r2472434 r2473441  
    77Requires at least: 5.2
    88Tested up to: 5.5
    9 Stable tag: 3.6.1
     9Stable tag: 3.7.0
    1010Requires PHP: 5.6
    1111                       
     
    5252Translator needed to localize the Channel Solution for Twitch.
    5353
    54 == Changelog ==     
     54== Changelog ==
     55= 3.7.0 Released 12th February 2021 =
     56* Faults Resolved
     57    - A fix relating to users API credentials not loading properly.
     58* Feature Improvements
     59    - New Scope: moderation:read
     60* Technical Notes
     61    - None
     62* Configuration Advice
     63    - None
     64* Database Changes
     65    - None=
     66       
    5567= 3.6.1 Released 8th February 2021 =
    5668* Faults Resolved
  • twitchpress/trunk/twitchpress.php

    r2472434 r2473441  
    55 * Github URI: https://github.com/RyanBayne/TwitchPress
    66 * Description: Add the power of Twitch.tv to WordPress
    7  * Version: 3.6.1
     7 * Version: 3.7.0
    88 * Author: Ryan Bayne
    99 * Author URI: https://ryanbayne.wordpress.com/
     
    1515 */
    1616 
    17 const TWITCHPRESS_VERSION = '3.6.1';
     17const TWITCHPRESS_VERSION = '3.7.0';
    1818
    1919// Exit if accessed directly.
Note: See TracChangeset for help on using the changeset viewer.