I was looking through the code and noticed that there’s some unreachable code in your plugin.
There’s a redirect on line 6
& and exit statement on line 7
.
There are 17
lines of code after this that are unreachable.
public function impact_activate( $plugin ) {
$arr = explode( '/', $plugin );
if ( count( $arr ) >= 1 && strpos( $arr[ count( $arr ) - 1 ], 'impact' ) !== false ) {
$store_url = home_url();
$path = '/wp-admin/admin.php?page=impact-settings';
$url = $store_url . $path;
wp_safe_redirect( $url );
exit;
global $user;
global $wpdb;
$store_url = home_url();
$user = wp_get_current_user();
$endpoint = '/wc-auth/v1/authorize';
$params = array(
'app_name' => 'Impact',
'scope' => 'read_write',
'user_id' => $user->user_login,
'return_url' => home_url() . '/wp-admin/admin.php?page=impact-settings',
'callback_url' => home_url() . '/wp-json/impact/v1/callback',
);
$query_string = http_build_query( $params );
$url = $store_url . $endpoint . '?' . $query_string;
wp_safe_redirect( $url );
exit;
}
}
I’d suggest deleting these lines to clean up the code base.
]]>Hello there,
I just installed the plugin on a test site. After installing the plugin I clicked the “Activate” button.
This lead me to a File not found.
error. ??
I looked into your source code.
public function impact_activate( $plugin ) {
$arr = explode( '/', $plugin );
if ( count( $arr ) >= 1 && strpos( $arr[ count( $arr ) - 1 ], 'impact' ) !== false ) {
$store_url = home_url();
$path = '/wp-admin/admin.php?page=impact-settings';
$url = $store_url . $path;
wp_safe_redirect( $url );
exit;
{...}
}
}
It looks like you’re using home_url() which is generally used on the front-end of the website.
If WordPress is installed in a subdirectory such as example.com/wp/
then when you activate the plugin it will load example.com/wp-admin/admin.php?page=impact-settings
which doesn’t exist.
I recommend using admin_url() instead.
]]>Hey ! I just install this plugin, and I can’t found the way to modify the settigns. Can you please explain the method ?
]]>