Skip to content
This repository has been archived by the owner on Mar 4, 2018. It is now read-only.

Commit

Permalink
removed post count option for news posts
Browse files Browse the repository at this point in the history
news posts section post count is now referenced from 'posts_per_page'
option in WordPress settings.
  • Loading branch information
zyml committed Dec 21, 2012
1 parent 4ee4e7a commit b40dd71
Showing 1 changed file with 29 additions and 21 deletions.
50 changes: 29 additions & 21 deletions library/classes/postviews-section.php
Expand Up @@ -184,7 +184,8 @@ protected function parse_query_args() {
$_query_args[ 'post_status' ] = 'inherit'; $_query_args[ 'post_status' ] = 'inherit';


// Post Count // Post Count
$_query_args[ 'posts_per_page' ] = $this->settings[ 'count' ]; if ( !$this->settings[ 'use_main_query' ] )
$_query_args[ 'posts_per_page' ] = $this->settings[ 'count' ];


return $_query_args; return $_query_args;


Expand Down Expand Up @@ -455,13 +456,14 @@ public function add_theme_option_fields( $fields ) {
'section' => 'ar2_zone_' . $this->zone->id . '_' . $this->id, 'section' => 'ar2_zone_' . $this->zone->id . '_' . $this->id,
); );


$fields[ 'section-' . $this->id . '-count' ] = array ( if ( !$this->settings[ 'use_main_query' ] )
'setting' => $this->get_field_name( 'count' ), $fields[ 'section-' . $this->id . '-count' ] = array (
'type' => 'dropdown', 'setting' => $this->get_field_name( 'count' ),
'title' => __( 'Post Count', 'ar2' ), 'type' => 'dropdown',
'section' => 'ar2_zone_' . $this->zone->id . '_' . $this->id, 'title' => __( 'Post Count', 'ar2' ),
'options' => apply_filters( 'ar2_post_count_options', array ( 1 => 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ) ), 'section' => 'ar2_zone_' . $this->zone->id . '_' . $this->id,
); 'options' => apply_filters( 'ar2_post_count_options', array ( 1 => 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ) ),
);


return $fields; return $fields;


Expand Down Expand Up @@ -503,11 +505,13 @@ public function customize_register( $wp_customize ) {
'type' => 'option', 'type' => 'option',
'transport' => 'postMessage', 'transport' => 'postMessage',
) ); ) );
$wp_customize->add_setting( $this->get_field_name( 'count' ), array (
'default' => $this->settings[ 'count' ], if ( !$this->settings[ 'use_main_query' ] )
'type' => 'option', $wp_customize->add_setting( $this->get_field_name( 'count' ), array (
'transport' => 'postMessage', 'default' => $this->settings[ 'count' ],
) ); 'type' => 'option',
'transport' => 'postMessage',
) );


// Controls // Controls
$wp_customize->add_control( 'ar2_section-' . $this->id . '-enabled', array ( $wp_customize->add_control( 'ar2_section-' . $this->id . '-enabled', array (
Expand Down Expand Up @@ -536,13 +540,15 @@ public function customize_register( $wp_customize ) {
'post_section' => $this->id, 'post_section' => $this->id,
'taxonomy' => $this->settings[ 'taxonomy' ], 'taxonomy' => $this->settings[ 'taxonomy' ],
) ) ); ) ) );
$wp_customize->add_control( 'ar2_section-' . $this->id . '-count', array (
'settings' => $this->get_field_name( 'count' ), if ( !$this->settings[ 'use_main_query' ] )
'label' => __( 'Post Count', 'ar2' ), $wp_customize->add_control( 'ar2_section-' . $this->id . '-count', array (
'type' => 'select', 'settings' => $this->get_field_name( 'count' ),
'section' => 'ar2_section_' . $this->id, 'label' => __( 'Post Count', 'ar2' ),
'choices' => apply_filters( 'ar2_post_count_options', array ( 1 => 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ) ), 'type' => 'select',
) ); 'section' => 'ar2_section_' . $this->id,
'choices' => apply_filters( 'ar2_post_count_options', array ( 1 => 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ) ),
) );


