$plug ) { self::$slugs[ $plug[ 'id' ] ] = $plug[ 'slug' ]; if ( isset( $options[ 'plugin_key' ][ $plug[ 'id' ] ] ) && $options[ 'plugin_key' ][ $plug[ 'id' ] ] != '' ) { $plugin[ $plug_id ][ 'key' ] = $options[ 'plugin_key' ][ $plug[ 'id' ] ]; } elseif ( isset( $plugin[ $plug_id ][ 'key' ] ) && $plugin[ $plug_id ][ 'key' ] != '' ) { $options[ 'plugin_key' ][ $plug[ 'id' ] ] = $plugin[ $plug_id ][ 'key' ]; $update = true; } } self::$plugin_info = $plugin; if ( $update ) { self::set_options( $options ); } add_filter( 'berocket_display_additional_notices', array( __CLASS__, 'berocket_display_additional_notices' ) ); if( ! is_network_admin() ) { add_filter( 'custom_menu_order', array( __CLASS__, 'wp_menu_order' ) ); } //ADMIN NOTICE CHECK add_filter( 'berocket_admin_notice_is_display_notice', array( __CLASS__, 'admin_notice_is_display_notice' ), 10, 3 ); add_filter( 'berocket_admin_notice_is_display_notice_priority', array( __CLASS__, 'admin_notice_is_display_notice' ), 10, 3 ); } public static function error_log() { if ( self::$debug_mode ) { self::$error_log = apply_filters( 'BeRocket_updater_error_log', self::$error_log ); self::$error_log[ 'real_memory_usage' ] = memory_get_peak_usage( true ); self::$error_log[ 'script_memory_usage' ] = memory_get_peak_usage( false ); self::$error_log[ 'memory_limit' ] = ini_get( 'memory_limit' ); self::$error_log[ 'WP_DEBUG' ] = 'WP_DEBUG:' . ( defined( 'WP_DEBUG' ) ? ( WP_DEBUG ? 'true' : 'false' ) : 'false' ) . '; WP_DEBUG_DISPLAY:' . ( defined( 'WP_DEBUG_DISPLAY' ) ? ( WP_DEBUG_DISPLAY ? 'true' : 'false' ) : 'false' ); ?> " . $item[ 0 ] . ""; $new_sub_order[ $compatibility_hack[ str_replace( "edit.php?post_type=", "", $item[ 2 ] ) ] ][] = $item; } else { $new_order_temp[] = $item; $new_order_sort[] = $item[ 0 ]; } } $new_sub_order = apply_filters('BeRocket_updater_menu_order_sub_order', $new_sub_order); array_multisort( $new_order_sort, $new_order_temp ); $new_order = array(); if( $BeRocket_item !== false ) { $new_order[] = $BeRocket_item; } foreach ( $new_order_temp as $item ) { $new_order[] = $item; if ( ! empty( $new_sub_order[ $item[ 2 ] ] ) ) { foreach ( $new_sub_order[ $item[ 2 ] ] as $sub_item ) { $new_order[] = $sub_item; } } } if( $account_keys_item !== false ) { $new_order[] = $account_keys_item; } $submenu[ 'berocket_account' ] = $new_order; return $menu_ord; } public static function add_to_debug( $data, $plugin, $keys = false ) { if ( self::$debug_mode ) { if ( $keys === false ) { self::$error_log[ $plugin ][] = $data; } elseif ( is_array( $keys ) ) { if ( count( $keys ) > 0 ) { $data_set = self::$error_log[ $plugin ]; $last_key = array_pop( $keys ); foreach ( $keys as $key ) { if ( ! is_array( $data_set[ $key ] ) ) { $data_set[ $key ] = array(); } $new_set = &$data_set[ $key ]; unset( $data_set ); $data_set = &$new_set; unset( $new_set ); } if ( empty( $last_key ) ) { $data_set[] = $data; } else { $data_set[ $last_key ] = $data; } } else { self::$error_log[ $plugin ][] = $data; } } else { self::$error_log[ $plugin ][ $keys ] = $data; } } } public static function berocket_display_additional_notices( $notices ) { if ( ! empty( $_GET[ 'page' ] ) && $_GET[ 'page' ] == 'berocket_account' ) { return $notices; } $plugin_count = get_option('berocket_updater_registered_plugins'); update_option('berocket_updater_registered_plugins', count(self::$plugin_info)); if( count(self::$plugin_info) != $plugin_count ) { $not_activated_notices = false; } else { if ( is_network_admin() ) { $not_activated_notices = get_site_transient( 'berocket_not_activated_notices_site' ); } else { $not_activated_notices = get_transient( 'berocket_not_activated_notices' ); } } if ( $not_activated_notices == false ) { $active_plugin = get_option( 'berocket_key_activated_plugins' ); $active_site_plugin = get_site_option( 'berocket_key_activated_plugins' ); if ( ! is_array( $active_plugin ) ) { $active_plugin = array(); } if ( ! is_array( $active_site_plugin ) ) { $active_site_plugin = array(); } $not_activated_notices = array(); foreach ( self::$plugin_info as $plugin ) { if ( empty( $active_plugin[ $plugin[ 'id' ] ] ) && empty( $active_site_plugin[ $plugin[ 'id' ] ] ) ) { if ( version_compare( $plugin[ 'version' ], '2.0', '>=' ) ) { $not_activated_notices[] = array( 'start' => 0, 'end' => 0, 'name' => $plugin[ 'name' ], 'html' => ''.__('Please', 'BeRocket_domain'). ' ' . __('activate plugin', 'BeRocket_domain') . ' ' . $plugin[ 'name' ] . ' ' . __('with help of Plugin/Account Key from', 'BeRocket_domain') . ' ' . __('BeRocket account', 'BeRocket_domain') . '. ' . __('You can activate plugin in', 'BeRocket_domain') . ' ' . __('BeRocket Account settings', 'BeRocket_domain') . ' ', 'righthtml' => '', 'rightwidth' => 0, 'nothankswidth' => 0, 'contentwidth' => 1600, 'subscribe' => false, 'priority' => 10, 'height' => 70, 'repeat' => false, 'repeatcount' => 1, 'image' => array( 'local' => '', 'width' => 0, 'height' => 0, 'scale' => 1, ) ); } } } if ( is_network_admin() ) { set_site_transient( 'berocket_not_activated_notices_site', $not_activated_notices, 7200 ); } else { set_transient( 'berocket_not_activated_notices', $not_activated_notices, 7200 ); } } $notices = array_merge( $notices, $not_activated_notices ); return $notices; } public static function get_plugin_count() { $count = count( self::$plugin_info ); return $count; } public static function allow_berocket_host( $allow, $host, $url ) { if ( $host == 'berocket.com' ) { $allow = true; } return $allow; } public static function test_key() { if ( ! isset( $_POST[ 'key' ] ) || ! isset( $_POST[ 'id' ] ) ) { $data = array( 'key_exist' => 0, 'status' => 'Failed', 'error' => 'Incorrect query for this function(ID and Key must be sended)' ); $out = json_encode( $data ); } else { $key = sanitize_text_field( $_POST[ 'key' ] ); $id = sanitize_text_field( $_POST[ 'id' ] ); $out = get_transient( 'brupdate_' . $id . '_' . $key ); if ( $out == false ) { $site_url = get_site_url(); $plugins = self::$plugin_info; if ( is_array( $plugins ) ) { $plugins = array_keys( $plugins ); $plugins = implode( ',', $plugins ); } else { $plugins = ''; } $response = wp_remote_post( BeRocket_update_path . 'main/account_updater', array( 'body' => array( 'key' => $key, 'id' => $id, 'url' => $site_url, 'plugins' => $plugins ), 'method' => 'POST', 'timeout' => 30, 'redirection' => 5, 'blocking' => true, 'sslverify' => false ) ); if ( ! is_wp_error( $response ) ) { $out = wp_remote_retrieve_body( $response ); $current_plugin = false; $out = json_decode( $out, true ); if ( ! is_array( $out ) ) { $out = array(); } $out[ 'upgrade' ] = array(); $options = self::get_options(); if ( $id != 0 ) { foreach ( self::$plugin_info as $plugin ) { if ( $plugin[ 'id' ] == $id ) { $current_plugin = $plugin; break; } } if ( $current_plugin !== false ) { if ( empty( $out[ 'error' ] ) ) { $options[ 'plugin_key' ][ $id ] = $key; if ( isset( $out[ 'versions' ][ $id ] ) && version_compare( $current_plugin[ 'version' ], $out[ 'versions' ][ $id ], '<' ) ) { $upgrade_button = 'Upgrade plugin'; $out[ 'plugin_table' ] = '

