Plugin Directory

Changeset 2562159


Ignore:
Timestamp:
07/11/2021 08:39:38 AM (5 years ago)
Author:
Ryan Bayne
Message:

Example Pages Feature

Location:
twitchpress
Files:
422 added
1 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • twitchpress/trunk

    • Property svn:global-ignores set to
      twitchpress-logs
  • twitchpress/trunk/functions.php

    r2527323 r2562159  
    12041204    set_transient( 'twitchpress_oauth_' . $local_state['random14'], $local_state, 6000 );
    12051205
    1206     $scope = twitchpress_prepare_scopes( $permitted_scopes, true );
    1207          
     1206    // After installation $permitted_scopes can be empty, results in $scope being an array...
     1207    $scope = '';
     1208    if( $permitted_scopes ) {
     1209        $scope = twitchpress_prepare_scopes( $permitted_scopes, true );
     1210    }
     1211
    12081212    // Build Twitch.tv oauth2 URL...
    12091213    $url = 'https://id.twitch.tv/oauth2/authorize?' .
     
    18791883* @param mixed $for_url
    18801884*
    1881 * @version 1.5
     1885* @version 2.0
    18821886*/
    18831887function twitchpress_prepare_scopes( $scopes_array ) {
    1884     if( !$scopes_array ){ return array(); }
     1888    if( !$scopes_array ){ return ''; }
    18851889   
    18861890    $scopes_string = '';
     
    25112515* @param mixed $notice_output false|user|admin
    25122516*
    2513 * @version 2.0
     2517* @version 2.1
    25142518*/
    25152519function twitchpress_user_sub_sync_single( $wp_user_id, $output_notice = false ){       
     2520    // Do not process the keyholder to avoid displaying notices that do not apply to them...
     2521    if( $wp_user_id == 1 ) { return; }
     2522   
    25162523    $twitch_api = new TwitchPress_Twitch_API();   
    25172524    $twitch_user_id = twitchpress_get_user_twitchid_by_wpid( $wp_user_id );   
  • twitchpress/trunk/includes/admin/class.twitchpress-admin-notices.php

    r2527323 r2562159  
    3232    /**
    3333     * Array of notices - name => callback.
     34     *
    3435     * @var array
    3536     */
     
    5051        add_action( 'shutdown', array( __CLASS__, 'store_notices' ) );
    5152   
    52         // When displaying administrator (staff) only notices.
    53         if ( current_user_can( 'manage_twitchpress' ) ) {
     53        if ( current_user_can( 'activate_plugins' ) ) {
    5454            add_action( 'admin_print_styles', array( __CLASS__, 'add_notices' ) );
    5555        }
     
    200200
    201201    /**
    202      * Show a notice.
     202     * Request a pre-set notice to be displayed using the notices name...
    203203     * @param string $name
    204204     */
  • twitchpress/trunk/includes/admin/class.twitchpress-admin-quicktools.php

    r2527323 r2562159  
    9696        */
    9797    }
    98    
     98           
    9999    /**
    100100    * Listens for tools being used on the Quick Tools table view.
     
    178178    }
    179179
     180    /**
     181    * Install a group of example pages...
     182    *
     183    * @version 1.0
     184    */
     185    public function tool_install_example_pages() {
     186        $tool_info = array(
     187            'title'       => __( 'Install Example Pages', 'multitool' ),
     188            'description' => __( 'Installs pages that include shortcodes using your configuration. This includes an index page listing all other pages.', 'multitool' ),
     189            'version'     => '1.1',
     190            'author'      => 'Ryan Bayne',
     191            'url'         => '',
     192            'category'    => 'users',
     193            'capability'  => 'activate_plugins',
     194            'option'      => null,
     195            'function'    => __FUNCTION__,
     196            'plugin'      => 'TwitchPress',
     197        );
     198       
     199        if( $this->return_tool_info ){ return $tool_info; }     
     200       
     201        if( !current_user_can( $tool_info['capability'] ) ) { return; }
     202
     203        $notices = new TwitchPress_Admin_Notices();
     204
     205        require_once( TWITCHPRESS_PLUGIN_DIR_PATH . 'includes/admin/class.twitchpress-admin-install-examples.php' );
     206        TwitchPress_Install_Examples::everything();
     207    }
     208   
    180209    /**
    181210    * Called by a button in the Help tab under Installation.
  • twitchpress/trunk/includes/admin/class.twitchpress-admin-setup-wizard.php

    r2527323 r2562159  
    13221322        <h1><?php _e( 'Options', 'twitchpress' ); ?></h1>
    13231323
    1324 
    13251324        <form method="post">
    1326        
     1325
     1326            <h3><?php _e( 'Training', 'twitchpress' ); ?></h3>
     1327            <p><?php _e( 'The following options are for new users of the plugin and are the quickest way to learn how to get the most out of it.', 'twitchpress' ); ?></p>
     1328                   
     1329            <table class="form-table">
     1330                <tr>
     1331                    <th scope="row"><label for="twitchpress_install_samples"><?php _e( 'Do you want to install example pages?', 'twitchpress' ); ?></label></th>
     1332                    <td>
     1333                        <input type="checkbox" id="twitchpress_install_samples" name="twitchpress_install_samples" class="input-checkbox" value="yes" />
     1334                        <label for="twitchpress_install_samples"><?php _e( 'Yes, install some examples.', 'twitchpress' ); ?></label>
     1335                    </td>
     1336                </tr>               
     1337            </table>
     1338 
    13271339            <h3><?php _e( 'Systems', 'twitchpress' ); ?></h3>
    13281340            <p><?php _e( 'Only activate (by checking the boxes) the systems you require because some system requirements
     
    14311443        check_admin_referer( 'twitchpress-setup' );
    14321444       
     1445        if( isset( $_POST['twitchpress_install_samples'] ) && $_POST['twitchpress_install_samples'] == 'yes' ) {
     1446            require_once( TWITCHPRESS_PLUGIN_DIR_PATH . 'includes/admin/class.twitchpress-admin-install-examples.php' );
     1447            TwitchPress_Install_Examples::everything();       
     1448        } 
     1449             
    14331450        if( isset( $_POST['twitchpress_subscription_data'] ) && $_POST['twitchpress_subscription_data'] == 'yes' ) {
    14341451            update_option( 'twitchpress_twitchsubscribers_switch', 'yes' );   
  • twitchpress/trunk/includes/admin/notices/install.php

    r2156650 r2562159  
    1010?>
    1111<div id="message" class="updated twitchpress-message twitchpress-connect">
    12     <p><?php _e( '<strong>Welcome to WordPress TwitchPress</strong> &#8211; You&lsquo;re almost ready to begin using the plugin.', 'twitchpress' ); ?></p>
     12    <p><?php _e( '<strong>Welcome to WordPress TwitchPress</strong> &#8211; You&lsquo;re almost ready to begin using the plugin. It is recommended that you now complete the Setup Wizard to configure TwitchPress.', 'twitchpress' ); ?></p>
    1313    <p class="submit"><a href="<?php echo esc_url( admin_url( 'admin.php?page=twitchpress-setup' ) ); ?>" class="button-primary"><?php _e( 'Run the Setup Wizard', 'twitchpress' ); ?></a> <a class="button-secondary skip" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'twitchpress-hide-notice', 'install' ), 'twitchpress_hide_notices_nonce', '_twitchpress_notice_nonce' ) ); ?>"><?php _e( 'Skip Setup', 'twitchpress' ); ?></a></p>
    1414</div>
  • twitchpress/trunk/includes/admin/settings/class.twitchpress-settings-general.php

    r2527323 r2562159  
    7171     */
    7272    public function save() {     
     73       
     74        // Handle all sections (tabs) first...
    7375        global $current_section;
    7476        $settings = $this->get_settings( $current_section );
    7577        TwitchPress_Admin_Settings::save_fields( $settings ); // Use the saved values where possible...
    7678 
    77         // React to team section being submitted...
    78         if( !isset( $_POST['twitchpress_team_name'] ) ) {
    79             TwitchPress_Admin_Settings::add_error( sprintf( __( 'Please enter your teams name as shown on Twitch.', 'twitchpress' ), $team_id ) );
    80             return;
     79        // Handle the $current_section only...
     80        switch ( $current_section ) {
     81            case 'default':
     82
     83            break;
     84            case 'removal':
     85
     86            break;
     87            case 'advanced':
     88
     89            break;
     90            case 'systems':
     91
     92            break;
     93            case 'team':
     94           
     95                // React to team section being submitted...
     96                if( !isset( $_POST['twitchpress_team_name'] ) ) {
     97                    TwitchPress_Admin_Settings::add_error( __( 'Please enter your teams name as shown on Twitch.', 'twitchpress' ) );
     98                    return;
     99                }
     100               
     101                $twitch_api = new TwitchPress_Twitch_API();
     102                $twitch_api->get_team( get_option( 'twitchpress_team_name' ) );
     103                               
     104                if( $twitch_api->curl_object->response_code == 200 ) {
     105                    $team_id = $twitch_api->curl_object->curl_reply_body->data['0']->id;
     106                    twitchpress_update_main_channels_team_id( $team_id );   
     107                    TwitchPress_Admin_Settings::add_message( sprintf( __( 'Your main teams ID is %d and will be used to request team data from Twitch.', 'twitchpress' ), $team_id ) );
     108                } elseif( $twitch_api->curl_object->response_code == 404 ) {
     109                    TwitchPress_Admin_Settings::add_error( sprintf( __( 'Your team could not be found. Ensure the name is entered correctly and try again.', 'twitchpress' ), $team_id ) );
     110                }
     111               
     112            break;
    81113        }
    82        
    83         $twitch_api = new TwitchPress_Twitch_API();
    84         $twitch_api->get_team( get_option( 'twitchpress_team_name' ) );
    85                        
    86         if( $twitch_api->curl_object->response_code == 200 ) {
    87             $team_id = $twitch_api->curl_object->curl_reply_body->data['0']->id;
    88             twitchpress_update_main_channels_team_id( $team_id );   
    89             TwitchPress_Admin_Settings::add_message( sprintf( __( 'Your main teams ID is %d and will be used to request team data from Twitch.', 'twitchpress' ), $team_id ) );
    90         } elseif( $twitch_api->curl_object->response_code == 404 ) {
    91             TwitchPress_Admin_Settings::add_error( sprintf( __( 'Your team could not be found. Ensure the name is entered correctly and try again.', 'twitchpress' ), $team_id ) );
    92         }       
     114 
     115       
    93116    } 
    94117
  • twitchpress/trunk/includes/admin/settings/class.twitchpress-settings-users.php

    r2334500 r2562159  
    205205                    'desc'            => __( 'Use Main Login Form', 'twitchpress-login' ),
    206206                    'id'              => 'twitchpress_login_button',
    207                     'default'         => 'yes',
     207                    'default'         => 'no',
    208208                    'type'            => 'checkbox',
    209209                    'checkboxgroup'   => '',
  • twitchpress/trunk/includes/classes/class.twitchpress-api-logging.php

    r2527323 r2562159  
    126126    * @return WP_Error - this is the only return done
    127127    *
    128     * @version 2.0
     128    * @version 3.0
    129129    */
    130130    static function outcome( $entryid, $outcome, $life = 129600, $meta = array() ) {
     
    136136            return new WP_Error( __CLASS__, __( 'Invalid value type passed to TwitchPress_API_Logging::outcome()', 'twitchpress') );
    137137        }
    138        
    139         twitchpress_db_insert(             
    140             $wpdb->twitchpress_activity,
    141             array( 'entryid' => $entryid, 'outcome' => $outcome, 'life' => $life )
    142         );
     138
     139        twitchpress_db_update( $wpdb->twitchpress_activity, 'entryid = ' . $entryid, array( 'outcome' => $outcome, 'life' => $life ) );
    143140               
    144141        self::process_meta( $entryid, $meta );       
     
    257254   
    258255    /**
    259     * Outcome soft-closes a record by updating the original activity-table entry.
     256    * Closes a record by updating the original activity-table entry.
    260257    * This is used within class.twitchpress-curl.php to signal the end of the Curl
    261258    * call, outside of context.
     
    273270        if( !self::ready() ) { return; }
    274271        twitchpress_db_update( $wpdb->twitchpress_activity, 'entryid = "' . $entryid . '"', array( 'outcome' => $outcome ) );
     272       
     273        // Determine if the log entry should be added to a report...
     274        #TODO 
    275275    }
    276276}
  • twitchpress/trunk/includes/posts/class.twitchpress-post-type-webhooks.php

    r2527323 r2562159  
    2525       
    2626        // Save Post
    27         add_action( 'save_post', array( __CLASS__, 'save_twitchpress_webhooks_options' ) );         
    28         add_action( 'save_post', array( __CLASS__, 'save_twitchpress_webhooks_eventsub' ) );
     27        add_action( 'save_post_webhooks', array( __CLASS__, 'save_twitchpress_webhooks_options' ) );         
     28        add_action( 'save_post_webhook', array( __CLASS__, 'save_twitchpress_webhooks_eventsub' ) );
    2929                 
    3030        // Update Post
    31         add_action( 'update_post', array( __CLASS__, 'save_twitchpress_webhooks_options' ) );         
    32         add_action( 'update_post', array( __CLASS__, 'save_twitchpress_webhooks_eventsub' ) );         
     31        add_action( 'update_post_webhook', array( __CLASS__, 'save_twitchpress_webhooks_options' ) );         
     32        add_action( 'update_post_webhook', array( __CLASS__, 'save_twitchpress_webhooks_eventsub' ) );         
    3333    }
    3434 
     
    334334        //var_dump_twitchpress( $this->curl_object );
    335335        twitchpress_deliberate_error();
    336  
    337  
    338  
     336
    339337        error_log( implode( ',', $result ) );
    340338    }
  • twitchpress/trunk/install.php

    r2527323 r2562159  
    6666   
    6767    // Flush old notices to avoid confusion during a new installation...
    68     TwitchPress_Admin_Notices::remove_all_notices();
    69        
     68    TwitchPress_Admin_Notices::remove_all_notices(); 
     69   
    7070    // Queue upgrades/setup wizard
    7171    $current_installed_version = get_option( 'twitchpress_version', null );
     
    7676        delete_transient( '_twitchpress_activation_redirect' );
    7777        set_transient( '_twitchpress_activation_redirect', 1, 30 );
    78     }                                   
     78    }                                 
    7979}
    8080
     
    117117function twitchpress_offer_wizard() {
    118118    $offer_wizard = false;
    119    
     119                                     
    120120    if( !current_user_can( 'administrator' ) ) {       
    121121        return;   
     
    123123   
    124124    // Avoid registering notice during the Setup Wizard.
    125     if( isset( $_GET['page']) && $_GET['page'] == 'twitchpress-setup' ) {   
     125    if( isset( $_GET['page']) && $_GET['page'] == 'twitchpress-setup' ) {    
    126126        return;   
    127127    }
     
    132132    }
    133133
    134     if( !twitchpress_get_main_channels_name() ) {
     134    $a = get_option( 'twitchpress_main_channels_name' );               
     135    $b = get_option( 'twitchpress_main_channels_id' );           
     136    $c = get_option( 'twitchpress_app_id' );                           
     137    $d = get_option( 'twitchpress_app_secret' );                       
     138    $e = get_option( 'twitchpress_main_channels_code' );               
     139    $f = get_option( 'twitchpress_main_channels_token' );             
     140   
     141    if( !$a ) { $offer_wizard = 'twitchpress_main_channels_name'; }
     142    elseif( !$b ) { $offer_wizard = 'twitchpress_main_channels_id'; }
     143    elseif( !$c ) { $offer_wizard = 'twitchpress_app_id'; }
     144    elseif( !$d ) { $offer_wizard = 'twitchpress_app_secret'; }
     145    elseif( !$e ) { $offer_wizard = 'twitchpress_main_channels_code'; }
     146    elseif( !$f ) { $offer_wizard = 'twitchpress_main_channels_token'; }     
     147   
     148    if( $offer_wizard === false ) { return; }
     149   
     150    // Build a link to wizard...
     151    $wizard_link = '<p><a href="' . admin_url( 'index.php?page=twitchpress-setup' ) . '" class="button button-primary">' . __( 'Setup Wizard', 'twitchpress' ) . '</a></p>';
     152   
     153    // Add a new installation notice if it appears to be a fresh installation...
     154    if( !$a && !$b && !$c && !$d && !$e && !$f ) {
    135155       
    136         $offer_wizard = 'twitchpress_main_channels_name';
    137        
    138     } elseif( !twitchpress_get_main_channels_twitchid() ) {
    139                          
    140         $offer_wizard = 'twitchpress_main_channels_id';
    141        
    142     } elseif( !twitchpress_get_app_id() ) {
    143        
    144         $offer_wizard = 'twitchpress_app_id';
    145        
    146     } elseif( !twitchpress_get_app_secret() ) {
    147        
    148         $offer_wizard = 'twitchpress_app_secret';
    149        
    150     } elseif( !twitchpress_get_main_channels_code() ) {
    151              
    152         $offer_wizard = 'twitchpress_main_channels_code';
    153        
    154     } elseif( !twitchpress_get_main_channels_token() ) {
    155        
    156         $offer_wizard = 'twitchpress_main_channels_token';
    157        
     156        TwitchPress_Admin_Notices::add_wordpress_notice(
     157            'noappvaluesofferwizard',
     158            'info',
     159            false,
     160            __( 'Setup Wizard', 'twitchpress' ),
     161            sprintf( __( 'TwitchPress includes a Setup Wizard to help you get the plugin configured, please complete it now. %s', 'twitchpress'), $wizard_link )   
     162        );
     163
     164    } else {
     165
     166        TwitchPress_Admin_Notices::add_wordpress_notice(
     167            'missingvaluesofferwizard',
     168            'info',
     169            false,
     170            __( 'Twitch API Credentials Missing', 'twitchpress' ),
     171            sprintf( __( 'TwitchPress is not ready because the %s option is missing. If you have already been using the plugin and this notice suddenly appears then it suggests important options have been deleted or renamed. You can go through the Setup Wizard again to correct this problem. You should also report it. %s', 'twitchpress'), $offer_wizard, $wizard_link )   
     172        );     
    158173    }     
    159    
    160     if( $offer_wizard === false ) { return; }
    161    
    162     $wizard_link = '<p><a href="' . admin_url( 'index.php?page=twitchpress-setup' ) . '" class="button button-primary">' . __( 'Setup Wizard', 'twitchpress' ) . '</a></p>';
    163    
    164     TwitchPress_Admin_Notices::add_wordpress_notice(
    165         'missingvaluesofferwizard',
    166         'info',
    167         false,
    168         __( 'Twitch API Credentials Missing', 'twitchpress' ),
    169         sprintf( __( 'TwitchPress is not ready because the %s option is missing. If you have already been using the plugin and this notice suddenly appears then it suggests important options have been deleted or renamed. You can go through the Setup Wizard again to correct this problem. You should also report it. %s', 'twitchpress'), $offer_wizard, $wizard_link )   
    170     );           
    171174}
    172175   
  • twitchpress/trunk/readme.txt

    r2527323 r2562159  
    77Requires at least: 5.4
    88Tested up to: 5.7
    9 Stable tag: 3.13.0
     9Stable tag: 3.14.0
    1010Requires PHP: 5.6
    1111                       
     
    102102== Changelog == 
    103103   
     104= 3.14.0 UPGRADE 11th July 2021 =
     105* New Features
     106    - Option to install examples pages added to Setup Wizard
     107    - Quick tool for installing example pages
     108* Feature Changes
     109    - Twitch Login button will no longer be displayed as soon as the plugin is activated
     110* Faults Resolved
     111    - First-time installation notice will now appear admin and not just those with twitchpress capabilities
     112* Technical Notes
     113    - General settings save function uses a switch statement to handle individual tabs now
     114    - Function twitchpress_prepare_scopes() will now return empty string instead of empty array if no scopes setup
     115    - Admin user with ID 1 (reffered to as the keyholder) will not be subscription-synced anymore (was left active for testing)
     116* Configuration Advice
     117    - None
     118* Database Changes
     119    - None   
     120         
    104121= 3.13.0 UPGRADE Released 6th May 2021 =
    105122* New Features
     
    108125    - Webhooks option added to System switches in General Settings
    109126    - Added a Content Gate checkbox for switching content gating on/off as a system
    110     - New options added to Edit Webhooks view for webhook type and the desirned action in WordPress
     127    - New options added to Edit Webhooks view for webhook type
    111128* Faults Resolved
    112129    - PHP object as array error in function validate_user_token() avoided but the cause still to be determined.
  • twitchpress/trunk/shortcodes.php

    r2527323 r2562159  
    147147        'collection'      => '', // Example: https://embed.twitch.tv/?video=v124085610&collection=GMEgKwTQpRQwyA
    148148        'height'          => 600, // 50%|Minimum: 400|Default: 480
     149        'layout'          => 'default',
    149150        'theme'           => 'light', // light|dark
    150151        'width'           => '100%'  // 80%|100%|Minimum: 340|Default: 940               
    151152    ), $atts, 'twitchpress_embed_everything' );
    152    
     153
    153154    $atts['channel'] = str_replace( '”', '', $atts['channel'] );
    154155   
  • twitchpress/trunk/twitchpress.php

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