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.../libs/flowflow/core/src
File: LARemoteUpdater.php
<?php namespace la\core;
[0] Fix | Delete
[1] Fix | Delete
use stdClass;
[2] Fix | Delete
[3] Fix | Delete
/**
[4] Fix | Delete
* Flow-Flow.
[5] Fix | Delete
*
[6] Fix | Delete
* @package FlowFlow
[7] Fix | Delete
* @author Looks Awesome <email@looks-awesome.com>
[8] Fix | Delete
[9] Fix | Delete
* @link http://looks-awesome.com
[10] Fix | Delete
* @copyright Looks Awesome
[11] Fix | Delete
*/
[12] Fix | Delete
abstract class LARemoteUpdater{
[13] Fix | Delete
protected $context;
[14] Fix | Delete
private $info = null;
[15] Fix | Delete
[16] Fix | Delete
function __construct($context) {
[17] Fix | Delete
$this->context = $context;
[18] Fix | Delete
[19] Fix | Delete
global $wpdb;
[20] Fix | Delete
$table = LAUtils::dbm($context)->option_table_name;
[21] Fix | Delete
$option = LAUtils::slug_down($context) . '_registration_id';
[22] Fix | Delete
if (!empty( $wpdb->get_var($wpdb->prepare('select value from ' . $table . ' where id = %s', $option)) )){
[23] Fix | Delete
add_filter( 'pre_set_site_transient_update_plugins', [ $this, 'modify_transient' ], 10, 1 );
[24] Fix | Delete
add_filter( 'plugins_api', [ $this, 'plugin_popup' ], 10, 3);
[25] Fix | Delete
add_filter( 'upgrader_post_install', [ $this, 'after_install' ], 10, 3 );
[26] Fix | Delete
}
[27] Fix | Delete
}
[28] Fix | Delete
[29] Fix | Delete
/** @noinspection PhpUnused */
[30] Fix | Delete
public final function modify_transient( $transient ) {
[31] Fix | Delete
if( isset($transient->checked) && $transient->checked) {
[32] Fix | Delete
$info = $this->getInfo();
[33] Fix | Delete
if (version_compare($info->plugin['version'], LAUtils::version($this->context)) === 1){
[34] Fix | Delete
$plugin = $this->getPluginWithNewVersion($info);
[35] Fix | Delete
$transient->response[ $plugin->plugin ] = $plugin;
[36] Fix | Delete
}
[37] Fix | Delete
}
[38] Fix | Delete
return $transient;
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
/**
[42] Fix | Delete
* @param $result
[43] Fix | Delete
* @param $action
[44] Fix | Delete
* @param $args
[45] Fix | Delete
*
[46] Fix | Delete
* @noinspection PhpUnused
[47] Fix | Delete
* @noinspection PhpUnusedParameterInspection
[48] Fix | Delete
*/
[49] Fix | Delete
public final function plugin_popup( $result, $action, $args ) {
[50] Fix | Delete
if( ! empty( $args->slug ) ) {
[51] Fix | Delete
if( $args->slug == LAUtils::slug($this->context) ) {
[52] Fix | Delete
return $this->getPlugin($this->getInfo());
[53] Fix | Delete
}
[54] Fix | Delete
}
[55] Fix | Delete
return $result;
[56] Fix | Delete
}
[57] Fix | Delete
[58] Fix | Delete
/** @noinspection PhpUnusedParameterInspection */
[59] Fix | Delete
public final function after_install( $response, $hook_extra, $result ) {
[60] Fix | Delete
global $wp_filesystem; // Get global FS object
[61] Fix | Delete
$slug = LAUtils::slug($this->context);
[62] Fix | Delete
$destination = WP_PLUGIN_DIR . '/' . $slug .'/';
[63] Fix | Delete
$wp_filesystem->move( $result['destination'], $destination );
[64] Fix | Delete
$result['destination'] = $destination;
[65] Fix | Delete
$result['destination_name'] = $slug;
[66] Fix | Delete
return $result;
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
public final function getInfo(){
[70] Fix | Delete
if (is_null($this->info)){
[71] Fix | Delete
$this->info = $this->get_repository_info();
[72] Fix | Delete
}
[73] Fix | Delete
return $this->info;
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
protected function getPlugin($info){
[77] Fix | Delete
$plugin = [
[78] Fix | Delete
'name' => $info->plugin["name"],
[79] Fix | Delete
'slug' => $info->basename,
[80] Fix | Delete
'plugin' => $info->basename . '/' . $info->basename . '.php',
[81] Fix | Delete
'version' => $info->plugin['version'],
[82] Fix | Delete
'author' => $info->author["name"],
[83] Fix | Delete
'author_profile' => $info->author["url"],
[84] Fix | Delete
'last_updated' => $info->plugin['published_at'],
[85] Fix | Delete
'homepage' => $info->plugin["url"],
[86] Fix | Delete
'short_description' => $info->plugin["description"],
[87] Fix | Delete
'sections' => [
[88] Fix | Delete
'description' => $info->plugin["description"],
[89] Fix | Delete
'changelog' => $info->plugin["changelog"],
[90] Fix | Delete
]
[91] Fix | Delete
];
[92] Fix | Delete
if (isset($info->plugin['download_url'])) $plugin['download_link'] = $info->plugin['download_url'];
[93] Fix | Delete
return (object) $plugin;
[94] Fix | Delete
}
[95] Fix | Delete
[96] Fix | Delete
protected abstract function getPluginWithNewVersion($info);
[97] Fix | Delete
protected abstract function getUrlToPluginMetafileJson();
[98] Fix | Delete
[99] Fix | Delete
private function get_repository_info(){
[100] Fix | Delete
$db = LAUtils::dbm($this->context);
[101] Fix | Delete
$registration_id = $db->getOption('registration_id');
[102] Fix | Delete
[103] Fix | Delete
$result = wp_remote_get($this->getUrlToPluginMetafileJson());
[104] Fix | Delete
if (!is_wp_error($result) && isset($result['response']) && isset($result['response']['code']) && $result['response']['code'] == 200) {
[105] Fix | Delete
$settings = $db->getGeneralSettings()->original();
[106] Fix | Delete
if (is_array($settings) && isset($settings['purchase_code'])){
[107] Fix | Delete
$json = json_decode($result['body']);
[108] Fix | Delete
$purchase_code = $settings['purchase_code'];
[109] Fix | Delete
[110] Fix | Delete
$info = new stdClass();
[111] Fix | Delete
$info->basename = LAUtils::slug($this->context);
[112] Fix | Delete
[113] Fix | Delete
$info->plugin = [];
[114] Fix | Delete
$info->plugin["name"] = $json->item->name;
[115] Fix | Delete
$info->plugin['version'] = $json->item->version;
[116] Fix | Delete
$info->plugin['published_at'] = $json->item->updated_at;
[117] Fix | Delete
$info->plugin["url"] = $json->item->url;
[118] Fix | Delete
$info->plugin["description"] = $json->item->description;
[119] Fix | Delete
$info->plugin["changelog"] = $json->item->changelog;
[120] Fix | Delete
$info->plugin['download_url'] = $json->item->download_url . "?action=la_update&registration_id={$registration_id}&purchase_code={$purchase_code}";
[121] Fix | Delete
[122] Fix | Delete
$info->author = [];
[123] Fix | Delete
$info->author["url"] = $json->author->url;
[124] Fix | Delete
$info->author["name"] = $json->author->name;
[125] Fix | Delete
[126] Fix | Delete
return $info;
[127] Fix | Delete
}
[128] Fix | Delete
}
[129] Fix | Delete
return null;
[130] Fix | Delete
}
[131] Fix | Delete
}
[132] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function