コード例 #1
0
 /**
  * Ensure there is a playlist capable player available
  */
 public function validate_players()
 {
     global $pagenow, $plugin_page;
     // only on admin.php?page=page-brightcove-playlists
     if ($pagenow != 'admin.php' || $plugin_page != 'page-brightcove-playlists') {
         return;
     }
     $player_api = new BC_Player_Management_API();
     $players = $player_api->player_list_playlist_enabled();
     if (is_wp_error($players) || !is_array($players) || $players['item_count'] < 1) {
         BC_Utility::admin_notice_messages(array(array('message' => __('A specified Source does not have a playlist capable player <a href="https://studio.brightcove.com/products/videocloud/players/">configured</a>. Make sure there is at least one player with "Display Playlist" enabled.', 'brightcove'), 'type' => 'error')));
     }
 }
 public function delete_source()
 {
     global $bc_accounts;
     if (!isset($_GET['_wpnonce'])) {
         return false;
     }
     if (!wp_verify_nonce($_GET['_wpnonce'], 'bc_delete_source_id_' . $_GET['account'])) {
         return false;
     }
     $delete_account = $bc_accounts->delete_account(sanitize_text_field($_GET['account']));
     if (is_wp_error($delete_account)) {
         BC_Utility::admin_notice_messages(array(array('message' => $delete_account->get_error_message(), 'type' => 'error')));
     }
     BC_Utility::admin_notice_messages(array(array('message' => esc_html__('Source Deleted', 'brightcove'), 'type' => 'updated')));
 }
コード例 #3
0
 public function update_profile()
 {
     global $bc_accounts;
     if (!isset($_POST['_bc_profile_nonce'])) {
         return false;
     }
     if (!wp_verify_nonce($_POST['_bc_profile_nonce'], 'bc_profile_nonce')) {
         return false;
     }
     $hash = BC_Utility::sanitize_payload_item($_POST['bc-user-default-source']);
     $user_id = BC_Utility::sanitize_id($_POST['user_id']);
     $accounts = $bc_accounts->get_sanitized_all_accounts();
     if (!isset($accounts[$hash])) {
         BC_Utility::admin_notice_messages(array(array('message' => esc_html__('The specified Source does not exist.', 'brightcove'), 'type' => 'error')));
         return false;
     }
     BC_Utility::update_user_meta($user_id, '_brightcove_default_account_' . get_current_blog_id(), $hash);
     return true;
 }
コード例 #4
0
 public function add_account($account_id, $client_id, $client_secret, $account_name = 'New Account', $set_default = '', $allow_update = true)
 {
     // Check if WP CLI is working and bail in admin if it is.
     if (defined('WP_CLI') && !WP_CLI) {
         return false;
     }
     $is_valid_account = $this->is_valid_account($account_id, $client_id, $client_secret, $account_name);
     if (is_array($is_valid_account)) {
         foreach ($is_valid_account as $wp_error) {
             if (is_wp_error($wp_error)) {
                 BC_Utility::admin_notice_messages(array(array('message' => $wp_error->get_error_message(), 'type' => 'error')));
             }
         }
         return false;
     }
     if (true !== $is_valid_account) {
         return new WP_Error('brightcove-invalid-account', esc_html__('Account credentials are invalid. Please ensure you are using all the correct information from Brightcove Video Cloud Studio to secure a token.', 'brightcove'));
     }
     $operation = $allow_update ? 'update' : 'add';
     $account_hash = $this->make_account_change(array('account_id' => $account_id, 'account_name' => $account_name, 'client_id' => $client_id, 'client_secret' => $client_secret, 'set_default' => $set_default, 'operation' => $operation));
     if (false === $account_hash) {
         return new WP_Error('brightcove-account-exists', esc_html__('Unable to update this account via WP-CLI.', 'brightcove'));
     }
     if ($account_hash && !$this->get_account_details_for_site() && 'default' === $set_default) {
         $this->set_account_details_for_site($account_hash);
     }
     $this->set_sync_type($account_id, 'full');
     $this->set_current_account($account_hash);
     $all_accounts = $this->get_all_accounts();
     // If this is the first account, make it the default.
     if (count($all_accounts) <= 1) {
         update_option('_brightcove_default_account', $account_hash);
     }
     $this->restore_default_account();
     return true;
 }
コード例 #5
0
 /**
  * Method to display source update or error messages
  *
  * @return bool
  */
 public function admin_notice_handler()
 {
     if (empty($this->notices)) {
         return false;
     }
     BC_Utility::admin_notice_messages($this->notices);
     return true;
 }
コード例 #6
0
 public static function bc_activation_admin_notices()
 {
     global $bc_accounts;
     if (count($bc_accounts->get_sanitized_all_accounts()) > 0) {
         delete_option('_brightcove_plugin_activated');
         return;
     }
     if (get_option('_brightcove_plugin_activated') !== false && current_user_can('manage_options') && get_current_screen()->base !== 'brightcove_page_brightcove-sources' && get_current_screen()->base !== 'brightcove_page_brightcove-edit-source' && get_current_screen()->base !== 'admin_page_page-brightcove-edit-source') {
         $notices[] = array('message' => sprintf('%s <a href="%s"><strong>%s</strong></a>', esc_html__('Please configure Brightcove settings from', 'brightcove'), esc_url(admin_url('admin.php?page=brightcove-sources')), esc_html__('here', 'brightcove')), 'type' => 'updated');
         BC_Utility::admin_notice_messages($notices);
     }
 }