admin->screens(); $amem_edit_screens = amem()->admin->edit_screens(); if ( in_array( $screen->id, $amem_screens, true ) ) { add_action( 'in_admin_header', array( $this, 'after_in_admin_header' ) ); return; } if ( isset( $screen->post_type ) && $screen->post_type === $this->post_type ) { // add_action( 'restrict_manage_posts', array( $this, 'add_custom_meta_filter_dropdown'), 10 ); add_filter( 'pre_get_posts', array( $this, 'type_filter'), 10, 1); } } /** * Add form type filter * * @since 1.0.0 */ function add_custom_meta_filter_dropdown() { global $typenow; // 특정 포스트 타입에 대해서만 필터링 옵션 추가 (예: 'post', 'page' 등) if ($typenow === 'amem-form') { ?> 'select_type', 'value' => sanitize_key($_REQUEST['form_type']), // phpcs:disable WordPress.Security.NonceVerification -- already verified by ACF 'compare' => '=', ); // 메타 쿼리를 설정하여 사용자 목록을 필터링합니다. $query->set('meta_query', array($meta_query)); } return $query; } /** * Admin 목록 에 column 추가 * * @since 1.0.0 * * @param array $columns The columns array. * @return array */ public function admin_table_columns( $_columns ) { // Set the "no found" label to be our custom HTML for no results. if ( empty( acf_request_arg( 's' ) ) ) { global $wp_post_types; $this->not_found_label = $wp_post_types[ $this->post_type ]->labels->not_found; $wp_post_types[ $this->post_type ]->labels->not_found = $this->get_not_found_html(); } $columns = array( 'cb' => $_columns['cb'], 'title' => $_columns['title'], 'amem-id' => __( 'ID', 'advanced-members' ), 'amem-field_group' => __( 'Field Group', 'advanced-members' ), 'amem-type' => __( 'Type', 'advanced-members' ), 'amem-shortcode' => __( 'Shortcode', 'advanced-members' ), ); return $columns; } /** * Admin 목록 추가된 column 의 값 * * @since 1.0.0 * * @param string $column_name The name of the column to display. * @param array $form_id Form ID. */ public function admin_table_columns_html( $column_name, $form_id ) { switch ( $column_name ) { case 'amem-id': echo esc_html($form_id); break; case 'amem-field_group': $form = amem_get_form( $form_id ); $field_groups = amem_get_form_field_groups( $form['key'] ); if( empty( $field_groups ) ){ esc_html_e('No connected field groups' , 'advanced-members'); }else{ foreach ( $field_groups as $key => $field_group ) { echo sprintf('%3$s%2$s', esc_url( get_edit_post_link( $field_group['ID'] ) ), esc_html($field_group['title']), $key > 0 ? ' ,' : '' ); } } break; case 'amem-type': $amem_types = amem_form_types('core'); $type = get_post_meta( $form_id, 'select_type', true ); echo ( isset($amem_types[$type]) ? esc_html($amem_types[$type]) : '' ); if( $regist_role = get_post_meta( $form_id, 'regist_role', true ) ){ echo sprintf('[%s]', esc_html(amem_get_role_label($regist_role)) ); } break; case 'amem-shortcode': $code = sprintf( '[advanced-members form="%s"]', esc_attr($form_id) ); echo '' . esc_html($code) . ''; break; } } function after_in_admin_header() { global $title, $acf_page_title; $_acf_page_title = $acf_page_title; $acf_page_title = false; // acf_get_view( 'global/navigation' ); $acf_page_title = $_acf_page_title; $screen = get_current_screen(); $amem_screens = ['acf_page_amem_dashboard', 'acf_page_amem_settings']; if ( in_array( $screen->id, $amem_screens, true ) ) { acf_get_view( 'global/form-top' ); } // do_action( 'acf/in_admin_header' ); do_action( 'amem/in_admin_header' ); } /** * Renders a specific admin table column. * * @since 1.0.0 * * @param string $column_name The name of the column to display. * @param array $post The main ACF post array. * @return void */ public function render_admin_table_column( $column_name, $post ) { switch ( $column_name ) { case 'acf-key': echo ''; echo esc_html( $post['key'] ); break; // Description. case 'acf-description': if ( ( is_string( $post['description'] ) || is_numeric( $post['description'] ) ) && ! empty( $post['description'] ) ) { echo '' . acf_esc_html( $post['description'] ) . '';/* phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped */ } else { echo ''; echo '' . esc_html__( 'No description', 'advanced-members' ) . ''; } break; case 'acf-taxonomies': $this->render_admin_table_column_taxonomies( $post ); break; case 'acf-field-groups': $this->render_admin_table_column_field_groups( $post ); break; case 'acf-count': $this->render_admin_table_column_num_posts( $post ); break; // Local JSON. case 'acf-json': $this->render_admin_table_column_local_status( $post ); break; } } /** * Renders the field groups attached to the post type in the list table. * * @since 1.0.0 * * @param array $post_type The main post type array. * @return void */ public function render_admin_table_column_field_groups( $post_type ) { $field_groups = acf_get_field_groups( array( 'post_type' => $post_type['post_type'] ) ); if ( empty( $field_groups ) ) { echo ''; echo '' . esc_html__( 'No field groups', 'advanced-members' ) . ''; return; } $labels = wp_list_pluck( $field_groups, 'title' ); $limit = 3; $shown_labels = array_slice( $labels, 0, $limit ); $hidden_labels = array_slice( $labels, $limit ); $text = implode( ', ', $shown_labels ); if ( ! empty( $hidden_labels ) ) { $text .= ', +' . count( $hidden_labels ) . ''; } echo acf_esc_html( $text );/* phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped */ } /** * Renders the taxonomies attached to the post type in the list table. * * @since 1.0.0 * * @param array $post_type The main post type array. * @return void */ public function render_admin_table_column_taxonomies( $post_type ) { $taxonomies = array(); $labels = array(); if ( is_array( $post_type['taxonomies'] ) ) { $taxonomies = $post_type['taxonomies']; } $acf_taxonomies = acf_get_internal_post_type_posts( 'acf-taxonomy' ); foreach ( $acf_taxonomies as $acf_taxonomy ) { if ( is_array( $acf_taxonomy['object_type'] ) && in_array( $post_type['post_type'], $acf_taxonomy['object_type'], true ) ) { $taxonomies[] = $acf_taxonomy['taxonomy']; } } $taxonomies = array_unique( $taxonomies ); foreach ( $taxonomies as $tax_slug ) { $taxonomy = get_taxonomy( $tax_slug ); if ( ! is_object( $taxonomy ) || empty( $taxonomy->label ) ) { continue; } $labels[] = $taxonomy->label; } if ( empty( $labels ) ) { echo ''; echo '' . esc_html__( 'No taxonomies', 'advanced-members' ) . ''; return; } $limit = 3; $shown_labels = array_slice( $labels, 0, $limit ); $hidden_labels = array_slice( $labels, $limit ); $text = implode( ', ', $shown_labels ); if ( ! empty( $hidden_labels ) ) { $text .= ', +' . count( $hidden_labels ) . ''; } echo acf_esc_html( $text );/* phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped */ } } // Instantiate. Forms::getInstance(); endif; // Class exists check.