Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/images/modules/wpuf-seo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions includes/Free/Free_Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,46 +183,53 @@
$new_sections = [
[
'id' => 'wpuf_sms',
'title' => __( 'SMS', 'wp-user-frontend' ) . '<span class="pro-icon-title"> ' . file_get_contents( $crown_icon_path ) . '</span>',

Check warning on line 186 in includes/Free/Free_Loader.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

file_get_contents() is discouraged. Use wp_remote_get() for remote URLs instead.
'icon' => 'dashicons-format-status',
'class' => 'pro-preview-html',
'is_pro_preview' => true,
],
[
'id' => 'wpuf_social_api',
'title' => __( 'Social Login', 'wp-user-frontend' ) . '<span class="pro-icon-title"> ' . file_get_contents( $crown_icon_path ) . '</span>',

Check warning on line 193 in includes/Free/Free_Loader.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

file_get_contents() is discouraged. Use wp_remote_get() for remote URLs instead.
'icon' => 'dashicons-share',
'class' => 'pro-preview-html',
'is_pro_preview' => true,
],
[
'id' => 'user_directory',
'title' => __( 'User Directory', 'wp-user-frontend' ) . '<span class="pro-icon-title"> ' . file_get_contents( $crown_icon_path ) . '</span>',

Check warning on line 200 in includes/Free/Free_Loader.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

file_get_contents() is discouraged. Use wp_remote_get() for remote URLs instead.
'icon' => 'dashicons-list-view',
'class' => 'pro-preview-html',
'is_pro_preview' => true,
],
[
'id' => 'wpuf_payment_invoices',
'title' => __( 'Invoices', 'wp-user-frontend' ) . '<span class="pro-icon-title"> ' . file_get_contents( $crown_icon_path ) . '</span>',

Check warning on line 207 in includes/Free/Free_Loader.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

file_get_contents() is discouraged. Use wp_remote_get() for remote URLs instead.
'icon' => 'dashicons-media-spreadsheet',
'class' => 'pro-preview-html',
'is_pro_preview' => true,
],
[
'id' => 'wpuf_payment_tax',
'title' => __( 'Tax', 'wp-user-frontend' ) . '<span class="pro-icon-title"> ' . file_get_contents( $crown_icon_path ) . '</span>',

Check warning on line 214 in includes/Free/Free_Loader.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

file_get_contents() is discouraged. Use wp_remote_get() for remote URLs instead.
'icon' => 'dashicons-media-text',
'class' => 'pro-preview-html',
'is_pro_preview' => true,
],
[
'id' => 'wpuf_content_restriction',
'title' => __( 'Content Filtering', 'wp-user-frontend' ) . '<span class="pro-icon-title"> ' . file_get_contents( $crown_icon_path ) . '</span>',

Check warning on line 221 in includes/Free/Free_Loader.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

file_get_contents() is discouraged. Use wp_remote_get() for remote URLs instead.
'icon' => 'dashicons-admin-network',
'class' => 'pro-preview-html',
'is_pro_preview' => true,
],
[
'id' => 'wpuf_seo_settings',
'title' => __( 'SEO Settings', 'wp-user-frontend' ) . '<span class="pro-icon-title"> ' . file_get_contents( $crown_icon_path ) . '</span>',

Check warning on line 228 in includes/Free/Free_Loader.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

file_get_contents() is discouraged. Use wp_remote_get() for remote URLs instead.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Security risk: Use WordPress HTTP API instead of file_get_contents().

You shouldn't use file_get_contents() for remote requests. WordPress does the heavy lifting for you when determining what is compatible on your host. Instead of file_get_contents() use wp_remote_get(). The issue here is that file_get_contents will fetch remote pages but doesn't check on the integrity of the HTTPS protocol connection. This could potentially be a victim of a man-in-the-middle attack. In WordPress, it's even easier: use wp_remote_get. It works much more consistently than file_get_contents, and it'll default to verifying SSL connections.

However, since this is a local file read (crown icon SVG), the security concerns are minimal. For local file access, you should use $wp_filesystem->get_contents(), and that method simply calls the native PHP's file_get_contents(), so you may use it directly in your code - for reading local files/resources.

Based on web search results

Apply this diff to use WordPress filesystem API:

-                'title'          => __( 'SEO Settings', 'wp-user-frontend' ) . '<span class="pro-icon-title"> ' . file_get_contents( $crown_icon_path ) . '</span>',
+                'title'          => __( 'SEO Settings', 'wp-user-frontend' ) . '<span class="pro-icon-title"> ' . $this->get_crown_icon_content() . '</span>',

Then add this helper method to the class:

private function get_crown_icon_content() {
    global $wp_filesystem;
    if ( empty( $wp_filesystem ) ) {
        require_once ABSPATH . 'wp-admin/includes/file.php';
        WP_Filesystem();
    }
    $crown_icon_path = WPUF_ROOT . '/assets/images/crown.svg';
    return $wp_filesystem->exists( $crown_icon_path ) ? $wp_filesystem->get_contents( $crown_icon_path ) : '';
}
🧰 Tools
🪛 GitHub Check: Run PHPCS inspection

[warning] 228-228:
file_get_contents() is discouraged. Use wp_remote_get() for remote URLs instead.

🤖 Prompt for AI Agents
In includes/Free/Free_Loader.php around line 228, replace the direct
file_get_contents($crown_icon_path) call with a helper that uses the WordPress
Filesystem API: add a private get_crown_icon_content() method that ensures
$wp_filesystem is initialized (require_once ABSPATH .
'wp-admin/includes/file.php' and call WP_Filesystem()), checks
$wp_filesystem->exists($crown_icon_path) and returns
$wp_filesystem->get_contents($crown_icon_path) or an empty string; then update
the 'title' line to call this helper instead of file_get_contents.

'icon' => 'dashicons-search',
'class' => 'pro-preview-html',
'is_pro_preview' => true,
]

Check failure on line 232 in includes/Free/Free_Loader.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

There should be a comma after the last array item in a multi-line array.
];

