Changeset 2967453
- Timestamp:
- 09/15/2023 11:04:02 AM (3 years ago)
- Location:
- postpeek
- Files:
-
- 1 added
- 2 edited
-
assets/screenshot-3.png (added)
-
trunk/postpeek.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
postpeek/trunk/postpeek.php
r2967398 r2967453 3 3 /** 4 4 * Plugin Name: PostPeek 5 * Description: PostPeek: Immediate Post Insights, a convenient plugin that adds a direct link to search console stats for each post within your WordPress dashboard.6 * Version: 1. 0.45 * Description: PostPeek: Immediate Post Insights, a convenient plugin that adds a direct link to search console stats for each post. 6 * Version: 1.1.1 7 7 * Tested up to: 6.3 8 8 * Author: Jlil … … 37 37 add_action('admin_menu', array($this, 'postpeek_options_page')); 38 38 add_action('admin_init', array($this, 'postpeek_settings_init')); 39 } 39 40 // Hook the function into the 'admin_bar_menu' action 41 add_action('admin_bar_menu', array($this, 'add_admin_bar_search_console_link'), 999); 42 } 43 44 45 public function add_admin_bar_search_console_link($wp_admin_bar) 46 { 47 // Check if the user has the necessary capabilities. 48 if (!$this->user_has_capability()) { 49 return; 50 } 51 52 // Fetch plugin options 53 $options = get_option('postpeek_options', array()); 54 55 // Determine account type 56 $site_type = isset($options['site_type']) ? $options['site_type'] : 'url_prefix'; 57 58 // Create the resource identifier based on the account type 59 $home_url = home_url(); // Get the full URL 60 $parsed_url = parse_url($home_url); // Parse the URL 61 $host = $parsed_url['host']; // Extract the host component 62 63 // When using [domain_property], must extract only the host, [example.com], not [https://example.com] 64 $resource_id = ($site_type === 'domain_property') ? "sc-domain:$host" : home_url(); 65 66 // Get default_date_period from options, or set it to 7 days if not set 67 $default_date_period = isset($options['default_date_period']) ? $options['default_date_period'] : 'num_of_days=7'; 68 69 // Define the link based on whether the user is in the admin area or the frontend 70 // Determine the URL to point to based on the current page context 71 if (is_admin()) { 72 $page_url = '&page=!' . esc_url($home_url); 73 } elseif (is_home() || is_front_page() || is_search()) { 74 $page_url = '&page=!' . esc_url($home_url); 75 } elseif (is_single() || is_page()) { 76 $page_url = '&page=!' . esc_url(get_permalink()); 77 } elseif (is_category() || is_tag() || is_tax()) { 78 $term = get_queried_object(); 79 $page_url = '&page=!' . esc_url(get_term_link($term)); 80 } else { 81 $page_url = '&page=!' . esc_url($home_url); // Fallback to home URL 82 } 83 84 // Create the complete URL 85 $search_console_url = "https://search.google.com/search-console/performance/search-analytics?resource_id=" . $resource_id . $page_url . "&" . esc_attr($default_date_period); 86 87 // Add the Search Console link to the admin bar 88 $args = array( 89 'id' => 'search_console', 90 'title' => 'Search Console', 91 'href' => $search_console_url, 92 'meta' => array( 93 'target' => '_blank', 94 'class' => 'google_link' 95 ) 96 ); 97 $wp_admin_bar->add_node($args); 98 } 99 100 101 102 103 40 104 41 105 public function postpeek_settings_init() … … 54 118 add_settings_field( 55 119 'postpeek_site_type', 56 'Search Console AccountType',120 'Search Console Site Type', 57 121 array($this, 'postpeek_site_type_render'), 58 122 'postpeek', -
postpeek/trunk/readme.txt
r2967398 r2967453 1 === PostPeek : One-Click Access to Your Search Console Stats===1 === PostPeek - One-Click Access to Your Search Console === 2 2 3 3 Contributors: jlil … … 5 5 Requires at least: 4.0 6 6 Tested up to: 6.3 7 Stable tag: 1. 0.47 Stable tag: 1.1.1 8 8 License: GPL-2.0-or-later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 30 30 2. **User Role Filter**: Specify which user roles can see the "Search Console" link in the Quick Actions menu. 31 31 3. **Default Report Timeframe**: Set the default time period for the report displayed when accessing Google Search Console. 32 33 == New Feature: Admin Bar Search Console Link == 34 35 Admin Bar Quick Access to Google Search Console 36 37 We've introduced a new feature that allows you to quickly access Google Search Console directly from your WordPress Admin Bar. This link dynamically updates based on where you are in the WordPress dashboard or the frontend of your site: 38 39 1. **Admin Area**: The link directs you to Search Console statistics for your homepage. 40 2. **Frontend**: If you're on a post, page, category, or tag, the link directs you to the relevant Search Console statistics. 41 42 This saves you time and provides immediate insights without having to leave your website. 32 43 33 44 == How to Use == … … 61 72 1. PostPeek-search-console-link Example 62 73 2. PostPeek Settings 74 3. Admin Bar Search Console Link 63 75 64 76 == Installation == … … 74 86 == Changelog == 75 87 76 = 1.0.4 = 88 = 1.1.1 [15-09-2023] = 89 * Added "Admin Bar Search Console Link" feature. 90 91 = 1.1.0 [15-09-2023] = 77 92 * Added "Default Report Timeframe" feature. 78 93 * Fixed a minor bug related to user role permissions. 79 94 * Updated plugin description and documentation. 80 95 81 = 1.0.3 =96 = 1.0.3 [14-09-2023] = 82 97 * Fixed a minor bug. 83 98 84 = 1.0.2 =99 = 1.0.2 [14-09-2023] = 85 100 * Introduced "User Role Filter" to specify which roles can see the "Search Console" link. 86 101 87 = 1.0.1 =102 = 1.0.1 [13-09-2023] = 88 103 * Added the "Site Type Selection" option for Google Search Console. 89 104 * Initial public release after beta testing.
Note: See TracChangeset
for help on using the changeset viewer.