| Server IP : 38.190.208.107 / Your IP : 216.73.217.46 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : root ( 0) PHP Version : 8.2.28 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/wp.10/wp-content/plugins/clarity-seo/ |
Upload File : |
<?php
/*
Plugin Name: Clarity SEO
Description: Adds unique meta tags and Schema.org markup per page, with automatic pre-filling, sitemap and robots.txt. Now with expanded features to outperform competitors: 20+ schema types, advanced redirections, image SEO, local SEO, keyword tracking, and more.
Version: 2.2.3
Author: PluginJoy
Author URI: https://pluginjoy.com
Contributors: aacers
License: GPL v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: clarity-seo
*/
// Prevent direct access
if (!defined('ABSPATH')) {
exit;
}
// Include all files (added new ones for expansions)
require_once plugin_dir_path(__FILE__) . 'includes/metabox.php';
require_once plugin_dir_path(__FILE__) . 'includes/schema.php';
require_once plugin_dir_path(__FILE__) . 'includes/sitemap.php';
require_once plugin_dir_path(__FILE__) . 'includes/settings.php';
require_once plugin_dir_path(__FILE__) . 'includes/audit.php';
require_once plugin_dir_path(__FILE__) . 'includes/gsc.php';
require_once plugin_dir_path(__FILE__) . 'includes/redirections.php'; // New: Advanced redirections
require_once plugin_dir_path(__FILE__) . 'includes/image-seo.php'; // New: Image SEO
require_once plugin_dir_path(__FILE__) . 'includes/local-seo.php'; // New: Local SEO
require_once plugin_dir_path(__FILE__) . 'includes/tracking.php'; // New: Keyword tracking & reports
require_once plugin_dir_path(__FILE__) . 'includes/breadcrumbs.php'; // New: Breadcrumbs
require_once plugin_dir_path(__FILE__) . 'includes/setup-wizard.php'; // New: Setup wizard
require_once plugin_dir_path(__FILE__) . 'includes/import-export.php'; // New: Import from other plugins
// Enqueue admin scripts (expanded for new features)
function clarity_seo_enqueue_scripts($hook) {
if (!in_array($hook, ['post.php', 'post-new.php', 'tools.php', 'clarity-seo-page'])) { // Added for wizard/404 log
return;
}
wp_enqueue_script(
'clarity-seo-admin',
plugin_dir_url(__FILE__) . 'includes/admin.js',
['wp-edit-post', 'wp-element', 'wp-components', 'wp-data'],
'2.2',
true
);
wp_localize_script('clarity-seo-admin', 'clarity_seo_admin_data', [
'siteTitle' => get_bloginfo('name'),
'siteDescription' => get_bloginfo('description'),
'defaultKeywords' => get_option('clarity_seo_default_keywords', 'seo, schema, optimization, wordpress'),
'defaultOgImage' => get_option('clarity_seo_default_og_image', ''),
'organizationDescription' => get_option('clarity_seo_organization_description', get_bloginfo('description')),
// New: For trends integration in metabox
'googleTrendsApi' => 'https://trends.google.com/trends/api/', // Placeholder; user needs key for full
]);
}
add_action('admin_enqueue_scripts', 'clarity_seo_enqueue_scripts');
// Add meta tags to <head> for each page
function clarity_seo_add_meta_tags() {
if (is_singular()) {
global $post;
$meta_title = get_post_meta($post->ID, '_clarity_seo_meta_title', true);
$meta_description = get_post_meta($post->ID, '_clarity_seo_meta_description', true);
$meta_keywords = get_post_meta($post->ID, '_clarity_seo_meta_keywords', true);
$og_image = get_post_meta($post->ID, '_clarity_seo_og_image', true);
$focus_keywords = get_post_meta($post->ID, '_clarity_seo_focus_keywords', true);
// Fallbacks for automatic pre-filling
if (empty($meta_title)) {
$meta_title = get_the_title($post->ID);
if (is_front_page()) {
$meta_title = get_bloginfo('name');
} else {
$meta_title .= ' - ' . get_bloginfo('name');
}
// WooCommerce fallback
if ('product' === $post->post_type) {
$meta_title = get_the_title($post->ID) . ' - Buy Now | ' . get_bloginfo('name');
}
}
if (empty($meta_description)) {
$meta_description = wp_trim_words(get_the_excerpt($post->ID), 25, '...');
if (empty($meta_description) && !empty($post->post_content)) {
$blocks = parse_blocks($post->post_content);
foreach ($blocks as $block) {
if ($block['blockName'] === 'core/paragraph' || $block['blockName'] === 'core/html') {
$content = isset($block['innerContent'][0]) ? $block['innerContent'][0] : $block['attributes']['content'];
if ($content) {
$meta_description = wp_trim_words(wp_strip_all_tags($content), 25, '...');
break;
}
}
}
}
if (empty($meta_description) && is_front_page()) {
$meta_description = get_bloginfo('description');
}
// WooCommerce fallback
if ('product' === $post->post_type && empty($meta_description)) {
$meta_description = wp_trim_words(get_post_meta($post->ID, '_yoast_wpseo_metadesc', true) ?: $post->post_excerpt, 25, '...');
}
}
if (empty($meta_keywords)) {
$meta_keywords = get_option('clarity_seo_default_keywords', 'seo, schema, optimization, wordpress');
if (!is_front_page()) {
$meta_keywords .= ', ' . strtolower(get_the_title($post->ID));
}
// Append focus keywords if set
if (!empty($focus_keywords)) {
$meta_keywords .= ', ' . $focus_keywords;
}
}
if (empty($og_image) && has_post_thumbnail($post->ID)) {
$og_image = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
} elseif (empty($og_image)) {
$og_image = get_option('clarity_seo_default_og_image', '');
}
// Output meta tags
echo '<meta name="description" content="' . esc_attr($meta_description) . '">' . "\n";
echo '<meta name="keywords" content="' . esc_attr($meta_keywords) . '">' . "\n";
echo '<meta name="author" content="' . esc_attr(get_bloginfo('name')) . '">' . "\n";
echo '<meta property="og:title" content="' . esc_attr($meta_title) . '">' . "\n";
echo '<meta property="og:description" content="' . esc_attr($meta_description) . '">' . "\n";
echo '<meta property="og:image" content="' . esc_url($og_image) . '">' . "\n";
echo '<meta property="og:url" content="' . esc_url(get_permalink($post->ID)) . '">' . "\n";
echo '<meta name="twitter:card" content="summary_large_image">' . "\n";
echo '<link rel="canonical" href="' . esc_url(get_permalink($post->ID)) . '">' . "\n";
}
}
add_action('wp_head', 'clarity_seo_add_meta_tags', 1); // Priority 1 to avoid conflicts
// Redirect handling
add_action('template_redirect', 'clarity_seo_handle_redirects');
// New: Add admin pages for expansions
add_action('admin_menu', 'clarity_seo_add_extra_pages');
function clarity_seo_add_extra_pages() {
add_management_page(esc_html__('404 Monitor', 'clarity-seo'), esc_html__('404 Monitor', 'clarity-seo'), 'manage_options', 'clarity-seo-404', 'clarity_seo_404_callback');
add_options_page(esc_html__('SEO Setup Wizard', 'clarity-seo'), esc_html__('SEO Wizard', 'clarity-seo'), 'manage_options', 'clarity-seo-wizard', 'clarity_seo_wizard_callback');
}
// New: Schedule email reports (cron)
add_action('clarity_seo_email_reports', 'clarity_seo_send_email_reports');
if (!wp_next_scheduled('clarity_seo_email_reports')) {
wp_schedule_event(time(), 'weekly', 'clarity_seo_email_reports'); // Weekly like Rank Math free
}