Skip to content

Commit

Permalink
Merge pull request #20 from sanjeevbigstep/v3.0.0-beta-development
Browse files Browse the repository at this point in the history
V3.0.0 beta development
  • Loading branch information
digitallysavvy committed Aug 4, 2021
2 parents 0adf9ec + 30618c0 commit 5b1bf93
Show file tree
Hide file tree
Showing 1,890 changed files with 129,787 additions and 853 deletions.
47 changes: 46 additions & 1 deletion admin/class-agora-channels-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ public static function define_columns() {
'title' => __( 'Title', 'agoraio' ),
'type' => __( 'Type', 'agoraio' ),
'shortcode' => __( 'Shortcode', 'agoraio' ),
//'recordings' => __( 'Recordings', 'agoraio' ),
'date' => __( 'Date', 'agoraio' ),
);

return $columns;
}

public static function define_recordings_channels_columns() {
$columns = array(
'title' => __( 'Channel Name', 'agoraio' ),
'type' => __( 'Type', 'agoraio' ),
'date' => __( 'Date', 'agoraio' ),
);

Expand Down Expand Up @@ -62,6 +73,10 @@ protected function get_bulk_actions() {
$actions = array(
'delete' => __( 'Delete', 'agoraio' ),
);

if(isset($_GET['page']) && ($_GET['page'] == 'agoraio-recordings')){
$actions = array();
}

return $actions;
}
Expand Down Expand Up @@ -181,11 +196,14 @@ public static function record_count() {

function column_title( $item ) {
$title = '<strong>' . $item->title() . '</strong>';
if(isset($_GET['page']) && ($_GET['page'] == 'agoraio-recordings')){
$title = '<a href="'. esc_url( admin_url('admin.php?page=agoraio-recordings-listing&id='.$item->id()) ) .'"><strong>' . $item->title() . '</strong></a>';
}
return $title;
}

protected function handle_row_actions( $item, $column_name, $primary ) {
if ( $column_name !== $primary ) {
if ( $column_name !== $primary || ((isset($_GET['page']) && ($_GET['page'] == 'agoraio-recordings')))) {
return '';
}

Expand Down Expand Up @@ -251,6 +269,33 @@ public function column_type( $item ) {
return $item->type();
}

/* public function column_recordings( $item ){
$isrecordingSettingsDone = $item->isrecordingSettingsDone();
$recordingOptions = array(""=>"Type", "composite" => "Composite", "individual" => "Individual");
$output = 'Please fill recording settings details.';
// Show Recordings Shortcode if recording setting is done
if($isrecordingSettingsDone){
$recording_type = $item->getRecordingType();
?>
<select class="create_recordings_shortcode" onchange="updateRecordingShortcode(this.value, <?php echo $item->id(); ?>)">
<?php foreach($recordingOptions as $value=>$option) { ?>
<option value="<?php echo $value; ?>" <?php if($value == $recording_type){ echo "selected"; } ?>><?php echo $option; ?></option>
<?php } ?>
</select>
<?php
$shortcode = $item->shortcode('recording');
$output = "\n" . '<span class="shortcode recording-shortcode-row-'.$item->id().'"><input type="text"'
. ' onfocus="this.select();" readonly="readonly"'
. ' value="' . esc_attr( $shortcode ) . '"'
. ' class="large-text code" /></span>';
}
return trim( $output );
} */

/**
* Render a column when no column specific method exists.
*
Expand Down
188 changes: 176 additions & 12 deletions admin/class-wp-agora-io-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,31 @@ public function __construct( $plugin_name, $version ) {
// add_filter('plugin_action_links_'.$name, array($this, 'plugin_add_settings_link') );

add_action('wp_ajax_save-agora-setting', array($this, 'saveAjaxSettings'));

add_action('wp_ajax_get_all_users_list', array($this, 'getAllUsersList'));
add_action('wp_ajax_run_recordings_shortcode', array($this, 'runRecordingShortcode'));
}

public function runRecordingShortcode(){
$shortcode = stripslashes(sanitize_text_field($_POST['shortcode']));
echo do_shortcode($shortcode);
wp_die();
}

public function getAllUsersList(){
$args = array('fields' => array( 'ID', 'display_name' ) );
$users = get_users($args);

$users_options = array(
0 => __('Select', 'agoraio')
);

foreach($users as $user){
$users_options[$user->ID] = __($user->display_name, 'agoraio');
}

echo json_encode($users_options);
wp_die();
}


Expand All @@ -42,26 +67,33 @@ public function saveAjaxSettings() {
unset($_POST['action']);
$keys = array_keys($_POST);
$key = $keys[0];
$value = sanitize_text_field( $_POST[$key] );

$options = get_option($this->plugin_name);
if($key != 'global_colors'){
$value = sanitize_text_field( $_POST[$key] );
}else{
$value = $_POST[$key];
}

$options = sanitize_option($this->plugin_name, get_option($this->plugin_name));
$old_value = $options;

if (!$options) {
$options = array();
}
$options[$key] = $value;

$r = false;
if (!$old_value) {
$r = add_option( $this->plugin_name, $options);
$r = false;
if (!$old_value) {
//echo '<pre>';print_r($this->plugin_name); echo '</pre>';die;
$r = update_option( $this->plugin_name, $options);

} else {
// $r = update_option($this->plugin_name, $options);
$serialized_value = maybe_serialize( $options );
$update_args = array(
'option_value' => $serialized_value,
);
$r = $wpdb->update(
$update_args = array(
'option_value' => $serialized_value,
);

$r = $wpdb->update(
$wpdb->options,
$update_args,
array( 'option_name' => $this->plugin_name ) );
Expand Down Expand Up @@ -102,6 +134,22 @@ public function register_admin_menu_pages() {

add_action( 'load-' . $addnew, array($this, 'agora_load_channel_pages'), 10, 0 );

$recordings = add_submenu_page( 'agoraio',
__( 'Agora Recordings', 'agoraio' ),
__( 'Recordings', 'agoraio' ),
'manage_options', 'agoraio-recordings',
array($this, 'include_agora_recordings_page') );

add_action( 'load-' . $recordings, array($this, 'agora_load_channel_pages'), 10, 0 );

$recordings_listing = add_submenu_page( '',
__( 'Agora Recordings Listing', 'agoraio' ),
__( 'Recordings', 'agoraio' ),
'manage_options', 'agoraio-recordings-listing',
array($this, 'include_agora_recordings_listing_page') );

add_action( 'load-' . $recordings_listing, array($this, 'agora_recordings_listing_page'), 10, 0 );

$settings = add_submenu_page( 'agoraio',
__( 'Agora Settings', 'agoraio' ),
__( 'Settings', 'agoraio' ),
Expand All @@ -117,6 +165,7 @@ public function include_agora_channels_page() {
$this->create_agora_metaboxes_form();
$post_id = $post->initial() ? -1 : $post->id();
include_once('views/agora-admin-new-channel.php');
include_once('views/parts/modal-layout-image.php');
return;
}

Expand All @@ -126,6 +175,8 @@ public function include_agora_channels_page() {
$this->channels_obj = new Agora_Channels_List_Table();
$this->channels_obj->prepare_items();
include_once('views/agora-admin-channels.php');


}

private function create_agora_metaboxes_form() {
Expand Down Expand Up @@ -155,9 +206,39 @@ private function create_agora_metaboxes_form() {
'agora_channel_recording'
);

// Custom Settings metabox
add_meta_box(
'agora-form-chat',
__('Settings', 'agoraio'),
'render_agoraio_channel_form_chat_support',
null,
'agora_chat_support'
);

// Ghost Mode metabox
/*add_meta_box(
'agora-ghost-mode',
__('Ghost Mode', 'agoraio'),
'render_agoraio_channel_form_ghost_mode',
null,
'agora_ghost_mode'
);
// Layout metabox
add_meta_box(
'agora-layout',
__('Layout', 'agoraio'),
'render_agoraio_channel_form_layout',
null,
'agora_layout'
);*/

add_action( 'agoraio_channel_form_settings', array($this, 'handle_channel_form_metabox_settings'), 10, 1 );
add_action( 'agoraio_channel_form_appearance', array($this, 'handle_channel_form_metabox_appearance'), 10, 1 );
add_action( 'agoraio_channel_form_recording', array($this, 'handle_channel_form_metabox_recording'), 10, 1 );
add_action( 'agoraio_channel_form_chat_support', array($this, 'handle_channel_form_chat_support'), 10, 1 );
//add_action( 'agoraio_channel_form_ghost_mode', array($this, 'handle_channel_form_ghost_mode'), 10, 1 );
//add_action( 'agoraio_channel_form_layout', array($this, 'handle_channel_form_layout'), 10, 1 );
}

public function include_agora_new_channel_page() {
Expand All @@ -168,7 +249,7 @@ public function include_agora_new_channel_page() {
}
// die("<pre>P:".print_r($post, true)."</pre>");

$this->create_agora_metaboxes_form();
$this->create_agora_metaboxes_form();

$post_id = $post->initial() ? -1 : $post->id();
include_once('views/agora-admin-new-channel.php');
Expand All @@ -184,7 +265,7 @@ public function agora_enqueue_color_picker() {
// http://fieldmanager.org/docs/misc/adding-fields-after-the-title/
// https://metabox.io/how-to-create-custom-meta-boxes-custom-fields-in-wordpress/
public function handle_channel_form_metabox_settings($channel) {
global $wp_meta_boxes;
global $wp_meta_boxes;

do_meta_boxes( get_current_screen(), 'agora_channel_settings', $channel );
unset( $wp_meta_boxes['post']['agora_channel_settings'] );
Expand All @@ -204,6 +285,44 @@ public function handle_channel_form_metabox_recording($channel) {
unset( $wp_meta_boxes['post']['agora_channel_recording'] );
}

public function handle_channel_form_chat_support($channel) {
global $wp_meta_boxes;

do_meta_boxes( get_current_screen(), 'agora_chat_support', $channel );
unset( $wp_meta_boxes['post']['agora_chat_support'] );
}

/*public function handle_channel_form_ghost_mode($channel) {
global $wp_meta_boxes;
do_meta_boxes( get_current_screen(), 'agora_ghost_mode', $channel );
unset( $wp_meta_boxes['post']['agora_ghost_mode'] );
}
public function handle_channel_form_layout($channel) {
global $wp_meta_boxes;
do_meta_boxes( get_current_screen(), 'agora_layout', $channel );
unset( $wp_meta_boxes['post']['agora_layout'] );
}*/

public function include_agora_recordings_page(){

if ( ! class_exists( 'Agora_Channels_List_Table' ) ) {
require_once( 'class-agora-channels-list-table.php' );
}
$this->channels_obj = new Agora_Channels_List_Table();
$this->channels_obj->prepare_items();

//$agora_options = get_option($this->plugin_name);
include_once('views/agora-admin-recordings.php');
}

public function include_agora_recordings_listing_page(){
if(!isset($_GET['id'])){ return; }
include_once('views/agora-admin-recording-listings.php');
}

public function include_agora_settings_page() {
$agora_options = get_option($this->plugin_name);
include_once('views/agora-admin-settings.php');
Expand Down Expand Up @@ -307,6 +426,20 @@ public function agora_load_channel_pages() {
// die("EDIT: <pre>".print_r($channel, true)."</pre>");
// $this->include_agora_new_channel_page();

} else if($_GET['page'] == "agoraio-recordings"){

if ( ! class_exists( 'Agora_Channels_List_Table' ) ) {
require_once( 'class-agora-channels-list-table.php' );
}

add_filter( 'manage_' . $current_screen->id . '_columns',
array( 'Agora_Channels_List_Table', 'define_recordings_channels_columns' ), 10, 0 );

add_screen_option( 'per_page', array(
'default' => 20,
'option' => 'agoraio_per_page',
) );

} else {
if ( ! class_exists( 'Agora_Channels_List_Table' ) ) {
require_once( 'class-agora-channels-list-table.php' );
Expand Down Expand Up @@ -340,6 +473,15 @@ private function save_channel( $args ) {
return $channel;
}

public function agora_load_recordings_pages() {
global $plugin_page;
$current_screen = get_current_screen();
}

public function agora_recordings_listing_page(){

}

public function agora_load_settings_pages() {
global $plugin_page;
$current_screen = get_current_screen();
Expand All @@ -355,11 +497,33 @@ public function plugin_add_settings_link($links) {
// Admin styles for settings pages...
public function enqueue_styles() {
wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wp-agora-io-admin.css', array(), $this->version, 'all' );

/* jQuery UI drag-drop CSS */
wp_enqueue_style( $this->plugin_name.'-drag-drop-custom-css', plugin_dir_url( __FILE__ ) . 'css/wp-agora-io-drag-drop.css', $this->version, 'all' );
wp_enqueue_style( $this->plugin_name.'-jquery-ui-css', 'https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css', $this->version, 'all' );

}

// Admin scripts for ajax requests on settings pages...
public function enqueue_scripts() {

$recordings_regions = WP_Agora_Public::$recordings_regions;
?>
<script>
var plugineBaseURL = "<?php echo plugins_url('wp-agora-io'); ?>";
var cloudRegions = '<?php print_r(json_encode($recordings_regions)); ?>';
</script>
<?php
wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wp-agora-io-admin.js', array( 'jquery' ), $this->version, false );

/* jQuery UI drag-drop JS */
wp_enqueue_script( $this->plugin_name.'-jquery-ui', 'https://code.jquery.com/ui/1.12.1/jquery-ui.js', array( 'jquery' ), $this->version, false );

wp_enqueue_script($this->plugin_name.'-hls-player-js', 'https://cdn.jsdelivr.net/npm/hls.js@latest', array( ), $this->version, false);

$bootstrap_js = plugin_dir_url( $this->plugin_name ) . $this->plugin_name.'/public/js/bootstrap/bootstrap.min.js';
wp_enqueue_script( 'bootstrap_js', $bootstrap_js, array('jquery'), null );

}

}
Expand Down

0 comments on commit 5b1bf93

Please sign in to comment.