Astra_Posts_Structures_Configs
Register Posts Structures Customizer Configurations.
Description
Source
File: inc/modules/posts-structures/customizer/class-astra-posts-structures-configs.php
class Astra_Posts_Structures_Configs extends Astra_Customizer_Config_Base { /** * Excluding some post types with avoiding narrow-width container layout. * * @return array * @since 4.0.0 */ public static function get_narrow_width_exculde_cpts() { return apply_filters( 'astra_exculde_narrow_width_support_posttypes', array( 'product', 'download', 'course', 'lesson', 'tutor_quiz', 'tutor_assignments', 'sfwd-assignment', 'sfwd-essays', 'sfwd-transactions', 'sfwd-certificates', 'sfwd-quiz' ) ); } /** * Register Posts Structures Customizer Configurations. * * @param Array $configurations Astra Customizer Configurations. * @param WP_Customize_Manager $wp_customize instance of WP_Customize_Manager. * @since 4.0.0 * @return Array Astra Customizer Configurations with updated configurations. */ public function register_configuration( $configurations, $wp_customize ) { $post_types = Astra_Posts_Structure_Loader::get_supported_post_types(); if ( ! empty( $post_types ) ) { $_configs = array( array( 'name' => 'section-posts-structure', 'type' => 'section', 'priority' => 69, 'title' => __( 'Custom Post Types', 'astra' ), ), ); $ignore_single_for_posttypes = array( 'post', 'product' ); $ignore_archive_for_posttypes = array( 'post', 'product' ); /** * Individual post types main section. */ foreach ( $post_types as $index => $label ) { $post_type_object = get_post_type_object( $label ); $parent_section = 'section-posts-structure'; if ( 'download' === $label ) { $parent_section = 'section-edd-group'; } if ( 'llms_membership' === $label ) { $parent_section = 'section-lifterlms'; } if ( 'groups' === $label || 'sfwd-topic' === $label || 'sfwd-lessons' === $label || 'sfwd-courses' === $label ) { $parent_section = 'section-learndash'; } $_configs[] = array( 'name' => 'section-posttype-' . $label, 'type' => 'section', 'section' => $parent_section, 'title' => isset( $post_type_object->labels->name ) ? $post_type_object->labels->name : ucfirst( $label ), 'priority' => 69, ); if ( ! in_array( $label, $ignore_archive_for_posttypes ) ) { $_configs[] = array( 'name' => 'archive-posttype-' . $label, 'type' => 'section', 'title' => __( 'Archive', 'astra' ) . ' ' . ucfirst( $label ), 'section' => 'section-posttype-' . $label, 'priority' => 5, ); } if ( ! in_array( $label, $ignore_single_for_posttypes ) ) { $_configs[] = array( 'name' => 'single-posttype-' . $label, 'type' => 'section', 'title' => __( 'Single', 'astra' ) . ' ' . ucfirst( $label ), 'section' => 'section-posttype-' . $label, 'priority' => 10, ); } } $configurations = array_merge( $configurations, $_configs ); } return $configurations; } }
Expand full source code Collapse full source code View on Trac
Changelog
Version | Description |
---|---|
4.0.0 | Introduced. |
Methods
- astra_get_dynamic_section_title — Function to get formatted dynamic cpt section title.
- get_narrow_width_exculde_cpts — Excluding some post types with avoiding narrow-width container layout.
- register_configuration — Register Posts Structures Customizer Configurations.