Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assets/build/js/main.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => 'd30a32a27c47da7979ee');
<?php return array('dependencies' => array('react', 'wp-element'), 'version' => '82d429cc8c4233110b16');
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "rtcamp/react-pages-features",
"name": "rtcamp/transcoder",
"description": "1.0.0",
"type": "wordpress-plugin",
"require-dev": {
Expand Down
94 changes: 94 additions & 0 deletions inc/classes/class-assets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php
/**
* Assets class.
*
* @package transcoder
*/

namespace Transcoder\Inc;

use Transcoder\Inc\Traits\Singleton;

/**
* Class Assets
*/
class Assets {

use Singleton;

/**
* Construct method.
*/
protected function __construct() {
$this->setup_hooks();
}

/**
* To setup action/filter.
*
* @return void
*/
protected function setup_hooks() {

/**
* Action
*/
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );

}

/**
* To enqueue scripts and styles.
*
* @return void
*/
public function enqueue_scripts() {

wp_register_script(
'easydam-script',
RT_TRANSCODER_URL . '/assets/build/js/main.js',
array(),
filemtime( RT_TRANSCODER_PATH . '/assets/build/js/main.js' ),
true
);

wp_register_style(
'easydam-style',
RT_TRANSCODER_URL . '/assets/build/css/main.css',
array(),
filemtime( RT_TRANSCODER_PATH . '/assets/build/css/main.css' )
);

wp_enqueue_script( 'easydam-script' );
wp_enqueue_style( 'easydam-style' );

}

/**
* To enqueue scripts and styles. in admin.
*
* @return void
*/
public function admin_enqueue_scripts() {

wp_register_script(
'easydam-script',
RT_TRANSCODER_URL . '/assets/build/js/admin.js',
array(),
filemtime( RT_TRANSCODER_PATH . '/assets/build/js/admin.js' ),
true
);

wp_register_style(
'easydam-style',
RT_TRANSCODER_URL . '/assets/build/css/admin.css',
array(),
filemtime( RT_TRANSCODER_PATH . '/assets/build/css/admin.css' )
);

wp_enqueue_script( 'easydam-script' );
wp_enqueue_style( 'easydam-style' );

}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Function closing brace must go on the next line following the body; found 1 blank lines before brace (PSR2.Methods.FunctionClosingBrace.SpacingBeforeClose).

}
49 changes: 49 additions & 0 deletions inc/classes/class-blocks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
/**
* Class to handle file system.
*
* @package transcoder
*/

namespace Transcoder\Inc;

use Transcoder\Inc\Traits\Singleton;

/**
* Class Blocks
*/
class Blocks {

use Singleton;

/**
* Construct method.
*/
protected function __construct() {

$this->setup_hooks();
}

/**
* Setup hooks.
*
* @return void
*/
public function setup_hooks() {
add_action( 'init', array( $this, 'register_blocks' ) );
}

/**
* Register all custom gutenberg blocks.
*
* @return void
*/
public function register_blocks() {

// Register example-block Block.
register_block_type(
RT_TRANSCODER_PATH . '/assets/build/blocks/easydam-player/'
);

}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Function closing brace must go on the next line following the body; found 1 blank lines before brace (PSR2.Methods.FunctionClosingBrace.SpacingBeforeClose).

}
189 changes: 189 additions & 0 deletions inc/classes/class-pages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
<?php
/**
* Assets class.
*
* @package transcoder
*/

namespace Transcoder\Inc;

use Transcoder\Inc\Traits\Singleton;