if ( $wp_customize->is_preview() && !is_admin() ) { if ( $wp_customize->is_preview() && !is_admin() ) {
add_action( 'wp_footer', array( $this, 'do_customize_preview_js' ), 30 ); add_action( 'wp_footer', array( $this, 'do_customize_preview_js' ), 30 );
Expand Down Expand Up @@ -685,7 +691,9 @@ public function validate( $output, $input, $defaults ) {
$output[ 'sections' ][ $this->id ][ 'taxonomy' ] = ( isset( $input[ 'sections' ][ $this->id ][ 'taxonomy' ] ) && taxonomy_exists( $input[ 'sections' ][ $this->id ][ 'taxonomy' ] ) ? $input[ 'sections' ][ $this->id ][ 'taxonomy' ] : $defaults[ 'sections' ][ $this->id ][ 'taxonomy' ] ); $output[ 'sections' ][ $this->id ][ 'taxonomy' ] = ( isset( $input[ 'sections' ][ $this->id ][ 'taxonomy' ] ) && taxonomy_exists( $input[ 'sections' ][ $this->id ][ 'taxonomy' ] ) ? $input[ 'sections' ][ $this->id ][ 'taxonomy' ] : $defaults[ 'sections' ][ $this->id ][ 'taxonomy' ] );
$output[ 'sections' ][ $this->id ][ 'terms' ] = isset( $input[ 'sections' ][ $this->id ][ 'terms' ] ) ? ar2_theme_options_validate_terms_input( $input[ 'sections' ][ $this->id ][ 'terms' ] ) : $defaults[ 'sections' ][ $this->id ][ 'terms' ]; $output[ 'sections' ][ $this->id ][ 'terms' ] = isset( $input[ 'sections' ][ $this->id ][ 'terms' ] ) ? ar2_theme_options_validate_terms_input( $input[ 'sections' ][ $this->id ][ 'terms' ] ) : $defaults[ 'sections' ][ $this->id ][ 'terms' ];
$output[ 'sections' ][ $this->id ][ 'type' ] = ( isset( $input[ 'sections' ][ $this->id ][ 'type' ] ) && in_array( $input[ 'sections' ][ $this->id ][ 'type' ], array_keys( $this->list_display_types() ) ) ? $input[ 'sections' ][ $this->id ][ 'type' ] : $defaults[ 'sections' ][ $this->id ][ 'type' ] ); $output[ 'sections' ][ $this->id ][ 'type' ] = ( isset( $input[ 'sections' ][ $this->id ][ 'type' ] ) && in_array( $input[ 'sections' ][ $this->id ][ 'type' ], array_keys( $this->list_display_types() ) ) ? $input[ 'sections' ][ $this->id ][ 'type' ] : $defaults[ 'sections' ][ $this->id ][ 'type' ] );
$output[ 'sections' ][ $this->id ][ 'count' ] = ( isset( $input[ 'sections' ][ $this->id ][ 'count' ] ) && is_numeric( $input[ 'sections' ][ $this->id ][ 'count' ] ) ? absint( $input[ 'sections' ][ $this->id ][ 'count' ] ) : $defaults[ 'sections' ][ $this->id ][ 'count' ] );
if ( !$this->settings[ 'use_main_query' ] )
$output[ 'sections' ][ $this->id ][ 'count' ] = ( isset( $input[ 'sections' ][ $this->id ][ 'count' ] ) && is_numeric( $input[ 'sections' ][ $this->id ][ 'count' ] ) ? absint( $input[ 'sections' ][ $this->id ][ 'count' ] ) : $defaults[ 'sections' ][ $this->id ][ 'count' ] );


return $output; return $output;


Expand Down

0 comments on commit b40dd71

Please sign in to comment.