| 1 |
<?php |
| 2 |
// If this file is called directly, abort. |
| 3 |
if (!defined('ABSPATH')) { |
| 4 |
exit; |
| 5 |
} |
| 6 |
|
| 7 |
|
| 8 |
/** |
| 9 |
* Instant Indexing API of Google Console page contents. |
| 10 |
* |
| 11 |
* Expects the following variable to be set before include: |
| 12 |
* $is_configured - bool, whether Google service account is configured |
| 13 |
* |
| 14 |
* @package Google Instant Indexing |
| 15 |
*/ |
| 16 |
?> |
| 17 |
|
| 18 |
<?php if (!$is_configured) { ?> |
| 19 |
<div class="dashboard-card"> |
| 20 |
<h2>Configuration Required</h2> |
| 21 |
<p class="description" style="color: var(--dashboard-text-secondary); font-size: 16px; line-height: 1.6;"> |
| 22 |
<?php |
| 23 |
echo wp_kses_post( |
| 24 |
sprintf( |
| 25 |
'Please goto the %s page to configure the Google Instant Indexing.', |
| 26 |
'<a href="' . esc_url(admin_url('admin.php?page=' . Metasync_Admin::$page_slug . '-seo-controls')) . '" style="color: var(--dashboard-accent);">Indexation Control</a>' |
| 27 |
) |
| 28 |
); |
| 29 |
?> |
| 30 |
</p> |
| 31 |
</div> |
| 32 |
<?php return; |
| 33 |
} ?> |
| 34 |
|
| 35 |
<?php |
| 36 |
$get_data = metasync_sanitize_input_array($_GET); |
| 37 |
$urls = home_url('/'); |
| 38 |
if (isset($get_data['posturl'])) { |
| 39 |
$urls = esc_url_raw(wp_unslash($get_data['posturl'])); |
| 40 |
} |
| 41 |
|
| 42 |
$action = 'update'; |
| 43 |
if (isset($get_data['postaction'])) { |
| 44 |
$action = sanitize_title(wp_unslash($get_data['postaction'])); |
| 45 |
} |
| 46 |
|
| 47 |
?> |
| 48 |
<form id="metasync-giapi-form" class="wpform" method="post"> |
| 49 |
<div class="dashboard-card"> |
| 50 |
<h2>URL Configuration</h2> |
| 51 |
<p style="color: var(--dashboard-text-secondary); margin-bottom: 20px;">Enter the URLs you want to index with Google.</p> |
| 52 |
|
| 53 |
<table class="form-table"> |
| 54 |
<tr valign="top"> |
| 55 |
<th scope="row"> |
| 56 |
URL for Indexing: |
| 57 |
</th> |
| 58 |
<td> |
| 59 |
<textarea name="url" id="metasync-giapi-url" class="wide-text" rows="4"><?php echo esc_textarea($urls); ?></textarea> |
| 60 |
<br> |
| 61 |
<p class="description" style="color: var(--dashboard-text-secondary);">URL up to 100 for Google</p> |
| 62 |
</td> |
| 63 |
</tr> |
| 64 |
</table> |
| 65 |
</div> |
| 66 |
|
| 67 |
<div class="dashboard-card"> |
| 68 |
<h2>Indexing Actions</h2> |
| 69 |
<p style="color: var(--dashboard-text-secondary); margin-bottom: 20px;">Choose the action you want to perform on the URLs.</p> |
| 70 |
|
| 71 |
<table class="form-table"> |
| 72 |
<tr valign="top"> |
| 73 |
<th scope="row"> |
| 74 |
Actions of Indexing: |
| 75 |
</th> |
| 76 |
<td> |
| 77 |
<div style="display: flex; flex-direction: column; gap: 12px;"> |
| 78 |
<label style="display: flex; align-items: center; gap: 8px; color: var(--dashboard-text-primary);"> |
| 79 |
<input type="radio" name="metasync_api_action" value="update" class="metasync-giapi-action" <?php checked($action, 'update'); ?>> |
| 80 |
Publish URL |
| 81 |
</label> |
| 82 |
<label style="display: flex; align-items: center; gap: 8px; color: var(--dashboard-text-primary);"> |
| 83 |
<input type="radio" name="metasync_api_action" value="status" class="metasync-giapi-action" <?php checked($action, 'status'); ?>> |
| 84 |
URL status |
| 85 |
</label> |
| 86 |
<label style="display: flex; align-items: center; gap: 8px; color: var(--dashboard-text-primary);"> |
| 87 |
<input type="radio" name="metasync_api_action" value="remove" class="metasync-giapi-action" <?php checked($action, 'remove'); ?>> |
| 88 |
Remove URL |
| 89 |
</label> |
| 90 |
</div> |
| 91 |
</td> |
| 92 |
</tr> |
| 93 |
</table> |
| 94 |
</div> |
| 95 |
|
| 96 |
<div class="dashboard-card"> |
| 97 |
<h2>Execute Action</h2> |
| 98 |
<p style="color: var(--dashboard-text-secondary); margin-bottom: 20px;">Send your request to Google's Indexing API.</p> |
| 99 |
<button type="button" id="metasync-btn-send" name="metasync-btn-send" class="button button-primary"> |
| 100 |
<span class="dashicons dashicons-upload" style="margin-top:3px;font-size:15px;width:15px;height:15px;"></span> Send URL |
| 101 |
</button> |
| 102 |
</div> |
| 103 |
</form> |
| 104 |
|
| 105 |
<div class="dashboard-card" id="metasync-giapi-response" style="display: none;"> |
| 106 |
<h2>API Response</h2> |
| 107 |
<div class="result-wrapper" style="background: rgba(255, 255, 255, 0.05); border-radius: 8px; padding: 20px; margin-top: 16px;"> |
| 108 |
<code class="result-action" style="color: var(--dashboard-accent); font-weight: 600;"></code> |
| 109 |
<h4 class="result-status-code" style="color: var(--dashboard-text-primary); margin: 12px 0;"></h4> |
| 110 |
<p class="result-message" style="color: var(--dashboard-text-secondary);"></p> |
| 111 |
</div> |
| 112 |
</div> |