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/clone/wp-conte.../plugins/ninja-fo.../includes/Admin/Menus
File: Addons.php
<?php if ( ! defined( 'ABSPATH' ) ) exit;
[0] Fix | Delete
[1] Fix | Delete
final class NF_Admin_Menus_Addons extends NF_Abstracts_Submenu
[2] Fix | Delete
{
[3] Fix | Delete
public $parent_slug = 'ninja-forms';
[4] Fix | Delete
[5] Fix | Delete
public $menu_slug = 'ninja-forms#add-ons';
[6] Fix | Delete
[7] Fix | Delete
public $position = 7;
[8] Fix | Delete
[9] Fix | Delete
public function __construct()
[10] Fix | Delete
{
[11] Fix | Delete
$disable_marketing = false;
[12] Fix | Delete
if ( ! apply_filters( 'ninja_forms_disable_marketing', $disable_marketing ) ) {
[13] Fix | Delete
parent::__construct();
[14] Fix | Delete
}
[15] Fix | Delete
[16] Fix | Delete
add_action( 'admin_init', array( $this, 'nf_upgrade_redirect' ) );
[17] Fix | Delete
}
[18] Fix | Delete
[19] Fix | Delete
/**
[20] Fix | Delete
* If we have required updates, unregister the menu item
[21] Fix | Delete
*/
[22] Fix | Delete
public function nf_upgrade_redirect() {
[23] Fix | Delete
global $pagenow;
[24] Fix | Delete
[25] Fix | Delete
if( "1" == get_option( 'ninja_forms_needs_updates' ) ) {
[26] Fix | Delete
remove_submenu_page( $this->parent_slug, $this->menu_slug );
[27] Fix | Delete
}
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
public function get_page_title()
[31] Fix | Delete
{
[32] Fix | Delete
$title = '<span style="color:#84cc1e">' . esc_html__( 'Add-Ons', 'ninja-forms' ) . '</span>';
[33] Fix | Delete
[34] Fix | Delete
return $title;
[35] Fix | Delete
}
[36] Fix | Delete
[37] Fix | Delete
public function get_capability()
[38] Fix | Delete
{
[39] Fix | Delete
return apply_filters( 'ninja_forms_admin_extend_capabilities', $this->capability );
[40] Fix | Delete
}
[41] Fix | Delete
[42] Fix | Delete
public function display()
[43] Fix | Delete
{
[44] Fix | Delete
// Fetch our marketing feed.
[45] Fix | Delete
$saved = get_option( 'ninja_forms_addons_feed', false );
[46] Fix | Delete
// If we got back nothing...
[47] Fix | Delete
if ( ! $saved ) {
[48] Fix | Delete
// Default to the in-app file.
[49] Fix | Delete
$items = file_get_contents( Ninja_Forms::$dir . '/lib/Legacy/addons-feed.json' );
[50] Fix | Delete
$items = json_decode( $items, true );
[51] Fix | Delete
} // Otherwise... (We did get something from the db.)
[52] Fix | Delete
else {
[53] Fix | Delete
// Use the data we fetched.
[54] Fix | Delete
$items = json_decode( $saved, true );
[55] Fix | Delete
}
[56] Fix | Delete
//shuffle( $items );
[57] Fix | Delete
[58] Fix | Delete
$notices = array();
[59] Fix | Delete
[60] Fix | Delete
//Check if an affiliate ID is set
[61] Fix | Delete
$u_id = get_option( 'nf_aff', false );
[62] Fix | Delete
if ( !$u_id ) $u_id = apply_filters( 'ninja_forms_affiliate_id', false );
[63] Fix | Delete
[64] Fix | Delete
foreach ($items as &$item) {
[65] Fix | Delete
$plugin_data = array();
[66] Fix | Delete
if( !empty( $item['plugin'] ) && file_exists( WP_PLUGIN_DIR.'/'.$item['plugin'] ) ){
[67] Fix | Delete
$plugin_data = get_plugin_data( WP_PLUGIN_DIR.'/'.$item['plugin'], false, true );
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
if ( ! file_exists( Ninja_Forms::$dir . '/' . $item[ 'image' ] ) ) {
[71] Fix | Delete
$item[ 'image' ] = 'assets/img/add-ons/placeholder.png';
[72] Fix | Delete
}
[73] Fix | Delete
[74] Fix | Delete
$version = isset ( $plugin_data['Version'] ) ? $plugin_data['Version'] : '';
[75] Fix | Delete
[76] Fix | Delete
//Rewrite link for affiliates
[77] Fix | Delete
if ( $u_id && $item[ 'link' ]) {
[78] Fix | Delete
$last_slash = strripos( $item[ 'link' ], '/' );
[79] Fix | Delete
$item[ 'link' ] = substr( $item[ 'link' ], 0, $last_slash );
[80] Fix | Delete
$item[ 'link' ] = urlencode( $item[ 'link' ] );
[81] Fix | Delete
$item[ 'link' ] = 'http://www.shareasale.com/r.cfm?u=' . $u_id . '&b=812237&m=63061&afftrack=&urllink=' . $item[ 'link' ];
[82] Fix | Delete
}
[83] Fix | Delete
[84] Fix | Delete
if ( ! empty ( $version ) && $version < $item['version'] ) {
[85] Fix | Delete
[86] Fix | Delete
$notices[] = array(
[87] Fix | Delete
'title' => $item[ 'title' ],
[88] Fix | Delete
'old_version' => $version,
[89] Fix | Delete
'new_version' => $item[ 'version' ]
[90] Fix | Delete
);
[91] Fix | Delete
}
[92] Fix | Delete
[93] Fix | Delete
$item["status"] = self::getItemStatus($item);
[94] Fix | Delete
}
[95] Fix | Delete
[96] Fix | Delete
$groups = [
[97] Fix | Delete
'advanced' => [
[98] Fix | Delete
'title' => __( 'Advanced Form Features', 'ninja-forms' ),
[99] Fix | Delete
'items' => self::filterItemsByCategroy( $items, 'advanced-form-features' ),
[100] Fix | Delete
],
[101] Fix | Delete
'submissions' => [
[102] Fix | Delete
'title' => __( 'Submissions Extended', 'ninja-forms' ),
[103] Fix | Delete
'items' => self::filterItemsByCategroy( $items, 'submissions-extended' ),
[104] Fix | Delete
],
[105] Fix | Delete
'payments' => [
[106] Fix | Delete
'title' => __( 'Accept Payments', 'ninja-forms' ),
[107] Fix | Delete
'items' => self::filterItemsByCategroy( $items, 'accept-payments' ),
[108] Fix | Delete
],
[109] Fix | Delete
'automation' => [
[110] Fix | Delete
'title' => __( 'Automation', 'ninja-forms' ),
[111] Fix | Delete
'items' => self::filterItemsByCategroy( $items, 'automation' ),
[112] Fix | Delete
],
[113] Fix | Delete
'marketing' => [
[114] Fix | Delete
'title' => __( 'Email Marketing', 'ninja-forms' ),
[115] Fix | Delete
'items' => self::filterItemsByCategroy( $items, 'email-marketing' ),
[116] Fix | Delete
],
[117] Fix | Delete
'crm' => [
[118] Fix | Delete
'title' => __( 'CRMs', 'ninja-forms' ),
[119] Fix | Delete
'items' => self::filterItemsByCategroy( $items, 'crm-integrations' ),
[120] Fix | Delete
],
[121] Fix | Delete
'notifications' => [
[122] Fix | Delete
'title' => __( 'Notifications & Workflow', 'ninja-forms' ),
[123] Fix | Delete
'items' => self::filterItemsByCategroy( $items, 'notification-workflow' ),
[124] Fix | Delete
],
[125] Fix | Delete
];
[126] Fix | Delete
[127] Fix | Delete
return [
[128] Fix | Delete
"notices" => $notices,
[129] Fix | Delete
"groups" => $groups,
[130] Fix | Delete
"items" => $items
[131] Fix | Delete
];
[132] Fix | Delete
}
[133] Fix | Delete
[134] Fix | Delete
public static function filterItemsByCategroy( $items, $category ) {
[135] Fix | Delete
return array_filter( $items, function( $item ) use ($category) {
[136] Fix | Delete
return array_filter( $item['categories'], function( $itemCategory ) use ($category){
[137] Fix | Delete
return $category === $itemCategory['slug'];
[138] Fix | Delete
});
[139] Fix | Delete
});
[140] Fix | Delete
}
[141] Fix | Delete
[142] Fix | Delete
public static function getItemStatus( $item ) {
[143] Fix | Delete
$status = "unknown";
[144] Fix | Delete
[145] Fix | Delete
if( ! empty( $item['plugin'] ) && file_exists( WP_PLUGIN_DIR.'/'.$item['plugin'] ) ) {
[146] Fix | Delete
[147] Fix | Delete
if( is_plugin_active( $item['plugin'] ) ) {
[148] Fix | Delete
$status = 'active';
[149] Fix | Delete
} elseif( is_plugin_inactive( $item['plugin'] ) ) {
[150] Fix | Delete
$status = "installed";
[151] Fix | Delete
}
[152] Fix | Delete
[153] Fix | Delete
}
[154] Fix | Delete
return $status;
[155] Fix | Delete
}
[156] Fix | Delete
[157] Fix | Delete
} // End Class NF_Admin_Addons
[158] Fix | Delete
[159] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function