| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* MetaSync - Google Index API Settings |
| 5 |
* |
| 6 |
* This view integrates Google Index API settings into MetaSync's general settings |
| 7 |
* |
| 8 |
* @package MetaSync |
| 9 |
* @subpackage GoogleIndexDirect |
| 10 |
* @version 1.0.0 |
| 11 |
*/ |
| 12 |
|
| 13 |
// Prevent direct access |
| 14 |
if (!defined('ABSPATH')) { |
| 15 |
exit; |
| 16 |
} |
| 17 |
|
| 18 |
?> |
| 19 |
|
| 20 |
<div style="padding: 20px;"> |
| 21 |
<!-- Requirements (Collapsible) --> |
| 22 |
<details style="margin-top: 20px; padding-top: 15px;"> |
| 23 |
<summary style="cursor: pointer; font-weight: 600; margin-bottom: 10px;">Requirements</summary> |
| 24 |
<div style="margin-top: 10px;"> |
| 25 |
<ul style="margin-left: 20px;"> |
| 26 |
<li>Google Cloud Project with Indexing API enabled</li> |
| 27 |
<li>Service Account with appropriate permissions</li> |
| 28 |
<li>Domain verified in Google Search Console</li> |
| 29 |
<li>Service account added as user in Search Console</li> |
| 30 |
</ul> |
| 31 |
</div> |
| 32 |
</details> |
| 33 |
|
| 34 |
<!-- Configuration Status --> |
| 35 |
<div style="margin-bottom: 20px;"> |
| 36 |
<?php if ($is_configured): ?> |
| 37 |
<div class="notice notice-success inline" style="margin: 0 0 15px 0; padding: 10px;"> |
| 38 |
<p style="margin: 0;"> |
| 39 |
<strong>Service Account Configured: </strong><br> |
| 40 |
<strong>Email:</strong> <?php echo esc_html($service_info['client_email']); ?><br> |
| 41 |
<strong>Project ID:</strong> <?php echo esc_html($service_info['project_id']); ?> |
| 42 |
</p> |
| 43 |
</div> |
| 44 |
<?php else: ?> |
| 45 |
<div class="notice notice-warning inline" style="margin: 0 0 15px 0; padding: 10px;"> |
| 46 |
<p style="margin: 0;"> |
| 47 |
<strong>Service Account Not Configured</strong><br> |
| 48 |
Please provide your Google service account JSON below. |
| 49 |
</p> |
| 50 |
</div> |
| 51 |
<?php endif; ?> |
| 52 |
</div> |
| 53 |
|
| 54 |
<!-- Settings Fields --> |
| 55 |
<table class="form-table" style="margin-top: 0;"> |
| 56 |
<tr> |
| 57 |
<th scope="row" style="width: 200px;"> |
| 58 |
<label for="google_index_service_account_json">Service Account JSON</label> |
| 59 |
</th> |
| 60 |
<td> |
| 61 |
<textarea name="google_index_service_account_json" |
| 62 |
id="google_index_service_account_json" |
| 63 |
class="large-text code" |
| 64 |
rows="8" |
| 65 |
placeholder="Paste your Google service account JSON here..."><?php |
| 66 |
if ($is_configured && !empty($saved_json_display)) { |
| 67 |
echo esc_textarea($saved_json_display); |
| 68 |
} |
| 69 |
?></textarea> |
| 70 |
<p class="description"> |
| 71 |
<strong>How to get this:</strong><br> |
| 72 |
1. Go to <a href="https://console.cloud.google.com/apis/credentials" target="_blank">Google Cloud Console → Credentials</a><br> |
| 73 |
2. Create or select a Service Account → Generate JSON key<br> |
| 74 |
3. Paste the JSON content above or upload the file below |
| 75 |
</p> |
| 76 |
</td> |
| 77 |
</tr> |
| 78 |
|
| 79 |
<tr> |
| 80 |
<th scope="row"> |
| 81 |
<label for="google_index_service_account_file">Upload JSON File</label> |
| 82 |
</th> |
| 83 |
<td> |
| 84 |
<input type="file" |
| 85 |
name="google_index_service_account_file" |
| 86 |
id="google_index_service_account_file" |
| 87 |
accept=".json" |
| 88 |
class="regular-text" /> |
| 89 |
<p class="description"> |
| 90 |
Upload your service account JSON file. This will auto-populate the textarea above. |
| 91 |
</p> |
| 92 |
</td> |
| 93 |
</tr> |
| 94 |
</table> |
| 95 |
|
| 96 |
<!-- Action Buttons and Test Results --> |
| 97 |
<?php if ($is_configured): ?> |
| 98 |
<div style="margin-top: 20px; padding-top: 15px; border-top: 1px solid #ddd;"> |
| 99 |
<button type="button" |
| 100 |
id="google-index-test-connection" |
| 101 |
class="button button-secondary"> |
| 102 |
<span class="dashicons dashicons-yes" style="margin-top:3px;font-size:15px;width:15px;height:15px;"></span> Test Connection |
| 103 |
</button> |
| 104 |
|
| 105 |
<button type="button" |
| 106 |
id="google-index-clear-config" |
| 107 |
class="button button-link-delete" |
| 108 |
style="margin-left: 10px;"> |
| 109 |
<span class="dashicons dashicons-trash" style="margin-top:3px;font-size:15px;width:15px;height:15px;"></span> Clear Configuration |
| 110 |
</button> |
| 111 |
|
| 112 |
<div id="google-index-test-results" style="margin-top: 15px;"></div> |
| 113 |
</div> |
| 114 |
<?php endif; ?> |
| 115 |
|
| 116 |
</div> |
| 117 |
|
| 118 |
<style> |
| 119 |
/* Additional styles for Google Index API section */ |
| 120 |
#google-index-test-results .notice { |
| 121 |
margin-top: 10px; |
| 122 |
} |
| 123 |
|
| 124 |
#google-index-test-results ul { |
| 125 |
margin-left: 20px; |
| 126 |
} |
| 127 |
|
| 128 |
.metasync-accordion-section details[open] summary { |
| 129 |
margin-bottom: 15px; |
| 130 |
} |
| 131 |
|
| 132 |
.metasync-accordion-section pre { |
| 133 |
font-size: 12px; |
| 134 |
line-height: 1.4; |
| 135 |
} |
| 136 |
|
| 137 |
.metasync-accordion-section .notice.inline { |
| 138 |
display: block; |
| 139 |
} |
| 140 |
</style> |
| 141 |
|
| 142 |
<!-- File upload handling and unsaved changes integration is now handled by the admin JavaScript --> |
| 143 |
|