diff options
author | Anthony G. Basile <blueness@gentoo.org> | 2016-08-23 20:02:23 -0400 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2016-08-23 20:02:50 -0400 |
commit | ad3f35663e4e2b80a92166b590d3e2052b5aab91 (patch) | |
tree | 94f987efbdb50e1426956c1c04ac459a19c77e53 /plugins/jetpack/modules/infinite-scroll/infinity.php | |
parent | bin/update-wordpress: also update twentyfourteen twentyfifteen twentysixteen (diff) | |
download | blogs-gentoo-ad3f35663e4e2b80a92166b590d3e2052b5aab91.tar.gz blogs-gentoo-ad3f35663e4e2b80a92166b590d3e2052b5aab91.tar.bz2 blogs-gentoo-ad3f35663e4e2b80a92166b590d3e2052b5aab91.zip |
Update plugin jetpack to 4.2.2
Diffstat (limited to 'plugins/jetpack/modules/infinite-scroll/infinity.php')
-rw-r--r-- | plugins/jetpack/modules/infinite-scroll/infinity.php | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/plugins/jetpack/modules/infinite-scroll/infinity.php b/plugins/jetpack/modules/infinite-scroll/infinity.php index 0aba8d22..c4810fbe 100644 --- a/plugins/jetpack/modules/infinite-scroll/infinity.php +++ b/plugins/jetpack/modules/infinite-scroll/infinity.php @@ -255,7 +255,7 @@ class The_Neverending_Home_Page { self::$settings = apply_filters( 'infinite_scroll_settings', $settings ); } - /** This filter is documented in modules/infinite-scroll/infinity.php */ + /** This filter is already documented in modules/infinite-scroll/infinity.php */ return (object) apply_filters( 'infinite_scroll_settings', self::$settings ); } @@ -300,7 +300,12 @@ class The_Neverending_Home_Page { * Is this guaranteed to be the last batch of posts? */ static function is_last_batch() { - return (bool) ( count( self::wp_query()->posts ) < self::get_settings()->posts_per_page ); + $post_type = get_post_type(); + $entries = wp_count_posts( empty( $post_type ) ? 'post' : $post_type )->publish; + if ( self::wp_query()->get( 'paged' ) && self::wp_query()->get( 'paged' ) > 1 ) { + $entries -= self::get_settings()->posts_per_page * self::wp_query()->get( 'paged' ); + } + return $entries <= self::get_settings()->posts_per_page; } /** @@ -369,18 +374,25 @@ class The_Neverending_Home_Page { if ( empty( $id ) ) return; + // Add our scripts. + wp_register_script( 'the-neverending-homepage', plugins_url( 'infinity.js', __FILE__ ), array( 'jquery' ), '4.0.0', true ); + + // Add our default styles. + wp_register_style( 'the-neverending-homepage', plugins_url( 'infinity.css', __FILE__ ), array(), '20140422' ); + // Make sure there are enough posts for IS - if ( 'click' == self::get_settings()->type && self::is_last_batch() ) + if ( self::is_last_batch() ) { return; + } // Add a class to the body. add_filter( 'body_class', array( $this, 'body_class' ) ); // Add our scripts. - wp_enqueue_script( 'the-neverending-homepage', plugins_url( 'infinity.js', __FILE__ ), array( 'jquery' ), '4.0.0', true ); + wp_enqueue_script( 'the-neverending-homepage' ); // Add our default styles. - wp_enqueue_style( 'the-neverending-homepage', plugins_url( 'infinity.css', __FILE__ ), array(), '20140422' ); + wp_enqueue_style( 'the-neverending-homepage' ); add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_spinner_scripts' ) ); @@ -735,6 +747,7 @@ class The_Neverending_Home_Page { } } } + unset( $post_type ); // Base JS settings @@ -1429,7 +1442,7 @@ class The_Neverending_Home_Page { */ private function default_footer() { $credits = sprintf( - '<a href="http://wordpress.org/" target="_blank" rel="generator">%1$s</a> ', + '<a href="https://wordpress.org/" target="_blank" rel="generator">%1$s</a> ', __( 'Proudly powered by WordPress', 'jetpack' ) ); $credits .= sprintf( |