Plugin Directory

Changeset 2024613


Ignore:
Timestamp:
02/04/2019 01:11:13 PM (7 years ago)
Author:
Ryan Bayne
Message:

Helix progress including web hooks

Location:
channel-solution-for-twitch
Files:
213 added
15 deleted
30 edited

Legend:

Unmodified
Added
Removed
  • channel-solution-for-twitch/trunk

    • Property svn:ignore set to
      depreciated.php
  • channel-solution-for-twitch/trunk/functions.php

    r1977739 r2024613  
    22add_filter( 'get_avatar', 'twitchpress_slug_get_avatar', 10, 5 );
    33function twitchpress_slug_get_avatar( $avatar, $id_or_email, $size, $default, $alt = '' ) {
    4                                    
    5     //If is email, try and find user ID
    6     if( ! is_numeric( $id_or_email ) && is_email( $id_or_email ) ){
    7         $user  = get_user_by( 'email', $id_or_email );
     4 
     5    //If is email, try and find user ID...
     6    if( !is_numeric( $id_or_email ) ){
     7        $user = get_user_by( 'email', $id_or_email );
    88        if( $user ){
    99            $id_or_email = $user->ID;
     
    1111    }
    1212
    13     //if not user ID, return
    14     if( ! is_numeric( $id_or_email ) ){
     13    //If still no user ID, return...
     14    if( !is_numeric( $id_or_email ) ){
    1515        return $avatar;
    1616    }
    1717
    18     //Find URL of saved avatar in user meta
     18    //Find URL of saved avatar in user meta...
    1919    $saved = get_user_meta( $id_or_email, 'twitchpress_avatar_url', true ); 
    2020     
     
    105105        'channel_commercial'         => array(),
    106106        'channel_editor'             => array(),
    107         'channel_feed_edit'          => array(),
    108         'channel_feed_read'          => array(),
    109107        'channel_read'               => array(),
    110108        'channel_stream'             => array(),
    111109        'channel_subscriptions'      => array(),
    112         'chat_login'                 => array(),
    113110        'collections_edit'           => array(),
    114111        'communities_edit'           => array(),
     
    148145    $scope['user_subscriptions']['label']         = __( 'Get Your Subscriptions', 'twitchpress' );
    149146    $scope['channel_check_subscription']['label'] = __( 'Check Viewers Subscription', 'twitchpress' );
    150     $scope['chat_login']['label']                 = __( 'Chat Permission', 'twitchpress' );
    151     $scope['channel_feed_read']['label']          = __( 'Get Channel Feed', 'twitchpress' );
    152     $scope['channel_feed_edit']['label']          = __( 'Post To Channels Feed', 'twitchpress' );
    153147    $scope['communities_edit']['label']           = __( 'Manage Users Communities', 'twitchpress' );
    154148    $scope['communities_moderate']['label']       = __( 'Manage Community Moderators', 'twitchpress' );
     
    179173    $scope['user_subscriptions']['apidesc']         = __( 'Read access to subscriptions of a user.', 'twitchpress' );
    180174    $scope['channel_check_subscription']['apidesc'] = __( 'Read access to check if a user is subscribed to your channel.', 'twitchpress' );
    181     $scope['chat_login']['apidesc']                 = __( 'Ability to log into chat and send messages', 'twitchpress' );
    182     $scope['channel_feed_read']['apidesc']          = __( 'Ability to view to a channel feed.', 'twitchpress' );
    183     $scope['channel_feed_edit']['apidesc']          = __( 'Ability to add posts and reactions to a channel feed.', 'twitchpress' );
    184175    $scope['communities_edit']['apidesc']           = __( 'Manage a user’s communities.', 'twitchpress' );
    185176    $scope['communities_moderate']['apidesc']       = __( 'Manage community moderators.', 'twitchpress' );
     
    210201    $scope['user_subscriptions']['userdesc']         = __( 'Permission to get your subscriptions.', 'twitchpress' );
    211202    $scope['channel_check_subscription']['userdesc'] = __( 'Read access to check if a user is subscribed to your channel.', 'twitchpress' );
    212     $scope['chat_login']['userdesc']                 = __( 'Ability to log into your chat and send messages', 'twitchpress' );
    213     $scope['channel_feed_read']['userdesc']          = __( 'Ability to import your channel feed.', 'twitchpress' );
    214     $scope['channel_feed_edit']['userdesc']          = __( 'Ability to add posts and reactions to your channel feed.', 'twitchpress' );
    215203    $scope['communities_edit']['userdesc']           = __( 'Manage your user’s communities.', 'twitchpress' );
    216204    $scope['communities_moderate']['userdesc']       = __( 'Manage your community moderators.', 'twitchpress' );
     
    747735
    748736    // Build oauth2 URL.
    749     $url = 'https://api.twitch.tv/kraken/oauth2/authorize?' .
     737    $url = 'https://id.twitch.tv/oauth2/authorize?' .
    750738        'response_type=code' . '&' .
    751739        'client_id=' . twitchpress_get_app_id() . '&' .
     
    798786* running none urgent tasks during existing operations and demanding requests.
    799787*/
    800 function twitchpress_is_background_process() {        
     788function twitchpress_is_background_process() {   
    801789    if ( ( 'wp-login.php' === basename( $_SERVER['SCRIPT_FILENAME'] ) )
    802790            || ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST )
     
    10361024*/
    10371025function twitchpress_was_valid_token_returned( $returned_value ){
    1038    
    1039     if( !array( $returned_value ) ) {
     1026                                             
     1027    if( !array( $returned_value ) ) {       
    10401028        return false;
    10411029    }
     
    10511039    return true;
    10521040}                     
     1041
     1042/**
     1043* A helix function for confirming access
     1044*
     1045* @returns boolean true if the value appears normal.
     1046*
     1047* @version 1.0
     1048*/
     1049function twitchpress_was_valid_token_returned_from_helix( $returned_value ){
     1050                                             
     1051    if( !is_object( $returned_value ) ) {       
     1052        return false;
     1053    }
     1054   
     1055    if( !isset( $returned_value->access_token ) ) {
     1056        return false;
     1057    }
     1058
     1059    if( !twitchpress_validate_token( $returned_value->access_token ) ) {
     1060        return false;
     1061    }
     1062   
     1063    return true;
     1064}
    10531065     
    10541066/**
     
    12351247        return;
    12361248    }
    1237              
    1238                        
     1249                               
    12391250    // Tracking adds more values to help trace where redirect was requested.
    1240     if( get_option( 'twitchress_redirect_tracking_switch' ) == 'yes' )
     1251    if( get_option( 'twitchpress_redirect_tracking_switch' ) == 'yes' )
    12411252    {
    12421253        $url = add_query_arg( array( 'redirected-line' => $line, 'redirected-function' => $function ), esc_url_raw( $url ) );
     
    13031314}
    13041315
    1305 function twitchpress_var_dump( $var ) {
    1306     return var_dump_twitchpress( $var );   
     1316function twitchpress_var_dump( $var, $function = null, $line = null, $file = null, $wp_die = false  ) {
     1317                                   
     1318    if( !twitchpress_are_errors_allowed() ){ return false; }
     1319   
     1320    $header = '';
     1321    if( $function ) {
     1322        $header .= 'Function: ' . $function . ' ';
     1323    }
     1324    if( $line ) {
     1325        $header .= 'Line: ' . $line . ' ';   
     1326    }
     1327    if( $file ) {
     1328        $header .= 'File: ' . $file . ' ';   
     1329    }
     1330    if( $header ) {
     1331        echo '<h4>' . $header . '</h4>';     
     1332    }
     1333   
     1334    if( !function_exists( 'wp_get_current_user' ) ) { return null; }
     1335   
     1336    echo '<pre>'; var_dump( $var ); echo '</pre>';   
     1337   
     1338    if( $wp_die ) {
     1339        wp_die();
     1340    }
    13071341}
    13081342
     
    13211355*/
    13221356function twitchpress_are_errors_allowed() {
    1323     if( twitchpress_is_background_process() ) {
     1357
     1358    if( twitchpress_is_background_process() ) { 
    13241359        return false;
    1325     }       
    1326                     
     1360    }   
     1361               
    13271362    if( !get_option( 'twitchpress_displayerrors' ) || get_option( 'twitchpress_displayerrors' ) !== 'yes' ) {
    1328         return false;
     1363       return false;
    13291364    }
    13301365
    13311366    // We can bypass the protection to display errors for a specified user.
    1332     if( 'BYPASS' == get_option( 'bugnet_error_dump_user_id') ) {
    1333         return true;   
     1367    if( 'BYPASS' == get_option( 'bugnet_error_dump_user_id') ) { 
     1368       return true;   
    13341369    }
    13351370   
    13361371    // A value of ADMIN allows anyone with "activate_plugins" permission to see errors.
    1337     if( !current_user_can( 'activate_plugins' ) ) {
    1338         return false;
     1372    if( !current_user_can( 'activate_plugins' ) ) {   
     1373       return false;
    13391374    } 
    1340     elseif( 'ADMIN' == get_option( 'bugnet_error_dump_user_id') ) {
    1341         return true;   
    1342     }
    1343    
     1375    elseif( 'ADMIN' == get_option( 'bugnet_error_dump_user_id') ) { 
     1376       return true;   
     1377    }
     1378
    13441379    // Match current users ID to the entered ID which restricts error display to a single user.
    1345     if( get_current_user_id() != get_option( 'bugnet_error_dump_user_id') ) {
    1346         return false;   
     1380    if( get_current_user_id() != get_option( 'bugnet_error_dump_user_id') ) { 
     1381       return false;   
    13471382    }
    13481383   
  • channel-solution-for-twitch/trunk/includes/admin/class.twitchpress-admin-help.php

    r1969461 r2024613  
    2323     * Hook in tabs.
    2424     */
    25     public function __construct() {
     25    public function __construct() {                     
    2626        add_action( 'current_screen', array( $this, 'add_tabs' ), 50 );
     27       
     28        // Get the Twitch applications status...
     29        $set_app = new TwitchPress_Set_App();
     30        $this->set_app_status = $set_app->status();
     31       
     32        // The admin help offers a link for the admin to go through oAuth...
     33        $state = array( 'redirectto' => admin_url( 'index.php?page=twitchpress' ),
     34            'userrole'   => 'administrator',
     35            'outputtype' => 'admin',
     36            'reason'     => 'mainchannelsetup',
     37            'function'   => __FUNCTION__,
     38            'file'       => __FILE__
     39        );
     40        $this->oauth_url = twitchpress_generate_authorization_url( twitchpress_get_global_accepted_scopes(), $state );     
    2741    }
    2842
     
    3549        $screen = get_current_screen();
    3650                                       
    37         if ( ! $screen || ! in_array( $screen->id, twitchpress_get_screen_ids() ) ) {
     51        if ( ! $screen || ! in_array( $screen->id, twitchpress_get_screen_ids() ) ) {             
    3852            return;
    39         }
     53        }                                                                                                                                           
    4054       
    4155        $page = empty( $_GET['page'] ) ? '' : sanitize_title( $_GET['page'] );
    4256        $tab  = empty( $_GET['tab'] )  ? '' : sanitize_title( $_GET['tab'] );
    43 
     57         
    4458        /**
    4559        * This is the right side sidebar, usually displaying a list of links.
     
    5771            '<p><a href="https://dev.twitch.tv/dashboard/apps" target="_blank">' . __( 'Twitch Apps', 'twitchpress' ) . '</a></p>' .
    5872            '<p><a href="https://github.com/RyanBayne/TwitchPress/wiki/Extensions" target="_blank">' . __( 'Extensions', 'twitchpress' ) . '</a></p>' .
     73            '<p><a href="https://dev.twitch.tv/docs/api/reference/" target="_blank">' . __( 'Twitch API Doc', 'twitchpress' ) . '</a></p>' .           
    5974            '<p><a href="https://www.patreon.com/zypherevolved" target="_blank">' . __( 'Patron Pledges', 'twitchpress' ) . '</a></p>' .
    6075            '<p><a href="https://www.paypal.me/zypherevolved" target="_blank">' . __( 'PayPal Donations', 'twitchpress' ) . '</a></p>'
     
    7388            '<p><a href="' . TWITCHPRESS_GITHUB . '/issues?state=open' . '" class="button button-primary">' . __( 'Report a bug', 'twitchpress' ) . '</a></p>',
    7489        ) );
    75                                  
     90       
     91        ########################################################################
     92        #                                                                      #
     93        #                          INSTALLATION TAB                            #
     94        #                                                                      #
     95        ########################################################################                         
    7696        $nonce = wp_create_nonce( 'tool_action' );
    7797       
     
    81101            'content'   =>
    82102                '<h2>' . __( 'Setup Wizard', 'twitchpress' ) . '</h2>' .
    83                 '<p>' . __( 'You must complete the Setup Wizard and you can go through it again to correct mistakes in the plugins initial configuration.', 'twitchpress' ) . '</p>' .
     103                '<p>' . __( 'You can use the Setup Wizard more than once and not just on the first installation.', 'twitchpress' ) . '</p>' .
    84104                '<p><a href="' . admin_url( 'index.php?page=twitchpress-setup' ) . '" class="button button-primary">' . __( 'Setup wizard', 'twitchpress' ) . '</a></p>' .
    85105                '<h2>' . __( 'Re-authorize Main Channel', 'twitchpress' ) . '</h2>' .
     
    88108            'callback'  => array( $this, 'installation' ),
    89109        ) );   
    90                                    
     110       
     111        ########################################################################
     112        #                                                                      #
     113        #                          CONTRIBUTION TAB                            #
     114        #                                                                      #
     115        ########################################################################                                   
    91116        $screen->add_help_tab( array(
    92117            'id'        => 'twitchpress_contribute_tab',
     
    194219    * Installation tab in help section.
    195220    *
    196     * @version 2.0
     221    * @version 3.0
    197222    */
    198     public function installation() {
    199        
    200         $output = '';
    201        
    202         if( TWITCHPRESS_API_NAME == 'kraken' )
    203         {
    204             $kraken = new TWITCHPRESS_Twitch_API_Calls();
    205            
    206             // Test Top Game
    207             $channel = $kraken->get_top_games( __FUNCTION__ );
    208            
    209             // Get main channel as a Twitch user.         
    210             //$twitch_user = $kraken->get_users( twitchpress_get_main_channels_name() );
    211                    
    212             // Test Get Application Token
    213             $token_result = twitchpress_get_app_token();
    214         }
    215         else
    216         {   # untested
    217             $helix = new TwitchPress_Twitch_API();
    218            
    219             $channel = $helix->get_top_games();
     223    public function installation() {     
    220224 
    221             // Test Get Application Token
    222             $token_result = twitchpress_get_app_token(); 
    223         }
    224 
    225         if( !isset( $channel['top'][0]['game']['name'] ) ) {
    226             $output .= __( '<h2>No Application Code</h2>', 'twitchpress' );
    227             $output .= __( '<p>Could not get the current Top Game from Twitch.tv which indicates application details are missing. Please complete the Setup Wizard.</p>', 'twitchpress' ); 
    228         }       
    229         elseif( !twitchpress_get_main_channels_name() ) {
    230             $output .= __( '<h2>Main Channel Not Setup</h2>', 'twitchpress' );
    231             $output .= __( '<p>The main Twitch channel is usually owned by the website owner. The owner must go through the Authorize Main Channel procedure and provide a higher level of access to their account than a user would.</p>', 'twitchpress' ); 
    232         }
    233         elseif( !$token_result ){
    234             $output .= __( '<h2>No Application Token</h2>', 'twitchpress' );
    235             $output .= __( '<p>All the cool features will not work until we have a token. Please ensure your application was setup properly in the Setup Wizard.</p>', 'twitchpress' ); 
    236         }
    237        
    238         elseif( !$token_result ){
    239             $output .= __( '<h2>No Application Token</h2>', 'twitchpress' );
    240             $output .= __( '<p>All the cool features will not work until we have a token. Please ensure your application was setup properly in the Setup Wizard.</p>', 'twitchpress' ); 
    241         }
    242         elseif( !$token_result ){
    243             $output .= __( '<h2>No Application Token</h2>', 'twitchpress' );
    244             $output .= __( '<p>All the cool features will not work until we have a token. Please ensure your application was setup properly in the Setup Wizard.</p>', 'twitchpress' ); 
    245         }
    246         elseif( !$token_result ){
    247             $output .= __( '<h2>No Application Token</h2>', 'twitchpress' );
    248             $output .= __( '<p>All the cool features will not work until we have a token. Please ensure your application was setup properly in the Setup Wizard.</p>', 'twitchpress' ); 
    249         }
    250         else {
    251             $output .= __( '<h2>TwitchPress Is Ready</h2>', 'twitchpress' );
    252             $output .= __( '<p>Only a small number of tests were carried out but it seems the plugin is setup and ready to add new superpowers your WordPress.</p>', 'twitchpress' ); 
    253         }
    254 
    255         // Check for existing cache.
    256         $cache = get_transient( 'twitchpress_help_tab_installation_status' );
    257         if( $cache )
    258         {
    259             $output .= __('<p>You are viewing cached data. Please refresh in 2 minutes.</p>', 'twitchpress' );
    260         }
    261         else
    262         {
    263             // No existing cache found, so test Kraken, generate output, cache output, output output!
    264             $output .= __( '<p>You are viewing fresh results. The data will be cached for 120 seconds.</p>', 'twitchpress' ); 
    265         }
    266            
    267         // Avoid making these requests for every admin page request.
    268         set_transient( 'twitchpress_help_tab_installation_status', $output, 120 );
    269 
    270         print $output;   
    271225    }
    272226   
     
    386340    *
    387341    * @author Ryan Bayne
    388     * @version 2.3
     342    * @version 2.4
    389343    */
    390344    public function user_status() {
    391        
    392         // Check for existing cache.
     345        // Ensure the Twitch API application has been setup...
     346        if( $this->set_app_status[0] !== 1 ) {
     347            echo '<h3>' . __( 'Welcome to TwitchPress', 'twitchpress' ) . '</h3>';
     348            echo $this->set_app_status[1]; 
     349            echo '<p><a href="' . admin_url( 'index.php?page=twitchpress-setup' ) . '" class="button button-primary">' . __( 'Setup wizard', 'twitchpress' ) . '</a></p>';           
     350            return;   
     351        }
     352       
     353        // Check for existing output cache...
    393354        $cache = get_transient( 'twitchpresshelptabuserstatus' );
    394355        if( $cache )
     
    414375        if( TWITCHPRESS_API_NAME == 'helix' )
    415376        {
    416             $helix = new TwitchPress_Twitch_API();
    417 
    418             // Test Get Users Token
    419             $output .= '<h2>' . __( 'Test: Get Your Token', 'twitchpress' ) . '</h2>';
    420             $token_result = $helix->establish_user_token( __FUNCTION__, $current_user_wp_id );
    421 
    422             if( $token_result ){$output .= __( 'Result: You have a token!' ); }
    423             else{ $output .= __( 'Result: You do not have a token!' ); $overall_result = false; }
    424 
    425             // Test Validate Users Token
    426             $output .= '<h2>' . __( 'Test: Validating Your Token', 'twitchpress' ) . '</h2>';
    427             $token_result = $helix->check_user_token( $current_user_wp_id );
    428 
    429             if( isset( $token_result['token'] ) && isset( $token_result['scopes'] ) && isset( $token_result['name'] ) ) {
    430                 $output .= __( 'Result: Your token is valid. ' );   
    431             }else{$output .= __( 'Result: Your token does not appear to be valid. ' ); $overall_result = false; }
    432 
    433             // Test Get Users Channel
    434             $output .=  '<h2>Test: Get Your Channel</h2>';
     377            // Display current users token...
     378            $output = '<h3>Twitch User Status</h3>';
     379                 
     380            // Get users (current admin) authorization token...
    435381            $current_user_token = twitchpress_get_user_token( $current_user_wp_id );
    436             $channel = $helix->get_tokens_channel( $current_user_token );
    437 
    438             if( !isset( $channel['display_name'] ) || !$channel['display_name'] )
     382
     383            if( !$current_user_token )
    439384            {
    440                 $output .= __( 'Could not get your channel because: ', 'twitchpress' );
    441                 $overall_result = false;   
     385                $output .= __( 'You have not completed the Twitch Authorization procedure.', 'twitchpress' );
     386                $output .= sprintf( '<p><a href="%s">Click here to complete it</a></p>', $this->oauth_url );
     387                print $output;
     388                return;
    442389            }
    443             elseif( is_numeric( $channel['status'] ) )
    444             {
    445                 $output .= '<h3>' . __( 'Result: Error ', 'twitchpress' ) . $channel['status'] . '</h3>';
    446                 $output .= twitchpress_kraken_httpstatuses( $channel['status'], 'wiki' );
    447                 $overall_result = false;   
    448             }
    449             else
    450             {         
    451                 if( isset( $channel['display_name'] ) ) { $channel_display_name = $channel['display_name']; }
    452                 if( isset( $channel['status'] ) ) { $channel_status = $channel['status']; }
    453                 if( isset( $channel['game'] ) ) { $channel_game = $channel['game']; }
    454                
    455                 $output .= '<ul>';
    456                 $output .= '<li><strong>Channel ID: </strong>' . $channel['_id'] . '</li>';
    457                 $output .= '<li><strong>Display Name: </strong>' . $channel_display_name . '</li>';
    458                 $output .= '<li><strong>Status: </strong>' . $channel_status . '</li>';
    459                 $output .= '<li><strong>Game: </strong>' . $channel_game . '</li>';
    460                 $output .= '</ul>';
    461             }
    462 
    463             // Check if user is subscribed to the main channel.
    464             if( isset( $channel['_id'] ) )
    465             {
    466                 $output .= '<h2>' . __( 'Test: Subscription Check Method One', 'twitchpress' ) . '</h2>';   
    467                 $users_subscription = $helix->get_users_subscription_apicall( $channel['_id'], twitchpress_get_main_channels_twitchid(), $current_user_token );
    468                 if( !$users_subscription )
    469                 {
    470                     $output .= __( 'Not subscribed to the main channel.', 'twitchpress' );
    471                 }
    472                 else
    473                 {
    474                     $output .= __( 'Subscribed to the main channel', 'twitchpress' );
    475                 }
    476             }
    477 
    478             // Subscription check two.
    479             if( isset( $channel['_id'] ) )
    480             {       
    481                 $output .= '<h2>' . __( 'Test: Subscription Check Method Two', 'twitchpress' ) . '</h2>';
    482                 $users_sub_2 = $helix->is_user_subscribed_to_main_channel( $current_user_wp_id );
    483                 if( !$users_sub_2 )
    484                 {
    485                     $output .= __( 'Not subscribed to the main channel.', 'twitchpress' );
    486                 }
    487                 else
    488                 {
    489                     // Get the full subscription object.
    490                     $sub_object = $helix->getUserSubscription( $channel['_id'], twitchpress_get_main_channels_twitchid(), $current_user_token );
    491 
    492                     $output .= '<ul>';
    493 
    494                         $output .= '<li>Sub Plan: ' . $sub_object['sub_plan'] . '</li>';
    495                         $output .= '<li>Plan Name: ' . $sub_object['sub_plan_name'] . '</li>';
    496                         $output .= '<li>Channel ID: ' . $sub_object['channel']['_id'] . '</li>';
    497                                
    498                         if( $sub_object['channel']['partner'] )
    499                         {
    500                             $output .= '<li>Partner Status: ' . __( 'Partnered', 'twitchpress' ) . '<li>';
    501                         }
    502                         else
    503                         {
    504                             $output .= '<li>Partner Status: ' . __( 'Not Partnered', 'twitchpress' ) . '<li>';   
    505                         }
    506                    
    507                     $output .= '</ul>';
    508                 } 
    509             }     
    510 
    511             // Get Tokens Scopes
    512             $output .= '<h2>' . __( 'Your Tokens Current Scopes', 'twitchpress' ) . '</h2>';
    513             if( !$scope = twitchpress_get_users_token_scopes( $current_user_wp_id ) )
    514             {
    515                 $output .= '<h3>' . __( 'No Scopes Found', 'twitchpress' ) . '</h3>';
    516             }
    517             else
    518             {   
    519                 $output .= '<ol>';
    520                 foreach( $scope as $key => $item )
    521                 {
    522                     $output .= '<li>' . esc_html( $item ) . '</li>';
    523                 }   
    524                 $output .= '</ol>';
    525             }               
     390
     391            $output .= '<ul>';
     392           
     393            // Status: User has a token...
     394            $output .= '<li class="dashicons-before dashicons-yes">User Token</li>';
     395
     396            // List End
     397            $output .= '</ul>';
     398           
    526399        }
    527400        elseif( TWITCHPRESS_API_NAME == 'kraken' )
     
    642515        set_transient( 'twitchpresshelptabuserstatus', $output, 120 );
    643516       
    644         print $output;   
    645        
    646         print sprintf( __( 'Please check Twitch.tv status %s before creating fault reports.' ), '<a target="_blank" href="https://twitchstatus.com/">here</a>' );   
     517        print $output;           
    647518    } 
    648519     
     
    653524    *
    654525    * @author Ryan Bayne
    655     * @version 3.0
     526    * @version 3.1
    656527    */
    657528    public function app_status() {
     529       
     530        // Ensure the Twitch API application has been setup...
     531        if( $this->set_app_status[0] !== 1 ) {
     532            echo '<h3>' . __( 'Welcome to TwitchPress', 'twitchpress' ) . '</h3>';
     533            echo $this->set_app_status[1];             
     534            echo '<p><a href="' . admin_url( 'index.php?page=twitchpress-setup' ) . '" class="button button-primary">' . __( 'Setup wizard', 'twitchpress' ) . '</a></p>';           
     535            return;   
     536        }
     537               
    658538        // Check for existing cache.
    659539        $cache = get_transient( 'twitchpresshelptabappstatus' );
     
    686566            $twitch_api = new TWITCHPRESS_Twitch_API();
    687567        }
    688 
     568                                 
    689569        $output .= '<h2>' . __( 'Application Credentials', 'twitchpress' ) . '</h2>';
    690570        $output .= '<p>Old App ID Method: ' . twitchpress_get_main_client_id() . '</p>';
     
    730610    *
    731611    * @author Ryan Bayne
    732     * @version 2.3
     612    * @version 2.4
    733613    */
    734614    public function channel_status() {
     615       
     616        // Ensure the Twitch API application has been setup...
     617        if( $this->set_app_status[0] !== 1 ) {
     618            echo '<h3>' . __( 'Welcome to TwitchPress', 'twitchpress' ) . '</h3>';
     619            echo $this->set_app_status[1];             
     620            echo '<p><a href="' . admin_url( 'index.php?page=twitchpress-setup' ) . '" class="button button-primary">' . __( 'Setup wizard', 'twitchpress' ) . '</a></p>';           
     621            return;   
     622        }
     623               
    735624        // Check for existing cache.
    736625        $cache = get_transient( 'twitchpresshelptabchannelstatus' );
     
    757646        if( TWITCHPRESS_API_NAME == 'kraken' )
    758647        {
    759             $kraken_or_helix = new TWITCHPRESS_Twitch_API_Calls();
     648            $kraken = new TWITCHPRESS_Twitch_API_Calls();         
     649            $twitch_user = $kraken->get_users( twitchpress_get_main_channels_name() );           
    760650        }
    761651        else
    762         {   # untested
    763             $kraken_or_helix = new TWITCHPRESS_Twitch_API();
     652        { 
     653            $helix = new TWITCHPRESS_Twitch_API();
     654            $twitch_user = $helix->get_user_without_email_by_login_name( twitchpress_get_main_channels_name() );
    764655        }
    765656
     
    776667        $output .= '<p>' . twitchpress_get_main_channels_name() . '</p>';
    777668       
    778         // Get main channel as a Twitch user.         
    779         $twitch_user = $kraken_or_helix->get_users( twitchpress_get_main_channels_name() );
    780 
    781669        // Main Channel ID
    782670        //$output .= '<h2>' . __( 'Main Channel ID', 'twitchpress' ) . '</h2>';
     
    804692    public function testing() {
    805693
    806            
     694        if( TWITCHPRESS_API_NAME == 'helix' ){
     695            /*  Make a call using Twitch API class */
     696            $twitch_api = new TWITCHPRESS_Twitch_API();
     697            $endpoint = 'https://api.twitch.tv/helix/users?login=ZypheREvolved';
     698            $headers = array( 'Client-ID' => twitchpress_get_app_id() );
     699            $curl = $twitch_api->WP_Http_Curl( 'GET', $endpoint, $headers );       
     700            $curl->finish_new_request();       
     701           
     702            //twitchpress_var_dump( $curl->final_output );
     703        }
     704       
     705                                                       
     706     /*    Make a call without using the Twitch API class...       
     707        // Create new curl object for performing an API call...
     708        $new_curl = new TwitchPress_Extend_WP_Http_Curl(
     709            twitchpress_get_app_id(),
     710            twitchpress_get_app_secret(),
     711            twitchpress_get_app_token(),
     712            'GET',                                                                       
     713            'https://api.twitch.tv/helix/users?login=ZypheREvolved'
     714        );
     715       
     716        // Add headers if the default does not add them in the current package...
     717        $new_curl->option_headers_additional( array(           
     718            'Client-ID' => twitchpress_get_app_id(),
     719        ) );
     720       
     721        // Add body parameters if the package hasn't been designed to add them automatically...
     722        $new_curl->option_body_additional();
     723       
     724        // Now add miscellanous values that will make up our curl request...
     725        $new_curl->option_other_additional();
     726       
     727        // Finish the request, this makes the call and sets $this->final_output...
     728        $new_curl->finish_new_request();
     729     */
     730     
     731     
     732        ########################################################################
     733        #                                                                      #
     734        #                               WEBHOOKS                               #
     735        #                                                                      #
     736        ########################################################################
     737        /*
     738        $test1 = 1;
     739        $test2 = 0;
     740        $test3 = 0;
     741       
     742        $callback = 'http://localhost/twitchpress/branches/beta/wp-admin/admin.php';
     743        $topic    = 'https://api.twitch.tv/helix/streams?user_id=120841817';
     744       
     745        if( $test1 )
     746        {
     747            $twitch_webhooks = new TwitchPress_Twitch_Webhooks();
     748           
     749            $twitch_webhooks->callback = $callback;
     750            $twitch_webhooks->mode     = 'subscribe';
     751            $twitch_webhooks->topic    = $topic;
     752            $twitch_webhooks->secret   = null;
     753           
     754            $result = $twitch_webhooks->users_follows( 0, 1, '120841817', null );
     755           
     756            twitchpress_var_dump( $result );
     757        }
     758       
     759        if( $test2 )
     760        {
     761            $curl = new WP_Http_Curl();
     762            $curl_version_object = curl_version();
     763
     764            $result = $curl->request(
     765                'https://api.twitch.tv/helix/webhooks/hub',
     766                array(
     767                    'method'     => 'POST',
     768                    'user-agent' => 'curl/' . $curl_version_object['version'],
     769                    'stream'     => false,
     770                    'filename'   => false,
     771                    'decompress' => false,
     772                    'headers' => array(
     773                        'content-type'      => 'application/x-www-form-urlencoded',
     774                        'client_id'         => twitchpress_get_app_id(),
     775                    ),
     776                    'body' => array (
     777                        'hub.callback'      => 'http://localhost/twitchpress/branches/beta/wp-admin/admin.php',
     778                        'hub.mode'          => 'subscribe',
     779                        'hub.topic'         => 'https://api.twitch.tv/helix/users/follows',
     780                        'hub.lease_seconds' => 0,
     781                        'hub.secret'        => null,
     782                        'first'             => 1,
     783                        'from_id'           => 120841817,
     784                        'to_id'             => null
     785                    )
     786                )
     787            );
     788            twitchpress_var_dump( $result );
     789        }
     790       
     791        if( $test3 )
     792        {
     793            $http = new WP_Http();
     794            $curl_version_object = curl_version();
     795
     796            $body = json_encode( array (
     797                        'hub.callback'      => $callback,
     798                        'hub.mode'          => 'subscribe',
     799                        'hub.topic'         => $topic,
     800                        'hub.lease_seconds' => 0,
     801                        'hub.secret'        => null,
     802                        'first'             => 1,
     803                        'from_id'           => 120841817,
     804                        'to_id'             => null
     805                    )
     806            );
     807           
     808           
     809            $result = $http->request(
     810                'https://api.twitch.tv/helix/webhooks/hub',
     811                array(
     812                    'method'     => 'POST',
     813                    'stream'     => false,
     814                    'filename'   => false,
     815                    'decompress' => false,
     816                    'headers' => array(
     817                        'Accept'            => 'application/json',
     818                        'Content-Type'      => 'application/json; charset=utf-8',
     819                        'Client-ID'         => twitchpress_get_app_id(),
     820                    ),
     821                    'body' => $body
     822                )
     823            );
     824                         
     825            twitchpress_var_dump( $result ); 
     826        }
     827        */       
    807828    }
    808829}
  • channel-solution-for-twitch/trunk/includes/admin/class.twitchpress-admin-menus.php

    r1856051 r2024613  
    3939    function secondary_menu_items() {
    4040       
    41         add_submenu_page( $this->slug, __('Feed Posts',  $this->slug), __('Feed Posts',  $this->slug), 'manage_options', 'edit.php?post_type=twitchfeed', '' );
    42         add_submenu_page( $this->slug, __('Channels',    $this->slug), __('Channels',    $this->slug), 'manage_options', 'edit.php?post_type=twitchchannels', '' );
    43         add_submenu_page( $this->slug, __('Tools',       $this->slug), __('Tools',       $this->slug), 'manage_options', 'twitchpress_tools', array( $this, 'tools_page' ) );
    44         add_submenu_page( $this->slug, __('Data',        $this->slug), __('Data',        $this->slug), 'manage_options', 'twitchpress_data', array( $this, 'data_page' ) );
     41        add_submenu_page( $this->slug, __('Webhooks',  $this->slug), __('Webhooks',  $this->slug), 'manage_options', 'edit.php?post_type=webhooks', '' );
     42        add_submenu_page( $this->slug, __('Channels',  $this->slug), __('Channels',    $this->slug), 'manage_options', 'edit.php?post_type=twitchchannels', '' );
     43        add_submenu_page( $this->slug, __('Tools',     $this->slug), __('Tools',       $this->slug), 'manage_options', 'twitchpress_tools', array( $this, 'tools_page' ) );
     44        add_submenu_page( $this->slug, __('Data',      $this->slug), __('Data',        $this->slug), 'manage_options', 'twitchpress_data', array( $this, 'data_page' ) );
    4545
    4646        // PayPal, Patreon, Streamtip
  • channel-solution-for-twitch/trunk/includes/admin/class.twitchpress-admin-notices.php

    r1856051 r2024613  
    369369    * @param mixed $dismissible
    370370    *
    371     * @version 1.0
     371    * @version 1.1
    372372    */
    373373    public static function notice( $type, $title, $description, $dismissible = false ) {
     
    382382    * @param mixed $dismissible
    383383    *
    384     * @version 1.0
     384    * @version 1.1
    385385    */
    386386    public static function error( $title, $desc, $dismissible = false ) {
    387387        $d = ''; if( $dismissible ){ $d = ' is-dismissible'; }
    388         ?><div class="notice notice-error<?php echo $d; ?>"><p><?php echo '<strong>' . $title . ': </strong>' . $desc; ?>.</p></div><?php     
     388        ?><div class="notice notice-error<?php echo $d; ?>"><p><?php echo '<strong>' . $title . ': </strong>' . $desc; ?></p></div><?php     
    389389    }
    390390   
     
    396396    * @param mixed $dismissible
    397397    *
    398     * @version 1.0
     398    * @version 1.1
    399399    */
    400400    public static function warning( $title, $desc, $dismissible = false ) {
    401401        $d = ''; if( $dismissible ){ $d = ' is-dismissible'; }
    402         ?><div class="notice notice-warning<?php echo $d; ?>"><p><?php echo '<strong>' . $title . ': </strong>' . $desc; ?>.</p></div><?php     
     402        ?><div class="notice notice-warning<?php echo $d; ?>"><p><?php echo '<strong>' . $title . ': </strong>' . $desc; ?></p></div><?php     
    403403    }
    404404   
     
    410410    * @param mixed $dismissible
    411411    *
    412     * @version 1.0
     412    * @version 1.1
    413413    */
    414414    public static function success( $title, $desc, $dismissible = false ) {
    415415        $d = ''; if( $dismissible ){ $d = ' is-dismissible'; }
    416         ?><div class="notice notice-success<?php echo $d; ?>"><p><?php echo '<strong>' . $title . ': </strong>' . $desc; ?>.</p></div><?php     
     416        ?><div class="notice notice-success<?php echo $d; ?>"><p><?php echo '<strong>' . $title . ': </strong>' . $desc; ?></p></div><?php     
    417417    }
    418418   
     
    424424    * @param mixed $dismissible
    425425    *
    426     * @version 1.0
     426    * @version 1.1
    427427    */
    428428    public static function info( $title, $desc, $dismissible = false ) {
    429429        $d = ''; if( $dismissible ){ $d = ' is-dismissible'; }
    430         ?><div class="notice notice-info<?php echo $d; ?>"><p><?php echo '<strong>' . $title . ': </strong>' . $desc; ?>.</p></div><?php     
     430        ?><div class="notice notice-info<?php echo $d; ?>"><p><?php echo '<strong>' . $title . ': </strong>' . $desc; ?></p></div><?php     
    431431    }   
    432432}
  • channel-solution-for-twitch/trunk/includes/admin/class.twitchpress-admin-quicktools.php

    r1966127 r2024613  
    435435       
    436436        // Get the main channel Twitch ID.
    437         $channel_id = twitchpress_get_main_channel_id();
     437        $channel_id = twitchpress_get_main_channels_twitchid();
    438438        $output .= sprintf( __( '<p><strong>Main Channel ID: %s</strong></p>', 'twitchpress' ), $channel_id );
    439439       
    440440        // Get main account token.     
    441         $channel_token = twitchpress_get_main_client_token();
     441        $channel_token = twitchpress_get_main_channels_token();
    442442        $output .= sprintf( __( '<p><strong>Main Token: %s</strong></p>', 'twitchpress' ), $channel_token );
    443443
     
    454454       
    455455        // Get possible existing sub plan from a earlier sub sync.
    456         $local_sub_plan = get_user_meta( $user_id, 'twitchpress_sub_plan_' . twitchpress_get_main_channel_id(), true  );
     456        $local_sub_plan = get_user_meta( $user_id, 'twitchpress_sub_plan_' . $channel_id, true  );
    457457        $output .= sprintf( __( '<p><strong>Existing Sub Plan Value: %s</strong></p>', 'twitchpress' ), $local_sub_plan );
    458458
     
    603603       
    604604        // Get the main channel Twitch ID.
    605         $channel_id = twitchpress_get_main_channel_id();
     605        $channel_id = twitchpress_get_main_channels_twitchid();
    606606        $output .= sprintf( __( '<p><strong>Main Channel ID: %s</strong></p>', 'twitchpress' ), $channel_id );
    607607       
     
    622622       
    623623        // Get possible existing sub plan from a earlier sub sync.
    624         $local_sub_plan = get_user_meta( $user_id, 'twitchpress_sub_plan_' . twitchpress_get_main_channel_id(), true  );
     624        $local_sub_plan = get_user_meta( $user_id, 'twitchpress_sub_plan_' . $channel_id, true  );
    625625        $output .= sprintf( __( '<p><strong>Existing Sub Plan Value: %s</strong></p>', 'twitchpress' ), $local_sub_plan );
    626626
  • channel-solution-for-twitch/trunk/includes/admin/class.twitchpress-admin-setup-wizard.php

    r1977739 r2024613  
    159159     * Setup Wizard Footer.
    160160     */
    161     public function setup_wizard_footer() {
    162         ?>
    163             <?php if ( 'next_steps' === $this->step ) : ?>
     161    public function setup_wizard_footer() {
     162        if ( 'next_steps' === $this->step ) : ?>
    164163                <a class="twitchpress-return-to-dashboard" href="<?php echo esc_url( admin_url() ); ?>"><?php _e( 'Return to the WordPress Dashboard', 'twitchpress' ); ?></a>
    165164            <?php endif; ?>
     
    268267                    <th scope="row"><label for="twitchpress_main_channels_name"><?php _e( 'Main Channels Name', 'twitchpress' ); ?></label></th>
    269268                    <td>
    270                         <input type="text" id="twitchpress_main_channels_name" name="twitchpress_main_channels_name" class="input-text" value="<?php echo get_option( 'twitchpress_main_channels_name' );?>" />
     269                        <input type="text" id="twitchpress_main_channels_name" name="twitchpress_main_channels_name" class="input-text" value="<?php echo esc_html( get_option( 'twitchpress_main_channels_name' ) );?>" />
    271270                        <label for="twitchpress_main_channels_name"><?php _e( 'example: ZypheREvolved, StarCitizen, nookyyy', 'twitchpress' ); ?></label>
    272271                    </td>
     
    328327                </tr>
    329328                <tr>
    330                     <th scope="row"><label for="twitchpress_scope_channel_read"><?php _e( 'channel_read', 'twitchpress' ); ?></label></th>
    331                     <td>
    332                         <input type="checkbox" id="twitchpress_scope_channel_read" name="twitchpress_scopes[]" class="input-checkbox" value="channel_read" <?php checked( get_option( 'twitchpress_scope_channel_read' ), 'yes', true ); ?> />
    333                         <label for="twitchpress_scope_channel_read"><?php _e( 'Read access to non-public channel information, including email address and stream key.', 'twitchpress' ); ?></label>
    334                     </td>
    335                 </tr>
    336                 <tr>
    337329                    <th scope="row"><label for="twitchpress_scope_channel_editor"><?php _e( 'channel_editor', 'twitchpress' ); ?></label></th>
    338330                    <td>
     
    377369                </tr>
    378370                <tr>
    379                     <th scope="row"><label for="twitchpress_scope_chat_login"><?php _e( 'chat_login', 'twitchpress' ); ?></label></th>
    380                     <td>
    381                         <input type="checkbox" id="twitchpress_scope_chat_login" name="twitchpress_scopes[]" class="input-checkbox" value="chat_login" <?php checked( get_option( 'twitchpress_scope_chat_login' ), 'yes', true ); ?> />
    382                         <label for="twitchpress_scope_chat_login"><?php _e( 'Ability to log into chat and send messages.', 'twitchpress' ); ?></label>
    383                     </td>
    384                 </tr>
    385                 <tr>
    386                     <th scope="row"><label for="twitchpress_scope_channel_feed_read"><?php _e( 'channel_feed_read', 'twitchpress' ); ?></label></th>
    387                     <td>
    388                         <input type="checkbox" id="twitchpress_scope_channel_feed_read" name="twitchpress_scopes[]" class="input-checkbox" value="channel_feed_read" <?php checked( get_option( 'twitchpress_scope_channel_feed_read' ), 'yes', true ); ?> />
    389                         <label for="twitchpress_scope_channel_feed_read"><?php _e( 'Ability to view to a channel feed.', 'twitchpress' ); ?></label>
    390                     </td>
    391                 </tr>
    392                 <tr>
    393                     <th scope="row"><label for="twitchpress_scope_channel_feed_edit"><?php _e( 'channel_feed_edit', 'twitchpress' ); ?></label></th>
    394                     <td>
    395                         <input type="checkbox" id="twitchpress_scope_channel_feed_edit" name="twitchpress_scopes[]" class="input-checkbox" value="channel_feed_edit" <?php checked( get_option( 'twitchpress_scope_channel_feed_edit' ), 'yes', true ); ?> />
    396                         <label for="twitchpress_scope_channel_feed_edit"><?php _e( 'Ability to add posts and reactions to a channel feed.', 'twitchpress' ); ?></label>
    397                     </td>
    398                 </tr>
    399                 <tr>
    400371                    <th scope="row"><label for="twitchpress_scope_communities_edit"><?php _e( 'communities_edit', 'twitchpress' ); ?></label></th>
    401372                    <td>
     
    503474                </tr>
    504475
    505             </table>   
    506                
     476            </table> 
     477                   
    507478            <h3><?php _e( 'Permissions Scope for Visitors', 'twitchpress' ); ?></h3>
    508479            <p><?php _e( 'Select the scopes that will be needed for public features. Most sites will only need 2-3 scopes unless you are building a Twitch suite for full channel management. Visitors will be shown your selected scopes during an oAuth2 request.', 'twitchpress' ); ?></p>
     
    587558                </tr>
    588559                <tr>
    589                     <th scope="row"><label for="twitchpress_visitor_scope_chat_login"><?php _e( 'chat_login', 'twitchpress' ); ?></label></th>
    590                     <td>
    591                         <input type="checkbox" id="twitchpress_visitor_scope_chat_login" name="twitchpress_visitor_scopes[]" class="input-checkbox" value="chat_login" <?php checked( get_option( 'twitchpress_visitor_scope_chat_login' ), 'yes', true ); ?> />
    592                         <label for="twitchpress_visitor_scope_chat_login"><?php _e( 'Ability to log into chat and send messages.', 'twitchpress' ); ?></label>
    593                     </td>
    594                 </tr>
    595                 <tr>
    596                     <th scope="row"><label for="twitchpress_visitor_scope_channel_feed_read"><?php _e( 'channel_feed_read', 'twitchpress' ); ?></label></th>
    597                     <td>
    598                         <input type="checkbox" id="twitchpress_visitor_scope_channel_feed_read" name="twitchpress_visitor_scopes[]" class="input-checkbox" value="channel_feed_read" <?php checked( get_option( 'twitchpress_visitor_scope_channel_feed_read' ), 'yes', true ); ?> />
    599                         <label for="twitchpress_visitor_scope_channel_feed_read"><?php _e( 'Ability to view to a channel feed.', 'twitchpress' ); ?></label>
    600                     </td>
    601                 </tr>
    602                 <tr>
    603                     <th scope="row"><label for="twitchpress_visitor_scope_channel_feed_edit"><?php _e( 'channel_feed_edit', 'twitchpress' ); ?></label></th>
    604                     <td>
    605                         <input type="checkbox" id="twitchpress_visitor_scope_channel_feed_edit" name="twitchpress_visitor_scopes[]" class="input-checkbox" value="channel_feed_edit" <?php checked( get_option( 'twitchpress_visitor_scope_channel_feed_edit' ), 'yes', true ); ?> />
    606                         <label for="twitchpress_visitor_scope_channel_feed_edit"><?php _e( 'Ability to add posts and reactions to a channel feed.', 'twitchpress' ); ?></label>
    607                     </td>
    608                 </tr>
    609                 <tr>
    610560                    <th scope="row"><label for="twitchpress_visitor_scope_communities_edit"><?php _e( 'communities_edit', 'twitchpress' ); ?></label></th>
    611561                    <td>
     
    713663                </tr>       
    714664       
    715             </table>       
     665            </table>   
     666                   
    716667            <p class="twitchpress-setup-actions step">
    717668                <input type="submit" class="button-primary button button-large button-next" value="<?php esc_attr_e( 'Continue', 'twitchpress' ); ?>" name="save_step" />
     
    750701        // Delete options for scopes that are not in $_POST (not checked) and add those that are.
    751702        $all_scopes = twitchpress_scopes();
     703        $new_app_scopes = array();
    752704        foreach( $all_scopes as $scope => $scope_info ) { 
    753705            if( in_array( str_replace( ':', '_', $scope ), $_POST['twitchpress_scopes'] ) ) {   
    754706                update_option( 'twitchpress_scope_' . str_replace( ':', '_', $scope ), 'yes' );
     707                $new_app_scopes[] = $scope;
    755708            } else {                         
    756709                delete_option( 'twitchpress_scope_' . str_replace( ':', '_', $scope ) );
    757710            }
    758711        }
     712       
     713        // Store the main scopes as app scopes for the servers own needs...
     714        twitchpress_update_app_token_scopes( $new_app_scopes );
    759715       
    760716        foreach( $all_scopes as $scope => $scope_info ) { 
     
    784740        ########################################################################
    785741        #                                                                      #
    786         #                            ACCESS TOKEN                              #
     742        #                       REQUEST APP ACCESS TOKEN                       #
    787743        #                                                                      #
    788744        ########################################################################
     
    791747        $twitch_api_obj = new TWITCHPRESS_Twitch_API();
    792748        $call_object = $twitch_api_obj->request_app_access_token( __FUNCTION__ );                                 
    793        
     749
    794750        // Error on no curl response code being found...
    795751        if( !isset( $call_object->response_code ) ) {
     
    822778        if( TWITCHPRESS_API_NAME == 'kraken' )
    823779        {
    824             $kraken_calls_obj = new TWITCHPRESS_Twitch_API_Calls();
     780            $twitch_api_obj = new TWITCHPRESS_Twitch_API_Calls();
     781            // Confirm channel exists by using the "users?login" endpoint.
     782            $user_objects = $twitch_api_obj->get_users( $main_channel );   
     783           
     784            if( !isset( $user_objects['users'][0]['_id'] ) ) {
     785                TwitchPress_Admin_Notices::add_custom_notice( 'wizardchanneldoesnotexist', sprintf( __( 'The channel you entered was not found. You entered %s. Please check the spelling and try again.'), esc_html( $main_channel ) ) );
     786                return;                         
     787            }   
     788           
     789            $twitch_user_id = $user_objects['users'][0]['_id'];                 
    825790        }
    826791        else
    827         {   # untested
    828             $helix = new TWITCHPRESS_Twitch_API();
    829         }
    830      
    831         // Confirm channel exists by using the "users?login" endpoint.
    832         $user_objects = $kraken_calls_obj->get_users( $main_channel );
    833 
    834         if( !isset( $user_objects['users'][0]['_id'] ) ) {
    835             TwitchPress_Admin_Notices::add_custom_notice( 'wizardchanneldoesnotexist', sprintf( __( 'The channel you entered was not found. You entered %s. Please check the spelling and try again.'), esc_html( $main_channel ) ) );
    836             return;                         
    837         }
    838        
    839         $twitch_user_id = $user_objects['users'][0]['_id'];
    840 
     792        {   
     793            $twitch_api_obj = new TWITCHPRESS_Twitch_API();
     794            $user_objects = $twitch_api_obj->get_user_without_email_by_login_name( $main_channel );
     795       
     796            if( !isset( $user_objects->data[0]->id ) ) {
     797                TwitchPress_Admin_Notices::add_custom_notice( 'wizardchanneldoesnotexist', sprintf( __( 'The channel you entered was not found. You entered %s. Please check the spelling and try again.'), esc_html( $main_channel ) ) );
     798                return;                         
     799            }
     800           
     801            $twitch_user_id = $user_objects->data[0]->id;       
     802        }
     803 
    841804        // The current user has logged into what we will assume is their own personal account, for now.
    842805        // So add the channel/user ID to their user meta. 
     
    12121175        }
    12131176       
    1214         //wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
    1215         //exit;
    1216 
    1217         // Send user to authorise their main Twitch channel.
    1218         $post_credentials_kraken = new TWITCHPRESS_Twitch_API();
    1219                                
     1177        // Send user to authorise their main Twitch channel.             
    12201178        $state = array( 'redirectto' => admin_url( 'index.php?page=twitchpress-setup&step=next_steps' ),
    12211179                        'userrole'   => 'administrator',
  • channel-solution-for-twitch/trunk/includes/admin/settings/class.twitchpress-settings-general.php

    r1941995 r2024613  
    6363        global $current_section;
    6464        $settings = $this->get_settings( $current_section );
     65        echo '<p>' . __( 'Please use logging with care. These features can generate
     66        a lot of files in a very short time. They are intended for debugging by
     67        someone who is monitoring the site. If you need more automati clean-up for
     68        long-term history please make a request.', 'twitchpress' ). '</p>';
    6569        TwitchPress_Admin_Settings::output_fields( $settings );
    6670    }
     
    146150                    'autoload'        => false,
    147151                ),   
    148            
    149                 array(
    150                     'desc'            => __( 'Delete Feed Posts', 'twitchpress' ),
    151                     'id'              => 'twitchpress_remove_feed_posts',
    152                     'default'         => 'no',
    153                     'type'            => 'checkbox',
    154                     'checkboxgroup'   => '',
    155                     'show_if_checked' => 'yes',
    156                     'autoload'        => false,
    157                 ),   
    158            
     152
    159153                array(
    160154                    'desc'            => __( 'Delete Database Tables', 'twitchpress' ),
     
    218212                array(
    219213                    'desc'            => __( 'Activate Redirect Tracking', 'twitchpress' ),
    220                     'id'              => 'twitchress_redirect_tracking_switch',
     214                    'id'              => 'twitchpress_redirect_tracking_switch',
    221215                    'default'         => 'no',
    222216                    'type'            => 'checkbox',
     
    231225                array(
    232226                    'desc'            => __( 'Activate Sandbox-mode', 'twitchpress' ),
    233                     'id'              => 'twitchress_sandbox_mode_switch',
     227                    'id'              => 'twitchpress_sandbox_mode_switch',
    234228                    'default'         => 'no',
    235229                    'type'            => 'checkbox',
     
    244238                array(
    245239                    'desc'            => __( 'Sandbox-mode Generator', 'twitchpress' ),
    246                     'id'              => 'twitchress_sandbox_mode_generator_switch',
     240                    'id'              => 'twitchpress_sandbox_mode_generator_switch',
    247241                    'default'         => 'no',
    248242                    'type'            => 'checkbox',
     
    257251                array(
    258252                    'desc'            => __( 'Sandbox-mode False/Fail Returns', 'twitchpress' ),
    259                     'id'              => 'twitchress_sandbox_mode_falsereturns_switch',
     253                    'id'              => 'twitchpress_sandbox_mode_falsereturns_switch',
    260254                    'default'         => 'no',
    261255                    'type'            => 'checkbox',
     
    537531                    'title' => __( 'Report Switches', 'wpseed' ),
    538532                    'type'     => 'title',
    539                     'desc'     => __( 'Reports generate information and statistics for none developers. Reports can also create documents.', 'twitchpress' ),
     533                    'desc'     => __( 'Reports generate snap-shot information and statistics. Reports are intended for long-term monitoring.', 'twitchpress' ),
    540534                    'id'     => 'twitchpress_bugnet_report_switches',
    541535                ),
  • channel-solution-for-twitch/trunk/includes/admin/settings/class.twitchpress-settings-kraken.php

    r1966127 r2024613  
    330330                    'scope'           => 'channel_check_subscription',
    331331                ),
    332                
    333                 array(
    334                     'desc'            => __( 'chat_login: Ability to log into chat and send messages.', 'twitchpress' ),
    335                     'id'              => 'twitchpress_scope_chat_login',
    336                     'default'         => $default,
    337                     'type'            => 'scopecheckbox',
    338                     'checkboxgroup'   => '',
    339                     'show_if_checked' => 'yes',
    340                     'autoload'        => false,
    341                     'scope'           => 'chat_login',
    342                 ),
    343332             
    344                 array(
    345                     'desc'            => __( 'channel_feed_read: Ability to view to a channel feed.', 'twitchpress' ),
    346                     'id'              => 'twitchpress_scope_channel_feed_read',
    347                     'default'         => $default,
    348                     'type'            => 'scopecheckbox',
    349                     'checkboxgroup'   => '',
    350                     'show_if_checked' => 'yes',
    351                     'autoload'        => false,
    352                     'scope'           => 'channel_feed_read',
    353                 ),
    354                
    355                 array(
    356                     'desc'            => __( 'channel_feed_edit: Ability to add posts and reactions to a channel feed."', 'twitchpress' ),
    357                     'id'              => 'twitchpress_scope_channel_feed_edit',
    358                     'default'         => $default,
    359                     'type'            => 'scopecheckbox',
    360                     'checkboxgroup'   => '',
    361                     'show_if_checked' => 'yes',
    362                     'autoload'        => false,
    363                     'scope'           => 'channel_feed_edit',
    364                 ),
    365 
    366333                array(
    367334                    'desc'            => __( 'communities_edit: Manage a user’s communities."', 'twitchpress' ),
     
    398365
    399366                array(
    400                     'desc'            => __( 'channel_feed_edit: Turn on Viewer Heartbeat Service ability to record user data."', 'twitchpress' ),
    401                     'id'              => 'twitchpress_scope_viewing_activity_read',
    402                     'default'         => $default,
    403                     'type'            => 'scopecheckbox',
    404                     'checkboxgroup'   => 'end',
    405                     'show_if_checked' => 'yes',
    406                     'autoload'        => false,
    407                     'scope'           => 'viewing_activity_read',
    408                 ),
    409  
     367                    'desc'            => __( 'analytics:read:extensions: View analytics data for your extensions."', 'twitchpress' ),
     368                    'id'              => 'twitchpress_scope_analytics_read_extensions',
     369                    'default'         => $default,
     370                    'type'            => 'scopecheckbox',
     371                    'checkboxgroup'   => '',
     372                    'show_if_checked' => 'yes',
     373                    'autoload'        => false,
     374                    'scope'           => 'analytics_read_extensions',
     375                ),
     376               
     377                array(
     378                    'desc'            => __( 'analytics:read:games: View analytics data for your games."', 'twitchpress' ),
     379                    'id'              => 'twitchpress_scope_analytics_read_games',
     380                    'default'         => $default,
     381                    'type'            => 'scopecheckbox',
     382                    'checkboxgroup'   => '',
     383                    'show_if_checked' => 'yes',
     384                    'autoload'        => false,
     385                    'scope'           => 'analytics_read_games',
     386                ),
     387               
     388                array(
     389                    'desc'            => __( 'bits:read: View Bits information for your channel."', 'twitchpress' ),
     390                    'id'              => 'twitchpress_scope_bits_read',
     391                    'default'         => $default,
     392                    'type'            => 'scopecheckbox',
     393                    'checkboxgroup'   => '',
     394                    'show_if_checked' => 'yes',
     395                    'autoload'        => false,
     396                    'scope'           => 'bits_read',
     397                ),
     398               
     399                array(
     400                    'desc'            => __( 'clips:edit: Manage a clip object."', 'twitchpress' ),
     401                    'id'              => 'twitchpress_scope_clips_edit',
     402                    'default'         => $default,
     403                    'type'            => 'scopecheckbox',
     404                    'checkboxgroup'   => '',
     405                    'show_if_checked' => 'yes',
     406                    'autoload'        => false,
     407                    'scope'           => 'clips_edit',
     408                ),
     409               
     410                array(
     411                    'desc'            => __( 'user:edit: Manage a user object."', 'twitchpress' ),
     412                    'id'              => 'twitchpress_scope_user_edit',
     413                    'default'         => $default,
     414                    'type'            => 'scopecheckbox',
     415                    'checkboxgroup'   => '',
     416                    'show_if_checked' => 'yes',
     417                    'autoload'        => false,
     418                    'scope'           => 'user_edit',
     419                ),
     420               
     421                array(
     422                    'desc'            => __( 'user:edit:broadcast: Edit your channel’s broadcast configuration, including extension configuration."', 'twitchpress' ),
     423                    'id'              => 'twitchpress_scope_user_edit_broadcast',
     424                    'default'         => $default,
     425                    'type'            => 'scopecheckbox',
     426                    'checkboxgroup'   => '',
     427                    'show_if_checked' => 'yes',
     428                    'autoload'        => false,
     429                    'scope'           => 'user_edit_broadcast',
     430                ),
     431
     432                array(
     433                    'desc'            => __( 'user:read:broadcast: View your broadcasting configuration, including extension configurations."', 'twitchpress' ),
     434                    'id'              => 'twitchpress_scope_user_read_broadcast',
     435                    'default'         => $default,
     436                    'type'            => 'scopecheckbox',
     437                    'checkboxgroup'   => '',
     438                    'show_if_checked' => 'yes',
     439                    'autoload'        => false,
     440                    'scope'           => 'user_read_broadcast',
     441                ),
     442     
     443                array(
     444                    'desc'            => __( 'user:read:email: Read authorized user’s email address."', 'twitchpress' ),
     445                    'id'              => 'twitchpress_scope_user_read_email',
     446                    'default'         => $default,
     447                    'type'            => 'scopecheckbox',
     448                    'checkboxgroup'   => '',
     449                    'show_if_checked' => 'yes',
     450                    'autoload'        => false,
     451                    'scope'           => 'user_read_email',
     452                ),
     453
    410454                array(
    411455                    'type'     => 'sectionend',
     
    541585                    'scope'           => 'channel_check_subscription',
    542586                ),
    543                
    544                 array(
    545                     'desc'            => __( 'chat_login: Ability to log into chat and send messages.', 'twitchpress' ),
    546                     'id'              => 'twitchpress_visitor_scope_chat_login',
    547                     'default'         => $default,
    548                     'type'            => 'scopecheckboxpublic',
    549                     'checkboxgroup'   => '',
    550                     'show_if_checked' => 'yes',
    551                     'autoload'        => false,
    552                     'scope'           => 'chat_login',
    553                 ),
    554              
    555                 array(
    556                     'desc'            => __( 'channel_feed_read: Ability to view to a channel feed.', 'twitchpress' ),
    557                     'id'              => 'twitchpress_visitor_scope_channel_feed_read',
    558                     'default'         => $default,
    559                     'type'            => 'scopecheckboxpublic',
    560                     'checkboxgroup'   => '',
    561                     'show_if_checked' => 'yes',
    562                     'autoload'        => false,
    563                     'scope'           => 'channel_feed_read',
    564                 ),
    565                
    566                 array(
    567                     'desc'            => __( 'channel_feed_edit: Ability to add posts and reactions to a channel feed."', 'twitchpress' ),
    568                     'id'              => 'twitchpress_visitor_scope_channel_feed_edit',
    569                     'default'         => $default,
    570                     'type'            => 'scopecheckboxpublic',
    571                     'checkboxgroup'   => '',
    572                     'show_if_checked' => 'yes',
    573                     'autoload'        => false,
    574                     'scope'           => 'channel_feed_edit',
    575                 ),
    576 
     587                             
    577588                array(
    578589                    'desc'            => __( 'communities_edit: Manage a user’s communities."', 'twitchpress' ),
     
    607618                    'scope'           => 'collections_edit',
    608619                ),
    609 
    610                 array(
    611                     'desc'            => __( 'channel_feed_edit: Turn on Viewer Heartbeat Service ability to record user data."', 'twitchpress' ),
    612                     'id'              => 'twitchpress_visitor_scope_viewing_activity_read',
    613                     'default'         => $default,
    614                     'type'            => 'scopecheckboxpublic',
    615                     'checkboxgroup'   => 'end',
    616                     'show_if_checked' => 'yes',
    617                     'autoload'        => false,
    618                     'scope'           => 'viewing_activity_read',
    619                 ),
    620620 
     621                array(
     622                    'desc'            => __( 'analytics:read:extensions: View analytics data for your extensions."', 'twitchpress' ),
     623                    'id'              => 'twitchpress_visitor_scope_analytics_read_extensions',
     624                    'default'         => $default,
     625                    'type'            => 'scopecheckboxpublic',
     626                    'checkboxgroup'   => '',
     627                    'show_if_checked' => 'yes',
     628                    'autoload'        => false,
     629                    'scope'           => 'analytics_read_extensions',
     630                ),
     631               
     632                array(
     633                    'desc'            => __( 'analytics:read:games: View analytics data for your games."', 'twitchpress' ),
     634                    'id'              => 'twitchpress_visitor_scope_analytics_read_games',
     635                    'default'         => $default,
     636                    'type'            => 'scopecheckboxpublic',
     637                    'checkboxgroup'   => '',
     638                    'show_if_checked' => 'yes',
     639                    'autoload'        => false,
     640                    'scope'           => 'analytics_read_games',
     641                ),
     642               
     643                array(
     644                    'desc'            => __( 'bits:read: View Bits information for your channel."', 'twitchpress' ),
     645                    'id'              => 'twitchpress_visitor_scope_bits_read',
     646                    'default'         => $default,
     647                    'type'            => 'scopecheckboxpublic',
     648                    'checkboxgroup'   => '',
     649                    'show_if_checked' => 'yes',
     650                    'autoload'        => false,
     651                    'scope'           => 'bits_read',
     652                ),
     653               
     654                array(
     655                    'desc'            => __( 'clips:edit: Manage a clip object."', 'twitchpress' ),
     656                    'id'              => 'twitchpress_visitor_scope_clips_edit',
     657                    'default'         => $default,
     658                    'type'            => 'scopecheckboxpublic',
     659                    'checkboxgroup'   => '',
     660                    'show_if_checked' => 'yes',
     661                    'autoload'        => false,
     662                    'scope'           => 'clips_edit',
     663                ),
     664               
     665                array(
     666                    'desc'            => __( 'user:edit: Manage a user object."', 'twitchpress' ),
     667                    'id'              => 'twitchpress_visitor_scope_user_edit',
     668                    'default'         => $default,
     669                    'type'            => 'scopecheckboxpublic',
     670                    'checkboxgroup'   => '',
     671                    'show_if_checked' => 'yes',
     672                    'autoload'        => false,
     673                    'scope'           => 'user_edit',
     674                ),
     675               
     676                array(
     677                    'desc'            => __( 'user:edit:broadcast: Edit your channel’s broadcast configuration, including extension configuration."', 'twitchpress' ),
     678                    'id'              => 'twitchpress_visitor_scope_user_edit_broadcast',
     679                    'default'         => $default,
     680                    'type'            => 'scopecheckboxpublic',
     681                    'checkboxgroup'   => '',
     682                    'show_if_checked' => 'yes',
     683                    'autoload'        => false,
     684                    'scope'           => 'user_edit_broadcast',
     685                ),
     686
     687                array(
     688                    'desc'            => __( 'user:read:broadcast: View your broadcasting configuration, including extension configurations."', 'twitchpress' ),
     689                    'id'              => 'twitchpress_visitor_scope_user_read_broadcast',
     690                    'default'         => $default,
     691                    'type'            => 'scopecheckboxpublic',
     692                    'checkboxgroup'   => '',
     693                    'show_if_checked' => 'yes',
     694                    'autoload'        => false,
     695                    'scope'           => 'user_read_broadcast',
     696                ),
     697     
     698                array(
     699                    'desc'            => __( 'user:read:email: Read authorized user’s email address."', 'twitchpress' ),
     700                    'id'              => 'twitchpress_visitor_scope_user_read_email',
     701                    'default'         => $default,
     702                    'type'            => 'scopecheckboxpublic',
     703                    'checkboxgroup'   => '',
     704                    'show_if_checked' => 'yes',
     705                    'autoload'        => false,
     706                    'scope'           => 'user_read_email',
     707                ),
     708
    621709                array(
    622710                    'type'     => 'sectionend',
  • channel-solution-for-twitch/trunk/includes/admin/views/html-admin-data.php

    r1856051 r2024613  
    2323    echo 'TwitchPress: ' . esc_html( $title );
    2424    ?>
    25     <?php if( get_option( 'twitchress_sandbox_mode_switch' ) == 'yes' ) { _e( '- Sandbox Mode Active', 'twitchpress' ); }?>
     25    <?php if( get_option( 'twitchpress_sandbox_mode_switch' ) == 'yes' ) { _e( '- Sandbox Mode Active', 'twitchpress' ); }?>
    2626    </h1>
    2727   
  • channel-solution-for-twitch/trunk/includes/admin/views/html-admin-page.php

    r1856051 r2024613  
    2323    echo 'TwitchPress: ' . esc_html( $title );
    2424    ?>
    25     <?php if( get_option( 'twitchress_sandbox_mode_switch' ) == 'yes' ) { _e( ' - Sandbox Mode Active', 'twitchpress' ); }?>
     25    <?php if( get_option( 'twitchpress_sandbox_mode_switch' ) == 'yes' ) { _e( ' - Sandbox Mode Active', 'twitchpress' ); }?>
    2626    </h1>
    2727   
  • channel-solution-for-twitch/trunk/includes/admin/views/html-admin-settings.php

    r1856051 r2024613  
    1111    <h1>
    1212        <?php _e( 'TwitchPress Settings', 'twitchpress' ); ?>
    13         <?php if( get_option( 'twitchress_sandbox_mode_switch' ) == 'yes' ) { _e( ' - Sandbox Mode Active', 'twitchpress' ); }?>
     13        <?php if( get_option( 'twitchpress_sandbox_mode_switch' ) == 'yes' ) { _e( ' - Sandbox Mode Active', 'twitchpress' ); }?>
    1414    </h1>
    1515    <form method="<?php echo esc_attr( apply_filters( 'twitchpress_settings_form_method_tab_' . $current_tab, 'post' ) ); ?>" id="mainform" action="" enctype="multipart/form-data">
  • channel-solution-for-twitch/trunk/includes/class.twitchpress-curl.php

    r1966127 r2024613  
    1111 * @category Class
    1212 * @author   Ryan Bayne
     13 *
     14 * See class.twitchpress-extend-wp-http-curl.php for an alternative class that might replace this.
    1315 */
    1416
     
    4345    * @var mixed
    4446    */
    45     public $type = 'get';
     47    public $type = 'unset';
    4648   
    4749    /**
     
    132134    * @var array
    133135    */
    134     private $curl_request_body = array();
     136    public $curl_request_body = array();
    135137
    136138    /**
     
    171173    public $response_message = null;
    172174   
    173     public $originating_file = null;
    174    
    175     public $originating_function = null;
    176 
    177     public $originating_line = null;
     175    public $originating_file = 'Unknown';
     176   
     177    public $originating_function = 'Unknown';
     178
     179    public $originating_line = 'Unknown';
    178180   
    179181    public $refresh_token = null;
     
    182184        $this->curl_version = curl_version();
    183185        $this->current_user = get_current_user_id();
    184     }       
    185    
    186     /**
    187     * Optional function offering all parameters when making a WP_Http_Curl
    188     * call within the TwitchPress system. Use this to learn which values are available
    189     * and then pass the returned array to call_start() as the $optional_args value.
    190     *
    191     * Any arguments not made will initially be populated by this classes defaults
    192     * but later we might have options that over-ride in-line defaults.
    193     *
    194     * @uses WP_Http_Curl()
    195     * @uses curl_version()
    196     *
    197     * @since 2.5.0
    198     * @version 3.0
    199     */   
    200     public function call_params( $can_cache = null, $cache_time = null, $can_queue = null, $giving_user = null, $user_specific = null, $retry = null, $originating_function = null, $originating_line = null ) {
    201      
    202         if( $can_cache )
    203         {
    204             $this->can_cache = $can_cache;
    205         }
    206         else
    207         {
    208             // Apply the admin setting to override the classes default...
    209         }
    210                
    211         if( $cache_time )
    212         {
    213             $this->cache_time = $cache_time;
    214         }
    215         else
    216         {
    217             // Apply the admin setting to override the classes default...
    218         }
    219                
    220         if( $can_queue )
    221         {
    222             $this->can_queue = $can_queue;
    223         }
    224         else
    225         {
    226             // Apply the admin setting to override the classes default...
    227         }
    228                                
    229         if( $user_specific )
    230         {
    231             $this->user_specific = $user_specific;
    232         }
    233         else
    234         {
    235             // Apply the admin setting to override the classes default...
    236         }
    237                
    238         if( $retry )
    239         {
    240             $this->retry = $retry;   
    241         }
    242         else
    243         {
    244             // Apply the admin setting to override the classes default...
    245         }
    246        
    247         // Values that will not have settings...
    248         $this->giving_user = $giving_user;
    249         $this->originating_function = $originating_function;
    250         $this->originating_line = $originating_line;           
    251     }
    252                    
     186       
     187        // Load and configure a BugNet object...
     188        $this->bugnet = new BugNet();
     189    }   
     190         
    253191    /**
    254192    * Required method when making a WP_Http_Curl call.
     
    271209        // Create the WordPress Http Curl object
    272210        $this->WP_Http_Curl_Object = new WP_Http_Curl();
    273        
     211                                 
    274212        // Optional arguments submitted will over-ride $this default...
    275213        $this->arguments( $optional_args );   
     
    290228        }
    291229       
     230        // Handle WP_Error returned by WP_Http_Curl_Object()
     231        if( is_wp_error( $this->curl_reply ) ) {
     232            return false;   
     233        }
     234
    292235        // Check, set and react to the response code...
    293236        $this->check_response_code();
     
    296239        $this->decode_body();         
    297240    }
    298    
     241       
     242    /**
     243    * Optional function offering all parameters when making a WP_Http_Curl
     244    * call within the TwitchPress system. Use this to learn which values are available
     245    * and then pass the returned array to call_start() as the $optional_args value.
     246    *
     247    * Any arguments not made will initially be populated by this classes defaults
     248    * but later we might have options that over-ride in-line defaults.
     249    *
     250    * @uses WP_Http_Curl()
     251    * @uses curl_version()
     252    *
     253    * @since 2.5.0
     254    * @version 3.0
     255    */   
     256    public function call_params( $can_cache = null, $cache_time = null, $can_queue = null, $giving_user = null, $user_specific = null, $retry = null, $originating_function = null, $originating_line = null ) {
     257
     258        if( $can_cache )
     259        {
     260            $this->can_cache = $can_cache;
     261        }
     262        else
     263        {
     264            // Apply the admin setting to override the classes default...
     265        }
     266               
     267        if( $cache_time )
     268        {
     269            $this->cache_time = $cache_time;
     270        }
     271        else
     272        {
     273            // Apply the admin setting to override the classes default...
     274        }
     275               
     276        if( $can_queue )
     277        {
     278            $this->can_queue = $can_queue;
     279        }
     280        else
     281        {
     282            // Apply the admin setting to override the classes default...
     283        }
     284                               
     285        if( $user_specific )
     286        {
     287            $this->user_specific = $user_specific;
     288        }
     289        else
     290        {
     291            // Apply the admin setting to override the classes default...
     292        }
     293               
     294        if( $retry )
     295        {
     296            $this->retry = $retry;   
     297        }
     298        else
     299        {
     300            // Apply the admin setting to override the classes default...
     301        }
     302       
     303        // Values that will not have settings...
     304        $this->giving_user = $giving_user;
     305        $this->originating_function = $originating_function;
     306        $this->originating_line = $originating_line;           
     307    }
     308                       
    299309    /**
    300310    * Prepare final request values - always use this after the developer has been giving
     
    318328                'user_specific'    => $this->user_specific,
    319329                'retry'            => $this->retry,
     330                'file'             => $this->originating_line,
    320331                'function'         => $this->originating_function,
    321332                'line'             => $this->originating_line,
     
    323334        );
    324335
    325         // Prepare arguments...
     336        // Build the final request...
    326337        $this->curl_request = array(
    327             'headers'    => array(),
     338            'headers'    => $this->headers,
    328339            'method'     => strtoupper( $this->type ),
    329340            'body'       => $this->curl_request_body,
     
    333344            'decompress' => false
    334345        );     
    335        
    336         // Add custom headers...
    337         if( $this->headers && is_array( $this->headers ) )
    338         {
    339             $this->curl_request['headers'] = array_merge( $this->curl_request['headers'], $this->headers );   
    340         }
    341      
    342     }
    343    
    344     /**
    345     * Decide if the call can/should be made to Twitch.tv at this time or queue.
    346     *
    347     * @version 1.0
    348     */
    349     public function queue() {
    350         if( !$this->can_queue ) { $this->call_execute(); } 
    351        
    352         // We will check for a recent request and result that matches
    353         $this->get_transient();
    354     }
    355    
     346    }
     347   
     348    public function add_headers( $new_headers = array() )  {
     349        if( !$this->headers || !is_array( $this->headers ) ) {
     350            $this->headers = array();     
     351        }
     352       
     353        $this->headers = array_merge( $new_headers, $this->headers );       
     354    }
     355   
    356356    /**                       
    357357    * Check if there is a transient cache of the exact same call!
     
    382382        }   
    383383    }
     384       
     385    /**
     386    * Decide if the call can/should be made to Twitch.tv at this time or queue.
     387    *
     388    * @version 1.0
     389    */
     390    public function queue() {
     391        if( !$this->can_queue ) { $this->call_execute(); } 
     392       
     393        // We will check for a recent request and result that matches
     394        $this->get_transient();
     395    }
    384396   
    385397    public function call_execute() {
    386 
     398           
    387399        $this->curl_reply = $this->WP_Http_Curl_Object->request( $this->endpoint, $this->curl_request );       
    388            
     400       
    389401        // Should this curl request be cached?
    390402        if( $this->can_cache )
     
    402414
    403415    public function check_response_code() {
     416       
    404417        if( isset( $this->curl_reply['response']['code'] ) ) {
    405418            $this->response_code = $this->curl_reply['response']['code'];
     
    419432    } 
    420433   
     434    public function get_curl_request() {
     435        return $this->curl_request;
     436    }
     437   
     438    public function get_curl_request_body() {
     439        return $this->curl_request_body;
     440    }
     441   
    421442    public function user_output() {
    422443       
  • channel-solution-for-twitch/trunk/includes/class.twitchpress-listener-main-account-oauth.php

    r1977739 r2024613  
    2121
    2222if( !class_exists( 'TWITCHPRESS_Listener_Main_Twitchtv_Account_oAuth' ) ) :
    23              
    24 class TWITCHPRESS_Listener_Main_Twitchtv_Account_oAuth {
     23
     24class TWITCHPRESS_Listener_Main_Twitchtv_Account_oAuth_Kraken {
    2525    public $rejection_reason = 'No incoming request detected.';
    2626    public $scope = null;
     
    3636       
    3737        // Is the request a return from Twitch?
    38         if( !$this->detect() )
    39         {
     38        if( !$this->detect() ){
    4039            return;
    4140        } 
     
    4847
    4948        // Did we get an access token and refresh token?
    50         if( !$this->access_token || !$this->refresh_token )
    51         { 
     49        if( !$this->access_token || !$this->refresh_token ){ 
    5250            return;
    5351        }
     
    5856        // Make a test call and confirm channel details.
    5957        $this->channel();
    60 
     58       
    6159        unset( $this->api_calls );
    6260
     
    162160            $this->rejection_reason = __( 'Main Account Listener: Code is invalid.', 'twitchpress' );
    163161        }
    164 
     162                         
    165163        if( $return === true ) {
    166164            return false;
    167165        }
    168        
     166
    169167        $this->redirect_to = $transient_state['redirectto'];
    170168        $this->code = sanitize_key( $_GET['code'] );
     
    183181        $token_array = $this->api_calls->request_user_access_token( $this->code, __FUNCTION__ );
    184182        unset( $twitch_api_calls );   
    185        
     183
    186184        if( !$token_array )
    187         {
     185        {   
    188186            $this->rejection_reason = __( 'Twitch.tv rejected a request for a user token.', 'twitchpress' );
    189187            return false;
     
    215213        twitchpress_update_main_channels_refresh_token( $this->refresh_token );
    216214        twitchpress_update_main_channels_scopes( $this->returned_scope );                                   
    217        
    218         // Store main channel scopes as the app scopes which is simply a way of
    219         // managing the applicable scopes when making requests...
    220         twitchpress_update_app_token_scopes( $this->returned_scope );
    221215       
    222216        TwitchPress_Admin_Notices::add_custom_notice( 'mainkrakenapplicationsetup', __( 'Twitch.tv provided a token to allow this site to access your channel based on the permissions (scopes) you selected.')  );   
     
    260254    }
    261255}
    262            // changed from plugins_loaded 18th november 2018
    263 add_action( 'init', array( new TWITCHPRESS_Listener_Main_Twitchtv_Account_oAuth(), 'listen' ), 50 );
     256
     257class TWITCHPRESS_Listener_Main_Twitchtv_Account_oAuth_Helix {
     258    public $rejection_reason = 'No incoming request detected.';
     259    public $scope = null;
     260    public $state = null;
     261    public $code = null;
     262    public $wp_user_id = null;
     263    public $access_token = null;
     264    public $refresh_token = null;
     265    public $returned_scope = null;
     266    public $redirect_to = null;
     267   
     268    function listen() {
     269       
     270        // Is the request a return from Twitch?
     271        if( !$this->detect() )
     272        {
     273            return;
     274        } 
     275               
     276        // We will need to make a call to Twitch.
     277        $this->api_calls = new TwitchPress_Twitch_API();
     278               
     279        // detect() establishes what we need to request a token. 
     280        $this->token();   
     281
     282        // Did we get a refresh token?
     283        if( !$this->refresh_token )
     284        {         
     285            return;
     286        }         
     287                 
     288        // Did we get an access token?
     289        if( !$this->access_token )
     290        {       
     291            return;
     292        }
     293         
     294        // Store all credentials now in this class object.
     295        $this->store();
     296
     297        // Make a test call and confirm channel details.
     298        $this->channel();
     299
     300        // Storage went well, redirect the user to a suitable page.
     301        $this->redirect();
     302        exit;
     303    }
     304   
     305    function detect() {
     306                     
     307        if ( $_SERVER['REQUEST_METHOD'] !== 'GET' ) {   
     308            return false;
     309        }             
     310   
     311        if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {   
     312            return false;
     313        }
     314         
     315        if( defined( 'DOING_CRON' ) && DOING_CRON ) { 
     316            return false;   
     317        }       
     318         
     319        if( defined( 'DOING_AJAX' ) && DOING_AJAX ) {     
     320            return false;   
     321        }
     322       
     323        // This listener is for requests started on administration side only. 
     324        if( !is_user_logged_in() ) {         
     325            return false;
     326        }     
     327       
     328        $this->wp_user_id = get_current_user_id(); 
     329       
     330        // This is not a listener for processing WordPress logins.
     331        // This $_GET is set by TwitchPress_Login_Extension.
     332        if( isset( $_GET['twitchpress_sentto_login'] ) ) {   
     333            return false;
     334        }
     335               
     336        // Create a notice for an error.
     337        if( isset( $_GET['error'] ) ) {     
     338            return false;
     339        }
     340         
     341        if( !isset( $_GET['scope'] ) ) {   
     342            return false;
     343        }
     344       
     345        $this->scope = sanitize_text_field( $_GET['scope'] );     
     346           
     347        if( !isset( $_GET['state'] ) || !is_string( $_GET['state'] ) ) {       
     348            return false;
     349        }   
     350       
     351        $this->state = sanitize_key( $_GET['state'] );
     352       
     353        // Change to true when $_REQUEST cannot be validated.
     354        $return = false;
     355         
     356        if( !isset( $_GET['code'] ) ) {       
     357            $return = true;
     358            $this->rejection_reason = __( 'Main Account Listener: No code returned.', 'twitchpress' );
     359        }
     360
     361        // We require the local state value stored in transient.
     362        elseif( !$transient_state = get_transient( 'twitchpress_oauth_' . $this->state ) ) {       
     363            $return = true;     
     364            $this->rejection_reason = __( 'Main Account Listener: No matching transient.', 'twitchpress' );
     365        } 
     366       
     367        // Ensure the reason for this request is an attempt to set the main channels credentials
     368        elseif( !isset( $transient_state['reason'] ) ) {
     369            $return = true;     
     370            $this->rejection_reason = __( 'Main Account Listener: Reason not provided for this request.', 'twitchpress' );           
     371        }             
     372         
     373        // Ensure we have the admin view or page the user needs to be sent to.
     374        elseif( $transient_state['reason'] !== 'mainchannelsetup' ) {         
     375            $return = true;     
     376            $this->rejection_reason = __( 'Main Account Listener: Request reason rejected for this procedure.', 'twitchpress' );   
     377        }
     378                 
     379        // Ensure we have the admin view or page the user needs to be sent to.
     380        elseif( !isset( $transient_state['redirectto'] ) ) {         
     381            $return = true;     
     382            $this->rejection_reason = __( 'Main Account Listener: The redirectto value does not exist.', 'twitchpress' );   
     383        }
     384         
     385        // For this procedure the userrole MUST be administrator.
     386        elseif( !isset( $transient_state['userrole'] ) ) {       
     387            $return = true;     
     388            $this->rejection_reason = __( 'Main Account Listener: this request is not an expected operation related to the main account.', 'twitchpress' );   
     389        }         
     390       
     391        elseif( !isset( $transient_state['userrole'] ) || 'administrator' !== $transient_state['userrole'] ) {       
     392            $return = true;   
     393            $this->rejection_reason = __( 'Main Account Listener: User is not an administrator.', 'twitchpress' );   
     394        }         
     395               
     396        // NEW IF - Validate the code as a measure to prevent URL spamming that gets further than here.
     397        elseif( !twitchpress_validate_code( $_GET['code'] ) ) {       
     398            $return = true;     
     399            $this->rejection_reason = __( 'Main Account Listener: Code is invalid.', 'twitchpress' );
     400        }
     401
     402        if( $return === true ) {   
     403            return false;
     404        }
     405       
     406        // No reason to reject the request...
     407        $this->rejection_reason = __( 'Not rejected', 'twitchpress' );
     408                               
     409        $this->redirect_to = $transient_state['redirectto'];
     410        $this->code = sanitize_key( $_GET['code'] );
     411                       
     412        // This is a genuine Twitch.tv response!
     413        return true;
     414    }
     415   
     416    /**
     417    * Request a token.
     418    *
     419    * @version 1.0
     420    */
     421    function token() {       
     422        // Request oAuth token for the current user and the main channel.
     423        $token_array = $this->api_calls->request_user_access_token( $this->code, __FUNCTION__ );
     424               
     425        if( !$token_array )
     426        {
     427            $this->rejection_reason = __( 'Twitch.tv rejected a request for a user token.', 'twitchpress' );
     428            return false;
     429        }     
     430       
     431        $this->access_token = $token_array->access_token;
     432        $this->refresh_token = $token_array->refresh_token;
     433        $this->returned_scope = $token_array->scope;
     434    }
     435   
     436    /**
     437    * Store credentials.
     438    *
     439    * @version 1.0
     440    */
     441    function store() {
     442           
     443        // Update current user although this is a main channel procedure.
     444        // This is to enforce the user as the owner of the logged in Twitch account and the main channel.
     445        twitchpress_update_user_code( $this->wp_user_id, $this->code );       
     446        twitchpress_update_user_token( $this->wp_user_id, $this->access_token );
     447        twitchpress_update_user_token_refresh( $this->wp_user_id, $this->refresh_token );       
     448
     449        // Start storing main channel credentials. 
     450        update_option( 'twitchpress_main_code', $this->code );// old value, being phased out.
     451        twitchpress_update_main_channels_code( $this->code );
     452        twitchpress_update_main_channels_wpowner_id( $this->wp_user_id );
     453        twitchpress_update_main_channels_token( $this->access_token );
     454        twitchpress_update_main_channels_refresh_token( $this->refresh_token );
     455        twitchpress_update_main_channels_scopes( $this->returned_scope );                                   
     456       
     457        // Store main channel scopes as the app scopes which is simply a way of
     458        // managing the applicable scopes when making requests...
     459        twitchpress_update_app_token_scopes( $this->returned_scope );
     460       
     461        TwitchPress_Admin_Notices::add_custom_notice( 'mainkrakenapplicationsetup', __( 'Twitch.tv provided a token to allow this site to access your channel based on the permissions (scopes) you selected.')  );   
     462    }
     463   
     464    /**
     465    * Make a test call by getting the current users Twitch channel and take
     466    * the opportunity to get any data we do not yet have.
     467    *
     468    * @version 2.0
     469    */
     470    function channel() {
     471        // Confirm the giving main (default) channel is valid.
     472        $user_objects = $this->api_calls->get_users( twitchpress_get_main_channels_name() );
     473       
     474        twitchpress_var_dump( $user_objects );
     475        wp_die();
     476       
     477        if( !isset( $user_objects['users'][0]['_id'] ) ) {
     478            TwitchPress_Admin_Notices::add_custom_notice( 'listenerchanneldoesnotexist', __( '<strong>Channel Was Not Confirmed:</strong> TwitchPress wants to avoid errors in future by ensuring what you typed is correct. So far it could not confirm your entered channel is correct. Please check the spelling of your channel and the status of Twitch. If your entered channel name is correct and Twitch is online, please report this message.', 'twitchpress' ) );     
     479            return;                         
     480        }
     481
     482        twitchpress_update_main_channels_id( $user_objects['users'][0]['_id'] );
     483       
     484        // Assume the channel is owned by the current logged in admin or they just want it paired with the current WP account.
     485        // Store all possible details in user meta.
     486        twitchpress_update_user_oauth(
     487            $this->wp_user_id,
     488            $this->code,
     489            $this->access_token,
     490            $user_objects['users'][0]['_id']
     491        );       
     492    }
     493   
     494    /**
     495    * Forward user to the custom destinaton i.e. where they were before oAuth2.
     496    *
     497    * @version 1.0
     498    */
     499    function redirect() {
     500        twitchpress_redirect_tracking( $this->redirect_to, __LINE__, __FUNCTION__ );
     501        exit;       
     502    }
     503}
     504     
     505if( TWITCHPRESS_API_NAME == 'kraken' )
     506{   
     507    add_action( 'init', array( new TWITCHPRESS_Listener_Main_Twitchtv_Account_oAuth_Kraken(), 'listen' ), 50 );
     508}
     509else
     510{
     511    add_action( 'init', array( new TWITCHPRESS_Listener_Main_Twitchtv_Account_oAuth_Helix(), 'listen' ), 50 );   
     512}
    264513
    265514endif;
  • channel-solution-for-twitch/trunk/includes/class.twitchpress-listener.php

    r1710928 r2024613  
    117117            );
    118118        } 
    119     }     
    120    
    121     /**
    122     * Handles request from Developer Toolbar to sync the main channels
    123     * feed into WP.
    124     *
    125     * @version 1.0
    126     */
    127     private static function developertoolbar_sync_main_channel_feed_to_wp() {
    128 
    129         // Security is done already but we need safeguards should the method be called elsewhere.
    130         if( !user_can( TWITCHPRESS_CURRENTUSERID, 'activate_plugins' ) ) { 
    131             return;   
    132         }
    133 
    134         $verify_nonce = wp_verify_nonce( $_REQUEST['_wpnonce'], 'twitchpresssyncmainfeedtowp' );
    135                
    136         if ( $verify_nonce ) {
    137  
    138             $result = twitchpress_sync_feed_to_wp();
    139          
    140             $total = 0;
    141             if( is_array( $result ) ) {       
    142                 $total = count( $result );
    143             }
    144                                        
    145             TwitchPress_Admin_Notices::add_wordpress_notice(
    146                 'devtoolbarnotice-syncmainfeedtowp',
    147                 'success',
    148                 true,
    149                 __( 'Feed Posts Imported', 'twitchpress' ),
    150                 sprintf( __( 'TwitchPress imported %s channel feed entries.', 'twitchpress' ), $total )
    151             );
    152         }       
    153     }     
     119    }         
    154120}   
    155121
  • channel-solution-for-twitch/trunk/includes/class.twitchpress-post-types.php

    r1941995 r2024613  
    2626        add_filter( 'rest_api_allowed_post_types', array( __CLASS__, 'rest_api_allowed_post_types' ) );
    2727        add_action( 'twitchpress_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) );
    28         //add_action( 'add_meta_boxes', array( __CLASS__, 'add_custom_boxes' ) );
     28        add_action( 'add_meta_boxes', array( __CLASS__, 'add_custom_boxes' ) );
    2929        add_action( 'save_post', array( __CLASS__, 'save_twitchpress_post_sharing_options' ) ); 
    3030        add_action( 'post_submitbox_misc_actions', array( __CLASS__, 'post_submitbox' ) );
     
    4040        }
    4141
    42         if ( taxonomy_exists( 'twitchfeed_type' ) ) {
    43             return;
     42        if ( !taxonomy_exists( 'twitchfeed_type' ) ) {
     43            self::register_taxonomy_feed();
    4444        }
    4545
    4646        do_action( 'twitchpress_register_taxonomy' );
    4747
     48    }
     49   
     50    public static function register_taxonomy_feed() {
    4851        $permalinks = twitchpress_get_permalink_structure();
    4952       
     
    131134        );
    132135
    133         do_action( 'twitchpress_after_register_taxonomy' );
     136        do_action( 'twitchpress_after_register_taxonomy' );       
    134137    }
    135138
     
    371374}
    372375
    373 TwitchPress_Post_types::init();
     376//TwitchPress_Post_types::init();
  • channel-solution-for-twitch/trunk/includes/class.twitchpress-set-app.php

    r1977739 r2024613  
    33 * TwitchPress - Twitch API application credentials are set here ONLY!
    44 *
    5  * In theory this class will be initiated once during any request. So the goal
    6  * is to establish a working set of application credentials for use during that
    7  * request. 
     5 * Class is initiated and added to the object registry for use by any plugin within
     6 * any request. In theory this class will be initiated once during any page request
     7 * but we can use it to check on app status.
    88 *
    99 * @author   Ryan Bayne
     
    2626    public $app_redirect = null;
    2727    public $app_token = null;
     28   
     29    /**
     30    * Scopes to be accepted by visitors for this application. Scopes are not
     31    * required by the application itself.
     32    *
     33    * @var mixed
     34    */
    2835    public $app_scopes = null;
     36    public $app_ready = true;
    2937
    3038    public function __construct() {
     
    4149        $this->app_expiry       = get_option( 'twitchpress_app_expiry', 0 );
    4250
    43         // Handle a missing token post setup completion...
     51        // Consider a first time plugin activation scenario...
     52        if( !$this->app_id && $this->app_secret && $this->app_redirect && $this->app_token && $this->app_scopes && $this->app_expiry ) {
     53            return $this->bugnet->log( __FUNCTION__, __( 'Twitch application has not been setup yet!', 'twitchpress' ), array(), true, false );
     54        }
     55       
    4456        if( !$this->app_token && $this->app_id && $this->app_secret && $this->app_redirect )
    4557        {
     
    4860        else
    4961        {
    50             // Ensure token is still valid else request new one...ijk
     62            // Ensure token is still valid else request new one...
    5163            add_action( 'init', array( $this, 'validate_token' ), 5 );
    5264        }
     65    }
     66   
     67    public function status( $code = false ) {                           
     68
     69        if( !$this->app_id && !$this->app_secret && !$this->app_redirect && !$this->app_token && !$this->app_scopes && !$this->app_expiry )
     70        {
     71            if( $code ){ return 0; }
     72            return array( 0, __( 'Twitch application credentials have not been setup. Please complete the Setup Wizard.', 'twitchpress' ) );       
     73        }
     74       
     75        if( !$this->app_id )
     76        {
     77            if( $code ){ return 2; }
     78            return array( 2, __( 'Twitch application ID has not been stored. Correct this by completing the Setup Wizard.', 'twitchpress' ) );
     79        }
     80       
     81        if( !$this->app_secret )
     82        {
     83            if( $code ) { return 3; }
     84            return array( 3, __( 'Twitch application secret has not been stored. You can fix this by completing the Setup Wizard or in Settings.', 'twitchpress' ) );           
     85        }       
     86       
     87        if( !$this->app_redirect )
     88        {
     89            if( $code ) { return 4; }
     90            return array( 4, __( 'Twitch application needs a redirect value. You can resolve this in Settings under the Twitch API tab.', 'twitchpress' ) );
     91           
     92        }
     93       
     94        if( !$this->app_scopes )
     95        {
     96            if( $code ) { return 5; }
     97            return array( 5, __( 'No scope/permissions have been stored for the Twitch application. You can add those in the Setup Wizard and Settings.', 'twitchpress' ) );
     98           
     99        }
     100
     101        if( !$this->app_token )
     102        {
     103            if( $code ) { return 6; }
     104            return array( 6, __( 'No token was found for the Twitch API application. This should be generated automatically and is an issue that needs immediate attention.', 'twitchpress' ) );
     105        }
     106       
     107        // Returning 1 is suitable for a positive result (true)...
     108        if( $code ){ return 1; }
     109        return array( 1, __( 'Twitch API application is ready!', 'twitchpress' ) );
    53110    }
    54111   
     
    66123    }
    67124
    68     /**
    69     * Use application credentials to request an access_token which has
    70     * gone missing from WP options table.
    71     *
    72     * This method assumes that all other applications credentials exist.
    73     *
    74     * @version 1.0
    75     */
    76125    public function missing_token() {
    77126
    78127        // Create our own special Curl object which uses WP_Http_Curl()
    79128        $call_object = new TwitchPress_Curl();
     129        $call_object->originating_file = __FILE__;
    80130        $call_object->originating_function = __FUNCTION__;
    81131        $call_object->originating_line = __LINE__;
    82132        $call_object->type = 'POST';
    83         $call_object->endpoint = 'https://api.twitch.tv/kraken/oauth2/token?client_id=' . twitchpress_get_app_id();
    84 
     133       
     134        if( TWITCHPRESS_API_NAME == 'kraken' )
     135        {
     136            $call_object->endpoint = 'https://api.twitch.tv/kraken/oauth2/token?client_id=' . twitchpress_get_app_id();
     137        }
     138        else
     139        {
     140            $call_object->endpoint = 'https://id.twitch.tv/oauth2/token';   
     141        }
     142       
    85143        // Set none API related parameters i.e. cache and rate controls...
    86144        $call_object->call_params( 
     
    90148            null,
    91149            false,
    92             false
     150            false,
     151            __FUNCTION__,
     152            __LINE__
    93153        );
    94154       
     
    119179        twitchpress_update_app_token_expiry( $call_object->curl_reply_body->expires_in );
    120180
    121         $this->bugnet->log( __FUNCTION__, __( 'Replacement access_token and expiry stored.', 'twitchpress' ), array(), true, false );           
    122     }
    123    
    124     /**
    125     * Validates the current application access_token and if not valid
    126     * will request a new one.
    127     *
    128     * @version 1.0
    129     */
     181        // Update this objects app_token value...
     182        $this->app_token = $call_object->curl_reply_body->access_token;
     183       
     184        $this->bugnet->log( __FUNCTION__, __( 'Replacement access_token and expiry was stored.', 'twitchpress' ), array(), true, false );           
     185    }
     186
    130187    public function validate_token() {
     188       
     189        // Lets be sure we actually have a token...
     190        if( !$this->app_token ) {
     191            return $this->bugnet->log( __FUNCTION__, __( 'Token validation could not be performed because the app access token was not set and may not exist!', 'twitchpress' ), array(), true, false );   
     192        }
    131193       
    132194        // Create our own special Curl object which uses WP_Http_Curl()
    133195        $call_object = new TwitchPress_Curl();
     196        $call_object->originating_file = __FILE__;
    134197        $call_object->originating_function = __FUNCTION__;
    135198        $call_object->originating_line = __LINE__;
    136199        $call_object->type = 'GET';
    137         $call_object->endpoint = 'https://id.twitch.tv/oauth2/validate';
    138                
     200       
     201        if( TWITCHPRESS_API_NAME == 'kraken' )
     202        {
     203            $call_object->endpoint = 'https://id.twitch.tv/oauth2/validate';
     204        }
     205        else
     206        {
     207            $call_object->endpoint = 'https://id.twitch.tv/oauth2/validate';   
     208        }
     209           
    139210        // Set none API related parameters i.e. cache and rate controls...
    140211        $call_object->call_params(
     
    144215            null,
    145216            false,
    146             false
     217            false,
     218            __FUNCTION__,
     219            __LINE__
    147220        );
    148 
    149         // Add the access_token as an OAuth header...
    150         $call_object->headers = array(
    151             'Authorization' => 'OAuth ' . $this->app_token,
    152             'Accept'        => 'application/vnd.twitchtv.v5+json'
    153         );
    154 
     221       
     222        if( TWITCHPRESS_API_NAME == 'kraken' )
     223        {
     224            // Add the access_token as an OAuth header...
     225            $call_object->headers = array(
     226                'Authorization' => 'OAuth ' . $this->app_token,
     227                'Accept'        => 'application/vnd.twitchtv.v5+json'
     228            );
     229        }
     230        else
     231        {                           
     232            // Add the access_token as an OAuth header...
     233            $call_object->headers = array(
     234                'Authorization' => 'OAuth ' . $this->app_token,
     235                //'Accept'        => 'application/vnd.twitchtv.v5+json'
     236            );   
     237        }
     238       
    155239        // Start + make the request to Twitch.tv API in one line...
    156240        $call_object->do_call( 'twitch' );
     
    171255        // Request a new access_token (stored as app_token in the TwitchPress system)...
    172256        $this->new_token();
    173        
    174     }
    175    
    176     /**
    177     * Request a new access_token - usually on the expiry of a previous because
    178     * the first token is generated during the Setup Wizard.
    179     *
    180     * @version 1.0
    181     */
     257    }
     258   
    182259    public function new_token() {
    183260 
    184261        // Create our own special Curl object which uses WP_Http_Curl()
    185262        $call_object = new TwitchPress_Curl();
     263        $call_object->originating_function = __FILE__;
    186264        $call_object->originating_function = __FUNCTION__;
    187265        $call_object->originating_line = __LINE__;
    188266        $call_object->type = 'POST';
    189         $call_object->endpoint = 'https://api.twitch.tv/kraken/oauth2/token?client_id=' . twitchpress_get_app_id();
    190        
     267       
     268        if( TWITCHPRESS_API_NAME == 'kraken' )
     269        {
     270            $call_object->endpoint = 'https://api.twitch.tv/kraken/oauth2/token?client_id=' . twitchpress_get_app_id();
     271        }
     272        else
     273        {
     274            $call_object->endpoint = 'https://id.twitch.tv/oauth2/token';   
     275        }
     276
    191277        // Set none API related parameters i.e. cache and rate controls...
    192278        $call_object->call_params(
     
    196282            null,
    197283            false,
    198             false
     284            false,
     285            __FUNCTION__,
     286            __LINE__
    199287        );
    200288       
     
    224312        twitchpress_update_app_token_expiry( $call_object->curl_reply_body->expires_in );
    225313
    226         $this->bugnet->log( __FUNCTION__, __( 'New access_token and expiry time stored.', 'twitchpress' ), array(), true, false );               
     314        return $this->bugnet->log( __FUNCTION__, __( 'New access_token and expiry time stored.', 'twitchpress' ), array(), true, false );               
    227315    }
    228316}
  • channel-solution-for-twitch/trunk/includes/class.twitchpress-sync.php

    r1971902 r2024613  
    139139        }
    140140       
    141         $id = twitchpress_get_main_channel_id();// Right now everything defaults to the main channel.
     141        $id = twitchpress_get_main_channels_twitchid();// Right now everything defaults to the main channel.
    142142
    143143        $earliest_time = $option['last_time'] + $option['delay'];
     
    705705    * @returns true if a change is made and false if no change to sub status has been made.
    706706    *
    707     * @version 2.2
     707    * @version 2.5
    708708    */
    709709    private function main_channel_sub_sync( $user_id, $output_notice = false ) {
     
    732732
    733733        // Get possible existing sub plan from an earlier sub sync...
    734         $local_sub_plan = get_user_meta( $user_id, 'twitchpress_sub_plan_' . twitchpress_get_main_channel_id(), true  );
     734        $local_sub_plan = get_user_meta( $user_id, 'twitchpress_sub_plan_' . $channel_id, true  );
    735735       
    736736        // If Twitch user is a subscriber to channel do_action() early here, maybe a simple thank you notice.
     
    11591159            echo __( 'Ready', 'twitchpress-sync' );
    11601160            return;
    1161            
    1162             /*   TODO: If scopes allow it, make a call and test the token and code.
    1163             // Make a call using users token and code, confirming validity.                 
    1164             $kraken = new TWITCHPRESS_Twitch_API_Calls();
    1165             $sub_call_result = $kraken->chat_generateToken( $token, $code );
    1166             if( !$sub_call_result )
    1167             {
    1168                 echo __( 'New Token Required - Please logout then login using Twitch', 'twitchpress-sync' );
    1169                 return;
    1170             }
    1171             */
    11721161        }
    11731162
  • channel-solution-for-twitch/trunk/includes/functions.twitchpress-frontend-notices.php

    r1966127 r2024613  
    3535* @version 1.0
    3636*/
    37 function twitchpress_display_frontend_notices_the_content( string $post_content ) { 
     37function twitchpress_display_frontend_notices_the_content( $post_content ) { 
    3838    global $GLOBALS;
    3939                                                   
  • channel-solution-for-twitch/trunk/includes/functions.twitchpress-shortcodes.php

    r1966127 r2024613  
    1616}
    1717
     18function twitchpress_videos_shortcode( $atts ) {             
     19    $html_output = '';
     20   
     21    $atts = shortcode_atts( array(             
     22        'id'       => null,
     23        'user_id'  => null,
     24        'game_id'  => null,
     25        'after'    => null,
     26        'before'   => null,
     27        'first'    => null,
     28        'language' => null,
     29        'period'   => null,
     30        'sort'     => null,
     31        'type'     => null,
     32        'links'    => false
     33    ), $atts, 'twitchpress_video' );   
     34     
     35    $transient_code = $atts['id'] . $atts['user_id'] . $atts['game_id'];
     36   
     37    if( $cache = get_transient( 'twitchpress_video' . $transient_code ) ) {
     38       // return $cache;
     39    }
     40   
     41    // Get the stream.
     42    $helix = new TWITCHPRESS_Twitch_API();
     43   
     44    $result = $helix->get_videos( $atts['id'], $atts['user_id'], $atts['game_id'] );
     45   
     46    if( $result )
     47    {
     48        if( $atts['links'] )
     49        {
     50            $html_output .= '<ol>';
     51            foreach( $result->data as $key => $item )
     52            {                         
     53                $html_output .= '<li>';
     54                $html_output .= '<a href="' . $item->url . '">' . $item->title . '</a>';         
     55                $html_output .= '</li>';       
     56            }
     57            $html_output .= '</ol>';
     58        }
     59        else
     60        {
     61            $html_output .= '<ol>';
     62            foreach( $result->data as $key => $item )
     63            {                         
     64                $html_output .= '<li>';
     65 
     66                $html_output .= '
     67                <iframe
     68                    src="https://player.twitch.tv/?video=' . $item->id . '&autoplay=false"
     69                    height="720"
     70                    width="1280"
     71                    frameborder="0"
     72                    scrolling="no"
     73                    allowfullscreen="true">
     74                </iframe>';   
     75                                     
     76                $html_output .= '</li>';       
     77            }
     78            $html_output .= '</ol>';                 
     79        }
     80    }
     81
     82    set_transient( 'twitchpress_videos' . $transient_code, $html_output, 86400 );
     83   
     84    return $html_output;
     85}                                       
     86add_shortcode( 'twitchpress_videos', 'twitchpress_videos_shortcode' );
     87   
     88function twitchpress_get_top_games_list_shortcode( $atts ) {             
     89    $html_output = '';
     90   
     91    $atts = shortcode_atts( array(             
     92        'total'   => 10,
     93    ), $atts, 'twitchpress_get_top_games_list' );
     94   
     95    if( $cache = get_transient( 'twitchpress_get_top_games_list' . $atts['total'] ) ) {
     96        return $cache;
     97    }                 
     98    // Get the stream.
     99    $helix = new TWITCHPRESS_Twitch_API();
     100   
     101    $result = $helix->get_top_games( null, null, $atts['total'] );
     102   
     103    if( $result && isset( $result->data[0] ) )
     104    {
     105        $html_output .= '<ol>';
     106        foreach( $result->data as $key => $game )
     107        {                         
     108            $html_output .= '<li>';
     109            $html_output .= $game->name;       
     110            $html_output .= '</li>';       
     111        }
     112        $html_output .= '</ol>';
     113    }
     114
     115    set_transient( 'twitchpress_get_top_games_list' . $atts['total'], $html_output, 86400 );
     116   
     117    return $html_output;
     118}                                       
     119add_shortcode( 'twitchpress_get_top_games_list', 'twitchpress_get_top_games_list_shortcode' );
     120
    18121/**
    19122* Shortcode outputs a basic status for the giving channel.
     
    23126* @version 1.1
    24127*/
    25 function twitchpress_channel_status_shortcode( $atts ) {         
     128function twitchpress_channel_status_line_shortcode( $atts ) {
     129    if( TWITCHPRESS_API_NAME == 'kraken' )
     130    {
     131        return twitchpress_channel_status_line_kraken( $atts );   
     132    }
     133    else
     134    {
     135        return twitchpress_channel_status_line_helix( $atts );   
     136    }
     137}
     138function twitchpress_channel_status_line_kraken( $atts ) {         
    26139    $html_output = null;
    27140           
     
    38151
    39152    // Check cache.
    40     if( $cache = get_transient( 'twitchpress_shortcode_channel_status' ) )
     153    if( $cache = get_transient( 'twitchpress_shortcode_channel_status_line' ) )
    41154    {
    42155        return $cache;
    43156    }
    44    
    45     if( TWITCHPRESS_API_NAME == 'kraken' )
    46     {
    47         $twitchpress = new TWITCHPRESS_Twitch_API_Calls();
    48     }
    49     else
    50     {   # untested
    51         $helix = new TWITCHPRESS_Twitch_API();
    52     }
     157
     158    $twitchpress = new TWITCHPRESS_Twitch_API_Calls();
    53159
    54160    // Get channel ID using the channel/username.
     
    84190    }
    85191   
    86     set_transient( 'twitchpress_shortcode_channel_status', $html_output, 120 );
     192    set_transient( 'twitchpress_shortcode_channel_status_line', $html_output, 120 );
    87193   
    88194    return $html_output;
    89195}
    90 add_shortcode( 'twitchpress_channel_status', 'twitchpress_channel_status_shortcode' );
     196function twitchpress_channel_status_line_helix( $atts ) { 
     197   
     198    $atts = shortcode_atts( array(             
     199            'channel_id'   => null,
     200            'channel_name' => null,
     201    ), $atts, 'twitchpress_channel_status' );
     202   
     203    // If no channel ID or name is giving...
     204    if( !$atts['channel_id'] && !$atts['channel_name'] ) {
     205        return __( 'Channel status-line shortcode has not been setup!', 'twitchpress' );     
     206    }
     207   
     208    // Establish an ID if we only have a channel name... 
     209    if( !$atts['channel_id'] && $atts['channel_name'] ) {             
     210        $helix = new TWITCHPRESS_Twitch_API();
     211        $result = $helix->get_user_by_login_name_without_email_address( $atts['channel_name'] );
     212        if( isset( $result->data[0]->id ) ) {
     213            $channel_id = $result->data[0]->id;
     214        } else {
     215            $channel_id = null;
     216            $html_output = sprintf( __( 'Failed to retrieve channel ID %s', 'twitchpress' ), esc_html( $atts['channel_name'] ) );
     217        }                   
     218    }
     219   
     220    // Use cached HTML if we have a channel ID...
     221    if( $channel_id ) {
     222        $cache = get_transient( 'twitchpress_channel_status_line_' . $channel_id );
     223        if( $cache ) {
     224            return $cache;
     225        }
     226    }                 
     227
     228    // Get the stream.
     229    if( !$helix ){ $helix = new TWITCHPRESS_Twitch_API(); }
     230         
     231    $result = $helix->get_stream_by_userid( $channel_id );     
     232
     233    if( !$result || $result->type !== 'live' )
     234    {
     235        $html_output = '<p>' . __( 'Channel Offline', 'twitchpress' ) . '</p>';   
     236    }
     237    else
     238    {                                 
     239        $html_output = '<p>' . __( 'Channel Live', 'twitchpress' ) . '</p>'; 
     240    }
     241   
     242    set_transient( 'twitchpress_channel_status_line' . $channel_id, $html_output, 120 );
     243   
     244    return $html_output;
     245}
     246add_shortcode( 'twitchpress_channel_status_line', 'twitchpress_channel_status_line_shortcode' );
     247
    91248
    92249/**
    93250* Shortcode outputs a status line for the giving channel.
    94251*
    95 * @version 1.0
     252* @version 2.0
    96253*/
    97 function twitchpress_channel_status_line_shortcode( $atts ) {         
     254function twitchpress_channel_status_shortcode( $atts ) {   
     255    if( TWITCHPRESS_API_NAME == 'kraken' )
     256    {
     257        return twitchpress_channel_status_shortcode_kraken( $atts );   
     258    }
     259    else
     260    {
     261        return twitchpress_channel_status_shortcode_helix( $atts );   
     262    }
     263}
     264function twitchpress_channel_status_shortcode_kraken( $atts ) {
     265         
    98266    $atts = shortcode_atts( array(             
    99267            'channel_id'   => null,
     
    113281    }
    114282   
    115     if( TWITCHPRESS_API_NAME == 'kraken' )
    116     {
    117         $twitchpress = new TWITCHPRESS_Twitch_API_Calls();
    118     }
    119     else
    120     {   # untested
    121         $helix = new TWITCHPRESS_Twitch_API();
    122     }
    123    
     283    $twitchpress = new TWITCHPRESS_Twitch_API_Calls();
     284
    124285    // Get channel ID using the channel/username.
    125286    if( $atts['channel_id'] === null && $atts['channel_name'] !== null )
     
    162323    return $html_output;
    163324}
    164 add_shortcode( 'twitchpress_channel_status_line', 'twitchpress_channel_status_line_shortcode' );
     325function twitchpress_channel_status_shortcode_helix( $atts ) {       
     326    $atts = shortcode_atts( array(             
     327            'channel_id'   => null,
     328            'channel_name' => null,
     329    ), $atts, 'twitchpress_channel_status' );
     330   
     331    // If no channel ID or name is giving...
     332    if( !$atts['channel_id'] && !$atts['channel_name'] ) {
     333        return __( 'Channel status shortcode has not been setup!', 'twitchpress' );     
     334    }
     335   
     336    // Establish an ID if we only have a channel name... 
     337    if( !$atts['channel_id'] && $atts['channel_name'] ) {             
     338        $helix = new TWITCHPRESS_Twitch_API();
     339        $result = $helix->get_user_by_login_name_without_email_address( $atts['channel_name'] );
     340        if( isset( $result->data[0]->id ) ) {
     341            $channel_id = $result->data[0]->id;
     342        } else {
     343            $channel_id = null;
     344            $html_output = sprintf( __( 'Failed to retrieve channel ID %s', 'twitchpress' ), esc_html( $atts['channel_name'] ) );
     345        }                   
     346    }
     347   
     348    // Use cached HTML if we have a channel ID...
     349    if( $channel_id ) {
     350        $cache = get_transient( 'twitchpress_channel_status_line_' . $channel_id );
     351        if( $cache ) {
     352            return $cache;
     353        }
     354    }                 
     355
     356    // Get the stream.
     357    if( !$helix ){ $helix = new TWITCHPRESS_Twitch_API(); }
     358         
     359    $result = $helix->get_stream_by_userid( $channel_id );     
     360
     361    if( !$result || $result->type !== 'live' )
     362    {         
     363        $html_output = '<p>' . __( 'Channel Offline', 'twitchpress' ) . '</p>';   
     364    }
     365    else
     366    {                               
     367        $html_output = '<p>';       
     368        $html_output .= ' ' . esc_html( $result->user_name ) . ' ';
     369        $html_output .= ' is live with ' . esc_html( $result->viewer_count ) . ' viewers ';
     370        $html_output .= '</p>';
     371    }
     372   
     373    set_transient( 'twitchpress_channel_status' . $channel_id, $html_output, 120 );
     374   
     375    return $html_output;
     376}
     377add_shortcode( 'twitchpress_channel_status', 'twitchpress_channel_status_shortcode' );
     378
    165379
    166380/**
    167381* Shortcode outputs a status box with some extra information for the giving channel.
    168382*
    169 * @version 1.0
     383* @version 2.0
    170384*/
    171 function twitchpress_channel_status_box_shortcode( $atts ) {       
     385function twitchpress_channel_status_box_shortcode( $atts ) {
     386    if( TWITCHPRESS_API_NAME == 'kraken' )
     387    {
     388        return twitchpress_channel_status_box_shortcode_kraken( $atts );   
     389    }
     390    else
     391    {
     392        return twitchpress_channel_status_box_shortcode_helix( $atts );   
     393    }   
     394}
     395function twitchpress_channel_status_box_shortcode_kraken( $atts ) {       
    172396    $atts = shortcode_atts( array(             
    173397            'channel_id'   => null,
     
    178402    if( $atts['channel_id'] === null && $atts['channel_name'] === null )
    179403    {
    180         return '';     
     404        return 'Shortcode has not been setup properly!';     
    181405    }   
    182406
     
    186410        return $cache;
    187411    }
    188    
    189     if( TWITCHPRESS_API_NAME == 'kraken' )
    190     {
    191         $twitchpress = new TWITCHPRESS_Twitch_API_Calls();
    192     }
    193     else
    194     {   # untested
    195         $helix = new TWITCHPRESS_Twitch_API();
    196     }
     412
     413    $twitchpress = new TWITCHPRESS_Twitch_API_Calls();
    197414   
    198415    // Get channel ID using the channel/username.
     
    232449        $html_output .= '<br />Followers: ' . $channel_object['channel']['followers'] . ' ';
    233450        $html_output .= '</div>';
    234        
    235         return $html_output;
    236     }
    237    
    238     set_transient( 'twitchpress_shortcode_channel_status_box', $html_output, 120 );
     451    }
     452   
     453    set_transient( 'twitchpress_channel_status_box', $html_output, 120 );
    239454   
    240455    return $html_output;   
    241456}
    242 add_shortcode( 'twitchpress_channel_status_box', 'twitchpress_channel_status_box_shortcode' );
    243 
     457function twitchpress_channel_status_box_shortcode_helix( $atts ) {       
     458    $atts = shortcode_atts( array(             
     459            'channel_id'   => null,
     460            'channel_name' => null,
     461    ), $atts, 'twitchpress_shortcode_channel_status_box' );
     462   
     463    // Establish channel ID
     464    if( $atts['channel_id'] === null && $atts['channel_name'] === null )
     465    {
     466        return 'Shortcode has not been setup properly!';     
     467    }   
     468    $helix = new TWITCHPRESS_Twitch_API();
     469
     470    // Establish an ID if we only have a channel name... 
     471    if( !$atts['channel_id'] && $atts['channel_name'] ) {             
     472        $helix = new TWITCHPRESS_Twitch_API();
     473        $result = $helix->get_user_without_email_by_login_name( $atts['channel_name'] );
     474        if( isset( $result->data[0]->id ) ) {
     475            $channel_id = $result->data[0]->id;
     476        } else {
     477            $channel_id = null;
     478            $html_output = sprintf( __( 'Failed to retrieve channel ID %s', 'twitchpress' ), esc_html( $atts['channel_name'] ) );
     479        }                   
     480    }
     481
     482    // Use cached HTML if we have a channel ID...
     483    if( $channel_id ) {
     484        $cache = get_transient( 'twitchpress_channel_status_box' . $channel_id );
     485        if( $cache ) {
     486            return $cache;
     487        }
     488    }                 
     489                               
     490    // Get the stream.
     491    if( !$helix ){ $helix = new TWITCHPRESS_Twitch_API(); }
     492         
     493    $result = $helix->get_stream_by_userid( $channel_id );     
     494                       
     495    if( !$result || $result->type !== 'live' )
     496    {
     497        $html_output = '<p>' . __( 'Channel Offline', 'twitchpress' ) . '</p>';   
     498    }
     499    else
     500    {                                                           
     501        $html_output = '<div>';
     502        $html_output .= 'Channel: ' . $result->user_name . ' ';
     503        $html_output .= '<br />Game: ' . $result->game_id . ' ';
     504        $html_output .= '<br />Viewers: ' . $result->viewer_count . ' ';
     505        $html_output .= '</div>';
     506    }
     507   
     508    set_transient( 'twitchpress_channel_status_box' . $channel_id, $html_output, 120 );
     509   
     510    return $html_output;   
     511}
     512add_shortcode( 'twitchpress_shortcode_channel_status_box', 'twitchpress_channel_status_box_shortcode' );
     513       
     514                                       
    244515/**
    245516* Shortcode outputs an unordered list of channels with status.
  • channel-solution-for-twitch/trunk/includes/libraries/bugnet/class.bugnet.php

    r1966127 r2024613  
    6767        require_once( plugin_basename( '/handlers/class.bugnet-handler-email.php' ) );
    6868        require_once( plugin_basename( '/handlers/class.bugnet-handler-logfiles.php' ) );
    69         require_once( plugin_basename( '/handlers/class.bugnet-handler-restapi.php' ) );
     69        require_once( plugin_basename( '/handlers/class.bugnet-handler-api.php' ) );
    7070        require_once( plugin_basename( '/handlers/class.bugnet-handler-wpdb.php' ) );
    7171        require_once( plugin_basename( '/handlers/class.bugnet-handler-tracing.php' ) );
     
    8181        $this->handler_emails                  = new BugNet_Handler_Email();
    8282        $this->handler_logfiles                = new BugNet_Handler_LogFiles();
    83         $this->handler_restapi                 = new BugNet_Handler_RESTAPI();
     83        $this->handler_restapi                 = new BugNet_Handler_API();
    8484        $this->handler_wpdb                    = new BugNet_Handler_WPDB();
    8585        $this->handler_tracing                 = new BugNet_Handler_Tracing();
     
    9494 
    9595    /**
    96      * React to an event that is usually unexpected and important. This is
    97      * like a more serious log and it does use the log() method itself.
    98      *
    99      * Place this method where you suspect something is going wrong or where
    100      * fault occurence would be a high priority.
     96     * React to an event that is usually unexpected and important.
     97     * Often a serious event that takes priority over day to day log entries. 
    10198     *
    10299     * The entire library becomes available to the log entry i.e.
    103      * - It could be writtent ot the end of a daily log file.
     100     * - It could be writtent to the end of a daily log file.
    104101     * - It could be displayed in an administrator only notice.
    105102     * - It could be displayed in a public wp_die() page.
     
    288285    * methods.
    289286    *
    290     * @param string $tag
    291     * @param string $line please use __LINE__
    292     * @param string $function please use __FUNCTION__
    293     * @param boolean $end true will trigger output then delete trace.
    294     * @param string $note optional note to help identify the step.
     287    * @param mixed $tag
     288    * @param mixed $line
     289    * @param mixed $function
     290    * @param mixed $file
     291    * @param mixed $end
     292    * @param mixed $message
    295293    * @param mixed $atts
    296     *
    297     * @version 1.0
     294    * @param mixed $error
     295    *
     296    * @version 2.0
    298297    */
    299298    public function trace( $tag, $line, $function, $file, $end, $message, $atts = array(), $error = false ) {
     
    313312                'tag'           => $tag,
    314313                'time'          => time(),
    315                 'eventid'       => wp_rand( 111111, 999999 ), // Seperates instances of the same trace.
     314                'eventid'       => TWITCHPRESS_REQUEST_KEY, // Seperates instances of the same trace.
    316315                'automaticonly' => false, // true forces trace to require a controlled ending.
    317316                'maintracefile' => false, // Log to the main trace text file.
     
    323322        $args = wp_parse_args( $atts, $default_args );
    324323       
    325         // Build a data array to make it easier to access later.
     324        // Build an array of common values to make it easier to access later...
    326325        $info = array( 'line'     => $line,
    327326                       'function' => $function,
  • channel-solution-for-twitch/trunk/includes/libraries/bugnet/handlers/class.bugnet-handler-tracing.php

    r1856051 r2024613  
    2828    * @version 1.0
    2929    */
    30     public function do_trace( $tag, $args, $info, $transient_life_seconds = 86400 ) {
    31         // Add $tag to a transient that only stores trace tags.
    32         // We used this to get traces which are also stored in their own transients. 
     30    public function do_trace( $tag, $args, $info, $transient_life_seconds = 86400 ) {   
     31 
     32        // List of traces for managing individual trace transients $tag => time() a 
    3333        $this->update_trace_list( $tag, 'add' );
    34 
    35         // Get possible entries already made as part of a series.
     34       
     35        // Get current traces existing entries...
    3636        $trans = $this->get_trace_transient_temporary( $tag );
    37        
     37
    3838        // Delete existing transient in order to set it again.
    3939        if( !empty( $trans ) )
     
    8181   
    8282    public function delete_temporary_trace( $tag ) {
    83        
    8483        delete_transient( 'bugnet_' . $tag  );   
    8584       
     
    8988
    9089    /**
    91     * Called as late as possible to process all traces that do not have
    92     * a controlled ending i.e. there is no deliberate call to end a trace
    93     * and process it at the moment we want.
     90    * Hooked by "shutdown" in class.bugnet.php
    9491    *
    9592    * By default all traces that do not have the "automaticonly" value
     
    9895    * @version 1.0
    9996    */
    100     public function automatically_process_traces() {
     97    public function automatically_process_traces() {   
     98       
     99        // Avoid every creation of this object running this...
     100        if( defined( 'BUGNET_AUTO_PROCESS_TRACES_DONE' ) ) { return; }
     101        else { define( 'BUGNET_AUTO_PROCESS_TRACES_DONE', true ); }
     102         
    101103        $traces = $this->get_trace_list();
    102 
     104       
    103105        if( !is_array( $traces ) ){ return; }
    104106         
     
    106108
    107109            $trace_transient = $this->get_trace_transient_temporary( $tag );
    108  
     110                    
    109111            $this->end_trace( $tag );
    110112        }   
     
    112114   
    113115    /**
     116    * Called by manual tool and uninstallation procedure.
     117    *
    114118    * Deletes the two main caches and an infinite number of temporary
    115119    * individual caches.
     
    118122    */
    119123    public function delete_all_trace_cache_data() {
    120        
    121124        // Remove individual traces first.
    122125        $traces = $this->get_trace_list();
     
    141144    * @param mixed $args
    142145    * @param mixed $data
     146    *
     147    * @version 2.0
    143148    */
    144149    public function end_trace( $tag, $automatic = true ) {
     
    151156        if( isset( $trace_array['automaticonly'] ) && true == $trace_array['automaticonly'] ){ return; }
    152157       
     158        if( !$this->does_trace_dir_exist() ) {
     159            $result = $this->create_trace_files_directory();
     160            if( !$result ) { return false; }
     161        }
     162           
    153163        // Insert data to permament records, start with main trace file.
    154164        if( true === $trace_array['traceargs']['maintracefile'] )
     
    160170        if( true === $trace_array['traceargs']['newtracefile'] )
    161171        {
    162             // TODO: write trace to a new file stored in traces folder.   
     172            $this->create_individual_trace_file( $tag, $trace_array );
    163173        }
    164174       
     
    185195    public function update_trace_list( $tag, $task = 'add' ) {
    186196        $trans = get_transient( 'bugnet_trace_list' );
    187        
     197                     
    188198        // If requested to remove a trace entry but none exist at all.
    189         if( $task == 'remove' && !$trans )
    190         {
     199        if( $task == 'remove' && !$trans ) {   
    191200            return false;
    192201        }
    193        
     202                   
    194203        // If the transient has not been initialized yet.
    195204        if( !is_array( $trans ) ) {
    196205            $trans = array();
    197206        }
    198        
    199         delete_transient( 'bugnet_trace_list' );
    200        
    201         if( $task == 'add' && !isset( $trans[ $tag ] ) ) {
    202 
     207                 
     208        if( $task == 'add' && !isset( $trans[ $tag ] ) )
     209        {       
    203210            // Tag is a string for sure.
    204211            $trans[ $tag ] = time();
     
    208215        }
    209216        elseif( $task == 'remove' && isset( $trans[ $tag ] ) )
    210         {
     217        {   
    211218            unset( $trans[ $tag ] );
    212219            $this->set_trace_list_transient( $trans );   
     
    219226    * @version 1.0
    220227    */
    221     public function set_trace_list_transient( $value ) {
    222         set_transient( 'bugnet_trace_list', $value, 86400 );
    223     }
    224 
     228    public function set_trace_list_transient( $new_transient_value ) { 
     229        delete_transient( 'bugnet_trace_list' );
     230        set_transient( 'bugnet_trace_list', $new_transient_value, 86400 );
     231    }
     232
     233    /**
     234    * Create and write an entire trace to a file for the current server request.
     235    *
     236    * @version 1.0
     237    */
     238    public function create_individual_trace_file( $tag, $trace_array ) {
     239        // Run clean-up on folder number...
     240        $this->individual_trace_file_folder_cleanup();
     241
     242        // Confirm file-per-trace directory exists...
     243        if( !$this->does_file_per_trace_directory_exist() ) {
     244            $result = $this->create_file_per_trace_directory();
     245            if( !$result ) { return false; }
     246        }
     247       
     248        // Does our planned file name already exist...
     249        if( file_exists( $this->get_file_per_trace_directory() . TWITCHPRESS_REQUEST_KEY ) ) {
     250            return false;
     251        }
     252         
     253        // Open new trace file for a one time write...
     254        $pointer = fopen( $this->get_file_per_trace_directory() . TWITCHPRESS_REQUEST_KEY, 'w' );           
     255        if( !$pointer ){ return false; }
     256                   
     257        $csv_array = $this->build_trace_file_rows_array( $trace_array );
     258
     259        foreach( $csv_array as $key => $entry_array ) {
     260            fputcsv( $pointer, $entry_array );
     261        }
     262       
     263        @fclose( $pointer );
     264
     265        // Delete the transient for this trace...
     266        $this->update_trace_list( $tag, 'remove' );
     267       
     268        return false;
     269    }
     270   
     271    /**
     272    * Automatic safeguard to prevent too many daily folders existing. An entire
     273    * month will be allowed and there will be a limit of 10 trace files per
     274    * folder by default.
     275    *
     276    * @version 1.0
     277    */
     278    public function individual_trace_file_folder_cleanup() {
     279        // Count number of folders...
     280       
     281        // Delete the oldest folders if there are 30...
     282    }
     283   
    225284    /**
    226285    * Processes a request to update the main trace file with the
     
    231290    * @returns boolean false if nothing written else true
    232291    *
    233     * @version 1.0
     292    * @version 2.0
    234293    */
    235294    public function update_main_tracefile( $trace_array ) {
    236295        // Confirm directory and main trace file exists, else create them.
    237296        if( !$this->does_main_trace_file_exist() ) {
    238             if( !$this->does_trace_dir_exist() ) {
    239                 $result = $this->create_trace_files_directory();
    240                 if( !$result ) { return false; }
    241             }
    242297            $result = $this->create_main_trace_file();
    243298            if( !$result ){ return false; }   
     
    317372    */
    318373    public function get_traces_directory() {
    319         return WP_CONTENT_DIR . '/bugnet/traces/';   
     374        return TWITCHPRESS_LOG_DIR . 'traces/';   
    320375    } 
    321376     
     
    333388    public function does_main_trace_file_exist() {
    334389        return file_exists( $this->get_main_trace_file_path() );           
     390    }
     391
     392    public function get_file_per_trace_directory() {
     393        return $this->get_traces_directory() . 'file_per_trace/';   
     394    }
     395   
     396    public function does_file_per_trace_directory_exist() { 
     397        return file_exists( $this->get_file_per_trace_directory() );
     398    }
     399   
     400    public function create_file_per_trace_directory() {
     401        return mkdir( $this->get_file_per_trace_directory(), 0777, true );
    335402    }
    336403   
     
    383450    */
    384451    public function does_daily_trace_file_exist() {
    385         return file_exists( WP_CONTENT_DIR . "/bugnet/traces/daily/" . $this->todays_filename() );
     452        return file_exists( WP_CONTENT_DIR . "/traces/daily/" . $this->todays_filename() );
    386453    }
    387454   
  • channel-solution-for-twitch/trunk/includes/libraries/bugnet/readme.txt

    r1856051 r2024613  
    1 ======== BugNet for WordPress ========
     1======== About BugNet for WordPress ========
    22
    33Version: 0.1.1
  • channel-solution-for-twitch/trunk/includes/libraries/twitch/kraken/class.twitch-api-calls.php

    r1974437 r2024613  
    101101     * @version 5.8
    102102     */
    103     public function getUserObject_Authd( string $token, string $code ){
     103    public function getUserObject_Authd( $token, $code ){
    104104       
    105105        // Ensure required scope is permitted else we return the WP_Error confirm_scope() generates.
     
    174174     * @version 1.2
    175175     */
    176     public function addBlockedUser( string $chan, string $username, string $token, string $code){
     176    public function addBlockedUser( $chan, $username, $token, $code){
    177177
    178178        // Ensure required scope is permitted else we return the WP_Error confirm_scope() generates.
     
    212212     * @version 1.5
    213213     */
    214     public function removeBlockedUser( string $chan, string $username, string $token, string $code){
     214    public function removeBlockedUser( $chan, $username, $token, $code){
    215215
    216216        // Ensure required scope is permitted else we return the WP_Error confirm_scope() generates.
     
    15451545        $return = array();
    15461546       
    1547         if( 'yes' == get_option( 'twitchress_sandbox_mode_generator_switch' ) )
     1547        if( 'yes' == get_option( 'twitchpress_sandbox_mode_generator_switch' ) )
    15481548        {
    15491549             /* Not doing anything here yet, but we could generate users based on real Twitch channels. */
     
    15791579
    15801580        // If false returns not on, we only return the affirmative response.
    1581         if( 'yes' !== get_option( 'twitchress_sandbox_mode_falsereturns_switch' ) )
     1581        if( 'yes' !== get_option( 'twitchpress_sandbox_mode_falsereturns_switch' ) )
    15821582        {
    15831583            return $return[0];
  • channel-solution-for-twitch/trunk/includes/libraries/twitch/kraken/class.twitch-api.php

    r1977739 r2024613  
    6161            'channel_commercial',
    6262            'channel_editor',
    63             'channel_feed_edit',
    64             'channel_feed_read',
    6563            'channel_read',
    6664            'channel_stream',
    6765            'channel_subscriptions',
    68             'chat_login',
    6966            'collections_edit',
    7067            'communities_edit',
     
    130127        $this->set_all_credentials();
    131128       
    132         if( get_option( 'twitchress_sandbox_mode_switch' ) == 'yes' ) {
     129        if( get_option( 'twitchpress_sandbox_mode_switch' ) == 'yes' ) {
    133130            $this->twitch_sandbox_mode = true;
    134131        }
     
    11201117            null,
    11211118            false,
    1122             false
     1119            false,
     1120            __FUNCTION__,
     1121            __LINE__
    11231122        );
    11241123       
     
    12131212            if( $requesting_function == null ) { $request_string = __( 'Requesting function is not known!', 'twitchpress' ); }
    12141213            else{ $request_string = __( 'Requesting function is ', 'twitchpress' ) . $requesting_function; }
    1215             $this->bugnet->log( __FUNCTION__, sprintf( __( 'No access token returned: %s()', 'twitchpress' ), $request_string ), array(), true, false );
     1214            $this->bugnet->log( __FUNCTION__, sprintf( __( 'No user access token returned: %s()', 'twitchpress' ), $request_string ), array(), true, false );
    12161215       
    12171216            return false;
  • channel-solution-for-twitch/trunk/loader.php

    r1977739 r2024613  
    2727     * @deprecated use constant TWITCHPRESS_VERSION
    2828     */
    29     public $version = '2.16.0';
     29    public $version = '2.16.3';
    3030
    3131    /**
     
    146146        if ( ! defined( 'TWITCHPRESS_UPLOADS_DIR' ) ) {       define( 'TWITCHPRESS_UPLOADS_DIR', $upload_dir['basedir'] . 'twitchpress-uploads/' ); }
    147147        if ( ! defined( 'TWITCHPRESS_LOG_DIR' ) ) {           define( 'TWITCHPRESS_LOG_DIR', TWITCHPRESS_PLUGIN_DIR_PATH . 'twitchpress-logs/' ); }
    148         if ( ! defined( 'TWITCHPRESS_SESSION_CACHE_GROUP')) { define( 'TWITCHPRESS_SESSION_CACHE_GROUP', 'twitchpress_session_id' ); }
    149148        if ( ! defined( 'TWITCHPRESS_DEV_MODE' ) ) {          define( 'TWITCHPRESS_DEV_MODE', false ); }
    150149        if ( ! defined( 'TWITCHPRESS_WORDPRESSORG_SLUG' ) ) { define( 'TWITCHPRESS_WORDPRESSORG_SLUG', false ); }
    151                            
     150        if ( ! defined( 'TWITCHPRESS_REQUEST_KEY' ) ) {       define( 'TWITCHPRESS_REQUEST_KEY', $_SERVER["REQUEST_TIME_FLOAT"] . TWITCHPRESS_CURRENTUSERID ); }
     151                   
    152152        // Support (project) constants.
    153153        if ( ! defined( 'TWITCHPRESS_HOME' ) ) {              define( 'TWITCHPRESS_HOME', 'https://wordpress.org/plugins/channel-solution-for-twitch' ); }
     
    216216        require_once( 'includes/libraries/twitch/' . TWITCHPRESS_API_NAME . '/functions.twitch-api-statuses.php' );
    217217       
    218         if( get_option( 'twitchress_sandbox_mode_switch' ) == 'yes' ) { 
     218        if( get_option( 'twitchpress_sandbox_mode_switch' ) == 'yes' ) { 
    219219            require_once( 'includes/libraries/twitch/' . TWITCHPRESS_API_NAME . '/class.twitch-api-sandbox.php' );
    220220        } else {
     
    222222        }
    223223       
    224         // Helix does not have separate classes...
    225224        if( TWITCHPRESS_API_NAME == 'kraken' ) {
    226225            require_once( 'includes/libraries/twitch/' . TWITCHPRESS_API_NAME . '/class.twitch-api-calls.php' );       
     
    235234        include_once( plugin_basename( 'requests.php' ) );
    236235        require_once( 'includes/class.twitchpress-listener-main-account-oauth.php' );
     236        require_once( 'includes/libraries/twitch/helix/class.twitch-webhooks.php' );
    237237       
    238238        // Load Core Objects
     
    295295        add_action( 'init', array( $this, 'output_errors' ), 2 );
    296296        add_action( 'init', array( $this, 'output_actions' ), 2 );           
    297         add_action( 'init', array( $this, 'output_filters' ), 2 );       
     297        add_action( 'init', array( $this, 'output_filters' ), 2 );   
     298       
     299        add_filter( 'views_edit-plugins', array( $this, 'views_edit_plugins' ), 1 );
     300
     301    }
     302       
     303    public function views_edit_plugins( $views ) {       
     304        $screen = get_current_screen();
    298305    }
    299306   
    300307    public function init_system() {
    301 
     308                   
    302309        // Before init action.
    303310        do_action( 'before_twitchpress_init' );   
     
    387394    }
    388395
    389     public static function show_errors() {
     396    public static function show_errors() {     
    390397        global $wpdb, $bugnet;
    391398        echo '<div id="bugnet-wperror-dump">';       
  • channel-solution-for-twitch/trunk/options.php

    r1977739 r2024613  
    2121     
    2222}
    23 
     23                                                 
    2424function twitchpress_options_misc() {
    2525    $arr = array();
    26 
     26                       
    2727    $arr[ 'twitchpress_admin_notices' ] = array();
     28    $arr[ 'twitchpress_admin_notice_missingvaluesofferwizard' ] = array();
    2829    $arr[ 'twitchpress_displayerrors' ] = array();
    2930    $arr[ 'twitchpress_db_version' ] = array();
     
    4445    $arr[ 'twitchpress_feedback_prompt' ] = array();
    4546    $arr[ 'twitchpress_displayerrors' ] = array();
    46     $arr[ 'twitchress_redirect_tracking_switch' ] = array();
     47    $arr[ 'twitchpress_redirect_tracking_switch' ] = array();
    4748    $arr[ 'twitchpress_new_channeltowp' ] = array();
    4849    $arr[ 'twitchpress_new_wptochannel' ] = array();
     
    8687
    8788    // Depreciated
    88     $arr[ 'twitchpress_main_client_secret' ] = array();// Depreciated - use twitchpress_app_secret
    89     $arr[ 'twitchpress_main_client_id' ] = array();// Depreciated use twitchpress_main_client_id
    90     $arr[ 'twitchpress_main_redirect_uri' ] = array();// Depreciated use twitchpress_app_redirect
    91     $arr[ 'twitchpress_main_channel_postid' ] = array();// Depreciated - Generated on behalf of the main user.
    92     $arr[ 'twitchpress_main_channel_name' ] = array();// Depreciated - Main channel name (this might be the title of channel and not lowercase, please confirm)
    93     $arr[ 'twitchpress_main_channel_id' ] = array();// Depreciated - Main channels Twitch ID (same as user ID)
    94     $arr[ 'twitchpress_main_code' ] = array();// Depreciated - Generated on behalf of the main user.
    95     $arr[ 'twitchpress_main_token' ] = array();// Depreciated - Generated on behalf of the main user.
     89    $arr[ 'twitchpress_main_client_secret' ] = array();// Deprecated - use twitchpress_app_secret
     90    $arr[ 'twitchpress_main_client_id' ] = array();// Deprecated use twitchpress_main_client_id
     91    $arr[ 'twitchpress_main_redirect_uri' ] = array();// Deprecated use twitchpress_app_redirect
     92    $arr[ 'twitchpress_main_channel_postid' ] = array();// Deprecated - Generated on behalf of the main user.
     93    $arr[ 'twitchpress_main_channel_name' ] = array();// Deprecated - Main channel name (this might be the title of channel and not lowercase, please confirm)
     94    $arr[ 'twitchpress_main_channel_id' ] = array();// Deprecated - Main channels Twitch ID (same as user ID)
     95    $arr[ 'twitchpress_main_code' ] = array();// Deprecated - Generated on behalf of the main user.
     96    $arr[ 'twitchpress_main_token' ] = array();// Deprecated - Generated on behalf of the main user.
    9697    $arr[ 'twitchpress_main_token_scopes' ] = array();// Depreciated - Generated on behalf of the main user.
    9798       
     
    192193    $arr[ 'twitchpress_scope_channel_commercial' ] = array();
    193194    $arr[ 'twitchpress_scope_channel_editor' ] = array();
    194     $arr[ 'twitchpress_scope_channel_feed_edit' ] = array();
    195     $arr[ 'twitchpress_scope_channel_feed_read' ] = array();
    196195    $arr[ 'twitchpress_scope_channel_read' ] = array();
    197196    $arr[ 'twitchpress_scope_channel_stream' ] = array();
    198197    $arr[ 'twitchpress_scope_channel_subscriptions' ] = array();
    199     $arr[ 'twitchpress_scope_chat_login' ] = array();
    200198    $arr[ 'twitchpress_scope_collections_edit' ] = array();
    201199    $arr[ 'twitchpress_scope_communities_edit' ] = array();
     
    220218    $arr[ 'twitchpress_visitor_scope_channel_commercial' ] = array();
    221219    $arr[ 'twitchpress_visitor_scope_channel_editor' ] = array();
    222     $arr[ 'twitchpress_visitor_scope_channel_feed_edit' ] = array();
    223     $arr[ 'twitchpress_visitor_scope_channel_feed_read' ] = array();
    224220    $arr[ 'twitchpress_visitor_scope_channel_read' ] = array();
    225221    $arr[ 'twitchpress_visitor_scope_channel_stream' ] = array();
    226222    $arr[ 'twitchpress_visitor_scope_channel_subscriptions' ] = array();
    227     $arr[ 'twitchpress_visitor_scope_chat_login' ] = array();
    228223    $arr[ 'twitchpress_visitor_scope_collections_edit' ] = array();
    229224    $arr[ 'twitchpress_visitor_scope_communities_edit' ] = array();
  • channel-solution-for-twitch/trunk/readme.txt

    r1977763 r2024613  
    77Requires at least: 4.9
    88Tested up to: 4.9
    9 Stable tag: 2.16.0
     9Stable tag: 2.17.0
    1010Requires PHP: 5.6
    1111                       
     
    1414== Description ==
    1515
    16 TwitchPress is an adaptable solution for the creation of a Twitch service that can do anything Twitch.tv allows.
    17 Marry your WordPress gaming site with your Twitch channel in everyway possible using the plugins extension system
    18 or create a site that offersr channel management services to the public.
    19 
    20 = Core Features =
    21 The initial purpose of the free plugin is to share WP posts on Twitch channel feeds and collect feed updates
    22 from Twitch.tv for publishing as new WordPress posts. All updates to the core will focus on improving this feature
    23 and the plugins extension system. Using the extension system we can make TwitchPress and WP do anything possible
    24 with the Twitch API.
     16TwitchPress is an adaptable solution for the creation of a Twitch powered
     17WordPress site that offers the gaming community fresh content.
     18This solution for Twitch can easily be made to do anything Twitch.tv allows through the API.
     19The overall design has sponsored streamers in-mind. Something that will show more
     20throughout 2019.
    2521
    2622= Links =                                                               
     
    3632= Features List =
    3733 
     34* Various shortcodes
    3835* Extension system
    3936* Custom post for each channel/user
     
    4643= Features In Extensions =
    4744
     45* More shortcodes
    4846* Sign-In Via Twitch
    4947* Registration Via Twitch
     
    7775== Upgrade Notice ==
    7876
    79 There are no special instructions for this upgrade. 
     77If your Twitch.tv app is old or you have login issues please create new application
     78credentials. Then update TwitchPress by completing the Setup Wizard. 
    8079
    8180== Changelog ==
     81
     82= 2.17.0: =
     83* Bugfixes
     84    - Deprecated function twitchpress_get_main_channel_id() replaced with twitchpress_get_main_channels_twitchid()
     85    - function twitchpress_display_frontend_notices_the_content() string instance removed
     86    - Options are now removed when the plugin is deleted
     87* Feature Changes
     88    - This version does not support the Twitch feed post type or taxonomies
     89    - Made it clearer to users that the "chat_login" scope is deprecated   
     90    - New custom post type "webhooks" as part of an admin controlled system for managing Twitch subscribed updates
     91* Technical Changes
     92    - New webhook system started
     93    - Removed function get_channel_subscriptions_sandbox() as there is now a separate sandbox file and class
     94    - Shortcode for channel status line now has a Helix version: twitchpress_channel_status_line_shortcode_helix()
     95    - Updated helix function get_streams()
     96    - Removed channel_feed_read scope as the feed service is no longer available
     97    - Removed channel_feed_edit scope as the feed service is no longer available
     98    - chat_login scope will no longer be available for old apps so apps must be re-created
     99    - Corrected option name from twitchpress_sandbox_mode_switch to twitchpress_sandbox_mode_switch
     100    - Installation tab of the Help area no longer peforms API calls to determine status
     101    - Corrected spelling of twitchress_redirect_tracking_switch to twitchpress_redirect_tracking_switch
     102    - New class for extending WP_Http_Curl() within the TwitchPress system for any API
     103    - File name change (spelling): depreciated.php to deprecated.php
     104    - Unused constant removed: TWITCHPRESS_SESSION_CACHE_GROUP
     105    - New constant TWITCHPRESS_REQUEST_KEY which holds the current float time and logged in user ID is appended
     106    - BugNet change - the "eventid" value in trace() is now set using TWITCHPRESS_REQUEST_KEY and not wp_rand()
     107* Configuration
     108    - No changes
     109* Database
     110    - No changes
     111   
    82112= 2.16.0: 19th November 2018 =
    83113* Bugfixes
  • channel-solution-for-twitch/trunk/twitchpress.php

    r1977739 r2024613  
    55 * Github URI: https://github.com/RyanBayne/TwitchPress
    66 * Description: Add Twitch stream and channel management services to WordPress.
    7  * Version: 2.16.0
     7 * Version: 2.17.0
    88 * Author: Ryan Bayne
    99 * Author URI: https://ryanbayne.wordpress.com/
    1010 * Requires at least: 4.9
    11  * Tested up to: 4.9
     11 * Tested up to: 5.0
    1212 * License: GPL3
    1313 * License URI: http://www.gnu.org/licenses/gpl-3.0.txt
    1414 * Domain Path: /i18n/languages/
    15  *
    16  * @package TwitchPress
    17  * @category Core
    18  * @author Ryan Bayne (Gaming Handle: ZypheREvolved)
    19  * @license GNU General Public License, Version 3
    20  * @copyright 2016-2018 Ryan R. Bayne ([email protected])
    2115 */
    2216 
    2317// Exit if accessed directly.
    2418if ( ! defined( 'ABSPATH' ) ) { exit; }
    25                  
     19                                                            
    2620if ( ! class_exists( 'WordPressTwitchPress' ) ) :
    2721
    28 if ( ! defined( 'TWITCHPRESS_VERSION' ) ) { define( 'TWITCHPRESS_VERSION', '2.16.0' ); }
     22if ( ! defined( 'TWITCHPRESS_VERSION' ) ) { define( 'TWITCHPRESS_VERSION', '2.17.0' ); }
    2923
    3024if ( ! defined( 'TWITCHPRESS_ABSPATH' ) ) { define( 'TWITCHPRESS_ABSPATH', __FILE__ ); }
     
    4034include_once( TWITCHPRESS_PLUGIN_DIR_PATH . 'install.php' );
    4135include_once( TWITCHPRESS_PLUGIN_DIR_PATH . 'functions.php' );
    42 include_once( TWITCHPRESS_PLUGIN_DIR_PATH . 'depreciated.php' );
     36include_once( TWITCHPRESS_PLUGIN_DIR_PATH . 'deprecated.php' );
    4337include_once( TWITCHPRESS_PLUGIN_DIR_PATH . 'integration.php' );
    4438include_once( TWITCHPRESS_PLUGIN_DIR_PATH . 'extensions.php' );
  • channel-solution-for-twitch/trunk/uninstall.php

    r1967050 r2024613  
    1111 * @version     2.0
    1212 */
    13  
     13
    1414// Ensure plugin uninstall is being run by WordPress.
    1515if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
    16     exit;
     16    wp_die( __( 'Uninstallation file incorrectly requested for the TwitchPress plugin.', 'twitchpress' ) );
    1717}
     18                                                             
     19if( 'yes' == get_option( 'twitchpress_remove_database_tables' ) ) { twitchpress_remove_database_tables(); }
     20if( 'yes' == get_option( 'twitchpress_remove_extensions' ) ) { twitchpress_remove_extensions(); }
     21if( 'yes' == get_option( 'twitchpress_remove_user_data' ) ) { twitchpress_remove_user_data(); }
     22if( 'yes' == get_option( 'twitchpress_remove_media' ) ) { twitchpress_remove_media(); }
     23if( 'yes' == get_option( 'twitchpress_remove_roles' ) ) { twitchpress_remove_roles(); }
     24
     25// The plan is to offer different levels of uninstallation to make testing and re-configuration easier...
     26//if( 'yes' == get_option( 'twitchpress_remove_options' ) ) { twitchpress_remove_options_surgically(); }
     27if( 'yes' == get_option( 'twitchpress_remove_options' ) ) { twitchpress_remove_options(); }
    1828
    1929/**
    20 * Uninstall all of the plugins options without any care. Meant as a developer tool and
    21 * a part of 100% uninstallation.
     30* Uninstall all of the plugins options with care!
    2231*
    2332* @version 2.0
    2433*/
    25 function twitchpress_remove_options() {
    26     // Include the array of known options (extensions might create some we do not know about yet)
    27     include_once( 'options.php' );
    28    
    29     // Some options need to be removed last.
    30     $remove_last = array(
    31         'twitchpress_remove_options',
    32         'twitchpress_remove_feed_posts',
    33         'twitchpress_remove_database_tables',
    34         'twitchpress_remove_extensions',
    35         'twitchpress_remove_user_data',
    36         'twitchpress_remove_media'
    37     );
    38    
    39     foreach( twitchpress_options_array() as $option_group_key => $option_group_array ) {
    40         foreach( $option_group_array as $option_key => $option_array ) {
    41             if( !in_array( $option_key, $remove_last ) ) {
    42                 delete_option( $option_key );
    43             }
    44         }
    45     }
    46    
    47 }   
    48 
    49 /**
    50 * Uninstall options related to the uninstall procedure itself.
    51 *
    52 * @version 1.0
    53 */
    54 function twitchpress_remove_uninstallation_options() {
    55 
    56     // Now remove the uninstallation options.
    57     delete_option( 'twitchpress_remove_options' );
    58     delete_option( 'twitchpress_remove_feed_posts' );
     34function twitchpress_remove_options() {     
     35    delete_option( 'twitchpress_admin_notices' );
     36    delete_option( 'twitchpress_admin_notice_missingvaluesofferwizard' );
     37    delete_option( 'twitchpress_allapi_id_streamlabs' );
     38    delete_option( 'twitchpress_allapi_redirect_uri_streamlabs' );
     39    delete_option( 'twitchpress_allapi_secret_streamlabs' );
     40    delete_option( 'twitchpress_allapi_streamlabs_default_key' );
     41    delete_option( 'twitchpress_allapi_streamlabs_default_secret' );
     42    delete_option( 'twitchpress_allapi_streamlabs_default_uri' );
     43    delete_option( 'twitchpress_automatic_registration' );
     44    delete_option( 'twitchpress_bugnet_cache_action_hooks' );
     45    delete_option( 'twitchpress_display_actions' );
     46    delete_option( 'twitchpress_display_filters' );
     47    delete_option( 'twitchpress_login_button' );
     48    delete_option( 'twitchpress_login_button_text' );
     49    delete_option( 'twitchpress_login_loggedin_page_id' );
     50    delete_option( 'twitchpress_login_loginpage_position' );
     51    delete_option( 'twitchpress_login_loginpage_type' );
     52    delete_option( 'twitchpress_login_mainform_page_id' );
     53    delete_option( 'twitchpress_login_redirect_to_custom' );
     54    delete_option( 'twitchpress_login_requiretwitch' );
     55    delete_option( 'twitchpress_main_channels_refresh_token' );
     56    delete_option( 'twitchpress_registration_button' );
     57    delete_option( 'twitchpress_registration_requirevalidemail' );
     58    delete_option( 'twitchpress_registration_twitchonly' );
    5959    delete_option( 'twitchpress_remove_database_tables' );
    6060    delete_option( 'twitchpress_remove_extensions' );
     61    delete_option( 'twitchpress_remove_media' );
     62    delete_option( 'twitchpress_remove_options' );
     63    delete_option( 'twitchpress_remove_roles' );
    6164    delete_option( 'twitchpress_remove_user_data' );
    62     delete_option( 'twitchpress_remove_media' );
    63 
     65    delete_option( 'twitchpress_scope_analytics_read_extensions' );
     66    delete_option( 'twitchpress_scope_analytics_read_games' );
     67    delete_option( 'twitchpress_scope_bits_read' );
     68    delete_option( 'twitchpress_scope_channel_feed_edit' );
     69    delete_option( 'twitchpress_scope_channel_feed_read' );
     70    delete_option( 'twitchpress_scope_chat_edit' );
     71    delete_option( 'twitchpress_scope_chat_read' );
     72    delete_option( 'twitchpress_scope_clips_edit' );
     73    delete_option( 'twitchpress_scope_user_edit' );
     74    delete_option( 'twitchpress_scope_user_edit_broadcast' );
     75    delete_option( 'twitchpress_scope_user_read_broadcast' );
     76    delete_option( 'twitchpress_scope_user_read_email' );
     77    delete_option( 'twitchpress_sync_timing' );
     78    delete_option( 'twitchpress_twitchapi_call_count' );
     79    delete_option( 'twitchpress_twitchpress-embed-everything_settings' );
     80    delete_option( 'twitchpress_twitchpress-login-extension_settings' );
     81    delete_option( 'twitchpress_twitchpress-subscriber-management_settings' );
     82    delete_option( 'twitchpress_twitchpress-sync-extension_settings' );
     83    delete_option( 'twitchpress_twitchpress-um-extension_settings' );
     84    delete_option( 'twitchpress_visitor_scope_analytics_read_extensions' );
     85    delete_option( 'twitchpress_visitor_scope_analytics_read_games' );
     86    delete_option( 'twitchpress_visitor_scope_bits_read' );
     87    delete_option( 'twitchpress_visitor_scope_channel_check_subscription' );
     88    delete_option( 'twitchpress_visitor_scope_channel_commercial' );
     89    delete_option( 'twitchpress_visitor_scope_channel_editor' );
     90    delete_option( 'twitchpress_visitor_scope_channel_feed_edit' );
     91    delete_option( 'twitchpress_visitor_scope_channel_feed_read' );
     92    delete_option( 'twitchpress_visitor_scope_channel_read' );
     93    delete_option( 'twitchpress_visitor_scope_channel_stream' );
     94    delete_option( 'twitchpress_visitor_scope_channel_subscriptions' );
     95    delete_option( 'twitchpress_visitor_scope_chat_edit' );
     96    delete_option( 'twitchpress_visitor_scope_chat_read' );
     97    delete_option( 'twitchpress_visitor_scope_clips_edit' );
     98    delete_option( 'twitchpress_visitor_scope_collections_edit' );
     99    delete_option( 'twitchpress_visitor_scope_communities_edit' );
     100    delete_option( 'twitchpress_visitor_scope_communities_moderate' );
     101    delete_option( 'twitchpress_visitor_scope_openid' );
     102    delete_option( 'twitchpress_visitor_scope_user_blocks_edit' );
     103    delete_option( 'twitchpress_visitor_scope_user_blocks_read' );
     104    delete_option( 'twitchpress_visitor_scope_user_edit' );
     105    delete_option( 'twitchpress_visitor_scope_user_edit_broadcast' );
     106    delete_option( 'twitchpress_visitor_scope_user_follows_edit' );
     107    delete_option( 'twitchpress_visitor_scope_user_read' );
     108    delete_option( 'twitchpress_visitor_scope_user_read_broadcast' );
     109    delete_option( 'twitchpress_visitor_scope_user_read_email' );
     110    delete_option( 'twitchpress_visitor_scope_user_subscriptions' );
     111    delete_option( 'twitchpress_visitor_scope_viewing_activity_read' );
     112    delete_option( 'twitchress_sandbox_mode_falsereturns_switch' );
     113    delete_option( 'twitchress_sandbox_mode_generator_switch' );
     114    delete_option( 'twitchress_sandbox_mode_switch' );
    64115}   
    65 
    66 /**
    67 * Remove feed posts (the core plugins custom post type)
    68 *
    69 * @version 1.0
    70 */
    71 function twitchpress_remove_feed_posts() {}
    72116
    73117/**
     
    76120* @version 1.0
    77121*/
    78 function twitchpress_remove_database_tables() {}
     122function twitchpress_remove_database_tables() {/* no tables yet */}
    79123
    80124/**
     
    87131        foreach( $extensions_group_array as $extension_name => $extension_array ) {
    88132            deactivate_plugins( $extension_name, true );
    89             uninstall_plugin( $extension_name );
     133            uninstall_plugin( $extension_name );                                 
    90134        }
    91135    }     
     
    145189    remove_role( 'twitchpressdeveloper' );
    146190}
    147 
    148 if( 'yes' == get_option( 'twitchpress_remove_options' ) ) { twitchpress_remove_options(); }
    149 if( 'yes' == get_option( 'twitchpress_remove_feed_posts' ) ) { twitchpress_remove_feed_posts(); }
    150 if( 'yes' == get_option( 'twitchpress_remove_database_tables' ) ) { twitchpress_remove_database_tables(); }
    151 if( 'yes' == get_option( 'twitchpress_remove_extensions' ) ) { twitchpress_remove_extensions(); }
    152 if( 'yes' == get_option( 'twitchpress_remove_user_data' ) ) { twitchpress_remove_user_data(); }
    153 if( 'yes' == get_option( 'twitchpress_remove_media' ) ) { twitchpress_remove_media(); }
    154 if( 'yes' == get_option( 'twitchpress_remove_roles' ) ) { twitchpress_remove_roles(); }
    155 
    156 // Final action is removal of this group of options.
    157 if( 'yes' == get_option( 'twitchpress_remove_uninstallation_options' ) ) { twitchpress_remove_uninstallation_options(); }
Note: See TracChangeset for help on using the changeset viewer.