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: LAAdminBase.php
<?php namespace la\core;
[0] Fix | Delete
if ( ! defined( 'WPINC' ) ) die;
[1] Fix | Delete
[2] Fix | Delete
use Exception;
[3] Fix | Delete
use la\core\cache\LAFacebookCacheManager;
[4] Fix | Delete
use la\core\db\LADBManager;
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* FlowFlow.
[8] Fix | Delete
*
[9] Fix | Delete
* @property array | null $context
[10] Fix | Delete
*
[11] Fix | Delete
* @package FlowFlow
[12] Fix | Delete
* @author Looks Awesome <email@looks-awesome.com>
[13] Fix | Delete
*
[14] Fix | Delete
* @link http://looks-awesome.com
[15] Fix | Delete
* @copyright Looks Awesome
[16] Fix | Delete
*/
[17] Fix | Delete
abstract class LAAdminBase {
[18] Fix | Delete
/** @var LADBManager $db */
[19] Fix | Delete
protected $db = null;
[20] Fix | Delete
protected $context = null;
[21] Fix | Delete
protected $plugin_slug = null;
[22] Fix | Delete
[23] Fix | Delete
public function __construct($context) {
[24] Fix | Delete
$this->context = $context;
[25] Fix | Delete
$this->plugin_slug = LAUtils::slug($context);
[26] Fix | Delete
$this->db = LAUtils::dbm($context);
[27] Fix | Delete
[28] Fix | Delete
// Load admin style sheet and JavaScript.
[29] Fix | Delete
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_admin_scripts' ] );
[30] Fix | Delete
[31] Fix | Delete
// Add the options page and menu item.
[32] Fix | Delete
add_action( 'admin_menu', [ $this, 'add_social_stream_admin_menu' ] );
[33] Fix | Delete
[34] Fix | Delete
$plugin_basename = $context['plugin_dir_name'] . '/' . LAUtils::slug($context) . '.php';
[35] Fix | Delete
add_filter( 'plugin_action_links_' . $plugin_basename, [ $this, 'add_action_links' ] );
[36] Fix | Delete
[37] Fix | Delete
// Add the options page and menu item.
[38] Fix | Delete
add_action( 'admin_menu', [ $this, 'add_plugin_admin_menu' ] );
[39] Fix | Delete
[40] Fix | Delete
foreach (['date_format', 'time_format', 'timezone_string', 'WPLANG'] as $option){
[41] Fix | Delete
add_action( "update_option_{$option}", [$this->db, 'update_wp_date_format_hook'], 10, 3);
[42] Fix | Delete
}
[43] Fix | Delete
}
[44] Fix | Delete
[45] Fix | Delete
public function getPluginSlug() {
[46] Fix | Delete
return $this->plugin_slug;
[47] Fix | Delete
}
[48] Fix | Delete
[49] Fix | Delete
/**
[50] Fix | Delete
* Register the administration menu for this plugin into the WordPress Dashboard menu.
[51] Fix | Delete
*
[52] Fix | Delete
* @since 1.0.0
[53] Fix | Delete
*/
[54] Fix | Delete
public final function add_social_stream_admin_menu(){
[55] Fix | Delete
$this->addPluginAdminMenu( [ $this, 'display_plugin_admin_page' ] );
[56] Fix | Delete
}
[57] Fix | Delete
[58] Fix | Delete
/**
[59] Fix | Delete
* Register the administration menu for this plugin into the WordPress Dashboard menu.
[60] Fix | Delete
*
[61] Fix | Delete
* @since 1.0.0
[62] Fix | Delete
*/
[63] Fix | Delete
public final function add_plugin_admin_menu(){
[64] Fix | Delete
$this->addPluginAdminSubMenu( [ $this, 'display_plugin_admin_subpage' ] );
[65] Fix | Delete
}
[66] Fix | Delete
[67] Fix | Delete
/**
[68] Fix | Delete
* Register and enqueue admin-specific style sheet and JavaScript.
[69] Fix | Delete
*
[70] Fix | Delete
* @param $hook
[71] Fix | Delete
*
[72] Fix | Delete
* @since 1.0.0
[73] Fix | Delete
*/
[74] Fix | Delete
public final function enqueue_admin_scripts($hook) {
[75] Fix | Delete
$screen_id = 'social-apps_page_' . $this->getPluginSlug() . '-admin';
[76] Fix | Delete
$plugin_directory = $this->context['plugin_url'] . $this->context['plugin_dir_name'] . '/';
[77] Fix | Delete
$this->enqueueAdminStylesAlways($plugin_directory);
[78] Fix | Delete
$this->enqueueAdminScriptsAlways($plugin_directory);
[79] Fix | Delete
do_action('ff_enqueue_admin_resources');
[80] Fix | Delete
[81] Fix | Delete
if ($hook == 'toplevel_page_flow-flow'){
[82] Fix | Delete
$this->enqueueAdminStylesOnlyAtNewsPage($plugin_directory);
[83] Fix | Delete
$this->enqueueAdminScriptsOnlyAtNewsPage($plugin_directory);
[84] Fix | Delete
}
[85] Fix | Delete
else if ( $screen_id == $hook ) {
[86] Fix | Delete
$this->initPluginAdminPage();
[87] Fix | Delete
$this->enqueueAdminStylesOnlyAtPluginPage($plugin_directory);
[88] Fix | Delete
$this->enqueueAdminScriptsOnlyAtPluginPage($plugin_directory);
[89] Fix | Delete
do_action('ff_enqueue_admin_resources_only_at_plugin_page');
[90] Fix | Delete
}
[91] Fix | Delete
}
[92] Fix | Delete
[93] Fix | Delete
/**
[94] Fix | Delete
* Render the settings page for this plugin.
[95] Fix | Delete
*
[96] Fix | Delete
* @throws Exception
[97] Fix | Delete
* @since 1.0.0
[98] Fix | Delete
*/
[99] Fix | Delete
public final function display_plugin_admin_page() {
[100] Fix | Delete
if (FF_USE_WP){
[101] Fix | Delete
if ( !current_user_can( 'manage_options' ) ) {
[102] Fix | Delete
wp_die( __( 'You do not have sufficient permissions to access this page.', $this->getPluginSlug()));
[103] Fix | Delete
}
[104] Fix | Delete
$this->context['admin_page_title'] = esc_html( get_admin_page_title() );
[105] Fix | Delete
}
[106] Fix | Delete
else {
[107] Fix | Delete
if (!isset($this->context['admin_page_title'])) $this->context['admin_page_title'] = 'Flow-Flow - Social Streams Plugin';
[108] Fix | Delete
}
[109] Fix | Delete
$this->displayPluginAdminPage();
[110] Fix | Delete
}
[111] Fix | Delete
[112] Fix | Delete
/**
[113] Fix | Delete
* Add settings action link to the plugins page.
[114] Fix | Delete
*
[115] Fix | Delete
* @since 1.0.0
[116] Fix | Delete
*
[117] Fix | Delete
* @param $links
[118] Fix | Delete
*
[119] Fix | Delete
* @return array
[120] Fix | Delete
*/
[121] Fix | Delete
public final function add_action_links( $links ) {
[122] Fix | Delete
return array_merge($this->addActionLinks(), $links);
[123] Fix | Delete
}
[124] Fix | Delete
[125] Fix | Delete
/**
[126] Fix | Delete
* Render the settings page for this plugin.
[127] Fix | Delete
* @throws Exception
[128] Fix | Delete
* @since 1.0.0
[129] Fix | Delete
*/
[130] Fix | Delete
public final function display_plugin_admin_subpage(){
[131] Fix | Delete
$context = $this->contextForAdminPage();
[132] Fix | Delete
/** @noinspection PhpIncludeInspection */
[133] Fix | Delete
include_once( $context['root'] . 'views/admin.php');
[134] Fix | Delete
}
[135] Fix | Delete
[136] Fix | Delete
protected abstract function initPluginAdminPage();
[137] Fix | Delete
protected abstract function addPluginAdminSubMenu($displayAdminPageFunction);
[138] Fix | Delete
[139] Fix | Delete
protected abstract function enqueueAdminStylesAlways($plugin_directory);
[140] Fix | Delete
protected abstract function enqueueAdminScriptsAlways($plugin_directory);
[141] Fix | Delete
protected function enqueueAdminStylesOnlyAtNewsPage($plugin_directory){
[142] Fix | Delete
wp_enqueue_style('social-streams-news-styles', $plugin_directory . 'css/news.css', [], '1.0');
[143] Fix | Delete
}
[144] Fix | Delete
protected function enqueueAdminScriptsOnlyAtNewsPage($plugin_directory){
[145] Fix | Delete
wp_enqueue_script('social-streams-news', $plugin_directory . 'js/news.js', [ 'jquery', 'underscore' ], '1.0');
[146] Fix | Delete
wp_localize_script('social-streams-news', 'FFIADMIN', [
[147] Fix | Delete
'assets_url' => $this->context['plugin_url'] . '/' . $this->context['slug'],
[148] Fix | Delete
'plugins' => $this->getPluginsState(),
[149] Fix | Delete
'requirements' => [
[150] Fix | Delete
'php_status' => version_compare(phpversion(), '5.3', '>='),
[151] Fix | Delete
'php' => preg_replace("(-.+)", '', phpversion()),
[152] Fix | Delete
'wp_status' => (float)get_bloginfo('version') > 4,
[153] Fix | Delete
'wp' => get_bloginfo('version'),
[154] Fix | Delete
'memory_status' => preg_replace('/[^0-9]/', '', ini_get('memory_limit')) >= 32,
[155] Fix | Delete
'memory' => ini_get('memory_limit'),
[156] Fix | Delete
'upload_status' => preg_replace('/[^0-9]/', '', ini_get('upload_max_filesize')) >= 64,
[157] Fix | Delete
'upload' => ini_get('upload_max_filesize')
[158] Fix | Delete
]
[159] Fix | Delete
] );
[160] Fix | Delete
}
[161] Fix | Delete
protected abstract function enqueueAdminStylesOnlyAtPluginPage($plugin_directory);
[162] Fix | Delete
protected function enqueueAdminScriptsOnlyAtPluginPage($plugin_directory){
[163] Fix | Delete
// Enqueue scripts
[164] Fix | Delete
wp_enqueue_script( $this->getPluginSlug() . '-streams-script', $plugin_directory . 'js/streams.js', [ 'jquery' ], LAUtils::version($this->context));
[165] Fix | Delete
wp_enqueue_script( $this->getPluginSlug() . '-admin-script', $plugin_directory . 'js/admin.js', [ 'jquery', 'backbone', 'underscore' ], LAUtils::version($this->context));
[166] Fix | Delete
wp_enqueue_script( $this->getPluginSlug() . '-zeroclipboard', $plugin_directory . 'js/zeroclipboard/ZeroClipboard.min.js', [ 'jquery' ], LAUtils::version($this->context));
[167] Fix | Delete
wp_enqueue_script( $this->getPluginSlug() . '-tinycolor', $plugin_directory . 'js/tinycolor.js', [ 'jquery' ], LAUtils::version($this->context));
[168] Fix | Delete
wp_enqueue_script( $this->getPluginSlug() . '-colorpickersliders', $plugin_directory . 'js/jquery.colorpickersliders.js', [ 'jquery' ], LAUtils::version($this->context));
[169] Fix | Delete
[170] Fix | Delete
wp_localize_script($this->getPluginSlug() . '-admin-script', 'WP_FF_admin', [] );
[171] Fix | Delete
[172] Fix | Delete
// old
[173] Fix | Delete
// wp_localize_script($this->getPluginSlug() . '-admin-script', '_nonce', wp_create_nonce('flow_flow_nonce'));
[174] Fix | Delete
// wp_localize_script($this->getPluginSlug() . '-admin-script', 'isWordpress', (string)FF_USE_WP);
[175] Fix | Delete
// wp_localize_script($this->getPluginSlug() . '-admin-script', '_ajaxurl', (string)$this->context['ajax_url']);//???
[176] Fix | Delete
// wp_localize_script($this->getPluginSlug() . '-admin-script', '_siteurl', site_url());
[177] Fix | Delete
// wp_localize_script($this->getPluginSlug() . '-admin-script', 'la_plugin_slug_down', LAUtils::slug_down($this->context));
[178] Fix | Delete
wp_localize_script($this->getPluginSlug() . '-admin-script', 'la_plugin', array('slug_down' => LAUtils::slug_down($this->context)));
[179] Fix | Delete
}
[180] Fix | Delete
[181] Fix | Delete
protected function addActionLinks(){
[182] Fix | Delete
$links['settings'] = '<a href="' . admin_url('admin.php?page=' . $this->getPluginSlug()) . '-admin' . '">' . 'Settings' . '</a>';
[183] Fix | Delete
$links['docs'] = '<a target="_blank" href="' . $this->context['faq_url'] . '">' . 'Docs' . '</a>';
[184] Fix | Delete
return $links;
[185] Fix | Delete
}
[186] Fix | Delete
[187] Fix | Delete
/**
[188] Fix | Delete
* States:
[189] Fix | Delete
* 0 - not installer
[190] Fix | Delete
* 1 - installed
[191] Fix | Delete
* 2 - activated
[192] Fix | Delete
*/
[193] Fix | Delete
private function getPluginsState(){
[194] Fix | Delete
$plugins = [
[195] Fix | Delete
'flow-flow' => [
[196] Fix | Delete
'flow-flow/flow-flow.php',
[197] Fix | Delete
'flow-flow',
[198] Fix | Delete
],
[199] Fix | Delete
'insta-flow' => [
[200] Fix | Delete
'insta-flow/insta-flow.php',
[201] Fix | Delete
'insta-flow-admin',
[202] Fix | Delete
],
[203] Fix | Delete
'social-stacks' => [
[204] Fix | Delete
'social-stacks/social-stacks.php',
[205] Fix | Delete
'social-stacks-admin',
[206] Fix | Delete
]
[207] Fix | Delete
];
[208] Fix | Delete
[209] Fix | Delete
$result = [];
[210] Fix | Delete
foreach ($plugins as $k => $v){
[211] Fix | Delete
$state = 0;
[212] Fix | Delete
if(file_exists(WP_PLUGIN_DIR . '/' . $v[0])){
[213] Fix | Delete
$state = 1;
[214] Fix | Delete
}
[215] Fix | Delete
if(is_plugin_active($v[0])){
[216] Fix | Delete
$state = 2;
[217] Fix | Delete
}
[218] Fix | Delete
$result[$k] = [
[219] Fix | Delete
'state' => $state,
[220] Fix | Delete
'plugin_page_slug' => $v[1]
[221] Fix | Delete
];
[222] Fix | Delete
}
[223] Fix | Delete
return $result;
[224] Fix | Delete
}
[225] Fix | Delete
[226] Fix | Delete
private function addPluginAdminMenu($displayAdminPageFunction){
[227] Fix | Delete
$plugin_directory = $this->context['plugin_url'] . $this->context['plugin_dir_name'];
[228] Fix | Delete
[229] Fix | Delete
$wp_version = (float)get_bloginfo('version');
[230] Fix | Delete
if ($wp_version > 3.8) { // From 3.8 WP supports SVG icons
[231] Fix | Delete
$icon = $plugin_directory . '/assets/social-streams-icon.svg';
[232] Fix | Delete
} else {
[233] Fix | Delete
$icon = 'dashicons-networking';
[234] Fix | Delete
}
[235] Fix | Delete
[236] Fix | Delete
if ( empty ( $GLOBALS['admin_page_hooks']['flow-flow'] ) ){
[237] Fix | Delete
add_menu_page(
[238] Fix | Delete
'Social Apps',
[239] Fix | Delete
'Social Apps',
[240] Fix | Delete
'manage_options',
[241] Fix | Delete
'flow-flow',
[242] Fix | Delete
$displayAdminPageFunction,
[243] Fix | Delete
$icon
[244] Fix | Delete
);
[245] Fix | Delete
}
[246] Fix | Delete
}
[247] Fix | Delete
[248] Fix | Delete
/**
[249] Fix | Delete
* @throws Exception
[250] Fix | Delete
*/
[251] Fix | Delete
private function displayPluginAdminPage(){
[252] Fix | Delete
if (FF_USE_WP){
[253] Fix | Delete
if ( !current_user_can( 'manage_options' ) ) {
[254] Fix | Delete
wp_die( __( 'You do not have sufficient permissions to access this page.', $this->getPluginSlug()));
[255] Fix | Delete
}
[256] Fix | Delete
}
[257] Fix | Delete
$context = $this->context;
[258] Fix | Delete
$activated = $this->db->registrationCheck();
[259] Fix | Delete
$this->db->dataInit();
[260] Fix | Delete
$context['activated'] = $activated;
[261] Fix | Delete
/** @noinspection PhpIncludeInspection */
[262] Fix | Delete
include_once(LAUtils::root($context) . 'views/news.php');
[263] Fix | Delete
}
[264] Fix | Delete
[265] Fix | Delete
/**
[266] Fix | Delete
* @return array|null
[267] Fix | Delete
* @throws Exception
[268] Fix | Delete
*/
[269] Fix | Delete
protected function contextForAdminPage() {
[270] Fix | Delete
$context = $this->context;
[271] Fix | Delete
$this->db->dataInit();
[272] Fix | Delete
[273] Fix | Delete
/** @var LAFacebookCacheManager $facebookCache */
[274] Fix | Delete
$facebookCache = $context['facebook_cache'];
[275] Fix | Delete
$context['activated'] = $this->db->registrationCheck();
[276] Fix | Delete
$context['admin_page_title'] = esc_html( get_admin_page_title() );
[277] Fix | Delete
$context['options'] = $this->db->getOption('options', true);
[278] Fix | Delete
$context['auth_options'] = $this->db->getOption('fb_auth_options', true);
[279] Fix | Delete
$context['extended_facebook_access_token'] = $facebookCache->getAccessToken();
[280] Fix | Delete
$context['extended_facebook_access_token_error'] = $facebookCache->getError();
[281] Fix | Delete
$context['streams'] = $this->db->streamsWithStatus();
[282] Fix | Delete
$context['sources'] = $this->db->sources();
[283] Fix | Delete
return $context;
[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