' . $upgrade_button . '

' . $out[ 'plugin_table' ]; $out[ 'upgrade' ][] = array( 'id' => $id, 'upgrade' => $upgrade_button ); } } } } else { foreach ( self::$plugin_info as $plugin ) { if ( isset( $out[ 'versions' ][ $plugin[ 'id' ] ] ) && version_compare( $plugin[ 'version' ], $out[ 'versions' ][ $plugin[ 'id' ] ], '<' ) ) { $upgrade_button = 'Upgrade plugin'; $out[ 'upgrade' ][] = array( 'id' => $plugin[ 'id' ], 'upgrade' => $upgrade_button ); } } $options[ 'account_key' ] = $key; } self::set_options( $options ); delete_site_transient( 'update_plugins' ); $out = json_encode( $out ); set_transient( 'brupdate_' . $id . '_' . $key, $out, 600 ); } else { $data = array( 'key_exist' => 0, 'status' => 'Failed', 'error' => $response->get_error_message() ); $out = json_encode( $data ); } } self::update_check_set(''); } echo $out; wp_die(); } public static function scripts() { ?>

BeRocket Account Settings

'; echo ''; echo ''; echo ''; echo ''; echo ''; unset( $plugins_key[ $plugin[ 'id' ] ] ); } foreach ( $plugins_key as $key_id => $key_val ) { echo ''; } ?>

