Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/flow-flo.../includes
File: FlowFlowActivator.php
<?php namespace flow;
[0] Fix | Delete
[1] Fix | Delete
use flow\db\FFDB;
[2] Fix | Delete
use flow\db\FFDBManager;
[3] Fix | Delete
use flow\db\FFDBMigrationManager;
[4] Fix | Delete
use la\core\cache\LAFacebookCacheAdapter;
[5] Fix | Delete
use la\core\db\LADB;
[6] Fix | Delete
use la\core\db\LADDLUtils;
[7] Fix | Delete
use la\core\LAActivatorBase;
[8] Fix | Delete
use la\core\LAUtils;
[9] Fix | Delete
use la\core\snapshots\LASnapshotManager;
[10] Fix | Delete
use ReflectionException;
[11] Fix | Delete
use wpdb;
[12] Fix | Delete
[13] Fix | Delete
class FlowFlowActivator extends LAActivatorBase{
[14] Fix | Delete
[15] Fix | Delete
/**
[16] Fix | Delete
* @throws ReflectionException
[17] Fix | Delete
*/
[18] Fix | Delete
protected function checkPlugin(){
[19] Fix | Delete
$mm = new FFDBMigrationManager($this->context);
[20] Fix | Delete
$mm->migrate();
[21] Fix | Delete
unset($mm);
[22] Fix | Delete
}
[23] Fix | Delete
[24] Fix | Delete
/**
[25] Fix | Delete
* @param $file
[26] Fix | Delete
*
[27] Fix | Delete
* @return array
[28] Fix | Delete
*/
[29] Fix | Delete
protected function initContext($file){
[30] Fix | Delete
/** @var wpdb $wpdb */
[31] Fix | Delete
$wpdb = $GLOBALS['wpdb'];
[32] Fix | Delete
[33] Fix | Delete
$context = [
[34] Fix | Delete
'root' => plugin_dir_path($file),
[35] Fix | Delete
'slug' => 'flow-flow',
[36] Fix | Delete
'slug_down' => 'flow_flow',
[37] Fix | Delete
'plugin_url' => plugin_dir_url(dirname($file).'/'),
[38] Fix | Delete
'plugin_dir_name' => basename(dirname($file)),
[39] Fix | Delete
'admin_url' => admin_url('admin-ajax.php'),
[40] Fix | Delete
'table_name_prefix' => $wpdb->prefix . 'ff_',
[41] Fix | Delete
'version' => '4.8.3',
[42] Fix | Delete
'faq_url' => 'https://docs.social-streams.com/',
[43] Fix | Delete
'count_posts_4init' => 30
[44] Fix | Delete
];
[45] Fix | Delete
$adapter = new LAFacebookCacheAdapter();
[46] Fix | Delete
$context['facebook_cache'] = $adapter;
[47] Fix | Delete
$context['db_manager'] = new FFDBManager($context);
[48] Fix | Delete
$adapter->setContext($context);
[49] Fix | Delete
return $context;
[50] Fix | Delete
}
[51] Fix | Delete
[52] Fix | Delete
protected function checkEnvironment(){
[53] Fix | Delete
if(version_compare(PHP_VERSION, '5.6.0') == -1){
[54] Fix | Delete
deactivate_plugins( plugin_basename( __FILE__ ) );
[55] Fix | Delete
wp_die( '<b>Flow-Flow Social Stream</b> plugin requires PHP version 5.6.0 or higher. Pls update your PHP version or ask hosting support to do this for you, you are using old and unsecure one' );
[56] Fix | Delete
}
[57] Fix | Delete
[58] Fix | Delete
if(!function_exists('curl_version')){
[59] Fix | Delete
deactivate_plugins( plugin_basename( __FILE__ ) );
[60] Fix | Delete
wp_die( '<b>Flow-Flow Social Stream</b> plugin requires curl extension for php. Please install/enable this extension or ask your hosting to help you with this.' );
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
if(!function_exists('mysqli_connect')){
[64] Fix | Delete
deactivate_plugins( plugin_basename( __FILE__ ) );
[65] Fix | Delete
wp_die( '<b>Flow-Flow Social Stream</b> plugin requires mysqli extension for MySQL. Please install/enable this extension on your server or ask your hosting to help you with this. <a href="http://php.net/manual/en/mysqli.installation.php">Installation guide</a>' );
[66] Fix | Delete
}
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
protected function singleSiteDeactivate(){
[70] Fix | Delete
wp_clear_scheduled_hook( 'flow_flow_load_cache' );
[71] Fix | Delete
wp_clear_scheduled_hook( 'flow_flow_load_cache_4disabled' );
[72] Fix | Delete
wp_clear_scheduled_hook( 'flow_flow_email_notification' );
[73] Fix | Delete
wp_clear_scheduled_hook( 'flow_flow_check_facebook_token' );
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
protected function beforePluginLoad(){
[77] Fix | Delete
parent::beforePluginLoad();
[78] Fix | Delete
[79] Fix | Delete
try {
[80] Fix | Delete
do_action('ff_addon_loaded', $this->context);
[81] Fix | Delete
} catch (\Error $e){
[82] Fix | Delete
error_log($e->getMessage());
[83] Fix | Delete
}
[84] Fix | Delete
[85] Fix | Delete
if (! defined('FF_AJAX_URL')) {
[86] Fix | Delete
$admin = function_exists('current_user_can') && current_user_can('manage_options');
[87] Fix | Delete
if (!$admin && defined('FF_ALTERNATE_GET_DATA') && FF_ALTERNATE_GET_DATA){
[88] Fix | Delete
$this->setContextValue('ajax_url', plugins_url( 'ff.php', __FILE__ ));
[89] Fix | Delete
}
[90] Fix | Delete
else {
[91] Fix | Delete
$this->setContextValue('ajax_url', admin_url('admin-ajax.php'));
[92] Fix | Delete
}
[93] Fix | Delete
[94] Fix | Delete
if (defined('FF_BOOST_SERVER') && !empty(FF_BOOST_SERVER)){
[95] Fix | Delete
$this->setContextValue('public_url', FF_BOOST_SERVER . 'flow-flow/ff');
[96] Fix | Delete
}
[97] Fix | Delete
}
[98] Fix | Delete
[99] Fix | Delete
/** @noinspection PhpExpressionResultUnusedInspection */
[100] Fix | Delete
new FlowFlowUpdater($this->context);
[101] Fix | Delete
}
[102] Fix | Delete
[103] Fix | Delete
protected function registerCronActions(){
[104] Fix | Delete
parent::registerCronActions();
[105] Fix | Delete
[106] Fix | Delete
$time = time();
[107] Fix | Delete
$ff = FlowFlow::get_instance($this->context);
[108] Fix | Delete
[109] Fix | Delete
add_action('flow_flow_load_cache', [ $ff, 'refreshCache' ] );
[110] Fix | Delete
if(false == wp_next_scheduled('flow_flow_load_cache')){
[111] Fix | Delete
wp_schedule_event($time, 'minute', 'flow_flow_load_cache');
[112] Fix | Delete
}
[113] Fix | Delete
[114] Fix | Delete
add_action('flow_flow_load_cache_4disabled', [ $ff, 'refreshCache4Disabled' ] );
[115] Fix | Delete
if(false == wp_next_scheduled('flow_flow_load_cache_4disabled')){
[116] Fix | Delete
wp_schedule_event($time, 'six_hours', 'flow_flow_load_cache_4disabled');
[117] Fix | Delete
}
[118] Fix | Delete
[119] Fix | Delete
add_action('flow_flow_email_notification', [ $ff, 'emailNotification' ] );
[120] Fix | Delete
if(false == wp_next_scheduled('flow_flow_email_notification')){
[121] Fix | Delete
wp_schedule_event($time, 'daily', 'flow_flow_email_notification');
[122] Fix | Delete
}
[123] Fix | Delete
[124] Fix | Delete
add_action('flow_flow_check_facebook_token', [$ff, 'checkFacebookToken']);
[125] Fix | Delete
if (false == wp_next_scheduled('flow_flow_check_facebook_token')){
[126] Fix | Delete
wp_schedule_event($time, 'daily', 'flow_flow_check_facebook_token');
[127] Fix | Delete
}
[128] Fix | Delete
}
[129] Fix | Delete
[130] Fix | Delete
protected function registerShutdownActions() {
[131] Fix | Delete
add_action( 'shutdown', [ $this, 'shutdownAction' ] );
[132] Fix | Delete
}
[133] Fix | Delete
[134] Fix | Delete
/** @noinspection DuplicatedCode */
[135] Fix | Delete
protected function registerAjaxActions(){
[136] Fix | Delete
$dbm = LAUtils::dbm($this->context);
[137] Fix | Delete
$slug_down = LAUtils::slug_down($this->context);
[138] Fix | Delete
$ff = FlowFlow::get_instance($this->context);
[139] Fix | Delete
[140] Fix | Delete
// public endpoints
[141] Fix | Delete
add_action('wp_ajax_fetch_posts', [ $ff, 'processAjaxRequest' ] );
[142] Fix | Delete
add_action('wp_ajax_nopriv_fetch_posts', [ $ff, 'processAjaxRequest' ] );
[143] Fix | Delete
add_action('wp_ajax_load_cache', [ $ff, 'processAjaxRequestBackground' ] );
[144] Fix | Delete
add_action('wp_ajax_nopriv_load_cache', [ $ff, 'processAjaxRequestBackground' ] );
[145] Fix | Delete
add_action('wp_ajax_' . $slug_down . '_load_comments_and_carousel', [ $ff, 'loadCommentsAndCarousel' ] );
[146] Fix | Delete
add_action('wp_ajax_nopriv_' . $slug_down . '_load_comments_and_carousel', [ $ff, 'loadCommentsAndCarousel' ] );
[147] Fix | Delete
[148] Fix | Delete
// roles detect
[149] Fix | Delete
add_action('wp_ajax_' . $slug_down . '_moderation_apply_action', [ $ff, 'moderation_apply' ] );
[150] Fix | Delete
[151] Fix | Delete
// secured endpoints
[152] Fix | Delete
add_action('wp_ajax_' . $slug_down . '_sources', [ $dbm, 'get_sources' ] );
[153] Fix | Delete
add_action('wp_ajax_' . $slug_down . '_social_auth', [ $dbm, 'social_auth' ] );
[154] Fix | Delete
add_action('wp_ajax_' . $slug_down . '_save_sources_settings', [ $dbm, 'save_sources_settings' ] );
[155] Fix | Delete
add_action('wp_ajax_' . $slug_down . '_get_stream_settings', [ $dbm, 'get_stream_settings' ] );
[156] Fix | Delete
add_action('wp_ajax_' . $slug_down . '_get_shortcode_pages', [ $dbm, 'get_shortcode_pages' ] );
[157] Fix | Delete
add_action('wp_ajax_' . $slug_down . '_ff_save_settings', [ $dbm, 'ff_save_settings_fn' ] );
[158] Fix | Delete
add_action('wp_ajax_' . $slug_down . '_save_stream_settings', [ $dbm, 'save_stream_settings' ] );
[159] Fix | Delete
add_action('wp_ajax_' . $slug_down . '_create_stream', [ $dbm, 'create_stream' ] );
[160] Fix | Delete
add_action('wp_ajax_' . $slug_down . '_clone_stream', [ $dbm, 'clone_stream' ] );
[161] Fix | Delete
add_action('wp_ajax_' . $slug_down . '_delete_stream', [ $dbm, 'delete_stream' ] );
[162] Fix | Delete
[163] Fix | Delete
//boosts
[164] Fix | Delete
add_action('wp_ajax_' . $slug_down . '_get_boosts', [ $dbm, 'get_boosts' ] );
[165] Fix | Delete
add_action('wp_ajax_' . $slug_down . '_payment_success', [ $dbm, 'paymentSuccess' ] );
[166] Fix | Delete
add_action('wp_ajax_' . $slug_down . '_upgrade_subscription', [ $dbm, 'upgradeSubscription' ] );
[167] Fix | Delete
add_action('wp_ajax_' . $slug_down . '_cancel_subscription', [ $dbm, 'cancelSubscription' ] );
[168] Fix | Delete
add_action('wp_ajax_' . $slug_down . '_clear_subscription', [ $dbm, 'clearSubscriptionCache' ] );
[169] Fix | Delete
[170] Fix | Delete
new LASnapshotManager($this->context);
[171] Fix | Delete
[172] Fix | Delete
if (!FF_USE_WP_CRON){
[173] Fix | Delete
add_action('wp_ajax_' . $slug_down . '_refresh_cache', [ $ff, 'refreshCache' ] );
[174] Fix | Delete
add_action('wp_ajax_nopriv_' . $slug_down . '_refresh_cache', [ $ff, 'refreshCache' ] );
[175] Fix | Delete
}
[176] Fix | Delete
}
[177] Fix | Delete
[178] Fix | Delete
protected function renderAdminSide(){
[179] Fix | Delete
/** @noinspection PhpExpressionResultUnusedInspection */
[180] Fix | Delete
new FlowFlowAdmin($this->context);
[181] Fix | Delete
}
[182] Fix | Delete
[183] Fix | Delete
protected function renderPublicSide(){
[184] Fix | Delete
$ff = FlowFlow::get_instance($this->context);
[185] Fix | Delete
add_action('init', [ $ff, 'register_shortcodes' ] );
[186] Fix | Delete
add_action('init', [ $ff, 'load_plugin_textdomain' ] );
[187] Fix | Delete
add_action('wp_enqueue_scripts', [ $ff, 'enqueue_scripts' ] );
[188] Fix | Delete
add_action('wpmu_new_blog', [ $ff, 'activate_new_site' ] );
[189] Fix | Delete
}
[190] Fix | Delete
[191] Fix | Delete
public function shutdownAction(){
[192] Fix | Delete
[193] Fix | Delete
$error = error_get_last();
[194] Fix | Delete
[195] Fix | Delete
if( is_null( $error ) ) {
[196] Fix | Delete
return;
[197] Fix | Delete
}
[198] Fix | Delete
[199] Fix | Delete
$fatals = [
[200] Fix | Delete
E_USER_ERROR => 'Fatal Error',
[201] Fix | Delete
E_ERROR => 'Fatal Error',
[202] Fix | Delete
E_PARSE => 'Parse Error',
[203] Fix | Delete
E_CORE_ERROR => 'Core Error',
[204] Fix | Delete
E_CORE_WARNING => 'Core Warning',
[205] Fix | Delete
E_COMPILE_ERROR => 'Compile Error',
[206] Fix | Delete
E_COMPILE_WARNING => 'Compile Warning'
[207] Fix | Delete
];
[208] Fix | Delete
[209] Fix | Delete
// check if error related to flow-flow
[210] Fix | Delete
if ( strpos( $error['file'], 'flow-flow' ) !== false && isset( $fatals[ $error['type'] ] ) ) {
[211] Fix | Delete
[212] Fix | Delete
// error_log(print_r(debug_backtrace(), true));
[213] Fix | Delete
[214] Fix | Delete
$msg = $fatals[ $error['type'] ] . ': ' . $error['message'] . ' in ';
[215] Fix | Delete
$msg .= $error['file'] . ' on line ' . $error['line'] . PHP_EOL;
[216] Fix | Delete
[217] Fix | Delete
if (!empty( $msg )) {
[218] Fix | Delete
[219] Fix | Delete
error_log( $msg , 3, FF_LOG_FILE_DEST);
[220] Fix | Delete
[221] Fix | Delete
}
[222] Fix | Delete
[223] Fix | Delete
}
[224] Fix | Delete
[225] Fix | Delete
}
[226] Fix | Delete
[227] Fix | Delete
/**
[228] Fix | Delete
* Use this method fpr old php version
[229] Fix | Delete
* @deprecated
[230] Fix | Delete
*/
[231] Fix | Delete
public function initWPWidget(){
[232] Fix | Delete
if (!defined('FF_ENABLE_WIDGET') || FF_ENABLE_WIDGET){
[233] Fix | Delete
$widget = new FlowFlowWPWidget();
[234] Fix | Delete
$widget->setContext($this->context);
[235] Fix | Delete
register_widget($widget);
[236] Fix | Delete
}
[237] Fix | Delete
}
[238] Fix | Delete
[239] Fix | Delete
/**
[240] Fix | Delete
* Use this method fpr old php version
[241] Fix | Delete
* @deprecated
[242] Fix | Delete
*/
[243] Fix | Delete
public function initVCIntegration(){
[244] Fix | Delete
$dbm = LAUtils::dbm($this->context);
[245] Fix | Delete
[246] Fix | Delete
//Important!
[247] Fix | Delete
//It will be execute before migrations!
[248] Fix | Delete
//Need to check exist tables and fields!
[249] Fix | Delete
$streams = [];
[250] Fix | Delete
if (LADDLUtils::existTable($dbm->conn(), $dbm->streams_table_name)) {
[251] Fix | Delete
$streams = LADB::streams( $dbm->conn(), $dbm->streams_table_name );
[252] Fix | Delete
}
[253] Fix | Delete
[254] Fix | Delete
$stream_options = [];
[255] Fix | Delete
if(sizeof($streams)){
[256] Fix | Delete
foreach($streams as $id => $stream){
[257] Fix | Delete
$stream_options['Stream #' . $id . ( $stream['name'] ? ' - ' . $stream['name'] : '')] = $id;
[258] Fix | Delete
}
[259] Fix | Delete
}
[260] Fix | Delete
[261] Fix | Delete
/** @noinspection PhpUndefinedFunctionInspection */
[262] Fix | Delete
vc_map( [
[263] Fix | Delete
"name" => __("Social Stream"),
[264] Fix | Delete
'admin_enqueue_css' => [ LAUtils::plugin_url($this->context) . '/css/admin-icon.css' ],
[265] Fix | Delete
'front_enqueue_css' => [ LAUtils::plugin_url($this->context) . '/css/admin-icon.css' ],
[266] Fix | Delete
'icon' => 'streams-icon',
[267] Fix | Delete
"description" => __("Flow-Flow plugin social stream"),
[268] Fix | Delete
"base" => "ff",
[269] Fix | Delete
"category" => __('Social'),
[270] Fix | Delete
"weight" => 0,
[271] Fix | Delete
"params" => [
[272] Fix | Delete
[
[273] Fix | Delete
'type' => 'dropdown',
[274] Fix | Delete
'class' => '',
[275] Fix | Delete
'admin_label' => true,
[276] Fix | Delete
"holder" => "div",
[277] Fix | Delete
"heading" => __("Choose stream to place on page:" ),
[278] Fix | Delete
"description" => "Please create and edit stream on plugin's page in admin.",
[279] Fix | Delete
"param_name" => "id",
[280] Fix | Delete
"value" => $stream_options,
[281] Fix | Delete
"std" => '--'
[282] Fix | Delete
]
[283] Fix | Delete
]
[284] Fix | Delete
] );
[285] Fix | Delete
}
[286] Fix | Delete
}
[287] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function