__( 'The link is now in your footer.', 'aiprofile-inside' ),
'footer_moved' => __( 'Moved: the link is now in your footer, and no longer in your main menu.', 'aiprofile-inside' ),
'footer_removed' => __( 'The link is no longer in your footer.', 'aiprofile-inside' ),
);
if ( isset( $dones[ $done ] ) ) {
echo '
' . esc_html( $dones[ $done ] ) . '
';
}
$messages = array(
'empty' => __( 'Paste your AiProfile link first.', 'aiprofile-inside' ),
'notfound' => __( 'We could not find an AiProfile with this link. Check the link and try again.', 'aiprofile-inside' ),
'unreachable' => __( 'AiProfile could not be reached. Try again in a minute.', 'aiprofile-inside' ),
);
if ( isset( $messages[ $msg ] ) ) {
echo '
' . esc_html( $messages[ $msg ] ) . '
';
}
if ( 'stillnone' === $msg ) {
echo '
' . esc_html__( 'We did not find an AiProfile with the address of your site yet. When yours is ready, look again.', 'aiprofile-inside' ) . '
' . esc_html__( 'Connect your AiProfile', 'aiprofile-inside' ) . '
';
aiprofile_inside_render_message();
if ( is_array( $pending ) && ! empty( $pending['key'] ) ) {
aiprofile_inside_render_found( $pending );
} elseif ( ! empty( $settings['key'] ) && ! $change ) {
aiprofile_inside_render_connected( $settings );
} else {
// Not connected, nothing checked, and the owner did not ask for the
// paste field (?change=1): look for the profile by this site's address.
$first = empty( $settings['key'] ) && ! $change;
$matches = $first ? aiprofile_inside_detect() : array();
if ( 1 === count( $matches ) ) {
aiprofile_inside_render_found( $matches[0], true );
} elseif ( count( $matches ) > 1 ) {
aiprofile_inside_render_choose( $matches );
} else {
// None found (or the lookup failed): offer to make one first. Not
// on ?change=1, where the owner chose to paste another link.
$make = $first && aiprofile_inside_render_make();
aiprofile_inside_render_form( $make );
}
}
echo '
';
}
/**
* Whether this site's address can be a business website: not a local or test
* address (localhost, an IP, .local, .test and the like, WordPress
* Playground), where a build has nothing public to read.
*
* @param string $host The site's host.
* @return bool
*/
function aiprofile_inside_public_host( $host ) {
$host = strtolower( $host );
if ( '' === $host || false === strpos( $host, '.' ) || filter_var( $host, FILTER_VALIDATE_IP ) || false !== strpos( $host, ':' ) ) {
return false;
}
if ( 'playground.wordpress.net' === $host ) {
return false;
}
return ! preg_match( '/\.(local|localhost|test|invalid|example|internal|lan|home\.arpa)$/', $host );
}
/**
* The link that makes an AiProfile from this site (since 1.3.7): the build on
* AiProfile with the site's own address, so it starts straight away. Empty
* when the origin or the address is not usable, or the site is a local one.
*
* @return string
*/
function aiprofile_inside_build_url() {
$origin = aiprofile_inside_origin();
$host = aiprofile_inside_site_host();
if ( '' === $origin || ! aiprofile_inside_public_host( $host ) || in_array( wp_get_environment_type(), array( 'local', 'development' ), true ) ) {
return '';
}
return $origin . '/build?url=' . rawurlencode( $host ) . '&src=wp-plugin';
}
/**
* "No AiProfile yet?" (since 1.3.7), above the paste field when no profile
* has this site's address: a button that makes one on AiProfile (new tab),
* and a link that looks again once it is made.
*
* @return bool Whether the card was shown.
*/
function aiprofile_inside_render_make() {
$url = aiprofile_inside_build_url();
if ( '' === $url ) {
return false;
}
$again = wp_nonce_url( add_query_arg( 'action', 'aiprofile_inside_look_again', admin_url( 'admin-post.php' ) ), 'aiprofile_inside_look_again' );
?>
' . esc_html__( 'Your theme did not show the answers on this page, so the plugin now shows them in its own page layout, between the header and footer of your theme. You can change this under Settings, Page layout.', 'aiprofile-inside' ) . '
';
} elseif ( 'plugin' !== $mode && isset( $state['misses'] ) && (int) $state['misses'] >= AIPROFILE_INSIDE_LAYOUT_MISSES ) {
// Switched off by the owner, or the answers page is the front page,
// where the plugin does not switch by itself.
echo '
' . esc_html__( 'Your theme does not show the answers on this page, so visitors and AI assistants do not see them. Switch on "Use the plugin\'s page layout" under Settings, Page layout.', 'aiprofile-inside' ) . '
';
}
}
/** Since 1.3.6: the switch for the plugin's own page layout, in the settings form. */
function aiprofile_inside_render_layout_setting() {
$block = ! aiprofile_inside_layout_possible();
$on = ! $block && aiprofile_inside_use_own_layout();
?>