DEBUG MODE

Account key

'; if ( isset( $plugin[ 'name' ] ) ) { echo $plugin[ 'name' ]; } else { echo $plugin[ 'slug' ]; } echo '

Errors

Select plugin
array( 'url' => $site_url ), 'method' => 'POST', 'timeout' => 30, 'redirection' => 5, 'blocking' => true, 'sslverify' => false ) ); if ( ! is_wp_error( $response ) ) { $out = wp_remote_retrieve_body( $response ); if ( ! empty( $out ) ) { $out = json_decode( @ $out ); if ( ! empty( $out->status ) && $out->status == 'success' ) { $version = $out->version; } } } set_transient( 'brversion_' . $plugin[ 'id' ] . '_' . $key, $version, 600 ); } } if ( ! is_array( $active_plugin ) ) { $active_plugin = array(); } $responsed = false; if ( $version !== false ) { $active_plugin[ $plugin[ 'id' ] ] = true; if ( version_compare( $plugin[ 'version' ], $version, '<' ) && ! empty($value) ) { $value->checked[ $plugin[ 'plugin' ] ] = $version; $val = array( 'id' => 'br_' . $plugin[ 'id' ], 'new_version' => $version, 'package' => BeRocket_update_path . 'main/update_product/' . $plugin[ 'id' ] . '/' . $key, 'url' => BeRocket_update_path . 'product/' . $plugin[ 'id' ], 'plugin' => $plugin[ 'plugin' ], 'slug' => $plugin[ 'slug' ] ); if( ! empty($plugin['free_slug']) ) { include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); $api = plugins_api( 'plugin_information', array( 'slug' => wp_unslash( $plugin['free_slug'] ), 'is_ssl' => is_ssl(), 'fields' => array( 'banners' => true, 'reviews' => false, 'downloaded' => false, 'active_installs' => true, 'icons' => true ) ) ); $api = (array)$api; $val = array_merge($api, $val); } $val = (object)$val; $value->response[ $plugin[ 'plugin' ] ] = $val; $responsed = true; } } else { $active_plugin[ $plugin[ 'id' ] ] = false; } if( ! $responsed && isset($plugin[ 'version_capability' ]) && $plugin[ 'version_capability' ] >= 10 ) { $val = (object) array( 'id' => 'br_' . $plugin[ 'id' ], 'new_version' => $plugin[ 'version' ], 'package' => BeRocket_update_path . 'main/update_product/' . $plugin[ 'id' ] . '/' . ( empty($key) ? 'none' : $key ), 'url' => BeRocket_update_path . 'product/' . $plugin[ 'id' ], 'plugin' => $plugin[ 'plugin' ], 'slug' => $plugin[ 'slug' ] ); $no_update_paid[$plugin[ 'plugin' ]] = $val; } } if ( is_network_admin() ) { update_site_option( 'berocket_key_activated_plugins', $active_plugin ); } else { update_option( 'berocket_key_activated_plugins', $active_plugin ); } delete_site_transient( 'berocket_not_activated_notices_site' ); delete_transient( 'berocket_not_activated_notices' ); if ( is_multisite() ) { global $wpdb; $current_site = get_current_site(); $all_sites = get_sites(array('fields' => 'ids')); if( is_array($all_sites) ) { foreach($all_sites as $site_id) { switch_to_blog($site_id); delete_site_transient( 'berocket_not_activated_notices_site' ); delete_transient( 'berocket_not_activated_notices' ); restore_current_blog(); } } } if ( ! empty($value) && isset( $value->no_update ) && is_array( $value->no_update ) ) { $value->no_update = array_merge($value->no_update, $no_update_paid); foreach ( $value->no_update as $key => $val ) { if ( isset( $val->slug ) && in_array( $val->slug, self::$slugs ) ) { if( ! array_key_exists($key, $no_update_paid) ) { unset( $value->no_update[ $key ] ); } } } } return $value; } public static function plugin_info() { $plugin = wp_unslash( $_REQUEST[ 'plugin' ] ); if ( in_array( $plugin, self::$slugs ) ) { remove_action( 'install_plugins_pre_plugin-information', 'install_plugin_information' ); $plugin_id = array_search( $plugin, self::$slugs ); $plugin_info = get_transient( 'brplugin_info_' . $plugin_id ); if ( $plugin_info == false ) { $url = BeRocket_update_path . 'main/update_info/' . $plugin_id; $site_url = get_site_url(); $response = wp_remote_post( $url, array( 'body' => array( 'url' => $site_url ), 'method' => 'POST', 'timeout' => 30, 'redirection' => 5, 'blocking' => true, 'sslverify' => false ) ); if ( ! is_wp_error( $response ) ) { $plugin_info = wp_remote_retrieve_body( $response ); set_transient( 'brplugin_info_' . $plugin_id, $plugin_info, 600 ); } } echo $plugin_info; die; } } public static function get_options() { if ( ! function_exists( 'is_plugin_active_for_network' ) ) { require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); } if ( is_multisite() && is_plugin_active_for_network( plugin_basename( __FILE__ ) ) ) { $options = get_site_option( 'BeRocket_account_option' ); } else { $options = get_option( 'BeRocket_account_option' ); } return $options; } public static function set_options( $options ) { if ( ! function_exists( 'is_plugin_active_for_network' ) ) { require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); } if ( is_multisite() && is_plugin_active_for_network( plugin_basename( __FILE__ ) ) ) { update_site_option( 'BeRocket_account_option', $options ); } else { update_option( 'BeRocket_account_option', $options ); } self::update_check_set(''); } public static function admin_notice_is_display_notice($display_notice, $item, $search_data) { if( ! empty($item['for_plugin']) && is_array($item['for_plugin']) && ! empty($item['for_plugin']['id']) && ! empty($item['for_plugin']['version']) ) { $has_free = false; foreach ( self::$plugin_info as $plugin ) { if( version_compare($plugin[ 'version' ], '2.0', '<') ) { $has_free = true; } if ( $plugin[ 'id' ] == $item['for_plugin']['id'] && version_compare($plugin[ 'version' ], $item['for_plugin']['version'], '>=') ) { $display_notice = false; break; } } if( ! $has_free && ! empty($item['for_plugin']['onlyfree']) ) { $display_notice = false; } } return $display_notice; } } BeRocket_updater::init(); add_action( 'plugins_loaded', array( 'BeRocket_updater', 'run' ), 999 ); }