* Get how many posts are good, okay, needs improvement or are missing the focus keyphrase for the given post type. * * @since 4.2.0 * * @param string $postType The post type name. * @return array The overview for the given post type. */ public function getPostTypeOverview( $postType ) { $overview = aioseo()->core->cache->get( $postType . '_overview_data' ); if ( null !== $overview ) { return $overview; } $posts = aioseo()->core->db->start( 'posts as p' ) ->select( 'p.ID, ap.seo_score, ap.keyphrases' ) ->leftJoin( 'aioseo_posts as ap', 'ap.post_id = p.ID' ) ->where( 'p.post_status', 'publish' ) ->where( 'p.post_type', $postType ) ->run() ->result(); $overview = [ 'total' => 0, 'needsImprovement' => 0, 'okay' => 0, 'good' => 0, 'withoutFocusKeyphrase' => 0, ]; foreach ( $posts as $post ) { if ( ! aioseo()->helpers->isPageAnalysisEligible( $post->ID ) ) { continue; } $overview['total']++; if ( empty( $post->keyphrases ) || strpos( $post->keyphrases, '{"focus":{"keyphrase":""' ) === 0 ) { $overview['withoutFocusKeyphrase']++; // We skip to the next since we will just consider posts with focus keyphrase in the counts. continue; } if ( 50 > $post->seo_score ) { $overview['needsImprovement']++; continue; } if ( 50 <= $post->seo_score && 80 >= $post->seo_score ) { $overview['okay']++; continue; } if ( 80 < $post->seo_score ) { $overview['good']++; } } aioseo()->core->cache->update( $postType . '_overview_data', $overview, HOUR_IN_SECONDS ); return $overview; } /** * Change the JOIN and WHERE clause to filter just the posts we need to show depending on the query string. * * @since 4.2.0 * * @param array $clauses Associative array of the clauses for the query. * @param \WP_Query $query The WP_Query instance (passed by reference). * @return array The clauses array updated. */ public function changeClausesToFilterPosts( $clauses, $query = null ) { if ( ! is_admin() || ! $query->is_main_query() ) { return $clauses; } $filter = filter_input( INPUT_GET, 'aioseo-filter' ); if ( empty( $filter ) ) { return $clauses; } $whereClause = ''; $noKeyphrasesClause = "(aioseo_p.keyphrases = '' OR aioseo_p.keyphrases IS NULL OR aioseo_p.keyphrases LIKE '{\"focus\":{\"keyphrase\":\"\"%')"; switch ( $filter ) { case 'withoutFocusKeyphrase': $whereClause = " AND $noKeyphrasesClause "; break; case 'needsImprovement': $whereClause = " AND aioseo_p.seo_score < 50 AND NOT $noKeyphrasesClause "; break; case 'okay': $whereClause = " AND aioseo_p.seo_score BETWEEN 50 AND 80 AND NOT $noKeyphrasesClause "; break; case 'good': $whereClause = " AND aioseo_p.seo_score > 80 AND NOT $noKeyphrasesClause "; break; } $prefix = aioseo()->core->db->prefix; $postsTable = aioseo()->core->db->db->posts; $clauses['join'] .= " LEFT JOIN {$prefix}aioseo_posts AS aioseo_p ON ({$postsTable}.ID = aioseo_p.post_id) "; $clauses['where'] .= $whereClause; add_action( 'wp', [ $this, 'filterPostsAfterChangingClauses' ] ); return $clauses; } /** * Filter the posts array to remove the ones that are not eligible for page analysis. * Hooked into `wp` action hook. * * @since 4.7.1 * * @return void */ public function filterPostsAfterChangingClauses() { remove_action( 'wp', [ $this, 'filterPostsAfterChangingClauses' ] ); global $wp_query; if ( ! empty( $wp_query->posts ) && is_array( $wp_query->posts ) ) { $wp_query->posts = array_filter( $wp_query->posts, function ( $post ) { return aioseo()->helpers->isPageAnalysisEligible( $post->ID ); } ); // Update `post_count` for pagination. if ( isset( $wp_query->post_count ) ) { $wp_query->post_count = count( $wp_query->posts ); } } } }
Fatal error: Uncaught Error: Class 'AIOSEO\Plugin\Common\Admin\PostSettings' not found in /home/kordian1/domains/ostrabrama.pl/public_html/wp-content/plugins/all-in-one-seo-pack/app/Lite/Admin/PostSettings.php:16 Stack trace: #0 /home/kordian1/domains/ostrabrama.pl/public_html/wp-content/plugins/all-in-one-seo-pack/vendor/composer/ClassLoader.php(576): include() #1 /home/kordian1/domains/ostrabrama.pl/public_html/wp-content/plugins/all-in-one-seo-pack/vendor/composer/ClassLoader.php(427): Composer\Autoload\{closure}('/home/kordian1/...') #2 [internal function]: Composer\Autoload\ClassLoader->loadClass('AIOSEO\\Plugin\\L...') #3 /home/kordian1/domains/ostrabrama.pl/public_html/wp-content/plugins/all-in-one-seo-pack/app/AIOSEO.php(315): spl_autoload_call('AIOSEO\\Plugin\\L...') #4 /home/kordian1/domains/ostrabrama.pl/public_html/wp-content/plugins/all-in-one-seo-pack/app/AIOSEO.php(97): AIOSEO\Plugin\AIOSEO->load() #5 /home/kordian1/domains/ostrabrama.pl/public_html/wp-content/plugins/all-in-one-seo-pack/app/AIOSEO.php(76): in /home/kordian1/domains/ostrabrama.pl/public_html/wp-content/plugins/all-in-one-seo-pack/app/Lite/Admin/PostSettings.php on line 16