/**
* Class Assets
*/
class Pages {
use Singleton;

/**
* Construct method.
*/
protected function __construct() {
$this->setup_hooks();
}

/**
* To setup action/filter.
*
* @return void
*/
protected function setup_hooks() {
/**
* Action
*/
add_action( 'admin_menu', array( $this, 'add_admin_pages' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
add_action( 'admin_head', array( $this, 'handle_admin_head' ) );
}

/**
* To add admin pages.
*
* @return void
*/
public function add_admin_pages() {
add_menu_page(
__( 'EasyDAM', 'transcoder' ),
__( 'EasyDAM', 'transcoder' ),
'manage_options',
'easydam',
array( $this, 'render_easydam_page' ),
'dashicons-admin-generic',
6
);

add_submenu_page(
'easydam',
__( 'Video editor', 'transcoder' ),
__( 'Video editor', 'transcoder' ),
'edit_posts',
'video_editor',
array( $this, 'render_video_editor_page' )
);
}

/**
* Handle admin head to remove admin notices.
*
* @return void
*/
public function handle_admin_head() {
Comment thread
KMchaudhary marked this conversation as resolved.
// Get the current screen object.
$screen = get_current_screen();

// Check if this is your custom admin page.
if ( $screen && in_array( $screen->id, array( 'toplevel_page_easydam', 'easydam_page_video_editor' ) ) ) {
// Remove admin notices.
remove_all_actions( 'admin_notices' );
remove_all_actions( 'all_admin_notices' );

// Remove "Thank you for creating with WordPress" text.
add_filter( 'admin_footer_text', '__return_empty_string' );

// Remove the WordPress version number.
add_filter( 'update_footer', '__return_empty_string', 11 );
}
}

/**
* To render the easydam page.
*
* @return void
*/
public function render_easydam_page() {
?>
<div id="root-easydam">easydam root</div>
<?php
}

/**
* To render the video-editor page.
*
* @return void
*/
public function render_video_editor_page() {
// Check if the attachment_id is set.
$attachment_id = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : 0; // phpcs:ignore
if ( empty( $attachment_id ) ) {
wp_die( 'Invalid URL! please check that you are trying to edit correct media.' );
}

// Check if the attachment is video.
$attachment = get_post( $attachment_id );
if ( 'video' !== substr( $attachment->post_mime_type, 0, 5 ) ) {
wp_die( 'Invalid URL! please check that you are trying to edit correct media.' );
}

?>
<div id="root-video-editor">video editor root</div>
<?php
}

/**
* To enqueue scripts and styles. in admin.
*
* @param string $hook_suffix Admin page name.
*
* @return void
*/
public function admin_enqueue_scripts( $hook_suffix ) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: The method parameter $hook_suffix is never used (Generic.CodeAnalysis.UnusedFunctionParameter.Found).

$screen = get_current_screen();

if ( $screen && in_array( $screen->id, array( 'toplevel_page_easydam', 'easydam_page_video_editor' ) ) ) {
wp_register_style(
'transcoder-page-style-easydam',
RT_TRANSCODER_URL . '/pages/build/style.css',
array(),
filemtime( RT_TRANSCODER_PATH . '/pages/build/style.css' )
);

wp_enqueue_style( 'transcoder-page-style-easydam' );
}

// Check if this is your custom admin page.
if ( 'easydam_page_video_editor' === $screen && $screen->id ) {

wp_register_script(
'transcoder-page-script-video-editor',
RT_TRANSCODER_URL . '/pages/build/video-editor.js',
array( 'wp-element' ),
filemtime( RT_TRANSCODER_PATH . '/pages/build/video-editor.js' ),
true
);

// Pass dynamic data to React using wp_localize_script.
wp_localize_script(
'transcoder-page-script-video-editor',
'videoData',
array(
'nonce' => wp_create_nonce( 'wp_rest' ), // WordPress nonce for API requests.
'currentUserId' => get_current_user_id(), // Current user ID.
'currentUserRoles' => wp_get_current_user()->roles, // Current user roles.
)
);

wp_enqueue_script( 'transcoder-page-script-video-editor' );
} elseif ( 'toplevel_page_easydam' === $screen && $screen->id ) {
wp_register_script(
'transcoder-page-script-easydam',
RT_TRANSCODER_URL . '/pages/build/easydam.js',
array( 'wp-element' ),
filemtime( RT_TRANSCODER_PATH . '/pages/build/easydam.js' ),
true
);

wp_enqueue_script( 'transcoder-page-script-easydam' );
} elseif ( 'easydam_page_components' === $screen && $screen->id ) {
wp_register_script(
'transcoder-page-script-wp-components',
RT_TRANSCODER_URL . '/pages/build/wp-components.js',
array( 'wp-element' ),
filemtime( RT_TRANSCODER_PATH . '/pages/build/wp-components.js' ),
true
);

wp_enqueue_script( 'transcoder-page-script-wp-components' );
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Function closing brace must go on the next line following the body; found 1 blank lines before brace (PSR2.Methods.FunctionClosingBrace.SpacingBeforeClose).

}
Loading