channel_info_popup();
$this->channel_manager_page( $updated );
}
/**
* Renders the channel manager page.
*
* @param string $updated contains the channel name if the page is loaded after a channel update.
*/
private function channel_manager_page( $updated ) {
echo '
';
echo '
';
$this->channel_manager_content( $updated );
echo '
';
}
/**
* Renders the channel tiles wrappers for the installed and uninstalled channels.
*
* @param string $updated contains the channel name if the page is loaded after a channel update.
*/
private function channel_manager_content( $updated ) {
$channels_class = new WPPFM_Channel();
$response = $channels_class->get_channels_from_server();
if ( ! is_wp_error( $response ) ) {
$available_channels = json_decode( $response['body'] );
if ( $available_channels ) {
$installed_channels_names = $channels_class->get_installed_channel_names();
$channels_class->add_status_data_to_available_channels( $available_channels, $installed_channels_names, $updated );
$channels_class->add_channel_info_links_to_channels( $available_channels );
// Split the available channels into installed and uninstalled.
$installed_channels = array_filter(
$available_channels,
function ( $channel ) {
return ( 'installed' === $channel->status );
}
);
$uninstalled_channels = array_filter(
$available_channels,
function ( $channel ) {
return ( 'installed' !== $channel->status );
}
);
if ( 'false' === get_option( 'wppfm_manual_channel_update', 'false' ) ) {
wppfm_auto_update_installed_channels( $installed_channels );
}
echo '';
foreach ( $installed_channels as $channel ) {
$this->installed_channel_tile( $channel );
}
echo '
';
echo '';
foreach ( $uninstalled_channels as $channel ) {
$this->uninstalled_channel_tile( $channel );
}
}
} else {
/* translators: %s: link to the support page */
wppfm_handle_wp_errors_response( $response, sprintf( esc_html__( '2965 - Could not connect to the channel download server. Please try to refresh the page in a few minutes again. You can open a support ticket at %s if the issue persists.', 'wp-product-feed-manager' ), WPPFM_SUPPORT_PAGE_URL ) );
}
}
/**
* Renders a channel tile of a channel that is installed.
*
* @param object $channel containing the channel data.
*/
private function installed_channel_tile( $channel ) {
$latest_version = (float) $channel->installed_version >= (float) $channel->version;
$remove_nonce = wp_create_nonce( 'delete-channel-nonce' );
echo
'
' . esc_html( $channel->channel ) . '
';
$this->channel_data_storage_element( $channel );
echo '
';
}
/**
* Renders a channel tile of a channel that is not yet installed.
*
* @param object $channel containing the channel data.
*/
private function uninstalled_channel_tile( $channel ) {
$install_nonce = wp_create_nonce( 'install-channel-nonce' );
echo
'
' . esc_html( $channel->channel ) . '
';
$this->channel_data_storage_element( $channel );
echo '
';
}
private function channel_tile_info_button( $channel_short_name ) {
echo '
' . esc_html__( 'Channel Info', 'wp-product-feed-manager' ) . '';
}
/**
* Renders a hidden channel data storage element containing the channels data.
*
* @param object $channel containing the channel data.
*/
private function channel_data_storage_element( $channel ) {
echo
'
';
}
/**
* Renders the channel info popup screen. Initial display style is none.
*/
private function channel_info_popup() {
echo
'';
}
}
// end of WPPFM_Channel_Manager_Page class
endif;