array( 'name' => __( 'wpLingua - Translations', 'wplingua' ), 'singular_name' => __( 'wpLingua - Translation', 'wplingua' ), 'all_items' => __( 'wpLingua - All translations', 'wplingua' ), 'edit_item' => __( 'wpLingua - Edit translation', 'wplingua' ), 'menu_name' => __( 'Translations', 'wplingua' ), 'search_items' => __( 'Search translations', 'wplingua' ), ), 'public' => false, 'publicly_queryable' => false, 'show_ui' => true, 'exclude_from_search' => true, 'show_in_nav_menus' => false, 'show_in_menu' => false, 'has_archive' => false, 'rewrite' => false, 'menu_icon' => 'dashicons-translation', 'supports' => array( 'title', ), 'capability_type' => 'post', 'capabilities' => array( 'create_posts' => false, ), 'map_meta_cap' => true, ) ); } /** * Remove quick edit on wpLingua translations list * * This function is a filter that removes the Quick Edit link on the wpLingua * translations list in the WordPress admin area. * * @param array $actions An array of row action links. * @param object $post The post object. * @return array The modified array of row action links. */ function wplng_translation_remove_quick_edit( $actions, $post ) { // Check that the post type is a wpLingua translation if ( $post->post_type !== 'wplng_translation' ) { return $actions; } unset( $actions['view'] ); unset( $actions['inline hide-if-no-js'] ); return $actions; } /** * Display 100 translations by default in admin area * * @param mixed $result * @return mixed */ function wplng_translation_per_page( $result ) { if ( false === $result ) { $result = '100'; } return $result; } /** * Filters the query for the 'wplng_translation' post type in the WordPress admin area. * * This function modifies the main query in the admin area to include a meta query * that filters posts of type 'wplng_translation' based on the meta key * 'wplng_translation_original_language_id'. Only posts where this meta key matches * the current website's language ID (retrieved via `wplng_get_language_website_id()`) * will be included in the results. * * @param WP_Query $query The current query instance. * @return void */ function wplng_filter_wplng_translation_posts( $query ) { // Check if we are in the admin area, working with the main query, // and the post type is 'wplng_translation'. if ( is_admin() && $query->is_main_query() && $query->get( 'post_type' ) === 'wplng_translation' ) { $query->set( 'meta_query', array( array( 'key' => 'wplng_translation_original_language_id', 'value' => wplng_get_language_website_id(), 'compare' => '=', ), ) ); } } /** * Filter translations by status: Display option on CPT list * * @return void */ function wplng_restrict_manage_posts_translation_status() { if ( empty( $_GET['post_type'] ) || 'wplng_translation' !== $_GET['post_type'] ) { return; } $languages_target = wplng_get_languages_target_ids(); $options = array(); $translation_status = ''; if ( ! empty( $_GET['translation_status'] ) ) { $translation_status = sanitize_title( $_GET['translation_status'] ); } if ( count( $languages_target ) === 1 ) { $options = array( '' => __( 'All translation status', 'wplingua' ), 'reviewed' => __( 'Reviewed', 'wplingua' ), 'unreviewed' => __( 'Unreviewed', 'wplingua' ), ); } else { $options = array( '' => __( 'All translation status', 'wplingua' ), 'full-reviewed' => __( 'Full reviewed', 'wplingua' ), 'partially-reviewed' => __( 'Partially reviewed', 'wplingua' ), 'reviewed' => __( 'Reviewed', 'wplingua' ), 'unreviewed' => __( 'Full unreviewed', 'wplingua' ), ); } $html = '