: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
self.$tabList.add( self.$content ).find( '.active' ).removeClass( 'active' );
$t.add( self.$content.find( '.section-content:eq(' + index + ')' ) ).addClass( 'active' );
self.$form.removeClass('stream-view-visible');
if (self.$form.find('#streams-cont [data-view-mode="streams-update"].view-visible').length) {
self.$form.addClass('stream-view-visible');
self.activeTabIndex = index;
sessionStorage.setItem('as_active_tab', index);
$backupsForm.on('click', '.create_backup', this.createBackup);
$backupsForm.on('click', '.restore_backup', this.restoreBackup);
$backupsForm.on('click', '.delete_backup', this.deleteBackup);
this.$form.delegate('.admin-button.submit-button', 'click', function (e) {
// validate activation form
if ($t.is('#user-settings-sbmt')) {
$licenseCont = $('#envato_license');
if ($licenseCont.is('.plugin-activated')) {
promise = self.popup('Are you sure?');
promise.then(function success(){
$licenseCont.find('input').val('');
$licenseCont.find(':checkbox').prop('checked', false);
if (!self.validateEmail($licenseCont.find('#company_email').val())) {
$licenseCont.find('#company_email').addClass('validation-error');
if (!self.validateCode($licenseCont.find('#purchase_code').val())) {
$licenseCont.find('#purchase_code').addClass('validation-error');
opts.attemptToActivate = true;
if ($t.is('#user-settings-sbmt-2')) {
$('#news_subscription').prop('checked', true);
function submitForm(opts) {
$t.addClass('button-in-progress');
self.makeOverlayTo('show');
$t.closest('form').trigger('submit', opts);
sessionStorage.setItem('section-submit', $t.attr('id'));
this.$form.on('click', 'a[href*="#"]', function (e) {
FlowFlow.makeOverlayTo('hide');
self.$form.find(this.hash).click();
this.$form.on('submit', function(e, opts){
// console.time('submit')
var $inputs = self.$form.find('.section-content').not('#streams-cont, #campaigns-cont, #sources-cont').find(':input');
//Serialize form as array
serialized = $inputs.serializeArray();
for(var i =0, len = serialized.length;i<len;i++){
serialized[i]['value'] = $.trim(serialized[i]['value']);
//turn it into a string if you wish
serialized = $.param(serialized);
$inputs.filter('input[type=checkbox]:not(:checked)').each(
if (name != 'mod-roles') {
serialized += '&' + encodeURIComponent(this.name) + '=nope';
action: la_plugin_slug_down + '_ff_save_settings',
doSubcribe: opts.doSubscribe,
$.post( vars.ajaxurl, data, function( response ) {
console.log('Got this from the server: ' , response )
var $fb_token, $submitted;
if ( response == -1 || response.error ) {
var promise = FlowFlow.popup('Nay! Something went wrong, if it repeats please contact support.', false, 'alert');
FlowFlow.makeOverlayTo('hide');
// Do something on success
console.log(response.settings)
if (typeof response === 'string' && response.indexOf('curl')) {
var promise = FlowFlow.popup('Please set DISABLE CURL_FOLLOW_LOCATION setting to YES under General tab', false, 'alert');
FlowFlow.makeOverlayTo('hide');
if (opts.attemptToActivate && response.activated !== true) {
alert(response.activated);
self.makeOverlayTo('hide');
$fb_token = $('input[name="flow_flow_fb_auth_options[facebook_access_token]"]').parent();
if (response.fb_extended_token == false){
$fb_token.find('.desc').remove();
$fb_token.find('textarea').remove();
$fb_token.append('<p class="desc fb-token-notice" style="margin: 10px 0 5px; color: red !important">! Extended token is not generated, Facebook feeds might not work</p>');
$fb_token.removeClass('fb-empty');
else if (response.settings.flow_flow_fb_auth_options.facebook_access_token == response.fb_extended_token){
if (response.settings && response.settings.flow_flow_fb_auth_options && response.settings.flow_flow_fb_auth_options.facebook_access_token == '') {
$fb_token.addClass('fb-empty');
if (response.fb_extended_token && !$fb_token.find('textarea').length) {
$fb_token.find('.desc').remove();
$fb_token.append('<p class="desc" style="margin: 30px 0 5px">Generated long-life token, it should be different from that you entered above then FB auth is OK</p><textarea disabled rows=3>' + response.fb_extended_token + '</textarea>');
$fb_token.removeClass('fb-empty');
if (!opts.doReload) self.makeOverlayTo('hide');
$submitted = $('#' + sessionStorage.getItem('section-submit'));
$submitted.addClass('updated-button').html('<i class="flaticon-check_mark" data-action="edit"></i> Updated');
$submitted.removeClass('button-in-progress');
setTimeout( function () {
$submitted.html('Save changes').removeClass('updated-button');
if (opts.doReload) location.reload();
}, 'json' ).fail( function( d ){
console.log( d.responseText );
alert('Error occurred. ' + d.responseText);
self.makeOverlayTo('hide');
this.$form.delegate('input', 'keydown', function (e){
if ($t.is('.validation-error')) {
$t.removeClass('validation-error');
this.$form.find('#facebook_use_own_app').change(function(){
var $p = $t.closest('dl');
var checked = this.checked;
$p.find('dd, dt').not('.ff-toggler').find('input')[ checked ? 'removeClass' : 'addClass' ]('disabled')
$p[ checked ? 'addClass' : 'removeClass' ]('ff-own-app');
$('#facebook-auth')[this.checked ? 'hide' : 'show']();
this.$form.find('.extension__cta--disabled').click(function(e){
$( window ).on('beforeunload', function (e) {
sessionStorage.setItem('as_scroll', $('body').scrollTop() || $('html').scrollTop());
this.$errorPopup.on('mouseleave', function(e){
self.$errorPopup.removeClass('visible')
this.$form.find('#boosts .extension__cta.grey-button').on( 'click', function ( e ) {
var promise = FlowFlow.popup( 'You are about to cancel subscription. All active boosted feeds and cloud streams will become self-hosted. Are you sure?');
promise.then(function yes(){
window.location.replace( hr )
}, function no ( reason ) {
this.$popupBanner.on( 'click', function () {
self.$popupBanner.removeClass( 'banner-visible' );
this.$form.on( 'click', '.show-debug', function ( e ) {
$('#debug-info').toggle();
if ( window.FF_Cookie ) {
if ( window.FF_Cookie.get( 'ff_first_time' ) ) {
$( '.tutorial-first-time' ).hide();
$( '.tutorial-link' ).click();
window.FF_Cookie.set( 'ff_first_time', '1', { expires: 356 });
$('.coupon-apply').on( 'click', function () {
$( '#general-settings-sbmt' ).click();
$('.coupon-clear').on( 'click', function () {
$( '#boosts_coupon' ).val( '' );
$( '#general-settings-sbmt' ).click();
$( '#boosts').on( 'click', '[data-plan="custom"] .extension__cta--secured', function ( e ) {
var prompt = self.popup( '<label>Enter plan ID</label> <input id="boosts_custom_plan_id" name="boosts_custom_plan_id" type="text">', 'neutral', false, { right: 'Go To Payment', left: 'cancel'} )
prompt.then( function yes ( value ) {
var id = $( '#boosts_custom_plan_id' ).val();
var coupon = $('#boosts_coupon').val();
window.location.replace( 'https://social-streams.com/boosts/?intent=' + id + '&domain=' + encodeURIComponent( location.href + '&subscription=1') + ( coupon ? '&coupon=' + coupon : '' ) + '&ajax=' + vars.ajaxurl );
}, function cancel ( reason ) {
// boost manual activation
$( '#boosts').on( 'click', '#boosts_manual', function ( e ) {
var prompt = self.popup( '<div class="boost_custom_wrap"><label>Checkout email</label> <input id="boosts_manual_email" name="boosts_manual_email" type="text"><br><label>Checkout ID</label> <input id="boosts_manual_id" name="boosts_manual_id" type="text"></div>', 'neutral', false, { right: 'Activate', left: 'cancel'} )
prompt.then( function yes ( value ) {
var email = $( '#boosts_manual_email' ).val();
var id = $('#boosts_manual_id').val();
window.location.replace( vars.ajaxurl + "?action=flow_flow_payment_success&email=" + email + "&checkout_id=" + id );
self.popup( 'Please enter both email and ID', false, 'alert' );
}, function cancel ( reason ) {
this.initFoursquareAuth();
this.initInstagramAuth();
showNotification: function ( html ) {
var timeout = this.$popupBanner.data( 'timeout' );
this.$popupBanner.find( 'div' ).html( html ).end().addClass( 'banner-visible' );
if ( timeout ) { // current
timeout = setTimeout( function () {
FlowFlow.$popupBanner.removeClass( 'banner-visible' );
this.$popupBanner.data( 'timeout', timeout );
initFacebookAuth: function () {
//https://www.facebook.com/dialog/oauth
var f = "https://flow.looks-awesome.com/service/auth/facebook-instagram.php?" + $.param({
$("#facebook-auth").click(function(){
if ($(this).html() === 'Log Out') {
$('#facebook_access_token').val('');
$('#fb-auth-settings-sbmt').click();
$("#facebook-auth").html('Connect');
document.location.href = f;
$("#fb-refresh-token").click(function(){
document.location.href = f;
if ($('#facebook_access_token').val() !== '') {
$("#facebook-auth").html('Log Out')
initFoursquareAuth: function () {
var j = "https://foursquare.com/oauth2/authenticate?" + $.param({
client_id: "22XC2KJFR2SFU4BNF4PP1HMTV3JUBSEEVTQZCSCXXIERVKA3",
redirect_uri: "http://flow.looks-awesome.com/service/auth/foursquare.php?back=" + this.backUrl,
$("#foursquare-auth").click(function(){
if ($(this).html() === 'Log Out') {
$('#foursquare_access_token').val('');
$('#fq-auth-settings-sbmt').click();
$("#foursquare-auth").html('Authorize');
document.location.href = j;
if ($('#foursquare_access_token').val() !== '') {
$("#foursquare-auth").html('Log Out')
if ($('#foursquare_client_id').val() === '') {
var $par = $('#foursquare_client_id').parent();
$par.add($par.prev('dt').first()).hide();
if ($('#foursquare_client_secret').val() === '') {
var $par = $('#foursquare_client_secret').parent();
$par.add($par.prev('dt').first()).hide();
initInstagramAuth: function () {
//http://stackoverflow.com/questions/7131909/facebook-callback-appends-to-return-url/7297873#7297873
if (window.location.hash && window.location.hash == '#_=_') {
window.location.hash = '';
var h = "https://api.instagram.com/oauth/authorize/?" + $.param({
client_id: "94072d7b728f47b68bc7fc86767b3ebe",
redirect_uri: "http://social-streams.com/services/auth/instagram.php?back=" + this.backUrl,
scope: "basic public_content"
$("#inst-auth").click(function(){
if ($(this).html() === 'Log Out') {
$('#instagram_access_token').val('');
$('#inst-auth-settings-sbmt').click();
$("#inst-auth").html('Authorize');
document.location.href = h;
if ($('#instagram_access_token').val() !== '') {
$("#inst-auth").html('Log Out');
checkScrollbar : function () {
this.bodyIsOverflowing = document.body.scrollHeight > document.body.clientHeight
this.scrollbarWidth = this.measureScrollbar();
setScrollbar : function () {
var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10)
if (this.bodyIsOverflowing) {
this.$body.css('padding-right', bodyPad + this.scrollbarWidth);
this.$popupBanner.css('margin-right', bodyPad + this.scrollbarWidth);
resetScrollbar : function () {
this.$body.css('padding-right', '');
this.$popupBanner.css('margin-right', '');
measureScrollbar : function () { // thx walsh
var scrollDiv = document.createElement('div')
scrollDiv.className = 'ff-modal-scrollbar-measure'
this.$body.append(scrollDiv)
var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth
this.$body[0].removeChild(scrollDiv);
switchToView: function (view) {
this.$streamsContainer.find('.view-visible').removeClass('view-visible');
// setTimeout(function(){
self.$streamsContainer.find('#streams-' + view).addClass('view-visible');
self.$form.removeClass('stream-view-visible');
self.$streamsContainer.find('#stream-view-' + view).addClass('view-visible');
self.$form.addClass('stream-view-visible');
console.log('switch to view', view)
sessionStorage.setItem('ff_stream', view);
setHeight : function (id) {
if (id && !isNaN(parseInt(id))) {
self.$streamsContainer.find('#stream-view-' + id + ', #streams-list').each(function(){
heights.push($(this).outerHeight());
self.$streamsContainer.find('.section-stream[data-view-mode="streams-update"], #streams-list').each(function(){
heights.push($(this).outerHeight());
maxH = Math.max.apply(Math, heights);
self.$streamsContainer.css('minHeight', maxH);
setupTabsAndContainer: function () {
$activeTab = $('.section-tabs li:eq(' + this.activeTabIndex +')');