Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
renderSignUpLink() {
// Taken from client/layout/masterbar/logged-out.jsx
const { currentQuery, currentRoute, oauth2Client, pathname, translate, wccomFrom } = this.props;
let signupUrl = config( 'signup_url' );
const signupFlow = get( currentQuery, 'signup_flow' );
if (
// Match locales like `/log-in/jetpack/es`
startsWith( currentRoute, '/log-in/jetpack' )
) {
// Basic validation that we're in a valid Jetpack Authorization flow
if (
includes( get( currentQuery, 'redirect_to' ), '/jetpack/connect/authorize' ) &&
includes( get( currentQuery, 'redirect_to' ), '_wp_nonce' )
) {
/**
* `log-in/jetpack/:locale` is reached as part of the Jetpack connection flow. In
* this case, the redirect_to will handle signups as part of the flow. Use the
* `redirect_to` parameter directly for signup.
*/
signupUrl = currentQuery.redirect_to;
return new Promise( ( resolve, reject ) => {
// TODO: Maybe store this configuration in local storage? The problem is that the configuration for a user could
// change if they purchase upgrades or if their upgrades expire. There's also throttling that happens for unpaid users.
// There is lots to consider before storing this configuration
debug( 'Using rest api to get olark configuration' );
const clientSlug = config( 'client_slug' );
wpcomUndocumented.getOlarkConfiguration( clientSlug, ( error, configuration ) => {
if ( error ) {
reject( error );
return;
}
resolve( configuration );
} );
} );
},
return false;
}
if ( typeof window !== 'undefined' ) {
if ( hostname === window.location.hostname ) {
// even if hostname matches, the url might be outside calypso
// outside calypso should be considered external
// double separators are valid paths - but not handled correctly
if ( pathname && isLegacyRoute( pathname.replace( '//', '/' ) ) ) {
return true;
}
return false;
}
}
return hostname !== config( 'hostname' );
}
beforeEach(() => iocInstance = new IoC(config()));
export function isDiscoverPost( post ) {
return !! (
get( post, 'discover_metadata' ) || get( post, 'site_ID' ) === config( 'discover_blog_id' )
);
}
recordEvent( eventName, eventValue = null ) {
if ( ! isEnabled( 'atlas' ) ) {
return;
}
const params = Object.assign( {}, eventValue, {
event: eventName
} );
const urlParams = Object.keys( params ).map( function( key ) {
return encodeURIComponent( key ) + '=' + encodeURIComponent( params[ key ] );
} ).join( '&' );
loadScript( `https://ad.atdmt.com/m/a.js;m=${ config( 'atlas_tag_id' ) };cache=${ Math.random() }?${ urlParams }` );
},
app.get( '/discover', function( req, res, next ) {
if ( ! req.context.isLoggedIn ) {
res.redirect( config( 'discover_logged_out_redirect_url' ) );
} else {
next();
}
} );
function loginEndpointData() {
return {
client_id: config( 'wpcom_signup_id' ),
client_secret: config( 'wpcom_signup_key' ),
service: 'apple',
signup_flow_name: 'no-signup',
};
}
export function requestFollow( action ) {
const feedUrl = get( action, 'payload.feedUrl' );
return http(
{
method: 'POST',
path: '/read/following/mine/new',
apiVersion: '1.1',
body: {
url: feedUrl,
source: config( 'readerFollowingSource' ),
},
},
action
);
}
export function getExtensionSettingsPath( plugin ) {
const pluginSlug = get( plugin, 'slug', '' );
const sections = getSections();
const section = find( sections, value => value.name === pluginSlug );
const env = get( section, 'envId', [] );
if ( ! includes( env, config( 'env_id' ) ) ) {
return;
}
return get( section, 'settings_path' );
}