array( 'name' => __( 'wpLingua - Website slugs', 'wplingua' ), 'singular_name' => __( 'wpLingua - Website slug', 'wplingua' ), 'all_items' => __( 'wpLingua - All slugs', 'wplingua' ), 'edit_item' => __( 'wpLingua - Edit slug', 'wplingua' ), 'menu_name' => __( 'Website slugs', 'wplingua' ), 'search_items' => __( 'Search slugs', '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 slugs list. * * This function is a filter on post_row_actions and is used to remove the * quick edit action from the list of actions on the slugs list page. * * @param array $actions An array of row action links. * @param WP_Post $post The post object. * * @return array */ function wplng_slug_remove_quick_edit( $actions, $post ) { // Check if the post type is 'wplng_slug'. if ( $post->post_type !== 'wplng_slug' ) { return $actions; } unset( $actions['view'] ); unset( $actions['inline hide-if-no-js'] ); return $actions; } /** * Display 100 translations by default in admin area * * This function is a filter on the posts_per_page option and is used to * display 100 translations by default in the admin area. * * @param mixed $result * @return mixed */ function wplng_slug_per_page( $result ) { if ( false === $result ) { $result = '100'; } return $result; } /** * Filters the query for the 'wplng_slug' 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_slug' based on the meta key * 'wplng_slug_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_slug_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_slug' ) { $query->set( 'meta_query', array( array( 'key' => 'wplng_slug_original_language_id', 'value' => wplng_get_language_website_id(), 'compare' => '=', ), ) ); } } /** * Filter slugs by status: Display option on CPT list * * @return void */ function wplng_restrict_manage_posts_slug_status() { // Check if we are on the right post type. if ( empty( $_GET['post_type'] ) || 'wplng_slug' !== $_GET['post_type'] ) { return; } // Get languages target IDs. $languages_target = wplng_get_languages_target_ids(); // Set default options for the select. $options = array( '' => __( 'All slug status', 'wplingua' ), ); // Set slug status value from URL parameter if set. $slug_status = ''; if ( ! empty( $_GET['slug_status'] ) ) { $slug_status = sanitize_title( $_GET['slug_status'] ); } // If only one language target id, then use simple status options. if ( count( $languages_target ) === 1 ) { $options = array_merge( $options, array( 'reviewed' => __( 'Reviewed', 'wplingua' ), 'unreviewed' => __( 'Unreviewed', 'wplingua' ), ) ); } else { // If more than one language target id, // then use full, partially and reviewed status options. $options = array_merge( $options, array( 'full-reviewed' => __( 'Full reviewed', 'wplingua' ), 'partially-reviewed' => __( 'Partially reviewed', 'wplingua' ), 'reviewed' => __( 'Reviewed', 'wplingua' ), 'unreviewed' => __( 'Full unreviewed', 'wplingua' ), ) ); } // Display the select with options. $html = '