admin = $admin;
}
/**
* @param Metasync_Admin $admin
* @return self
*/
public static function get_instance(Metasync_Admin $admin): self
{
if (null === self::$instance || self::$instance->admin !== $admin) {
self::$instance = new self($admin);
}
return self::$instance;
}
// ------------------------------------------------------------------
// Dashboard iframe (~200 lines)
// ------------------------------------------------------------------
public function create_admin_dashboard_iframe()
{
$general_options = Metasync::get_option('general');
$otto_pixel_uuid = isset($general_options['otto_pixel_uuid']) ? $general_options['otto_pixel_uuid'] : '';
$api_key = isset($general_options['searchatlas_api_key']) ? $general_options['searchatlas_api_key'] : '';
$hide_dashboard = $general_options['hide_dashboard_framework'] ?? false;
if ($hide_dashboard) {
?>
admin->is_heartbeat_connected()) {
?>
admin->get_fresh_jwt_token();
if ($jwt_token) {
$jwt_parts = explode('.', $jwt_token);
$jwt_header_info = count($jwt_parts) >= 2 ? 'Valid format (' . count($jwt_parts) . ' parts)' : 'Invalid format';
} else {
}
$public_hash = false;
if ($jwt_token && $otto_pixel_uuid) {
$public_hash = $this->admin->fetch_public_hash($otto_pixel_uuid, $jwt_token);
if ($public_hash) {
} else {
}
} else {
$missing_params = [];
if (empty($jwt_token)) $missing_params[] = 'JWT_TOKEN';
if (empty($otto_pixel_uuid)) $missing_params[] = 'OTTO_UUID';
}
$dashboard_domain = Metasync_Admin::get_effective_dashboard_domain();
if ($public_hash) {
$iframe_url = $dashboard_domain . '/seo-automation-v3/public?uuid=' . urlencode($otto_pixel_uuid)
. '&category=onpage_optimizations&subGroup=page_title&public_hash=' . urlencode($public_hash);
} else {
$iframe_url = $dashboard_domain . '/seo-automation-v3/tasks?uuid=' . urlencode($otto_pixel_uuid) . '&category=All&Embed=True';
if ($jwt_token) {
$iframe_url .= '&jwtToken=' . urlencode($jwt_token) . '&impersonate=1';
} else {
}
}
$iframe_url .= '&source=wordpress-plugin-iframe';
$whitelabel_company_name = Metasync::get_whitelabel_company_name();
if ($whitelabel_company_name) {
$iframe_url .= '&whitelabel=' . urlencode($whitelabel_company_name);
}
$whitelabel_settings = Metasync::get_whitelabel_settings();
$is_whitelabel_domain = !empty($whitelabel_settings['domain']);
?>
admin->render_plugin_header('Dashboard'); ?>
admin->render_navigation_menu('dashboard'); ?>
has_access();
if (isset($_POST['whitelabel_password_submit']) && !$password_validated) {
$password_error = 'Incorrect password. Please try again.';
}
}
$is_authenticated = $password_validated;
$whitelabel_otto_name = Metasync::get_whitelabel_otto_name();
$page_slug = Metasync_Admin::$page_slug;
?>
*/
?>
admin->render_navigation_menu('general'); ?>
đ Protected Section
â Access Denied:
đĄ Security Tip: You can set a custom password in the White Label Settings to protect this section.
â
Success! All plugin settings have been cleared successfully and a new Plugin Auth Token has been generated. Please reconfigure the plugin as needed.
â Error! Failed to clear settings due to a security check failure. Please try again.
â
Success! Error logs have been cleared successfully.
â Error! Failed to clear error logs due to a security check failure. Please try again.
â
Success! Plugin access roles have been saved successfully.
â Error! Failed to save plugin access roles.
disable_other_sitemap_generators();
$result = $sitemap_generator->generate_sitemap();
if (is_wp_error($result)) {
echo '' . esc_html($result->get_error_message()) . '
';
} else {
$message = esc_html__('Sitemap generated successfully!', 'metasync');
if ($disabled_plugins) {
$message .= ' ' . esc_html__('Conflicting sitemap generators have been automatically disabled.', 'metasync');
}
$robots_result = get_transient('metasync_sitemap_robots_updated');
if ($robots_result && $robots_result['success']) {
if ($robots_result['action'] === 'added') {
$message .= ' ' . esc_html__('Sitemap URL has been added to robots.txt.', 'metasync');
} elseif ($robots_result['action'] === 'updated') {
$message .= ' ' . esc_html__('Sitemap URL has been updated in robots.txt.', 'metasync');
} elseif ($robots_result['action'] === 'created') {
$message .= ' ' . esc_html__('robots.txt file has been created with sitemap URL.', 'metasync');
}
delete_transient('metasync_sitemap_robots_updated');
}
echo '' . esc_html($message) . '
';
}
} elseif (isset($_POST['enable_auto_update'])) {
update_option('metasync_sitemap_auto_update', true);
$sitemap_generator->setup_auto_update_hooks();
echo '' . esc_html__('Auto-update enabled!', 'metasync') . '
';
} elseif (isset($_POST['disable_auto_update'])) {
update_option('metasync_sitemap_auto_update', false);
echo '' . esc_html__('Auto-update disabled!', 'metasync') . '
';
} elseif (isset($_POST['delete_sitemap'])) {
$deleted = $sitemap_generator->delete_sitemap();
if ($deleted) {
update_option('metasync_sitemap_auto_update', false);
echo '' . esc_html__('Sitemap deleted successfully!', 'metasync') . '
';
} else {
echo '' . esc_html__('Failed to delete sitemap. The file may not exist or is not writable.', 'metasync') . '
';
}
} elseif (isset($_POST['enable_other_sitemaps'])) {
$enabled_plugins = $sitemap_generator->enable_other_sitemap_generators();
if ($enabled_plugins) {
echo '' . esc_html__('Other sitemap plugins have been re-enabled successfully!', 'metasync') . '
';
} else {
echo '' . esc_html__('No sitemap plugins were found to re-enable.', 'metasync') . '
';
}
}
}
$sitemap_exists = $sitemap_generator->sitemap_exists();
$sitemap_url = $sitemap_generator->get_sitemap_url();
$url_count = $sitemap_generator->count_urls();
$last_generated = $sitemap_generator->get_last_generated_time();
$auto_update_enabled = get_option('metasync_sitemap_auto_update', false);
$active_sitemap_plugins = $sitemap_generator->check_active_sitemap_plugins();
require_once plugin_dir_path(dirname(__FILE__)) . 'views/metasync-xml-sitemap.php';
}
public function create_admin_custom_pages_page()
{
?>
create_admin_plugin_interface();
}
public function create_admin_search_engine_verification_page()
{
$page_slug = Metasync_Admin::$page_slug . '_searchengines-verification';
?>
admin->render_plugin_header('Instant Indexing'); ?>
admin->render_navigation_menu('instant_index'); ?>
show_google_instant_indexing_settings();
?>
admin->render_plugin_header('Google Console'); ?>
admin->render_navigation_menu('google_console'); ?>
show_google_instant_indexing_console();
?>
admin->render_plugin_header('Bing Console'); ?>
admin->render_navigation_menu('bing_console'); ?>
show_bing_instant_indexing_console();
?>
');
settings_fields(Metasync_Admin::option_group);
do_settings_sections($page_slug);
do_settings_sections($site_info_slug);
submit_button();
printf('');
}
public function create_admin_error_logs_page()
{
?>
handle_sync_log_ajax();
return;
}
$page = isset($_GET['paged']) ? max(1, intval($_GET['paged'])) : 1;
$per_page = 10;
$offset = ($page - 1) * $per_page;
$filters = [
'date_range' => isset($_GET['date_range']) ? sanitize_text_field($_GET['date_range']) : '',
'status' => isset($_GET['status']) ? sanitize_text_field($_GET['status']) : '',
];
$date_range = $filters['date_range'];
$wp_now_ts = current_time('timestamp');
$date_from = '';
$date_to = '';
if (!empty($date_range)) {
$date_to = date('Y-m-d H:i:s', $wp_now_ts);
if ($date_range === 'today') {
$start_ts = strtotime('today', $wp_now_ts);
$date_from = date('Y-m-d H:i:s', $start_ts);
} elseif ($date_range === 'yesterday') {
$start_ts = strtotime('yesterday', $wp_now_ts);
$end_ts = strtotime('today', $wp_now_ts) - 1;
$date_from = date('Y-m-d H:i:s', $start_ts);
$date_to = date('Y-m-d H:i:s', $end_ts);
} elseif ($date_range === 'this_week') {
$start_of_week = (int) get_option('start_of_week', 1);
$day_of_week = (int) date('w', $wp_now_ts);
$delta_days = ($day_of_week - $start_of_week + 7) % 7;
$start_ts = strtotime('-' . $delta_days . ' days', strtotime('today', $wp_now_ts));
$date_from = date('Y-m-d H:i:s', $start_ts);
} elseif ($date_range === 'this_month') {
$start_ts = strtotime(date('Y-m-01 00:00:00', $wp_now_ts));
$date_from = date('Y-m-d H:i:s', $start_ts);
} elseif ($date_range === 'all') {
// no bounds
}
}
if (!empty($date_from)) {
$filters['date_from'] = $date_from;
}
if (!empty($date_to)) {
$filters['date_to'] = $date_to;
}
$filters = array_filter($filters);
$sync_records = $sync_db->getAllRecords($per_page, $offset, $filters);
$total_records = $sync_db->get_count($filters);
$total_pages = ceil($total_records / $per_page);
$stats = $sync_db->get_statistics();
?>
Error Logs ');
// $error_log = new Metasync_Error_Logs_Table($this->data_error_log_list);
// $error_log->create_admin_error_log_list_interface();
}
public function create_admin_heartbeat_error_logs_page()
{
?>
diff($ago);
$string = [
'y' => 'year',
'm' => 'month',
'w' => 'week',
'd' => 'day',
'h' => 'hour',
'i' => 'minute',
's' => 'second',
];
foreach ($string as $k => &$v) {
if (isset($diff->$k) && $diff->$k) {
$v = $diff->$k . ' ' . $v . ($diff->$k > 1 ? 's' : '');
} else {
unset($string[$k]);
}
}
if (!$full) $string = array_slice($string, 0, 1);
return $string ? implode(', ', $string) . ' ago' : 'just now';
}
private function build_filter_query_string($filters)
{
$query_parts = [];
foreach ($filters as $key => $value) {
if (!empty($value)) {
$query_parts[] = $key . '=' . urlencode($value);
}
}
return !empty($query_parts) ? '&' . implode('&', $query_parts) : '';
}
private function handle_sync_log_ajax()
{
wp_die();
}
}