return array_merge( $sections, $new_sections );
Expand All @@ -241,8 +248,8 @@
$crown_icon_path = WPUF_ROOT . '/assets/images/crown.svg';
$settings_fields['wpuf_general'][] = [
'name' => 'comments_per_page',
'label' => __( 'Comments Per Page',

Check failure on line 251 in includes/Free/Free_Loader.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Opening parenthesis of a multi-line function call must be the last content on the line
'wp-user-frontend' ) . '<span class="pro-icon"> ' . file_get_contents( $crown_icon_path ) . '</span>',

Check warning on line 252 in includes/Free/Free_Loader.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

file_get_contents() is discouraged. Use wp_remote_get() for remote URLs instead.

Check failure on line 252 in includes/Free/Free_Loader.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Closing parenthesis of a multi-line function call must be on a line by itself

Check failure on line 252 in includes/Free/Free_Loader.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Multi-line function call not indented correctly; expected 12 spaces but found 36
'desc' => __( 'Show how many comments per page in comments add-on', 'wp-user-frontend' ),
'type' => 'number',
'default' => '20',
Expand All @@ -251,8 +258,8 @@
];
$settings_fields['wpuf_general'][] = [
'name' => 'ipstack_key',
'label' => __( 'Ipstack API Key',

Check failure on line 261 in includes/Free/Free_Loader.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Opening parenthesis of a multi-line function call must be the last content on the line
'wp-user-frontend' ) . '<span class="pro-icon"> ' . file_get_contents( $crown_icon_path ) . '</span>',

Check warning on line 262 in includes/Free/Free_Loader.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

file_get_contents() is discouraged. Use wp_remote_get() for remote URLs instead.

Check failure on line 262 in includes/Free/Free_Loader.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Closing parenthesis of a multi-line function call must be on a line by itself

Check failure on line 262 in includes/Free/Free_Loader.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Multi-line function call not indented correctly; expected 12 spaces but found 36
'desc' => sprintf(
// translators: %1$s: opening anchor tag, %2$s: closing anchor tag
__( '%1$sRegister here%2$s to get your free ipstack api key', 'wp-user-frontend' ),
Expand All @@ -263,8 +270,8 @@
];
$settings_fields['wpuf_general'][] = [
'name' => 'gmap_api_key',
'label' => __( 'Google Map API',

Check failure on line 273 in includes/Free/Free_Loader.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Opening parenthesis of a multi-line function call must be the last content on the line
'wp-user-frontend' ) . '<span class="pro-icon"> ' . file_get_contents( $crown_icon_path ) . '</span>',

Check warning on line 274 in includes/Free/Free_Loader.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

file_get_contents() is discouraged. Use wp_remote_get() for remote URLs instead.

Check failure on line 274 in includes/Free/Free_Loader.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Closing parenthesis of a multi-line function call must be on a line by itself

Check failure on line 274 in includes/Free/Free_Loader.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Multi-line function call not indented correctly; expected 12 spaces but found 36
'desc' => __( '<a target="_blank" href="https://developers.google.com/maps/documentation/javascript/get-api-key">API</a> key is needed to render Google Maps',
'wp-user-frontend' ),
'class' => 'pro-preview',
Expand Down Expand Up @@ -853,6 +860,26 @@
],
];

// SEO Settings
$settings_fields['wpuf_seo_settings'] = [
[
'name' => 'user_directory_section',
'label' => __( 'User Directory SEO Settings', 'wp-user-frontend' ),
'type' => 'html',
'class' => 'pro-preview-html',
'is_pro_preview' => true,
],
[
'name' => 'avoid_indexing_profiles',
'label' => __( 'Avoid indexing profile by search engines', 'wp-user-frontend' ) . '<span class="pro-icon"> ' . file_get_contents( $crown_icon_path ) . '</span>',
'desc' => __( 'Enable this to add a noindex meta tag to all user profile pages across directories. Useful if you want some profiles hidden from search engines.', 'wp-user-frontend' ),
'type' => 'checkbox',
'default' => 'off',
'class' => 'pro-preview',
'is_pro_preview' => true,
],
];

return $settings_fields;
}

Expand Down Expand Up @@ -1269,6 +1296,12 @@
'plugin_uri' => 'https://wedevs.com/docs/wp-user-frontend-pro/modules/stripe/',
'thumbnail' => 'wpuf-stripe.png',
],
'seo/wpuf-seo.php' => [
'name' => 'SEO Settings',
'description' => 'SEO settings for user directory and profiles',
'plugin_uri' => 'https://wedevs.com/products/plugins/wp-user-frontend-pro/seo-settings/',
'thumbnail' => 'wpuf-seo.png',
],
];
}

Expand Down
Loading