RWPAI_PLUGIN_ID,
'slug' => RWPAI_PLUGIN_NAME,
'type' => 'plugin',
'public_key' => 'pk_dd636842a6e5bcce15263e7dae1ff',
'is_premium' => false,
'is_premium_only' => false,
'is_org_compliant' => true,
'opt_in' => false,
'has_premium_version' => false,
'has_addons' => false,
'has_paid_plans' => false,
)
);
}
return $rwpai_freemius;
}
// Initialize Freemius and signal that the SDK has loaded.
rwpai_freemius();
do_action( 'rwpai_freemius_loaded' );
}
// Its for /wp-admin/plugins.php.
add_filter(
'plugin_action_links_' . plugin_basename( __FILE__ ),
function ( $links ) {
$settings_url = admin_url( 'admin.php?page=' . RWPAI_MENU_SLUG ); // Replace with your actual settings slug.
$docs_url = 'https://wordpress.org/plugins/' . RWPAI_PLUGIN_SLUG . '/#description'; // Example docs URL.
$support_url = 'https://wordpress.org/support/plugin/' . RWPAI_PLUGIN_SLUG . '/';
$custom_links = array(
'' . __( 'Settings', 'ai-agent' ) . '',
'' . __( 'Docs', 'ai-agent' ) . '',
'' . __( 'Support', 'ai-agent' ) . '',
);
return array_merge( $custom_links, $links );
}
);
// WP Admin code related.
require_once plugin_dir_path( __FILE__ ) . 'components/admin.php';
// Regiseter Public rest api.
require_once plugin_dir_path( __FILE__ ) . 'components/public.php';
// Triggered when the plugin is activated.
register_activation_hook( __FILE__, 'rwpai_on_plugin_activate' );
/**
* Runs on plugin activation.
*
* Sets a flag that will be used to determine if a redirect should
* occur immediately after the plugin is activated.
*/
function rwpai_on_plugin_activate() {
// Set a flag so we know to redirect after activation.
add_option( 'rwpai_do_activation_redirect', true );
if ( function_exists( 'rwpai_ensure_mcp_settings' ) ) {
rwpai_ensure_mcp_settings();
}
}
/**
* Redirects to the plugin settings page after activation.
*
* Checks if the activation redirect flag is set and redirects
* to the plugin settings page if it is. Then deletes the flag
* to prevent future redirects.
*/
function rwpai_redirect_after_activation() {
// Check if we should redirect after activation.
if ( get_option( 'rwpai_do_activation_redirect', false ) ) {
// Delete the flag so we don't redirect again.
delete_option( 'rwpai_do_activation_redirect' );
// Only redirect if we're not already on the settings page.
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Activation redirect, no nonce available during plugin activation.
if ( ! isset( $_GET['activate-multi'] ) ) {
wp_safe_redirect( admin_url( 'admin.php?page=' . RWPAI_MENU_SLUG ) );
exit;
}
}
}
// Check the flag on the next admin load and redirect.
add_action( 'admin_init', 'rwpai_redirect_after_activation' );