New IDs, finish Submit Translation page and begin BIG TS.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace RomhackPlaza\Extenders;
|
||||
use RomhackPlaza\Identifiers\Post_Fields;
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Discord_Notification extends Abstract_Extender {
|
||||
@@ -12,7 +13,8 @@ class Discord_Notification extends Abstract_Extender {
|
||||
|
||||
protected function extend(): void
|
||||
{
|
||||
$this->add_action( 'RomhackPlaza\\Extenders\\Discord_Notification\\Send_Notification_After_Submission', [ $this, 'send_notification_after_submission' ], 10, 4 );
|
||||
$this->add_action( 'RomhackPlaza\\Extenders\\Discord_Notification\\Send_Notification_After_Submission',
|
||||
[ $this, 'send_notification_after_submission' ], 10, 4 );
|
||||
}
|
||||
|
||||
protected function get_webhook_url( string $type = 'global' ): string {
|
||||
@@ -93,7 +95,7 @@ class Discord_Notification extends Abstract_Extender {
|
||||
if( $webhook == null || $content == null ) return;
|
||||
|
||||
$this->send_to_discord( $webhook, $content );
|
||||
update_post_meta( $post_id, 'discord_noticed', "yes" );
|
||||
update_post_meta( $post_id, Post_Fields::DISCORD_NOTICED->value, "yes" );
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,9 @@ class SubmissionAccordionNode extends Node {
|
||||
case 'team-information':
|
||||
return __('Team Information', 'romhackplaza');
|
||||
break;
|
||||
case 'extra-links':
|
||||
return __( 'Related Links', 'romhackplaza');
|
||||
break;
|
||||
}
|
||||
|
||||
return __( "Unknown", 'romhackplaza' );
|
||||
@@ -51,6 +54,9 @@ class SubmissionAccordionNode extends Node {
|
||||
case 'team-information':
|
||||
return 'fas fa-users';
|
||||
break;
|
||||
case 'extra-links':
|
||||
return 'fas fa-link';
|
||||
break;
|
||||
}
|
||||
|
||||
return 'fas fa-question-circle';
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace RomhackPlaza;
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Identifier {
|
||||
|
||||
const string CAP_EDIT_POSTS = "edit_posts";
|
||||
const string CAP_EDIT_OTHER_POSTS = "edit_others_posts";
|
||||
|
||||
const string CPT_TRANSLATIONS = "translations";
|
||||
const string CPT_ROMHACKS = "romhacks";
|
||||
const string CPT_HOMEBREWS = "homebrew";
|
||||
const string CPT_UTILITIES = "utilities";
|
||||
const string CPT_DOCUMENTS = "documents";
|
||||
const string CPT_LUA_SCRIPTS = "lua-scripts";
|
||||
const string CPT_TUTORIALS = "tutorials";
|
||||
const string CPT_NEWS = "news";
|
||||
const string CPT_REVIEWS = "reviews";
|
||||
|
||||
// ...
|
||||
|
||||
const string TAX_GAME = "game";
|
||||
const string TAX_STATUS = "hack-status";
|
||||
const string TAX_LANG = "language";
|
||||
const string TAX_PLATFORM = "platform";
|
||||
const string TAX_AUTHORS = "author-name";
|
||||
const string TAX_UTILITY_CATEGORY = "utility-category";
|
||||
const string TAX_LEVEL = "experience-level";
|
||||
const string TAX_OS = "utility-os";
|
||||
const string TAX_DOCUMENT_CATEGORY = "document-category";
|
||||
const string TAX_MODIFICATIONS = "modifications";
|
||||
const string TAX_HOMEBREW_TYPE = "homebrew-type";
|
||||
const string TAX_NEWS_CATEGORY = "news-category";
|
||||
const string TAX_GENRE = "genre";
|
||||
const string TAX_TUTORIAL_CATEGORY = "tutorial-category";
|
||||
const string TAX_LUA_MODIFICATIONS = "lua-modifications";
|
||||
|
||||
// ...
|
||||
|
||||
const string ENTRY_GALLERY = "my_gallery";
|
||||
const string ENTRY_MAIN_IMAGE = "custom_featured_image";
|
||||
|
||||
private function __construct() {}
|
||||
|
||||
}
|
||||
13
src/Identifiers/Misc.php
Normal file
13
src/Identifiers/Misc.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace RomhackPlaza\Identifiers;
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
enum Misc: string {
|
||||
|
||||
case PS_LOCKED = 'locked';
|
||||
case CAP_EDIT_POSTS = 'edit_posts';
|
||||
case CAP_EDIT_OTHERS_POSTS = 'edit_others_posts';
|
||||
case CAP_MANAGE_OPTIONS = 'manage_options';
|
||||
|
||||
}
|
||||
19
src/Identifiers/Post_Fields.php
Normal file
19
src/Identifiers/Post_Fields.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace RomhackPlaza\Identifiers;
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
enum Post_Fields: string {
|
||||
|
||||
case DISCORD_NOTICED = 'discord_noticed';
|
||||
case ENTRY_TITLE = 'entry_title';
|
||||
case GALLERY = 'my_gallery';
|
||||
case HASHES = 'hashes';
|
||||
case LAST_UPDATED = 'release_date';
|
||||
case MAIN_IMAGE = 'custom_featured_image';
|
||||
case RELEASE_SITE = 'release_site';
|
||||
case STAFF_CREDITS = 'staff';
|
||||
case VERSION_NUMBER = 'version_number';
|
||||
case YOUTUBE_VIDEO = 'youtube_video';
|
||||
|
||||
}
|
||||
18
src/Identifiers/Post_Types.php
Normal file
18
src/Identifiers/Post_Types.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace RomhackPlaza\Identifiers;
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
enum Post_Types: string {
|
||||
|
||||
case TRANSLATIONS = 'translations';
|
||||
case ROMHACKS = 'romhacks';
|
||||
case HOMEBREWS = 'homebrew';
|
||||
case UTILITIES = 'utilities';
|
||||
case DOCUMENTS = 'documents';
|
||||
case LUA_SCRIPTS = 'lua-scripts';
|
||||
case TUTORIALS = 'tutorials';
|
||||
case NEWS = 'news';
|
||||
case REVIEWS = 'reviews';
|
||||
|
||||
}
|
||||
24
src/Identifiers/Taxonomies.php
Normal file
24
src/Identifiers/Taxonomies.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace RomhackPlaza\Identifiers;
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
enum Taxonomies: string {
|
||||
|
||||
case GAME = 'game';
|
||||
case STATUS = 'hack-status';
|
||||
case LANG = 'language';
|
||||
case PLATFORM = 'platform';
|
||||
case AUTHORS = 'author-name';
|
||||
case UTILITY_CATEGORY = 'utility-category';
|
||||
case LEVEL = 'experience-level';
|
||||
case OS = 'utility-os';
|
||||
case DOCUMENT_CATEGORY = 'document-category';
|
||||
case MODIFICATIONS = 'modifications';
|
||||
case HOMEBREW_TYPE = 'homebrew-type';
|
||||
case NEWS_CATEGORY = 'news-category';
|
||||
case GENRE = 'genre';
|
||||
case TUTORIAL_CATEGORY = 'tutorial-category';
|
||||
case LUA_MODIFICATIONS = 'lua-modifications';
|
||||
|
||||
}
|
||||
@@ -131,4 +131,15 @@ class Script {
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function enable_i18n(): Script {
|
||||
|
||||
if( $this->type == Script_Type::JS ) {
|
||||
$this->deps[] = 'wp-i18n';
|
||||
wp_set_script_translations($this->handle, 'romhackplaza');
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user