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 '

' . esc_html__( 'Feed Manager - Channel Manager', 'wp-product-feed-manager' ) . '

'; // Feed Manager Channel Manager Table 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 '

' . esc_html__( 'Installed Channels:', 'wp-product-feed-manager' ) . '

'; echo '
'; foreach ( $installed_channels as $channel ) { $this->installed_channel_tile( $channel ); } echo '
'; echo '

' . esc_html__( 'Available Channels:', 'wp-product-feed-manager' ) . '

'; 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 '
channel-logo

' . esc_html( $channel->channel ) . '

' . esc_html__( 'Remove', 'wp-product-feed-manager' ) . ''; if ( $latest_version || 'false' === get_option( 'wppfm_manual_channel_update', 'false' ) ) { $this->channel_tile_info_button( $channel->short_name ); } else { $update_nonce = wp_create_nonce( 'update-channel-nonce' ); echo '' . esc_html__( 'Update Available', 'wp-product-feed-manager' ) . ''; } echo '
'; $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 '
channel-logo

' . esc_html( $channel->channel ) . '

' . esc_html__( 'Install', 'wp-product-feed-manager' ) . ''; $this->channel_tile_info_button( $channel->short_name ); echo '
'; $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;