New IDs, finish Submit Translation page and begin BIG TS.
This commit is contained in:
@@ -6,6 +6,9 @@ defined( '\ABSPATH' ) || exit;
|
||||
use RomhackPlaza\API\File_Server;
|
||||
use RomhackPlaza\Extenders\Post\Properties;
|
||||
use RomhackPlaza\Format;
|
||||
use RomhackPlaza\Identifiers\Post_Fields;
|
||||
use RomhackPlaza\Identifiers\Taxonomies;
|
||||
use RomhackPlaza\Modal;
|
||||
use RomhackPlaza\Overrides\Roles;
|
||||
use RomhackPlaza\Script;
|
||||
use RomhackPlaza\Script_Type;
|
||||
@@ -213,14 +216,16 @@ class Submissions extends Abstract_Extender {
|
||||
|
||||
$context['terms_language'] = array_merge( $priority_terms, $other_terms );
|
||||
|
||||
$context['value_terms_language'] = $context['submission_post_id'] != 0 ? wp_get_post_terms( $context['submission_post_id'], 'language', [ 'fields' => 'ids' ] ) |> $this->test_terms_array(...) : [];
|
||||
$context['value_terms_language'] = $context['submission_post_id'] != 0
|
||||
? wp_get_post_terms( $context['submission_post_id'], Taxonomies::LANG->value, [ 'fields' => 'ids' ] ) |> $this->test_terms_array(...)
|
||||
: [];
|
||||
|
||||
return $context;
|
||||
}
|
||||
|
||||
protected function add_and_format_game( &$context ){
|
||||
|
||||
$game_term = $context['submission_post_id'] != 0 ? get_the_terms( $context['submission_post_id'], 'game' ) : 0;
|
||||
$game_term = $context['submission_post_id'] != 0 ? get_the_terms( $context['submission_post_id'], Taxonomies::GAME->value ) : 0;
|
||||
$context['value_game_id'] = $game_term != 0 && !is_wp_error( $game_term ) ? $game_term[0]->term_id : '';
|
||||
$context['value_game_name'] = $game_term != 0 && !is_wp_error( $game_term ) ? $game_term[0]->name : '';
|
||||
|
||||
@@ -231,11 +236,11 @@ class Submissions extends Abstract_Extender {
|
||||
protected function add_and_format_platform( &$context ){
|
||||
|
||||
$context['terms_platform'] = \Timber\Timber::get_terms([
|
||||
'taxonomy' => 'platform',
|
||||
'taxonomy' => Taxonomies::PLATFORM->value,
|
||||
'hide_empty' => false,
|
||||
]);
|
||||
|
||||
$platform_term = $context['submission_post_id'] != 0 ? wp_get_post_terms( $context['submission_post_id'], 'platform', ['fields' => 'ids'] ) : 0;
|
||||
$platform_term = $context['submission_post_id'] != 0 ? wp_get_post_terms( $context['submission_post_id'], Taxonomies::PLATFORM->value , ['fields' => 'ids'] ) : 0;
|
||||
$context['value_platform_id'] = $platform_term != 0 && !empty( $platform_term ) ? $platform_term[0] : '';
|
||||
|
||||
return $context;
|
||||
@@ -243,18 +248,18 @@ class Submissions extends Abstract_Extender {
|
||||
|
||||
protected function add_and_format_hashes( &$context )
|
||||
{
|
||||
$context['value_hashes'] = $context['submission_post_id'] != 0 ? esc_textarea( get_post_meta( $context['submission_post_id'], 'hashes', true ) ) : '';
|
||||
$context['value_hashes'] = $context['submission_post_id'] != 0 ? esc_textarea( get_post_meta( $context['submission_post_id'], Post_Fields::HASHES->value, true ) ) : '';
|
||||
return $context;
|
||||
}
|
||||
|
||||
protected function add_and_format_genre( &$context ){
|
||||
|
||||
$context['terms_genre'] = \Timber\Timber::get_terms([
|
||||
'taxonomy' => 'genre',
|
||||
'taxonomy' => Taxonomies::GENRE->value,
|
||||
'hide_empty' => false,
|
||||
]);
|
||||
|
||||
$genre_term = $context['submission_post_id'] != 0 ? wp_get_post_terms( $context['submission_post_id'], 'genre', ['fields' => 'ids'] ) : 0;
|
||||
$genre_term = $context['submission_post_id'] != 0 ? wp_get_post_terms( $context['submission_post_id'], Taxonomies::GENRE->value, ['fields' => 'ids'] ) : 0;
|
||||
$context['value_genre_id'] = $genre_term != 0 && !empty( $genre_term ) ? $genre_term[0] : '';
|
||||
|
||||
return $context;
|
||||
@@ -262,11 +267,11 @@ class Submissions extends Abstract_Extender {
|
||||
|
||||
protected function add_and_format_status( &$context ){
|
||||
|
||||
$context['list_status'] = \Timber\Timber::get_terms([
|
||||
'taxonomy' => 'hack-status',
|
||||
$context['terms_status'] = \Timber\Timber::get_terms([
|
||||
'taxonomy' => Taxonomies::STATUS->value,
|
||||
'hide_empty' => false,
|
||||
]);
|
||||
$context['value_terms_status'] = $context['submission_post_id'] != 0 ? wp_get_post_terms( $context['submission_post_id'], 'hack-status', [ 'fields' => 'ids' ] ) |> $this->test_terms_array(...) : [];
|
||||
$context['value_terms_status'] = $context['submission_post_id'] != 0 ? wp_get_post_terms( $context['submission_post_id'], Taxonomies::STATUS->value, [ 'fields' => 'ids' ] ) |> $this->test_terms_array(...) : [];
|
||||
|
||||
return $context;
|
||||
}
|
||||
@@ -282,7 +287,7 @@ class Submissions extends Abstract_Extender {
|
||||
$context['attachments_settings'] = [
|
||||
'post_id' => $context['submission_post_id'] != 0 ? $context['submission_post_id'] : 'new-post',
|
||||
'fields_groups' => "REPLACED",
|
||||
'fields' => [ 'custom_featured_image', 'my_gallery' ],
|
||||
'fields' => [ Post_Fields::MAIN_IMAGE->value, Post_Fields::GALLERY->value ],
|
||||
'submit_value' => __( 'Add Images', 'romhackplaza' ),
|
||||
'updated_message' => __( "Images added!", 'romhackplaza' ),
|
||||
'form' => false
|
||||
@@ -294,18 +299,25 @@ class Submissions extends Abstract_Extender {
|
||||
|
||||
protected function add_and_format_author( &$context ){
|
||||
|
||||
$context['value_authors'] = $context['submission_post_id'] != 0 ? get_the_terms( $context['submission_post_id'], 'author' ) |> $this->test_terms_array(...) : [];
|
||||
$context['value_authors'] = $context['submission_post_id'] != 0 ? get_the_terms( $context['submission_post_id'], Taxonomies::AUTHORS->value ) |> $this->test_terms_array(...) : [];
|
||||
return $context;
|
||||
|
||||
}
|
||||
|
||||
protected function add_and_format_credits( &$context ){
|
||||
|
||||
$context['value_credits'] = $context['submission_post_id'] != 0 ? esc_textarea( get_post_meta( $context['submission_post_id'], 'staff', true ) ) : '';
|
||||
$context['value_credits'] = $context['submission_post_id'] != 0 ? esc_textarea( get_post_meta( $context['submission_post_id'], Post_Fields::STAFF_CREDITS->value, true ) ) : '';
|
||||
return $context;
|
||||
|
||||
}
|
||||
|
||||
protected function add_and_format_extra_links( &$context ){
|
||||
|
||||
$context['value_release_site'] = $context['submission_post_id'] != 0 ? esc_attr( get_post_meta( $context['submission_post_id'], Post_Fields::RELEASE_SITE->value, true ) ) : '';
|
||||
$context['value_youtube_video'] = $context['submission_post_id'] != 0 ? esc_attr( get_post_meta( $context['submission_post_id'], Post_Fields::YOUTUBE_VIDEO->value, true ) ) : '';
|
||||
return $context;
|
||||
}
|
||||
|
||||
public function fill_fields_for_timber( $context ){
|
||||
|
||||
global $post;
|
||||
@@ -362,17 +374,17 @@ class Submissions extends Abstract_Extender {
|
||||
$context['entry_title_field_name'] = __( "Name:", "romhackplaza" );
|
||||
|
||||
// Entry title value.
|
||||
$context['value_entry_title'] = $context['submission_post_id'] != 0 ? esc_attr( get_post_meta( $context['submission_post_id'], 'entry_title', true ) ) : "";
|
||||
$context['value_entry_title'] = $context['submission_post_id'] != 0 ? esc_attr( get_post_meta( $context['submission_post_id'], Post_Fields::ENTRY_TITLE->value, true ) ) : "";
|
||||
|
||||
// Patch version label.
|
||||
$context['version_number_field_name'] = __( "Version:", "romhackplaza" );
|
||||
|
||||
// Patch version value
|
||||
$context['value_version_number'] = $context['submission_post_id'] != 0 ? esc_attr( get_post_meta( $context['submission_post_id'], 'versionNumber', true ) ) : "";
|
||||
$context['value_version_number'] = $context['submission_post_id'] != 0 ? esc_attr( get_post_meta( $context['submission_post_id'], Post_Fields::VERSION_NUMBER->value, true ) ) : "";
|
||||
|
||||
// Release date value
|
||||
$context['value_release_date'] = "";
|
||||
$release_date = $context['submission_post_id'] != 0 ? get_post_meta( $context['submission_post_id'], 'release_date', true ) : false;
|
||||
$release_date = $context['submission_post_id'] != 0 ? get_post_meta( $context['submission_post_id'], Post_Fields::LAST_UPDATED->value, true ) : false;
|
||||
if( $release_date ) {
|
||||
$date = \DateTime::createFromFormat( 'Ymd', $release_date );
|
||||
if( $date )
|
||||
@@ -394,6 +406,8 @@ class Submissions extends Abstract_Extender {
|
||||
'quicktags' => array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close'),
|
||||
];
|
||||
|
||||
$context['submission_save_as_draft_checkbox'] = $context['submission_post_id'] != 0 && get_post_status($context['submission_post_id']) === 'draft';
|
||||
|
||||
$post_type_rhpz_obj = null;
|
||||
|
||||
if( str_contains( $post->post_name, 'translation' ) ){
|
||||
@@ -411,6 +425,7 @@ class Submissions extends Abstract_Extender {
|
||||
$context = $this->add_and_format_main_image_gallery( $context );
|
||||
$context = $this->add_and_format_author( $context );
|
||||
$context = $this->add_and_format_credits( $context );
|
||||
$context = $this->add_and_format_extra_links( $context );
|
||||
|
||||
}
|
||||
|
||||
@@ -456,6 +471,10 @@ class Submissions extends Abstract_Extender {
|
||||
|
||||
}
|
||||
|
||||
new Modal(
|
||||
'submissions', "", ""
|
||||
)->render();
|
||||
|
||||
return $context;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user